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() { }
46 // Modal dialogs have a return code - usually the id of the last
48 void SetReturnCode(int returnCode
) { m_returnCode
= returnCode
; }
49 int GetReturnCode() const { return m_returnCode
; }
51 // The identifier for the affirmative button
52 void SetAffirmativeId(int affirmativeId
) { m_affirmativeId
= affirmativeId
; }
53 int GetAffirmativeId() const { return m_affirmativeId
; }
55 // Identifier for Esc key translation
56 void SetEscapeId(int escapeId
) { m_escapeId
= escapeId
; }
57 int GetEscapeId() const { return m_escapeId
; }
59 #if wxUSE_STATTEXT // && wxUSE_TEXTCTRL
60 // splits text up at newlines and places the
61 // lines into a vertical wxBoxSizer
62 wxSizer
*CreateTextSizer( const wxString
&message
);
63 #endif // wxUSE_STATTEXT // && wxUSE_TEXTCTRL
65 // places buttons into a horizontal wxBoxSizer
66 wxSizer
*CreateButtonSizer( long flags
,
67 bool separated
= false,
68 wxCoord distance
= 0 );
70 wxStdDialogButtonSizer
*CreateStdDialogButtonSizer( long flags
);
71 #endif // wxUSE_BUTTON
74 // emulate click of a button with the given id if it's present in the dialog
76 // return true if button was "clicked" or false if we don't have it
77 bool EmulateButtonClickIfPresent(int id
);
79 // this function is used by OnCharHook() to decide whether the given key
80 // should close the dialog
82 // for most platforms the default implementation (which just checks for
83 // Esc) is sufficient, but Mac port also adds Cmd-. here and other ports
84 // could do something different if needed
85 virtual bool IsEscapeKey(const wxKeyEvent
& event
);
88 // The return code from modal dialog
91 // The identifier for the affirmative button (usually wxID_OK)
94 // The identifier for cancel button (usually wxID_CANCEL)
98 // handle Esc key presses
99 void OnCharHook(wxKeyEvent
& event
);
101 DECLARE_NO_COPY_CLASS(wxDialogBase
)
102 DECLARE_EVENT_TABLE()
103 WX_DECLARE_CONTROL_CONTAINER();
107 #if defined(__WXUNIVERSAL__) && !defined(__WXMICROWIN__)
108 #include "wx/univ/dialog.h"
110 #if defined(__WXPALMOS__)
111 #include "wx/palmos/dialog.h"
112 #elif defined(__WXMSW__)
113 #include "wx/msw/dialog.h"
114 #elif defined(__WXMOTIF__)
115 #include "wx/motif/dialog.h"
116 #elif defined(__WXGTK20__)
117 #include "wx/gtk/dialog.h"
118 #elif defined(__WXGTK__)
119 #include "wx/gtk1/dialog.h"
120 #elif defined(__WXMAC__)
121 #include "wx/mac/dialog.h"
122 #elif defined(__WXCOCOA__)
123 #include "wx/cocoa/dialog.h"
124 #elif defined(__WXPM__)
125 #include "wx/os2/dialog.h"
130 // _WX_DIALOG_H_BASE_