]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cocoa/dialog.h
Further wxAUI commits
[wxWidgets.git] / include / wx / cocoa / dialog.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/cocoa/dialog.h
3 // Purpose: wxDialog class
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2002/12/15
7 // RCS-ID: $Id$
8 // Copyright: David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_COCOA_DIALOG_H_
13 #define _WX_COCOA_DIALOG_H_
14
15 #include "wx/defs.h"
16 // NOTE: we don't need panel.h, but other things expect it to be included
17 #include "wx/panel.h"
18 #include "wx/cocoa/NSPanel.h"
19
20 WXDLLEXPORT_DATA(extern const wxChar) wxDialogNameStr[];
21
22 // ========================================================================
23 // wxDialog
24 // ========================================================================
25 class WXDLLEXPORT wxDialog : public wxDialogBase, protected wxCocoaNSPanel
26 {
27 DECLARE_DYNAMIC_CLASS(wxDialog)
28 DECLARE_EVENT_TABLE()
29 WX_DECLARE_COCOA_OWNER(NSPanel,NSWindow,NSWindow)
30 // ------------------------------------------------------------------------
31 // initialization
32 // ------------------------------------------------------------------------
33 public:
34 wxDialog() { Init(); }
35
36 #if WXWIN_COMPATIBILITY_2_6
37 // Constructor with a modal flag, but no window id - the old convention
38 wxDialog(wxWindow *parent,
39 const wxString& title, bool WXUNUSED(modal),
40 int x = wxDefaultCoord, int y= wxDefaultCoord, int width = 500, int height = 500,
41 long style = wxDEFAULT_DIALOG_STYLE,
42 const wxString& name = wxDialogNameStr)
43 {
44 Init();
45 Create(parent, wxID_ANY, title, wxPoint(x, y), wxSize(width, height),
46 style, name);
47 }
48 #endif // WXWIN_COMPATIBILITY_2_6
49
50 // Constructor with no modal flag - the new convention.
51 wxDialog(wxWindow *parent, wxWindowID winid,
52 const wxString& title,
53 const wxPoint& pos = wxDefaultPosition,
54 const wxSize& size = wxDefaultSize,
55 long style = wxDEFAULT_DIALOG_STYLE,
56 const wxString& name = wxDialogNameStr)
57 {
58 Init();
59 Create(parent, winid, title, pos, size, style, name);
60 }
61
62 bool Create(wxWindow *parent, wxWindowID winid,
63 const wxString& title,
64 const wxPoint& pos = wxDefaultPosition,
65 const wxSize& size = wxDefaultSize,
66 long style = wxDEFAULT_DIALOG_STYLE,
67 const wxString& name = wxDialogNameStr);
68
69 ~wxDialog();
70 protected:
71 void Init();
72
73 // ------------------------------------------------------------------------
74 // Cocoa specifics
75 // ------------------------------------------------------------------------
76 protected:
77 virtual void CocoaDelegate_windowWillClose(void);
78 virtual bool Cocoa_canBecomeMainWindow(bool &canBecome)
79 { canBecome = true; return true; }
80
81 // ------------------------------------------------------------------------
82 // Implementation
83 // ------------------------------------------------------------------------
84 public:
85 virtual bool Show(bool show = true);
86
87 void SetModal(bool flag);
88 virtual bool IsModal() const { return m_isModal; }
89 bool m_isModal;
90
91 // For now, same as Show(true) but returns return code
92 virtual int ShowModal();
93
94 // may be called to terminate the dialog with the given return code
95 virtual void EndModal(int retCode);
96
97 // ------------------------------------------------------------------------
98 // Event handlers
99 // ------------------------------------------------------------------------
100 protected:
101 void OnCloseWindow(wxCloseEvent& event);
102 // Standard buttons
103 void OnOK(wxCommandEvent& event);
104 void OnApply(wxCommandEvent& event);
105 void OnCancel(wxCommandEvent& event);
106
107 // end either modal or modeless dialog
108 void EndDialog(int rc);
109
110 };
111
112 #endif // _WX_COCOA_DIALOG_H_