]>
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 | WXDLLEXPORT_DATA(extern const wxChar*) wxDialogNameStr; | |
22 | ||
23 | class WXDLLEXPORT wxDialogModalData; | |
24 | ||
25 | // Dialog boxes | |
26 | class WXDLLEXPORT wxDialog : public wxDialogBase | |
27 | { | |
28 | public: | |
29 | wxDialog() { Init(); } | |
30 | ||
31 | // Constructor with a modal flag, but no window id - the old convention | |
32 | wxDialog(wxWindow *parent, | |
33 | const wxString& title, bool modal, | |
34 | int x = -1, int y= -1, int width = 500, int height = 500, | |
35 | long style = wxDEFAULT_DIALOG_STYLE, | |
36 | const wxString& name = wxDialogNameStr) | |
37 | { | |
38 | Init(); | |
39 | ||
40 | long modalStyle = modal ? wxDIALOG_MODAL : wxDIALOG_MODELESS ; | |
41 | Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), | |
42 | style | modalStyle, name); | |
43 | } | |
44 | ||
45 | // Constructor with no modal flag - the new convention. | |
46 | wxDialog(wxWindow *parent, wxWindowID id, | |
47 | const wxString& title, | |
48 | const wxPoint& pos = wxDefaultPosition, | |
49 | const wxSize& size = wxDefaultSize, | |
50 | long style = wxDEFAULT_DIALOG_STYLE, | |
51 | const wxString& name = wxDialogNameStr) | |
52 | { | |
53 | Init(); | |
54 | ||
55 | (void)Create(parent, id, title, pos, size, style, name); | |
56 | } | |
57 | ||
58 | bool Create(wxWindow *parent, wxWindowID id, | |
59 | const wxString& title, | |
60 | const wxPoint& pos = wxDefaultPosition, | |
61 | const wxSize& size = wxDefaultSize, | |
62 | long style = wxDEFAULT_DIALOG_STYLE, | |
63 | const wxString& name = wxDialogNameStr); | |
64 | ||
65 | virtual ~wxDialog(); | |
66 | ||
67 | void SetModal(bool flag); | |
68 | virtual bool IsModal() const; | |
69 | ||
70 | // For now, same as Show(TRUE) but returns return code | |
71 | virtual int ShowModal(); | |
72 | ||
73 | // may be called to terminate the dialog with the given return code | |
74 | virtual void EndModal(int retCode); | |
75 | ||
76 | // returns TRUE if we're in a modal loop | |
77 | bool IsModalShowing() const; | |
78 | ||
79 | // implementation only from now on | |
80 | // ------------------------------- | |
81 | ||
82 | // override some base class virtuals | |
83 | virtual bool Show(bool show = TRUE); | |
84 | ||
85 | virtual void Raise(); | |
86 | ||
87 | // event handlers | |
88 | void OnCharHook(wxKeyEvent& event); | |
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 | // Windows callbacks | |
100 | WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); | |
101 | ||
102 | #if wxUSE_CTL3D | |
103 | virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, | |
104 | WXUINT message, WXWPARAM wParam, WXLPARAM lParam); | |
105 | #endif // wxUSE_CTL3D | |
106 | ||
107 | protected: | |
108 | // find the window to use as parent for this dialog if none has been | |
109 | // specified explicitly by the user | |
110 | // | |
111 | // may return NULL | |
112 | wxWindow *FindSuitableParent() const; | |
113 | ||
114 | // show modal dialog and enter modal loop | |
115 | void DoShowModal(); | |
116 | ||
117 | // common part of all ctors | |
118 | void Init(); | |
119 | ||
120 | private: | |
121 | wxWindow* m_oldFocus; | |
122 | bool m_endModalCalled; // allow for closing within InitDialog | |
123 | ||
124 | // this pointer is non-NULL only while the modal event loop is running | |
125 | wxDialogModalData *m_modalData; | |
126 | ||
127 | ||
128 | DECLARE_DYNAMIC_CLASS(wxDialog) | |
129 | DECLARE_EVENT_TABLE() | |
130 | DECLARE_NO_COPY_CLASS(wxDialog) | |
131 | }; | |
132 | ||
133 | #endif | |
134 | // _WX_DIALOG_H_ |