]> git.saurik.com Git - wxWidgets.git/blob - include/wx/frame.h
Integrated recent API-change
[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 // ----------------------------------------------------------------------------
36 // wxFrame is a top-level window with optional menubar, statusbar and toolbar
37 //
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 // ----------------------------------------------------------------------------
46
47 class WXDLLEXPORT wxFrameBase : public wxWindow
48 {
49 public:
50 // construction
51 wxFrameBase();
52
53 wxFrame *New(wxWindow *parent,
54 wxWindowID id,
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);
60
61 // frame state
62 // -----------
63
64 // maximize = TRUE => maximize, otherwise - restore
65 virtual void Maximize(bool maximize = TRUE) = 0;
66
67 // undo Maximize() or Iconize()
68 virtual void Restore() = 0;
69
70 // iconize = TRUE => iconize, otherwise - restore
71 virtual void Iconize(bool iconize = TRUE) = 0;
72
73 // return TRUE if the frame is maximized
74 virtual bool IsMaximized() const = 0;
75
76 // return TRUE if the frame is iconized
77 virtual bool IsIconized() const = 0;
78
79 // get the frame icon
80 const wxIcon& GetIcon() const { return m_icon; }
81
82 // set the frame icon
83 virtual void SetIcon(const wxIcon& icon) { m_icon = icon; }
84
85 // make the window modal (all other windows unresponsive)
86 virtual void MakeModal(bool modal = TRUE);
87
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;
91
92 // menu bar functions
93 // ------------------
94
95 virtual void SetMenuBar(wxMenuBar *menubar) = 0;
96 virtual wxMenuBar *GetMenuBar() const { return m_frameMenuBar; }
97
98 // call this to simulate a menu command
99 bool Command(int id) { return ProcessCommand(id); }
100
101 // process menu command: returns TRUE if processed
102 bool ProcessCommand(int id);
103
104 // status bar functions
105 // --------------------
106 #if wxUSE_STATUSBAR
107 // create the main status bar by calling OnCreateStatusBar()
108 virtual wxStatusBar* CreateStatusBar(int number = 1,
109 long style = wxST_SIZEGRIP,
110 wxWindowID id = 0,
111 const wxString& name =
112 wxStatusLineNameStr);
113 // return a new status bar
114 virtual wxStatusBar *OnCreateStatusBar(int number,
115 long style,
116 wxWindowID id,
117 const wxString& name);
118 // get the main status bar
119 virtual wxStatusBar *GetStatusBar() const { return m_frameStatusBar; }
120
121 // sets the main status bar
122 void SetStatusBar(wxStatusBar *statBar) { m_frameStatusBar = statBar; }
123
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
128
129 // toolbar functions
130 // -----------------
131 #if wxUSE_TOOLBAR
132 // create main toolbar bycalling OnCreateToolBar()
133 virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER|wxTB_HORIZONTAL,
134 wxWindowID id = -1,
135 const wxString& name = wxToolBarNameStr);
136 // return a new toolbar
137 virtual wxToolBar *OnCreateToolBar(long style,
138 wxWindowID id,
139 const wxString& name );
140
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
145
146 // old functions, use the new ones instead!
147 #if WXWIN_COMPATIBILITY_2
148 bool Iconized() const { return IsIconized(); }
149 #endif // WXWIN_COMPATIBILITY_2
150
151 // implementation only from now on
152 // -------------------------------
153
154 // override some base class virtuals
155 virtual bool Destroy();
156 virtual bool IsTopLevel() const { return TRUE; }
157
158 // event handlers
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)) { }
166
167 // send wxUpdateUIEvents for all menu items (called from OnIdle())
168 void DoMenuUpdates();
169 void DoMenuUpdates(wxMenu* menu, wxWindow* focusWin);
170
171 protected:
172 // the frame main menu/status/tool bars
173 // ------------------------------------
174
175 // this (non virtual!) function should be called from dtor to delete the
176 // main menubar, statusbar and toolbar (if any)
177 void DeleteAllBars();
178
179 wxMenuBar *m_frameMenuBar;
180
181 #if wxUSE_STATUSBAR
182 // override to update status bar position (or anything else) when
183 // something changes
184 virtual void PositionStatusBar() { }
185
186 wxStatusBar *m_frameStatusBar;
187 #endif // wxUSE_STATUSBAR
188
189 #if wxUSE_TOOLBAR
190 // override to update status bar position (or anything else) when
191 // something changes
192 virtual void PositionToolBar() { }
193
194 wxToolBar *m_frameToolBar;
195 #endif // wxUSE_TOOLBAR
196
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;
201
202 // the frame icon
203 wxIcon m_icon;
204
205 DECLARE_EVENT_TABLE()
206 };
207
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"
223 #endif
224
225 #endif
226 // _WX_FRAME_H_BASE_