doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DialogHelpers.h
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 #ifndef DIALOGHELPERS_H_
30 #define DIALOGHELPERS_H_
31 
33 {
34 public:
35 
36  HWND mWindow;
37  int mID;
38 
39  rvDialogItem ( int id ) { mID = id; }
40 
41  void Cache ( HWND parent )
42  {
43  mWindow = GetDlgItem ( parent, mID );
44  }
45 
46  void Check ( bool checked )
47  {
48  SendMessage ( mWindow, BM_SETCHECK, checked ? BST_CHECKED : BST_UNCHECKED, 0 );
49  }
50 
51  void Enable ( bool enable )
52  {
53  EnableWindow ( mWindow, enable );
54  }
55 
56  bool IsChecked ( void )
57  {
58  return SendMessage ( mWindow, BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
59  }
60 
61  void SetText ( const char* text )
62  {
63  SetWindowText ( mWindow, text );
64  }
65 
66  void GetText ( idStr& out )
67  {
68  char text[4096];
69  GetWindowText ( mWindow, text, 4095 );
70  out = text;
71  }
72 
73  float GetFloat ( void )
74  {
75  idStr text;
76  GetText ( text );
77  return atof( text );
78  }
79 
80  void SetFloat ( float f )
81  {
82  SetText ( va("%g", f ) );
83  }
84 
85  operator HWND( void ) const { return mWindow; }
86 };
87 
89 {
90 protected:
91 
92  void Cache ( HWND parent, int count )
93  {
94  int i;
95  unsigned char* ptr;
96 
97  ptr = (unsigned char*)this;
98  for ( i = 0; i < count; i ++, ptr += sizeof(rvDialogItem) )
99  {
100  ((rvDialogItem*)ptr)->Cache ( parent );
101  }
102  }
103 };
104 
105 #define DIALOGITEM_BEGIN(name) \
106 class name : public rvDialogItemContainer \
107 { \
108 public: \
109  name ( void ) { } \
110  name ( HWND hwnd ) { Cache ( hwnd ); } \
111  void Cache ( HWND parent ) \
112  { \
113  rvDialogItemContainer::Cache ( parent, sizeof(*this)/sizeof(rvDialogItem) ); \
114  }
115 
116 
117 #define DIALOGITEM(id,name) \
118 class c##name : public rvDialogItem \
119 { \
120 public: \
121  c##name(int localid=id) : rvDialogItem ( localid ) { } \
122 } name;
123 
124 #define DIALOGITEM_END() \
125 };
126 
127 
128 #endif // DIALOGHELPERS_H_
rvDialogItem(int id)
Definition: DialogHelpers.h:39
void GetText(idStr &out)
Definition: DialogHelpers.h:66
void SetFloat(float f)
Definition: DialogHelpers.h:80
int i
Definition: process.py:33
void Enable(bool enable)
Definition: DialogHelpers.h:51
GLuint GLuint GLsizei count
Definition: glext.h:2845
void SetText(const char *text)
Definition: DialogHelpers.h:61
void Cache(HWND parent)
Definition: DialogHelpers.h:41
void Cache(HWND parent, int count)
Definition: DialogHelpers.h:92
float GetFloat(void)
Definition: DialogHelpers.h:73
GLuint id
Definition: glext.h:3103
tuple f
Definition: idal.py:89
Definition: Str.h:116
void Check(bool checked)
Definition: DialogHelpers.h:46
bool IsChecked(void)
Definition: DialogHelpers.h:56
char * va(const char *fmt,...)
Definition: Str.cpp:1568