]> git.saurik.com Git - wxWidgets.git/blob - include/wx/dialog.h
non-pch build fixes
[wxWidgets.git] / include / wx / dialog.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/dialog.h
3 // Purpose: wxDialogBase class
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 29.06.99
7 // RCS-ID: $Id$
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_DIALOG_H_BASE_
13 #define _WX_DIALOG_H_BASE_
14
15 #include "wx/defs.h"
16 #include "wx/containr.h"
17 #include "wx/toplevel.h"
18
19 class WXDLLEXPORT wxSizer;
20 class WXDLLEXPORT wxStdDialogButtonSizer;
21
22 #define wxDIALOG_NO_PARENT 0x0001 // Don't make owned by apps top window
23
24 #ifdef __WXWINCE__
25 #define wxDEFAULT_DIALOG_STYLE (wxCAPTION | wxMAXIMIZE | wxCLOSE_BOX | wxNO_BORDER)
26 #else
27 #define wxDEFAULT_DIALOG_STYLE (wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX)
28 #endif
29
30 extern WXDLLEXPORT_DATA(const wxChar) wxDialogNameStr[];
31
32 class WXDLLEXPORT wxDialogBase : public wxTopLevelWindow
33 {
34 public:
35 enum
36 {
37 // all flags allowed in wxDialogBase::CreateButtonSizer()
38 ButtonSizerFlags = wxOK|wxCANCEL|wxYES|wxNO|wxHELP|wxNO_DEFAULT
39 };
40
41 wxDialogBase() { Init(); }
42 virtual ~wxDialogBase() { }
43
44 // define public wxDialog methods to be implemented by the derived classes
45 virtual int ShowModal() = 0;
46 virtual void EndModal(int retCode) = 0;
47 virtual bool IsModal() const = 0;
48
49
50 // Modal dialogs have a return code - usually the id of the last
51 // pressed button
52 void SetReturnCode(int returnCode) { m_returnCode = returnCode; }
53 int GetReturnCode() const { return m_returnCode; }
54
55 // Set the identifier for the affirmative button: this button will close
56 // the dialog after validating data and calling TransferDataFromWindow()
57 void SetAffirmativeId(int affirmativeId);
58 int GetAffirmativeId() const { return m_affirmativeId; }
59
60 // Set identifier for Esc key translation: the button with this id will
61 // close the dialog without doing anything else; special value wxID_NONE
62 // means to not handle Esc at all while wxID_ANY means to map Esc to
63 // wxID_CANCEL if present and GetAffirmativeId() otherwise
64 void SetEscapeId(int escapeId);
65 int GetEscapeId() const { return m_escapeId; }
66
67 #if wxUSE_STATTEXT // && wxUSE_TEXTCTRL
68 // splits text up at newlines and places the
69 // lines into a vertical wxBoxSizer
70 wxSizer *CreateTextSizer( const wxString &message );
71 #endif // wxUSE_STATTEXT // && wxUSE_TEXTCTRL
72
73 // places buttons into a horizontal wxBoxSizer
74 wxSizer *CreateButtonSizer( long flags,
75 bool separated = false,
76 wxCoord distance = 0 );
77 #if wxUSE_BUTTON
78 wxStdDialogButtonSizer *CreateStdDialogButtonSizer( long flags );
79 #endif // wxUSE_BUTTON
80
81 protected:
82 // emulate click of a button with the given id if it's present in the dialog
83 //
84 // return true if button was "clicked" or false if we don't have it
85 bool EmulateButtonClickIfPresent(int id);
86
87 // this function is used by OnCharHook() to decide whether the given key
88 // should close the dialog
89 //
90 // for most platforms the default implementation (which just checks for
91 // Esc) is sufficient, but Mac port also adds Cmd-. here and other ports
92 // could do something different if needed
93 virtual bool IsEscapeKey(const wxKeyEvent& event);
94
95 // end either modal or modeless dialog, for the modal dialog rc is used as
96 // the dialog return code
97 void EndDialog(int rc);
98
99 // call Validate() and TransferDataFromWindow() and close dialog with
100 // wxID_OK return code
101 void AcceptAndClose();
102
103
104 // The return code from modal dialog
105 int m_returnCode;
106
107 // The identifier for the affirmative button (usually wxID_OK)
108 int m_affirmativeId;
109
110 // The identifier for cancel button (usually wxID_CANCEL)
111 int m_escapeId;
112
113 private:
114 // common part of all ctors
115 void Init();
116
117 // handle Esc key presses
118 void OnCharHook(wxKeyEvent& event);
119
120 // handle closing the dialog window
121 void OnCloseWindow(wxCloseEvent& event);
122
123 // handle the standard buttons
124 void OnButton(wxCommandEvent& event);
125
126 // update the background colour
127 void OnSysColourChanged(wxSysColourChangedEvent& event);
128
129
130 DECLARE_NO_COPY_CLASS(wxDialogBase)
131 DECLARE_EVENT_TABLE()
132 WX_DECLARE_CONTROL_CONTAINER();
133 };
134
135
136 #if defined(__WXUNIVERSAL__) && !defined(__WXMICROWIN__)
137 #include "wx/univ/dialog.h"
138 #else
139 #if defined(__WXPALMOS__)
140 #include "wx/palmos/dialog.h"
141 #elif defined(__WXMSW__)
142 #include "wx/msw/dialog.h"
143 #elif defined(__WXMOTIF__)
144 #include "wx/motif/dialog.h"
145 #elif defined(__WXGTK20__)
146 #include "wx/gtk/dialog.h"
147 #elif defined(__WXGTK__)
148 #include "wx/gtk1/dialog.h"
149 #elif defined(__WXMAC__)
150 #include "wx/mac/dialog.h"
151 #elif defined(__WXCOCOA__)
152 #include "wx/cocoa/dialog.h"
153 #elif defined(__WXPM__)
154 #include "wx/os2/dialog.h"
155 #endif
156 #endif
157
158 #endif
159 // _WX_DIALOG_H_BASE_