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