1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxDialogBase class
4 // Author: Vadim Zeitlin
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_DIALOG_H_BASE_
13 #define _WX_DIALOG_H_BASE_
16 #include "wx/containr.h"
17 #include "wx/toplevel.h"
19 class WXDLLEXPORT wxSizer
;
20 class WXDLLEXPORT wxStdDialogButtonSizer
;
22 #define wxDIALOG_NO_PARENT 0x0001 // Don't make owned by apps top window
25 #define wxDEFAULT_DIALOG_STYLE (wxCAPTION | wxMAXIMIZE | wxCLOSE_BOX | wxNO_BORDER)
27 #define wxDEFAULT_DIALOG_STYLE (wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX)
30 extern WXDLLEXPORT_DATA(const wxChar
) wxDialogNameStr
[];
32 class WXDLLEXPORT wxDialogBase
: public wxTopLevelWindow
37 // all flags allowed in wxDialogBase::CreateButtonSizer()
38 ButtonSizerFlags
= wxOK
|wxCANCEL
|wxYES
|wxNO
|wxHELP
|wxNO_DEFAULT
41 wxDialogBase() { Init(); }
42 virtual ~wxDialogBase() { }
44 // public wxDialog API, 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;
50 // Modal dialogs have a return code - usually the id of the last
52 void SetReturnCode(int returnCode
) { m_returnCode
= returnCode
; }
53 int GetReturnCode() const { return m_returnCode
; }
55 // The identifier for the affirmative button
56 void SetAffirmativeId(int affirmativeId
) { m_affirmativeId
= affirmativeId
; }
57 int GetAffirmativeId() const { return m_affirmativeId
; }
59 // Identifier for Esc key translation
60 void SetEscapeId(int escapeId
) { m_escapeId
= escapeId
; }
61 int GetEscapeId() const { return m_escapeId
; }
63 #if wxUSE_STATTEXT // && wxUSE_TEXTCTRL
64 // splits text up at newlines and places the
65 // lines into a vertical wxBoxSizer
66 wxSizer
*CreateTextSizer( const wxString
&message
);
67 #endif // wxUSE_STATTEXT // && wxUSE_TEXTCTRL
69 // places buttons into a horizontal wxBoxSizer
70 wxSizer
*CreateButtonSizer( long flags
,
71 bool separated
= false,
72 wxCoord distance
= 0 );
74 wxStdDialogButtonSizer
*CreateStdDialogButtonSizer( long flags
);
75 #endif // wxUSE_BUTTON
78 // emulate click of a button with the given id if it's present in the dialog
80 // return true if button was "clicked" or false if we don't have it
81 bool EmulateButtonClickIfPresent(int id
);
83 // this function is used by OnCharHook() to decide whether the given key
84 // should close the dialog
86 // for most platforms the default implementation (which just checks for
87 // Esc) is sufficient, but Mac port also adds Cmd-. here and other ports
88 // could do something different if needed
89 virtual bool IsEscapeKey(const wxKeyEvent
& event
);
91 // end either modal or modeless dialog, for the modal dialog rc is used as
92 // the dialog return code
93 void EndDialog(int rc
);
96 // The return code from modal dialog
99 // The identifier for the affirmative button (usually wxID_OK)
102 // The identifier for cancel button (usually wxID_CANCEL)
106 // common part of all ctors
109 // handle Esc key presses
110 void OnCharHook(wxKeyEvent
& event
);
112 // handle closing the dialog window
113 void OnCloseWindow(wxCloseEvent
& event
);
115 // handle the standard buttons
116 void OnOK(wxCommandEvent
& event
);
117 void OnApply(wxCommandEvent
& event
);
118 void OnCancel(wxCommandEvent
& event
);
120 // update the background colour
121 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
124 DECLARE_NO_COPY_CLASS(wxDialogBase
)
125 DECLARE_EVENT_TABLE()
126 WX_DECLARE_CONTROL_CONTAINER();
130 #if defined(__WXUNIVERSAL__) && !defined(__WXMICROWIN__)
131 #include "wx/univ/dialog.h"
133 #if defined(__WXPALMOS__)
134 #include "wx/palmos/dialog.h"
135 #elif defined(__WXMSW__)
136 #include "wx/msw/dialog.h"
137 #elif defined(__WXMOTIF__)
138 #include "wx/motif/dialog.h"
139 #elif defined(__WXGTK20__)
140 #include "wx/gtk/dialog.h"
141 #elif defined(__WXGTK__)
142 #include "wx/gtk1/dialog.h"
143 #elif defined(__WXMAC__)
144 #include "wx/mac/dialog.h"
145 #elif defined(__WXCOCOA__)
146 #include "wx/cocoa/dialog.h"
147 #elif defined(__WXPM__)
148 #include "wx/os2/dialog.h"
153 // _WX_DIALOG_H_BASE_