]> git.saurik.com Git - wxWidgets.git/blame - src/msw/frame.cpp
Removed a deprecated wxBitmap constructor, and some
[wxWidgets.git] / src / msw / frame.cpp
CommitLineData
2bda0e17 1/////////////////////////////////////////////////////////////////////////////
7c0ea335 2// Name: msw/frame.cpp
0d53fc34 3// Purpose: wxFrame
2bda0e17
KB
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
6c9a19aa 8// Copyright: (c) Julian Smart
2bda0e17
KB
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
1e6feb95 66#if wxUSE_MENUS_NATIVE
03baf031 67 extern wxMenu *wxCurrentPopupMenu;
1e6feb95 68#endif // wxUSE_MENUS_NATIVE
2bda0e17 69
7c0ea335
VZ
70// ----------------------------------------------------------------------------
71// event tables
72// ----------------------------------------------------------------------------
73
0d53fc34 74BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
0d53fc34 75 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
2bda0e17
KB
76END_EVENT_TABLE()
77
58b43418 78IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow)
2bda0e17 79
7c0ea335
VZ
80// ============================================================================
81// implementation
82// ============================================================================
83
84// ----------------------------------------------------------------------------
85// static class members
86// ----------------------------------------------------------------------------
87
1e6feb95
VZ
88#if wxUSE_STATUSBAR
89 #if wxUSE_NATIVE_STATUSBAR
0d53fc34 90 bool wxFrame::m_useNativeStatusBar = TRUE;
1e6feb95 91 #else
0d53fc34 92 bool wxFrame::m_useNativeStatusBar = FALSE;
1e6feb95
VZ
93 #endif
94#endif // wxUSE_NATIVE_STATUSBAR
2bda0e17 95
7c0ea335
VZ
96// ----------------------------------------------------------------------------
97// creation/destruction
98// ----------------------------------------------------------------------------
2bda0e17 99
0d53fc34 100void wxFrame::Init()
2bda0e17 101{
9f3362c4
VZ
102#if wxUSE_TOOLTIPS
103 m_hwndToolTip = 0;
104#endif
a2327a9f
JS
105
106 // Data to save/restore when calling ShowFullScreen
a2327a9f
JS
107 m_fsStatusBarFields = 0;
108 m_fsStatusBarHeight = 0;
109 m_fsToolBarHeight = 0;
f6bcfd97 110
9327c3aa 111 m_wasMinimized = FALSE;
7c0ea335 112}
9f3362c4 113
0d53fc34 114bool wxFrame::Create(wxWindow *parent,
7c0ea335
VZ
115 wxWindowID id,
116 const wxString& title,
117 const wxPoint& pos,
118 const wxSize& size,
119 long style,
120 const wxString& name)
121{
82c9f85c
VZ
122 if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
123 return FALSE;
d2aef312 124
a756f210 125 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
2bda0e17 126
82c9f85c 127 wxModelessWindows.Append(this);
f6bcfd97 128
82c9f85c 129 return TRUE;
2bda0e17
KB
130}
131
0d53fc34 132wxFrame::~wxFrame()
2bda0e17 133{
82c9f85c 134 m_isBeingDeleted = TRUE;
2bda0e17 135
82c9f85c 136 DeleteAllBars();
2bda0e17
KB
137}
138
d4597e13
VZ
139// ----------------------------------------------------------------------------
140// wxFrame client size calculations
141// ----------------------------------------------------------------------------
2bda0e17 142
0d53fc34 143void wxFrame::DoSetClientSize(int width, int height)
2bda0e17 144{
82c9f85c 145 // leave enough space for the status bar if we have (and show) it
7c0ea335 146#if wxUSE_STATUSBAR
8d8bd249
VZ
147 wxStatusBar *statbar = GetStatusBar();
148 if ( statbar && statbar->IsShown() )
149 {
8d8bd249
VZ
150 height += statbar->GetSize().y;
151 }
7c0ea335 152#endif // wxUSE_STATUSBAR
2bda0e17 153
68d02db3
VZ
154 // call GetClientAreaOrigin() to take the toolbar into account
155 wxPoint pt = GetClientAreaOrigin();
156 width += pt.x;
157 height += pt.y;
158
82c9f85c 159 wxTopLevelWindow::DoSetClientSize(width, height);
2bda0e17
KB
160}
161
d4597e13
VZ
162// Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
163void wxFrame::DoGetClientSize(int *x, int *y) const
164{
165 wxTopLevelWindow::DoGetClientSize(x, y);
166
68d02db3
VZ
167 // account for the possible toolbar
168 wxPoint pt = GetClientAreaOrigin();
169 if ( x )
170 *x -= pt.x;
171
172 if ( y )
173 *y -= pt.y;
174
d4597e13
VZ
175#if wxUSE_STATUSBAR
176 // adjust client area height to take the status bar into account
177 if ( y )
178 {
179 wxStatusBar *statbar = GetStatusBar();
180 if ( statbar && statbar->IsShown() )
181 {
182 *y -= statbar->GetClientSize().y;
183 }
184 }
185#endif // wxUSE_STATUSBAR
186}
187
7c0ea335 188// ----------------------------------------------------------------------------
0d53fc34 189// wxFrame: various geometry-related functions
7c0ea335
VZ
190// ----------------------------------------------------------------------------
191
0d53fc34 192void wxFrame::Raise()
c48926e1
VZ
193{
194#ifdef __WIN16__
195 // no SetForegroundWindow() in Win16
196 wxFrameBase::Raise();
197#else // Win32
198 ::SetForegroundWindow(GetHwnd());
199#endif // Win16/32
200}
201
67bd5bad 202// generate an artificial resize event
0d53fc34 203void wxFrame::SendSizeEvent()
67bd5bad 204{
67bd5bad
GT
205 if ( !m_iconized )
206 {
82c9f85c
VZ
207 RECT r = wxGetWindowRect(GetHwnd());
208
67bd5bad
GT
209 (void)::PostMessage(GetHwnd(), WM_SIZE,
210 IsMaximized() ? SIZE_MAXIMIZED : SIZE_RESTORED,
211 MAKELPARAM(r.right - r.left, r.bottom - r.top));
212 }
213}
214
d427503c 215#if wxUSE_STATUSBAR
0d53fc34 216wxStatusBar *wxFrame::OnCreateStatusBar(int number,
7c0ea335
VZ
217 long style,
218 wxWindowID id,
219 const wxString& name)
2bda0e17
KB
220{
221 wxStatusBar *statusBar = NULL;
222
47d67540 223#if wxUSE_NATIVE_STATUSBAR
1f0500b3 224 if ( !UsesNativeStatusBar() )
2bda0e17 225 {
1f0500b3 226 statusBar = (wxStatusBar *)new wxStatusBarGeneric(this, id, style);
2bda0e17
KB
227 }
228 else
229#endif
230 {
1f0500b3
VZ
231 statusBar = new wxStatusBar(this, id, style, name);
232 }
ed791986 233
1f0500b3 234 statusBar->SetFieldsCount(number);
2bda0e17 235
7c0ea335 236 return statusBar;
2bda0e17
KB
237}
238
0d53fc34 239void wxFrame::PositionStatusBar()
2bda0e17 240{
d4597e13 241 if ( !m_frameStatusBar || !m_frameStatusBar->IsShown() )
ed791986
VZ
242 return;
243
cbc66a27
VZ
244 int w, h;
245 GetClientSize(&w, &h);
246 int sw, sh;
247 m_frameStatusBar->GetSize(&sw, &sh);
248
249 // Since we wish the status bar to be directly under the client area,
250 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
251 m_frameStatusBar->SetSize(0, h, w, sh);
2bda0e17 252}
d427503c 253#endif // wxUSE_STATUSBAR
2bda0e17 254
6522713c 255#if wxUSE_MENUS_NATIVE
ea9a4296 256
0d53fc34 257void wxFrame::AttachMenuBar(wxMenuBar *menubar)
2bda0e17 258{
f008af16 259 wxFrameBase::AttachMenuBar(menubar);
6beb85c0 260
f6bcfd97 261 if ( !menubar )
c2dcfdef 262 {
f6bcfd97
BP
263 // actually remove the menu from the frame
264 m_hMenu = (WXHMENU)0;
265 InternalSetMenuBar();
065de612 266 }
f6bcfd97 267 else // set new non NULL menu bar
065de612 268 {
f6bcfd97 269 // Can set a menubar several times.
f6bcfd97
BP
270 if ( menubar->GetHMenu() )
271 {
272 m_hMenu = menubar->GetHMenu();
273 }
f008af16 274 else // no HMENU yet
f6bcfd97 275 {
f6bcfd97 276 m_hMenu = menubar->Create();
065de612 277
f6bcfd97 278 if ( !m_hMenu )
f008af16
VZ
279 {
280 wxFAIL_MSG( _T("failed to create menu bar") );
f6bcfd97 281 return;
f008af16 282 }
f6bcfd97 283 }
065de612 284
f6bcfd97 285 InternalSetMenuBar();
1e6feb95 286 }
2bda0e17
KB
287}
288
0d53fc34 289void wxFrame::InternalSetMenuBar()
2bda0e17 290{
04ef50df 291#ifndef __WXMICROWIN__
42e69d6b 292 if ( !::SetMenu(GetHwnd(), (HMENU)m_hMenu) )
2bda0e17 293 {
f6bcfd97 294 wxLogLastError(wxT("SetMenu"));
2bda0e17 295 }
04ef50df 296#endif
2bda0e17
KB
297}
298
1e6feb95
VZ
299#endif // wxUSE_MENUS_NATIVE
300
2bda0e17 301// Responds to colour changes, and passes event on to children.
0d53fc34 302void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
2bda0e17 303{
a756f210 304 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
2bda0e17
KB
305 Refresh();
306
1e6feb95 307#if wxUSE_STATUSBAR
2bda0e17
KB
308 if ( m_frameStatusBar )
309 {
310 wxSysColourChangedEvent event2;
311 event2.SetEventObject( m_frameStatusBar );
02800301 312 m_frameStatusBar->GetEventHandler()->ProcessEvent(event2);
2bda0e17 313 }
1e6feb95 314#endif // wxUSE_STATUSBAR
2bda0e17
KB
315
316 // Propagate the event to the non-top-level children
317 wxWindow::OnSysColourChanged(event);
318}
319
a2327a9f 320// Pass TRUE to show full screen, FALSE to restore.
0d53fc34 321bool wxFrame::ShowFullScreen(bool show, long style)
a2327a9f 322{
085ad686 323 if ( IsFullScreen() == show )
c641b1d2
VS
324 return FALSE;
325
a2327a9f
JS
326 if (show)
327 {
1e6feb95 328#if wxUSE_TOOLBAR
f6bcfd97 329 wxToolBar *theToolBar = GetToolBar();
a2327a9f 330 if (theToolBar)
1e6feb95 331 theToolBar->GetSize(NULL, &m_fsToolBarHeight);
a2327a9f
JS
332
333 // zap the toolbar, menubar, and statusbar
334
335 if ((style & wxFULLSCREEN_NOTOOLBAR) && theToolBar)
336 {
337 theToolBar->SetSize(-1,0);
338 theToolBar->Show(FALSE);
339 }
1e6feb95 340#endif // wxUSE_TOOLBAR
a2327a9f 341
04ef50df 342#ifndef __WXMICROWIN__
a2327a9f
JS
343 if (style & wxFULLSCREEN_NOMENUBAR)
344 SetMenu((HWND)GetHWND(), (HMENU) NULL);
04ef50df 345#endif
a2327a9f 346
1e6feb95
VZ
347#if wxUSE_STATUSBAR
348 wxStatusBar *theStatusBar = GetStatusBar();
349 if (theStatusBar)
350 theStatusBar->GetSize(NULL, &m_fsStatusBarHeight);
351
a2327a9f
JS
352 // Save the number of fields in the statusbar
353 if ((style & wxFULLSCREEN_NOSTATUSBAR) && theStatusBar)
354 {
579b10c2
JS
355 //m_fsStatusBarFields = theStatusBar->GetFieldsCount();
356 //SetStatusBar((wxStatusBar*) NULL);
357 //delete theStatusBar;
358 theStatusBar->Show(FALSE);
a2327a9f
JS
359 }
360 else
361 m_fsStatusBarFields = 0;
1e6feb95 362#endif // wxUSE_STATUSBAR
a2327a9f
JS
363 }
364 else
365 {
1e6feb95 366#if wxUSE_TOOLBAR
a2327a9f
JS
367 wxToolBar *theToolBar = GetToolBar();
368
369 // restore the toolbar, menubar, and statusbar
370 if (theToolBar && (m_fsStyle & wxFULLSCREEN_NOTOOLBAR))
371 {
372 theToolBar->SetSize(-1, m_fsToolBarHeight);
373 theToolBar->Show(TRUE);
374 }
1e6feb95 375#endif // wxUSE_TOOLBAR
a2327a9f 376
1e6feb95
VZ
377#if wxUSE_STATUSBAR
378 if ( m_fsStyle & wxFULLSCREEN_NOSTATUSBAR )
a2327a9f 379 {
579b10c2
JS
380 //CreateStatusBar(m_fsStatusBarFields);
381 if (GetStatusBar())
382 {
383 GetStatusBar()->Show(TRUE);
384 PositionStatusBar();
385 }
a2327a9f 386 }
1e6feb95 387#endif // wxUSE_STATUSBAR
a2327a9f 388
04ef50df 389#ifndef __WXMICROWIN__
a2327a9f
JS
390 if ((m_fsStyle & wxFULLSCREEN_NOMENUBAR) && (m_hMenu != 0))
391 SetMenu((HWND)GetHWND(), (HMENU)m_hMenu);
04ef50df 392#endif
a2327a9f 393 }
f6bcfd97 394
085ad686 395 return wxFrameBase::ShowFullScreen(show, style);
2bda0e17
KB
396}
397
7c0ea335
VZ
398// ----------------------------------------------------------------------------
399// tool/status bar stuff
400// ----------------------------------------------------------------------------
401
d427503c 402#if wxUSE_TOOLBAR
7c0ea335 403
0d53fc34 404wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
81d66cf3 405{
7c0ea335 406 if ( wxFrameBase::CreateToolBar(style, id, name) )
81d66cf3 407 {
81d66cf3 408 PositionToolBar();
81d66cf3 409 }
81d66cf3 410
7c0ea335 411 return m_frameToolBar;
81d66cf3
JS
412}
413
0d53fc34 414void wxFrame::PositionToolBar()
81d66cf3 415{
d4597e13
VZ
416 wxToolBar *toolbar = GetToolBar();
417 if ( toolbar && toolbar->IsShown() )
418 {
419 // don't call our (or even wxTopLevelWindow) version because we want
420 // the real (full) client area size, not excluding the tool/status bar
421 int width, height;
422 wxWindow::DoGetClientSize(&width, &height);
81d66cf3 423
7c0ea335 424#if wxUSE_STATUSBAR
d4597e13
VZ
425 wxStatusBar *statbar = GetStatusBar();
426 if ( statbar && statbar->IsShown() )
427 {
428 height -= statbar->GetClientSize().y;
429 }
7c0ea335 430#endif // wxUSE_STATUSBAR
81d66cf3 431
81d66cf3 432 int tw, th;
d4597e13 433 toolbar->GetSize(&tw, &th);
81d66cf3 434
d4597e13 435 if ( toolbar->GetWindowStyleFlag() & wxTB_VERTICAL )
81d66cf3 436 {
d4597e13 437 th = height;
81d66cf3
JS
438 }
439 else
440 {
d4597e13 441 tw = width;
98b96436
RR
442 if ( toolbar->GetWindowStyleFlag() & wxTB_FLAT )
443 th -= 3;
81d66cf3 444 }
7c0ea335 445
d4597e13
VZ
446 // use the 'real' MSW position here, don't offset relativly to the
447 // client area origin
448 toolbar->SetSize(0, 0, tw, th, wxSIZE_NO_ADJUSTMENTS);
81d66cf3
JS
449 }
450}
d4597e13 451
d427503c 452#endif // wxUSE_TOOLBAR
d2aef312 453
7c0ea335
VZ
454// ----------------------------------------------------------------------------
455// frame state (iconized/maximized/...)
456// ----------------------------------------------------------------------------
457
a23fd0e1
VZ
458// propagate our state change to all child frames: this allows us to emulate X
459// Windows behaviour where child frames float independently of the parent one
460// on the desktop, but are iconized/restored with it
0d53fc34 461void wxFrame::IconizeChildFrames(bool bIconize)
d2aef312 462{
a23fd0e1
VZ
463 for ( wxWindowList::Node *node = GetChildren().GetFirst();
464 node;
465 node = node->GetNext() )
466 {
467 wxWindow *win = node->GetData();
468
3ca6a5f0
BP
469 // iconizing the frames with this style under Win95 shell puts them at
470 // the bottom of the screen (as the MDI children) instead of making
471 // them appear in the taskbar because they are, by virtue of this
472 // style, not managed by the taskbar - instead leave Windows take care
473 // of them
474#ifdef __WIN95__
475 if ( win->GetWindowStyle() & wxFRAME_TOOL_WINDOW )
476 continue;
477#endif // Win95
478
3f7bc32b
VZ
479 // the child MDI frames are a special case and should not be touched by
480 // the parent frame - instead, they are managed by the user
2e9f62da 481 wxFrame *frame = wxDynamicCast(win, wxFrame);
1e6feb95
VZ
482 if ( frame
483#if wxUSE_MDI_ARCHITECTURE
484 && !wxDynamicCast(frame, wxMDIChildFrame)
485#endif // wxUSE_MDI_ARCHITECTURE
486 )
a23fd0e1 487 {
9327c3aa
VZ
488 // we don't want to restore the child frames which had been
489 // iconized even before we were iconized, so save the child frame
490 // status when iconizing the parent frame and check it when
491 // restoring it
492 if ( bIconize )
493 {
d7d02962
VZ
494 // note that we shouldn't touch the hidden frames neither
495 // because iconizing/restoring them would show them as a side
496 // effect
497 frame->m_wasMinimized = frame->IsIconized() || !frame->IsShown();
9327c3aa
VZ
498 }
499
500 // this test works for both iconizing and restoring
501 if ( !frame->m_wasMinimized )
502 frame->Iconize(bIconize);
a23fd0e1 503 }
d2aef312 504 }
d2aef312
VZ
505}
506
0d53fc34 507WXHICON wxFrame::GetDefaultIcon() const
82c9f85c
VZ
508{
509 return (WXHICON)(wxSTD_FRAME_ICON ? wxSTD_FRAME_ICON
510 : wxDEFAULT_FRAME_ICON);
511}
512
a23fd0e1 513// ===========================================================================
42e69d6b 514// message processing
a23fd0e1
VZ
515// ===========================================================================
516
42e69d6b
VZ
517// ---------------------------------------------------------------------------
518// preprocessing
519// ---------------------------------------------------------------------------
520
0d53fc34 521bool wxFrame::MSWTranslateMessage(WXMSG* pMsg)
42e69d6b
VZ
522{
523 if ( wxWindow::MSWTranslateMessage(pMsg) )
524 return TRUE;
525
1e6feb95 526#if wxUSE_MENUS && wxUSE_ACCEL && !defined(__WXUNIVERSAL__)
42e69d6b
VZ
527 // try the menu bar accels
528 wxMenuBar *menuBar = GetMenuBar();
529 if ( !menuBar )
530 return FALSE;
531
532 const wxAcceleratorTable& acceleratorTable = menuBar->GetAccelTable();
c50f1fb9 533 return acceleratorTable.Translate(this, pMsg);
1e6feb95
VZ
534#else
535 return FALSE;
536#endif // wxUSE_MENUS && wxUSE_ACCEL
42e69d6b
VZ
537}
538
539// ---------------------------------------------------------------------------
540// our private (non virtual) message handlers
541// ---------------------------------------------------------------------------
542
0d53fc34 543bool wxFrame::HandlePaint()
42e69d6b
VZ
544{
545 RECT rect;
546 if ( GetUpdateRect(GetHwnd(), &rect, FALSE) )
547 {
04ef50df 548#ifndef __WXMICROWIN__
42e69d6b
VZ
549 if ( m_iconized )
550 {
f618020a
MB
551 const wxIcon& icon = GetIcon();
552 HICON hIcon = icon.Ok() ? GetHiconOf(icon)
553 : (HICON)GetDefaultIcon();
42e69d6b
VZ
554
555 // Hold a pointer to the dc so long as the OnPaint() message
556 // is being processed
557 PAINTSTRUCT ps;
558 HDC hdc = ::BeginPaint(GetHwnd(), &ps);
559
560 // Erase background before painting or we get white background
561 MSWDefWindowProc(WM_ICONERASEBKGND, (WORD)(LONG)ps.hdc, 0L);
562
563 if ( hIcon )
564 {
565 RECT rect;
566 ::GetClientRect(GetHwnd(), &rect);
567
568 // FIXME: why hardcoded?
569 static const int icon_width = 32;
570 static const int icon_height = 32;
571
572 int icon_x = (int)((rect.right - icon_width)/2);
573 int icon_y = (int)((rect.bottom - icon_height)/2);
574
575 ::DrawIcon(hdc, icon_x, icon_y, hIcon);
576 }
577
578 ::EndPaint(GetHwnd(), &ps);
579
580 return TRUE;
581 }
582 else
04ef50df 583 #endif
42e69d6b 584 {
5d1d2d46 585 return wxWindow::HandlePaint();
42e69d6b
VZ
586 }
587 }
588 else
589 {
590 // nothing to paint - processed
591 return TRUE;
592 }
593}
594
0d53fc34 595bool wxFrame::HandleSize(int x, int y, WXUINT id)
42e69d6b
VZ
596{
597 bool processed = FALSE;
04ef50df 598#ifndef __WXMICROWIN__
42e69d6b
VZ
599
600 switch ( id )
601 {
602 case SIZENORMAL:
603 // only do it it if we were iconized before, otherwise resizing the
604 // parent frame has a curious side effect of bringing it under it's
605 // children
606 if ( !m_iconized )
607 break;
608
609 // restore all child frames too
610 IconizeChildFrames(FALSE);
611
3dd9b88a
VZ
612 (void)SendIconizeEvent(FALSE);
613
42e69d6b
VZ
614 // fall through
615
616 case SIZEFULLSCREEN:
617 m_iconized = FALSE;
618 break;
619
620 case SIZEICONIC:
621 // iconize all child frames too
622 IconizeChildFrames(TRUE);
623
3dd9b88a
VZ
624 (void)SendIconizeEvent();
625
42e69d6b
VZ
626 m_iconized = TRUE;
627 break;
628 }
04ef50df 629#endif
42e69d6b
VZ
630
631 if ( !m_iconized )
632 {
1e6feb95 633#if wxUSE_STATUSBAR
42e69d6b 634 PositionStatusBar();
1e6feb95
VZ
635#endif // wxUSE_STATUSBAR
636
637#if wxUSE_TOOLBAR
42e69d6b 638 PositionToolBar();
1e6feb95 639#endif // wxUSE_TOOLBAR
42e69d6b 640
4e4a5fed 641 processed = wxWindow::HandleSize(x, y, id);
42e69d6b
VZ
642 }
643
644 return processed;
645}
646
0d53fc34 647bool wxFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control)
42e69d6b
VZ
648{
649 if ( control )
650 {
651 // In case it's e.g. a toolbar.
652 wxWindow *win = wxFindWinFromHandle(control);
653 if ( win )
654 return win->MSWCommand(cmd, id);
655 }
656
657 // handle here commands from menus and accelerators
658 if ( cmd == 0 || cmd == 1 )
659 {
1e6feb95 660#if wxUSE_MENUS_NATIVE
42e69d6b
VZ
661 if ( wxCurrentPopupMenu )
662 {
663 wxMenu *popupMenu = wxCurrentPopupMenu;
664 wxCurrentPopupMenu = NULL;
665
666 return popupMenu->MSWCommand(cmd, id);
667 }
1e6feb95 668#endif // wxUSE_MENUS_NATIVE
42e69d6b
VZ
669
670 if ( ProcessCommand(id) )
671 {
672 return TRUE;
673 }
674 }
675
676 return FALSE;
677}
678
0d53fc34 679bool wxFrame::HandleMenuSelect(WXWORD nItem, WXWORD flags, WXHMENU hMenu)
a23fd0e1
VZ
680{
681 int item;
c219cecc 682 if ( flags == 0xFFFF && hMenu == 0 )
a23fd0e1 683 {
c219cecc 684 // menu was removed from screen
a23fd0e1
VZ
685 item = -1;
686 }
04ef50df 687#ifndef __WXMICROWIN__
c219cecc 688 else if ( !(flags & MF_POPUP) && !(flags & MF_SEPARATOR) )
a23fd0e1
VZ
689 {
690 item = nItem;
691 }
04ef50df 692#endif
a23fd0e1
VZ
693 else
694 {
c219cecc 695 // don't give hints for separators (doesn't make sense) nor for the
f6bcfd97
BP
696 // items opening popup menus (they don't have them anyhow) but do clear
697 // the status line - otherwise, we would be left with the help message
698 // for the previous item which doesn't apply any more
1f361cdd 699 DoGiveHelp(wxEmptyString, FALSE);
f6bcfd97 700
a23fd0e1
VZ
701 return FALSE;
702 }
703
704 wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, item);
ccef86c7
VZ
705 event.SetEventObject(this);
706
707 return GetEventHandler()->ProcessEvent(event);
708}
709
710bool wxFrame::HandleMenuLoop(const wxEventType& evtType, WXWORD isPopup)
711{
712 // we don't have the menu id here, so we use the id to specify if the event
713 // was from a popup menu or a normal one
714 wxMenuEvent event(evtType, isPopup ? -1 : 0);
715 event.SetEventObject(this);
a23fd0e1
VZ
716
717 return GetEventHandler()->ProcessEvent(event);
718}
719
720// ---------------------------------------------------------------------------
0d53fc34 721// the window proc for wxFrame
a23fd0e1
VZ
722// ---------------------------------------------------------------------------
723
0d53fc34 724long wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
a23fd0e1
VZ
725{
726 long rc = 0;
727 bool processed = FALSE;
728
729 switch ( message )
730 {
42e69d6b
VZ
731 case WM_CLOSE:
732 // if we can't close, tell the system that we processed the
733 // message - otherwise it would close us
734 processed = !Close();
735 break;
736
ccef86c7
VZ
737 case WM_SIZE:
738 processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam);
739 break;
740
42e69d6b
VZ
741 case WM_COMMAND:
742 {
743 WORD id, cmd;
744 WXHWND hwnd;
745 UnpackCommand((WXWPARAM)wParam, (WXLPARAM)lParam,
746 &id, &hwnd, &cmd);
747
748 processed = HandleCommand(id, cmd, (WXHWND)hwnd);
749 }
750 break;
751
ccef86c7
VZ
752 case WM_PAINT:
753 processed = HandlePaint();
754 break;
755
04ef50df 756#ifndef __WXMICROWIN__
a23fd0e1
VZ
757 case WM_MENUSELECT:
758 {
42e69d6b
VZ
759 WXWORD item, flags;
760 WXHMENU hmenu;
761 UnpackMenuSelect(wParam, lParam, &item, &flags, &hmenu);
762
763 processed = HandleMenuSelect(item, flags, hmenu);
a23fd0e1
VZ
764 }
765 break;
42e69d6b 766
ccef86c7
VZ
767#ifndef __WIN16__
768 case WM_ENTERMENULOOP:
769 processed = HandleMenuLoop(wxEVT_MENU_OPEN, wParam);
42e69d6b
VZ
770 break;
771
ccef86c7
VZ
772 case WM_EXITMENULOOP:
773 processed = HandleMenuLoop(wxEVT_MENU_CLOSE, wParam);
774 break;
775#endif // __WIN16__
776
42e69d6b
VZ
777 case WM_QUERYDRAGICON:
778 {
f618020a
MB
779 const wxIcon& icon = GetIcon();
780 HICON hIcon = icon.Ok() ? GetHiconOf(icon)
781 : (HICON)GetDefaultIcon();
42e69d6b
VZ
782 rc = (long)hIcon;
783 processed = rc != 0;
784 }
785 break;
ccef86c7 786#endif // !__WXMICROWIN__
a23fd0e1
VZ
787 }
788
789 if ( !processed )
7e25f59e 790 rc = wxFrameBase::MSWWindowProc(message, wParam, lParam);
a23fd0e1
VZ
791
792 return rc;
793}
21802234 794