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(
348 // Send anything to initialize the frame
350 ::WinSendMsg( GetHwnd()
355 hClient
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
356 ::WinShowWindow(GetHwnd(), (BOOL
)bShowCmd
);
357 ::WinShowWindow(hClient
, (BOOL
)bShowCmd
);
358 } // end of wxFrame::DoShowWindow
366 DoShowWindow((int)bShow
);
370 wxActivateEvent
vEvent(wxEVT_ACTIVATE
, TRUE
, m_windowId
);
372 ::WinQueryWindowPos(GetHwnd(), &vSwp
);
373 m_bIconized
= vSwp
.fl
& SWP_MINIMIZE
;
374 ::WinSetWindowPos( (HWND
) GetHWND()
380 ,SWP_ZORDER
| SWP_ACTIVATE
| SWP_SHOW
| SWP_MOVE
382 vEvent
.SetEventObject(this);
383 GetEventHandler()->ProcessEvent(vEvent
);
388 // Try to highlight the correct window (the parent)
392 HWND hWndParent
= GetHwndOf(GetParent());
394 ::WinQueryWindowPos(hWndParent
, &vSwp
);
395 m_bIconized
= vSwp
.fl
& SWP_MINIMIZE
;
397 ::WinSetWindowPos( hWndParent
403 ,SWP_ZORDER
| SWP_ACTIVATE
| SWP_SHOW
| SWP_MOVE
408 } // end of wxFrame::Show
410 void wxFrame::Iconize(
414 DoShowWindow(bIconize
? SWP_MINIMIZE
: SWP_RESTORE
);
415 } // end of wxFrame::Iconize
417 void wxFrame::Maximize(
420 DoShowWindow(bMaximize
? SWP_MAXIMIZE
: SWP_RESTORE
);
421 } // end of wxFrame::Maximize
423 void wxFrame::Restore()
425 DoShowWindow(SWP_RESTORE
);
426 } // end of wxFrame::Restore
428 bool wxFrame::IsIconized() const
433 ::WinQueryWindowPos(GetHwnd(), &vSwp
);
435 if (vSwp
.fl
& SWP_MINIMIZE
)
436 ((wxFrame
*)this)->m_bIconized
= TRUE
;
438 ((wxFrame
*)this)->m_bIconized
= FALSE
;
440 } // end of wxFrame::IsIconized
443 bool wxFrame::IsMaximized() const
448 ::WinQueryWindowPos(GetHwnd(), &vSwp
);
449 return (vSwp
.fl
& SWP_MAXIMIZE
);
450 } // end of wxFrame::IsMaximized
452 void wxFrame::SetIcon(
456 wxFrameBase::SetIcon(rIcon
);
458 if ((m_icon
.GetHICON()) != NULLHANDLE
)
460 ::WinSendMsg( GetHwnd()
462 ,(MPARAM
)((HPOINTER
)m_icon
.GetHICON())
465 ::WinSendMsg( GetHwnd()
471 } // end of wxFrame::SetIcon
474 wxStatusBar
* wxFrame::OnCreateStatusBar(
478 , const wxString
& rName
481 wxStatusBar
* pStatusBar
= NULL
;
483 pStatusBar
= wxFrameBase::OnCreateStatusBar( nNumber
489 } // end of wxFrame::OnCreateStatusBar
491 void wxFrame::PositionStatusBar()
494 // Native status bar positions itself
496 if (m_frameStatusBar
)
505 hWndClient
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
506 ::WinQueryWindowRect(hWndClient
, &vRect
);
507 nWidth
= vRect
.xRight
- vRect
.xLeft
;
508 nHeight
= vRect
.yTop
- vRect
.yBottom
;
510 m_frameStatusBar
->GetSize( &nStatbarWidth
515 // Since we wish the status bar to be directly under the client area,
516 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
518 m_frameStatusBar
->SetSize( 0
524 } // end of wxFrame::PositionStatusBar
525 #endif // wxUSE_STATUSBAR
527 void wxFrame::DetachMenuBar()
531 m_frameMenuBar
->Detach();
532 m_frameMenuBar
= NULL
;
534 } // end of wxFrame::DetachMenuBar
536 void wxFrame::SetMenuBar(
546 m_frameMenuBar
= NULL
;
548 // Can set a menubar several times.
549 // TODO: how to prevent a memory leak if you have a currently-unattached
550 // menubar? wxWindows assumes that the frame will delete the menu (otherwise
551 // there are problems for MDI).
552 if (pMenuBar
->GetHMenu())
554 m_hMenu
= pMenuBar
->GetHMenu();
560 m_hMenu
= pMenuBar
->Create();
566 InternalSetMenuBar();
568 m_frameMenuBar
= pMenuBar
;
569 pMenuBar
->Attach(this);
570 } // end of wxFrame::SetMenuBar
572 void wxFrame::InternalSetMenuBar()
574 WinSendMsg((HWND
)GetHwnd(), WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
575 } // end of wxFrame::InternalSetMenuBar
578 // Responds to colour changes, and passes event on to children
580 void wxFrame::OnSysColourChanged(
581 wxSysColourChangedEvent
& rEvent
584 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
587 if (m_frameStatusBar
)
589 wxSysColourChangedEvent vEvent2
;
591 vEvent2
.SetEventObject(m_frameStatusBar
);
592 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
596 // Propagate the event to the non-top-level children
598 wxWindow::OnSysColourChanged(rEvent
);
599 } // end of wxFrame::OnSysColourChanged
601 // Pass TRUE to show full screen, FALSE to restore.
602 bool wxFrame::ShowFullScreen(
614 m_fsIsShowing = TRUE;
617 wxToolBar *theToolBar = GetToolBar();
618 wxStatusBar *theStatusBar = GetStatusBar();
623 theToolBar->GetSize(&dummyWidth, &m_fsToolBarHeight);
625 theStatusBar->GetSize(&dummyWidth, &m_fsStatusBarHeight);
627 // zap the toolbar, menubar, and statusbar
629 if ((style & wxFULLSCREEN_NOTOOLBAR) && theToolBar)
631 theToolBar->SetSize(-1,0);
632 theToolBar->Show(FALSE);
635 if (style & wxFULLSCREEN_NOMENUBAR)
636 SetMenu((HWND)GetHWND(), (HMENU) NULL);
638 // Save the number of fields in the statusbar
639 if ((style & wxFULLSCREEN_NOSTATUSBAR) && theStatusBar)
641 m_fsStatusBarFields = theStatusBar->GetFieldsCount();
642 SetStatusBar((wxStatusBar*) NULL);
646 m_fsStatusBarFields = 0;
648 // zap the frame borders
650 // save the 'normal' window style
651 m_fsOldWindowStyle = GetWindowLong((HWND)GetHWND(), GWL_STYLE);
653 // save the old position, width & height, maximize state
654 m_fsOldSize = GetRect();
655 m_fsIsMaximized = IsMaximized();
657 // decide which window style flags to turn off
658 LONG newStyle = m_fsOldWindowStyle;
661 if (style & wxFULLSCREEN_NOBORDER)
662 offFlags |= WS_BORDER;
663 if (style & wxFULLSCREEN_NOCAPTION)
664 offFlags |= (WS_CAPTION | WS_SYSMENU);
666 newStyle &= (~offFlags);
668 // change our window style to be compatible with full-screen mode
669 SetWindowLong((HWND)GetHWND(), GWL_STYLE, newStyle);
671 // resize to the size of the desktop
675 ::GetWindowRect(GetDesktopWindow(), &rect);
676 width = rect.right - rect.left;
677 height = rect.bottom - rect.top;
679 SetSize(width, height);
681 // now flush the window style cache and actually go full-screen
682 SetWindowPos((HWND)GetHWND(), HWND_TOP, 0, 0, width, height, SWP_FRAMECHANGED);
684 wxSizeEvent event(wxSize(width, height), GetId());
685 GetEventHandler()->ProcessEvent(event);
694 m_fsIsShowing = FALSE;
696 wxToolBar *theToolBar = GetToolBar();
698 // restore the toolbar, menubar, and statusbar
699 if (theToolBar && (m_fsStyle & wxFULLSCREEN_NOTOOLBAR))
701 theToolBar->SetSize(-1, m_fsToolBarHeight);
702 theToolBar->Show(TRUE);
705 if ((m_fsStyle & wxFULLSCREEN_NOSTATUSBAR) && (m_fsStatusBarFields > 0))
707 CreateStatusBar(m_fsStatusBarFields);
711 if ((m_fsStyle & wxFULLSCREEN_NOMENUBAR) && (m_hMenu != 0))
712 SetMenu((HWND)GetHWND(), (HMENU)m_hMenu);
714 Maximize(m_fsIsMaximized);
715 SetWindowLong((HWND)GetHWND(),GWL_STYLE, m_fsOldWindowStyle);
716 SetWindowPos((HWND)GetHWND(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y,
717 m_fsOldSize.width, m_fsOldSize.height, SWP_FRAMECHANGED);
723 } // end of wxFrame::ShowFullScreen
728 bool wxFrame::OS2Create(
731 , const wxChar
* zWclass
733 , const wxChar
* zTitle
741 ULONG ulCreateFlags
= 0L;
742 ULONG ulStyleFlags
= 0L;
743 ULONG ulExtraFlags
= 0L;
744 FRAMECDATA vFrameCtlData
;
745 HWND hParent
= NULLHANDLE
;
746 HWND hClient
= NULLHANDLE
;
747 HWND hTitlebar
= NULLHANDLE
;
748 HWND hHScroll
= NULLHANDLE
;
749 HWND hVScroll
= NULLHANDLE
;
755 m_hDefaultIcon
= (WXHICON
) (wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
: wxDEFAULT_FRAME_ICON
);
756 memset(&vSwp
, '\0', sizeof(SWP
));
757 memset(&vSwpTitlebar
, '\0', sizeof(SWP
));
758 memset(&vSwpVScroll
, '\0', sizeof(SWP
));
759 memset(&vSwpHScroll
, '\0', sizeof(SWP
));
761 hParent
= GetWinHwnd(pParent
);
763 hParent
= HWND_DESKTOP
;
765 if (ulStyle
== wxDEFAULT_FRAME_STYLE
)
766 ulCreateFlags
= FCF_SIZEBORDER
| FCF_TITLEBAR
| FCF_SYSMENU
|
767 FCF_MINMAX
| FCF_VERTSCROLL
| FCF_HORZSCROLL
| FCF_TASKLIST
;
770 if ((ulStyle
& wxCAPTION
) == wxCAPTION
)
771 ulCreateFlags
= FCF_TASKLIST
;
773 ulCreateFlags
= FCF_NOMOVEWITHOWNER
;
775 if (ulStyle
& wxMINIMIZE_BOX
)
776 ulCreateFlags
|= FCF_MINBUTTON
;
777 if (ulStyle
& wxMAXIMIZE_BOX
)
778 ulCreateFlags
|= FCF_MAXBUTTON
;
779 if (ulStyle
& wxTHICK_FRAME
)
780 ulCreateFlags
|= FCF_DLGBORDER
;
781 if (ulStyle
& wxSYSTEM_MENU
)
782 ulCreateFlags
|= FCF_SYSMENU
;
783 if (ulStyle
& wxCAPTION
)
784 ulCreateFlags
|= FCF_TASKLIST
;
785 if (ulStyle
& wxCLIP_CHILDREN
)
787 // Invalid for frame windows under PM
790 if (ulStyle
& wxTINY_CAPTION_VERT
)
791 ulCreateFlags
|= FCF_TASKLIST
;
792 if (ulStyle
& wxTINY_CAPTION_HORIZ
)
793 ulCreateFlags
|= FCF_TASKLIST
;
795 if ((ulStyle
& wxTHICK_FRAME
) == 0)
796 ulCreateFlags
|= FCF_BORDER
;
797 if (ulStyle
& wxFRAME_TOOL_WINDOW
)
798 ulExtraFlags
= kFrameToolWindow
;
800 if (ulStyle
& wxSTAY_ON_TOP
)
801 ulCreateFlags
|= FCF_SYSMODAL
;
803 if ((ulStyle
& wxMINIMIZE
) || (ulStyle
& wxICONIZE
))
804 ulStyleFlags
|= WS_MINIMIZED
;
805 if (ulStyle
& wxMAXIMIZE
)
806 ulStyleFlags
|= WS_MAXIMIZED
;
809 // Clear the visible flag, we always call show
811 ulStyleFlags
&= (unsigned long)~WS_VISIBLE
;
815 // Set the frame control block
817 vFrameCtlData
.cb
= sizeof(vFrameCtlData
);
818 vFrameCtlData
.flCreateFlags
= ulCreateFlags
;
819 vFrameCtlData
.hmodResources
= 0L;
820 vFrameCtlData
.idResources
= 0;
823 // Create the frame window
825 if (!wxWindow::OS2Create( hParent
836 ,(void*)&vFrameCtlData
844 // Create the client window. We must call the API from here rather than
845 // the static base class create because we need a separate handle
847 if ((hClient
= ::WinCreateWindow( GetHwnd() // Frame is parent
848 ,zWclass
// Custom client class
849 ,NULL
// Window title
851 ,0, 0, 0, 0 // Window position
854 ,FID_CLIENT
// standard client ID
855 ,NULL
// Creation data
856 ,NULL
// Window Pres Params
862 // Send anything to initialize the frame
864 ::WinSendMsg( GetHwnd()
866 ,(MPARAM
)FCF_TASKLIST
871 // Now size everything. If adding a menu the client will need to be resized.
873 if (!::WinSetWindowPos( GetHwnd()
879 ,SWP_SIZE
| SWP_MOVE
| SWP_ACTIVATE
883 WinQueryWindowPos(GetHwnd(), &vSwp
);
885 if (ulCreateFlags
& FCF_TITLEBAR
)
887 hTitlebar
= WinWindowFromID(GetHwnd(), FID_TITLEBAR
);
888 WinQueryWindowPos(hTitlebar
, &vSwpTitlebar
);
890 if (ulCreateFlags
& FCF_HORZSCROLL
)
892 hHScroll
= WinWindowFromID(GetHwnd(), FID_HORZSCROLL
);
893 WinQueryWindowPos(hHScroll
, &vSwpHScroll
);
895 if (ulCreateFlags
& FCF_VERTSCROLL
)
897 hVScroll
= WinWindowFromID(GetHwnd(), FID_VERTSCROLL
);
898 WinQueryWindowPos(hVScroll
, &vSwpVScroll
);
900 if (!::WinSetWindowPos( hClient
903 ,(SV_CYSIZEBORDER
- 1) + vSwpHScroll
.cy
904 ,vSwp
.cx
- ((SV_CXSIZEBORDER
* 2) + vSwpVScroll
.cx
)
905 ,vSwp
.cy
- ((SV_CYSIZEBORDER
* 2) + 1 + vSwpTitlebar
.cy
+ vSwpHScroll
.cy
)
909 WinQueryWindowPos(hClient
, &vSwp
);
911 } // end of wxFrame::OS2Create
914 // Default activation behaviour - set the focus for the first child
917 void wxFrame::OnActivate(
918 wxActivateEvent
& rEvent
921 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
923 pNode
= pNode
->GetNext())
925 // FIXME all this is totally bogus - we need to do the same as wxPanel,
926 // but how to do it without duplicating the code?
929 wxWindow
* pChild
= pNode
->GetData();
931 if (!pChild
->IsTopLevel()
933 && !wxDynamicCast(pChild
, wxToolBar
)
934 #endif // wxUSE_TOOLBAR
936 && !wxDynamicCast(pChild
, wxStatusBar
)
937 #endif // wxUSE_STATUSBAR
944 } // end of wxFrame::OnActivate
946 // ----------------------------------------------------------------------------
947 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
948 // from the client area, so the client area is what's really available for the
950 // ----------------------------------------------------------------------------
952 // Checks if there is a toolbar, and returns the first free client position
953 wxPoint
wxFrame::GetClientAreaOrigin() const
955 wxPoint
vPoint(0, 0);
962 GetToolBar()->GetSize( &nWidth
966 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
972 // PM is backwards from windows
977 } // end of wxFrame::GetClientAreaOrigin
979 // ----------------------------------------------------------------------------
980 // tool/status bar stuff
981 // ----------------------------------------------------------------------------
985 wxToolBar
* wxFrame::CreateToolBar(
988 , const wxString
& rName
991 if (wxFrameBase::CreateToolBar( lStyle
998 return m_frameToolBar
;
999 } // end of wxFrame::CreateToolBar
1001 void wxFrame::PositionToolBar()
1006 hWndClient
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
1007 ::WinQueryWindowRect(hWndClient
, &vRect
);
1015 GetStatusBar()->GetClientSize( &nStatusX
1018 // PM is backwards from windows
1019 vRect
.yBottom
+= nStatusY
;
1021 #endif // wxUSE_STATUSBAR
1028 GetToolBar()->GetSize( &nToolbarWidth
1032 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
1034 nToolbarHeight
= vRect
.yBottom
;
1038 nToolbarWidth
= vRect
.xRight
;
1042 // Use the 'real' PM position here
1044 GetToolBar()->SetSize( 0
1048 ,wxSIZE_NO_ADJUSTMENTS
1051 } // end of wxFrame::PositionToolBar
1052 #endif // wxUSE_TOOLBAR
1054 // ----------------------------------------------------------------------------
1055 // frame state (iconized/maximized/...)
1056 // ----------------------------------------------------------------------------
1059 // propagate our state change to all child frames: this allows us to emulate X
1060 // Windows behaviour where child frames float independently of the parent one
1061 // on the desktop, but are iconized/restored with it
1063 void wxFrame::IconizeChildFrames(
1067 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
1069 pNode
= pNode
->GetNext() )
1071 wxWindow
* pWin
= pNode
->GetData();
1073 if (pWin
->IsKindOf(CLASSINFO(wxFrame
)) )
1075 ((wxFrame
*)pWin
)->Iconize(bIconize
);
1078 } // end of wxFrame::IconizeChildFrames
1080 // ===========================================================================
1081 // message processing
1082 // ===========================================================================
1084 // ---------------------------------------------------------------------------
1086 // ---------------------------------------------------------------------------
1087 bool wxFrame::OS2TranslateMessage(
1091 if (wxWindow::OS2TranslateMessage(pMsg
))
1094 // try the menu bar accels
1096 wxMenuBar
* pMenuBar
= GetMenuBar();
1101 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
1102 return rAcceleratorTable
.Translate(this, pMsg
);
1103 } // end of wxFrame::OS2TranslateMessage
1105 // ---------------------------------------------------------------------------
1106 // our private (non virtual) message handlers
1107 // ---------------------------------------------------------------------------
1108 bool wxFrame::HandlePaint()
1112 if (::WinQueryUpdateRect(GetHwnd(), &vRect
))
1117 // Icons in PM are the same as "pointers"
1122 hIcon
= (HPOINTER
)::WinSendMsg(GetHwnd(), WM_QUERYICON
, 0L, 0L);
1124 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1127 // Hold a pointer to the dc so long as the OnPaint() message
1128 // is being processed
1131 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
1134 // Erase background before painting or we get white background
1136 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
1143 hWndClient
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
1144 ::WinQueryWindowRect(hWndClient
, &vRect3
);
1146 static const int nIconWidth
= 32;
1147 static const int nIconHeight
= 32;
1148 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
1149 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
1151 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
1158 return wxWindow::HandlePaint();
1163 // nothing to paint - processed
1167 } // end of wxFrame::HandlePaint
1169 bool wxFrame::HandleSize(
1175 bool bProcessed
= FALSE
;
1181 // Only do it it if we were iconized before, otherwise resizing the
1182 // parent frame has a curious side effect of bringing it under it's
1188 // restore all child frames too
1190 IconizeChildFrames(FALSE
);
1197 m_bIconized
= FALSE
;
1202 // Iconize all child frames too
1204 IconizeChildFrames(TRUE
);
1212 // forward WM_SIZE to status bar control
1214 #if wxUSE_NATIVE_STATUSBAR
1215 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
1217 wxSizeEvent
vEvent( wxSize( nX
1220 ,m_frameStatusBar
->GetId()
1223 vEvent
.SetEventObject(m_frameStatusBar
);
1224 m_frameStatusBar
->OnSize(vEvent
);
1226 #endif // wxUSE_NATIVE_STATUSBAR
1228 PositionStatusBar();
1230 wxSizeEvent
vEvent( wxSize( nX
1236 vEvent
.SetEventObject(this);
1237 bProcessed
= GetEventHandler()->ProcessEvent(vEvent
);
1240 } // end of wxFrame::HandleSize
1242 bool wxFrame::HandleCommand(
1251 // In case it's e.g. a toolbar.
1253 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
1256 return pWin
->OS2Command( nCmd
1262 // Handle here commands from menus and accelerators
1264 if (nCmd
== 0 || nCmd
== 1)
1266 if (wxCurrentPopupMenu
)
1268 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1270 wxCurrentPopupMenu
= NULL
;
1272 return pPopupMenu
->OS2Command( nCmd
1277 if (ProcessCommand(nId
))
1283 } // end of wxFrame::HandleCommand
1285 bool wxFrame::HandleMenuSelect(
1293 if (nFlags
== 0xFFFF && hMenu
== 0)
1296 // Menu was removed from screen
1300 else if (!(nFlags
& MIS_SUBMENU
) && !(nFlags
& MIS_SEPARATOR
))
1307 // Don't give hints for separators (doesn't make sense) nor for the
1308 // items opening popup menus (they don't have them anyhow)
1312 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nMenuItem
);
1314 vEvent
.SetEventObject(this);
1315 return GetEventHandler()->ProcessEvent(vEvent
);
1316 } // end of wxFrame::HandleMenuSelect
1318 // ---------------------------------------------------------------------------
1319 // the window proc for wxFrame
1320 // ---------------------------------------------------------------------------
1322 MRESULT
wxFrame::OS2WindowProc(
1329 bool bProcessed
= FALSE
;
1335 // If we can't close, tell the system that we processed the
1336 // message - otherwise it would close us
1338 bProcessed
= !Close();
1347 UnpackCommand( (WXWPARAM
)wParam
1353 bProcessed
= HandleCommand( wId
1366 UnpackMenuSelect( wParam
1372 bProcessed
= HandleMenuSelect( wItem
1380 bProcessed
= HandlePaint();
1383 case CM_QUERYDRAGIMAGE
:
1388 hIcon
= (HPOINTER
)::WinSendMsg(GetHwnd(), WM_QUERYICON
, 0L, 0L);
1390 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1391 mRc
= (MRESULT
)hIcon
;
1392 bProcessed
= mRc
!= 0;
1397 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1402 mRc
= wxWindow::OS2WindowProc( uMessage
1407 } // wxFrame::OS2WindowProc