1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxFrame class interface
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_FRAME_H_BASE_
13 #define _WX_FRAME_H_BASE_
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 #include "wx/toplevel.h" // the base class
20 #include "wx/statusbr.h"
22 // the default names for various classs
23 extern WXDLLIMPEXP_DATA_CORE(const char) wxStatusLineNameStr
[];
24 extern WXDLLIMPEXP_DATA_CORE(const char) wxToolBarNameStr
[];
26 class WXDLLIMPEXP_FWD_CORE wxFrame
;
27 class WXDLLIMPEXP_FWD_CORE wxMenuBar
;
28 class WXDLLIMPEXP_FWD_CORE wxMenuItem
;
29 class WXDLLIMPEXP_FWD_CORE wxStatusBar
;
30 class WXDLLIMPEXP_FWD_CORE wxToolBar
;
32 // ----------------------------------------------------------------------------
34 // ----------------------------------------------------------------------------
36 // wxFrame-specific (i.e. not for wxDialog) styles
38 // Also see the bit summary table in wx/toplevel.h.
39 #define wxFRAME_NO_TASKBAR 0x0002 // No taskbar button (MSW only)
40 #define wxFRAME_TOOL_WINDOW 0x0004 // No taskbar button, no system menu
41 #define wxFRAME_FLOAT_ON_PARENT 0x0008 // Always above its parent
43 // ----------------------------------------------------------------------------
44 // wxFrame is a top-level window with optional menubar, statusbar and toolbar
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 // ----------------------------------------------------------------------------
55 class WXDLLIMPEXP_CORE wxFrameBase
: public wxTopLevelWindow
60 virtual ~wxFrameBase();
62 wxFrame
*New(wxWindow
*parent
,
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
);
73 // get the origin of the client area (which may be different from (0, 0)
74 // if the frame has a toolbar) in client coordinates
75 virtual wxPoint
GetClientAreaOrigin() const;
82 virtual void SetMenuBar(wxMenuBar
*menubar
);
83 virtual wxMenuBar
*GetMenuBar() const { return m_frameMenuBar
; }
85 // find the item by id in the frame menu bar: this is an internal function
86 // and exists mainly in order to be overridden in the MDI parent frame
87 // which also looks at its active child menu bar
88 virtual wxMenuItem
*FindItemInMenuBar(int menuId
) const;
90 // generate menu command corresponding to the given menu item
92 // returns true if processed
93 bool ProcessCommand(wxMenuItem
*item
);
95 // generate menu command corresponding to the given menu command id
97 // returns true if processed
98 bool ProcessCommand(int winid
);
100 bool ProcessCommand(int WXUNUSED(winid
)) { return false; }
101 #endif // wxUSE_MENUS
103 // status bar functions
104 // --------------------
106 // create the main status bar by calling OnCreateStatusBar()
107 virtual wxStatusBar
* CreateStatusBar(int number
= 1,
108 long style
= wxSTB_DEFAULT_STYLE
,
109 wxWindowID winid
= 0,
110 const wxString
& name
= wxStatusLineNameStr
);
111 // return a new status bar
112 virtual wxStatusBar
*OnCreateStatusBar(int number
,
115 const wxString
& name
);
116 // get the main status bar
117 virtual wxStatusBar
*GetStatusBar() const { return m_frameStatusBar
; }
119 // sets the main status bar
120 virtual void SetStatusBar(wxStatusBar
*statBar
);
122 // forward these to status bar
123 virtual void SetStatusText(const wxString
&text
, int number
= 0);
124 virtual void SetStatusWidths(int n
, const int widths_field
[]);
125 void PushStatusText(const wxString
&text
, int number
= 0);
126 void PopStatusText(int number
= 0);
128 // set the status bar pane the help will be shown in
129 void SetStatusBarPane(int n
) { m_statusBarPane
= n
; }
130 int GetStatusBarPane() const { return m_statusBarPane
; }
131 #endif // wxUSE_STATUSBAR
137 // create main toolbar bycalling OnCreateToolBar()
138 virtual wxToolBar
* CreateToolBar(long style
= -1,
139 wxWindowID winid
= wxID_ANY
,
140 const wxString
& name
= wxToolBarNameStr
);
141 // return a new toolbar
142 virtual wxToolBar
*OnCreateToolBar(long style
,
144 const wxString
& name
);
146 // get/set the main toolbar
147 virtual wxToolBar
*GetToolBar() const { return m_frameToolBar
; }
148 virtual void SetToolBar(wxToolBar
*toolbar
);
149 #endif // wxUSE_TOOLBAR
151 // implementation only from now on
152 // -------------------------------
157 void OnMenuOpen(wxMenuEvent
& event
);
158 void OnMenuClose(wxMenuEvent
& event
);
159 void OnMenuHighlight(wxMenuEvent
& event
);
160 #endif // wxUSE_STATUSBAR
162 // send wxUpdateUIEvents for all menu items in the menubar,
163 // or just for menu if non-NULL
164 virtual void DoMenuUpdates(wxMenu
* menu
= NULL
);
165 #endif // wxUSE_MENUS
167 // do the UI update processing for this window
168 virtual void UpdateWindowUI(long flags
= wxUPDATE_UI_NONE
);
170 // Implement internal behaviour (menu updating on some platforms)
171 virtual void OnInternalIdle();
173 #if wxUSE_MENUS || wxUSE_TOOLBAR
174 // show help text for the currently selected menu or toolbar item
175 // (typically in the status bar) or hide it and restore the status bar text
176 // originally shown before the menu was opened if show == false
177 virtual void DoGiveHelp(const wxString
& text
, bool show
);
180 virtual bool IsClientAreaChild(const wxWindow
*child
) const
182 return !IsOneOfBars(child
) && wxTopLevelWindow::IsClientAreaChild(child
);
186 // the frame main menu/status/tool bars
187 // ------------------------------------
189 // this (non virtual!) function should be called from dtor to delete the
190 // main menubar, statusbar and toolbar (if any)
191 void DeleteAllBars();
193 // test whether this window makes part of the frame
194 virtual bool IsOneOfBars(const wxWindow
*win
) const;
197 // override to update menu bar position when the frame size changes
198 virtual void PositionMenuBar() { }
200 // override to do something special when the menu bar is being removed
202 virtual void DetachMenuBar();
204 // override to do something special when the menu bar is attached to the
206 virtual void AttachMenuBar(wxMenuBar
*menubar
);
208 // Return true if we should update the menu item state from idle event
209 // handler or false if we should delay it until the menu is opened.
210 static bool ShouldUpdateMenuFromIdle();
212 wxMenuBar
*m_frameMenuBar
;
213 #endif // wxUSE_MENUS
215 #if wxUSE_STATUSBAR && (wxUSE_MENUS || wxUSE_TOOLBAR)
216 // the saved status bar text overwritten by DoGiveHelp()
217 wxString m_oldStatusText
;
219 // the last help string we have shown in the status bar
220 wxString m_lastHelpShown
;
224 // override to update status bar position (or anything else) when
226 virtual void PositionStatusBar() { }
228 // show the help string for the given menu item using DoGiveHelp() if the
229 // given item does have a help string (as determined by FindInMenuBar()),
230 // return false if there is no help for such item
231 bool ShowMenuHelp(int helpid
);
233 wxStatusBar
*m_frameStatusBar
;
234 #endif // wxUSE_STATUSBAR
240 // override to update status bar position (or anything else) when
242 virtual void PositionToolBar() { }
244 wxToolBar
*m_frameToolBar
;
245 #endif // wxUSE_TOOLBAR
247 #if wxUSE_MENUS && wxUSE_STATUSBAR
248 DECLARE_EVENT_TABLE()
249 #endif // wxUSE_MENUS && wxUSE_STATUSBAR
251 wxDECLARE_NO_COPY_CLASS(wxFrameBase
);
254 // include the real class declaration
255 #if defined(__WXUNIVERSAL__) // && !defined(__WXMICROWIN__)
256 #include "wx/univ/frame.h"
257 #else // !__WXUNIVERSAL__
258 #if defined(__WXMSW__)
259 #include "wx/msw/frame.h"
260 #elif defined(__WXGTK20__)
261 #include "wx/gtk/frame.h"
262 #elif defined(__WXGTK__)
263 #include "wx/gtk1/frame.h"
264 #elif defined(__WXMOTIF__)
265 #include "wx/motif/frame.h"
266 #elif defined(__WXMAC__)
267 #include "wx/osx/frame.h"
268 #elif defined(__WXCOCOA__)
269 #include "wx/cocoa/frame.h"
270 #elif defined(__WXPM__)
271 #include "wx/os2/frame.h"