]> icculus.org git repositories - icculus/iodoom3.git/blob - neo/tools/radiant/InspectorDialog.cpp
Various Mac OS X tweaks to get this to build. Probably breaking things.
[icculus/iodoom3.git] / neo / tools / radiant / InspectorDialog.cpp
1 /*
2 ===========================================================================
3
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. 
6
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).  
8
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.
13
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.
18
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/>.
21
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.
23
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.
25
26 ===========================================================================
27 */
28
29 #include "../../idlib/precompiled.h"
30 #pragma hdrstop
31
32 #include "qe3.h"
33 #include "Radiant.h"
34 #include "GLWidget.h"
35 #include "ConsoleDlg.h"
36 #include "InspectorDialog.h"
37 #include "TabsDlg.h"
38
39 CInspectorDialog *g_Inspectors = NULL;
40 // CInspectorDialog dialog
41
42 void InspectorsDockingCallback ( bool docked , int ID , CWnd* wnd )
43 {
44         g_Inspectors->SetDockedTabs( docked , ID );
45 }
46
47
48 // CInspectorDialog dialog
49 //IMPLEMENT_DYNAMIC(CInspectorDialog,CTabsDlg)
50 CInspectorDialog::CInspectorDialog(CWnd* pParent /*=NULL*/)
51         : CTabsDlg(CInspectorDialog::IDD, pParent)
52 {
53         initialized = false;
54         dockedTabs = W_CONSOLE | W_TEXTURE | W_MEDIA;
55 }
56
57 CInspectorDialog::~CInspectorDialog()
58 {
59 }
60
61
62 BEGIN_MESSAGE_MAP(CInspectorDialog, CTabsDlg)
63         ON_NOTIFY(TCN_SELCHANGE, IDC_TAB_INSPECTOR, OnTcnSelchange )
64         ON_WM_SIZE()
65         ON_WM_DESTROY()
66         ON_WM_CLOSE()
67 END_MESSAGE_MAP()
68
69
70 // CInspectorDialog message handlers
71
72 BOOL CInspectorDialog::OnInitDialog()
73 {
74         CTabsDlg::OnInitDialog();
75
76         ASSERT ( m_Tabs.GetSafeHwnd() );
77
78         LoadWindowPlacement(GetSafeHwnd() , "radiant_InspectorsWindow" );
79
80         consoleWnd.Create(IDD_DIALOG_CONSOLE, this);
81         texWnd.Create(TEXTURE_WINDOW_CLASS, "", QE3_SPLITTER_STYLE, CRect(5, 5, 10, 10), this, 1299);
82         mediaDlg.Create(IDD_DIALOG_TEXTURELIST, this);
83         entityDlg.Create(IDD_DIALOG_ENTITY, this);
84
85         dockedTabs = GetCvarInt ( "radiant_InspectorDockedDialogs" , W_CONSOLE | W_TEXTURE | W_MEDIA );
86
87         AddDockedWindow ( &consoleWnd , W_CONSOLE , 1 , "Console"        , (dockedTabs & W_CONSOLE ) != 0 , InspectorsDockingCallback );
88         AddDockedWindow ( &texWnd         , W_TEXTURE , 2 , "Textures"   , (dockedTabs & W_TEXTURE ) != 0 , InspectorsDockingCallback );
89         AddDockedWindow ( &mediaDlg       , W_MEDIA       , 3 , "Media"      , (dockedTabs & W_MEDIA   ) != 0 , InspectorsDockingCallback );
90         AddDockedWindow ( &entityDlg  , W_ENTITY  , 4 , "Entity"         , (dockedTabs & W_ENTITY  ) != 0 , InspectorsDockingCallback );
91         
92         SetMode(W_CONSOLE);     
93         initialized = true;
94
95         return TRUE;  // return TRUE unless you set the focus to a control
96         // EXCEPTION: OCX Property Pages should return FALSE
97 }
98
99 void CInspectorDialog::SetMode(int mode, bool updateTabs) {
100         FocusWindow ( mode );
101 }
102
103 void CInspectorDialog::UpdateEntitySel(eclass_t *ent) {
104         entityDlg.UpdateEntitySel(ent);
105 }
106
107 void CInspectorDialog::FillClassList() {
108         entityDlg.AddClassNames();
109 }
110
111 void CInspectorDialog::UpdateSelectedEntity() {
112         entityDlg.SetKeyValPairs();
113 }
114
115 bool CInspectorDialog::GetSelectAllCriteria(idStr &key, idStr &val) {
116         CString k, v;
117         entityDlg.editKey.GetWindowText(k);
118         entityDlg.editVal.GetWindowText(v);
119         key = k;
120         val = v;
121         return true;
122 }
123
124
125
126 void CInspectorDialog::OnSize(UINT nType, int cx, int cy)
127 {
128         CTabsDlg::OnSize(nType, cx, cy);
129
130         DockedWindowInfo* info = NULL;
131         POSITION pos;
132         WORD wID;
133
134         if (!initialized) {
135                 return;
136         }
137
138         CRect rect;
139         GetClientRect(rect);
140
141         CRect tabRect;
142         m_Tabs.GetWindowRect(tabRect);
143         // retain vert size but size 4 in from edges and 4 up from bottom
144         tabRect.left = 4;
145         tabRect.right = rect.Width() - 4;
146         tabRect.top = rect.Height() - tabRect.Height() - 4;
147         tabRect.bottom = rect.Height() - 4;
148         // adjust rect for children size
149         rect.bottom -= 5 + tabRect.Height();
150
151         m_Tabs.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), 0);
152
153         for( pos = m_Windows.GetStartPosition(); pos != NULL ; )
154         {
155                 m_Windows.GetNextAssoc( pos, wID, (void*&)info );
156
157                 if ( (info->m_State == DockedWindowInfo::DOCKED) ) {
158                         info->m_Window->SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), 0);
159                 }
160
161         }
162 }
163
164 void CInspectorDialog::OnDestroy()
165 {
166         ::SaveWindowPlacement(GetSafeHwnd() , "radiant_InspectorsWindow" );     
167         SetCvarInt("radiant_InspectorDockedDialogs" , dockedTabs );
168
169         CTabsDlg::OnDestroy();
170 }
171
172 void CInspectorDialog::OnClose()
173 {
174         CTabsDlg::OnClose();
175 }
176
177 BOOL CInspectorDialog::PreTranslateMessage(MSG* pMsg)
178 {
179         // TODO: Add your specialized code here and/or call the base class
180         if ( pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP) {
181                 g_pParentWnd->PostMessage(pMsg->message, pMsg->wParam, pMsg->lParam);
182         }
183         return CTabsDlg::PreTranslateMessage(pMsg);
184 }
185
186 void CInspectorDialog::SetDockedTabs ( bool docked , int ID )
187 {
188         if ( docked ) {
189                 dockedTabs |= ID;
190         }
191         else {
192                 dockedTabs &= ~ID;
193         }
194 }
195
196 void CInspectorDialog::AssignModel ()
197 {
198         entityDlg.AssignModel();
199 }