1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/dialog.h
3 // Purpose: wxDialog class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "dialog.h"
21 extern WXDLLEXPORT_DATA(const wxChar
*) wxDialogNameStr
;
23 class WXDLLEXPORT wxDialogModalData
;
25 #if wxUSE_TOOLBAR && (defined(__SMARTPHONE__) || defined(__POCKETPC__))
26 class WXDLLEXPORT wxToolBar
;
27 extern WXDLLEXPORT_DATA(const wxChar
*) wxToolBarNameStr
;
31 class WXDLLEXPORT wxDialog
: public wxDialogBase
34 wxDialog() { Init(); }
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
)
46 (void)Create(parent
, id
, title
, pos
, size
, style
, name
);
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
);
58 // return true if we're showing the dialog modally
59 virtual bool IsModal() const { return m_modalData
!= NULL
; }
61 // show the dialog modally and return the value passed to EndModal()
62 virtual int ShowModal();
64 // may be called to terminate the dialog with the given return code
65 virtual void EndModal(int retCode
);
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
,
77 const wxString
& name
);
79 // get the main toolbar
80 wxToolBar
*GetToolBar() const { return m_dialogToolBar
; }
81 #endif // wxUSE_TOOLBAR && __POCKETPC__
84 // implementation only from now on
85 // -------------------------------
87 // override some base class virtuals
88 virtual bool Show(bool show
= true);
93 void OnCharHook(wxKeyEvent
& event
);
94 void OnCloseWindow(wxCloseEvent
& event
);
97 void OnOK(wxCommandEvent
& event
);
98 void OnApply(wxCommandEvent
& event
);
99 void OnCancel(wxCommandEvent
& event
);
101 // Responds to colour changes
102 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
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.
113 WXLRESULT
MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
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
) );
125 // just call Show() or ShowModal()
126 wxDEPRECATED( void SetModal(bool flag
) );
129 wxDEPRECATED( bool IsModalShowing() const );
132 // find the window to use as parent for this dialog if none has been
133 // specified explicitly by the user
136 wxWindow
*FindSuitableParent() const;
138 // common part of all ctors
141 // end either modal or modeless dialog
142 void EndDialog(int rc
);
144 // emulate click of a button with the given id if it's present in the dialog
146 // return true if button was "clicked" or false if we don't have it
147 bool EmulateButtonClickIfPresent(int id
);
149 // handle Escape here
150 virtual bool MSWProcessMessage(WXMSG
* pMsg
);
153 wxWindow
* m_oldFocus
;
154 bool m_endModalCalled
; // allow for closing within InitDialog
156 #if wxUSE_TOOLBAR && defined(__POCKETPC__)
157 wxToolBar
* m_dialogToolBar
;
160 // this pointer is non-NULL only while the modal event loop is running
161 wxDialogModalData
*m_modalData
;
163 DECLARE_DYNAMIC_CLASS(wxDialog
)
164 DECLARE_EVENT_TABLE()
165 DECLARE_NO_COPY_CLASS(wxDialog
)