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