doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GEOptionsDlg.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 "../../sys/win32/rc/guied_resource.h"
33 #include "../common/ColorButton.h"
34 
35 #include "GEApp.h"
36 
37 /*
38 ================
39 GEOptionsDlg_GeneralProc
40 
41 Dialog procedure for the general options tab
42 ================
43 */
44 static INT_PTR CALLBACK GEOptionsDlg_GeneralProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
45 {
46  switch ( msg )
47  {
48  case WM_INITDIALOG:
49  ColorButton_SetColor ( GetDlgItem ( hwnd, IDC_GUIED_SELECTIONCOLOR ),
50  RGB(gApp.GetOptions().GetSelectionColor()[0]*255,
52  gApp.GetOptions().GetSelectionColor()[2]*255) );
53  CheckDlgButton ( hwnd, IDC_GUIED_IGNOREDESKTOP, gApp.GetOptions().GetIgnoreDesktopSelect()?BST_CHECKED:BST_UNCHECKED );
54  break;
55 
56  case WM_COMMAND:
57  switch ( LOWORD ( wParam ) )
58  {
60  {
61  CHOOSECOLOR col;
62  ZeroMemory ( &col, sizeof(col) );
63  col.lStructSize = sizeof(col);
64  col.lpCustColors = gApp.GetOptions().GetCustomColors ( );
65  col.hwndOwner = hwnd;
66  col.hInstance = NULL;
67  col.Flags = CC_RGBINIT;
68  col.rgbResult = ColorButton_GetColor ( GetDlgItem ( hwnd, IDC_GUIED_SELECTIONCOLOR ) );
69  if ( ChooseColor ( &col ) )
70  {
71  ColorButton_SetColor ( GetDlgItem ( hwnd, IDC_GUIED_SELECTIONCOLOR ), col.rgbResult );
72  }
73  break;
74  }
75  }
76  break;
77 
78  case WM_DRAWITEM:
79  ColorButton_DrawItem ( GetDlgItem ( hwnd, wParam ), (LPDRAWITEMSTRUCT)lParam );
80  return TRUE;
81 
82  case WM_NOTIFY:
83  switch (((NMHDR FAR *) lParam)->code)
84  {
85  case PSN_APPLY:
86  gApp.GetOptions().SetLastOptionsPage ( PropSheet_HwndToIndex ( GetParent ( hwnd ), PropSheet_GetCurrentPageHwnd ( GetParent ( hwnd ) ) ) );
88  gApp.GetOptions().SetIgnoreDesktopSelect ( IsDlgButtonChecked ( hwnd, IDC_GUIED_IGNOREDESKTOP ) != 0 );
89  break;
90  }
91  break;
92  }
93 
94  return FALSE;
95 }
96 
97 /*
98 ================
99 GEOptionsDlg_GridProc
100 
101 Dialog procedure for the grid settings tab
102 ================
103 */
104 static INT_PTR CALLBACK GEOptionsDlg_GridProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
105 {
106  switch ( msg )
107  {
108  case WM_INITDIALOG:
109  // Copy the options information to the dialog controls
110  ColorButton_SetColor ( GetDlgItem ( hwnd, IDC_GUIED_GRIDCOLOR ), RGB(gApp.GetOptions().GetGridColor()[0]*255,gApp.GetOptions().GetGridColor()[1]*255,gApp.GetOptions().GetGridColor()[2]*255) );
111  SetWindowText ( GetDlgItem ( hwnd, IDC_GUIED_SPACINGWIDTH ), va("%d", gApp.GetOptions().GetGridWidth ( ) ) );
112  SetWindowText ( GetDlgItem ( hwnd, IDC_GUIED_SPACINGHEIGHT ), va("%d", gApp.GetOptions().GetGridHeight ( ) ) );
113  CheckDlgButton ( hwnd, IDC_GUIED_GRIDVISIBLE, gApp.GetOptions().GetGridVisible()?BST_CHECKED:BST_UNCHECKED );
114  CheckDlgButton ( hwnd, IDC_GUIED_GRIDSNAP, gApp.GetOptions().GetGridSnap()?BST_CHECKED:BST_UNCHECKED );
115  return TRUE;
116 
117  case WM_DRAWITEM:
118  ColorButton_DrawItem ( GetDlgItem ( hwnd, wParam ), (LPDRAWITEMSTRUCT)lParam );
119  return TRUE;
120 
121  case WM_NOTIFY:
122  switch (((NMHDR FAR *) lParam)->code)
123  {
124  case PSN_APPLY:
125  {
126  char temp[32];
127 
128  // Copy the dialog control data back to the options
129  GetWindowText ( GetDlgItem ( hwnd, IDC_GUIED_SPACINGWIDTH ), temp, 32 );
130  gApp.GetOptions().SetGridWidth(atol(temp));
131  GetWindowText ( GetDlgItem ( hwnd, IDC_GUIED_SPACINGHEIGHT ), temp, 32 );
132  gApp.GetOptions().SetGridHeight(atol(temp));
133  gApp.GetOptions().SetGridVisible ( IsDlgButtonChecked ( hwnd, IDC_GUIED_GRIDVISIBLE ) != 0 );
134  gApp.GetOptions().SetGridSnap ( IsDlgButtonChecked ( hwnd, IDC_GUIED_GRIDSNAP ) != 0 );
136  break;
137  }
138  }
139  break;
140 
141  case WM_COMMAND:
142  switch ( LOWORD ( wParam ) )
143  {
144  case IDC_GUIED_GRIDCOLOR:
145  {
146  CHOOSECOLOR col;
147  ZeroMemory ( &col, sizeof(col) );
148  col.lStructSize = sizeof(col);
149  col.lpCustColors = gApp.GetOptions().GetCustomColors ( );
150  col.hwndOwner = hwnd;
151  col.hInstance = NULL;
152  col.Flags = CC_RGBINIT;
153  col.rgbResult = RGB(gApp.GetOptions().GetGridColor()[0]*255,gApp.GetOptions().GetGridColor()[1]*255,gApp.GetOptions().GetGridColor()[2]*255);
154  if ( ChooseColor ( &col ) )
155  {
156  ColorButton_SetColor ( GetDlgItem ( hwnd, IDC_GUIED_GRIDCOLOR ), col.rgbResult );
157  }
158  break;
159  }
160  }
161  return TRUE;
162  }
163 
164  return FALSE;
165 }
166 
167 /*
168 ================
169 GEOptionsDlg_DoModal
170 
171 Starts the options dialog and updates the global options if ok is pressed
172 ================
173 */
174 bool GEOptionsDlg_DoModal ( HWND parent )
175 {
176  PROPSHEETHEADER propsh;
177  PROPSHEETPAGE propsp[2];
178 
179  propsp[0].dwSize = sizeof(PROPSHEETPAGE);
180  propsp[0].dwFlags = PSP_USETITLE;
181  propsp[0].hInstance = win32.hInstance;
182  propsp[0].pszTemplate = MAKEINTRESOURCE(IDD_GUIED_OPTIONS_GENERAL);
183  propsp[0].pfnDlgProc = GEOptionsDlg_GeneralProc;
184  propsp[0].pszTitle = "General";
185  propsp[0].lParam = 0;
186 
187  propsp[1].dwSize = sizeof(PROPSHEETPAGE);
188  propsp[1].dwFlags = PSP_USETITLE;
189  propsp[1].hInstance = win32.hInstance;
190  propsp[1].pszTemplate = MAKEINTRESOURCE(IDD_GUIED_OPTIONS_GRID);
191  propsp[1].pfnDlgProc = GEOptionsDlg_GridProc;
192  propsp[1].pszTitle = "Grid";
193  propsp[1].lParam = 0;
194 
195  propsh.dwSize = sizeof(PROPSHEETHEADER);
196  propsh.nStartPage = gApp.GetOptions().GetLastOptionsPage ( );
197  propsh.dwFlags = PSH_PROPSHEETPAGE|PSH_NOAPPLYNOW|PSH_NOCONTEXTHELP;
198  propsh.hwndParent = parent;
199  propsh.pszCaption = "Options";
200  propsh.nPages = 2;
201  propsh.ppsp = (LPCPROPSHEETPAGE)&propsp;
202 
203  if ( PropertySheet ( &propsh ) )
204  {
205  gApp.GetOptions().Save ( );
206  return true;
207  }
208 
209  return false;
210 }
bool GEOptionsDlg_DoModal(HWND parent)
#define IDC_GUIED_IGNOREDESKTOP
int GetGridHeight(void)
Definition: GEOptions.h:218
void SetSelectionColor(idVec4 &color)
Definition: GEOptions.h:172
CONST PIXELFORMATDESCRIPTOR UINT
Definition: win_qgl.cpp:47
bool GetGridSnap(void)
Definition: GEOptions.h:228
idVec4 & GetSelectionColor(void)
Definition: GEOptions.h:268
bool Save(void)
Definition: GEOptions.cpp:72
void ColorButton_DrawItem(HWND hWnd, LPDRAWITEMSTRUCT dis)
rvGEApp gApp
Definition: guied.cpp:41
void SetIgnoreDesktopSelect(bool ignore)
Definition: GEOptions.h:278
rvGEOptions & GetOptions(void)
Definition: GEApp.h:163
void SetLastOptionsPage(int page)
Definition: GEOptions.h:243
#define IDD_GUIED_OPTIONS_GRID
#define NULL
Definition: Lib.h:88
void SetGridSnap(bool snap)
Definition: GEOptions.h:148
#define FAR
Definition: jmorecfg.h:205
bool GetGridVisible(void)
Definition: GEOptions.h:223
void SetGridVisible(bool vis)
Definition: GEOptions.h:154
bool GetIgnoreDesktopSelect(void)
Definition: GEOptions.h:283
COLORREF * GetCustomColors(void)
Definition: GEOptions.h:273
#define IDC_GUIED_SELECTIONCOLOR
int GetGridWidth(void)
Definition: GEOptions.h:213
#define IDC_GUIED_SPACINGWIDTH
#define IDD_GUIED_OPTIONS_GENERAL
idVec4 & GetGridColor(void)
Definition: GEOptions.h:208
void SetGridWidth(int width)
Definition: GEOptions.h:136
int GetLastOptionsPage(void)
Definition: GEOptions.h:238
MFnDagNode * GetParent(MFnDagNode *joint)
Definition: maya_main.cpp:350
void ColorButton_SetColor(HWND hWnd, COLORREF color)
Definition: ColorButton.cpp:44
#define IDC_GUIED_GRIDCOLOR
#define FALSE
Definition: mprintf.c:70
#define TRUE
Definition: mprintf.c:69
void SetGridHeight(int height)
Definition: GEOptions.h:142
HINSTANCE hInstance
Definition: win_local.h:102
void SetGridColor(idVec4 &color)
Definition: GEOptions.h:184
char * va(const char *fmt,...)
Definition: Str.cpp:1568
Win32Vars_t win32
Definition: win_main.cpp:65
#define IDC_GUIED_GRIDSNAP
#define IDC_GUIED_GRIDVISIBLE
#define IDC_GUIED_SPACINGHEIGHT
COLORREF ColorButton_GetColor(HWND hWnd)
Definition: ColorButton.cpp:95