]> git.saurik.com Git - wxWidgets.git/blob - include/wx/frame.h
correction for Mac OS X
[wxWidgets.git] / include / wx / frame.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/frame.h
3 // Purpose: wxFrame class interface
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 15.11.99
7 // RCS-ID: $Id$
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_FRAME_H_BASE_
13 #define _WX_FRAME_H_BASE_
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 #ifdef __GNUG__
20 #pragma interface "framebase.h"
21 #endif
22
23 #include "wx/window.h" // the base class
24 #include "wx/icon.h" // for m_icon
25
26 // the default names for various classs
27 WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr;
28 WXDLLEXPORT_DATA(extern const wxChar*) wxStatusLineNameStr;
29 WXDLLEXPORT_DATA(extern const wxChar*) wxToolBarNameStr;
30 WXDLLEXPORT_DATA(extern wxWindow*) wxWndHook;
31
32 class WXDLLEXPORT wxMenuBar;
33 class WXDLLEXPORT wxStatusBar;
34 class WXDLLEXPORT wxToolBar;
35
36 // Styles for ShowFullScreen
37 #define wxFULLSCREEN_NOMENUBAR 0x01
38 #define wxFULLSCREEN_NOTOOLBAR 0x02
39 #define wxFULLSCREEN_NOSTATUSBAR 0x04
40 #define wxFULLSCREEN_NOBORDER 0x08
41 #define wxFULLSCREEN_NOCAPTION 0x10
42 #define wxFULLSCREEN_ALL (wxFULLSCREEN_NOMENUBAR | wxFULLSCREEN_NOTOOLBAR | wxFULLSCREEN_NOSTATUSBAR | wxFULLSCREEN_NOBORDER | wxFULLSCREEN_NOCAPTION)
43
44 // ----------------------------------------------------------------------------
45 // wxFrame is a top-level window with optional menubar, statusbar and toolbar
46 //
47 // For each of *bars, a frame may have several of them, but only one is
48 // managed by the frame, i.e. resized/moved when the frame is and whose size
49 // is accounted for in client size calculations - all others should be taken
50 // care of manually. The CreateXXXBar() functions create this, main, XXXBar,
51 // but the actual creation is done in OnCreateXXXBar() functions which may be
52 // overridden to create custom objects instead of standard ones when
53 // CreateXXXBar() is called.
54 // ----------------------------------------------------------------------------
55
56 class WXDLLEXPORT wxFrameBase : public wxWindow
57 {
58 public:
59 // construction
60 wxFrameBase();
61 #ifdef __WXMAC_X__
62 virtual ~wxFrameBase() {} // Added min for Mac X
63 #endif
64
65 wxFrame *New(wxWindow *parent,
66 wxWindowID id,
67 const wxString& title,
68 const wxPoint& pos = wxDefaultPosition,
69 const wxSize& size = wxDefaultSize,
70 long style = wxDEFAULT_FRAME_STYLE,
71 const wxString& name = wxFrameNameStr);
72
73 // frame state
74 // -----------
75
76 // maximize = TRUE => maximize, otherwise - restore
77 virtual void Maximize(bool maximize = TRUE) = 0;
78
79 // undo Maximize() or Iconize()
80 virtual void Restore() = 0;
81
82 // iconize = TRUE => iconize, otherwise - restore
83 virtual void Iconize(bool iconize = TRUE) = 0;
84
85 // return TRUE if the frame is maximized
86 virtual bool IsMaximized() const = 0;
87
88 // return TRUE if the frame is iconized
89 virtual bool IsIconized() const = 0;
90
91 // get the frame icon
92 const wxIcon& GetIcon() const { return m_icon; }
93
94 // set the frame icon
95 virtual void SetIcon(const wxIcon& icon) { m_icon = icon; }
96
97 // make the window modal (all other windows unresponsive)
98 virtual void MakeModal(bool modal = TRUE);
99
100 // get the origin of the client area (which may be different from (0, 0)
101 // if the frame has a toolbar) in client coordinates
102 virtual wxPoint GetClientAreaOrigin() const;
103
104 // menu bar functions
105 // ------------------
106
107 virtual void SetMenuBar(wxMenuBar *menubar) = 0;
108 virtual wxMenuBar *GetMenuBar() const { return m_frameMenuBar; }
109
110 // call this to simulate a menu command
111 bool Command(int id) { return ProcessCommand(id); }
112
113 // process menu command: returns TRUE if processed
114 bool ProcessCommand(int id);
115
116 // status bar functions
117 // --------------------
118 #if wxUSE_STATUSBAR
119 // create the main status bar by calling OnCreateStatusBar()
120 virtual wxStatusBar* CreateStatusBar(int number = 1,
121 long style = wxST_SIZEGRIP,
122 wxWindowID id = 0,
123 const wxString& name =
124 wxStatusLineNameStr);
125 // return a new status bar
126 virtual wxStatusBar *OnCreateStatusBar(int number,
127 long style,
128 wxWindowID id,
129 const wxString& name);
130 // get the main status bar
131 virtual wxStatusBar *GetStatusBar() const { return m_frameStatusBar; }
132
133 // sets the main status bar
134 void SetStatusBar(wxStatusBar *statBar) { m_frameStatusBar = statBar; }
135
136 // forward these to status bar
137 virtual void SetStatusText(const wxString &text, int number = 0);
138 virtual void SetStatusWidths(int n, const int widths_field[]);
139 #endif // wxUSE_STATUSBAR
140
141 // toolbar functions
142 // -----------------
143 #if wxUSE_TOOLBAR
144 // create main toolbar bycalling OnCreateToolBar()
145 virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER|wxTB_HORIZONTAL,
146 wxWindowID id = -1,
147 const wxString& name = wxToolBarNameStr);
148 // return a new toolbar
149 virtual wxToolBar *OnCreateToolBar(long style,
150 wxWindowID id,
151 const wxString& name );
152
153 // get/set the main toolbar
154 virtual wxToolBar *GetToolBar() const { return m_frameToolBar; }
155 virtual void SetToolBar(wxToolBar *toolbar) { m_frameToolBar = toolbar; }
156 #endif // wxUSE_TOOLBAR
157
158 // old functions, use the new ones instead!
159 #if WXWIN_COMPATIBILITY_2
160 bool Iconized() const { return IsIconized(); }
161 #endif // WXWIN_COMPATIBILITY_2
162
163 // implementation only from now on
164 // -------------------------------
165
166 // override some base class virtuals
167 virtual bool Destroy();
168 virtual bool IsTopLevel() const { return TRUE; }
169
170 // event handlers
171 void OnIdle(wxIdleEvent& event);
172 void OnCloseWindow(wxCloseEvent& event);
173 void OnMenuHighlight(wxMenuEvent& event);
174 void OnSize(wxSizeEvent& event);
175 // this should go away, but for now it's called from docview.cpp,
176 // so should be there for all platforms
177 void OnActivate(wxActivateEvent &WXUNUSED(event)) { }
178
179 // send wxUpdateUIEvents for all menu items (called from OnIdle())
180 void DoMenuUpdates();
181 void DoMenuUpdates(wxMenu* menu, wxWindow* focusWin);
182
183 protected:
184 // the frame main menu/status/tool bars
185 // ------------------------------------
186
187 // this (non virtual!) function should be called from dtor to delete the
188 // main menubar, statusbar and toolbar (if any)
189 void DeleteAllBars();
190
191 wxMenuBar *m_frameMenuBar;
192
193 #if wxUSE_STATUSBAR
194 // override to update status bar position (or anything else) when
195 // something changes
196 virtual void PositionStatusBar() { }
197
198 // show the help string for this menu item in the given status bar: the
199 // status bar pointer can be NULL; return TRUE if help was shown
200 bool ShowMenuHelp(wxStatusBar *statbar, int id);
201
202 wxStatusBar *m_frameStatusBar;
203 #endif // wxUSE_STATUSBAR
204
205 #if wxUSE_TOOLBAR
206 // override to update status bar position (or anything else) when
207 // something changes
208 virtual void PositionToolBar() { }
209
210 wxToolBar *m_frameToolBar;
211 #endif // wxUSE_TOOLBAR
212
213 // the frame client to screen translation should take account of the
214 // toolbar which may shift the origin of the client area
215 virtual void DoClientToScreen(int *x, int *y) const;
216 virtual void DoScreenToClient(int *x, int *y) const;
217
218 // the frame icon
219 wxIcon m_icon;
220
221 DECLARE_EVENT_TABLE()
222 };
223
224 // include the real class declaration
225 #if defined(__WXMSW__)
226 #include "wx/msw/frame.h"
227 #elif defined(__WXMOTIF__)
228 #include "wx/motif/frame.h"
229 #elif defined(__WXGTK__)
230 #include "wx/gtk/frame.h"
231 #elif defined(__WXQT__)
232 #include "wx/qt/frame.h"
233 #elif defined(__WXMAC__)
234 #include "wx/mac/frame.h"
235 #elif defined(__WXPM__)
236 #include "wx/os2/frame.h"
237 #elif defined(__WXSTUBS__)
238 #include "wx/stubs/frame.h"
239 #endif
240
241 #endif
242 // _WX_FRAME_H_BASE_