]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/frame.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxFrame class interface
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_FRAME_H_BASE_
13 #define _WX_FRAME_H_BASE_
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
20 #pragma interface "framebase.h"
23 #include "wx/window.h" // the base class
24 #include "wx/icon.h" // for m_icon
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
;
31 class WXDLLEXPORT wxMenuBar
;
32 class WXDLLEXPORT wxStatusBar
;
33 class WXDLLEXPORT wxToolBar
;
35 // ----------------------------------------------------------------------------
36 // wxFrame is a top-level window with optional menubar, statusbar and toolbar
38 // For each of *bars, a frame may have several of them, but only one is
39 // managed by the frame, i.e. resized/moved when the frame is and whose size
40 // is accounted for in client size calculations - all others should be taken
41 // care of manually. The CreateXXXBar() functions create this, main, XXXBar,
42 // but the actual creation is done in OnCreateXXXBar() functions which may be
43 // overridden to create custom objects instead of standard ones when
44 // CreateXXXBar() is called.
45 // ----------------------------------------------------------------------------
47 class WXDLLEXPORT wxFrameBase
: public wxWindow
53 wxFrame
*New(wxWindow
*parent
,
55 const wxString
& title
,
56 const wxPoint
& pos
= wxDefaultPosition
,
57 const wxSize
& size
= wxDefaultSize
,
58 long style
= wxDEFAULT_FRAME_STYLE
,
59 const wxString
& name
= wxFrameNameStr
);
64 // maximize = TRUE => maximize, otherwise - restore
65 virtual void Maximize(bool maximize
= TRUE
) = 0;
67 // undo Maximize() or Iconize()
68 virtual void Restore() = 0;
70 // iconize = TRUE => iconize, otherwise - restore
71 virtual void Iconize(bool iconize
= TRUE
) = 0;
73 // return TRUE if the frame is maximized
74 virtual bool IsMaximized() const = 0;
76 // return TRUE if the frame is iconized
77 virtual bool IsIconized() const = 0;
80 const wxIcon
& GetIcon() const { return m_icon
; }
83 virtual void SetIcon(const wxIcon
& icon
) { m_icon
= icon
; }
85 // make the window modal (all other windows unresponsive)
86 virtual void MakeModal(bool modal
= TRUE
);
91 virtual void SetMenuBar(wxMenuBar
*menubar
) = 0;
92 virtual wxMenuBar
*GetMenuBar() const { return m_frameMenuBar
; }
94 // call this to simulate a menu command
95 bool Command(int id
) { return ProcessCommand(id
); }
97 // process menu command: returns TRUE if processed
98 bool ProcessCommand(int id
);
100 // status bar functions
101 // --------------------
103 // create the main status bar by calling OnCreateStatusBar()
104 virtual wxStatusBar
* CreateStatusBar(int number
= 1,
105 long style
= wxST_SIZEGRIP
,
107 const wxString
& name
=
108 wxStatusLineNameStr
);
109 // return a new status bar
110 virtual wxStatusBar
*OnCreateStatusBar(int number
,
113 const wxString
& name
);
114 // get the main status bar
115 virtual wxStatusBar
*GetStatusBar() const { return m_frameStatusBar
; }
117 // sets the main status bar
118 void SetStatusBar(wxStatusBar
*statBar
) { m_frameStatusBar
= statBar
; }
120 // forward these to status bar
121 virtual void SetStatusText(const wxString
&text
, int number
= 0);
122 virtual void SetStatusWidths(int n
, const int widths_field
[]);
123 #endif // wxUSE_STATUSBAR
128 // create main toolbar bycalling OnCreateToolBar()
129 virtual wxToolBar
* CreateToolBar(long style
= wxNO_BORDER
|wxTB_HORIZONTAL
,
131 const wxString
& name
= wxToolBarNameStr
);
132 // return a new toolbar
133 virtual wxToolBar
*OnCreateToolBar(long style
,
135 const wxString
& name
);
137 // get/set the main toolbar
138 virtual wxToolBar
*GetToolBar() const { return m_frameToolBar
; }
139 virtual void SetToolBar(wxToolBar
*toolbar
) { m_frameToolBar
= toolbar
; }
140 #endif // wxUSE_TOOLBAR
142 // old functions, use the new ones instead!
143 #if WXWIN_COMPATIBILITY_2
144 bool Iconized() const { return IsIconized(); }
145 #endif // WXWIN_COMPATIBILITY_2
147 // implementation only from now on
148 // -------------------------------
150 // override some base class virtuals
151 virtual bool Destroy();
152 virtual bool IsTopLevel() const { return TRUE
; }
155 void OnIdle(wxIdleEvent
& event
);
156 void OnCloseWindow(wxCloseEvent
& event
);
157 void OnMenuHighlight(wxMenuEvent
& event
);
158 void OnSize(wxSizeEvent
& event
);
159 // this should go away, but for now it's called from docview.cpp,
160 // so should be there for all platforms
161 void OnActivate(wxActivateEvent
&WXUNUSED(event
)) { }
163 // send wxUpdateUIEvents for all menu items (called from OnIdle())
164 void DoMenuUpdates();
165 void DoMenuUpdates(wxMenu
* menu
, wxWindow
* focusWin
);
168 // the frame main menu/status/tool bars
169 // ------------------------------------
171 // this (non virtual!) function should be called from dtor to delete the
172 // main menubar, statusbar and toolbar (if any)
173 void DeleteAllBars();
175 wxMenuBar
*m_frameMenuBar
;
178 // override to update status bar position (or anything else) when
180 virtual void PositionStatusBar() { }
182 wxStatusBar
*m_frameStatusBar
;
183 #endif // wxUSE_STATUSBAR
186 // override to update status bar position (or anything else) when
188 virtual void PositionToolBar() { }
190 wxToolBar
*m_frameToolBar
;
191 #endif // wxUSE_TOOLBAR
196 DECLARE_EVENT_TABLE()
199 // include the real class declaration
200 #if defined(__WXMSW__)
201 #include "wx/msw/frame.h"
202 #elif defined(__WXMOTIF__)
203 #include "wx/motif/frame.h"
204 #elif defined(__WXGTK__)
205 #include "wx/gtk/frame.h"
206 #elif defined(__WXQT__)
207 #include "wx/qt/frame.h"
208 #elif defined(__WXMAC__)
209 #include "wx/mac/frame.h"
210 #elif defined(__WXPM__)
211 #include "wx/os2/frame.h"
212 #elif defined(__WXSTUBS__)
213 #include "wx/stubs/frame.h"