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 #ifndef DIALOGHELPERS_H_
30 #define DIALOGHELPERS_H_
39 rvDialogItem ( int id ) { mID = id; }
41 void Cache ( HWND parent )
43 mWindow = GetDlgItem ( parent, mID );
46 void Check ( bool checked )
48 SendMessage ( mWindow, BM_SETCHECK, checked ? BST_CHECKED : BST_UNCHECKED, 0 );
51 void Enable ( bool enable )
53 EnableWindow ( mWindow, enable );
56 bool IsChecked ( void )
58 return SendMessage ( mWindow, BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
61 void SetText ( const char* text )
63 SetWindowText ( mWindow, text );
66 void GetText ( idStr& out )
69 GetWindowText ( mWindow, text, 4095 );
73 float GetFloat ( void )
80 void SetFloat ( float f )
82 SetText ( va("%g", f ) );
85 operator HWND( void ) const { return mWindow; }
88 class rvDialogItemContainer
92 void Cache ( HWND parent, int count )
97 ptr = (unsigned char*)this;
98 for ( i = 0; i < count; i ++, ptr += sizeof(rvDialogItem) )
100 ((rvDialogItem*)ptr)->Cache ( parent );
105 #define DIALOGITEM_BEGIN(name) \
106 class name : public rvDialogItemContainer \
110 name ( HWND hwnd ) { Cache ( hwnd ); } \
111 void Cache ( HWND parent ) \
113 rvDialogItemContainer::Cache ( parent, sizeof(*this)/sizeof(rvDialogItem) ); \
117 #define DIALOGITEM(id,name) \
118 class c##name : public rvDialogItem \
121 c##name(int localid=id) : rvDialogItem ( localid ) { } \
124 #define DIALOGITEM_END() \
128 #endif // DIALOGHELPERS_H_