]>
Commit | Line | Data |
---|---|---|
2bda0e17 | 1 | ///////////////////////////////////////////////////////////////////////////// |
7c0ea335 | 2 | // Name: msw/frame.cpp |
1e6feb95 | 3 | // Purpose: wxFrameMSW |
2bda0e17 KB |
4 | // Author: Julian Smart |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart and Markus Holzem | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
7c0ea335 VZ |
12 | // ============================================================================ |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
2bda0e17 | 20 | #ifdef __GNUG__ |
7c0ea335 | 21 | #pragma implementation "frame.h" |
2bda0e17 KB |
22 | #endif |
23 | ||
24 | // For compilers that support precompilation, includes "wx.h". | |
25 | #include "wx/wxprec.h" | |
26 | ||
27 | #ifdef __BORLANDC__ | |
9f3362c4 | 28 | #pragma hdrstop |
2bda0e17 KB |
29 | #endif |
30 | ||
31 | #ifndef WX_PRECOMP | |
9f3362c4 | 32 | #include "wx/frame.h" |
9f3362c4 | 33 | #include "wx/app.h" |
1e6feb95 | 34 | #include "wx/menu.h" |
9f3362c4 VZ |
35 | #include "wx/utils.h" |
36 | #include "wx/dialog.h" | |
37 | #include "wx/settings.h" | |
38 | #include "wx/dcclient.h" | |
d3cc7c65 | 39 | #include "wx/mdi.h" |
f6bcfd97 | 40 | #include "wx/panel.h" |
9f3362c4 | 41 | #endif // WX_PRECOMP |
2bda0e17 KB |
42 | |
43 | #include "wx/msw/private.h" | |
7c0ea335 VZ |
44 | |
45 | #if wxUSE_STATUSBAR | |
46 | #include "wx/statusbr.h" | |
ed791986 | 47 | #include "wx/generic/statusbr.h" |
7c0ea335 VZ |
48 | #endif // wxUSE_STATUSBAR |
49 | ||
50 | #if wxUSE_TOOLBAR | |
51 | #include "wx/toolbar.h" | |
52 | #endif // wxUSE_TOOLBAR | |
53 | ||
2bda0e17 | 54 | #include "wx/menuitem.h" |
6776a0b2 | 55 | #include "wx/log.h" |
2bda0e17 | 56 | |
1e6feb95 VZ |
57 | #ifdef __WXUNIVERSAL__ |
58 | #include "wx/univ/theme.h" | |
59 | #include "wx/univ/colschem.h" | |
60 | #endif // __WXUNIVERSAL__ | |
61 | ||
7c0ea335 VZ |
62 | // ---------------------------------------------------------------------------- |
63 | // globals | |
64 | // ---------------------------------------------------------------------------- | |
2bda0e17 | 65 | |
a23fd0e1 | 66 | extern wxWindowList wxModelessWindows; |
cde9f08e | 67 | extern wxList WXDLLEXPORT wxPendingDelete; |
2ffa221c | 68 | extern const wxChar *wxFrameClassName; |
1e6feb95 VZ |
69 | |
70 | #if wxUSE_MENUS_NATIVE | |
e1a6fc11 | 71 | extern wxMenu *wxCurrentPopupMenu; |
1e6feb95 | 72 | #endif // wxUSE_MENUS_NATIVE |
2bda0e17 | 73 | |
7c0ea335 VZ |
74 | // ---------------------------------------------------------------------------- |
75 | // event tables | |
76 | // ---------------------------------------------------------------------------- | |
77 | ||
1e6feb95 VZ |
78 | BEGIN_EVENT_TABLE(wxFrameMSW, wxFrameBase) |
79 | EVT_ACTIVATE(wxFrameMSW::OnActivate) | |
80 | EVT_SYS_COLOUR_CHANGED(wxFrameMSW::OnSysColourChanged) | |
2bda0e17 KB |
81 | END_EVENT_TABLE() |
82 | ||
6e264973 | 83 | #ifndef __WXUNIVERSAL__ |
af8964c4 | 84 | IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow) |
6e264973 | 85 | #endif |
2bda0e17 | 86 | |
7c0ea335 VZ |
87 | // ============================================================================ |
88 | // implementation | |
89 | // ============================================================================ | |
90 | ||
91 | // ---------------------------------------------------------------------------- | |
92 | // static class members | |
93 | // ---------------------------------------------------------------------------- | |
94 | ||
1e6feb95 VZ |
95 | #if wxUSE_STATUSBAR |
96 | #if wxUSE_NATIVE_STATUSBAR | |
97 | bool wxFrameMSW::m_useNativeStatusBar = TRUE; | |
98 | #else | |
99 | bool wxFrameMSW::m_useNativeStatusBar = FALSE; | |
100 | #endif | |
101 | #endif // wxUSE_NATIVE_STATUSBAR | |
2bda0e17 | 102 | |
7c0ea335 VZ |
103 | // ---------------------------------------------------------------------------- |
104 | // creation/destruction | |
105 | // ---------------------------------------------------------------------------- | |
2bda0e17 | 106 | |
1e6feb95 | 107 | void wxFrameMSW::Init() |
2bda0e17 | 108 | { |
bf505d28 VZ |
109 | m_iconized = |
110 | m_maximizeOnShow = FALSE; | |
7c0ea335 | 111 | |
9f3362c4 VZ |
112 | #if wxUSE_TOOLTIPS |
113 | m_hwndToolTip = 0; | |
114 | #endif | |
a2327a9f JS |
115 | |
116 | // Data to save/restore when calling ShowFullScreen | |
117 | m_fsStyle = 0; | |
118 | m_fsOldWindowStyle = 0; | |
119 | m_fsStatusBarFields = 0; | |
120 | m_fsStatusBarHeight = 0; | |
121 | m_fsToolBarHeight = 0; | |
f6bcfd97 | 122 | // m_fsMenu = 0; |
a2327a9f JS |
123 | m_fsIsMaximized = FALSE; |
124 | m_fsIsShowing = FALSE; | |
f6bcfd97 BP |
125 | |
126 | m_winLastFocused = (wxWindow *)NULL; | |
127 | ||
128 | // unlike (almost?) all other windows, frames are created hidden | |
129 | m_isShown = FALSE; | |
7c0ea335 | 130 | } |
9f3362c4 | 131 | |
1e6feb95 | 132 | bool wxFrameMSW::Create(wxWindow *parent, |
7c0ea335 VZ |
133 | wxWindowID id, |
134 | const wxString& title, | |
135 | const wxPoint& pos, | |
136 | const wxSize& size, | |
137 | long style, | |
138 | const wxString& name) | |
139 | { | |
2bda0e17 | 140 | SetName(name); |
2bda0e17 | 141 | m_windowStyle = style; |
2bda0e17 KB |
142 | |
143 | SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE)); | |
144 | ||
2bda0e17 KB |
145 | if ( id > -1 ) |
146 | m_windowId = id; | |
147 | else | |
148 | m_windowId = (int)NewControlId(); | |
149 | ||
150 | if (parent) parent->AddChild(this); | |
151 | ||
152 | int x = pos.x; | |
153 | int y = pos.y; | |
154 | int width = size.x; | |
155 | int height = size.y; | |
156 | ||
157 | m_iconized = FALSE; | |
d2aef312 | 158 | |
f6bcfd97 | 159 | wxTopLevelWindows.Append(this); |
319fefa9 | 160 | |
aeab10d0 | 161 | MSWCreate(m_windowId, parent, wxFrameClassName, this, title, |
d2aef312 | 162 | x, y, width, height, style); |
2bda0e17 KB |
163 | |
164 | wxModelessWindows.Append(this); | |
f6bcfd97 | 165 | |
2bda0e17 KB |
166 | return TRUE; |
167 | } | |
168 | ||
1e6feb95 | 169 | wxFrameMSW::~wxFrameMSW() |
2bda0e17 KB |
170 | { |
171 | m_isBeingDeleted = TRUE; | |
172 | wxTopLevelWindows.DeleteObject(this); | |
173 | ||
f6bcfd97 BP |
174 | // the ~wxToolBar() code relies on the previous line to be executed before |
175 | // this one, i.e. the frame should remove itself from wxTopLevelWindows | |
176 | // before destorying its toolbar | |
7c0ea335 | 177 | DeleteAllBars(); |
2bda0e17 KB |
178 | |
179 | if (wxTheApp && (wxTopLevelWindows.Number() == 0)) | |
180 | { | |
181 | wxTheApp->SetTopWindow(NULL); | |
182 | ||
183 | if (wxTheApp->GetExitOnFrameDelete()) | |
184 | { | |
185 | PostQuitMessage(0); | |
186 | } | |
187 | } | |
188 | ||
189 | wxModelessWindows.DeleteObject(this); | |
190 | ||
191 | // For some reason, wxWindows can activate another task altogether | |
192 | // when a frame is destroyed after a modal dialog has been invoked. | |
193 | // Try to bring the parent to the top. | |
36e2955a UM |
194 | // MT:Only do this if this frame is currently the active window, else weird |
195 | // things start to happen | |
196 | if ( wxGetActiveWindow() == this ) | |
2bda0e17 KB |
197 | if (GetParent() && GetParent()->GetHWND()) |
198 | ::BringWindowToTop((HWND) GetParent()->GetHWND()); | |
199 | } | |
200 | ||
81d66cf3 | 201 | // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc. |
1e6feb95 | 202 | void wxFrameMSW::DoGetClientSize(int *x, int *y) const |
2bda0e17 KB |
203 | { |
204 | RECT rect; | |
42e69d6b | 205 | ::GetClientRect(GetHwnd(), &rect); |
2bda0e17 | 206 | |
7c0ea335 | 207 | #if wxUSE_STATUSBAR |
a2327a9f | 208 | if ( GetStatusBar() && GetStatusBar()->IsShown() ) |
2bda0e17 | 209 | { |
81d66cf3 JS |
210 | int statusX, statusY; |
211 | GetStatusBar()->GetClientSize(&statusX, &statusY); | |
212 | rect.bottom -= statusY; | |
2bda0e17 | 213 | } |
7c0ea335 | 214 | #endif // wxUSE_STATUSBAR |
81d66cf3 JS |
215 | |
216 | wxPoint pt(GetClientAreaOrigin()); | |
217 | rect.bottom -= pt.y; | |
218 | rect.right -= pt.x; | |
219 | ||
0655ad29 VZ |
220 | if ( x ) |
221 | *x = rect.right; | |
222 | if ( y ) | |
223 | *y = rect.bottom; | |
2bda0e17 KB |
224 | } |
225 | ||
226 | // Set the client size (i.e. leave the calculation of borders etc. | |
227 | // to wxWindows) | |
1e6feb95 | 228 | void wxFrameMSW::DoSetClientSize(int width, int height) |
2bda0e17 | 229 | { |
8d8bd249 | 230 | HWND hWnd = GetHwnd(); |
2bda0e17 | 231 | |
8d8bd249 VZ |
232 | RECT rectClient; |
233 | ::GetClientRect(hWnd, &rectClient); | |
2bda0e17 | 234 | |
8d8bd249 VZ |
235 | RECT rectTotal; |
236 | ::GetWindowRect(hWnd, &rectTotal); | |
2bda0e17 | 237 | |
8d8bd249 VZ |
238 | // Find the difference between the entire window (title bar and all) |
239 | // and the client area; add this to the new client size to move the | |
240 | // window | |
241 | width += rectTotal.right - rectTotal.left - rectClient.right; | |
242 | height += rectTotal.bottom - rectTotal.top - rectClient.bottom; | |
2bda0e17 | 243 | |
7c0ea335 | 244 | #if wxUSE_STATUSBAR |
8d8bd249 VZ |
245 | wxStatusBar *statbar = GetStatusBar(); |
246 | if ( statbar && statbar->IsShown() ) | |
247 | { | |
248 | // leave enough space for the status bar | |
249 | height += statbar->GetSize().y; | |
250 | } | |
7c0ea335 | 251 | #endif // wxUSE_STATUSBAR |
2bda0e17 | 252 | |
8d8bd249 VZ |
253 | // note that this takes the toolbar into account |
254 | wxPoint pt = GetClientAreaOrigin(); | |
255 | width += pt.x; | |
256 | height += pt.y; | |
2bda0e17 | 257 | |
8d8bd249 VZ |
258 | if ( !::MoveWindow(hWnd, rectTotal.left, rectTotal.top, |
259 | width, height, TRUE /* redraw */) ) | |
260 | { | |
261 | wxLogLastError(_T("MoveWindow")); | |
262 | } | |
debe6624 | 263 | |
8d8bd249 VZ |
264 | wxSizeEvent event(wxSize(width, height), m_windowId); |
265 | event.SetEventObject(this); | |
266 | GetEventHandler()->ProcessEvent(event); | |
2bda0e17 KB |
267 | } |
268 | ||
1e6feb95 | 269 | void wxFrameMSW::DoGetSize(int *width, int *height) const |
2bda0e17 | 270 | { |
3dd9b88a VZ |
271 | RECT rect; |
272 | ::GetWindowRect(GetHwnd(), &rect); | |
273 | ||
274 | *width = rect.right - rect.left; | |
275 | *height = rect.bottom - rect.top; | |
2bda0e17 KB |
276 | } |
277 | ||
1e6feb95 | 278 | void wxFrameMSW::DoGetPosition(int *x, int *y) const |
2bda0e17 | 279 | { |
3dd9b88a VZ |
280 | RECT rect; |
281 | ::GetWindowRect(GetHwnd(), &rect); | |
2bda0e17 | 282 | |
3dd9b88a VZ |
283 | *x = rect.left; |
284 | *y = rect.top; | |
2bda0e17 KB |
285 | } |
286 | ||
7c0ea335 VZ |
287 | // ---------------------------------------------------------------------------- |
288 | // variations around ::ShowWindow() | |
289 | // ---------------------------------------------------------------------------- | |
290 | ||
1e6feb95 | 291 | void wxFrameMSW::DoShowWindow(int nShowCmd) |
7c0ea335 VZ |
292 | { |
293 | ::ShowWindow(GetHwnd(), nShowCmd); | |
294 | ||
295 | m_iconized = nShowCmd == SW_MINIMIZE; | |
296 | } | |
297 | ||
1e6feb95 | 298 | bool wxFrameMSW::Show(bool show) |
2bda0e17 | 299 | { |
f6bcfd97 BP |
300 | // don't use wxWindow version as we want to call DoShowWindow() |
301 | if ( !wxWindowBase::Show(show) ) | |
302 | return FALSE; | |
303 | ||
bf505d28 VZ |
304 | int nShowCmd; |
305 | if ( show ) | |
306 | { | |
307 | if ( m_maximizeOnShow ) | |
308 | { | |
309 | // show and maximize | |
310 | nShowCmd = SW_MAXIMIZE; | |
311 | ||
312 | m_maximizeOnShow = FALSE; | |
313 | } | |
314 | else // just show | |
315 | { | |
316 | nShowCmd = SW_SHOW; | |
317 | } | |
318 | } | |
319 | else // hide | |
320 | { | |
321 | nShowCmd = SW_HIDE; | |
322 | } | |
323 | ||
324 | DoShowWindow(nShowCmd); | |
2bda0e17 | 325 | |
7c0ea335 | 326 | if ( show ) |
2bda0e17 | 327 | { |
7c0ea335 | 328 | ::BringWindowToTop(GetHwnd()); |
2bda0e17 | 329 | |
7c0ea335 VZ |
330 | wxActivateEvent event(wxEVT_ACTIVATE, TRUE, m_windowId); |
331 | event.SetEventObject( this ); | |
332 | GetEventHandler()->ProcessEvent(event); | |
333 | } | |
bf505d28 | 334 | else // hide |
7c0ea335 VZ |
335 | { |
336 | // Try to highlight the correct window (the parent) | |
337 | if ( GetParent() ) | |
338 | { | |
339 | HWND hWndParent = GetHwndOf(GetParent()); | |
340 | if (hWndParent) | |
341 | ::BringWindowToTop(hWndParent); | |
342 | } | |
343 | } | |
2bda0e17 | 344 | |
7c0ea335 | 345 | return TRUE; |
2bda0e17 KB |
346 | } |
347 | ||
1e6feb95 | 348 | void wxFrameMSW::Iconize(bool iconize) |
2bda0e17 | 349 | { |
7c0ea335 | 350 | DoShowWindow(iconize ? SW_MINIMIZE : SW_RESTORE); |
2bda0e17 KB |
351 | } |
352 | ||
1e6feb95 | 353 | void wxFrameMSW::Maximize(bool maximize) |
2bda0e17 | 354 | { |
bf505d28 VZ |
355 | if ( IsShown() ) |
356 | { | |
357 | // just maximize it directly | |
358 | DoShowWindow(maximize ? SW_MAXIMIZE : SW_RESTORE); | |
359 | } | |
360 | else // hidden | |
361 | { | |
362 | // we can't maximize the hidden frame because it shows it as well, so | |
363 | // just remember that we should do it later in this case | |
364 | m_maximizeOnShow = TRUE; | |
365 | } | |
7c0ea335 VZ |
366 | } |
367 | ||
1e6feb95 | 368 | void wxFrameMSW::Restore() |
7c0ea335 VZ |
369 | { |
370 | DoShowWindow(SW_RESTORE); | |
2bda0e17 KB |
371 | } |
372 | ||
1e6feb95 | 373 | bool wxFrameMSW::IsIconized() const |
2bda0e17 | 374 | { |
04ef50df JS |
375 | #ifdef __WXMICROWIN__ |
376 | // TODO | |
377 | return FALSE; | |
378 | #else | |
1e6feb95 | 379 | ((wxFrameMSW *)this)->m_iconized = (::IsIconic(GetHwnd()) != 0); |
2bda0e17 | 380 | return m_iconized; |
04ef50df | 381 | #endif |
2bda0e17 KB |
382 | } |
383 | ||
6f63ec3f | 384 | // Is it maximized? |
1e6feb95 | 385 | bool wxFrameMSW::IsMaximized() const |
6f63ec3f | 386 | { |
04ef50df JS |
387 | #ifdef __WXMICROWIN__ |
388 | // TODO | |
389 | return FALSE; | |
390 | #else | |
7c0ea335 | 391 | return (::IsZoomed(GetHwnd()) != 0); |
04ef50df | 392 | #endif |
2bda0e17 KB |
393 | } |
394 | ||
1e6feb95 | 395 | void wxFrameMSW::SetIcon(const wxIcon& icon) |
2bda0e17 | 396 | { |
7c0ea335 VZ |
397 | wxFrameBase::SetIcon(icon); |
398 | ||
04ef50df | 399 | #if defined(__WIN95__) && !defined(__WXMICROWIN__) |
7c0ea335 VZ |
400 | if ( m_icon.Ok() ) |
401 | { | |
402 | SendMessage(GetHwnd(), WM_SETICON, | |
403 | (WPARAM)TRUE, (LPARAM)(HICON) m_icon.GetHICON()); | |
404 | } | |
405 | #endif // __WIN95__ | |
2bda0e17 KB |
406 | } |
407 | ||
67bd5bad | 408 | // generate an artificial resize event |
3a12b404 | 409 | void wxFrameMSW::SendSizeEvent() |
67bd5bad GT |
410 | { |
411 | RECT r; | |
412 | #ifdef __WIN16__ | |
413 | ::GetWindowRect(GetHwnd(), &r); | |
414 | #else | |
415 | if ( !::GetWindowRect(GetHwnd(), &r) ) | |
416 | { | |
417 | wxLogLastError(_T("GetWindowRect")); | |
418 | } | |
419 | #endif | |
420 | ||
421 | if ( !m_iconized ) | |
422 | { | |
423 | (void)::PostMessage(GetHwnd(), WM_SIZE, | |
424 | IsMaximized() ? SIZE_MAXIMIZED : SIZE_RESTORED, | |
425 | MAKELPARAM(r.right - r.left, r.bottom - r.top)); | |
426 | } | |
427 | } | |
428 | ||
d427503c | 429 | #if wxUSE_STATUSBAR |
1e6feb95 | 430 | wxStatusBar *wxFrameMSW::OnCreateStatusBar(int number, |
7c0ea335 VZ |
431 | long style, |
432 | wxWindowID id, | |
433 | const wxString& name) | |
2bda0e17 KB |
434 | { |
435 | wxStatusBar *statusBar = NULL; | |
436 | ||
47d67540 | 437 | #if wxUSE_NATIVE_STATUSBAR |
1f0500b3 | 438 | if ( !UsesNativeStatusBar() ) |
2bda0e17 | 439 | { |
1f0500b3 | 440 | statusBar = (wxStatusBar *)new wxStatusBarGeneric(this, id, style); |
2bda0e17 KB |
441 | } |
442 | else | |
443 | #endif | |
444 | { | |
1f0500b3 VZ |
445 | statusBar = new wxStatusBar(this, id, style, name); |
446 | } | |
ed791986 | 447 | |
1f0500b3 VZ |
448 | // Set the height according to the font and the border size |
449 | wxClientDC dc(statusBar); | |
450 | dc.SetFont(statusBar->GetFont()); | |
ed791986 | 451 | |
1f0500b3 VZ |
452 | wxCoord y; |
453 | dc.GetTextExtent(_T("X"), NULL, &y ); | |
ed791986 | 454 | |
1f0500b3 | 455 | int height = (int)( (11*y)/10 + 2*statusBar->GetBorderY()); |
ed791986 | 456 | |
1f0500b3 | 457 | statusBar->SetSize(-1, -1, -1, height); |
ed791986 | 458 | |
1f0500b3 | 459 | statusBar->SetFieldsCount(number); |
2bda0e17 | 460 | |
7c0ea335 | 461 | return statusBar; |
2bda0e17 KB |
462 | } |
463 | ||
1e6feb95 | 464 | void wxFrameMSW::PositionStatusBar() |
2bda0e17 | 465 | { |
ed791986 VZ |
466 | if ( !m_frameStatusBar ) |
467 | return; | |
468 | ||
cbc66a27 VZ |
469 | int w, h; |
470 | GetClientSize(&w, &h); | |
471 | int sw, sh; | |
472 | m_frameStatusBar->GetSize(&sw, &sh); | |
473 | ||
474 | // Since we wish the status bar to be directly under the client area, | |
475 | // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS. | |
476 | m_frameStatusBar->SetSize(0, h, w, sh); | |
2bda0e17 | 477 | } |
d427503c | 478 | #endif // wxUSE_STATUSBAR |
2bda0e17 | 479 | |
6522713c | 480 | #if wxUSE_MENUS_NATIVE |
ea9a4296 | 481 | |
6522713c | 482 | void wxFrameMSW::AttachMenuBar(wxMenuBar *menubar) |
2bda0e17 | 483 | { |
6beb85c0 VZ |
484 | m_frameMenuBar = menubar; |
485 | ||
f6bcfd97 | 486 | if ( !menubar ) |
c2dcfdef | 487 | { |
f6bcfd97 BP |
488 | // actually remove the menu from the frame |
489 | m_hMenu = (WXHMENU)0; | |
490 | InternalSetMenuBar(); | |
065de612 | 491 | } |
f6bcfd97 | 492 | else // set new non NULL menu bar |
065de612 | 493 | { |
f6bcfd97 | 494 | // Can set a menubar several times. |
f6bcfd97 BP |
495 | if ( menubar->GetHMenu() ) |
496 | { | |
497 | m_hMenu = menubar->GetHMenu(); | |
498 | } | |
499 | else | |
500 | { | |
6522713c | 501 | if ( menubar->IsAttached() ) |
ff8b6290 | 502 | menubar->Detach(); |
065de612 | 503 | |
f6bcfd97 | 504 | m_hMenu = menubar->Create(); |
065de612 | 505 | |
f6bcfd97 BP |
506 | if ( !m_hMenu ) |
507 | return; | |
508 | } | |
065de612 | 509 | |
f6bcfd97 | 510 | InternalSetMenuBar(); |
1e6feb95 | 511 | } |
2bda0e17 KB |
512 | } |
513 | ||
1e6feb95 | 514 | void wxFrameMSW::InternalSetMenuBar() |
2bda0e17 | 515 | { |
04ef50df | 516 | #ifndef __WXMICROWIN__ |
42e69d6b | 517 | if ( !::SetMenu(GetHwnd(), (HMENU)m_hMenu) ) |
2bda0e17 | 518 | { |
f6bcfd97 | 519 | wxLogLastError(wxT("SetMenu")); |
2bda0e17 | 520 | } |
04ef50df | 521 | #endif |
2bda0e17 KB |
522 | } |
523 | ||
1e6feb95 VZ |
524 | #endif // wxUSE_MENUS_NATIVE |
525 | ||
2bda0e17 | 526 | // Responds to colour changes, and passes event on to children. |
1e6feb95 | 527 | void wxFrameMSW::OnSysColourChanged(wxSysColourChangedEvent& event) |
2bda0e17 KB |
528 | { |
529 | SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE)); | |
530 | Refresh(); | |
531 | ||
1e6feb95 | 532 | #if wxUSE_STATUSBAR |
2bda0e17 KB |
533 | if ( m_frameStatusBar ) |
534 | { | |
535 | wxSysColourChangedEvent event2; | |
536 | event2.SetEventObject( m_frameStatusBar ); | |
02800301 | 537 | m_frameStatusBar->GetEventHandler()->ProcessEvent(event2); |
2bda0e17 | 538 | } |
1e6feb95 | 539 | #endif // wxUSE_STATUSBAR |
2bda0e17 KB |
540 | |
541 | // Propagate the event to the non-top-level children | |
542 | wxWindow::OnSysColourChanged(event); | |
543 | } | |
544 | ||
a2327a9f | 545 | // Pass TRUE to show full screen, FALSE to restore. |
1e6feb95 | 546 | bool wxFrameMSW::ShowFullScreen(bool show, long style) |
a2327a9f JS |
547 | { |
548 | if (show) | |
549 | { | |
550 | if (IsFullScreen()) | |
551 | return FALSE; | |
552 | ||
553 | m_fsIsShowing = TRUE; | |
554 | m_fsStyle = style; | |
555 | ||
1e6feb95 | 556 | #if wxUSE_TOOLBAR |
f6bcfd97 | 557 | wxToolBar *theToolBar = GetToolBar(); |
a2327a9f | 558 | if (theToolBar) |
1e6feb95 | 559 | theToolBar->GetSize(NULL, &m_fsToolBarHeight); |
a2327a9f JS |
560 | |
561 | // zap the toolbar, menubar, and statusbar | |
562 | ||
563 | if ((style & wxFULLSCREEN_NOTOOLBAR) && theToolBar) | |
564 | { | |
565 | theToolBar->SetSize(-1,0); | |
566 | theToolBar->Show(FALSE); | |
567 | } | |
1e6feb95 | 568 | #endif // wxUSE_TOOLBAR |
a2327a9f | 569 | |
04ef50df | 570 | #ifndef __WXMICROWIN__ |
a2327a9f JS |
571 | if (style & wxFULLSCREEN_NOMENUBAR) |
572 | SetMenu((HWND)GetHWND(), (HMENU) NULL); | |
04ef50df | 573 | #endif |
a2327a9f | 574 | |
1e6feb95 VZ |
575 | #if wxUSE_STATUSBAR |
576 | wxStatusBar *theStatusBar = GetStatusBar(); | |
577 | if (theStatusBar) | |
578 | theStatusBar->GetSize(NULL, &m_fsStatusBarHeight); | |
579 | ||
a2327a9f JS |
580 | // Save the number of fields in the statusbar |
581 | if ((style & wxFULLSCREEN_NOSTATUSBAR) && theStatusBar) | |
582 | { | |
579b10c2 JS |
583 | //m_fsStatusBarFields = theStatusBar->GetFieldsCount(); |
584 | //SetStatusBar((wxStatusBar*) NULL); | |
585 | //delete theStatusBar; | |
586 | theStatusBar->Show(FALSE); | |
a2327a9f JS |
587 | } |
588 | else | |
589 | m_fsStatusBarFields = 0; | |
1e6feb95 | 590 | #endif // wxUSE_STATUSBAR |
a2327a9f JS |
591 | |
592 | // zap the frame borders | |
593 | ||
594 | // save the 'normal' window style | |
595 | m_fsOldWindowStyle = GetWindowLong((HWND)GetHWND(), GWL_STYLE); | |
596 | ||
f6bcfd97 | 597 | // save the old position, width & height, maximize state |
a2327a9f | 598 | m_fsOldSize = GetRect(); |
f6bcfd97 | 599 | m_fsIsMaximized = IsMaximized(); |
a2327a9f | 600 | |
f6bcfd97 | 601 | // decide which window style flags to turn off |
a2327a9f JS |
602 | LONG newStyle = m_fsOldWindowStyle; |
603 | LONG offFlags = 0; | |
604 | ||
605 | if (style & wxFULLSCREEN_NOBORDER) | |
606 | offFlags |= WS_BORDER; | |
607 | if (style & wxFULLSCREEN_NOCAPTION) | |
608 | offFlags |= (WS_CAPTION | WS_SYSMENU); | |
609 | ||
610 | newStyle &= (~offFlags); | |
611 | ||
612 | // change our window style to be compatible with full-screen mode | |
613 | SetWindowLong((HWND)GetHWND(), GWL_STYLE, newStyle); | |
614 | ||
615 | // resize to the size of the desktop | |
616 | int width, height; | |
617 | ||
618 | RECT rect; | |
619 | ::GetWindowRect(GetDesktopWindow(), &rect); | |
620 | width = rect.right - rect.left; | |
621 | height = rect.bottom - rect.top; | |
622 | ||
623 | SetSize(width, height); | |
624 | ||
625 | // now flush the window style cache and actually go full-screen | |
626 | SetWindowPos((HWND)GetHWND(), HWND_TOP, 0, 0, width, height, SWP_FRAMECHANGED); | |
627 | ||
628 | wxSizeEvent event(wxSize(width, height), GetId()); | |
629 | GetEventHandler()->ProcessEvent(event); | |
630 | ||
631 | return TRUE; | |
632 | } | |
633 | else | |
634 | { | |
635 | if (!IsFullScreen()) | |
636 | return FALSE; | |
637 | ||
638 | m_fsIsShowing = FALSE; | |
639 | ||
1e6feb95 | 640 | #if wxUSE_TOOLBAR |
a2327a9f JS |
641 | wxToolBar *theToolBar = GetToolBar(); |
642 | ||
643 | // restore the toolbar, menubar, and statusbar | |
644 | if (theToolBar && (m_fsStyle & wxFULLSCREEN_NOTOOLBAR)) | |
645 | { | |
646 | theToolBar->SetSize(-1, m_fsToolBarHeight); | |
647 | theToolBar->Show(TRUE); | |
648 | } | |
1e6feb95 | 649 | #endif // wxUSE_TOOLBAR |
a2327a9f | 650 | |
1e6feb95 VZ |
651 | #if wxUSE_STATUSBAR |
652 | if ( m_fsStyle & wxFULLSCREEN_NOSTATUSBAR ) | |
a2327a9f | 653 | { |
579b10c2 JS |
654 | //CreateStatusBar(m_fsStatusBarFields); |
655 | if (GetStatusBar()) | |
656 | { | |
657 | GetStatusBar()->Show(TRUE); | |
658 | PositionStatusBar(); | |
659 | } | |
a2327a9f | 660 | } |
1e6feb95 | 661 | #endif // wxUSE_STATUSBAR |
a2327a9f | 662 | |
04ef50df | 663 | #ifndef __WXMICROWIN__ |
a2327a9f JS |
664 | if ((m_fsStyle & wxFULLSCREEN_NOMENUBAR) && (m_hMenu != 0)) |
665 | SetMenu((HWND)GetHWND(), (HMENU)m_hMenu); | |
04ef50df | 666 | #endif |
a2327a9f JS |
667 | |
668 | Maximize(m_fsIsMaximized); | |
669 | SetWindowLong((HWND)GetHWND(),GWL_STYLE, m_fsOldWindowStyle); | |
670 | SetWindowPos((HWND)GetHWND(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y, | |
671 | m_fsOldSize.width, m_fsOldSize.height, SWP_FRAMECHANGED); | |
672 | ||
673 | return TRUE; | |
674 | } | |
675 | } | |
676 | ||
2bda0e17 KB |
677 | /* |
678 | * Frame window | |
679 | * | |
680 | */ | |
681 | ||
1e6feb95 | 682 | bool wxFrameMSW::MSWCreate(int id, wxWindow *parent, const wxChar *wclass, wxWindow *wx_win, const wxChar *title, |
debe6624 | 683 | int x, int y, int width, int height, long style) |
2bda0e17 KB |
684 | |
685 | { | |
686 | m_defaultIcon = (WXHICON) (wxSTD_FRAME_ICON ? wxSTD_FRAME_ICON : wxDEFAULT_FRAME_ICON); | |
687 | ||
688 | // If child windows aren't properly drawn initially, WS_CLIPCHILDREN | |
689 | // could be the culprit. But without it, you can get a lot of flicker. | |
690 | ||
2bda0e17 | 691 | DWORD msflags = 0; |
3ca6a5f0 BP |
692 | if ( style & wxCAPTION ) |
693 | { | |
694 | if ( style & wxFRAME_TOOL_WINDOW ) | |
695 | msflags |= WS_POPUPWINDOW; | |
696 | else | |
697 | msflags |= WS_OVERLAPPED; | |
698 | } | |
2bda0e17 | 699 | else |
3ca6a5f0 BP |
700 | { |
701 | msflags |= WS_POPUP; | |
702 | } | |
2bda0e17 KB |
703 | |
704 | if (style & wxMINIMIZE_BOX) | |
705 | msflags |= WS_MINIMIZEBOX; | |
706 | if (style & wxMAXIMIZE_BOX) | |
707 | msflags |= WS_MAXIMIZEBOX; | |
708 | if (style & wxTHICK_FRAME) | |
709 | msflags |= WS_THICKFRAME; | |
710 | if (style & wxSYSTEM_MENU) | |
711 | msflags |= WS_SYSMENU; | |
f6bcfd97 | 712 | if ( style & wxMINIMIZE ) |
2bda0e17 KB |
713 | msflags |= WS_MINIMIZE; |
714 | if (style & wxMAXIMIZE) | |
715 | msflags |= WS_MAXIMIZE; | |
716 | if (style & wxCAPTION) | |
717 | msflags |= WS_CAPTION; | |
1c089c47 JS |
718 | if (style & wxCLIP_CHILDREN) |
719 | msflags |= WS_CLIPCHILDREN; | |
2bda0e17 | 720 | |
1e6feb95 | 721 | // Keep this in wxFrameMSW because it saves recoding this function |
2bda0e17 | 722 | // in wxTinyFrame |
8355a72f | 723 | #if wxUSE_ITSY_BITSY && !defined(__WIN32__) |
2bda0e17 KB |
724 | if (style & wxTINY_CAPTION_VERT) |
725 | msflags |= IBS_VERTCAPTION; | |
726 | if (style & wxTINY_CAPTION_HORIZ) | |
727 | msflags |= IBS_HORZCAPTION; | |
728 | #else | |
729 | if (style & wxTINY_CAPTION_VERT) | |
730 | msflags |= WS_CAPTION; | |
731 | if (style & wxTINY_CAPTION_HORIZ) | |
732 | msflags |= WS_CAPTION; | |
733 | #endif | |
734 | if ((style & wxTHICK_FRAME) == 0) | |
735 | msflags |= WS_BORDER; | |
736 | ||
737 | WXDWORD extendedStyle = MakeExtendedStyle(style); | |
738 | ||
b0a6bb75 | 739 | // make all frames appear in the win9x shell taskbar unless |
b3daa5a3 | 740 | // wxFRAME_TOOL_WINDOW or wxFRAME_NO_TASKBAR is given - without giving them |
b0a6bb75 | 741 | // WS_EX_APPWINDOW style, the child (i.e. owned) frames wouldn't appear in it |
2432b92d | 742 | #if !defined(__WIN16__) && !defined(__SC__) |
4b9fc37a GT |
743 | if ( (style & wxFRAME_TOOL_WINDOW) || |
744 | (style & wxFRAME_NO_TASKBAR) ) | |
b0a6bb75 | 745 | extendedStyle |= WS_EX_TOOLWINDOW; |
b3daa5a3 | 746 | else if ( !(style & wxFRAME_NO_TASKBAR) ) |
b0a6bb75 | 747 | extendedStyle |= WS_EX_APPWINDOW; |
1e6d9499 | 748 | #endif |
cd2df130 | 749 | |
2bda0e17 KB |
750 | if (style & wxSTAY_ON_TOP) |
751 | extendedStyle |= WS_EX_TOPMOST; | |
752 | ||
4204da65 | 753 | #ifndef __WIN16__ |
b96340e6 JS |
754 | if (m_exStyle & wxFRAME_EX_CONTEXTHELP) |
755 | extendedStyle |= WS_EX_CONTEXTHELP; | |
4204da65 | 756 | #endif |
b96340e6 | 757 | |
2bda0e17 | 758 | m_iconized = FALSE; |
a23fd0e1 VZ |
759 | if ( !wxWindow::MSWCreate(id, parent, wclass, wx_win, title, x, y, width, height, |
760 | msflags, NULL, extendedStyle) ) | |
761 | return FALSE; | |
762 | ||
2bda0e17 KB |
763 | // Seems to be necessary if we use WS_POPUP |
764 | // style instead of WS_OVERLAPPED | |
765 | if (width > -1 && height > -1) | |
42e69d6b | 766 | ::PostMessage(GetHwnd(), WM_SIZE, SIZE_RESTORED, MAKELPARAM(width, height)); |
a23fd0e1 VZ |
767 | |
768 | return TRUE; | |
2bda0e17 KB |
769 | } |
770 | ||
2bda0e17 KB |
771 | // Default activation behaviour - set the focus for the first child |
772 | // subwindow found. | |
1e6feb95 | 773 | void wxFrameMSW::OnActivate(wxActivateEvent& event) |
2bda0e17 | 774 | { |
f6bcfd97 | 775 | if ( event.GetActive() ) |
00c4e897 | 776 | { |
f6bcfd97 | 777 | // restore focus to the child which was last focused |
1e6feb95 | 778 | wxLogTrace(_T("focus"), _T("wxFrameMSW %08x activated."), m_hWnd); |
00c4e897 | 779 | |
e9456d8d VZ |
780 | wxWindow *parent = m_winLastFocused ? m_winLastFocused->GetParent() |
781 | : NULL; | |
782 | if ( !parent ) | |
783 | { | |
784 | parent = this; | |
785 | } | |
786 | ||
787 | wxSetFocusToChild(parent, &m_winLastFocused); | |
00c4e897 | 788 | } |
e9456d8d | 789 | else // deactivating |
2bda0e17 | 790 | { |
e9456d8d | 791 | // remember the last focused child if it is our child |
f6bcfd97 | 792 | m_winLastFocused = FindFocus(); |
e9456d8d VZ |
793 | |
794 | // so we NULL it out if it's a child from some other frame | |
795 | wxWindow *win = m_winLastFocused; | |
796 | while ( win ) | |
319fefa9 | 797 | { |
e9456d8d VZ |
798 | if ( win->IsTopLevel() ) |
799 | { | |
800 | if ( win != this ) | |
801 | { | |
802 | m_winLastFocused = NULL; | |
803 | } | |
804 | ||
f6bcfd97 | 805 | break; |
e9456d8d | 806 | } |
f6bcfd97 | 807 | |
e9456d8d | 808 | win = win->GetParent(); |
319fefa9 | 809 | } |
f6bcfd97 BP |
810 | |
811 | wxLogTrace(_T("focus"), | |
1e6feb95 | 812 | _T("wxFrameMSW %08x deactivated, last focused: %08x."), |
f6bcfd97 BP |
813 | m_hWnd, |
814 | m_winLastFocused ? GetHwndOf(m_winLastFocused) | |
815 | : NULL); | |
816 | ||
817 | event.Skip(); | |
2bda0e17 | 818 | } |
2bda0e17 KB |
819 | } |
820 | ||
7c0ea335 VZ |
821 | // ---------------------------------------------------------------------------- |
822 | // tool/status bar stuff | |
823 | // ---------------------------------------------------------------------------- | |
824 | ||
d427503c | 825 | #if wxUSE_TOOLBAR |
7c0ea335 | 826 | |
1e6feb95 | 827 | wxToolBar* wxFrameMSW::CreateToolBar(long style, wxWindowID id, const wxString& name) |
81d66cf3 | 828 | { |
7c0ea335 | 829 | if ( wxFrameBase::CreateToolBar(style, id, name) ) |
81d66cf3 | 830 | { |
81d66cf3 | 831 | PositionToolBar(); |
81d66cf3 | 832 | } |
81d66cf3 | 833 | |
7c0ea335 | 834 | return m_frameToolBar; |
81d66cf3 JS |
835 | } |
836 | ||
1e6feb95 | 837 | void wxFrameMSW::PositionToolBar() |
81d66cf3 | 838 | { |
81d66cf3 | 839 | RECT rect; |
42e69d6b | 840 | ::GetClientRect(GetHwnd(), &rect); |
81d66cf3 | 841 | |
7c0ea335 | 842 | #if wxUSE_STATUSBAR |
81d66cf3 JS |
843 | if ( GetStatusBar() ) |
844 | { | |
7c0ea335 VZ |
845 | int statusX, statusY; |
846 | GetStatusBar()->GetClientSize(&statusX, &statusY); | |
847 | rect.bottom -= statusY; | |
81d66cf3 | 848 | } |
7c0ea335 | 849 | #endif // wxUSE_STATUSBAR |
81d66cf3 | 850 | |
a2327a9f | 851 | if ( GetToolBar() && GetToolBar()->IsShown() ) |
81d66cf3 JS |
852 | { |
853 | int tw, th; | |
7c0ea335 | 854 | GetToolBar()->GetSize(&tw, &th); |
81d66cf3 | 855 | |
7c0ea335 | 856 | if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL ) |
81d66cf3 | 857 | { |
7c0ea335 | 858 | th = rect.bottom; |
81d66cf3 JS |
859 | } |
860 | else | |
861 | { | |
7c0ea335 | 862 | tw = rect.right; |
81d66cf3 | 863 | } |
7c0ea335 VZ |
864 | |
865 | // Use the 'real' MSW position here | |
866 | GetToolBar()->SetSize(0, 0, tw, th, wxSIZE_NO_ADJUSTMENTS); | |
81d66cf3 JS |
867 | } |
868 | } | |
d427503c | 869 | #endif // wxUSE_TOOLBAR |
d2aef312 | 870 | |
7c0ea335 VZ |
871 | // ---------------------------------------------------------------------------- |
872 | // frame state (iconized/maximized/...) | |
873 | // ---------------------------------------------------------------------------- | |
874 | ||
a23fd0e1 VZ |
875 | // propagate our state change to all child frames: this allows us to emulate X |
876 | // Windows behaviour where child frames float independently of the parent one | |
877 | // on the desktop, but are iconized/restored with it | |
1e6feb95 | 878 | void wxFrameMSW::IconizeChildFrames(bool bIconize) |
d2aef312 | 879 | { |
a23fd0e1 VZ |
880 | for ( wxWindowList::Node *node = GetChildren().GetFirst(); |
881 | node; | |
882 | node = node->GetNext() ) | |
883 | { | |
884 | wxWindow *win = node->GetData(); | |
885 | ||
3ca6a5f0 BP |
886 | // iconizing the frames with this style under Win95 shell puts them at |
887 | // the bottom of the screen (as the MDI children) instead of making | |
888 | // them appear in the taskbar because they are, by virtue of this | |
889 | // style, not managed by the taskbar - instead leave Windows take care | |
890 | // of them | |
891 | #ifdef __WIN95__ | |
892 | if ( win->GetWindowStyle() & wxFRAME_TOOL_WINDOW ) | |
893 | continue; | |
894 | #endif // Win95 | |
895 | ||
3f7bc32b VZ |
896 | // the child MDI frames are a special case and should not be touched by |
897 | // the parent frame - instead, they are managed by the user | |
b016a65b | 898 | wxFrameMSW *frame = wxDynamicCast(win, wxFrame); |
1e6feb95 VZ |
899 | if ( frame |
900 | #if wxUSE_MDI_ARCHITECTURE | |
901 | && !wxDynamicCast(frame, wxMDIChildFrame) | |
902 | #endif // wxUSE_MDI_ARCHITECTURE | |
903 | ) | |
a23fd0e1 | 904 | { |
3f7bc32b | 905 | frame->Iconize(bIconize); |
a23fd0e1 | 906 | } |
d2aef312 | 907 | } |
d2aef312 VZ |
908 | } |
909 | ||
a23fd0e1 | 910 | // =========================================================================== |
42e69d6b | 911 | // message processing |
a23fd0e1 VZ |
912 | // =========================================================================== |
913 | ||
42e69d6b VZ |
914 | // --------------------------------------------------------------------------- |
915 | // preprocessing | |
916 | // --------------------------------------------------------------------------- | |
917 | ||
1e6feb95 | 918 | bool wxFrameMSW::MSWTranslateMessage(WXMSG* pMsg) |
42e69d6b VZ |
919 | { |
920 | if ( wxWindow::MSWTranslateMessage(pMsg) ) | |
921 | return TRUE; | |
922 | ||
1e6feb95 | 923 | #if wxUSE_MENUS && wxUSE_ACCEL && !defined(__WXUNIVERSAL__) |
42e69d6b VZ |
924 | // try the menu bar accels |
925 | wxMenuBar *menuBar = GetMenuBar(); | |
926 | if ( !menuBar ) | |
927 | return FALSE; | |
928 | ||
929 | const wxAcceleratorTable& acceleratorTable = menuBar->GetAccelTable(); | |
c50f1fb9 | 930 | return acceleratorTable.Translate(this, pMsg); |
1e6feb95 VZ |
931 | #else |
932 | return FALSE; | |
933 | #endif // wxUSE_MENUS && wxUSE_ACCEL | |
42e69d6b VZ |
934 | } |
935 | ||
936 | // --------------------------------------------------------------------------- | |
937 | // our private (non virtual) message handlers | |
938 | // --------------------------------------------------------------------------- | |
939 | ||
1e6feb95 | 940 | bool wxFrameMSW::HandlePaint() |
42e69d6b VZ |
941 | { |
942 | RECT rect; | |
943 | if ( GetUpdateRect(GetHwnd(), &rect, FALSE) ) | |
944 | { | |
04ef50df | 945 | #ifndef __WXMICROWIN__ |
42e69d6b VZ |
946 | if ( m_iconized ) |
947 | { | |
c50f1fb9 | 948 | HICON hIcon = m_icon.Ok() ? GetHiconOf(m_icon) |
42e69d6b VZ |
949 | : (HICON)m_defaultIcon; |
950 | ||
951 | // Hold a pointer to the dc so long as the OnPaint() message | |
952 | // is being processed | |
953 | PAINTSTRUCT ps; | |
954 | HDC hdc = ::BeginPaint(GetHwnd(), &ps); | |
955 | ||
956 | // Erase background before painting or we get white background | |
957 | MSWDefWindowProc(WM_ICONERASEBKGND, (WORD)(LONG)ps.hdc, 0L); | |
958 | ||
959 | if ( hIcon ) | |
960 | { | |
961 | RECT rect; | |
962 | ::GetClientRect(GetHwnd(), &rect); | |
963 | ||
964 | // FIXME: why hardcoded? | |
965 | static const int icon_width = 32; | |
966 | static const int icon_height = 32; | |
967 | ||
968 | int icon_x = (int)((rect.right - icon_width)/2); | |
969 | int icon_y = (int)((rect.bottom - icon_height)/2); | |
970 | ||
971 | ::DrawIcon(hdc, icon_x, icon_y, hIcon); | |
972 | } | |
973 | ||
974 | ::EndPaint(GetHwnd(), &ps); | |
975 | ||
976 | return TRUE; | |
977 | } | |
978 | else | |
04ef50df | 979 | #endif |
42e69d6b | 980 | { |
5d1d2d46 | 981 | return wxWindow::HandlePaint(); |
42e69d6b VZ |
982 | } |
983 | } | |
984 | else | |
985 | { | |
986 | // nothing to paint - processed | |
987 | return TRUE; | |
988 | } | |
989 | } | |
990 | ||
1e6feb95 | 991 | bool wxFrameMSW::HandleSize(int x, int y, WXUINT id) |
42e69d6b VZ |
992 | { |
993 | bool processed = FALSE; | |
04ef50df | 994 | #ifndef __WXMICROWIN__ |
42e69d6b VZ |
995 | |
996 | switch ( id ) | |
997 | { | |
998 | case SIZENORMAL: | |
999 | // only do it it if we were iconized before, otherwise resizing the | |
1000 | // parent frame has a curious side effect of bringing it under it's | |
1001 | // children | |
1002 | if ( !m_iconized ) | |
1003 | break; | |
1004 | ||
1005 | // restore all child frames too | |
1006 | IconizeChildFrames(FALSE); | |
1007 | ||
3dd9b88a VZ |
1008 | (void)SendIconizeEvent(FALSE); |
1009 | ||
42e69d6b VZ |
1010 | // fall through |
1011 | ||
1012 | case SIZEFULLSCREEN: | |
1013 | m_iconized = FALSE; | |
1014 | break; | |
1015 | ||
1016 | case SIZEICONIC: | |
1017 | // iconize all child frames too | |
1018 | IconizeChildFrames(TRUE); | |
1019 | ||
3dd9b88a VZ |
1020 | (void)SendIconizeEvent(); |
1021 | ||
42e69d6b VZ |
1022 | m_iconized = TRUE; |
1023 | break; | |
1024 | } | |
04ef50df | 1025 | #endif |
42e69d6b VZ |
1026 | |
1027 | if ( !m_iconized ) | |
1028 | { | |
1e6feb95 | 1029 | #if wxUSE_STATUSBAR |
42e69d6b | 1030 | PositionStatusBar(); |
1e6feb95 VZ |
1031 | #endif // wxUSE_STATUSBAR |
1032 | ||
1033 | #if wxUSE_TOOLBAR | |
42e69d6b | 1034 | PositionToolBar(); |
1e6feb95 | 1035 | #endif // wxUSE_TOOLBAR |
42e69d6b VZ |
1036 | |
1037 | wxSizeEvent event(wxSize(x, y), m_windowId); | |
1038 | event.SetEventObject( this ); | |
1039 | processed = GetEventHandler()->ProcessEvent(event); | |
1040 | } | |
1041 | ||
1042 | return processed; | |
1043 | } | |
1044 | ||
1e6feb95 | 1045 | bool wxFrameMSW::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control) |
42e69d6b VZ |
1046 | { |
1047 | if ( control ) | |
1048 | { | |
1049 | // In case it's e.g. a toolbar. | |
1050 | wxWindow *win = wxFindWinFromHandle(control); | |
1051 | if ( win ) | |
1052 | return win->MSWCommand(cmd, id); | |
1053 | } | |
1054 | ||
1055 | // handle here commands from menus and accelerators | |
1056 | if ( cmd == 0 || cmd == 1 ) | |
1057 | { | |
1e6feb95 | 1058 | #if wxUSE_MENUS_NATIVE |
42e69d6b VZ |
1059 | if ( wxCurrentPopupMenu ) |
1060 | { | |
1061 | wxMenu *popupMenu = wxCurrentPopupMenu; | |
1062 | wxCurrentPopupMenu = NULL; | |
1063 | ||
1064 | return popupMenu->MSWCommand(cmd, id); | |
1065 | } | |
1e6feb95 | 1066 | #endif // wxUSE_MENUS_NATIVE |
42e69d6b VZ |
1067 | |
1068 | if ( ProcessCommand(id) ) | |
1069 | { | |
1070 | return TRUE; | |
1071 | } | |
1072 | } | |
1073 | ||
1074 | return FALSE; | |
1075 | } | |
1076 | ||
1e6feb95 | 1077 | bool wxFrameMSW::HandleMenuSelect(WXWORD nItem, WXWORD flags, WXHMENU hMenu) |
a23fd0e1 VZ |
1078 | { |
1079 | int item; | |
c219cecc | 1080 | if ( flags == 0xFFFF && hMenu == 0 ) |
a23fd0e1 | 1081 | { |
c219cecc | 1082 | // menu was removed from screen |
a23fd0e1 VZ |
1083 | item = -1; |
1084 | } | |
04ef50df | 1085 | #ifndef __WXMICROWIN__ |
c219cecc | 1086 | else if ( !(flags & MF_POPUP) && !(flags & MF_SEPARATOR) ) |
a23fd0e1 VZ |
1087 | { |
1088 | item = nItem; | |
1089 | } | |
04ef50df | 1090 | #endif |
a23fd0e1 VZ |
1091 | else |
1092 | { | |
1e6feb95 | 1093 | #if wxUSE_STATUSBAR |
c219cecc | 1094 | // don't give hints for separators (doesn't make sense) nor for the |
f6bcfd97 BP |
1095 | // items opening popup menus (they don't have them anyhow) but do clear |
1096 | // the status line - otherwise, we would be left with the help message | |
1097 | // for the previous item which doesn't apply any more | |
1098 | wxStatusBar *statbar = GetStatusBar(); | |
1099 | if ( statbar ) | |
1100 | { | |
1101 | statbar->SetStatusText(wxEmptyString); | |
1102 | } | |
1e6feb95 | 1103 | #endif // wxUSE_STATUSBAR |
f6bcfd97 | 1104 | |
a23fd0e1 VZ |
1105 | return FALSE; |
1106 | } | |
1107 | ||
1108 | wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, item); | |
1109 | event.SetEventObject( this ); | |
1110 | ||
1111 | return GetEventHandler()->ProcessEvent(event); | |
1112 | } | |
1113 | ||
1114 | // --------------------------------------------------------------------------- | |
1e6feb95 | 1115 | // the window proc for wxFrameMSW |
a23fd0e1 VZ |
1116 | // --------------------------------------------------------------------------- |
1117 | ||
1e6feb95 | 1118 | long wxFrameMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) |
a23fd0e1 VZ |
1119 | { |
1120 | long rc = 0; | |
1121 | bool processed = FALSE; | |
1122 | ||
1123 | switch ( message ) | |
1124 | { | |
42e69d6b VZ |
1125 | case WM_CLOSE: |
1126 | // if we can't close, tell the system that we processed the | |
1127 | // message - otherwise it would close us | |
1128 | processed = !Close(); | |
1129 | break; | |
1130 | ||
1131 | case WM_COMMAND: | |
1132 | { | |
1133 | WORD id, cmd; | |
1134 | WXHWND hwnd; | |
1135 | UnpackCommand((WXWPARAM)wParam, (WXLPARAM)lParam, | |
1136 | &id, &hwnd, &cmd); | |
1137 | ||
1138 | processed = HandleCommand(id, cmd, (WXHWND)hwnd); | |
1139 | } | |
1140 | break; | |
1141 | ||
04ef50df | 1142 | #ifndef __WXMICROWIN__ |
a23fd0e1 VZ |
1143 | case WM_MENUSELECT: |
1144 | { | |
42e69d6b VZ |
1145 | WXWORD item, flags; |
1146 | WXHMENU hmenu; | |
1147 | UnpackMenuSelect(wParam, lParam, &item, &flags, &hmenu); | |
1148 | ||
1149 | processed = HandleMenuSelect(item, flags, hmenu); | |
a23fd0e1 VZ |
1150 | } |
1151 | break; | |
04ef50df | 1152 | #endif |
42e69d6b VZ |
1153 | |
1154 | case WM_PAINT: | |
1155 | processed = HandlePaint(); | |
1156 | break; | |
1157 | ||
04ef50df | 1158 | #ifndef __WXMICROWIN__ |
42e69d6b VZ |
1159 | case WM_QUERYDRAGICON: |
1160 | { | |
c50f1fb9 | 1161 | HICON hIcon = m_icon.Ok() ? GetHiconOf(m_icon) |
42e69d6b VZ |
1162 | : (HICON)(m_defaultIcon); |
1163 | rc = (long)hIcon; | |
1164 | processed = rc != 0; | |
1165 | } | |
1166 | break; | |
04ef50df | 1167 | #endif |
42e69d6b VZ |
1168 | |
1169 | case WM_SIZE: | |
1170 | processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam); | |
1171 | break; | |
a23fd0e1 VZ |
1172 | } |
1173 | ||
1174 | if ( !processed ) | |
1175 | rc = wxWindow::MSWWindowProc(message, wParam, lParam); | |
1176 | ||
1177 | return rc; | |
1178 | } | |
21802234 | 1179 |