]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/dialog.h
ed6efac8347a9e2a069479113c6d1dad92bbc202
[wxWidgets.git] / include / wx / msw / dialog.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/dialog.h
3 // Purpose: wxDialog class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_DIALOG_H_
13 #define _WX_DIALOG_H_
14
15 #include "wx/panel.h"
16
17 extern WXDLLEXPORT_DATA(const wxChar) wxDialogNameStr[];
18
19 class WXDLLEXPORT wxDialogModalData;
20
21 #if wxUSE_TOOLBAR && (defined(__SMARTPHONE__) || defined(__POCKETPC__))
22 class WXDLLEXPORT wxToolBar;
23 extern WXDLLEXPORT_DATA(const wxChar) wxToolBarNameStr[];
24 #endif
25
26 // Dialog boxes
27 class WXDLLEXPORT wxDialog : public wxDialogBase
28 {
29 public:
30 wxDialog() { Init(); }
31
32 // full ctor
33 wxDialog(wxWindow *parent, wxWindowID id,
34 const wxString& title,
35 const wxPoint& pos = wxDefaultPosition,
36 const wxSize& size = wxDefaultSize,
37 long style = wxDEFAULT_DIALOG_STYLE,
38 const wxString& name = wxDialogNameStr)
39 {
40 Init();
41
42 (void)Create(parent, id, title, pos, size, style, name);
43 }
44
45 bool Create(wxWindow *parent, wxWindowID id,
46 const wxString& title,
47 const wxPoint& pos = wxDefaultPosition,
48 const wxSize& size = wxDefaultSize,
49 long style = wxDEFAULT_DIALOG_STYLE,
50 const wxString& name = wxDialogNameStr);
51
52 virtual ~wxDialog();
53
54 // return true if we're showing the dialog modally
55 virtual bool IsModal() const { return m_modalData != NULL; }
56
57 // show the dialog modally and return the value passed to EndModal()
58 virtual int ShowModal();
59
60 // may be called to terminate the dialog with the given return code
61 virtual void EndModal(int retCode);
62
63
64 // we treat dialog toolbars specially under Windows CE
65 #if wxUSE_TOOLBAR && defined(__POCKETPC__)
66 // create main toolbar by calling OnCreateToolBar()
67 virtual wxToolBar* CreateToolBar(long style = -1,
68 wxWindowID winid = wxID_ANY,
69 const wxString& name = wxToolBarNameStr);
70 // return a new toolbar
71 virtual wxToolBar *OnCreateToolBar(long style,
72 wxWindowID winid,
73 const wxString& name );
74
75 // get the main toolbar
76 wxToolBar *GetToolBar() const { return m_dialogToolBar; }
77 #endif // wxUSE_TOOLBAR && __POCKETPC__
78
79
80 // implementation only from now on
81 // -------------------------------
82
83 // override some base class virtuals
84 virtual bool Show(bool show = true);
85
86 virtual void Raise();
87
88 // event handlers
89 void OnCloseWindow(wxCloseEvent& event);
90
91 // Standard buttons
92 void OnOK(wxCommandEvent& event);
93 void OnApply(wxCommandEvent& event);
94 void OnCancel(wxCommandEvent& event);
95
96 // Responds to colour changes
97 void OnSysColourChanged(wxSysColourChangedEvent& event);
98
99 #ifdef __POCKETPC__
100 // Responds to the OK button in a PocketPC titlebar. This
101 // can be overridden, or you can change the id used for
102 // sending the event with SetAffirmativeId. Returns false
103 // if the event was not processed.
104 virtual bool DoOK();
105 #endif
106
107 // Windows callbacks
108 WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
109
110 #if WXWIN_COMPATIBILITY_2_6
111 // use the other ctor
112 wxDEPRECATED( wxDialog(wxWindow *parent,
113 const wxString& title, bool modal,
114 int x = wxDefaultCoord, int y = wxDefaultCoord, int width = 500, int height = 500,
115 long style = wxDEFAULT_DIALOG_STYLE,
116 const wxString& name = wxDialogNameStr) );
117
118 // just call Show() or ShowModal()
119 wxDEPRECATED( void SetModal(bool flag) );
120
121 // use IsModal()
122 wxDEPRECATED( bool IsModalShowing() const );
123 #endif // WXWIN_COMPATIBILITY_2_6
124
125 protected:
126 // find the window to use as parent for this dialog if none has been
127 // specified explicitly by the user
128 //
129 // may return NULL
130 wxWindow *FindSuitableParent() const;
131
132 // common part of all ctors
133 void Init();
134
135 // end either modal or modeless dialog
136 void EndDialog(int rc);
137
138 private:
139 wxWindow* m_oldFocus;
140 bool m_endModalCalled; // allow for closing within InitDialog
141
142 #if wxUSE_TOOLBAR && defined(__POCKETPC__)
143 wxToolBar* m_dialogToolBar;
144 #endif
145
146 // this pointer is non-NULL only while the modal event loop is running
147 wxDialogModalData *m_modalData;
148
149 DECLARE_DYNAMIC_CLASS(wxDialog)
150 DECLARE_EVENT_TABLE()
151 DECLARE_NO_COPY_CLASS(wxDialog)
152 };
153
154 #endif
155 // _WX_DIALOG_H_