]> git.saurik.com Git - wxWidgets.git/blob - include/wx/frame.h
(blind) fixes for Motif compilation
[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
62 wxFrame *New(wxWindow *parent,
63 wxWindowID id,
64 const wxString& title,
65 const wxPoint& pos = wxDefaultPosition,
66 const wxSize& size = wxDefaultSize,
67 long style = wxDEFAULT_FRAME_STYLE,
68 const wxString& name = wxFrameNameStr);
69
70 // frame state
71 // -----------
72
73 // maximize = TRUE => maximize, otherwise - restore
74 virtual void Maximize(bool maximize = TRUE) = 0;
75
76 // undo Maximize() or Iconize()
77 virtual void Restore() = 0;
78
79 // iconize = TRUE => iconize, otherwise - restore
80 virtual void Iconize(bool iconize = TRUE) = 0;
81
82 // return TRUE if the frame is maximized
83 virtual bool IsMaximized() const = 0;
84
85 // return TRUE if the frame is iconized
86 virtual bool IsIconized() const = 0;
87
88 // get the frame icon
89 const wxIcon& GetIcon() const { return m_icon; }
90
91 // set the frame icon
92 virtual void SetIcon(const wxIcon& icon) { m_icon = icon; }
93
94 // make the window modal (all other windows unresponsive)
95 virtual void MakeModal(bool modal = TRUE);
96
97 // get the origin of the client area (which may be different from (0, 0)
98 // if the frame has a toolbar) in client coordinates
99 virtual wxPoint GetClientAreaOrigin() const;
100
101 // menu bar functions
102 // ------------------
103
104 virtual void SetMenuBar(wxMenuBar *menubar) = 0;
105 virtual wxMenuBar *GetMenuBar() const { return m_frameMenuBar; }
106
107 // call this to simulate a menu command
108 bool Command(int id) { return ProcessCommand(id); }
109
110 // process menu command: returns TRUE if processed
111 bool ProcessCommand(int id);
112
113 // status bar functions
114 // --------------------
115 #if wxUSE_STATUSBAR
116 // create the main status bar by calling OnCreateStatusBar()
117 virtual wxStatusBar* CreateStatusBar(int number = 1,
118 long style = wxST_SIZEGRIP,
119 wxWindowID id = 0,
120 const wxString& name =
121 wxStatusLineNameStr);
122 // return a new status bar
123 virtual wxStatusBar *OnCreateStatusBar(int number,
124 long style,
125 wxWindowID id,
126 const wxString& name);
127 // get the main status bar
128 virtual wxStatusBar *GetStatusBar() const { return m_frameStatusBar; }
129
130 // sets the main status bar
131 void SetStatusBar(wxStatusBar *statBar) { m_frameStatusBar = statBar; }
132
133 // forward these to status bar
134 virtual void SetStatusText(const wxString &text, int number = 0);
135 virtual void SetStatusWidths(int n, const int widths_field[]);
136 #endif // wxUSE_STATUSBAR
137
138 // toolbar functions
139 // -----------------
140 #if wxUSE_TOOLBAR
141 // create main toolbar bycalling OnCreateToolBar()
142 virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER|wxTB_HORIZONTAL,
143 wxWindowID id = -1,
144 const wxString& name = wxToolBarNameStr);
145 // return a new toolbar
146 virtual wxToolBar *OnCreateToolBar(long style,
147 wxWindowID id,
148 const wxString& name );
149
150 // get/set the main toolbar
151 virtual wxToolBar *GetToolBar() const { return m_frameToolBar; }
152 virtual void SetToolBar(wxToolBar *toolbar) { m_frameToolBar = toolbar; }
153 #endif // wxUSE_TOOLBAR
154
155 // old functions, use the new ones instead!
156 #if WXWIN_COMPATIBILITY_2
157 bool Iconized() const { return IsIconized(); }
158 #endif // WXWIN_COMPATIBILITY_2
159
160 // implementation only from now on
161 // -------------------------------
162
163 // override some base class virtuals
164 virtual bool Destroy();
165 virtual bool IsTopLevel() const { return TRUE; }
166
167 // event handlers
168 void OnIdle(wxIdleEvent& event);
169 void OnCloseWindow(wxCloseEvent& event);
170 void OnMenuHighlight(wxMenuEvent& event);
171 void OnSize(wxSizeEvent& event);
172 // this should go away, but for now it's called from docview.cpp,
173 // so should be there for all platforms
174 void OnActivate(wxActivateEvent &WXUNUSED(event)) { }
175
176 // send wxUpdateUIEvents for all menu items (called from OnIdle())
177 void DoMenuUpdates();
178 void DoMenuUpdates(wxMenu* menu, wxWindow* focusWin);
179
180 protected:
181 // the frame main menu/status/tool bars
182 // ------------------------------------
183
184 // this (non virtual!) function should be called from dtor to delete the
185 // main menubar, statusbar and toolbar (if any)
186 void DeleteAllBars();
187
188 wxMenuBar *m_frameMenuBar;
189
190 #if wxUSE_STATUSBAR
191 // override to update status bar position (or anything else) when
192 // something changes
193 virtual void PositionStatusBar() { }
194
195 // show the help string for this menu item in the given status bar: the
196 // status bar pointer can be NULL; return TRUE if help was shown
197 bool ShowMenuHelp(wxStatusBar *statbar, int id);
198
199 wxStatusBar *m_frameStatusBar;
200 #endif // wxUSE_STATUSBAR
201
202 #if wxUSE_TOOLBAR
203 // override to update status bar position (or anything else) when
204 // something changes
205 virtual void PositionToolBar() { }
206
207 wxToolBar *m_frameToolBar;
208 #endif // wxUSE_TOOLBAR
209
210 // the frame client to screen translation should take account of the
211 // toolbar which may shift the origin of the client area
212 virtual void DoClientToScreen(int *x, int *y) const;
213 virtual void DoScreenToClient(int *x, int *y) const;
214
215 // the frame icon
216 wxIcon m_icon;
217
218 DECLARE_EVENT_TABLE()
219 };
220
221 // include the real class declaration
222 #if defined(__WXMSW__)
223 #include "wx/msw/frame.h"
224 #elif defined(__WXMOTIF__)
225 #include "wx/motif/frame.h"
226 #elif defined(__WXGTK__)
227 #include "wx/gtk/frame.h"
228 #elif defined(__WXQT__)
229 #include "wx/qt/frame.h"
230 #elif defined(__WXMAC__)
231 #include "wx/mac/frame.h"
232 #elif defined(__WXPM__)
233 #include "wx/os2/frame.h"
234 #elif defined(__WXSTUBS__)
235 #include "wx/stubs/frame.h"
236 #endif
237
238 #endif
239 // _WX_FRAME_H_BASE_