]>
Commit | Line | Data |
---|---|---|
2bda0e17 | 1 | ///////////////////////////////////////////////////////////////////////////// |
7c0ea335 | 2 | // Name: msw/frame.cpp |
0d53fc34 | 3 | // Purpose: wxFrame |
2bda0e17 KB |
4 | // Author: Julian Smart |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
6c9a19aa | 8 | // Copyright: (c) Julian Smart |
65571936 | 9 | // Licence: wxWindows licence |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
7c0ea335 VZ |
12 | // ============================================================================ |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
14f355c2 | 20 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
7c0ea335 | 21 | #pragma implementation "frame.h" |
2bda0e17 KB |
22 | #endif |
23 | ||
24 | // For compilers that support precompilation, includes "wx.h". | |
25 | #include "wx/wxprec.h" | |
26 | ||
27 | #ifdef __BORLANDC__ | |
9f3362c4 | 28 | #pragma hdrstop |
2bda0e17 KB |
29 | #endif |
30 | ||
31 | #ifndef WX_PRECOMP | |
9f3362c4 | 32 | #include "wx/frame.h" |
9f3362c4 | 33 | #include "wx/app.h" |
1e6feb95 | 34 | #include "wx/menu.h" |
9f3362c4 VZ |
35 | #include "wx/utils.h" |
36 | #include "wx/dialog.h" | |
37 | #include "wx/settings.h" | |
38 | #include "wx/dcclient.h" | |
d3cc7c65 | 39 | #include "wx/mdi.h" |
f6bcfd97 | 40 | #include "wx/panel.h" |
9f3362c4 | 41 | #endif // WX_PRECOMP |
2bda0e17 KB |
42 | |
43 | #include "wx/msw/private.h" | |
7c0ea335 | 44 | |
4676948b JS |
45 | #ifdef __WXWINCE__ |
46 | #include <commctrl.h> | |
47 | #endif | |
48 | ||
7c0ea335 VZ |
49 | #if wxUSE_STATUSBAR |
50 | #include "wx/statusbr.h" | |
ed791986 | 51 | #include "wx/generic/statusbr.h" |
7c0ea335 VZ |
52 | #endif // wxUSE_STATUSBAR |
53 | ||
54 | #if wxUSE_TOOLBAR | |
55 | #include "wx/toolbar.h" | |
56 | #endif // wxUSE_TOOLBAR | |
57 | ||
2bda0e17 | 58 | #include "wx/menuitem.h" |
6776a0b2 | 59 | #include "wx/log.h" |
2bda0e17 | 60 | |
1e6feb95 VZ |
61 | #ifdef __WXUNIVERSAL__ |
62 | #include "wx/univ/theme.h" | |
63 | #include "wx/univ/colschem.h" | |
64 | #endif // __WXUNIVERSAL__ | |
65 | ||
7c0ea335 VZ |
66 | // ---------------------------------------------------------------------------- |
67 | // globals | |
68 | // ---------------------------------------------------------------------------- | |
2bda0e17 | 69 | |
1e6feb95 | 70 | #if wxUSE_MENUS_NATIVE |
03baf031 | 71 | extern wxMenu *wxCurrentPopupMenu; |
1e6feb95 | 72 | #endif // wxUSE_MENUS_NATIVE |
2bda0e17 | 73 | |
7c0ea335 VZ |
74 | // ---------------------------------------------------------------------------- |
75 | // event tables | |
76 | // ---------------------------------------------------------------------------- | |
77 | ||
0d53fc34 | 78 | BEGIN_EVENT_TABLE(wxFrame, wxFrameBase) |
0d53fc34 | 79 | EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged) |
2bda0e17 KB |
80 | END_EVENT_TABLE() |
81 | ||
51596bcb | 82 | #if wxUSE_EXTENDED_RTTI |
bc9fb572 JS |
83 | WX_DEFINE_FLAGS( wxFrameStyle ) |
84 | ||
3ff066a4 | 85 | wxBEGIN_FLAGS( wxFrameStyle ) |
bc9fb572 JS |
86 | // new style border flags, we put them first to |
87 | // use them for streaming out | |
3ff066a4 SC |
88 | wxFLAGS_MEMBER(wxBORDER_SIMPLE) |
89 | wxFLAGS_MEMBER(wxBORDER_SUNKEN) | |
90 | wxFLAGS_MEMBER(wxBORDER_DOUBLE) | |
91 | wxFLAGS_MEMBER(wxBORDER_RAISED) | |
92 | wxFLAGS_MEMBER(wxBORDER_STATIC) | |
93 | wxFLAGS_MEMBER(wxBORDER_NONE) | |
cbe874bd | 94 | |
bc9fb572 | 95 | // old style border flags |
3ff066a4 SC |
96 | wxFLAGS_MEMBER(wxSIMPLE_BORDER) |
97 | wxFLAGS_MEMBER(wxSUNKEN_BORDER) | |
98 | wxFLAGS_MEMBER(wxDOUBLE_BORDER) | |
99 | wxFLAGS_MEMBER(wxRAISED_BORDER) | |
100 | wxFLAGS_MEMBER(wxSTATIC_BORDER) | |
cb0afb26 | 101 | wxFLAGS_MEMBER(wxBORDER) |
bc9fb572 JS |
102 | |
103 | // standard window styles | |
3ff066a4 SC |
104 | wxFLAGS_MEMBER(wxTAB_TRAVERSAL) |
105 | wxFLAGS_MEMBER(wxCLIP_CHILDREN) | |
106 | wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) | |
107 | wxFLAGS_MEMBER(wxWANTS_CHARS) | |
cb0afb26 | 108 | wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) |
3ff066a4 SC |
109 | wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) |
110 | wxFLAGS_MEMBER(wxVSCROLL) | |
111 | wxFLAGS_MEMBER(wxHSCROLL) | |
bc9fb572 JS |
112 | |
113 | // frame styles | |
3ff066a4 SC |
114 | wxFLAGS_MEMBER(wxSTAY_ON_TOP) |
115 | wxFLAGS_MEMBER(wxCAPTION) | |
116 | wxFLAGS_MEMBER(wxTHICK_FRAME) | |
117 | wxFLAGS_MEMBER(wxSYSTEM_MENU) | |
118 | wxFLAGS_MEMBER(wxRESIZE_BORDER) | |
119 | wxFLAGS_MEMBER(wxRESIZE_BOX) | |
120 | wxFLAGS_MEMBER(wxCLOSE_BOX) | |
121 | wxFLAGS_MEMBER(wxMAXIMIZE_BOX) | |
122 | wxFLAGS_MEMBER(wxMINIMIZE_BOX) | |
bc9fb572 | 123 | |
3ff066a4 SC |
124 | wxFLAGS_MEMBER(wxFRAME_TOOL_WINDOW) |
125 | wxFLAGS_MEMBER(wxFRAME_FLOAT_ON_PARENT) | |
bc9fb572 | 126 | |
3ff066a4 | 127 | wxFLAGS_MEMBER(wxFRAME_SHAPED) |
bc9fb572 | 128 | |
3ff066a4 | 129 | wxEND_FLAGS( wxFrameStyle ) |
bc9fb572 | 130 | |
51596bcb SC |
131 | IMPLEMENT_DYNAMIC_CLASS_XTI(wxFrame, wxTopLevelWindow,"wx/frame.h") |
132 | ||
3ff066a4 | 133 | wxBEGIN_PROPERTIES_TABLE(wxFrame) |
fb8a56b7 | 134 | wxEVENT_PROPERTY( Menu , wxEVT_COMMAND_MENU_SELECTED , wxCommandEvent) |
c5ca409b | 135 | |
3ff066a4 | 136 | wxPROPERTY( Title,wxString, SetTitle, GetTitle, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) |
af498247 VZ |
137 | wxPROPERTY_FLAGS( WindowStyle , wxFrameStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style |
138 | wxPROPERTY( MenuBar , wxMenuBar * , SetMenuBar , GetMenuBar , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) | |
3ff066a4 | 139 | wxEND_PROPERTIES_TABLE() |
51596bcb | 140 | |
3ff066a4 SC |
141 | wxBEGIN_HANDLERS_TABLE(wxFrame) |
142 | wxEND_HANDLERS_TABLE() | |
51596bcb | 143 | |
cbe874bd | 144 | wxCONSTRUCTOR_6( wxFrame , wxWindow* , Parent , wxWindowID , Id , wxString , Title , wxPoint , Position , wxSize , Size , long , WindowStyle) |
51596bcb SC |
145 | |
146 | #else | |
58b43418 | 147 | IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow) |
51596bcb | 148 | #endif |
2bda0e17 | 149 | |
7c0ea335 VZ |
150 | // ============================================================================ |
151 | // implementation | |
152 | // ============================================================================ | |
153 | ||
154 | // ---------------------------------------------------------------------------- | |
155 | // static class members | |
156 | // ---------------------------------------------------------------------------- | |
157 | ||
1e6feb95 VZ |
158 | #if wxUSE_STATUSBAR |
159 | #if wxUSE_NATIVE_STATUSBAR | |
cbe874bd | 160 | bool wxFrame::m_useNativeStatusBar = true; |
1e6feb95 | 161 | #else |
cbe874bd | 162 | bool wxFrame::m_useNativeStatusBar = false; |
1e6feb95 VZ |
163 | #endif |
164 | #endif // wxUSE_NATIVE_STATUSBAR | |
2bda0e17 | 165 | |
7c0ea335 VZ |
166 | // ---------------------------------------------------------------------------- |
167 | // creation/destruction | |
168 | // ---------------------------------------------------------------------------- | |
2bda0e17 | 169 | |
0d53fc34 | 170 | void wxFrame::Init() |
2bda0e17 | 171 | { |
cf8ff92f VZ |
172 | #if wxUSE_MENUS |
173 | m_hMenu = NULL; | |
174 | #endif // wxUSE_MENUS | |
175 | ||
9f3362c4 VZ |
176 | #if wxUSE_TOOLTIPS |
177 | m_hwndToolTip = 0; | |
178 | #endif | |
a2327a9f | 179 | |
cbe874bd | 180 | m_wasMinimized = false; |
7c0ea335 | 181 | } |
9f3362c4 | 182 | |
0d53fc34 | 183 | bool wxFrame::Create(wxWindow *parent, |
7c0ea335 VZ |
184 | wxWindowID id, |
185 | const wxString& title, | |
186 | const wxPoint& pos, | |
187 | const wxSize& size, | |
188 | long style, | |
189 | const wxString& name) | |
190 | { | |
82c9f85c | 191 | if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) ) |
ef6d716b | 192 | return false; |
d2aef312 | 193 | |
98a02e87 | 194 | SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE)); |
b9691677 | 195 | |
aaf803e9 | 196 | #if defined(__SMARTPHONE__) |
ef6d716b WS |
197 | SetLeftMenu(wxID_EXIT, _("Done")); |
198 | #endif | |
199 | ||
aaf803e9 JS |
200 | #if defined(__POCKETPC__) |
201 | // The guidelines state that Ctrl+Q should quit the app. | |
202 | // Let's define an accelerator table to send wxID_EXIT. | |
203 | wxAcceleratorEntry entries[1]; | |
204 | entries[0].Set(wxACCEL_CTRL, 'Q', wxID_EXIT); | |
205 | wxAcceleratorTable accel(1, entries); | |
206 | SetAcceleratorTable(accel); | |
207 | #endif | |
208 | ||
ef6d716b | 209 | return true; |
2bda0e17 KB |
210 | } |
211 | ||
0d53fc34 | 212 | wxFrame::~wxFrame() |
2bda0e17 | 213 | { |
cbe874bd | 214 | m_isBeingDeleted = true; |
82c9f85c | 215 | DeleteAllBars(); |
2bda0e17 KB |
216 | } |
217 | ||
d4597e13 VZ |
218 | // ---------------------------------------------------------------------------- |
219 | // wxFrame client size calculations | |
220 | // ---------------------------------------------------------------------------- | |
2bda0e17 | 221 | |
0d53fc34 | 222 | void wxFrame::DoSetClientSize(int width, int height) |
2bda0e17 | 223 | { |
82c9f85c | 224 | // leave enough space for the status bar if we have (and show) it |
7c0ea335 | 225 | #if wxUSE_STATUSBAR |
8d8bd249 VZ |
226 | wxStatusBar *statbar = GetStatusBar(); |
227 | if ( statbar && statbar->IsShown() ) | |
228 | { | |
8d8bd249 VZ |
229 | height += statbar->GetSize().y; |
230 | } | |
7c0ea335 | 231 | #endif // wxUSE_STATUSBAR |
2bda0e17 | 232 | |
68d02db3 VZ |
233 | // call GetClientAreaOrigin() to take the toolbar into account |
234 | wxPoint pt = GetClientAreaOrigin(); | |
235 | width += pt.x; | |
236 | height += pt.y; | |
237 | ||
82c9f85c | 238 | wxTopLevelWindow::DoSetClientSize(width, height); |
2bda0e17 KB |
239 | } |
240 | ||
d4597e13 VZ |
241 | // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc. |
242 | void wxFrame::DoGetClientSize(int *x, int *y) const | |
243 | { | |
244 | wxTopLevelWindow::DoGetClientSize(x, y); | |
245 | ||
68d02db3 VZ |
246 | // account for the possible toolbar |
247 | wxPoint pt = GetClientAreaOrigin(); | |
248 | if ( x ) | |
249 | *x -= pt.x; | |
250 | ||
251 | if ( y ) | |
252 | *y -= pt.y; | |
253 | ||
d4597e13 VZ |
254 | #if wxUSE_STATUSBAR |
255 | // adjust client area height to take the status bar into account | |
256 | if ( y ) | |
257 | { | |
258 | wxStatusBar *statbar = GetStatusBar(); | |
259 | if ( statbar && statbar->IsShown() ) | |
260 | { | |
261 | *y -= statbar->GetClientSize().y; | |
262 | } | |
263 | } | |
264 | #endif // wxUSE_STATUSBAR | |
265 | } | |
266 | ||
7c0ea335 | 267 | // ---------------------------------------------------------------------------- |
0d53fc34 | 268 | // wxFrame: various geometry-related functions |
7c0ea335 VZ |
269 | // ---------------------------------------------------------------------------- |
270 | ||
0d53fc34 | 271 | void wxFrame::Raise() |
c48926e1 | 272 | { |
c48926e1 | 273 | ::SetForegroundWindow(GetHwnd()); |
c48926e1 VZ |
274 | } |
275 | ||
67bd5bad | 276 | // generate an artificial resize event |
0d53fc34 | 277 | void wxFrame::SendSizeEvent() |
67bd5bad | 278 | { |
67bd5bad GT |
279 | if ( !m_iconized ) |
280 | { | |
82c9f85c VZ |
281 | RECT r = wxGetWindowRect(GetHwnd()); |
282 | ||
67bd5bad GT |
283 | (void)::PostMessage(GetHwnd(), WM_SIZE, |
284 | IsMaximized() ? SIZE_MAXIMIZED : SIZE_RESTORED, | |
285 | MAKELPARAM(r.right - r.left, r.bottom - r.top)); | |
286 | } | |
287 | } | |
288 | ||
d427503c | 289 | #if wxUSE_STATUSBAR |
0d53fc34 | 290 | wxStatusBar *wxFrame::OnCreateStatusBar(int number, |
7c0ea335 VZ |
291 | long style, |
292 | wxWindowID id, | |
293 | const wxString& name) | |
2bda0e17 | 294 | { |
5cb598ae | 295 | wxStatusBar *statusBar wxDUMMY_INITIALIZE(NULL); |
2bda0e17 | 296 | |
47d67540 | 297 | #if wxUSE_NATIVE_STATUSBAR |
1f0500b3 | 298 | if ( !UsesNativeStatusBar() ) |
2bda0e17 | 299 | { |
1f0500b3 | 300 | statusBar = (wxStatusBar *)new wxStatusBarGeneric(this, id, style); |
2bda0e17 KB |
301 | } |
302 | else | |
303 | #endif | |
304 | { | |
1f0500b3 VZ |
305 | statusBar = new wxStatusBar(this, id, style, name); |
306 | } | |
ed791986 | 307 | |
1f0500b3 | 308 | statusBar->SetFieldsCount(number); |
2bda0e17 | 309 | |
7c0ea335 | 310 | return statusBar; |
2bda0e17 KB |
311 | } |
312 | ||
0d53fc34 | 313 | void wxFrame::PositionStatusBar() |
2bda0e17 | 314 | { |
d4597e13 | 315 | if ( !m_frameStatusBar || !m_frameStatusBar->IsShown() ) |
ed791986 VZ |
316 | return; |
317 | ||
cbc66a27 VZ |
318 | int w, h; |
319 | GetClientSize(&w, &h); | |
320 | int sw, sh; | |
321 | m_frameStatusBar->GetSize(&sw, &sh); | |
322 | ||
323 | // Since we wish the status bar to be directly under the client area, | |
324 | // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS. | |
325 | m_frameStatusBar->SetSize(0, h, w, sh); | |
2bda0e17 | 326 | } |
d427503c | 327 | #endif // wxUSE_STATUSBAR |
2bda0e17 | 328 | |
6522713c | 329 | #if wxUSE_MENUS_NATIVE |
ea9a4296 | 330 | |
0d53fc34 | 331 | void wxFrame::AttachMenuBar(wxMenuBar *menubar) |
2bda0e17 | 332 | { |
3180bc0e | 333 | #if defined(__SMARTPHONE__) && defined(__WXWINCE__) |
fb8a56b7 | 334 | |
ed679e74 WS |
335 | wxMenu *autoMenu = NULL; |
336 | ||
337 | if( menubar->GetMenuCount() == 1 ) | |
338 | { | |
339 | autoMenu = wxTopLevelWindowMSW::ButtonMenu::DuplicateMenu(menubar->GetMenu(0)); | |
340 | SetRightMenu(wxID_ANY, menubar->GetLabelTop(0), autoMenu); | |
341 | } | |
342 | else | |
fb8a56b7 | 343 | { |
ed679e74 WS |
344 | autoMenu = new wxMenu; |
345 | ||
346 | for( size_t n = 0; n < menubar->GetMenuCount(); n++ ) | |
347 | { | |
348 | wxMenu *item = menubar->GetMenu(n); | |
349 | wxString label = menubar->GetLabelTop(n); | |
350 | wxMenu *new_item = wxTopLevelWindowMSW::ButtonMenu::DuplicateMenu(item); | |
351 | autoMenu->Append(wxID_ANY, label, new_item); | |
352 | } | |
353 | ||
354 | SetRightMenu(wxID_ANY, _("Menu"), autoMenu); | |
fb8a56b7 WS |
355 | } |
356 | ||
fb8a56b7 | 357 | #elif defined(WINCE_WITHOUT_COMMANDBAR) |
a96b4743 JS |
358 | if (!GetToolBar()) |
359 | { | |
cbe874bd | 360 | wxToolBar* toolBar = new wxToolBar(this, wxID_ANY, |
a96b4743 JS |
361 | wxDefaultPosition, wxDefaultSize, |
362 | wxBORDER_NONE | wxTB_HORIZONTAL, | |
af5454a4 | 363 | wxToolBarNameStr, menubar); |
a96b4743 JS |
364 | SetToolBar(toolBar); |
365 | menubar->SetToolBar(toolBar); | |
366 | } | |
fb8a56b7 WS |
367 | // Now adjust size for menu bar |
368 | int menuHeight = 26; | |
369 | ||
370 | //When the main window is created using CW_USEDEFAULT the height of the | |
371 | // is created is not taken into account). So we resize the window after | |
372 | // if a menubar is present | |
373 | { | |
374 | RECT rc; | |
375 | ::GetWindowRect((HWND) GetHWND(), &rc); | |
376 | // adjust for menu / titlebar height | |
377 | rc.bottom -= (2*menuHeight-1); | |
378 | ||
cbe874bd | 379 | ::MoveWindow((HWND) GetHWND(), rc.left, rc.top, rc.right, rc.bottom, FALSE); |
fb8a56b7 | 380 | } |
a96b4743 JS |
381 | #endif |
382 | ||
f008af16 | 383 | wxFrameBase::AttachMenuBar(menubar); |
6beb85c0 | 384 | |
f6bcfd97 | 385 | if ( !menubar ) |
c2dcfdef | 386 | { |
f6bcfd97 BP |
387 | // actually remove the menu from the frame |
388 | m_hMenu = (WXHMENU)0; | |
389 | InternalSetMenuBar(); | |
065de612 | 390 | } |
f6bcfd97 | 391 | else // set new non NULL menu bar |
065de612 | 392 | { |
3d487566 | 393 | #if !defined(__WXWINCE__) || defined(WINCE_WITH_COMMANDBAR) |
f6bcfd97 | 394 | // Can set a menubar several times. |
f6bcfd97 BP |
395 | if ( menubar->GetHMenu() ) |
396 | { | |
397 | m_hMenu = menubar->GetHMenu(); | |
398 | } | |
f008af16 | 399 | else // no HMENU yet |
f6bcfd97 | 400 | { |
f6bcfd97 | 401 | m_hMenu = menubar->Create(); |
065de612 | 402 | |
f6bcfd97 | 403 | if ( !m_hMenu ) |
f008af16 VZ |
404 | { |
405 | wxFAIL_MSG( _T("failed to create menu bar") ); | |
f6bcfd97 | 406 | return; |
f008af16 | 407 | } |
f6bcfd97 | 408 | } |
39d2f9a7 | 409 | #endif |
f6bcfd97 | 410 | InternalSetMenuBar(); |
1e6feb95 | 411 | } |
2bda0e17 KB |
412 | } |
413 | ||
0d53fc34 | 414 | void wxFrame::InternalSetMenuBar() |
2bda0e17 | 415 | { |
a96b4743 | 416 | #if defined(__WXMICROWIN__) || defined(__WXWINCE__) |
4676948b | 417 | // Nothing |
4676948b | 418 | #else |
42e69d6b | 419 | if ( !::SetMenu(GetHwnd(), (HMENU)m_hMenu) ) |
2bda0e17 | 420 | { |
f6bcfd97 | 421 | wxLogLastError(wxT("SetMenu")); |
2bda0e17 | 422 | } |
04ef50df | 423 | #endif |
2bda0e17 KB |
424 | } |
425 | ||
1e6feb95 VZ |
426 | #endif // wxUSE_MENUS_NATIVE |
427 | ||
2bda0e17 | 428 | // Responds to colour changes, and passes event on to children. |
0d53fc34 | 429 | void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event) |
2bda0e17 | 430 | { |
98a02e87 | 431 | SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE)); |
2bda0e17 KB |
432 | Refresh(); |
433 | ||
1e6feb95 | 434 | #if wxUSE_STATUSBAR |
2bda0e17 KB |
435 | if ( m_frameStatusBar ) |
436 | { | |
437 | wxSysColourChangedEvent event2; | |
438 | event2.SetEventObject( m_frameStatusBar ); | |
02800301 | 439 | m_frameStatusBar->GetEventHandler()->ProcessEvent(event2); |
2bda0e17 | 440 | } |
1e6feb95 | 441 | #endif // wxUSE_STATUSBAR |
2bda0e17 KB |
442 | |
443 | // Propagate the event to the non-top-level children | |
444 | wxWindow::OnSysColourChanged(event); | |
445 | } | |
446 | ||
cbe874bd | 447 | // Pass true to show full screen, false to restore. |
0d53fc34 | 448 | bool wxFrame::ShowFullScreen(bool show, long style) |
a2327a9f | 449 | { |
b01a88e0 VZ |
450 | // TODO-CE: add support for CE |
451 | #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) | |
085ad686 | 452 | if ( IsFullScreen() == show ) |
cbe874bd | 453 | return false; |
c641b1d2 | 454 | |
a2327a9f JS |
455 | if (show) |
456 | { | |
b01a88e0 VZ |
457 | // zap the toolbar, menubar, and statusbar if needed |
458 | // | |
459 | // TODO: hide commandbar for WINCE_WITH_COMMANDBAR | |
1e6feb95 | 460 | #if wxUSE_TOOLBAR |
f6bcfd97 | 461 | wxToolBar *theToolBar = GetToolBar(); |
a2327a9f JS |
462 | |
463 | if ((style & wxFULLSCREEN_NOTOOLBAR) && theToolBar) | |
464 | { | |
b01a88e0 VZ |
465 | if ( theToolBar->IsShown() ) |
466 | { | |
467 | theToolBar->SetSize(wxDefaultCoord,0); | |
468 | theToolBar->Show(false); | |
469 | } | |
470 | else // prevent it from being restored later | |
471 | { | |
472 | style &= ~wxFULLSCREEN_NOTOOLBAR; | |
473 | } | |
a2327a9f | 474 | } |
1e6feb95 | 475 | #endif // wxUSE_TOOLBAR |
a2327a9f JS |
476 | |
477 | if (style & wxFULLSCREEN_NOMENUBAR) | |
478 | SetMenu((HWND)GetHWND(), (HMENU) NULL); | |
479 | ||
1e6feb95 VZ |
480 | #if wxUSE_STATUSBAR |
481 | wxStatusBar *theStatusBar = GetStatusBar(); | |
1e6feb95 | 482 | |
a2327a9f JS |
483 | // Save the number of fields in the statusbar |
484 | if ((style & wxFULLSCREEN_NOSTATUSBAR) && theStatusBar) | |
485 | { | |
b01a88e0 VZ |
486 | if ( theStatusBar->IsShown() ) |
487 | theStatusBar->Show(false); | |
488 | else | |
489 | style &= ~wxFULLSCREEN_NOSTATUSBAR; | |
a2327a9f | 490 | } |
1e6feb95 | 491 | #endif // wxUSE_STATUSBAR |
a2327a9f | 492 | } |
b01a88e0 | 493 | else // restore to normal |
a2327a9f | 494 | { |
b01a88e0 | 495 | // restore the toolbar, menubar, and statusbar if we had hid them |
1e6feb95 | 496 | #if wxUSE_TOOLBAR |
a2327a9f JS |
497 | wxToolBar *theToolBar = GetToolBar(); |
498 | ||
b01a88e0 | 499 | if ((m_fsStyle & wxFULLSCREEN_NOTOOLBAR) && theToolBar) |
a2327a9f | 500 | { |
cbe874bd | 501 | theToolBar->Show(true); |
a2327a9f | 502 | } |
1e6feb95 | 503 | #endif // wxUSE_TOOLBAR |
a2327a9f | 504 | |
b01a88e0 VZ |
505 | if ((m_fsStyle & wxFULLSCREEN_NOMENUBAR) && m_hMenu) |
506 | ::SetMenu(GetHwnd(), (HMENU)m_hMenu); | |
507 | ||
1e6feb95 | 508 | #if wxUSE_STATUSBAR |
b01a88e0 VZ |
509 | wxStatusBar *theStatusBar = GetStatusBar(); |
510 | ||
511 | if ((m_fsStyle & wxFULLSCREEN_NOSTATUSBAR) && theStatusBar) | |
a2327a9f | 512 | { |
b01a88e0 VZ |
513 | theStatusBar->Show(true); |
514 | PositionStatusBar(); | |
a2327a9f | 515 | } |
1e6feb95 | 516 | #endif // wxUSE_STATUSBAR |
a2327a9f | 517 | } |
b01a88e0 | 518 | #endif // !defined(__WXMICROWIN__) && !defined(__WXWINCE__) |
f6bcfd97 | 519 | |
085ad686 | 520 | return wxFrameBase::ShowFullScreen(show, style); |
2bda0e17 KB |
521 | } |
522 | ||
7c0ea335 VZ |
523 | // ---------------------------------------------------------------------------- |
524 | // tool/status bar stuff | |
525 | // ---------------------------------------------------------------------------- | |
526 | ||
d427503c | 527 | #if wxUSE_TOOLBAR |
7c0ea335 | 528 | |
0d53fc34 | 529 | wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name) |
81d66cf3 | 530 | { |
3d487566 | 531 | #if defined(WINCE_WITHOUT_COMMANDBAR) |
39d2f9a7 JS |
532 | // We may already have a toolbar from calling SetMenuBar. |
533 | if (GetToolBar()) | |
534 | return GetToolBar(); | |
535 | #endif | |
7c0ea335 | 536 | if ( wxFrameBase::CreateToolBar(style, id, name) ) |
81d66cf3 | 537 | { |
81d66cf3 | 538 | PositionToolBar(); |
81d66cf3 | 539 | } |
81d66cf3 | 540 | |
7c0ea335 | 541 | return m_frameToolBar; |
81d66cf3 JS |
542 | } |
543 | ||
0d53fc34 | 544 | void wxFrame::PositionToolBar() |
81d66cf3 | 545 | { |
d4597e13 VZ |
546 | wxToolBar *toolbar = GetToolBar(); |
547 | if ( toolbar && toolbar->IsShown() ) | |
548 | { | |
3d487566 | 549 | #if defined(WINCE_WITHOUT_COMMANDBAR) |
09785dd3 JS |
550 | // We want to do something different in WinCE, because |
551 | // the toolbar should be associated with the commandbar, | |
552 | // and not an independent window. | |
553 | // TODO | |
554 | #else | |
d4597e13 VZ |
555 | // don't call our (or even wxTopLevelWindow) version because we want |
556 | // the real (full) client area size, not excluding the tool/status bar | |
557 | int width, height; | |
558 | wxWindow::DoGetClientSize(&width, &height); | |
81d66cf3 | 559 | |
7c0ea335 | 560 | #if wxUSE_STATUSBAR |
d4597e13 VZ |
561 | wxStatusBar *statbar = GetStatusBar(); |
562 | if ( statbar && statbar->IsShown() ) | |
563 | { | |
564 | height -= statbar->GetClientSize().y; | |
565 | } | |
7c0ea335 | 566 | #endif // wxUSE_STATUSBAR |
81d66cf3 | 567 | |
fb8a56b7 WS |
568 | int x = 0; |
569 | int y = 0; | |
3d487566 | 570 | #if defined(WINCE_WITH_COMMANDBAR) |
fb8a56b7 WS |
571 | // We're using a commandbar - so we have to allow for it. |
572 | if (GetMenuBar() && GetMenuBar()->GetCommandBar()) | |
573 | { | |
574 | RECT rect; | |
575 | ::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect); | |
576 | y = rect.bottom - rect.top; | |
577 | } | |
45f27284 JS |
578 | #endif |
579 | ||
229de929 | 580 | int tx, ty; |
81d66cf3 | 581 | int tw, th; |
229de929 | 582 | toolbar->GetPosition(&tx, &ty); |
d4597e13 | 583 | toolbar->GetSize(&tw, &th); |
cbe874bd | 584 | |
229de929 JS |
585 | // Adjust |
586 | if (ty < 0 && (-ty == th)) | |
587 | ty = 0; | |
588 | if (tx < 0 && (-tx == tw)) | |
cbe874bd WS |
589 | tx = 0; |
590 | ||
229de929 JS |
591 | int desiredW = tw; |
592 | int desiredH = th; | |
81d66cf3 | 593 | |
d4597e13 | 594 | if ( toolbar->GetWindowStyleFlag() & wxTB_VERTICAL ) |
81d66cf3 | 595 | { |
229de929 | 596 | desiredH = height; |
81d66cf3 JS |
597 | } |
598 | else | |
599 | { | |
229de929 JS |
600 | desiredW = width; |
601 | // if ( toolbar->GetWindowStyleFlag() & wxTB_FLAT ) | |
602 | // desiredW -= 3; | |
cbe874bd | 603 | } |
7c0ea335 | 604 | |
d4597e13 VZ |
605 | // use the 'real' MSW position here, don't offset relativly to the |
606 | // client area origin | |
229de929 JS |
607 | |
608 | // Optimise such that we don't have to always resize the toolbar | |
cbe874bd | 609 | // when the frame changes, otherwise we'll get a lot of flicker. |
5cb598ae WS |
610 | bool heightChanging wxDUMMY_INITIALIZE(true); |
611 | bool widthChanging wxDUMMY_INITIALIZE(true); | |
cbe874bd | 612 | |
229de929 JS |
613 | if ( toolbar->GetWindowStyleFlag() & wxTB_VERTICAL ) |
614 | { | |
615 | // It's OK if the current height is greater than what can be shown. | |
616 | heightChanging = (desiredH > th) ; | |
617 | widthChanging = (desiredW != tw) ; | |
cbe874bd WS |
618 | |
619 | // The next time around, we may not have to set the size | |
229de929 JS |
620 | if (heightChanging) |
621 | desiredH = desiredH + 200; | |
622 | } | |
623 | else | |
624 | { | |
625 | // It's OK if the current width is greater than what can be shown. | |
626 | widthChanging = (desiredW > tw) ; | |
627 | heightChanging = (desiredH != th) ; | |
628 | ||
cbe874bd | 629 | // The next time around, we may not have to set the size |
229de929 JS |
630 | if (widthChanging) |
631 | desiredW = desiredW + 200; | |
632 | } | |
cbe874bd | 633 | |
229de929 | 634 | if (tx != 0 || ty != 0 || widthChanging || heightChanging) |
45f27284 | 635 | toolbar->SetSize(x, y, desiredW, desiredH, wxSIZE_NO_ADJUSTMENTS); |
cbe874bd | 636 | |
09785dd3 | 637 | #endif // __WXWINCE__ |
81d66cf3 JS |
638 | } |
639 | } | |
d4597e13 | 640 | |
d427503c | 641 | #endif // wxUSE_TOOLBAR |
d2aef312 | 642 | |
7c0ea335 VZ |
643 | // ---------------------------------------------------------------------------- |
644 | // frame state (iconized/maximized/...) | |
645 | // ---------------------------------------------------------------------------- | |
646 | ||
a23fd0e1 VZ |
647 | // propagate our state change to all child frames: this allows us to emulate X |
648 | // Windows behaviour where child frames float independently of the parent one | |
649 | // on the desktop, but are iconized/restored with it | |
0d53fc34 | 650 | void wxFrame::IconizeChildFrames(bool bIconize) |
d2aef312 | 651 | { |
4bc0f25e VZ |
652 | m_iconized = bIconize; |
653 | ||
222ed1d6 | 654 | for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); |
a23fd0e1 VZ |
655 | node; |
656 | node = node->GetNext() ) | |
657 | { | |
658 | wxWindow *win = node->GetData(); | |
659 | ||
3ca6a5f0 BP |
660 | // iconizing the frames with this style under Win95 shell puts them at |
661 | // the bottom of the screen (as the MDI children) instead of making | |
662 | // them appear in the taskbar because they are, by virtue of this | |
663 | // style, not managed by the taskbar - instead leave Windows take care | |
664 | // of them | |
665 | #ifdef __WIN95__ | |
666 | if ( win->GetWindowStyle() & wxFRAME_TOOL_WINDOW ) | |
667 | continue; | |
668 | #endif // Win95 | |
669 | ||
3f7bc32b VZ |
670 | // the child MDI frames are a special case and should not be touched by |
671 | // the parent frame - instead, they are managed by the user | |
2e9f62da | 672 | wxFrame *frame = wxDynamicCast(win, wxFrame); |
1e6feb95 VZ |
673 | if ( frame |
674 | #if wxUSE_MDI_ARCHITECTURE | |
dad285d7 | 675 | && !IsMDIChild() |
1e6feb95 VZ |
676 | #endif // wxUSE_MDI_ARCHITECTURE |
677 | ) | |
a23fd0e1 | 678 | { |
9327c3aa VZ |
679 | // we don't want to restore the child frames which had been |
680 | // iconized even before we were iconized, so save the child frame | |
681 | // status when iconizing the parent frame and check it when | |
682 | // restoring it | |
683 | if ( bIconize ) | |
684 | { | |
9c72ebec | 685 | frame->m_wasMinimized = frame->IsIconized(); |
9327c3aa VZ |
686 | } |
687 | ||
9c72ebec VZ |
688 | // note that we shouldn't touch the hidden frames neither because |
689 | // iconizing/restoring them would show them as a side effect | |
690 | if ( !frame->m_wasMinimized && frame->IsShown() ) | |
9327c3aa | 691 | frame->Iconize(bIconize); |
a23fd0e1 | 692 | } |
d2aef312 | 693 | } |
d2aef312 VZ |
694 | } |
695 | ||
0d53fc34 | 696 | WXHICON wxFrame::GetDefaultIcon() const |
82c9f85c | 697 | { |
94826170 VZ |
698 | // we don't have any standard icons (any more) |
699 | return (WXHICON)0; | |
82c9f85c VZ |
700 | } |
701 | ||
a23fd0e1 | 702 | // =========================================================================== |
42e69d6b | 703 | // message processing |
a23fd0e1 VZ |
704 | // =========================================================================== |
705 | ||
42e69d6b VZ |
706 | // --------------------------------------------------------------------------- |
707 | // preprocessing | |
708 | // --------------------------------------------------------------------------- | |
709 | ||
0d53fc34 | 710 | bool wxFrame::MSWTranslateMessage(WXMSG* pMsg) |
42e69d6b VZ |
711 | { |
712 | if ( wxWindow::MSWTranslateMessage(pMsg) ) | |
cbe874bd | 713 | return true; |
42e69d6b | 714 | |
1e6feb95 | 715 | #if wxUSE_MENUS && wxUSE_ACCEL && !defined(__WXUNIVERSAL__) |
42e69d6b VZ |
716 | // try the menu bar accels |
717 | wxMenuBar *menuBar = GetMenuBar(); | |
718 | if ( !menuBar ) | |
cbe874bd | 719 | return false; |
42e69d6b VZ |
720 | |
721 | const wxAcceleratorTable& acceleratorTable = menuBar->GetAccelTable(); | |
c50f1fb9 | 722 | return acceleratorTable.Translate(this, pMsg); |
1e6feb95 | 723 | #else |
cbe874bd | 724 | return false; |
1e6feb95 | 725 | #endif // wxUSE_MENUS && wxUSE_ACCEL |
42e69d6b VZ |
726 | } |
727 | ||
728 | // --------------------------------------------------------------------------- | |
729 | // our private (non virtual) message handlers | |
730 | // --------------------------------------------------------------------------- | |
731 | ||
0d53fc34 | 732 | bool wxFrame::HandlePaint() |
42e69d6b VZ |
733 | { |
734 | RECT rect; | |
cbe874bd | 735 | if ( ::GetUpdateRect(GetHwnd(), &rect, FALSE) ) |
42e69d6b | 736 | { |
4676948b | 737 | #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) |
42e69d6b VZ |
738 | if ( m_iconized ) |
739 | { | |
f618020a MB |
740 | const wxIcon& icon = GetIcon(); |
741 | HICON hIcon = icon.Ok() ? GetHiconOf(icon) | |
742 | : (HICON)GetDefaultIcon(); | |
42e69d6b VZ |
743 | |
744 | // Hold a pointer to the dc so long as the OnPaint() message | |
745 | // is being processed | |
746 | PAINTSTRUCT ps; | |
747 | HDC hdc = ::BeginPaint(GetHwnd(), &ps); | |
748 | ||
749 | // Erase background before painting or we get white background | |
750 | MSWDefWindowProc(WM_ICONERASEBKGND, (WORD)(LONG)ps.hdc, 0L); | |
751 | ||
752 | if ( hIcon ) | |
753 | { | |
754 | RECT rect; | |
755 | ::GetClientRect(GetHwnd(), &rect); | |
756 | ||
757 | // FIXME: why hardcoded? | |
758 | static const int icon_width = 32; | |
759 | static const int icon_height = 32; | |
760 | ||
761 | int icon_x = (int)((rect.right - icon_width)/2); | |
762 | int icon_y = (int)((rect.bottom - icon_height)/2); | |
763 | ||
764 | ::DrawIcon(hdc, icon_x, icon_y, hIcon); | |
765 | } | |
766 | ||
767 | ::EndPaint(GetHwnd(), &ps); | |
768 | ||
cbe874bd | 769 | return true; |
42e69d6b VZ |
770 | } |
771 | else | |
04ef50df | 772 | #endif |
42e69d6b | 773 | { |
5d1d2d46 | 774 | return wxWindow::HandlePaint(); |
42e69d6b VZ |
775 | } |
776 | } | |
777 | else | |
778 | { | |
779 | // nothing to paint - processed | |
cbe874bd | 780 | return true; |
42e69d6b VZ |
781 | } |
782 | } | |
783 | ||
4bc0f25e | 784 | bool wxFrame::HandleSize(int WXUNUSED(x), int WXUNUSED(y), WXUINT id) |
42e69d6b | 785 | { |
4676948b | 786 | #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) |
42e69d6b VZ |
787 | switch ( id ) |
788 | { | |
4bc0f25e VZ |
789 | case SIZE_RESTORED: |
790 | case SIZE_MAXIMIZED: | |
42e69d6b VZ |
791 | // only do it it if we were iconized before, otherwise resizing the |
792 | // parent frame has a curious side effect of bringing it under it's | |
793 | // children | |
794 | if ( !m_iconized ) | |
795 | break; | |
796 | ||
797 | // restore all child frames too | |
cbe874bd | 798 | IconizeChildFrames(false); |
42e69d6b | 799 | |
cbe874bd | 800 | (void)SendIconizeEvent(false); |
42e69d6b VZ |
801 | break; |
802 | ||
4bc0f25e | 803 | case SIZE_MINIMIZED: |
42e69d6b | 804 | // iconize all child frames too |
cbe874bd | 805 | IconizeChildFrames(true); |
42e69d6b VZ |
806 | break; |
807 | } | |
276c8cfb WS |
808 | #else |
809 | wxUnusedVar(id); | |
4bc0f25e | 810 | #endif // !__WXWINCE__ |
42e69d6b VZ |
811 | |
812 | if ( !m_iconized ) | |
813 | { | |
1e6feb95 | 814 | #if wxUSE_STATUSBAR |
42e69d6b | 815 | PositionStatusBar(); |
1e6feb95 VZ |
816 | #endif // wxUSE_STATUSBAR |
817 | ||
818 | #if wxUSE_TOOLBAR | |
42e69d6b | 819 | PositionToolBar(); |
1e6feb95 | 820 | #endif // wxUSE_TOOLBAR |
42e69d6b | 821 | |
3d487566 | 822 | #if defined(WINCE_WITH_COMMANDBAR) |
fb8a56b7 WS |
823 | // Position the menu command bar |
824 | if (GetMenuBar() && GetMenuBar()->GetCommandBar()) | |
825 | { | |
826 | RECT rect; | |
827 | ::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect); | |
828 | wxSize clientSz = GetClientSize(); | |
829 | ||
830 | if ( !::MoveWindow((HWND) GetMenuBar()->GetCommandBar(), 0, 0, clientSz.x, rect.bottom - rect.top, true ) ) | |
831 | { | |
832 | wxLogLastError(wxT("MoveWindow")); | |
833 | } | |
834 | ||
835 | } | |
4bc0f25e | 836 | #endif // WINCE_WITH_COMMANDBAR |
42e69d6b VZ |
837 | } |
838 | ||
4bc0f25e VZ |
839 | // call the base class version to generate the appropriate events |
840 | return false; | |
42e69d6b VZ |
841 | } |
842 | ||
0d53fc34 | 843 | bool wxFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control) |
42e69d6b VZ |
844 | { |
845 | if ( control ) | |
846 | { | |
847 | // In case it's e.g. a toolbar. | |
848 | wxWindow *win = wxFindWinFromHandle(control); | |
849 | if ( win ) | |
850 | return win->MSWCommand(cmd, id); | |
851 | } | |
852 | ||
853 | // handle here commands from menus and accelerators | |
854 | if ( cmd == 0 || cmd == 1 ) | |
855 | { | |
1e6feb95 | 856 | #if wxUSE_MENUS_NATIVE |
42e69d6b VZ |
857 | if ( wxCurrentPopupMenu ) |
858 | { | |
859 | wxMenu *popupMenu = wxCurrentPopupMenu; | |
860 | wxCurrentPopupMenu = NULL; | |
861 | ||
862 | return popupMenu->MSWCommand(cmd, id); | |
863 | } | |
1e6feb95 | 864 | #endif // wxUSE_MENUS_NATIVE |
42e69d6b | 865 | |
3180bc0e | 866 | #if defined(__SMARTPHONE__) && defined(__WXWINCE__) |
fb8a56b7 WS |
867 | // handle here commands from Smartphone menu bar |
868 | if ( wxTopLevelWindow::HandleCommand(id, cmd, control ) ) | |
869 | { | |
870 | return true; | |
871 | } | |
3180bc0e | 872 | #endif // __SMARTPHONE__ && __WXWINCE__ |
fb8a56b7 | 873 | |
42e69d6b VZ |
874 | if ( ProcessCommand(id) ) |
875 | { | |
cbe874bd | 876 | return true; |
42e69d6b VZ |
877 | } |
878 | } | |
879 | ||
cbe874bd | 880 | return false; |
42e69d6b VZ |
881 | } |
882 | ||
0d53fc34 | 883 | bool wxFrame::HandleMenuSelect(WXWORD nItem, WXWORD flags, WXHMENU hMenu) |
a23fd0e1 VZ |
884 | { |
885 | int item; | |
c219cecc | 886 | if ( flags == 0xFFFF && hMenu == 0 ) |
a23fd0e1 | 887 | { |
c219cecc | 888 | // menu was removed from screen |
a23fd0e1 VZ |
889 | item = -1; |
890 | } | |
04ef50df | 891 | #ifndef __WXMICROWIN__ |
c219cecc | 892 | else if ( !(flags & MF_POPUP) && !(flags & MF_SEPARATOR) ) |
a23fd0e1 VZ |
893 | { |
894 | item = nItem; | |
895 | } | |
04ef50df | 896 | #endif |
a23fd0e1 VZ |
897 | else |
898 | { | |
c219cecc | 899 | // don't give hints for separators (doesn't make sense) nor for the |
f6bcfd97 BP |
900 | // items opening popup menus (they don't have them anyhow) but do clear |
901 | // the status line - otherwise, we would be left with the help message | |
902 | // for the previous item which doesn't apply any more | |
cbe874bd | 903 | DoGiveHelp(wxEmptyString, false); |
f6bcfd97 | 904 | |
cbe874bd | 905 | return false; |
a23fd0e1 VZ |
906 | } |
907 | ||
908 | wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, item); | |
ccef86c7 VZ |
909 | event.SetEventObject(this); |
910 | ||
911 | return GetEventHandler()->ProcessEvent(event); | |
912 | } | |
913 | ||
914 | bool wxFrame::HandleMenuLoop(const wxEventType& evtType, WXWORD isPopup) | |
915 | { | |
916 | // we don't have the menu id here, so we use the id to specify if the event | |
917 | // was from a popup menu or a normal one | |
918 | wxMenuEvent event(evtType, isPopup ? -1 : 0); | |
919 | event.SetEventObject(this); | |
a23fd0e1 VZ |
920 | |
921 | return GetEventHandler()->ProcessEvent(event); | |
922 | } | |
923 | ||
924 | // --------------------------------------------------------------------------- | |
0d53fc34 | 925 | // the window proc for wxFrame |
a23fd0e1 VZ |
926 | // --------------------------------------------------------------------------- |
927 | ||
c140b7e7 | 928 | WXLRESULT wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) |
a23fd0e1 | 929 | { |
c140b7e7 | 930 | WXLRESULT rc = 0; |
cbe874bd | 931 | bool processed = false; |
a23fd0e1 VZ |
932 | |
933 | switch ( message ) | |
934 | { | |
42e69d6b VZ |
935 | case WM_CLOSE: |
936 | // if we can't close, tell the system that we processed the | |
937 | // message - otherwise it would close us | |
938 | processed = !Close(); | |
939 | break; | |
940 | ||
ccef86c7 VZ |
941 | case WM_SIZE: |
942 | processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam); | |
943 | break; | |
944 | ||
42e69d6b VZ |
945 | case WM_COMMAND: |
946 | { | |
947 | WORD id, cmd; | |
948 | WXHWND hwnd; | |
949 | UnpackCommand((WXWPARAM)wParam, (WXLPARAM)lParam, | |
950 | &id, &hwnd, &cmd); | |
951 | ||
952 | processed = HandleCommand(id, cmd, (WXHWND)hwnd); | |
953 | } | |
954 | break; | |
955 | ||
ccef86c7 VZ |
956 | case WM_PAINT: |
957 | processed = HandlePaint(); | |
958 | break; | |
959 | ||
92f1a59c JS |
960 | case WM_INITMENUPOPUP: |
961 | processed = HandleInitMenuPopup((WXHMENU) wParam); | |
962 | break; | |
963 | ||
4676948b | 964 | #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) |
a23fd0e1 VZ |
965 | case WM_MENUSELECT: |
966 | { | |
42e69d6b VZ |
967 | WXWORD item, flags; |
968 | WXHMENU hmenu; | |
969 | UnpackMenuSelect(wParam, lParam, &item, &flags, &hmenu); | |
970 | ||
971 | processed = HandleMenuSelect(item, flags, hmenu); | |
a23fd0e1 VZ |
972 | } |
973 | break; | |
bc92cdf9 | 974 | |
ccef86c7 | 975 | case WM_EXITMENULOOP: |
373a5fb3 | 976 | processed = HandleMenuLoop(wxEVT_MENU_CLOSE, (WXWORD)wParam); |
ccef86c7 | 977 | break; |
ccef86c7 | 978 | |
42e69d6b VZ |
979 | case WM_QUERYDRAGICON: |
980 | { | |
f618020a MB |
981 | const wxIcon& icon = GetIcon(); |
982 | HICON hIcon = icon.Ok() ? GetHiconOf(icon) | |
983 | : (HICON)GetDefaultIcon(); | |
42e69d6b VZ |
984 | rc = (long)hIcon; |
985 | processed = rc != 0; | |
986 | } | |
987 | break; | |
ccef86c7 | 988 | #endif // !__WXMICROWIN__ |
a23fd0e1 VZ |
989 | } |
990 | ||
991 | if ( !processed ) | |
7e25f59e | 992 | rc = wxFrameBase::MSWWindowProc(message, wParam, lParam); |
a23fd0e1 VZ |
993 | |
994 | return rc; | |
995 | } | |
21802234 | 996 | |
92f1a59c JS |
997 | // handle WM_INITMENUPOPUP message |
998 | bool wxFrame::HandleInitMenuPopup(WXHMENU hMenu) | |
e39af974 | 999 | { |
92f1a59c JS |
1000 | wxMenu* menu = NULL; |
1001 | if (GetMenuBar()) | |
1002 | { | |
1003 | int nCount = GetMenuBar()->GetMenuCount(); | |
1004 | for (int n = 0; n < nCount; n++) | |
1005 | { | |
1006 | if (GetMenuBar()->GetMenu(n)->GetHMenu() == hMenu) | |
1007 | { | |
1008 | menu = GetMenuBar()->GetMenu(n); | |
1009 | break; | |
1010 | } | |
1011 | } | |
1012 | } | |
cbe874bd | 1013 | |
92f1a59c | 1014 | wxMenuEvent event(wxEVT_MENU_OPEN, 0, menu); |
e39af974 JS |
1015 | event.SetEventObject(this); |
1016 | ||
1017 | return GetEventHandler()->ProcessEvent(event); | |
e39af974 | 1018 | } |
a9928e9d JS |
1019 | |
1020 | // ---------------------------------------------------------------------------- | |
1021 | // wxFrame size management: we exclude the areas taken by menu/status/toolbars | |
1022 | // from the client area, so the client area is what's really available for the | |
1023 | // frame contents | |
1024 | // ---------------------------------------------------------------------------- | |
1025 | ||
1026 | // get the origin of the client area in the client coordinates | |
1027 | wxPoint wxFrame::GetClientAreaOrigin() const | |
1028 | { | |
1029 | wxPoint pt = wxTopLevelWindow::GetClientAreaOrigin(); | |
1030 | ||
1031 | #if wxUSE_TOOLBAR && !defined(__WXUNIVERSAL__) && \ | |
1032 | (!defined(__WXWINCE__) || (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__))) | |
1033 | wxToolBar *toolbar = GetToolBar(); | |
1034 | if ( toolbar && toolbar->IsShown() ) | |
1035 | { | |
1036 | int w, h; | |
1037 | toolbar->GetSize(&w, &h); | |
1038 | ||
1039 | if ( toolbar->GetWindowStyleFlag() & wxTB_VERTICAL ) | |
1040 | { | |
1041 | pt.x += w; | |
1042 | } | |
1043 | else | |
1044 | { | |
1045 | pt.y += h; | |
1046 | } | |
1047 | } | |
1048 | #endif // wxUSE_TOOLBAR | |
1049 | ||
3d487566 | 1050 | #if defined(WINCE_WITH_COMMANDBAR) |
fb8a56b7 WS |
1051 | if (GetMenuBar() && GetMenuBar()->GetCommandBar()) |
1052 | { | |
1053 | RECT rect; | |
1054 | ::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect); | |
1055 | pt.y += (rect.bottom - rect.top); | |
1056 | } | |
a9928e9d JS |
1057 | #endif |
1058 | ||
1059 | return pt; | |
1060 | } |