]>
Commit | Line | Data |
---|---|---|
ffecfa5a JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: palmos/frame.cpp | |
3 | // Purpose: wxFrame | |
4 | // Author: William Osborne | |
5 | // Modified by: | |
6 | // Created: 10/13/04 | |
7 | // RCS-ID: $Id: | |
8 | // Copyright: (c) William Osborne | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
20 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) | |
21 | #pragma implementation "frame.h" | |
22 | #endif | |
23 | ||
24 | // For compilers that support precompilation, includes "wx.h". | |
25 | #include "wx/wxprec.h" | |
26 | ||
27 | #ifdef __BORLANDC__ | |
28 | #pragma hdrstop | |
29 | #endif | |
30 | ||
31 | #ifndef WX_PRECOMP | |
32 | #include "wx/frame.h" | |
33 | #include "wx/app.h" | |
34 | #include "wx/menu.h" | |
35 | #include "wx/utils.h" | |
36 | #include "wx/dialog.h" | |
37 | #include "wx/settings.h" | |
38 | #include "wx/dcclient.h" | |
39 | #include "wx/mdi.h" | |
40 | #include "wx/panel.h" | |
41 | #endif // WX_PRECOMP | |
42 | ||
43 | #if wxUSE_STATUSBAR | |
44 | #include "wx/statusbr.h" | |
45 | #include "wx/generic/statusbr.h" | |
46 | #endif // wxUSE_STATUSBAR | |
47 | ||
48 | #if wxUSE_TOOLBAR | |
49 | #include "wx/toolbar.h" | |
50 | #endif // wxUSE_TOOLBAR | |
51 | ||
52 | #include "wx/menuitem.h" | |
53 | #include "wx/log.h" | |
54 | ||
55 | #ifdef __WXUNIVERSAL__ | |
56 | #include "wx/univ/theme.h" | |
57 | #include "wx/univ/colschem.h" | |
58 | #endif // __WXUNIVERSAL__ | |
59 | ||
60 | // ---------------------------------------------------------------------------- | |
61 | // globals | |
62 | // ---------------------------------------------------------------------------- | |
63 | ||
64 | #if wxUSE_MENUS_NATIVE | |
65 | extern wxMenu *wxCurrentPopupMenu; | |
66 | #endif // wxUSE_MENUS_NATIVE | |
67 | ||
68 | // ---------------------------------------------------------------------------- | |
69 | // event tables | |
70 | // ---------------------------------------------------------------------------- | |
71 | ||
72 | BEGIN_EVENT_TABLE(wxFrame, wxFrameBase) | |
73 | EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged) | |
74 | EVT_PAINT(wxFrame::OnPaint) | |
75 | END_EVENT_TABLE() | |
76 | ||
77 | #if wxUSE_EXTENDED_RTTI | |
78 | WX_DEFINE_FLAGS( wxFrameStyle ) | |
79 | ||
80 | wxBEGIN_FLAGS( wxFrameStyle ) | |
81 | // new style border flags, we put them first to | |
82 | // use them for streaming out | |
83 | wxFLAGS_MEMBER(wxBORDER_SIMPLE) | |
84 | wxFLAGS_MEMBER(wxBORDER_SUNKEN) | |
85 | wxFLAGS_MEMBER(wxBORDER_DOUBLE) | |
86 | wxFLAGS_MEMBER(wxBORDER_RAISED) | |
87 | wxFLAGS_MEMBER(wxBORDER_STATIC) | |
88 | wxFLAGS_MEMBER(wxBORDER_NONE) | |
89 | ||
90 | // old style border flags | |
91 | wxFLAGS_MEMBER(wxSIMPLE_BORDER) | |
92 | wxFLAGS_MEMBER(wxSUNKEN_BORDER) | |
93 | wxFLAGS_MEMBER(wxDOUBLE_BORDER) | |
94 | wxFLAGS_MEMBER(wxRAISED_BORDER) | |
95 | wxFLAGS_MEMBER(wxSTATIC_BORDER) | |
96 | wxFLAGS_MEMBER(wxBORDER) | |
97 | ||
98 | // standard window styles | |
99 | wxFLAGS_MEMBER(wxTAB_TRAVERSAL) | |
100 | wxFLAGS_MEMBER(wxCLIP_CHILDREN) | |
101 | wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) | |
102 | wxFLAGS_MEMBER(wxWANTS_CHARS) | |
103 | wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) | |
104 | wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) | |
105 | wxFLAGS_MEMBER(wxVSCROLL) | |
106 | wxFLAGS_MEMBER(wxHSCROLL) | |
107 | ||
108 | // frame styles | |
109 | wxFLAGS_MEMBER(wxSTAY_ON_TOP) | |
110 | wxFLAGS_MEMBER(wxCAPTION) | |
111 | wxFLAGS_MEMBER(wxTHICK_FRAME) | |
112 | wxFLAGS_MEMBER(wxSYSTEM_MENU) | |
113 | wxFLAGS_MEMBER(wxRESIZE_BORDER) | |
114 | wxFLAGS_MEMBER(wxRESIZE_BOX) | |
115 | wxFLAGS_MEMBER(wxCLOSE_BOX) | |
116 | wxFLAGS_MEMBER(wxMAXIMIZE_BOX) | |
117 | wxFLAGS_MEMBER(wxMINIMIZE_BOX) | |
118 | ||
119 | wxFLAGS_MEMBER(wxFRAME_TOOL_WINDOW) | |
120 | wxFLAGS_MEMBER(wxFRAME_FLOAT_ON_PARENT) | |
121 | ||
122 | wxFLAGS_MEMBER(wxFRAME_SHAPED) | |
123 | ||
124 | wxEND_FLAGS( wxFrameStyle ) | |
125 | ||
126 | IMPLEMENT_DYNAMIC_CLASS_XTI(wxFrame, wxTopLevelWindow,"wx/frame.h") | |
127 | ||
128 | wxBEGIN_PROPERTIES_TABLE(wxFrame) | |
129 | wxEVENT_PROPERTY( Menu , wxEVT_COMMAND_MENU_SELECTED , wxCommandEvent) | |
130 | ||
131 | wxPROPERTY( Title,wxString, SetTitle, GetTitle, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) | |
132 | wxPROPERTY_FLAGS( WindowStyle , wxFrameStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style | |
133 | wxPROPERTY( MenuBar , wxMenuBar * , SetMenuBar , GetMenuBar , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) | |
134 | wxEND_PROPERTIES_TABLE() | |
135 | ||
136 | wxBEGIN_HANDLERS_TABLE(wxFrame) | |
137 | wxEND_HANDLERS_TABLE() | |
138 | ||
139 | wxCONSTRUCTOR_6( wxFrame , wxWindow* , Parent , wxWindowID , Id , wxString , Title , wxPoint , Position , wxSize , Size , long , WindowStyle) | |
140 | ||
141 | #else | |
142 | IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow) | |
143 | #endif | |
144 | ||
145 | // ============================================================================ | |
146 | // implementation | |
147 | // ============================================================================ | |
148 | ||
149 | // ---------------------------------------------------------------------------- | |
150 | // static class members | |
151 | // ---------------------------------------------------------------------------- | |
152 | ||
153 | #if wxUSE_STATUSBAR | |
154 | #if wxUSE_NATIVE_STATUSBAR | |
155 | bool wxFrame::m_useNativeStatusBar = TRUE; | |
156 | #else | |
157 | bool wxFrame::m_useNativeStatusBar = FALSE; | |
158 | #endif | |
159 | #endif // wxUSE_NATIVE_STATUSBAR | |
160 | ||
161 | // ---------------------------------------------------------------------------- | |
162 | // creation/destruction | |
163 | // ---------------------------------------------------------------------------- | |
164 | ||
165 | void wxFrame::Init() | |
166 | { | |
167 | StatusBar=NULL; | |
168 | } | |
169 | ||
170 | bool wxFrame::Create(wxWindow *parent, | |
171 | wxWindowID id, | |
172 | const wxString& title, | |
173 | const wxPoint& pos, | |
174 | const wxSize& size, | |
175 | long style, | |
176 | const wxString& name) | |
177 | { | |
178 | if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name, this) ) | |
179 | return false; | |
180 | ||
181 | return true; | |
182 | } | |
183 | ||
184 | wxFrame::~wxFrame() | |
185 | { | |
186 | } | |
187 | ||
188 | // ---------------------------------------------------------------------------- | |
189 | // wxFrame client size calculations | |
190 | // ---------------------------------------------------------------------------- | |
191 | ||
192 | void wxFrame::DoSetClientSize(int width, int height) | |
193 | { | |
194 | } | |
195 | ||
196 | // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc. | |
197 | void wxFrame::DoGetClientSize(int *x, int *y) const | |
198 | { | |
199 | } | |
200 | ||
201 | // ---------------------------------------------------------------------------- | |
202 | // wxFrame: various geometry-related functions | |
203 | // ---------------------------------------------------------------------------- | |
204 | ||
205 | void wxFrame::Raise() | |
206 | { | |
207 | } | |
208 | ||
209 | // generate an artificial resize event | |
210 | void wxFrame::SendSizeEvent() | |
211 | { | |
212 | } | |
213 | ||
214 | #if wxUSE_STATUSBAR | |
215 | wxStatusBar *wxFrame::OnCreateStatusBar(int number, | |
216 | long style, | |
217 | wxWindowID id, | |
218 | const wxString& name) | |
219 | { | |
220 | wxStatusBar *statusBar = NULL; | |
221 | ||
222 | #if wxUSE_NATIVE_STATUSBAR | |
223 | if ( !UsesNativeStatusBar() ) | |
224 | { | |
225 | statusBar = (wxStatusBar *)new wxStatusBarGeneric(this, id, style); | |
226 | } | |
227 | else | |
228 | #endif | |
229 | { | |
230 | statusBar = new wxStatusBar(this, id, style, name); | |
231 | } | |
232 | ||
233 | statusBar->SetFieldsCount(number); | |
234 | ||
235 | StatusBar=statusBar; | |
236 | return statusBar; | |
237 | ||
238 | return NULL; | |
239 | } | |
240 | ||
241 | void wxFrame::PositionStatusBar() | |
242 | { | |
243 | } | |
244 | #endif // wxUSE_STATUSBAR | |
245 | ||
246 | #if wxUSE_MENUS_NATIVE | |
247 | ||
248 | void wxFrame::AttachMenuBar(wxMenuBar *menubar) | |
249 | { | |
250 | wxFrameBase::AttachMenuBar(menubar); | |
251 | ||
252 | if ( !menubar ) | |
253 | { | |
254 | // actually remove the menu from the frame | |
255 | m_hMenu = (WXHMENU)0; | |
256 | } | |
257 | } | |
258 | ||
259 | void wxFrame::InternalSetMenuBar() | |
260 | { | |
261 | } | |
262 | ||
263 | bool wxFrame::HandleMenuOpen() | |
264 | { | |
265 | if(!m_frameMenuBar) | |
266 | return false; | |
267 | ||
268 | m_frameMenuBar->LoadMenu(); | |
269 | return true; | |
270 | } | |
271 | ||
272 | bool wxFrame::HandleMenuSelect(int ItemID) | |
273 | { | |
274 | if (!m_frameMenuBar) | |
275 | return false; | |
276 | ||
277 | int item=m_frameMenuBar->ProcessCommand(ItemID); | |
278 | if(item==-1) | |
279 | return false; | |
280 | ||
281 | wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, item); | |
282 | commandEvent.SetEventObject(this); | |
283 | ||
284 | GetEventHandler()->ProcessEvent(commandEvent); | |
285 | return true; | |
286 | } | |
287 | ||
288 | #endif // wxUSE_MENUS_NATIVE | |
289 | ||
290 | // Responds to colour changes, and passes event on to children. | |
291 | void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event) | |
292 | { | |
293 | } | |
294 | ||
295 | void wxFrame::OnPaint(wxPaintEvent& event) | |
296 | { | |
297 | #if wxUSE_STATUSBAR | |
298 | if(StatusBar!=NULL) | |
299 | StatusBar->DrawStatusBar(); | |
300 | #endif | |
301 | } | |
302 | ||
303 | // Pass TRUE to show full screen, FALSE to restore. | |
304 | bool wxFrame::ShowFullScreen(bool show, long style) | |
305 | { | |
306 | return false; | |
307 | } | |
308 | ||
309 | // ---------------------------------------------------------------------------- | |
310 | // tool/status bar stuff | |
311 | // ---------------------------------------------------------------------------- | |
312 | ||
313 | #if wxUSE_TOOLBAR | |
314 | ||
315 | wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name) | |
316 | { | |
317 | return NULL; | |
318 | } | |
319 | ||
320 | void wxFrame::PositionToolBar() | |
321 | { | |
322 | } | |
323 | ||
324 | #endif // wxUSE_TOOLBAR | |
325 | ||
326 | // ---------------------------------------------------------------------------- | |
327 | // frame state (iconized/maximized/...) | |
328 | // ---------------------------------------------------------------------------- | |
329 | ||
330 | // propagate our state change to all child frames: this allows us to emulate X | |
331 | // Windows behaviour where child frames float independently of the parent one | |
332 | // on the desktop, but are iconized/restored with it | |
333 | void wxFrame::IconizeChildFrames(bool bIconize) | |
334 | { | |
335 | } | |
336 | ||
337 | WXHICON wxFrame::GetDefaultIcon() const | |
338 | { | |
339 | // we don't have any standard icons (any more) | |
340 | return (WXHICON)0; | |
341 | } | |
342 | ||
343 | // =========================================================================== | |
344 | // message processing | |
345 | // =========================================================================== | |
346 | ||
347 | // --------------------------------------------------------------------------- | |
348 | // preprocessing | |
349 | // --------------------------------------------------------------------------- | |
350 | ||
351 | bool wxFrame::MSWTranslateMessage(WXMSG* pMsg) | |
352 | { | |
353 | return false; | |
354 | } | |
355 | ||
356 | // --------------------------------------------------------------------------- | |
357 | // our private (non virtual) message handlers | |
358 | // --------------------------------------------------------------------------- | |
359 | ||
360 | bool wxFrame::HandlePaint() | |
361 | { | |
362 | return false; | |
363 | } | |
364 | ||
365 | bool wxFrame::HandleSize(int x, int y, WXUINT id) | |
366 | { | |
367 | return false; | |
368 | } | |
369 | ||
370 | bool wxFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control) | |
371 | { | |
372 | return false; | |
373 | } | |
374 | ||
375 | // --------------------------------------------------------------------------- | |
376 | // the window proc for wxFrame | |
377 | // --------------------------------------------------------------------------- | |
378 | ||
379 | WXLRESULT wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) | |
380 | { | |
381 | return false; | |
382 | } | |
383 | ||
384 | // ---------------------------------------------------------------------------- | |
385 | // wxFrame size management: we exclude the areas taken by menu/status/toolbars | |
386 | // from the client area, so the client area is what's really available for the | |
387 | // frame contents | |
388 | // ---------------------------------------------------------------------------- | |
389 | ||
390 | // get the origin of the client area in the client coordinates | |
391 | wxPoint wxFrame::GetClientAreaOrigin() const | |
392 | { | |
393 | wxPoint pt; | |
394 | return pt; | |
395 | } |