]>
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 // 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)
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 WXDLLEXPORT wxFrameBase
: public wxWindow
61 wxFrame
*New(wxWindow
*parent
,
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
);
72 // maximize = TRUE => maximize, otherwise - restore
73 virtual void Maximize(bool maximize
= TRUE
) = 0;
75 // undo Maximize() or Iconize()
76 virtual void Restore() = 0;
78 // iconize = TRUE => iconize, otherwise - restore
79 virtual void Iconize(bool iconize
= TRUE
) = 0;
81 // return TRUE if the frame is maximized
82 virtual bool IsMaximized() const = 0;
84 // return TRUE if the frame is iconized
85 virtual bool IsIconized() const = 0;
88 const wxIcon
& GetIcon() const { return m_icon
; }
91 virtual void SetIcon(const wxIcon
& icon
) { m_icon
= icon
; }
93 // make the window modal (all other windows unresponsive)
94 virtual void MakeModal(bool modal
= TRUE
);
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;
100 // menu bar functions
101 // ------------------
103 virtual void SetMenuBar(wxMenuBar
*menubar
) = 0;
104 virtual wxMenuBar
*GetMenuBar() const { return m_frameMenuBar
; }
106 // call this to simulate a menu command
107 bool Command(int id
) { return ProcessCommand(id
); }
109 // process menu command: returns TRUE if processed
110 bool ProcessCommand(int id
);
112 // status bar functions
113 // --------------------
115 // create the main status bar by calling OnCreateStatusBar()
116 virtual wxStatusBar
* CreateStatusBar(int number
= 1,
117 long style
= wxST_SIZEGRIP
,
119 const wxString
& name
=
120 wxStatusLineNameStr
);
121 // return a new status bar
122 virtual wxStatusBar
*OnCreateStatusBar(int number
,
125 const wxString
& name
);
126 // get the main status bar
127 virtual wxStatusBar
*GetStatusBar() const { return m_frameStatusBar
; }
129 // sets the main status bar
130 void SetStatusBar(wxStatusBar
*statBar
) { m_frameStatusBar
= statBar
; }
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
140 // create main toolbar bycalling OnCreateToolBar()
141 virtual wxToolBar
* CreateToolBar(long style
= wxNO_BORDER
|wxTB_HORIZONTAL
,
143 const wxString
& name
= wxToolBarNameStr
);
144 // return a new toolbar
145 virtual wxToolBar
*OnCreateToolBar(long style
,
147 const wxString
& name
);
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
154 // old functions, use the new ones instead!
155 #if WXWIN_COMPATIBILITY_2
156 bool Iconized() const { return IsIconized(); }
157 #endif // WXWIN_COMPATIBILITY_2
159 // implementation only from now on
160 // -------------------------------
162 // override some base class virtuals
163 virtual bool Destroy();
164 virtual bool IsTopLevel() const { return TRUE
; }
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
)) { }
175 // send wxUpdateUIEvents for all menu items (called from OnIdle())
176 void DoMenuUpdates();
177 void DoMenuUpdates(wxMenu
* menu
, wxWindow
* focusWin
);
180 // the frame main menu/status/tool bars
181 // ------------------------------------
183 // this (non virtual!) function should be called from dtor to delete the
184 // main menubar, statusbar and toolbar (if any)
185 void DeleteAllBars();
187 wxMenuBar
*m_frameMenuBar
;
190 // override to update status bar position (or anything else) when
192 virtual void PositionStatusBar() { }
194 wxStatusBar
*m_frameStatusBar
;
195 #endif // wxUSE_STATUSBAR
198 // override to update status bar position (or anything else) when
200 virtual void PositionToolBar() { }
202 wxToolBar
*m_frameToolBar
;
203 #endif // wxUSE_TOOLBAR
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;
213 DECLARE_EVENT_TABLE()
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"