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/DeclEditor_resource.h"
33 #include "../../sys/win32/rc/ScriptEditor_resource.h"
35 #include "../comafx/CPathTreeCtrl.h"
36 #include "../script/DialogScriptEditor.h"
37 #include "DialogDeclBrowser.h"
38 #include "DialogDeclEditor.h"
39 #include "DialogDeclNew.h"
41 #ifdef ID_DEBUG_MEMORY
47 const int DECLTYPE_SHIFT = 24;
48 const int DECLINDEX_MASK = ( 1 << DECLTYPE_SHIFT ) - 1;
49 const int DECLTYPE_SCRIPT = 126;
50 const int DECLTYPE_GUI = 127;
52 #define GetIdFromTypeAndIndex( type, index ) ( ( (int)type << DECLTYPE_SHIFT ) | index )
53 #define GetTypeFromId( id ) ( (declType_t) ( (int)id >> DECLTYPE_SHIFT ) )
54 #define GetIndexFromId( id ) ( (int)id & DECLINDEX_MASK )
56 toolTip_t DialogDeclBrowser::toolTips[] = {
57 { IDC_DECLBROWSER_TREE, "decl browser" },
58 { IDC_DECLBROWSER_EDIT_SEARCH_NAMES, "search for declarations with matching name, use meta characters: *, ? and [abc...]" },
59 { IDC_DECLBROWSER_EDIT_SEARCH_TEXT, "search for declarations containing text" },
60 { IDC_DECLBROWSER_BUTTON_FIND, "find declarations matching the search strings" },
61 { IDC_DECLBROWSER_BUTTON_EDIT, "edit selected declaration" },
62 { IDC_DECLBROWSER_BUTTON_NEW, "create new declaration" },
63 { IDC_DECLBROWSER_BUTTON_RELOAD, "reload declarations" },
65 { IDCANCEL, "cancel" },
70 static DialogDeclBrowser *g_DeclDialog = NULL;
73 IMPLEMENT_DYNAMIC(DialogDeclBrowser, CDialog)
77 DialogDeclBrowser::DialogDeclBrowser
80 DialogDeclBrowser::DialogDeclBrowser( CWnd* pParent /*=NULL*/ )
81 : CDialog(DialogDeclBrowser::IDD, pParent)
89 DialogDeclBrowser::~DialogDeclBrowser
92 DialogDeclBrowser::~DialogDeclBrowser() {
99 DialogDeclBrowser::DoDataExchange
102 void DialogDeclBrowser::DoDataExchange(CDataExchange* pDX) {
103 CDialog::DoDataExchange(pDX);
104 //{{AFX_DATA_MAP(DialogDeclBrowser)
105 DDX_Control(pDX, IDC_DECLBROWSER_TREE, declTree);
106 DDX_Control(pDX, IDC_DECLBROWSER_STATIC_SEARCH_NAMES, findNameStatic);
107 DDX_Control(pDX, IDC_DECLBROWSER_STATIC_SEARCH_TEXT, findTextStatic);
108 DDX_Control(pDX, IDC_DECLBROWSER_EDIT_SEARCH_NAMES, findNameEdit);
109 DDX_Control(pDX, IDC_DECLBROWSER_EDIT_SEARCH_TEXT, findTextEdit);
110 DDX_Control(pDX, IDC_DECLBROWSER_BUTTON_FIND, findButton);
111 DDX_Control(pDX, IDC_DECLBROWSER_BUTTON_EDIT, editButton);
112 DDX_Control(pDX, IDC_DECLBROWSER_BUTTON_NEW, newButton);
113 DDX_Control(pDX, IDC_DECLBROWSER_BUTTON_RELOAD, reloadButton);
114 DDX_Control(pDX, IDCANCEL, cancelButton);
120 DialogDeclBrowser::AddDeclTypeToTree
123 template< class type >
124 int idListDeclSortCompare( const type *a, const type *b ) {
125 return idStr::IcmpPath( (*a)->GetName(), (*b)->GetName() );
128 void DialogDeclBrowser::AddDeclTypeToTree( declType_t type, const char *root, CPathTreeCtrl &tree ) {
130 idList<const idDecl*> decls;
131 idPathTreeStack stack;
132 idStr rootStr, declName;
134 decls.SetNum( declManager->GetNumDecls( type ) );
135 for ( i = 0; i < decls.Num(); i++ ) {
136 decls[i] = declManager->DeclByIndex( type, i, false );
138 decls.Sort( idListDeclSortCompare );
143 stack.PushRoot( NULL );
145 for ( i = 0; i < decls.Num(); i++) {
146 declName = rootStr + decls[i]->GetName();
148 declName.BackSlashesToSlashes();
151 tree.AddPathToTree( declName, GetIdFromTypeAndIndex( type, decls[i]->Index() ), stack );
157 DialogDeclBrowser::AddScriptsToTree
160 void DialogDeclBrowser::AddScriptsToTree( CPathTreeCtrl &tree ) {
162 idPathTreeStack stack;
166 files = fileSystem->ListFilesTree( "script", ".script", true );
168 stack.PushRoot( NULL );
170 for ( i = 0; i < files->GetNumFiles(); i++) {
171 scriptName = files->GetFile( i );
173 scriptName.BackSlashesToSlashes();
174 scriptName.StripFileExtension();
176 tree.AddPathToTree( scriptName, GetIdFromTypeAndIndex( DECLTYPE_SCRIPT, i ), stack );
179 fileSystem->FreeFileList( files );
184 DialogDeclBrowser::AddGUIsToTree
187 void DialogDeclBrowser::AddGUIsToTree( CPathTreeCtrl &tree ) {
189 idPathTreeStack stack;
193 files = fileSystem->ListFilesTree( "guis", ".gui", true );
195 stack.PushRoot( NULL );
197 for ( i = 0; i < files->GetNumFiles(); i++) {
198 scriptName = files->GetFile( i );
200 scriptName.BackSlashesToSlashes();
201 scriptName.StripFileExtension();
203 tree.AddPathToTree( scriptName, GetIdFromTypeAndIndex( DECLTYPE_GUI, i ), stack );
206 fileSystem->FreeFileList( files );
211 DialogDeclBrowser::InitBaseDeclTree
214 void DialogDeclBrowser::InitBaseDeclTree( void ) {
218 baseDeclTree.DeleteAllItems();
220 for ( i = 0; i < declManager->GetNumDeclTypes(); i++ ) {
221 AddDeclTypeToTree( (declType_t)i, declManager->GetDeclNameFromType( (declType_t)i ), baseDeclTree );
224 AddScriptsToTree( baseDeclTree );
225 AddGUIsToTree( baseDeclTree );
230 DialogDeclBrowser::GetDeclName
233 void DialogDeclBrowser::GetDeclName( HTREEITEM item, idStr &typeName, idStr &declName ) const {
238 for( parent = declTree.GetParentItem( item ); parent; parent = declTree.GetParentItem( parent ) ) {
239 itemName = declTree.GetItemText( item );
240 declName = itemName + "/" + declName;
243 declName.Strip( '/' );
244 typeName = declTree.GetItemText( item );
249 DialogDeclBrowser::GetDeclFromTreeItem
252 const idDecl *DialogDeclBrowser::GetDeclFromTreeItem( HTREEITEM item ) const {
257 if ( declTree.GetChildItem( item ) ) {
261 id = declTree.GetItemData( item );
262 type = GetTypeFromId( id );
263 index = GetIndexFromId( id );
265 if ( type < 0 || type >= declManager->GetNumDeclTypes() ) {
269 decl = declManager->DeclByIndex( type, index, false );
276 DialogDeclBrowser::GetSelectedDecl
279 const idDecl *DialogDeclBrowser::GetSelectedDecl( void ) const {
280 return GetDeclFromTreeItem( declTree.GetSelectedItem() );
285 DialogDeclBrowser::EditSelected
288 void DialogDeclBrowser::EditSelected( void ) const {
295 item = declTree.GetSelectedItem();
297 if ( declTree.GetChildItem( item ) ) {
301 id = declTree.GetItemData( item );
302 type = GetTypeFromId( id );
303 index = GetIndexFromId( id );
307 decl = declManager->DeclByIndex( type, index, false );
308 spawnArgs.Set( "articulatedFigure", decl->GetName() );
309 AFEditorInit( &spawnArgs );
312 case DECL_PARTICLE: {
313 decl = declManager->DeclByIndex( type, index, false );
314 spawnArgs.Set( "model", decl->GetName() );
315 ParticleEditorInit( &spawnArgs );
319 decl = declManager->DeclByIndex( type, index, false );
320 spawnArgs.Set( "pda", decl->GetName() );
321 PDAEditorInit( &spawnArgs );
324 case DECLTYPE_SCRIPT:
326 idStr typeName, declName;
327 GetDeclName( item, typeName, declName );
328 DialogScriptEditor *scriptEditor;
329 scriptEditor = new DialogScriptEditor;
330 scriptEditor->Create( IDD_DIALOG_SCRIPTEDITOR, GetParent() );
331 scriptEditor->OpenFile( typeName + "/" + declName + ( ( type == DECLTYPE_SCRIPT ) ? ".script" : ".gui" ) );
332 scriptEditor->ShowWindow( SW_SHOW );
333 scriptEditor->SetFocus();
337 decl = declManager->DeclByIndex( type, index, false );
338 DialogDeclEditor *declEditor;
339 declEditor = new DialogDeclEditor;
340 declEditor->Create( IDD_DIALOG_DECLEDITOR, GetParent() );
341 declEditor->LoadDecl( const_cast<idDecl *>( decl ) );
342 declEditor->ShowWindow( SW_SHOW );
343 declEditor->SetFocus();
351 DeclBrowserCompareDecl
354 bool DeclBrowserCompareDecl( void *data, HTREEITEM item, const char *name ) {
355 return reinterpret_cast<DialogDeclBrowser *>(data)->CompareDecl( item, name );
360 DialogDeclBrowser::CompareDecl
363 bool DialogDeclBrowser::CompareDecl( HTREEITEM item, const char *name ) const {
364 if ( findNameString.Length() ) {
365 if ( !idStr::Filter( findNameString, name, false ) ) {
370 if ( findTextString.Length() ) {
374 id = declTree.GetItemData( item );
375 type = GetTypeFromId( id );
376 index = GetIndexFromId( id );
378 if ( type == DECLTYPE_SCRIPT || type == DECLTYPE_GUI ) {
379 // search for the text in the script or gui
382 if ( fileSystem->ReadFile( idStr( name ) + ( ( type == DECLTYPE_SCRIPT ) ? ".script" : ".gui" ), &buffer ) == -1 ) {
385 text = (char *) buffer;
386 fileSystem->FreeFile( buffer );
387 if ( text.Find( findTextString, false ) == -1 ) {
391 // search for the text in the decl
392 const idDecl *decl = declManager->DeclByIndex( type, index, false );
393 char *declText = (char *)_alloca( ( decl->GetTextLength() + 1 ) * sizeof( char ) );
394 decl->GetText( declText );
395 if ( idStr::FindText( declText, findTextString, false ) == -1 ) {
406 DialogDeclBrowser::OnInitDialog
409 BOOL DialogDeclBrowser::OnInitDialog() {
411 com_editors |= EDITOR_DECL;
413 CDialog::OnInitDialog();
415 GetClientRect( initialRect );
417 statusBar.CreateEx( SBARS_SIZEGRIP, WS_CHILD | WS_VISIBLE | CBRS_BOTTOM, initialRect, this, AFX_IDW_STATUS_BAR );
419 baseDeclTree.Create( 0, initialRect, this, IDC_DECLBROWSER_BASE_TREE );
423 findNameString = "*";
424 findNameEdit.SetWindowText( findNameString );
427 findTextEdit.SetWindowText( findTextString );
429 numListedDecls = baseDeclTree.SearchTree( DeclBrowserCompareDecl, this, declTree );
431 statusBar.SetWindowText( va( "%d decls listed", numListedDecls ) );
433 EnableToolTips( TRUE );
435 return TRUE; // return TRUE unless you set the focus to a control
436 // EXCEPTION: OCX Property Pages should return FALSE
444 void DeclBrowserInit( const idDict *spawnArgs ) {
446 if ( renderSystem->IsFullScreen() ) {
447 common->Printf( "Cannot run the declaration editor in fullscreen mode.\n"
448 "Set r_fullscreen to 0 and vid_restart.\n" );
452 if ( g_DeclDialog == NULL ) {
454 g_DeclDialog = new DialogDeclBrowser();
457 if ( g_DeclDialog->GetSafeHwnd() == NULL) {
458 g_DeclDialog->Create( IDD_DIALOG_DECLBROWSER );
460 // FIXME: restore position
462 g_DeclDialog->SetWindowPos( NULL, rct.left, rct.top, 0, 0, SWP_NOSIZE );
466 idKeyInput::ClearStates();
468 g_DeclDialog->ShowWindow( SW_SHOW );
469 g_DeclDialog->SetFocus();
480 void DeclBrowserRun( void ) {
482 MSG *msg = AfxGetCurrentMessage(); // TODO Robert fix me!!
484 MSG *msg = &m_msgCur;
487 while( ::PeekMessage(msg, NULL, NULL, NULL, PM_NOREMOVE) ) {
489 if ( !AfxGetApp()->PumpMessage() ) {
499 void DeclBrowserShutdown( void ) {
506 DeclBrowserReloadDeclarations
509 void DeclBrowserReloadDeclarations( void ) {
510 if ( g_DeclDialog ) {
511 g_DeclDialog->ReloadDeclarations();
517 DialogDeclBrowser::ReloadDeclarations
520 void DialogDeclBrowser::ReloadDeclarations( void ) {
525 BEGIN_MESSAGE_MAP(DialogDeclBrowser, CDialog)
526 ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
527 ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
534 ON_NOTIFY(TVN_SELCHANGED, IDC_DECLBROWSER_TREE, OnTreeSelChanged)
535 ON_NOTIFY(NM_DBLCLK, IDC_DECLBROWSER_TREE, OnTreeDblclk)
536 ON_BN_CLICKED(IDC_DECLBROWSER_BUTTON_FIND, OnBnClickedFind)
537 ON_BN_CLICKED(IDC_DECLBROWSER_BUTTON_EDIT, OnBnClickedEdit)
538 ON_BN_CLICKED(IDC_DECLBROWSER_BUTTON_NEW, OnBnClickedNew)
539 ON_BN_CLICKED(IDC_DECLBROWSER_BUTTON_RELOAD, OnBnClickedReload)
540 ON_BN_CLICKED(IDOK, OnBnClickedOk)
541 ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel)
544 // DialogDeclBrowser message handlers
548 DialogDeclBrowser::OnActivate
551 void DialogDeclBrowser::OnActivate( UINT nState, CWnd *pWndOther, BOOL bMinimized ) {
552 CDialog::OnActivate( nState, pWndOther, bMinimized );
557 DialogDeclBrowser::OnToolTipNotify
560 BOOL DialogDeclBrowser::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
561 // need to handle both ANSI and UNICODE versions of the message
562 TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
563 TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
565 if ( pNMHDR->hwndFrom == declTree.GetSafeHwnd() ) {
567 const idDecl *decl = GetDeclFromTreeItem( (HTREEITEM) pNMHDR->idFrom );
573 toolTip = va( "%s, line: %d", decl->GetFileName(), decl->GetLineNum() );
576 if( pNMHDR->code == TTN_NEEDTEXTA ) {
578 m_pchTip = new TCHAR[toolTip.GetLength() + 2];
579 lstrcpyn( m_pchTip, toolTip, toolTip.GetLength() + 1 );
580 pTTTW->lpszText = (WCHAR*)m_pchTip;
583 m_pwchTip = new WCHAR[toolTip.GetLength() + 2];
584 _mbstowcsz( m_pwchTip, toolTip, toolTip.GetLength() + 1 );
585 pTTTW->lpszText = (WCHAR*)m_pwchTip;
588 if( pNMHDR->code == TTN_NEEDTEXTA ) {
590 m_pchTip = new TCHAR[toolTip.GetLength() + 2];
591 _wcstombsz( m_pchTip, toolTip, toolTip.GetLength() + 1 );
592 pTTTA->lpszText = (LPTSTR)m_pchTip;
595 m_pwchTip = new WCHAR[toolTip.GetLength() + 2];
596 lstrcpyn( m_pwchTip, toolTip, toolTip.GetLength() + 1 );
597 pTTTA->lpszText = (LPTSTR) m_pwchTip;
603 return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
608 DialogDeclBrowser::OnSetFocus
611 void DialogDeclBrowser::OnSetFocus( CWnd *pOldWnd ) {
612 CDialog::OnSetFocus( pOldWnd );
617 DialogDeclBrowser::OnDestroy
620 void DialogDeclBrowser::OnDestroy() {
622 com_editors &= ~EDITOR_DECL;
624 return CDialog::OnDestroy();
629 DialogDeclBrowser::OnMove
632 void DialogDeclBrowser::OnMove( int x, int y ) {
633 if ( GetSafeHwnd() ) {
635 GetWindowRect( rct );
636 // FIXME: save position
638 CDialog::OnMove( x, y );
643 DialogDeclBrowser::OnMove
646 #define BORDER_SIZE 4
647 #define BUTTON_SPACE 4
648 #define TOOLBAR_HEIGHT 24
650 void DialogDeclBrowser::OnSize( UINT nType, int cx, int cy ) {
651 CRect clientRect, rect;
655 CDialog::OnSize( nType, cx, cy );
657 GetClientRect( clientRect );
659 if ( declTree.GetSafeHwnd() ) {
660 rect.left = BORDER_SIZE;
661 rect.top = BORDER_SIZE;
662 rect.right = clientRect.Width() - BORDER_SIZE;
663 rect.bottom = clientRect.Height() - 100;
664 declTree.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
667 if ( findNameStatic.GetSafeHwnd() ) {
668 rect.left = BORDER_SIZE + 2;
669 rect.top = clientRect.Height() - 100 + BUTTON_SPACE + 2;
670 rect.right = BORDER_SIZE + 80;
671 rect.bottom = clientRect.Height() - 76 + 2;
672 findNameStatic.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
675 if ( findTextStatic.GetSafeHwnd() ) {
676 rect.left = BORDER_SIZE + 2;
677 rect.top = clientRect.Height() - 78 + BUTTON_SPACE + 2;
678 rect.right = BORDER_SIZE + 80;
679 rect.bottom = clientRect.Height() - 54 + 2;
680 findTextStatic.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
683 if ( findNameEdit.GetSafeHwnd() ) {
684 rect.left = BORDER_SIZE + 80;
685 rect.top = clientRect.Height() - 100 + BUTTON_SPACE;
686 rect.right = clientRect.Width() - BORDER_SIZE;
687 rect.bottom = clientRect.Height() - 76;
688 findNameEdit.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
691 if ( findTextEdit.GetSafeHwnd() ) {
692 rect.left = BORDER_SIZE + 80;
693 rect.top = clientRect.Height() - 78 + BUTTON_SPACE;
694 rect.right = clientRect.Width() - BORDER_SIZE;
695 rect.bottom = clientRect.Height() - 54;
696 findTextEdit.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
699 if ( findButton.GetSafeHwnd() ) {
700 findButton.GetClientRect( rect );
701 int width = rect.Width();
702 int height = rect.Height();
703 rect.left = BORDER_SIZE;
704 rect.top = clientRect.Height() - TOOLBAR_HEIGHT - height;
705 rect.right = BORDER_SIZE + width;
706 rect.bottom = clientRect.Height() - TOOLBAR_HEIGHT;
707 findButton.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
710 if ( editButton.GetSafeHwnd() ) {
711 editButton.GetClientRect( rect );
712 int width = rect.Width();
713 int height = rect.Height();
714 rect.left = BORDER_SIZE + BUTTON_SPACE + width;
715 rect.top = clientRect.Height() - TOOLBAR_HEIGHT - height;
716 rect.right = BORDER_SIZE + BUTTON_SPACE + 2 * width;
717 rect.bottom = clientRect.Height() - TOOLBAR_HEIGHT;
718 editButton.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
721 if ( newButton.GetSafeHwnd() ) {
722 newButton.GetClientRect( rect );
723 int width = rect.Width();
724 int height = rect.Height();
725 rect.left = BORDER_SIZE + 2 * BUTTON_SPACE + 2 * width;
726 rect.top = clientRect.Height() - TOOLBAR_HEIGHT - height;
727 rect.right = BORDER_SIZE + 2 * BUTTON_SPACE + 3 * width;
728 rect.bottom = clientRect.Height() - TOOLBAR_HEIGHT;
729 newButton.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
732 if ( reloadButton.GetSafeHwnd() ) {
733 reloadButton.GetClientRect( rect );
734 int width = rect.Width();
735 int height = rect.Height();
736 rect.left = BORDER_SIZE + 3 * BUTTON_SPACE + 3 * width;
737 rect.top = clientRect.Height() - TOOLBAR_HEIGHT - height;
738 rect.right = BORDER_SIZE + 3 * BUTTON_SPACE + 4 * width;
739 rect.bottom = clientRect.Height() - TOOLBAR_HEIGHT;
740 reloadButton.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
743 if ( cancelButton.GetSafeHwnd() ) {
744 cancelButton.GetClientRect( rect );
745 int width = rect.Width();
746 int height = rect.Height();
747 rect.left = clientRect.Width() - BORDER_SIZE - width;
748 rect.top = clientRect.Height() - TOOLBAR_HEIGHT - height;
749 rect.right = clientRect.Width() - BORDER_SIZE;
750 rect.bottom = clientRect.Height() - TOOLBAR_HEIGHT;
751 cancelButton.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
754 if ( statusBar.GetSafeHwnd() ) {
755 rect.left = clientRect.Width() - 2;
756 rect.top = clientRect.Height() - 2;
757 rect.right = clientRect.Width() - 2;
758 rect.bottom = clientRect.Height() - 2;
759 statusBar.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
762 UnlockWindowUpdate();
767 DialogDeclBrowser::OnSizing
770 void DialogDeclBrowser::OnSizing( UINT nSide, LPRECT lpRect ) {
782 CDialog::OnSizing( nSide, lpRect );
784 if ( ( nSide - 1 ) % 3 == 0 ) {
785 if ( lpRect->right - lpRect->left < initialRect.Width() ) {
786 lpRect->left = lpRect->right - initialRect.Width();
788 } else if ( ( nSide - 2 ) % 3 == 0 ) {
789 if ( lpRect->right - lpRect->left < initialRect.Width() ) {
790 lpRect->right = lpRect->left + initialRect.Width();
793 if ( nSide >= 3 && nSide <= 5 ) {
794 if ( lpRect->bottom - lpRect->top < initialRect.Height() ) {
795 lpRect->top = lpRect->bottom - initialRect.Height();
797 } else if ( nSide >= 6 && nSide <= 9 ) {
798 if ( lpRect->bottom - lpRect->top < initialRect.Height() ) {
799 lpRect->bottom = lpRect->top + initialRect.Height();
806 DialogDeclBrowser::OnTreeSelChanged
809 void DialogDeclBrowser::OnTreeSelChanged( NMHDR* pNMHDR, LRESULT* pResult ) {
810 LV_KEYDOWN* pLVKeyDow = (LV_KEYDOWN*)pNMHDR;
812 const idDecl *decl = GetSelectedDecl();
814 statusBar.SetWindowText( va( "%d decls listed - %s, line: %d", numListedDecls, decl->GetFileName(), decl->GetLineNum() ) );
815 findNameEdit.SetWindowText( va( "%s/%s", declManager->GetDeclNameFromType( decl->GetType() ), decl->GetName() ) );
817 HTREEITEM item = declTree.GetSelectedItem();
818 idStr typeName, declName;
819 GetDeclName( item, typeName, declName );
820 findNameEdit.SetWindowText( va( "%s/%s*", typeName.c_str(), declName.c_str() ) );
821 statusBar.SetWindowText( va( "%d decls listed", numListedDecls ) );
829 DialogDeclBrowser::OnTreeDblclk
832 void DialogDeclBrowser::OnTreeDblclk( NMHDR *pNMHDR, LRESULT *pResult ) {
833 // post a message as if the edit button was clicked to make sure the editor gets focus
834 PostMessage( WM_COMMAND, ( BN_CLICKED << 16 ) | editButton.GetDlgCtrlID(), 0 );
841 DialogDeclBrowser::OnBnClickedFind
844 void DialogDeclBrowser::OnBnClickedFind() {
847 findNameEdit.GetWindowText( windowText );
848 findNameString = windowText;
849 findNameString.Strip( ' ' );
851 findTextEdit.GetWindowText( windowText );
852 findTextString = windowText;
853 findTextString.Strip( ' ' );
855 numListedDecls = baseDeclTree.SearchTree( DeclBrowserCompareDecl, this, declTree );
857 statusBar.SetWindowText( va( "%d decls listed", numListedDecls ) );
862 DialogDeclBrowser::OnBnClickedEdit
865 void DialogDeclBrowser::OnBnClickedEdit() {
871 DialogDeclBrowser::OnBnClickedNew
874 void DialogDeclBrowser::OnBnClickedNew() {
876 idStr typeName, declName;
878 DialogDeclNew newDeclDlg;
880 newDeclDlg.SetDeclTree( &baseDeclTree );
882 item = declTree.GetSelectedItem();
884 GetDeclName( item, typeName, declName );
885 newDeclDlg.SetDefaultType( typeName );
886 newDeclDlg.SetDefaultName( declName );
889 decl = GetSelectedDecl();
891 newDeclDlg.SetDefaultFile( decl->GetFileName() );
894 if ( newDeclDlg.DoModal() != IDOK ) {
898 decl = newDeclDlg.GetNewDecl();
901 declName = declManager->GetDeclNameFromType( decl->GetType() );
903 declName += decl->GetName();
905 int id = GetIdFromTypeAndIndex( decl->GetType(), decl->Index() );
907 baseDeclTree.InsertPathIntoTree( declName, id );
908 item = declTree.InsertPathIntoTree( declName, id );
909 declTree.SelectItem( item );
917 DialogDeclBrowser::OnBnClickedReload
920 void DialogDeclBrowser::OnBnClickedReload() {
922 declManager->Reload( false );
924 ReloadDeclarations();
929 DialogDeclBrowser::OnBnClickedOk
932 void DialogDeclBrowser::OnBnClickedOk() {
933 // with a modeless dialog once it is closed and re-activated windows seems
934 // to enjoy mapping ENTER back to the default button ( OK ) even if you have
935 // it NOT set as the default.. in this case use cancel button exit and ignore
936 // default IDOK handling.
942 DialogDeclBrowser::OnBnClickedCancel
945 void DialogDeclBrowser::OnBnClickedCancel() {