doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InspectorDialog.cpp
Go to the documentation of this file.
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 
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 
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 {
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 
105 }
106 
109 }
110 
113 }
114 
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 
165 {
166  ::SaveWindowPlacement(GetSafeHwnd() , "radiant_InspectorsWindow" );
167  SetCvarInt("radiant_InspectorDockedDialogs" , dockedTabs );
168 
170 }
171 
173 {
174  CTabsDlg::OnClose();
175 }
176 
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 
197 {
199 }
CMainFrame * g_pParentWnd
Definition: MainFrm.cpp:73
CEntityDlg entityDlg
#define IDD_DIALOG_TEXTURELIST
void UpdateEntitySel(eclass_t *ent)
CEdit editVal
Definition: EntityDlg.h:88
CMapWordToPtr m_Windows
Definition: TabsDlg.h:64
CONST PIXELFORMATDESCRIPTOR UINT
Definition: win_qgl.cpp:47
const GLdouble * v
Definition: glext.h:2936
void FocusWindow(int ID)
Definition: TabsDlg.cpp:258
afx_msg void OnDestroy()
Definition: TabsDlg.cpp:295
#define IDD_DIALOG_ENTITY
afx_msg void OnDestroy()
bool LoadWindowPlacement(HWND hwnd, const char *pName)
Definition: MainFrm.cpp:1431
void InspectorsDockingCallback(bool docked, int ID, CWnd *wnd)
void AddClassNames()
Definition: EntityDlg.cpp:117
bool GetSelectAllCriteria(idStr &key, idStr &val)
#define BOOL
Definition: mprintf.c:71
CInspectorDialog(CWnd *pParent=NULL)
void SetKeyValPairs(bool updateAnims=true)
Definition: EntityDlg.cpp:322
void SetDockedTabs(bool docked, int ID)
virtual BOOL PreTranslateMessage(MSG *pMsg)
unsigned int dockedTabs
#define NULL
Definition: Lib.h:88
bool initialized
Definition: maya_main.cpp:38
#define IDC_TAB_INSPECTOR
GLint mode
Definition: glext.h:4165
void AssignModel()
Definition: EntityDlg.cpp:855
CInspectorDialog * g_Inspectors
afx_msg void OnSize(UINT nType, int cx, int cy)
#define IDD_DIALOG_CONSOLE
void SetMode(int mode, bool updateTabs=true)
int GetCvarInt(const char *name, const int def)
Definition: PrefsDlg.cpp:255
void UpdateEntitySel(eclass_t *ent)
Definition: EntityDlg.cpp:407
afx_msg void OnClose()
Definition: Str.h:116
void SaveWindowPlacement(int ID=-1)
Definition: TabsDlg.cpp:335
void SetCvarInt(const char *name, const int value)
Definition: PrefsDlg.cpp:275
#define TRUE
Definition: mprintf.c:69
CEdit editKey
Definition: EntityDlg.h:87
virtual BOOL OnInitDialog()
Definition: TabsDlg.cpp:60
virtual ~CInspectorDialog()
CTabCtrl m_Tabs
Definition: TabsDlg.h:111
int PreTranslateMessage(MSG *msg)
Definition: TabsDlg.cpp:158