1
// Windows/Control/Dialog.h
3
#ifndef __WINDOWS_CONTROL_DIALOG_H
4
#define __WINDOWS_CONTROL_DIALOG_H
6
#include "Windows/Window.h"
12
#define WM_SETTEXT (6000) // wxID_HIGHEST + 1
13
#define WM_USER (6999) // wxID_HIGHEST + 1000
18
#define CBN_SELCHANGE 1
22
#define IDOK (5100) // wxID_OK
23
#define IDCANCEL (5101) // wxID_CANCEL
24
#define IDABORT (5115) // wxID_ABORT
25
#define IDYES (5103) // wxID_YES
26
#define IDNO (5104) // wxID_NO
27
#define IDHELP (5009) // wxID_HELP
30
#define BST_UNCHECKED 0
31
// #define BST_INDETERMINATE 0x0002
33
#define wsprintf(a,b,c,d,e) swprintf(a,9999,b,c,d,e) // FIXME
38
class CModalDialogImpl;
43
CModalDialogImpl * _window;
45
operator HWND() const { return HWND(_window); }
47
bool OnInit(CModalDialogImpl * window) {
51
virtual bool OnInit() { return false; }
52
virtual void OnOK() {}
53
virtual void OnCancel() {}
54
virtual void OnHelp() {}
55
virtual bool OnButtonClicked(int buttonID, wxWindow * buttonHWND) { return false; }
56
virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam) { return false; }
57
virtual bool OnCommand(int code, int itemID, LPARAM lParam) { return false; }
58
virtual bool OnTimer(WPARAM /* timerID */, LPARAM /* callback */) { return false; }
61
class CModalDialog : public CDialog
66
////////////////// COMPATIBILITY
68
bool CheckRadioButton(int firstButtonID, int lastButtonID, int checkButtonID)
71
for(int id = firstButtonID; id <= lastButtonID; id++)
73
CheckButton(id,id == checkButtonID);
76
this->CheckButton(checkButtonID,true);
82
bool CheckButton(int buttonID, UINT checkState);
83
bool CheckButton(int buttonID, bool checkState)
85
return CheckButton(buttonID, UINT(checkState ? BST_CHECKED : BST_UNCHECKED));
89
UINT IsButtonChecked(int buttonID) const;
91
bool IsButtonCheckedBool(long buttonID) const
92
{ return (IsButtonChecked(buttonID) == BST_CHECKED); }
94
void EnableItem(int id, bool state);
96
void SetItemText(int id, const TCHAR *txt);
98
wxWindow * GetItem(long id) const ;
100
void ShowItem(int itemID, int cmdShow) const;
102
void End(int result);
104
void SetText(const TCHAR *_title); // { _dialog->SetTitle(_title); }
106
bool GetText(CSysString &s);
108
INT_PTR Create(int id , HWND parentWindow);
110
void PostMessage(UINT message);
112
virtual void OnHelp() {}
114
UINT_PTR SetTimer(UINT_PTR idEvent , unsigned milliseconds);
116
void KillTimer(UINT_PTR idEvent);
118
virtual void OnOK() { End(IDOK); }
119
virtual void OnCancel() { End(IDCANCEL); }
122
class CDialogChildControl : public NWindows::CWindow
125
CDialogChildControl() {}
128
void Init(const NWindows::NControl::CModalDialog &parentDialog, int id)
131
this->Attach(parentDialog.GetItem(id));
133
virtual void SetText(LPCWSTR s);
134
virtual bool GetText(CSysString &s);
149
NWindows::NControl::CModalDialogImpl * (*createDialog)(NWindows::NControl::CModalDialog * dialog, HWND parentWindow);
150
CStringTable * stringTable;
153
void RegisterDialog(const CDialogInfo *dialogInfo);
155
#define REGISTER_DIALOG_NAME(x) CRegister ## x
157
#define REGISTER_DIALOG(id,x,stringTable) \
158
static NWindows::NControl::CModalDialogImpl * myCreate##x(NWindows::NControl::CModalDialog * dialog,HWND parentWindow) \
159
{ return new x##Impl(dialog,parentWindow,id); } \
160
static struct CDialogInfo g_DialogInfo = { id , myCreate##x, stringTable }; \
161
struct REGISTER_DIALOG_NAME(x) { \
162
REGISTER_DIALOG_NAME(x)() { RegisterDialog(&g_DialogInfo); }}; \
163
static REGISTER_DIALOG_NAME(x) g_RegisterDialog;
165
#define REGISTER_STRINGTABLE(stringTable) \
166
static struct CDialogInfo g_DialogInfo = { -1 , 0 , stringTable }; \
167
struct REGISTER_DIALOG_NAME(x) { \
168
REGISTER_DIALOG_NAME(x)() { RegisterDialog(&g_DialogInfo); }}; \
169
static REGISTER_DIALOG_NAME(x) g_RegisterDialog;