]>
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 and Markus Holzem | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_DIALOG_H_ | |
13 | #define _WX_DIALOG_H_ | |
14 | ||
15 | #ifdef __GNUG__ | |
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 wxWindowDisabler; | |
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 | long modalStyle = modal ? wxDIALOG_MODAL : wxDIALOG_MODELESS ; | |
39 | Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), | |
40 | style | modalStyle, name); | |
41 | } | |
42 | ||
43 | // Constructor with no modal flag - the new convention. | |
44 | wxDialog(wxWindow *parent, wxWindowID id, | |
45 | const wxString& title, | |
46 | const wxPoint& pos = wxDefaultPosition, | |
47 | const wxSize& size = wxDefaultSize, | |
48 | long style = wxDEFAULT_DIALOG_STYLE, | |
49 | const wxString& name = wxDialogNameStr) | |
50 | { | |
51 | Create(parent, id, title, pos, size, style, name); | |
52 | } | |
53 | ||
54 | bool Create(wxWindow *parent, wxWindowID id, | |
55 | const wxString& title, | |
56 | const wxPoint& pos = wxDefaultPosition, | |
57 | const wxSize& size = wxDefaultSize, | |
58 | long style = wxDEFAULT_DIALOG_STYLE, | |
59 | const wxString& name = wxDialogNameStr); | |
60 | ||
61 | virtual ~wxDialog(); | |
62 | ||
63 | void SetModal(bool flag); | |
64 | virtual bool IsModal() const; | |
65 | ||
66 | // For now, same as Show(TRUE) but returns return code | |
67 | virtual int ShowModal(); | |
68 | ||
69 | // may be called to terminate the dialog with the given return code | |
70 | virtual void EndModal(int retCode); | |
71 | ||
72 | // returns TRUE if we're in a modal loop | |
73 | bool IsModalShowing() const; | |
74 | ||
75 | // implementation only from now on | |
76 | // ------------------------------- | |
77 | ||
78 | // override some base class virtuals | |
79 | virtual bool Show(bool show = TRUE); | |
80 | ||
81 | // event handlers | |
82 | bool OnClose(); | |
83 | void OnCharHook(wxKeyEvent& event); | |
84 | void OnCloseWindow(wxCloseEvent& event); | |
85 | ||
86 | // Standard buttons | |
87 | void OnOK(wxCommandEvent& event); | |
88 | void OnApply(wxCommandEvent& event); | |
89 | void OnCancel(wxCommandEvent& event); | |
90 | ||
91 | // Responds to colour changes | |
92 | void OnSysColourChanged(wxSysColourChangedEvent& event); | |
93 | ||
94 | // Windows callbacks | |
95 | long MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); | |
96 | ||
97 | #if wxUSE_CTL3D | |
98 | virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, | |
99 | WXUINT message, WXWPARAM wParam, WXLPARAM lParam); | |
100 | #endif // wxUSE_CTL3D | |
101 | ||
102 | protected: | |
103 | // find the window to use as parent for this dialog if none has been | |
104 | // specified explicitly by the user | |
105 | // | |
106 | // may return NULL | |
107 | wxWindow *FindSuitableParent() const; | |
108 | ||
109 | // show modal dialog and enter modal loop | |
110 | void DoShowModal(); | |
111 | ||
112 | // common part of all ctors | |
113 | void Init(); | |
114 | ||
115 | private: | |
116 | wxWindow *m_oldFocus; | |
117 | ||
118 | // while we are showing a modal dialog we disable the other windows using | |
119 | // this object | |
120 | wxWindowDisabler *m_windowDisabler; | |
121 | ||
122 | DECLARE_DYNAMIC_CLASS(wxDialog) | |
123 | DECLARE_EVENT_TABLE() | |
124 | }; | |
125 | ||
126 | #endif | |
127 | // _WX_DIALOG_H_ |