123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- #include "../../idlib/precompiled.h"
- #pragma hdrstop
- #include "../../sys/win32/rc/debugger_resource.h"
- #include "DebuggerApp.h"
- #include "DebuggerQuickWatchDlg.h"
- rvDebuggerQuickWatchDlg::rvDebuggerQuickWatchDlg ( void )
- {
- }
- bool rvDebuggerQuickWatchDlg::DoModal ( rvDebuggerWindow* window, int callstackDepth, const char* variable )
- {
- mCallstackDepth = callstackDepth;
- mDebuggerWindow = window;
- mVariable = variable?variable:"";
-
- DialogBoxParam ( window->GetInstance(), MAKEINTRESOURCE(IDD_DBG_QUICKWATCH), window->GetWindow(), DlgProc, (LONG)this );
- return true;
- }
- INT_PTR CALLBACK rvDebuggerQuickWatchDlg::DlgProc ( HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam )
- {
- rvDebuggerQuickWatchDlg* dlg = (rvDebuggerQuickWatchDlg*) GetWindowLong ( wnd, GWL_USERDATA );
-
- switch ( msg )
- {
- case WM_GETMINMAXINFO:
- {
- MINMAXINFO* mmi = (MINMAXINFO*)lparam;
- mmi->ptMinTrackSize.x = 300;
- mmi->ptMinTrackSize.y = 200;
- break;
- }
-
- case WM_CLOSE:
- gDebuggerApp.GetOptions().SetWindowPlacement ( "wp_quickwatch", wnd );
- gDebuggerApp.GetOptions().SetColumnWidths ( "cw_quickwatch", GetDlgItem ( wnd, IDC_DBG_CURVALUE ) );
- EndDialog ( wnd, 0 );
- break;
-
- case WM_SIZE:
- {
- RECT client;
- RECT button;
-
- GetClientRect ( wnd, &client );
- GetWindowRect ( GetDlgItem ( wnd, IDC_DBG_RECALC ), &button );
- ScreenToClient ( wnd, (POINT*)&button );
- ScreenToClient ( wnd, (POINT*)&button.right );
- MoveWindow ( GetDlgItem ( wnd, IDC_DBG_RECALC ), client.right - dlg->mButtonFromRight, button.top, button.right-button.left,button.bottom-button.top, TRUE );
- GetWindowRect ( GetDlgItem ( wnd, IDC_DBG_CLOSE ), &button );
- ScreenToClient ( wnd, (POINT*)&button );
- ScreenToClient ( wnd, (POINT*)&button.right );
- MoveWindow ( GetDlgItem ( wnd, IDC_DBG_CLOSE ), client.right - dlg->mButtonFromRight, button.top, button.right-button.left,button.bottom-button.top, TRUE );
- GetWindowRect ( GetDlgItem ( wnd, IDC_DBG_ADDWATCH ), &button );
- ScreenToClient ( wnd, (POINT*)&button );
- ScreenToClient ( wnd, (POINT*)&button.right );
- MoveWindow ( GetDlgItem ( wnd, IDC_DBG_ADDWATCH ), client.right - dlg->mButtonFromRight, button.top, button.right-button.left,button.bottom-button.top, TRUE );
- GetWindowRect ( GetDlgItem ( wnd, IDC_DBG_VARIABLE ), &button );
- ScreenToClient ( wnd, (POINT*)&button );
- ScreenToClient ( wnd, (POINT*)&button.right );
- MoveWindow ( GetDlgItem ( wnd, IDC_DBG_VARIABLE ), button.left, button.top, client.right-button.left-dlg->mEditFromRight, button.bottom-button.top, TRUE );
- GetWindowRect ( GetDlgItem ( wnd, IDC_DBG_CURVALUE ), &button );
- ScreenToClient ( wnd, (POINT*)&button );
- ScreenToClient ( wnd, (POINT*)&button.right );
- MoveWindow ( GetDlgItem ( wnd, IDC_DBG_CURVALUE ), button.left, button.top, client.right-button.left-dlg->mEditFromRight, client.bottom-button.top - dlg->mEditFromBottom, TRUE );
-
- break;
- }
-
- case WM_INITDIALOG:
- {
- RECT client;
- RECT button;
-
- dlg = (rvDebuggerQuickWatchDlg*) lparam;
- SetWindowLong ( wnd, GWL_USERDATA, lparam );
- dlg->mWnd = wnd;
-
- GetClientRect ( wnd, &client );
- GetWindowRect ( GetDlgItem ( wnd, IDC_DBG_RECALC ), &button );
- ScreenToClient ( wnd, (POINT*)&button );
- dlg->mButtonFromRight = client.right - button.left;
- GetWindowRect ( GetDlgItem ( wnd, IDC_DBG_CURVALUE ), &button );
- ScreenToClient ( wnd, (POINT*)&button.right );
- dlg->mEditFromRight = client.right - button.right;
- dlg->mEditFromBottom = client.bottom - button.bottom;
-
-
- EnableWindow ( GetDlgItem ( wnd, IDC_DBG_ADDWATCH ), false );
- EnableWindow ( GetDlgItem ( wnd, IDC_DBG_RECALC ), false );
- EnableWindow ( GetDlgItem ( wnd, IDC_DBG_CURVALUE ), false );
- EnableWindow ( GetDlgItem ( wnd, IDC_DBG_CURVALUE_STATIC ), false );
-
- LVCOLUMN col;
- col.mask = LVCF_WIDTH|LVCF_TEXT;
- col.cx = 100;
- col.pszText = "Name";
- ListView_InsertColumn ( GetDlgItem ( wnd, IDC_DBG_CURVALUE ), 0, &col );
- col.cx = 150;
- col.pszText = "Value";
- ListView_InsertColumn ( GetDlgItem ( wnd, IDC_DBG_CURVALUE ), 1, &col );
-
-
- if ( dlg->mVariable.Length() )
- {
- dlg->SetVariable ( dlg->mVariable, true );
- SetWindowText( GetDlgItem ( wnd, IDC_DBG_VARIABLE ), dlg->mVariable );
- }
- gDebuggerApp.GetOptions().GetWindowPlacement ( "wp_quickwatch", wnd );
- gDebuggerApp.GetOptions().GetColumnWidths ( "cw_quickwatch", GetDlgItem ( wnd, IDC_DBG_CURVALUE ) );
-
- return TRUE;
- }
-
- case WM_COMMAND:
- switch ( LOWORD(wparam) )
- {
- case IDC_DBG_CLOSE:
- SendMessage ( wnd, WM_CLOSE, 0, 0 );
- break;
-
- case IDC_DBG_VARIABLE:
-
-
- if ( HIWORD(wparam) == EN_CHANGE )
- {
- bool enable = GetWindowTextLength ( GetDlgItem ( wnd, IDC_DBG_VARIABLE ) )?true:false;
- EnableWindow ( GetDlgItem ( wnd, IDC_DBG_ADDWATCH ), enable );
- EnableWindow ( GetDlgItem ( wnd, IDC_DBG_RECALC ), enable );
- }
- break;
- case IDC_DBG_ADDWATCH:
- {
- char varname[1024];
- GetWindowText ( GetDlgItem ( wnd, IDC_DBG_VARIABLE ), varname, 1023 );
- dlg->mDebuggerWindow->AddWatch ( varname );
- break;
- }
-
- case IDC_DBG_RECALC:
- {
- char varname[1024];
- GetWindowText ( GetDlgItem ( wnd, IDC_DBG_VARIABLE ), varname, 1023 );
- dlg->SetVariable ( varname );
- break;
- }
- }
- break;
- }
-
- return FALSE;
- }
- void rvDebuggerQuickWatchDlg::SetVariable ( const char* varname, bool force )
- {
-
- if ( !force && !mVariable.Icmp ( varname ) )
- {
- return;
- }
-
- SetCursor ( LoadCursor ( NULL, IDC_WAIT ) );
-
- ListView_DeleteAllItems ( GetDlgItem ( mWnd, IDC_DBG_CURVALUE ) );
-
- gDebuggerApp.GetClient().InspectVariable ( varname, mCallstackDepth );
-
- if ( !gDebuggerApp.GetClient().WaitFor ( DBMSG_INSPECTVARIABLE, 2500 ) )
- {
- return;
- }
-
-
- if ( !gDebuggerApp.GetClient().GetVariableValue(varname, mCallstackDepth)[0] )
- {
- return;
- }
-
- mVariable = varname;
- EnableWindow ( GetDlgItem ( mWnd, IDC_DBG_CURVALUE ), true );
- EnableWindow ( GetDlgItem ( mWnd, IDC_DBG_CURVALUE_STATIC ), true );
-
-
- LVITEM item;
- item.mask = LVIF_TEXT;
- item.pszText = (LPSTR)varname;
- item.iItem = 0;
- item.iSubItem = 0;
- ListView_InsertItem ( GetDlgItem ( mWnd, IDC_DBG_CURVALUE ), &item );
- ListView_SetItemText ( GetDlgItem ( mWnd, IDC_DBG_CURVALUE ), 0, 1, (LPSTR)gDebuggerApp.GetClient().GetVariableValue(varname,mCallstackDepth) );
-
- SetFocus ( GetDlgItem ( mWnd, IDC_DBG_VARIABLE ) );
- SetCursor ( LoadCursor ( NULL, IDC_ARROW ) );
- }
|