1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "frame.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
37 #include "wx/dialog.h"
38 #include "wx/settings.h"
39 #include "wx/dcclient.h"
44 #include "wx/msw/private.h"
47 #include "wx/statusbr.h"
48 #include "wx/generic/statusbr.h"
49 #endif // wxUSE_STATUSBAR
52 #include "wx/toolbar.h"
53 #endif // wxUSE_TOOLBAR
55 #include "wx/menuitem.h"
58 // ----------------------------------------------------------------------------
60 // ----------------------------------------------------------------------------
62 extern wxWindowList wxModelessWindows
;
63 extern wxList WXDLLEXPORT wxPendingDelete
;
64 extern const wxChar
*wxFrameClassName
;
65 extern wxMenu
*wxCurrentPopupMenu
;
67 // ----------------------------------------------------------------------------
69 // ----------------------------------------------------------------------------
71 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
72 EVT_ACTIVATE(wxFrame::OnActivate
)
73 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
76 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
78 // ============================================================================
80 // ============================================================================
82 // ----------------------------------------------------------------------------
83 // static class members
84 // ----------------------------------------------------------------------------
86 #if wxUSE_NATIVE_STATUSBAR
87 bool wxFrame::m_useNativeStatusBar
= TRUE
;
89 bool wxFrame::m_useNativeStatusBar
= FALSE
;
92 // ----------------------------------------------------------------------------
93 // creation/destruction
94 // ----------------------------------------------------------------------------
99 m_maximizeOnShow
= FALSE
;
105 // Data to save/restore when calling ShowFullScreen
107 m_fsOldWindowStyle
= 0;
108 m_fsStatusBarFields
= 0;
109 m_fsStatusBarHeight
= 0;
110 m_fsToolBarHeight
= 0;
112 m_fsIsMaximized
= FALSE
;
113 m_fsIsShowing
= FALSE
;
115 m_winLastFocused
= (wxWindow
*)NULL
;
117 // unlike (almost?) all other windows, frames are created hidden
121 bool wxFrame::Create(wxWindow
*parent
,
123 const wxString
& title
,
127 const wxString
& name
)
130 m_windowStyle
= style
;
131 m_frameMenuBar
= NULL
;
132 m_frameToolBar
= NULL
;
133 m_frameStatusBar
= NULL
;
135 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
140 m_windowId
= (int)NewControlId();
142 if (parent
) parent
->AddChild(this);
151 wxTopLevelWindows
.Append(this);
153 MSWCreate(m_windowId
, parent
, wxFrameClassName
, this, title
,
154 x
, y
, width
, height
, style
);
156 wxModelessWindows
.Append(this);
163 m_isBeingDeleted
= TRUE
;
164 wxTopLevelWindows
.DeleteObject(this);
166 // the ~wxToolBar() code relies on the previous line to be executed before
167 // this one, i.e. the frame should remove itself from wxTopLevelWindows
168 // before destorying its toolbar
171 if (wxTheApp
&& (wxTopLevelWindows
.Number() == 0))
173 wxTheApp
->SetTopWindow(NULL
);
175 if (wxTheApp
->GetExitOnFrameDelete())
181 wxModelessWindows
.DeleteObject(this);
183 // For some reason, wxWindows can activate another task altogether
184 // when a frame is destroyed after a modal dialog has been invoked.
185 // Try to bring the parent to the top.
186 // MT:Only do this if this frame is currently the active window, else weird
187 // things start to happen
188 if ( wxGetActiveWindow() == this )
189 if (GetParent() && GetParent()->GetHWND())
190 ::BringWindowToTop((HWND
) GetParent()->GetHWND());
193 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
194 void wxFrame::DoGetClientSize(int *x
, int *y
) const
197 ::GetClientRect(GetHwnd(), &rect
);
200 if ( GetStatusBar() && GetStatusBar()->IsShown() )
202 int statusX
, statusY
;
203 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
204 rect
.bottom
-= statusY
;
206 #endif // wxUSE_STATUSBAR
208 wxPoint
pt(GetClientAreaOrigin());
218 // Set the client size (i.e. leave the calculation of borders etc.
220 void wxFrame::DoSetClientSize(int width
, int height
)
222 HWND hWnd
= GetHwnd();
225 ::GetClientRect(hWnd
, &rectClient
);
228 ::GetWindowRect(hWnd
, &rectTotal
);
230 // Find the difference between the entire window (title bar and all)
231 // and the client area; add this to the new client size to move the
233 width
+= rectTotal
.right
- rectTotal
.left
- rectClient
.right
;
234 height
+= rectTotal
.bottom
- rectTotal
.top
- rectClient
.bottom
;
237 wxStatusBar
*statbar
= GetStatusBar();
238 if ( statbar
&& statbar
->IsShown() )
240 // leave enough space for the status bar
241 height
+= statbar
->GetSize().y
;
243 #endif // wxUSE_STATUSBAR
245 // note that this takes the toolbar into account
246 wxPoint pt
= GetClientAreaOrigin();
250 if ( !::MoveWindow(hWnd
, rectTotal
.left
, rectTotal
.top
,
251 width
, height
, TRUE
/* redraw */) )
253 wxLogLastError(_T("MoveWindow"));
256 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
257 event
.SetEventObject(this);
258 GetEventHandler()->ProcessEvent(event
);
261 void wxFrame::DoGetSize(int *width
, int *height
) const
264 GetWindowRect(GetHwnd(), &rect
);
265 *width
= rect
.right
- rect
.left
;
266 *height
= rect
.bottom
- rect
.top
;
269 void wxFrame::DoGetPosition(int *x
, int *y
) const
272 GetWindowRect(GetHwnd(), &rect
);
281 // ----------------------------------------------------------------------------
282 // variations around ::ShowWindow()
283 // ----------------------------------------------------------------------------
285 void wxFrame::DoShowWindow(int nShowCmd
)
287 ::ShowWindow(GetHwnd(), nShowCmd
);
289 m_iconized
= nShowCmd
== SW_MINIMIZE
;
292 bool wxFrame::Show(bool show
)
294 // don't use wxWindow version as we want to call DoShowWindow()
295 if ( !wxWindowBase::Show(show
) )
301 if ( m_maximizeOnShow
)
304 nShowCmd
= SW_MAXIMIZE
;
306 m_maximizeOnShow
= FALSE
;
318 DoShowWindow(nShowCmd
);
322 ::BringWindowToTop(GetHwnd());
324 wxActivateEvent
event(wxEVT_ACTIVATE
, TRUE
, m_windowId
);
325 event
.SetEventObject( this );
326 GetEventHandler()->ProcessEvent(event
);
330 // Try to highlight the correct window (the parent)
333 HWND hWndParent
= GetHwndOf(GetParent());
335 ::BringWindowToTop(hWndParent
);
342 void wxFrame::Iconize(bool iconize
)
344 DoShowWindow(iconize
? SW_MINIMIZE
: SW_RESTORE
);
347 void wxFrame::Maximize(bool maximize
)
351 // just maximize it directly
352 DoShowWindow(maximize
? SW_MAXIMIZE
: SW_RESTORE
);
356 // we can't maximize the hidden frame because it shows it as well, so
357 // just remember that we should do it later in this case
358 m_maximizeOnShow
= TRUE
;
362 void wxFrame::Restore()
364 DoShowWindow(SW_RESTORE
);
367 bool wxFrame::IsIconized() const
369 ((wxFrame
*)this)->m_iconized
= (::IsIconic(GetHwnd()) != 0);
374 bool wxFrame::IsMaximized() const
376 return (::IsZoomed(GetHwnd()) != 0);
379 void wxFrame::SetIcon(const wxIcon
& icon
)
381 wxFrameBase::SetIcon(icon
);
383 #if defined(__WIN95__)
386 SendMessage(GetHwnd(), WM_SETICON
,
387 (WPARAM
)TRUE
, (LPARAM
)(HICON
) m_icon
.GetHICON());
392 // generate an artificial resize event
393 void wxFrame::SendSizeEvent()
397 ::GetWindowRect(GetHwnd(), &r
);
399 if ( !::GetWindowRect(GetHwnd(), &r
) )
401 wxLogLastError(_T("GetWindowRect"));
407 (void)::PostMessage(GetHwnd(), WM_SIZE
,
408 IsMaximized() ? SIZE_MAXIMIZED
: SIZE_RESTORED
,
409 MAKELPARAM(r
.right
- r
.left
, r
.bottom
- r
.top
));
414 wxStatusBar
*wxFrame::OnCreateStatusBar(int number
,
417 const wxString
& name
)
419 wxStatusBar
*statusBar
= NULL
;
421 #if wxUSE_NATIVE_STATUSBAR
422 if ( !UsesNativeStatusBar() )
424 statusBar
= (wxStatusBar
*)new wxStatusBarGeneric(this, id
, style
);
429 statusBar
= new wxStatusBar(this, id
, style
, name
);
432 // Set the height according to the font and the border size
433 wxClientDC
dc(statusBar
);
434 dc
.SetFont(statusBar
->GetFont());
437 dc
.GetTextExtent(_T("X"), NULL
, &y
);
439 int height
= (int)( (11*y
)/10 + 2*statusBar
->GetBorderY());
441 statusBar
->SetSize(-1, -1, -1, height
);
443 statusBar
->SetFieldsCount(number
);
448 void wxFrame::PositionStatusBar()
450 if ( !m_frameStatusBar
)
454 GetClientSize(&w
, &h
);
456 m_frameStatusBar
->GetSize(&sw
, &sh
);
458 // Since we wish the status bar to be directly under the client area,
459 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
460 m_frameStatusBar
->SetSize(0, h
, w
, sh
);
462 #endif // wxUSE_STATUSBAR
464 void wxFrame::DetachMenuBar()
466 if ( m_frameMenuBar
)
468 m_frameMenuBar
->Detach();
469 m_frameMenuBar
= NULL
;
473 void wxFrame::SetMenuBar(wxMenuBar
*menubar
)
479 // actually remove the menu from the frame
480 m_hMenu
= (WXHMENU
)0;
481 InternalSetMenuBar();
483 else // set new non NULL menu bar
485 m_frameMenuBar
= NULL
;
487 // Can set a menubar several times.
488 // TODO: how to prevent a memory leak if you have a currently-unattached
489 // menubar? wxWindows assumes that the frame will delete the menu (otherwise
490 // there are problems for MDI).
491 if ( menubar
->GetHMenu() )
493 m_hMenu
= menubar
->GetHMenu();
499 m_hMenu
= menubar
->Create();
505 InternalSetMenuBar();
507 m_frameMenuBar
= menubar
;
508 menubar
->Attach(this);
512 void wxFrame::InternalSetMenuBar()
514 if ( !::SetMenu(GetHwnd(), (HMENU
)m_hMenu
) )
516 wxLogLastError(wxT("SetMenu"));
520 // Responds to colour changes, and passes event on to children.
521 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
523 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
526 if ( m_frameStatusBar
)
528 wxSysColourChangedEvent event2
;
529 event2
.SetEventObject( m_frameStatusBar
);
530 m_frameStatusBar
->GetEventHandler()->ProcessEvent(event2
);
533 // Propagate the event to the non-top-level children
534 wxWindow::OnSysColourChanged(event
);
537 // Pass TRUE to show full screen, FALSE to restore.
538 bool wxFrame::ShowFullScreen(bool show
, long style
)
545 m_fsIsShowing
= TRUE
;
548 wxToolBar
*theToolBar
= GetToolBar();
549 wxStatusBar
*theStatusBar
= GetStatusBar();
554 theToolBar
->GetSize(&dummyWidth
, &m_fsToolBarHeight
);
556 theStatusBar
->GetSize(&dummyWidth
, &m_fsStatusBarHeight
);
558 // zap the toolbar, menubar, and statusbar
560 if ((style
& wxFULLSCREEN_NOTOOLBAR
) && theToolBar
)
562 theToolBar
->SetSize(-1,0);
563 theToolBar
->Show(FALSE
);
566 if (style
& wxFULLSCREEN_NOMENUBAR
)
567 SetMenu((HWND
)GetHWND(), (HMENU
) NULL
);
569 // Save the number of fields in the statusbar
570 if ((style
& wxFULLSCREEN_NOSTATUSBAR
) && theStatusBar
)
572 //m_fsStatusBarFields = theStatusBar->GetFieldsCount();
573 //SetStatusBar((wxStatusBar*) NULL);
574 //delete theStatusBar;
575 theStatusBar
->Show(FALSE
);
578 m_fsStatusBarFields
= 0;
580 // zap the frame borders
582 // save the 'normal' window style
583 m_fsOldWindowStyle
= GetWindowLong((HWND
)GetHWND(), GWL_STYLE
);
585 // save the old position, width & height, maximize state
586 m_fsOldSize
= GetRect();
587 m_fsIsMaximized
= IsMaximized();
589 // decide which window style flags to turn off
590 LONG newStyle
= m_fsOldWindowStyle
;
593 if (style
& wxFULLSCREEN_NOBORDER
)
594 offFlags
|= WS_BORDER
;
595 if (style
& wxFULLSCREEN_NOCAPTION
)
596 offFlags
|= (WS_CAPTION
| WS_SYSMENU
);
598 newStyle
&= (~offFlags
);
600 // change our window style to be compatible with full-screen mode
601 SetWindowLong((HWND
)GetHWND(), GWL_STYLE
, newStyle
);
603 // resize to the size of the desktop
607 ::GetWindowRect(GetDesktopWindow(), &rect
);
608 width
= rect
.right
- rect
.left
;
609 height
= rect
.bottom
- rect
.top
;
611 SetSize(width
, height
);
613 // now flush the window style cache and actually go full-screen
614 SetWindowPos((HWND
)GetHWND(), HWND_TOP
, 0, 0, width
, height
, SWP_FRAMECHANGED
);
616 wxSizeEvent
event(wxSize(width
, height
), GetId());
617 GetEventHandler()->ProcessEvent(event
);
626 m_fsIsShowing
= FALSE
;
628 wxToolBar
*theToolBar
= GetToolBar();
630 // restore the toolbar, menubar, and statusbar
631 if (theToolBar
&& (m_fsStyle
& wxFULLSCREEN_NOTOOLBAR
))
633 theToolBar
->SetSize(-1, m_fsToolBarHeight
);
634 theToolBar
->Show(TRUE
);
637 if ((m_fsStyle
& wxFULLSCREEN_NOSTATUSBAR
)) // && (m_fsStatusBarFields > 0))
639 //CreateStatusBar(m_fsStatusBarFields);
642 GetStatusBar()->Show(TRUE
);
647 if ((m_fsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
648 SetMenu((HWND
)GetHWND(), (HMENU
)m_hMenu
);
650 Maximize(m_fsIsMaximized
);
651 SetWindowLong((HWND
)GetHWND(),GWL_STYLE
, m_fsOldWindowStyle
);
652 SetWindowPos((HWND
)GetHWND(),HWND_TOP
,m_fsOldSize
.x
, m_fsOldSize
.y
,
653 m_fsOldSize
.width
, m_fsOldSize
.height
, SWP_FRAMECHANGED
);
664 bool wxFrame::MSWCreate(int id
, wxWindow
*parent
, const wxChar
*wclass
, wxWindow
*wx_win
, const wxChar
*title
,
665 int x
, int y
, int width
, int height
, long style
)
668 m_defaultIcon
= (WXHICON
) (wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
: wxDEFAULT_FRAME_ICON
);
670 // If child windows aren't properly drawn initially, WS_CLIPCHILDREN
671 // could be the culprit. But without it, you can get a lot of flicker.
674 if ( style
& wxCAPTION
)
676 if ( style
& wxFRAME_TOOL_WINDOW
)
677 msflags
|= WS_POPUPWINDOW
;
679 msflags
|= WS_OVERLAPPED
;
686 if (style
& wxMINIMIZE_BOX
)
687 msflags
|= WS_MINIMIZEBOX
;
688 if (style
& wxMAXIMIZE_BOX
)
689 msflags
|= WS_MAXIMIZEBOX
;
690 if (style
& wxTHICK_FRAME
)
691 msflags
|= WS_THICKFRAME
;
692 if (style
& wxSYSTEM_MENU
)
693 msflags
|= WS_SYSMENU
;
694 if ( style
& wxMINIMIZE
)
695 msflags
|= WS_MINIMIZE
;
696 if (style
& wxMAXIMIZE
)
697 msflags
|= WS_MAXIMIZE
;
698 if (style
& wxCAPTION
)
699 msflags
|= WS_CAPTION
;
700 if (style
& wxCLIP_CHILDREN
)
701 msflags
|= WS_CLIPCHILDREN
;
703 // Keep this in wxFrame because it saves recoding this function
705 #if wxUSE_ITSY_BITSY && !defined(__WIN32__)
706 if (style
& wxTINY_CAPTION_VERT
)
707 msflags
|= IBS_VERTCAPTION
;
708 if (style
& wxTINY_CAPTION_HORIZ
)
709 msflags
|= IBS_HORZCAPTION
;
711 if (style
& wxTINY_CAPTION_VERT
)
712 msflags
|= WS_CAPTION
;
713 if (style
& wxTINY_CAPTION_HORIZ
)
714 msflags
|= WS_CAPTION
;
716 if ((style
& wxTHICK_FRAME
) == 0)
717 msflags
|= WS_BORDER
;
719 WXDWORD extendedStyle
= MakeExtendedStyle(style
);
721 // make all frames appear in the win9x shell taskbar unless
722 // wxFRAME_TOOL_WINDOW or wxFRAME_NO_TASKBAR is given - without giving them
723 // WS_EX_APPWINDOW style, the child (i.e. owned) frames wouldn't appear in it
724 #if !defined(__WIN16__) && !defined(__SC__)
725 if ( (style
& wxFRAME_TOOL_WINDOW
) ||
726 (style
& wxFRAME_NO_TASKBAR
) )
727 extendedStyle
|= WS_EX_TOOLWINDOW
;
728 else if ( !(style
& wxFRAME_NO_TASKBAR
) )
729 extendedStyle
|= WS_EX_APPWINDOW
;
732 if (style
& wxSTAY_ON_TOP
)
733 extendedStyle
|= WS_EX_TOPMOST
;
736 if (m_exStyle
& wxFRAME_EX_CONTEXTHELP
)
737 extendedStyle
|= WS_EX_CONTEXTHELP
;
741 if ( !wxWindow::MSWCreate(id
, parent
, wclass
, wx_win
, title
, x
, y
, width
, height
,
742 msflags
, NULL
, extendedStyle
) )
745 // Seems to be necessary if we use WS_POPUP
746 // style instead of WS_OVERLAPPED
747 if (width
> -1 && height
> -1)
748 ::PostMessage(GetHwnd(), WM_SIZE
, SIZE_RESTORED
, MAKELPARAM(width
, height
));
753 // Default activation behaviour - set the focus for the first child
755 void wxFrame::OnActivate(wxActivateEvent
& event
)
757 if ( event
.GetActive() )
759 // restore focus to the child which was last focused
760 wxLogTrace(_T("focus"), _T("wxFrame %08x activated."), m_hWnd
);
762 wxWindow
*parent
= m_winLastFocused
? m_winLastFocused
->GetParent()
769 wxSetFocusToChild(parent
, &m_winLastFocused
);
773 // remember the last focused child if it is our child
774 m_winLastFocused
= FindFocus();
776 // so we NULL it out if it's a child from some other frame
777 wxWindow
*win
= m_winLastFocused
;
780 if ( win
->IsTopLevel() )
784 m_winLastFocused
= NULL
;
790 win
= win
->GetParent();
793 wxLogTrace(_T("focus"),
794 _T("wxFrame %08x deactivated, last focused: %08x."),
796 m_winLastFocused
? GetHwndOf(m_winLastFocused
)
803 // ----------------------------------------------------------------------------
804 // tool/status bar stuff
805 // ----------------------------------------------------------------------------
809 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
811 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
816 return m_frameToolBar
;
819 void wxFrame::PositionToolBar()
822 ::GetClientRect(GetHwnd(), &rect
);
825 if ( GetStatusBar() )
827 int statusX
, statusY
;
828 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
829 rect
.bottom
-= statusY
;
831 #endif // wxUSE_STATUSBAR
833 if ( GetToolBar() && GetToolBar()->IsShown() )
836 GetToolBar()->GetSize(&tw
, &th
);
838 if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
847 // Use the 'real' MSW position here
848 GetToolBar()->SetSize(0, 0, tw
, th
, wxSIZE_NO_ADJUSTMENTS
);
851 #endif // wxUSE_TOOLBAR
853 // ----------------------------------------------------------------------------
854 // frame state (iconized/maximized/...)
855 // ----------------------------------------------------------------------------
857 // propagate our state change to all child frames: this allows us to emulate X
858 // Windows behaviour where child frames float independently of the parent one
859 // on the desktop, but are iconized/restored with it
860 void wxFrame::IconizeChildFrames(bool bIconize
)
862 for ( wxWindowList::Node
*node
= GetChildren().GetFirst();
864 node
= node
->GetNext() )
866 wxWindow
*win
= node
->GetData();
868 // iconizing the frames with this style under Win95 shell puts them at
869 // the bottom of the screen (as the MDI children) instead of making
870 // them appear in the taskbar because they are, by virtue of this
871 // style, not managed by the taskbar - instead leave Windows take care
874 if ( win
->GetWindowStyle() & wxFRAME_TOOL_WINDOW
)
878 // the child MDI frames are a special case and should not be touched by
879 // the parent frame - instead, they are managed by the user
880 wxFrame
*frame
= wxDynamicCast(win
, wxFrame
);
881 if ( frame
&& !frame
->IsMDIChild() )
883 frame
->Iconize(bIconize
);
888 // ===========================================================================
889 // message processing
890 // ===========================================================================
892 // ---------------------------------------------------------------------------
894 // ---------------------------------------------------------------------------
896 bool wxFrame::MSWTranslateMessage(WXMSG
* pMsg
)
898 if ( wxWindow::MSWTranslateMessage(pMsg
) )
901 // try the menu bar accels
902 wxMenuBar
*menuBar
= GetMenuBar();
906 const wxAcceleratorTable
& acceleratorTable
= menuBar
->GetAccelTable();
907 return acceleratorTable
.Translate(this, pMsg
);
910 // ---------------------------------------------------------------------------
911 // our private (non virtual) message handlers
912 // ---------------------------------------------------------------------------
914 bool wxFrame::HandlePaint()
917 if ( GetUpdateRect(GetHwnd(), &rect
, FALSE
) )
921 HICON hIcon
= m_icon
.Ok() ? GetHiconOf(m_icon
)
922 : (HICON
)m_defaultIcon
;
924 // Hold a pointer to the dc so long as the OnPaint() message
925 // is being processed
927 HDC hdc
= ::BeginPaint(GetHwnd(), &ps
);
929 // Erase background before painting or we get white background
930 MSWDefWindowProc(WM_ICONERASEBKGND
, (WORD
)(LONG
)ps
.hdc
, 0L);
935 ::GetClientRect(GetHwnd(), &rect
);
937 // FIXME: why hardcoded?
938 static const int icon_width
= 32;
939 static const int icon_height
= 32;
941 int icon_x
= (int)((rect
.right
- icon_width
)/2);
942 int icon_y
= (int)((rect
.bottom
- icon_height
)/2);
944 ::DrawIcon(hdc
, icon_x
, icon_y
, hIcon
);
947 ::EndPaint(GetHwnd(), &ps
);
953 return wxWindow::HandlePaint();
958 // nothing to paint - processed
963 bool wxFrame::HandleSize(int x
, int y
, WXUINT id
)
965 bool processed
= FALSE
;
970 // only do it it if we were iconized before, otherwise resizing the
971 // parent frame has a curious side effect of bringing it under it's
976 // restore all child frames too
977 IconizeChildFrames(FALSE
);
986 // iconize all child frames too
987 IconizeChildFrames(TRUE
);
998 wxSizeEvent
event(wxSize(x
, y
), m_windowId
);
999 event
.SetEventObject( this );
1000 processed
= GetEventHandler()->ProcessEvent(event
);
1006 bool wxFrame::HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
1010 // In case it's e.g. a toolbar.
1011 wxWindow
*win
= wxFindWinFromHandle(control
);
1013 return win
->MSWCommand(cmd
, id
);
1016 // handle here commands from menus and accelerators
1017 if ( cmd
== 0 || cmd
== 1 )
1019 if ( wxCurrentPopupMenu
)
1021 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
1022 wxCurrentPopupMenu
= NULL
;
1024 return popupMenu
->MSWCommand(cmd
, id
);
1027 if ( ProcessCommand(id
) )
1036 bool wxFrame::HandleMenuSelect(WXWORD nItem
, WXWORD flags
, WXHMENU hMenu
)
1039 if ( flags
== 0xFFFF && hMenu
== 0 )
1041 // menu was removed from screen
1044 else if ( !(flags
& MF_POPUP
) && !(flags
& MF_SEPARATOR
) )
1050 // don't give hints for separators (doesn't make sense) nor for the
1051 // items opening popup menus (they don't have them anyhow) but do clear
1052 // the status line - otherwise, we would be left with the help message
1053 // for the previous item which doesn't apply any more
1054 wxStatusBar
*statbar
= GetStatusBar();
1057 statbar
->SetStatusText(wxEmptyString
);
1063 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, item
);
1064 event
.SetEventObject( this );
1066 return GetEventHandler()->ProcessEvent(event
);
1069 // ---------------------------------------------------------------------------
1070 // the window proc for wxFrame
1071 // ---------------------------------------------------------------------------
1073 long wxFrame::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1076 bool processed
= FALSE
;
1081 // if we can't close, tell the system that we processed the
1082 // message - otherwise it would close us
1083 processed
= !Close();
1090 UnpackCommand((WXWPARAM
)wParam
, (WXLPARAM
)lParam
,
1093 processed
= HandleCommand(id
, cmd
, (WXHWND
)hwnd
);
1101 UnpackMenuSelect(wParam
, lParam
, &item
, &flags
, &hmenu
);
1103 processed
= HandleMenuSelect(item
, flags
, hmenu
);
1108 processed
= HandlePaint();
1111 case WM_QUERYDRAGICON
:
1113 HICON hIcon
= m_icon
.Ok() ? GetHiconOf(m_icon
)
1114 : (HICON
)(m_defaultIcon
);
1116 processed
= rc
!= 0;
1121 processed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), wParam
);
1126 rc
= wxWindow::MSWWindowProc(message
, wParam
, lParam
);