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