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