| 1 | /* |
|---|
| 2 | ----------------------------------------------------------------------------- |
|---|
| 3 | This source file is part of LEXIExporter |
|---|
| 4 | |
|---|
| 5 | Copyright 2006 NDS Limited |
|---|
| 6 | |
|---|
| 7 | Author(s): |
|---|
| 8 | Lasse Tassing |
|---|
| 9 | |
|---|
| 10 | This program is free software; you can redistribute it and/or modify it under |
|---|
| 11 | the terms of the GNU Lesser General Public License as published by the Free Software |
|---|
| 12 | Foundation; either version 2 of the License, or (at your option) any later |
|---|
| 13 | version. |
|---|
| 14 | |
|---|
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT |
|---|
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|---|
| 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
|---|
| 18 | |
|---|
| 19 | You should have received a copy of the GNU Lesser General Public License along with |
|---|
| 20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
|---|
| 21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to |
|---|
| 22 | http://www.gnu.org/copyleft/lesser.txt. |
|---|
| 23 | ----------------------------------------------------------------------------- |
|---|
| 24 | */ |
|---|
| 25 | |
|---|
| 26 | #include "LexiStdAfx.h" |
|---|
| 27 | #include "LexiMaxExport.h" |
|---|
| 28 | #include "LexiDialogViewLog.h" |
|---|
| 29 | #include "LexiExportObject.h" |
|---|
| 30 | |
|---|
| 31 | #include "..\Res\resource.h" |
|---|
| 32 | |
|---|
| 33 | // |
|---|
| 34 | CExportViewLogDlg::CExportViewLogDlg(Window* pParent, CMemoryLog *pLog) : Dialog(IDD_DIALOG_LOGVIEW, DlgProc, pParent) |
|---|
| 35 | { |
|---|
| 36 | m_pLog=pLog; |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | CExportViewLogDlg::~CExportViewLogDlg() |
|---|
| 40 | { |
|---|
| 41 | |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | // |
|---|
| 45 | INT_PTR CALLBACK CExportViewLogDlg::DlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) |
|---|
| 46 | { |
|---|
| 47 | CExportViewLogDlg* pThis = (CExportViewLogDlg*)Window::GetMapping(hWnd); |
|---|
| 48 | |
|---|
| 49 | switch(message) |
|---|
| 50 | { |
|---|
| 51 | case WM_INITDIALOG: |
|---|
| 52 | { |
|---|
| 53 | pThis = (CExportViewLogDlg*)lParam; |
|---|
| 54 | Window::AddMapping(pThis, hWnd); |
|---|
| 55 | |
|---|
| 56 | pThis->OnInitDialog(); |
|---|
| 57 | |
|---|
| 58 | } return 0; |
|---|
| 59 | |
|---|
| 60 | case WM_COMMAND: |
|---|
| 61 | { |
|---|
| 62 | switch(LOWORD(wParam)) |
|---|
| 63 | { |
|---|
| 64 | case IDOK: |
|---|
| 65 | pThis->EndDialog(IDOK); |
|---|
| 66 | break; |
|---|
| 67 | case IDCANCEL: |
|---|
| 68 | case IDC_CLOSE: |
|---|
| 69 | pThis->EndDialog(IDCANCEL); |
|---|
| 70 | break; |
|---|
| 71 | case IDC_SHOWDEBUG: |
|---|
| 72 | pThis->OnShowDebug(); |
|---|
| 73 | break; |
|---|
| 74 | case IDC_SHOWOGRE: |
|---|
| 75 | pThis->OnShowOGRE(); |
|---|
| 76 | break; |
|---|
| 77 | } |
|---|
| 78 | } break; |
|---|
| 79 | |
|---|
| 80 | case WM_CLOSE: |
|---|
| 81 | { |
|---|
| 82 | pThis->EndDialog(IDCANCEL); |
|---|
| 83 | // Allow user to abort progress? |
|---|
| 84 | } break; |
|---|
| 85 | |
|---|
| 86 | case WM_SIZE: |
|---|
| 87 | { |
|---|
| 88 | pThis->OnSize(); |
|---|
| 89 | } break; |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | return 0; |
|---|
| 93 | } |
|---|
| 94 | |
|---|
| 95 | // |
|---|
| 96 | |
|---|
| 97 | void CExportViewLogDlg::OnInitDialog() |
|---|
| 98 | { |
|---|
| 99 | Bind(IDC_LOGTREE, m_LogTree); |
|---|
| 100 | Bind(IDC_SHOWDEBUG, m_ShowDebug); |
|---|
| 101 | Bind(IDC_SHOWOGRE, m_ShowOGRE); |
|---|
| 102 | |
|---|
| 103 | // |
|---|
| 104 | GetClientRect(m_OrgClientRect); |
|---|
| 105 | |
|---|
| 106 | CDDObject *pGlobalSettings=CExporter::Get()->GetGlobalSettings(); |
|---|
| 107 | m_bShowDebug=pGlobalSettings->GetBool("ShowDebug", false); |
|---|
| 108 | m_ShowDebug.SetCheck(m_bShowDebug); |
|---|
| 109 | m_bShowOGRE=pGlobalSettings->GetBool("ShowOGRE", false); |
|---|
| 110 | m_ShowOGRE.SetCheck(m_bShowOGRE); |
|---|
| 111 | |
|---|
| 112 | HIMAGELIST hIcons=ImageList_Create(16, 16, ILC_COLOR32, 4, 1); |
|---|
| 113 | HANDLE hIcon=::LoadImage(CExporter::m_hInstance, MAKEINTRESOURCE(IDI_ICON_LOGDEBUG), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR|LR_SHARED); |
|---|
| 114 | ::ImageList_ReplaceIcon(hIcons, -1, (HICON)hIcon); |
|---|
| 115 | hIcon=::LoadImage(CExporter::m_hInstance, MAKEINTRESOURCE(IDI_ICON_LOGINFO), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR|LR_SHARED); |
|---|
| 116 | ::ImageList_ReplaceIcon(hIcons, -1, (HICON)hIcon); |
|---|
| 117 | hIcon=::LoadImage(CExporter::m_hInstance, MAKEINTRESOURCE(IDI_ICON_LOGWARNING), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR|LR_SHARED); |
|---|
| 118 | ::ImageList_ReplaceIcon(hIcons, -1, (HICON)hIcon); |
|---|
| 119 | hIcon=::LoadImage(CExporter::m_hInstance, MAKEINTRESOURCE(IDI_ICON_LOGERROR), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR|LR_SHARED); |
|---|
| 120 | ::ImageList_ReplaceIcon(hIcons, -1, (HICON)hIcon); |
|---|
| 121 | hIcon=::LoadImage(CExporter::m_hInstance, MAKEINTRESOURCE(IDI_ICON_LOGOGRE), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR|LR_SHARED); |
|---|
| 122 | ::ImageList_ReplaceIcon(hIcons, -1, (HICON)hIcon); |
|---|
| 123 | m_LogTree.SetImageList(hIcons, TVSIL_NORMAL); |
|---|
| 124 | |
|---|
| 125 | CenterWindow(); |
|---|
| 126 | Repopulate(); |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| 129 | // |
|---|
| 130 | void CExportViewLogDlg::OnSize() |
|---|
| 131 | { |
|---|
| 132 | // Check if have initialized dialog |
|---|
| 133 | if(m_OrgClientRect.right==0) return; |
|---|
| 134 | |
|---|
| 135 | RECT rNewMain; |
|---|
| 136 | GetClientRect(rNewMain); |
|---|
| 137 | int iDeltaY=rNewMain.bottom-m_OrgClientRect.bottom; |
|---|
| 138 | int iDeltaX=rNewMain.right-m_OrgClientRect.right; |
|---|
| 139 | |
|---|
| 140 | // Begin resize/move of all the controls |
|---|
| 141 | HDWP hdwp=::BeginDeferWindowPos(20); |
|---|
| 142 | RECT rTemp; |
|---|
| 143 | |
|---|
| 144 | // Resize tree output |
|---|
| 145 | m_LogTree.GetWindowRect(rTemp); |
|---|
| 146 | hdwp=::DeferWindowPos(hdwp, m_LogTree.m_hWnd, NULL, 0, 0, (rTemp.right-rTemp.left)+iDeltaX, (rTemp.bottom-rTemp.top)+iDeltaY, SWP_NOZORDER|SWP_NOMOVE); |
|---|
| 147 | |
|---|
| 148 | // Move debug button |
|---|
| 149 | m_ShowDebug.GetWindowRect(rTemp); |
|---|
| 150 | ScreenToClient(rTemp); |
|---|
| 151 | hdwp=::DeferWindowPos(hdwp, m_ShowDebug.m_hWnd, NULL, rTemp.left, rTemp.top+iDeltaY, 0, 0, SWP_NOZORDER|SWP_NOSIZE); |
|---|
| 152 | |
|---|
| 153 | // Move OGRE button |
|---|
| 154 | m_ShowOGRE.GetWindowRect(rTemp); |
|---|
| 155 | ScreenToClient(rTemp); |
|---|
| 156 | hdwp=::DeferWindowPos(hdwp, m_ShowOGRE.m_hWnd, NULL, rTemp.left, rTemp.top+iDeltaY, 0, 0, SWP_NOZORDER|SWP_NOSIZE); |
|---|
| 157 | |
|---|
| 158 | /* // Move auto-close button |
|---|
| 159 | m_AutoClose.GetWindowRect(rTemp); |
|---|
| 160 | ScreenToClient(rTemp); |
|---|
| 161 | hdwp=::DeferWindowPos(hdwp, m_AutoClose.m_hWnd, NULL, rTemp.left, rTemp.top+iDeltaY, 0, 0, SWP_NOZORDER|SWP_NOSIZE);*/ |
|---|
| 162 | |
|---|
| 163 | // Move close button |
|---|
| 164 | GetDlgItem(IDC_CLOSE)->GetWindowRect(rTemp); |
|---|
| 165 | ScreenToClient(rTemp); |
|---|
| 166 | hdwp=::DeferWindowPos(hdwp, GetDlgItem(IDC_CLOSE)->m_hWnd, NULL, rTemp.left+iDeltaX, rTemp.top+iDeltaY, 0, 0, SWP_NOZORDER|SWP_NOSIZE); |
|---|
| 167 | |
|---|
| 168 | ::EndDeferWindowPos(hdwp); |
|---|
| 169 | memcpy(&m_OrgClientRect, &rNewMain, sizeof(RECT)); |
|---|
| 170 | } |
|---|
| 171 | |
|---|
| 172 | void CExportViewLogDlg::OnShowDebug(void) |
|---|
| 173 | { |
|---|
| 174 | m_bShowDebug=m_ShowDebug.GetCheck()!=0; |
|---|
| 175 | CExporter::Get()->GetGlobalSettings()->SetBool("ShowDebug", m_bShowDebug); |
|---|
| 176 | Repopulate(); |
|---|
| 177 | } |
|---|
| 178 | void CExportViewLogDlg::OnShowOGRE(void) |
|---|
| 179 | { |
|---|
| 180 | m_bShowOGRE=m_ShowOGRE.GetCheck()!=0; |
|---|
| 181 | CExporter::Get()->GetGlobalSettings()->SetBool("ShowOGRE", m_bShowOGRE); |
|---|
| 182 | Repopulate(); |
|---|
| 183 | } |
|---|
| 184 | |
|---|
| 185 | void CExportViewLogDlg::Repopulate(void) |
|---|
| 186 | { |
|---|
| 187 | m_LogTree.DeleteAllItems(); |
|---|
| 188 | |
|---|
| 189 | for(int i=0;i<m_pLog->m_lMessages.size();i++) |
|---|
| 190 | { |
|---|
| 191 | AddMessage(m_pLog->m_lMessages[i]); |
|---|
| 192 | } |
|---|
| 193 | } |
|---|
| 194 | |
|---|
| 195 | void CExportViewLogDlg::AddMessage(CMemoryLog::SMessage *pMessage) |
|---|
| 196 | { |
|---|
| 197 | if(!m_bShowDebug && pMessage->iLevel==0) return; |
|---|
| 198 | if(pMessage->iLevel==4 && !m_bShowOGRE) return; |
|---|
| 199 | |
|---|
| 200 | TVINSERTSTRUCT tInsert; |
|---|
| 201 | tInsert.hParent=TVI_ROOT; |
|---|
| 202 | tInsert.hInsertAfter=TVI_LAST; |
|---|
| 203 | tInsert.item.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE; |
|---|
| 204 | tInsert.item.pszText=(char*)pMessage->sMessage.c_str(); |
|---|
| 205 | tInsert.item.iImage=pMessage->iLevel; |
|---|
| 206 | tInsert.item.iSelectedImage=pMessage->iLevel; |
|---|
| 207 | m_LogTree.InsertItem(&tInsert); |
|---|
| 208 | } |
|---|
| 209 | |
|---|
| 210 | |
|---|
| 211 | |
|---|
| 212 | // |
|---|
| 213 | |
|---|