1 /////////////////////////////////////////////////////////////////////////////
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
21 #include "wx/dialog.h"
22 #include "wx/settings.h"
23 #include "wx/dcclient.h"
26 #include "wx/os2/private.h"
29 #include "wx/statusbr.h"
30 #include "wx/generic/statusbr.h"
31 #endif // wxUSE_STATUSBAR
34 #include "wx/toolbar.h"
35 #endif // wxUSE_TOOLBAR
37 #include "wx/menuitem.h"
40 // ----------------------------------------------------------------------------
42 // ----------------------------------------------------------------------------
44 extern wxWindowList wxModelessWindows
;
45 extern wxList WXDLLEXPORT wxPendingDelete
;
46 extern wxChar wxFrameClassName
[];
47 extern wxMenu
*wxCurrentPopupMenu
;
49 // ----------------------------------------------------------------------------
51 // ----------------------------------------------------------------------------
53 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
54 EVT_ACTIVATE(wxFrame::OnActivate
)
55 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
58 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
60 // ============================================================================
62 // ============================================================================
64 // ----------------------------------------------------------------------------
65 // static class members
66 // ----------------------------------------------------------------------------
68 #if wxUSE_NATIVE_STATUSBAR
69 bool wxFrame::m_bUseNativeStatusBar
= TRUE
;
71 bool wxFrame::m_bUseNativeStatusBar
= FALSE
;
74 // ----------------------------------------------------------------------------
75 // creation/destruction
76 // ----------------------------------------------------------------------------
85 // Data to save/restore when calling ShowFullScreen
87 m_lFsOldWindowStyle
= 0L;
88 m_nFsStatusBarFields
= 0;
89 m_nFsStatusBarHeight
= 0;
90 m_nFsToolBarHeight
= 0;
91 m_bFsIsMaximized
= FALSE
;
92 m_bFsIsShowing
= FALSE
;
93 } // end of wxFrame::Init
98 , const wxString
& rsTitle
100 , const wxSize
& rSize
102 , const wxString
& rsName
107 int nWidth
= rSize
.x
;
108 int nHeight
= rSize
.y
;
111 m_windowStyle
= lulStyle
;
112 m_frameMenuBar
= NULL
;
113 m_frameToolBar
= NULL
;
114 m_frameStatusBar
= NULL
;
116 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
121 m_windowId
= (int)NewControlId();
124 pParent
->AddChild(this);
128 if ((m_windowStyle
& wxFRAME_FLOAT_ON_PARENT
) == 0)
132 wxTopLevelWindows
.Append(this);
134 OS2Create( m_windowId
146 wxModelessWindows
.Append(this);
148 } // end of wxFrame::Create
152 m_isBeingDeleted
= TRUE
;
153 wxTopLevelWindows
.DeleteObject(this);
157 if (wxTheApp
&& (wxTopLevelWindows
.Number() == 0))
159 wxTheApp
->SetTopWindow(NULL
);
161 if (wxTheApp
->GetExitOnFrameDelete())
163 ::WinPostMsg(GetHwnd(), WM_QUIT
, 0, 0);
166 wxModelessWindows
.DeleteObject(this);
169 // For some reason, wxWindows can activate another task altogether
170 // when a frame is destroyed after a modal dialog has been invoked.
171 // Try to bring the parent to the top.
173 // MT:Only do this if this frame is currently the active window, else weird
174 // things start to happen.
176 if (wxGetActiveWindow() == this)
178 if (GetParent() && GetParent()->GetHWND())
180 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
190 } // end of wxFrame::~wxFrame
193 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
195 void wxFrame::DoGetClientSize(
201 // OS/2 PM's coordinates go from bottom-left not
202 // top-left thus the += instead of the -=
208 // PM has no GetClientRect that inherantly knows about the client window
209 // We have to explicitly go fetch it!
211 hWndClient
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
212 ::WinQueryWindowRect(hWndClient
, &vRect
);
215 if ( GetStatusBar() )
220 GetStatusBar()->GetClientSize( &nStatusX
223 vRect
.yBottom
+= nStatusY
;
225 #endif // wxUSE_STATUSBAR
227 wxPoint
vPoint(GetClientAreaOrigin());
229 vRect
.yBottom
+= vPoint
.y
;
230 vRect
.xRight
-= vPoint
.x
;
236 } // end of wxFrame::DoGetClientSize
239 // Set the client size (i.e. leave the calculation of borders etc.
242 void wxFrame::DoSetClientSize(
247 HWND hWnd
= GetHwnd();
252 hWndClient
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
253 ::WinQueryWindowRect(hWndClient
, &vRect
);
255 ::WinQueryWindowRect(hWnd
, &vRect2
);
258 // Find the difference between the entire window (title bar and all)
259 // and the client area; add this to the new client size to move the
260 // window. Remember OS/2's backwards y coord system!
262 int nActualWidth
= vRect2
.xRight
- vRect2
.xLeft
- vRect
.xRight
+ nWidth
;
263 int nActualHeight
= vRect2
.yTop
+ vRect2
.yTop
- vRect
.yTop
+ nHeight
;
266 if ( GetStatusBar() )
271 GetStatusBar()->GetClientSize( &nStatusX
274 nActualHeight
+= nStatusY
;
276 #endif // wxUSE_STATUSBAR
278 wxPoint
vPoint(GetClientAreaOrigin());
279 nActualWidth
+= vPoint
.y
;
280 nActualHeight
+= vPoint
.x
;
284 vPointl
.x
= vRect2
.xLeft
;
285 vPoint
.y
= vRect2
.yTop
;
287 ::WinSetWindowPos( hWnd
293 ,SWP_MOVE
| SWP_SIZE
| SWP_SHOW
296 wxSizeEvent
vEvent( wxSize( nWidth
301 vEvent
.SetEventObject(this);
302 GetEventHandler()->ProcessEvent(vEvent
);
303 } // end of wxFrame::DoSetClientSize
305 void wxFrame::DoGetSize(
312 ::WinQueryWindowRect(GetHwnd(), &vRect
);
313 *pWidth
= vRect
.xRight
- vRect
.xLeft
;
314 *pHeight
= vRect
.yTop
- vRect
.yBottom
;
315 } // end of wxFrame::DoGetSize
317 void wxFrame::DoGetPosition(
325 ::WinQueryWindowRect(GetHwnd(), &vRect
);
326 vPoint
.x
= vRect
.xLeft
;
329 // OS/2 is backwards [WIN32 it is vRect.yTop]
331 vPoint
.y
= vRect
.yBottom
;
335 } // end of wxFrame::DoGetPosition
337 // ----------------------------------------------------------------------------
338 // variations around ::ShowWindow()
339 // ----------------------------------------------------------------------------
341 void wxFrame::DoShowWindow(
345 ::WinShowWindow(GetHwnd(), nShowCmd
);
346 m_bIconized
= nShowCmd
== SWP_MINIMIZE
;
347 } // end of wxFrame::DoShowWindow
353 DoShowWindow(bShow
? SWP_SHOW
: SWP_HIDE
);
357 wxActivateEvent
vEvent(wxEVT_ACTIVATE
, TRUE
, m_windowId
);
359 ::WinSetWindowPos( (HWND
) GetHWND()
367 vEvent
.SetEventObject(this);
368 GetEventHandler()->ProcessEvent(vEvent
);
373 // Try to highlight the correct window (the parent)
377 HWND hWndParent
= GetHwndOf(GetParent());
380 ::WinSetWindowPos( hWndParent
391 } // end of wxFrame::Show
393 void wxFrame::Iconize(
397 DoShowWindow(bIconize
? SWP_MINIMIZE
: SWP_RESTORE
);
398 } // end of wxFrame::Iconize
400 void wxFrame::Maximize(
403 DoShowWindow(bMaximize
? SWP_MAXIMIZE
: SWP_RESTORE
);
404 } // end of wxFrame::Maximize
406 void wxFrame::Restore()
408 DoShowWindow(SWP_RESTORE
);
409 } // end of wxFrame::Restore
411 bool wxFrame::IsIconized() const
416 ::WinQueryWindowPos(GetHwnd(), &vSwp
);
418 if (vSwp
.fl
& SWP_MINIMIZE
)
419 ((wxFrame
*)this)->m_bIconized
= TRUE
;
421 ((wxFrame
*)this)->m_bIconized
= FALSE
;
423 } // end of wxFrame::IsIconized
426 bool wxFrame::IsMaximized() const
431 ::WinQueryWindowPos(GetHwnd(), &vSwp
);
432 return (vSwp
.fl
& SWP_MAXIMIZE
);
433 } // end of wxFrame::IsMaximized
435 void wxFrame::SetIcon(
439 wxFrameBase::SetIcon(rIcon
);
443 ::WinSendMsg( GetHwnd()
445 ,(MPARAM
)((HICON
)m_icon
.GetHICON())
448 ::WinSendMsg( GetHwnd()
454 } // end of wxFrame::SetIcon
457 wxStatusBar
* wxFrame::OnCreateStatusBar(
461 , const wxString
& rName
464 wxStatusBar
* pStatusBar
= NULL
;
466 pStatusBar
= wxFrameBase::OnCreateStatusBar( nNumber
472 } // end of wxFrame::OnCreateStatusBar
474 void wxFrame::PositionStatusBar()
477 // Native status bar positions itself
479 if (m_frameStatusBar
)
488 hWndClient
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
489 ::WinQueryWindowRect(hWndClient
, &vRect
);
490 nWidth
= vRect
.xRight
- vRect
.xLeft
;
491 nHeight
= vRect
.yTop
- vRect
.yBottom
;
493 m_frameStatusBar
->GetSize( &nStatbarWidth
498 // Since we wish the status bar to be directly under the client area,
499 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
501 m_frameStatusBar
->SetSize( 0
507 } // end of wxFrame::PositionStatusBar
508 #endif // wxUSE_STATUSBAR
510 void wxFrame::DetachMenuBar()
514 m_frameMenuBar
->Detach();
515 m_frameMenuBar
= NULL
;
517 } // end of wxFrame::DetachMenuBar
519 void wxFrame::SetMenuBar(
529 m_frameMenuBar
= NULL
;
531 // Can set a menubar several times.
532 // TODO: how to prevent a memory leak if you have a currently-unattached
533 // menubar? wxWindows assumes that the frame will delete the menu (otherwise
534 // there are problems for MDI).
535 if (pMenuBar
->GetHMenu())
537 m_hMenu
= pMenuBar
->GetHMenu();
543 m_hMenu
= pMenuBar
->Create();
549 InternalSetMenuBar();
551 m_frameMenuBar
= pMenuBar
;
552 pMenuBar
->Attach(this);
553 } // end of wxFrame::SetMenuBar
555 void wxFrame::InternalSetMenuBar()
557 WinSendMsg((HWND
)GetHwnd(), WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
558 } // end of wxFrame::InternalSetMenuBar
561 // Responds to colour changes, and passes event on to children
563 void wxFrame::OnSysColourChanged(
564 wxSysColourChangedEvent
& rEvent
567 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
570 if (m_frameStatusBar
)
572 wxSysColourChangedEvent vEvent2
;
574 vEvent2
.SetEventObject(m_frameStatusBar
);
575 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
579 // Propagate the event to the non-top-level children
581 wxWindow::OnSysColourChanged(rEvent
);
582 } // end of wxFrame::OnSysColourChanged
584 // Pass TRUE to show full screen, FALSE to restore.
585 bool wxFrame::ShowFullScreen(
597 m_fsIsShowing = TRUE;
600 wxToolBar *theToolBar = GetToolBar();
601 wxStatusBar *theStatusBar = GetStatusBar();
606 theToolBar->GetSize(&dummyWidth, &m_fsToolBarHeight);
608 theStatusBar->GetSize(&dummyWidth, &m_fsStatusBarHeight);
610 // zap the toolbar, menubar, and statusbar
612 if ((style & wxFULLSCREEN_NOTOOLBAR) && theToolBar)
614 theToolBar->SetSize(-1,0);
615 theToolBar->Show(FALSE);
618 if (style & wxFULLSCREEN_NOMENUBAR)
619 SetMenu((HWND)GetHWND(), (HMENU) NULL);
621 // Save the number of fields in the statusbar
622 if ((style & wxFULLSCREEN_NOSTATUSBAR) && theStatusBar)
624 m_fsStatusBarFields = theStatusBar->GetFieldsCount();
625 SetStatusBar((wxStatusBar*) NULL);
629 m_fsStatusBarFields = 0;
631 // zap the frame borders
633 // save the 'normal' window style
634 m_fsOldWindowStyle = GetWindowLong((HWND)GetHWND(), GWL_STYLE);
636 // save the old position, width & height, maximize state
637 m_fsOldSize = GetRect();
638 m_fsIsMaximized = IsMaximized();
640 // decide which window style flags to turn off
641 LONG newStyle = m_fsOldWindowStyle;
644 if (style & wxFULLSCREEN_NOBORDER)
645 offFlags |= WS_BORDER;
646 if (style & wxFULLSCREEN_NOCAPTION)
647 offFlags |= (WS_CAPTION | WS_SYSMENU);
649 newStyle &= (~offFlags);
651 // change our window style to be compatible with full-screen mode
652 SetWindowLong((HWND)GetHWND(), GWL_STYLE, newStyle);
654 // resize to the size of the desktop
658 ::GetWindowRect(GetDesktopWindow(), &rect);
659 width = rect.right - rect.left;
660 height = rect.bottom - rect.top;
662 SetSize(width, height);
664 // now flush the window style cache and actually go full-screen
665 SetWindowPos((HWND)GetHWND(), HWND_TOP, 0, 0, width, height, SWP_FRAMECHANGED);
667 wxSizeEvent event(wxSize(width, height), GetId());
668 GetEventHandler()->ProcessEvent(event);
677 m_fsIsShowing = FALSE;
679 wxToolBar *theToolBar = GetToolBar();
681 // restore the toolbar, menubar, and statusbar
682 if (theToolBar && (m_fsStyle & wxFULLSCREEN_NOTOOLBAR))
684 theToolBar->SetSize(-1, m_fsToolBarHeight);
685 theToolBar->Show(TRUE);
688 if ((m_fsStyle & wxFULLSCREEN_NOSTATUSBAR) && (m_fsStatusBarFields > 0))
690 CreateStatusBar(m_fsStatusBarFields);
694 if ((m_fsStyle & wxFULLSCREEN_NOMENUBAR) && (m_hMenu != 0))
695 SetMenu((HWND)GetHWND(), (HMENU)m_hMenu);
697 Maximize(m_fsIsMaximized);
698 SetWindowLong((HWND)GetHWND(),GWL_STYLE, m_fsOldWindowStyle);
699 SetWindowPos((HWND)GetHWND(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y,
700 m_fsOldSize.width, m_fsOldSize.height, SWP_FRAMECHANGED);
706 } // end of wxFrame::ShowFullScreen
711 bool wxFrame::OS2Create(
714 , const wxChar
* zWclass
716 , const wxChar
* zTitle
724 ULONG ulCreateFlags
= 0L;
725 ULONG ulStyleFlags
= 0L;
726 ULONG ulExtraFlags
= 0L;
727 FRAMECDATA vFrameCtlData
;
728 HWND hParent
= NULLHANDLE
;
729 HWND hClient
= NULLHANDLE
;
730 HWND hTitlebar
= NULLHANDLE
;
731 HWND hHScroll
= NULLHANDLE
;
732 HWND hVScroll
= NULLHANDLE
;
738 m_hDefaultIcon
= (WXHICON
) (wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
: wxDEFAULT_FRAME_ICON
);
739 memset(&vSwp
, '\0', sizeof(SWP
));
740 memset(&vSwpTitlebar
, '\0', sizeof(SWP
));
741 memset(&vSwpVScroll
, '\0', sizeof(SWP
));
742 memset(&vSwpHScroll
, '\0', sizeof(SWP
));
744 hParent
= GetWinHwnd(pParent
);
746 hParent
= HWND_DESKTOP
;
748 if (ulStyle
== wxDEFAULT_FRAME_STYLE
)
749 ulCreateFlags
= FCF_SIZEBORDER
| FCF_TITLEBAR
| FCF_SYSMENU
|
750 FCF_MINMAX
| FCF_VERTSCROLL
| FCF_HORZSCROLL
| FCF_TASKLIST
;
753 if ((ulStyle
& wxCAPTION
) == wxCAPTION
)
754 ulCreateFlags
= FCF_TASKLIST
;
756 ulCreateFlags
= FCF_NOMOVEWITHOWNER
;
758 if (ulStyle
& wxMINIMIZE_BOX
)
759 ulCreateFlags
|= FCF_MINBUTTON
;
760 if (ulStyle
& wxMAXIMIZE_BOX
)
761 ulCreateFlags
|= FCF_MAXBUTTON
;
762 if (ulStyle
& wxTHICK_FRAME
)
763 ulCreateFlags
|= FCF_DLGBORDER
;
764 if (ulStyle
& wxSYSTEM_MENU
)
765 ulCreateFlags
|= FCF_SYSMENU
;
766 if (ulStyle
& wxCAPTION
)
767 ulCreateFlags
|= FCF_TASKLIST
;
768 if (ulStyle
& wxCLIP_CHILDREN
)
770 // Invalid for frame windows under PM
773 if (ulStyle
& wxTINY_CAPTION_VERT
)
774 ulCreateFlags
|= FCF_TASKLIST
;
775 if (ulStyle
& wxTINY_CAPTION_HORIZ
)
776 ulCreateFlags
|= FCF_TASKLIST
;
778 if ((ulStyle
& wxTHICK_FRAME
) == 0)
779 ulCreateFlags
|= FCF_BORDER
;
780 if (ulStyle
& wxFRAME_TOOL_WINDOW
)
781 ulExtraFlags
= kFrameToolWindow
;
783 if (ulStyle
& wxSTAY_ON_TOP
)
784 ulCreateFlags
|= FCF_SYSMODAL
;
786 if ((ulStyle
& wxMINIMIZE
) || (ulStyle
& wxICONIZE
))
787 ulStyleFlags
|= WS_MINIMIZED
;
788 if (ulStyle
& wxMAXIMIZE
)
789 ulStyleFlags
|= WS_MAXIMIZED
;
792 // Clear the visible flag, we always call show
794 ulStyleFlags
&= (unsigned long)~WS_VISIBLE
;
798 // Set the frame control block
800 vFrameCtlData
.cb
= sizeof(vFrameCtlData
);
801 vFrameCtlData
.flCreateFlags
= ulCreateFlags
;
802 vFrameCtlData
.hmodResources
= 0L;
803 vFrameCtlData
.idResources
= 0;
806 // Create the frame window
808 if (!wxWindow::OS2Create( hParent
819 ,(void*)&vFrameCtlData
827 // Create the client window. We must call the API from here rather than
828 // the static base class create because we need a separate handle
830 if ((hClient
= ::WinCreateWindow( GetHwnd() // Frame is parent
831 ,zWclass
// Custom client class
832 ,NULL
// Window title
834 ,0, 0, 0, 0 // Window position
837 ,FID_CLIENT
// standard client ID
838 ,NULL
// Creation data
839 ,NULL
// Window Pres Params
846 // Now size everything. If adding a menu the client will need to be resized.
848 if (!::WinSetWindowPos( GetHwnd()
854 ,SWP_SIZE
| SWP_MOVE
| SWP_ACTIVATE
858 WinQueryWindowPos(GetHwnd(), &vSwp
);
860 if (ulCreateFlags
& FCF_TITLEBAR
)
862 hTitlebar
= WinWindowFromID(GetHwnd(), FID_TITLEBAR
);
863 WinQueryWindowPos(hTitlebar
, &vSwpTitlebar
);
865 if (ulCreateFlags
& FCF_HORZSCROLL
)
867 hHScroll
= WinWindowFromID(GetHwnd(), FID_HORZSCROLL
);
868 WinQueryWindowPos(hHScroll
, &vSwpHScroll
);
870 if (ulCreateFlags
& FCF_VERTSCROLL
)
872 hVScroll
= WinWindowFromID(GetHwnd(), FID_VERTSCROLL
);
873 WinQueryWindowPos(hVScroll
, &vSwpVScroll
);
875 if (!::WinSetWindowPos( hClient
878 ,(SV_CYSIZEBORDER
- 1) + vSwpHScroll
.cy
879 ,vSwp
.cx
- ((SV_CXSIZEBORDER
* 2) + vSwpVScroll
.cx
)
880 ,vSwp
.cy
- ((SV_CYSIZEBORDER
* 2) + 1 + vSwpTitlebar
.cy
+ vSwpHScroll
.cy
)
885 } // end of wxFrame::OS2Create
888 // Default activation behaviour - set the focus for the first child
891 void wxFrame::OnActivate(
892 wxActivateEvent
& rEvent
895 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
897 pNode
= pNode
->GetNext())
899 // FIXME all this is totally bogus - we need to do the same as wxPanel,
900 // but how to do it without duplicating the code?
903 wxWindow
* pChild
= pNode
->GetData();
905 if (!pChild
->IsTopLevel()
907 && !wxDynamicCast(pChild
, wxToolBar
)
908 #endif // wxUSE_TOOLBAR
910 && !wxDynamicCast(pChild
, wxStatusBar
)
911 #endif // wxUSE_STATUSBAR
918 } // end of wxFrame::OnActivate
920 // ----------------------------------------------------------------------------
921 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
922 // from the client area, so the client area is what's really available for the
924 // ----------------------------------------------------------------------------
926 // Checks if there is a toolbar, and returns the first free client position
927 wxPoint
wxFrame::GetClientAreaOrigin() const
929 wxPoint
vPoint(0, 0);
936 GetToolBar()->GetSize( &nWidth
940 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
946 // PM is backwards from windows
951 } // end of wxFrame::GetClientAreaOrigin
953 // ----------------------------------------------------------------------------
954 // tool/status bar stuff
955 // ----------------------------------------------------------------------------
959 wxToolBar
* wxFrame::CreateToolBar(
962 , const wxString
& rName
965 if (wxFrameBase::CreateToolBar( lStyle
972 return m_frameToolBar
;
973 } // end of wxFrame::CreateToolBar
975 void wxFrame::PositionToolBar()
980 hWndClient
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
981 ::WinQueryWindowRect(hWndClient
, &vRect
);
989 GetStatusBar()->GetClientSize( &nStatusX
992 // PM is backwards from windows
993 vRect
.yBottom
+= nStatusY
;
995 #endif // wxUSE_STATUSBAR
1002 GetToolBar()->GetSize( &nToolbarWidth
1006 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
1008 nToolbarHeight
= vRect
.yBottom
;
1012 nToolbarWidth
= vRect
.xRight
;
1016 // Use the 'real' PM position here
1018 GetToolBar()->SetSize( 0
1022 ,wxSIZE_NO_ADJUSTMENTS
1025 } // end of wxFrame::PositionToolBar
1026 #endif // wxUSE_TOOLBAR
1028 // ----------------------------------------------------------------------------
1029 // frame state (iconized/maximized/...)
1030 // ----------------------------------------------------------------------------
1033 // propagate our state change to all child frames: this allows us to emulate X
1034 // Windows behaviour where child frames float independently of the parent one
1035 // on the desktop, but are iconized/restored with it
1037 void wxFrame::IconizeChildFrames(
1041 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
1043 pNode
= pNode
->GetNext() )
1045 wxWindow
* pWin
= pNode
->GetData();
1047 if (pWin
->IsKindOf(CLASSINFO(wxFrame
)) )
1049 ((wxFrame
*)pWin
)->Iconize(bIconize
);
1052 } // end of wxFrame::IconizeChildFrames
1054 // ===========================================================================
1055 // message processing
1056 // ===========================================================================
1058 // ---------------------------------------------------------------------------
1060 // ---------------------------------------------------------------------------
1061 bool wxFrame::OS2TranslateMessage(
1065 if (wxWindow::OS2TranslateMessage(pMsg
))
1068 // try the menu bar accels
1070 wxMenuBar
* pMenuBar
= GetMenuBar();
1075 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
1076 return rAcceleratorTable
.Translate(this, pMsg
);
1077 } // end of wxFrame::OS2TranslateMessage
1079 // ---------------------------------------------------------------------------
1080 // our private (non virtual) message handlers
1081 // ---------------------------------------------------------------------------
1082 bool wxFrame::HandlePaint()
1086 if (::WinQueryUpdateRect(GetHwnd(), &vRect
))
1091 // Icons in PM are the same as "pointers"
1096 hIcon
= (HPOINTER
)::WinSendMsg(GetHwnd(), WM_QUERYICON
, 0L, 0L);
1098 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1101 // Hold a pointer to the dc so long as the OnPaint() message
1102 // is being processed
1105 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
1108 // Erase background before painting or we get white background
1110 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
1117 hWndClient
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
1118 ::WinQueryWindowRect(hWndClient
, &vRect3
);
1120 static const int nIconWidth
= 32;
1121 static const int nIconHeight
= 32;
1122 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
1123 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
1125 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
1132 return wxWindow::HandlePaint();
1137 // nothing to paint - processed
1141 } // end of wxFrame::HandlePaint
1143 bool wxFrame::HandleSize(
1149 bool bProcessed
= FALSE
;
1155 // Only do it it if we were iconized before, otherwise resizing the
1156 // parent frame has a curious side effect of bringing it under it's
1162 // restore all child frames too
1164 IconizeChildFrames(FALSE
);
1171 m_bIconized
= FALSE
;
1176 // Iconize all child frames too
1178 IconizeChildFrames(TRUE
);
1186 // forward WM_SIZE to status bar control
1188 #if wxUSE_NATIVE_STATUSBAR
1189 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
1191 wxSizeEvent
vEvent( wxSize( nX
1194 ,m_frameStatusBar
->GetId()
1197 vEvent
.SetEventObject(m_frameStatusBar
);
1198 m_frameStatusBar
->OnSize(vEvent
);
1200 #endif // wxUSE_NATIVE_STATUSBAR
1202 PositionStatusBar();
1204 wxSizeEvent
vEvent( wxSize( nX
1210 vEvent
.SetEventObject(this);
1211 bProcessed
= GetEventHandler()->ProcessEvent(vEvent
);
1214 } // end of wxFrame::HandleSize
1216 bool wxFrame::HandleCommand(
1225 // In case it's e.g. a toolbar.
1227 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
1230 return pWin
->OS2Command( nCmd
1236 // Handle here commands from menus and accelerators
1238 if (nCmd
== 0 || nCmd
== 1)
1240 if (wxCurrentPopupMenu
)
1242 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1244 wxCurrentPopupMenu
= NULL
;
1246 return pPopupMenu
->OS2Command( nCmd
1251 if (ProcessCommand(nId
))
1257 } // end of wxFrame::HandleCommand
1259 bool wxFrame::HandleMenuSelect(
1267 if (nFlags
== 0xFFFF && hMenu
== 0)
1270 // Menu was removed from screen
1274 else if (!(nFlags
& MIS_SUBMENU
) && !(nFlags
& MIS_SEPARATOR
))
1281 // Don't give hints for separators (doesn't make sense) nor for the
1282 // items opening popup menus (they don't have them anyhow)
1286 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nMenuItem
);
1288 vEvent
.SetEventObject(this);
1289 return GetEventHandler()->ProcessEvent(vEvent
);
1290 } // end of wxFrame::HandleMenuSelect
1292 // ---------------------------------------------------------------------------
1293 // the window proc for wxFrame
1294 // ---------------------------------------------------------------------------
1296 MRESULT
wxFrame::OS2WindowProc(
1303 bool bProcessed
= FALSE
;
1309 // If we can't close, tell the system that we processed the
1310 // message - otherwise it would close us
1312 bProcessed
= !Close();
1321 UnpackCommand( (WXWPARAM
)wParam
1327 bProcessed
= HandleCommand( wId
1340 UnpackMenuSelect( wParam
1346 bProcessed
= HandleMenuSelect( wItem
1354 bProcessed
= HandlePaint();
1357 case CM_QUERYDRAGIMAGE
:
1362 hIcon
= (HPOINTER
)::WinSendMsg(GetHwnd(), WM_QUERYICON
, 0L, 0L);
1364 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1365 mRc
= (MRESULT
)hIcon
;
1366 bProcessed
= mRc
!= 0;
1371 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1376 mRc
= wxWindow::OS2WindowProc( uMessage
1381 } // wxFrame::OS2WindowProc