]>
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
);
88 // get the origin of the client area (which may be different from (0, 0)
89 // if the frame has a toolbar) in client coordinates
90 virtual wxPoint
GetClientAreaOrigin() const;
95 virtual void SetMenuBar(wxMenuBar
*menubar
) = 0;
96 virtual wxMenuBar
*GetMenuBar() const { return m_frameMenuBar
; }
98 // call this to simulate a menu command
99 bool Command(int id
) { return ProcessCommand(id
); }
101 // process menu command: returns TRUE if processed
102 bool ProcessCommand(int id
);
104 // status bar functions
105 // --------------------
107 // create the main status bar by calling OnCreateStatusBar()
108 virtual wxStatusBar
* CreateStatusBar(int number
= 1,
109 long style
= wxST_SIZEGRIP
,
111 const wxString
& name
=
112 wxStatusLineNameStr
);
113 // return a new status bar
114 virtual wxStatusBar
*OnCreateStatusBar(int number
,
117 const wxString
& name
);
118 // get the main status bar
119 virtual wxStatusBar
*GetStatusBar() const { return m_frameStatusBar
; }
121 // sets the main status bar
122 void SetStatusBar(wxStatusBar
*statBar
) { m_frameStatusBar
= statBar
; }
124 // forward these to status bar
125 virtual void SetStatusText(const wxString
&text
, int number
= 0);
126 virtual void SetStatusWidths(int n
, const int widths_field
[]);
127 #endif // wxUSE_STATUSBAR
132 // create main toolbar bycalling OnCreateToolBar()
133 virtual wxToolBar
* CreateToolBar(long style
= wxNO_BORDER
|wxTB_HORIZONTAL
,
135 const wxString
& name
= wxToolBarNameStr
);
136 // return a new toolbar
137 virtual wxToolBar
*OnCreateToolBar(long style
,
139 const wxString
& name
);
141 // get/set the main toolbar
142 virtual wxToolBar
*GetToolBar() const { return m_frameToolBar
; }
143 virtual void SetToolBar(wxToolBar
*toolbar
) { m_frameToolBar
= toolbar
; }
144 #endif // wxUSE_TOOLBAR
146 // old functions, use the new ones instead!
147 #if WXWIN_COMPATIBILITY_2
148 bool Iconized() const { return IsIconized(); }
149 #endif // WXWIN_COMPATIBILITY_2
151 // implementation only from now on
152 // -------------------------------
154 // override some base class virtuals
155 virtual bool Destroy();
156 virtual bool IsTopLevel() const { return TRUE
; }
159 void OnIdle(wxIdleEvent
& event
);
160 void OnCloseWindow(wxCloseEvent
& event
);
161 void OnMenuHighlight(wxMenuEvent
& event
);
162 void OnSize(wxSizeEvent
& event
);
163 // this should go away, but for now it's called from docview.cpp,
164 // so should be there for all platforms
165 void OnActivate(wxActivateEvent
&WXUNUSED(event
)) { }
167 // send wxUpdateUIEvents for all menu items (called from OnIdle())
168 void DoMenuUpdates();
169 void DoMenuUpdates(wxMenu
* menu
, wxWindow
* focusWin
);
172 // the frame main menu/status/tool bars
173 // ------------------------------------
175 // this (non virtual!) function should be called from dtor to delete the
176 // main menubar, statusbar and toolbar (if any)
177 void DeleteAllBars();
179 wxMenuBar
*m_frameMenuBar
;
182 // override to update status bar position (or anything else) when
184 virtual void PositionStatusBar() { }
186 wxStatusBar
*m_frameStatusBar
;
187 #endif // wxUSE_STATUSBAR
190 // override to update status bar position (or anything else) when
192 virtual void PositionToolBar() { }
194 wxToolBar
*m_frameToolBar
;
195 #endif // wxUSE_TOOLBAR
197 // the frame client to screen translation should take account of the
198 // toolbar which may shift the origin of the client area
199 virtual void DoClientToScreen(int *x
, int *y
) const;
200 virtual void DoScreenToClient(int *x
, int *y
) const;
205 DECLARE_EVENT_TABLE()
208 // include the real class declaration
209 #if defined(__WXMSW__)
210 #include "wx/msw/frame.h"
211 #elif defined(__WXMOTIF__)
212 #include "wx/motif/frame.h"
213 #elif defined(__WXGTK__)
214 #include "wx/gtk/frame.h"
215 #elif defined(__WXQT__)
216 #include "wx/qt/frame.h"
217 #elif defined(__WXMAC__)
218 #include "wx/mac/frame.h"
219 #elif defined(__WXPM__)
220 #include "wx/os2/frame.h"
221 #elif defined(__WXSTUBS__)
222 #include "wx/stubs/frame.h"