2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
26 ===========================================================================
29 #include "../../idlib/precompiled.h"
32 #include "../../sys/win32/rc/debugger_resource.h"
33 #include "DebuggerApp.h"
34 #include "DebuggerQuickWatchDlg.h"
38 rvDebuggerQuickWatchDlg::rvDebuggerQuickWatchDlg
41 rvDebuggerQuickWatchDlg::rvDebuggerQuickWatchDlg ( void )
47 rvDebuggerQuickWatchDlg::DoModal
52 bool rvDebuggerQuickWatchDlg::DoModal ( rvDebuggerWindow* window, int callstackDepth, const char* variable )
54 mCallstackDepth = callstackDepth;
55 mDebuggerWindow = window;
56 mVariable = variable?variable:"";
58 DialogBoxParam ( window->GetInstance(), MAKEINTRESOURCE(IDD_DBG_QUICKWATCH), window->GetWindow(), DlgProc, (LONG)this );
65 rvDebuggerQuickWatchDlg::DlgProc
67 Dialog Procedure for the quick watch dialog
70 INT_PTR CALLBACK rvDebuggerQuickWatchDlg::DlgProc ( HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam )
72 rvDebuggerQuickWatchDlg* dlg = (rvDebuggerQuickWatchDlg*) GetWindowLong ( wnd, GWL_USERDATA );
76 case WM_GETMINMAXINFO:
78 MINMAXINFO* mmi = (MINMAXINFO*)lparam;
79 mmi->ptMinTrackSize.x = 300;
80 mmi->ptMinTrackSize.y = 200;
85 gDebuggerApp.GetOptions().SetWindowPlacement ( "wp_quickwatch", wnd );
86 gDebuggerApp.GetOptions().SetColumnWidths ( "cw_quickwatch", GetDlgItem ( wnd, IDC_DBG_CURVALUE ) );
95 GetClientRect ( wnd, &client );
96 GetWindowRect ( GetDlgItem ( wnd, IDC_DBG_RECALC ), &button );
97 ScreenToClient ( wnd, (POINT*)&button );
98 ScreenToClient ( wnd, (POINT*)&button.right );
99 MoveWindow ( GetDlgItem ( wnd, IDC_DBG_RECALC ), client.right - dlg->mButtonFromRight, button.top, button.right-button.left,button.bottom-button.top, TRUE );
101 GetWindowRect ( GetDlgItem ( wnd, IDC_DBG_CLOSE ), &button );
102 ScreenToClient ( wnd, (POINT*)&button );
103 ScreenToClient ( wnd, (POINT*)&button.right );
104 MoveWindow ( GetDlgItem ( wnd, IDC_DBG_CLOSE ), client.right - dlg->mButtonFromRight, button.top, button.right-button.left,button.bottom-button.top, TRUE );
106 GetWindowRect ( GetDlgItem ( wnd, IDC_DBG_ADDWATCH ), &button );
107 ScreenToClient ( wnd, (POINT*)&button );
108 ScreenToClient ( wnd, (POINT*)&button.right );
109 MoveWindow ( GetDlgItem ( wnd, IDC_DBG_ADDWATCH ), client.right - dlg->mButtonFromRight, button.top, button.right-button.left,button.bottom-button.top, TRUE );
111 GetWindowRect ( GetDlgItem ( wnd, IDC_DBG_VARIABLE ), &button );
112 ScreenToClient ( wnd, (POINT*)&button );
113 ScreenToClient ( wnd, (POINT*)&button.right );
114 MoveWindow ( GetDlgItem ( wnd, IDC_DBG_VARIABLE ), button.left, button.top, client.right-button.left-dlg->mEditFromRight, button.bottom-button.top, TRUE );
116 GetWindowRect ( GetDlgItem ( wnd, IDC_DBG_CURVALUE ), &button );
117 ScreenToClient ( wnd, (POINT*)&button );
118 ScreenToClient ( wnd, (POINT*)&button.right );
119 MoveWindow ( GetDlgItem ( wnd, IDC_DBG_CURVALUE ), button.left, button.top, client.right-button.left-dlg->mEditFromRight, client.bottom-button.top - dlg->mEditFromBottom, TRUE );
129 // Attach the dialog class pointer to the window
130 dlg = (rvDebuggerQuickWatchDlg*) lparam;
131 SetWindowLong ( wnd, GWL_USERDATA, lparam );
134 GetClientRect ( wnd, &client );
136 GetWindowRect ( GetDlgItem ( wnd, IDC_DBG_RECALC ), &button );
137 ScreenToClient ( wnd, (POINT*)&button );
138 dlg->mButtonFromRight = client.right - button.left;
140 GetWindowRect ( GetDlgItem ( wnd, IDC_DBG_CURVALUE ), &button );
141 ScreenToClient ( wnd, (POINT*)&button.right );
142 dlg->mEditFromRight = client.right - button.right;
143 dlg->mEditFromBottom = client.bottom - button.bottom;
145 // Disable the value controls until a variable is entered
146 EnableWindow ( GetDlgItem ( wnd, IDC_DBG_ADDWATCH ), false );
147 EnableWindow ( GetDlgItem ( wnd, IDC_DBG_RECALC ), false );
148 EnableWindow ( GetDlgItem ( wnd, IDC_DBG_CURVALUE ), false );
149 EnableWindow ( GetDlgItem ( wnd, IDC_DBG_CURVALUE_STATIC ), false );
151 // Add the columns to the list control
153 col.mask = LVCF_WIDTH|LVCF_TEXT;
155 col.pszText = "Name";
156 ListView_InsertColumn ( GetDlgItem ( wnd, IDC_DBG_CURVALUE ), 0, &col );
158 col.pszText = "Value";
159 ListView_InsertColumn ( GetDlgItem ( wnd, IDC_DBG_CURVALUE ), 1, &col );
161 // Set the initial variable if one was given
162 if ( dlg->mVariable.Length() )
164 dlg->SetVariable ( dlg->mVariable, true );
165 SetWindowText( GetDlgItem ( wnd, IDC_DBG_VARIABLE ), dlg->mVariable );
168 gDebuggerApp.GetOptions().GetWindowPlacement ( "wp_quickwatch", wnd );
169 gDebuggerApp.GetOptions().GetColumnWidths ( "cw_quickwatch", GetDlgItem ( wnd, IDC_DBG_CURVALUE ) );
175 switch ( LOWORD(wparam) )
178 SendMessage ( wnd, WM_CLOSE, 0, 0 );
181 case IDC_DBG_VARIABLE:
182 // When the variable text changes to something other than empty
183 // we can enable the addwatch and recalc buttons
184 if ( HIWORD(wparam) == EN_CHANGE )
186 bool enable = GetWindowTextLength ( GetDlgItem ( wnd, IDC_DBG_VARIABLE ) )?true:false;
187 EnableWindow ( GetDlgItem ( wnd, IDC_DBG_ADDWATCH ), enable );
188 EnableWindow ( GetDlgItem ( wnd, IDC_DBG_RECALC ), enable );
192 case IDC_DBG_ADDWATCH:
195 GetWindowText ( GetDlgItem ( wnd, IDC_DBG_VARIABLE ), varname, 1023 );
196 dlg->mDebuggerWindow->AddWatch ( varname );
203 GetWindowText ( GetDlgItem ( wnd, IDC_DBG_VARIABLE ), varname, 1023 );
204 dlg->SetVariable ( varname );
216 rvDebuggerQuickWatchDlg::SetVariable
218 Sets the current variable being inspected
221 void rvDebuggerQuickWatchDlg::SetVariable ( const char* varname, bool force )
223 // See if the variable has changed
224 if ( !force && !mVariable.Icmp ( varname ) )
229 // Throw up a wait cursor
230 SetCursor ( LoadCursor ( NULL, IDC_WAIT ) );
232 // Clear the current value list control
233 ListView_DeleteAllItems ( GetDlgItem ( mWnd, IDC_DBG_CURVALUE ) );
235 // Get the value of the new variable
236 gDebuggerApp.GetClient().InspectVariable ( varname, mCallstackDepth );
238 // Wait for the variable value to be sent over from the debugger server
239 if ( !gDebuggerApp.GetClient().WaitFor ( DBMSG_INSPECTVARIABLE, 2500 ) )
244 // Make sure we got the value of the variable
245 if ( !gDebuggerApp.GetClient().GetVariableValue(varname, mCallstackDepth)[0] )
250 // Enable the windows that display the current value
252 EnableWindow ( GetDlgItem ( mWnd, IDC_DBG_CURVALUE ), true );
253 EnableWindow ( GetDlgItem ( mWnd, IDC_DBG_CURVALUE_STATIC ), true );
255 // Add the variablae value to the list control
257 item.mask = LVIF_TEXT;
258 item.pszText = (LPSTR)varname;
261 ListView_InsertItem ( GetDlgItem ( mWnd, IDC_DBG_CURVALUE ), &item );
262 ListView_SetItemText ( GetDlgItem ( mWnd, IDC_DBG_CURVALUE ), 0, 1, (LPSTR)gDebuggerApp.GetClient().GetVariableValue(varname,mCallstackDepth) );
264 // Give focus back to the variable edit control and set the cursor back to an arrow
265 SetFocus ( GetDlgItem ( mWnd, IDC_DBG_VARIABLE ) );
266 SetCursor ( LoadCursor ( NULL, IDC_ARROW ) );