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