]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: 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 | // Dialog boxes | |
24 | class WXDLLEXPORT wxDialog : public wxDialogBase | |
25 | { | |
26 | public: | |
27 | wxDialog() { Init(); } | |
28 | ||
29 | // Constructor with a modal flag, but no window id - the old convention | |
30 | wxDialog(wxWindow *parent, | |
31 | const wxString& title, bool modal, | |
32 | int x = -1, int y= -1, int width = 500, int height = 500, | |
33 | long style = wxDEFAULT_DIALOG_STYLE, | |
34 | const wxString& name = wxDialogNameStr) | |
35 | { | |
36 | long modalStyle = modal ? wxDIALOG_MODAL : wxDIALOG_MODELESS ; | |
37 | Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), | |
38 | style | modalStyle, name); | |
39 | } | |
40 | ||
41 | // Constructor with no modal flag - the new convention. | |
42 | wxDialog(wxWindow *parent, wxWindowID id, | |
43 | const wxString& title, | |
44 | const wxPoint& pos = wxDefaultPosition, | |
45 | const wxSize& size = wxDefaultSize, | |
46 | long style = wxDEFAULT_DIALOG_STYLE, | |
47 | const wxString& name = wxDialogNameStr) | |
48 | { | |
49 | Create(parent, id, title, pos, size, style, name); | |
50 | } | |
51 | ||
52 | bool Create(wxWindow *parent, wxWindowID id, | |
53 | const wxString& title, | |
54 | const wxPoint& pos = wxDefaultPosition, | |
55 | const wxSize& size = wxDefaultSize, | |
56 | long style = wxDEFAULT_DIALOG_STYLE, | |
57 | const wxString& name = wxDialogNameStr); | |
58 | ||
59 | ~wxDialog(); | |
60 | ||
61 | // override some base class virtuals | |
62 | virtual bool Destroy(); | |
63 | virtual bool Show(bool show); | |
64 | virtual void Iconize(bool iconize); | |
65 | virtual bool IsIconized() const; | |
66 | ||
67 | virtual bool IsTopLevel() const { return TRUE; } | |
68 | ||
69 | void SetModal(bool flag); | |
70 | virtual bool IsModal() const; | |
71 | ||
72 | // For now, same as Show(TRUE) but returns return code | |
73 | virtual int ShowModal(); | |
74 | ||
75 | // may be called to terminate the dialog with the given return code | |
76 | virtual void EndModal(int retCode); | |
77 | ||
78 | // returns TRUE if we're in a modal loop | |
79 | bool IsModalShowing() const; | |
80 | ||
81 | #if WXWIN_COMPATIBILITY | |
82 | bool Iconized() const { return IsIconized(); }; | |
83 | #endif | |
84 | ||
85 | // implementation only from now on | |
86 | // ------------------------------- | |
87 | ||
88 | // event handlers | |
89 | bool OnClose(); | |
90 | void OnCharHook(wxKeyEvent& event); | |
91 | void OnCloseWindow(wxCloseEvent& event); | |
92 | ||
93 | // Standard buttons | |
94 | void OnOK(wxCommandEvent& event); | |
95 | void OnApply(wxCommandEvent& event); | |
96 | void OnCancel(wxCommandEvent& event); | |
97 | ||
98 | // Responds to colour changes | |
99 | void OnSysColourChanged(wxSysColourChangedEvent& event); | |
100 | ||
101 | // Windows callbacks | |
102 | long MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); | |
103 | ||
104 | #if wxUSE_CTL3D | |
105 | virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, | |
106 | WXUINT message, WXWPARAM wParam, WXLPARAM lParam); | |
107 | #endif // wxUSE_CTL3D | |
108 | ||
109 | protected: | |
110 | // override more base class virtuals | |
111 | virtual void DoSetClientSize(int width, int height); | |
112 | virtual void DoGetPosition(int *x, int *y) 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 | ||
123 | // while we are showing a modal dialog we disable the other windows using | |
124 | // this object | |
125 | class wxWindowDisabler *m_windowDisabler; | |
126 | ||
127 | DECLARE_DYNAMIC_CLASS(wxDialog) | |
128 | DECLARE_EVENT_TABLE() | |
129 | }; | |
130 | ||
131 | #endif | |
132 | // _WX_DIALOG_H_ |