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(
346 HWND hTitlebar
= NULLHANDLE
;
347 HWND hHScroll
= NULLHANDLE
;
348 HWND hVScroll
= NULLHANDLE
;
349 HWND hMenuBar
= NULLHANDLE
;
357 // Send anything to initialize the frame
359 WinQueryWindowPos(GetHwnd(), &vSwp
);
360 hClient
= WinWindowFromID(GetHwnd(), FID_CLIENT
);
361 hTitlebar
= WinWindowFromID(GetHwnd(), FID_TITLEBAR
);
362 WinQueryWindowPos(hTitlebar
, &vSwpTitlebar
);
363 hHScroll
= WinWindowFromID(GetHwnd(), FID_HORZSCROLL
);
364 WinQueryWindowPos(hHScroll
, &vSwpHScroll
);
365 hVScroll
= WinWindowFromID(GetHwnd(), FID_VERTSCROLL
);
366 WinQueryWindowPos(hVScroll
, &vSwpVScroll
);
367 hMenuBar
= WinWindowFromID(GetHwnd(), FID_MENU
);
368 WinQueryWindowPos(hMenuBar
, &vSwpMenu
);
369 WinSetWindowPos( hClient
372 ,(SV_CYSIZEBORDER
- 1) + vSwpHScroll
.cy
373 ,vSwp
.cx
- ((SV_CXSIZEBORDER
* 2) + vSwpVScroll
.cx
)
374 ,vSwp
.cy
- ((SV_CYSIZEBORDER
* 2) + 1 + vSwpTitlebar
.cy
+ vSwpMenu
.cy
+ vSwpHScroll
.cy
)
377 ::WinShowWindow(GetHwnd(), (BOOL
)bShowCmd
);
378 ::WinShowWindow(hClient
, (BOOL
)bShowCmd
);
379 } // end of wxFrame::DoShowWindow
387 DoShowWindow((int)bShow
);
391 wxActivateEvent
vEvent(wxEVT_ACTIVATE
, TRUE
, m_windowId
);
393 ::WinQueryWindowPos(GetHwnd(), &vSwp
);
394 m_bIconized
= vSwp
.fl
& SWP_MINIMIZE
;
395 ::WinEnableWindow(GetHwnd(), TRUE
);
396 vEvent
.SetEventObject(this);
397 GetEventHandler()->ProcessEvent(vEvent
);
402 // Try to highlight the correct window (the parent)
406 HWND hWndParent
= GetHwndOf(GetParent());
408 ::WinQueryWindowPos(hWndParent
, &vSwp
);
409 m_bIconized
= vSwp
.fl
& SWP_MINIMIZE
;
411 ::WinSetWindowPos( hWndParent
417 ,SWP_ZORDER
| SWP_ACTIVATE
| SWP_SHOW
| SWP_MOVE
419 ::WinEnableWindow(hWndParent
, TRUE
);
423 } // end of wxFrame::Show
425 void wxFrame::Iconize(
429 DoShowWindow(bIconize
? SWP_MINIMIZE
: SWP_RESTORE
);
430 } // end of wxFrame::Iconize
432 void wxFrame::Maximize(
435 DoShowWindow(bMaximize
? SWP_MAXIMIZE
: SWP_RESTORE
);
436 } // end of wxFrame::Maximize
438 void wxFrame::Restore()
440 DoShowWindow(SWP_RESTORE
);
441 } // end of wxFrame::Restore
443 bool wxFrame::IsIconized() const
448 ::WinQueryWindowPos(GetHwnd(), &vSwp
);
450 if (vSwp
.fl
& SWP_MINIMIZE
)
451 ((wxFrame
*)this)->m_bIconized
= TRUE
;
453 ((wxFrame
*)this)->m_bIconized
= FALSE
;
455 } // end of wxFrame::IsIconized
458 bool wxFrame::IsMaximized() const
463 ::WinQueryWindowPos(GetHwnd(), &vSwp
);
464 return (vSwp
.fl
& SWP_MAXIMIZE
);
465 } // end of wxFrame::IsMaximized
467 void wxFrame::SetIcon(
471 wxFrameBase::SetIcon(rIcon
);
473 if ((m_icon
.GetHICON()) != NULLHANDLE
)
475 ::WinSendMsg( GetHwnd()
477 ,(MPARAM
)((HPOINTER
)m_icon
.GetHICON())
480 ::WinSendMsg( GetHwnd()
486 } // end of wxFrame::SetIcon
489 wxStatusBar
* wxFrame::OnCreateStatusBar(
493 , const wxString
& rName
496 wxStatusBar
* pStatusBar
= NULL
;
498 pStatusBar
= wxFrameBase::OnCreateStatusBar( nNumber
504 } // end of wxFrame::OnCreateStatusBar
506 void wxFrame::PositionStatusBar()
509 // Native status bar positions itself
511 if (m_frameStatusBar
)
520 hWndClient
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
521 ::WinQueryWindowRect(hWndClient
, &vRect
);
522 nWidth
= vRect
.xRight
- vRect
.xLeft
;
523 nHeight
= vRect
.yTop
- vRect
.yBottom
;
525 m_frameStatusBar
->GetSize( &nStatbarWidth
530 // Since we wish the status bar to be directly under the client area,
531 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
533 m_frameStatusBar
->SetSize( 0
539 } // end of wxFrame::PositionStatusBar
540 #endif // wxUSE_STATUSBAR
542 void wxFrame::DetachMenuBar()
546 m_frameMenuBar
->Detach();
547 m_frameMenuBar
= NULL
;
549 } // end of wxFrame::DetachMenuBar
551 void wxFrame::SetMenuBar(
564 m_frameMenuBar
= NULL
;
566 // Can set a menubar several times.
567 // TODO: how to prevent a memory leak if you have a currently-unattached
568 // menubar? wxWindows assumes that the frame will delete the menu (otherwise
569 // there are problems for MDI).
570 if (pMenuBar
->GetHMenu())
572 m_hMenu
= pMenuBar
->GetHMenu();
578 m_hMenu
= pMenuBar
->Create();
585 // Set the parent and owner of the menubar to be the frame
587 if (!::WinSetParent(m_hMenu
, GetHwnd(), FALSE
))
589 vError
= ::WinGetLastError(vHabmain
);
590 sError
= wxPMErrorToStr(vError
);
591 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
594 if (!::WinSetOwner(m_hMenu
, GetHwnd()))
596 vError
= ::WinGetLastError(vHabmain
);
597 sError
= wxPMErrorToStr(vError
);
598 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
600 InternalSetMenuBar();
602 m_frameMenuBar
= pMenuBar
;
603 pMenuBar
->Attach(this);
604 } // end of wxFrame::SetMenuBar
606 void wxFrame::InternalSetMenuBar()
608 WinSendMsg((HWND
)GetHwnd(), WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
609 } // end of wxFrame::InternalSetMenuBar
612 // Responds to colour changes, and passes event on to children
614 void wxFrame::OnSysColourChanged(
615 wxSysColourChangedEvent
& rEvent
618 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
621 if (m_frameStatusBar
)
623 wxSysColourChangedEvent vEvent2
;
625 vEvent2
.SetEventObject(m_frameStatusBar
);
626 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
630 // Propagate the event to the non-top-level children
632 wxWindow::OnSysColourChanged(rEvent
);
633 } // end of wxFrame::OnSysColourChanged
635 // Pass TRUE to show full screen, FALSE to restore.
636 bool wxFrame::ShowFullScreen(
648 m_fsIsShowing = TRUE;
651 wxToolBar *theToolBar = GetToolBar();
652 wxStatusBar *theStatusBar = GetStatusBar();
657 theToolBar->GetSize(&dummyWidth, &m_fsToolBarHeight);
659 theStatusBar->GetSize(&dummyWidth, &m_fsStatusBarHeight);
661 // zap the toolbar, menubar, and statusbar
663 if ((style & wxFULLSCREEN_NOTOOLBAR) && theToolBar)
665 theToolBar->SetSize(-1,0);
666 theToolBar->Show(FALSE);
669 if (style & wxFULLSCREEN_NOMENUBAR)
670 SetMenu((HWND)GetHWND(), (HMENU) NULL);
672 // Save the number of fields in the statusbar
673 if ((style & wxFULLSCREEN_NOSTATUSBAR) && theStatusBar)
675 m_fsStatusBarFields = theStatusBar->GetFieldsCount();
676 SetStatusBar((wxStatusBar*) NULL);
680 m_fsStatusBarFields = 0;
682 // zap the frame borders
684 // save the 'normal' window style
685 m_fsOldWindowStyle = GetWindowLong((HWND)GetHWND(), GWL_STYLE);
687 // save the old position, width & height, maximize state
688 m_fsOldSize = GetRect();
689 m_fsIsMaximized = IsMaximized();
691 // decide which window style flags to turn off
692 LONG newStyle = m_fsOldWindowStyle;
695 if (style & wxFULLSCREEN_NOBORDER)
696 offFlags |= WS_BORDER;
697 if (style & wxFULLSCREEN_NOCAPTION)
698 offFlags |= (WS_CAPTION | WS_SYSMENU);
700 newStyle &= (~offFlags);
702 // change our window style to be compatible with full-screen mode
703 SetWindowLong((HWND)GetHWND(), GWL_STYLE, newStyle);
705 // resize to the size of the desktop
709 ::GetWindowRect(GetDesktopWindow(), &rect);
710 width = rect.right - rect.left;
711 height = rect.bottom - rect.top;
713 SetSize(width, height);
715 // now flush the window style cache and actually go full-screen
716 SetWindowPos((HWND)GetHWND(), HWND_TOP, 0, 0, width, height, SWP_FRAMECHANGED);
718 wxSizeEvent event(wxSize(width, height), GetId());
719 GetEventHandler()->ProcessEvent(event);
728 m_fsIsShowing = FALSE;
730 wxToolBar *theToolBar = GetToolBar();
732 // restore the toolbar, menubar, and statusbar
733 if (theToolBar && (m_fsStyle & wxFULLSCREEN_NOTOOLBAR))
735 theToolBar->SetSize(-1, m_fsToolBarHeight);
736 theToolBar->Show(TRUE);
739 if ((m_fsStyle & wxFULLSCREEN_NOSTATUSBAR) && (m_fsStatusBarFields > 0))
741 CreateStatusBar(m_fsStatusBarFields);
745 if ((m_fsStyle & wxFULLSCREEN_NOMENUBAR) && (m_hMenu != 0))
746 SetMenu((HWND)GetHWND(), (HMENU)m_hMenu);
748 Maximize(m_fsIsMaximized);
749 SetWindowLong((HWND)GetHWND(),GWL_STYLE, m_fsOldWindowStyle);
750 SetWindowPos((HWND)GetHWND(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y,
751 m_fsOldSize.width, m_fsOldSize.height, SWP_FRAMECHANGED);
757 } // end of wxFrame::ShowFullScreen
762 bool wxFrame::OS2Create(
765 , const wxChar
* zWclass
767 , const wxChar
* zTitle
775 ULONG ulCreateFlags
= 0L;
776 ULONG ulStyleFlags
= 0L;
777 ULONG ulExtraFlags
= 0L;
778 FRAMECDATA vFrameCtlData
;
779 HWND hParent
= NULLHANDLE
;
780 HWND hClient
= NULLHANDLE
;
781 HWND hTitlebar
= NULLHANDLE
;
782 HWND hHScroll
= NULLHANDLE
;
783 HWND hVScroll
= NULLHANDLE
;
784 HWND hMenuBar
= NULLHANDLE
;
785 HWND hMenu1
= NULLHANDLE
;
786 HWND hMenu2
= NULLHANDLE
;
787 HWND hFrame
= NULLHANDLE
;
795 m_hDefaultIcon
= (WXHICON
) (wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
: wxDEFAULT_FRAME_ICON
);
796 memset(&vSwp
, '\0', sizeof(SWP
));
797 memset(&vSwpTitlebar
, '\0', sizeof(SWP
));
798 memset(&vSwpVScroll
, '\0', sizeof(SWP
));
799 memset(&vSwpHScroll
, '\0', sizeof(SWP
));
802 hParent
= GetWinHwnd(pParent
);
804 hParent
= HWND_DESKTOP
;
806 if (ulStyle
== wxDEFAULT_FRAME_STYLE
)
807 ulCreateFlags
= FCF_SIZEBORDER
| FCF_TITLEBAR
| FCF_SYSMENU
|
808 FCF_MINMAX
| FCF_VERTSCROLL
| FCF_HORZSCROLL
| FCF_TASKLIST
;
811 if ((ulStyle
& wxCAPTION
) == wxCAPTION
)
812 ulCreateFlags
= FCF_TASKLIST
;
814 ulCreateFlags
= FCF_NOMOVEWITHOWNER
;
816 if (ulStyle
& wxMINIMIZE_BOX
)
817 ulCreateFlags
|= FCF_MINBUTTON
;
818 if (ulStyle
& wxMAXIMIZE_BOX
)
819 ulCreateFlags
|= FCF_MAXBUTTON
;
820 if (ulStyle
& wxTHICK_FRAME
)
821 ulCreateFlags
|= FCF_DLGBORDER
;
822 if (ulStyle
& wxSYSTEM_MENU
)
823 ulCreateFlags
|= FCF_SYSMENU
;
824 if (ulStyle
& wxCAPTION
)
825 ulCreateFlags
|= FCF_TASKLIST
;
826 if (ulStyle
& wxCLIP_CHILDREN
)
828 // Invalid for frame windows under PM
831 if (ulStyle
& wxTINY_CAPTION_VERT
)
832 ulCreateFlags
|= FCF_TASKLIST
;
833 if (ulStyle
& wxTINY_CAPTION_HORIZ
)
834 ulCreateFlags
|= FCF_TASKLIST
;
836 if ((ulStyle
& wxTHICK_FRAME
) == 0)
837 ulCreateFlags
|= FCF_BORDER
;
838 if (ulStyle
& wxFRAME_TOOL_WINDOW
)
839 ulExtraFlags
= kFrameToolWindow
;
841 if (ulStyle
& wxSTAY_ON_TOP
)
842 ulCreateFlags
|= FCF_SYSMODAL
;
844 if ((ulStyle
& wxMINIMIZE
) || (ulStyle
& wxICONIZE
))
845 ulStyleFlags
|= WS_MINIMIZED
;
846 if (ulStyle
& wxMAXIMIZE
)
847 ulStyleFlags
|= WS_MAXIMIZED
;
850 // Clear the visible flag, we always call show
852 ulStyleFlags
&= (unsigned long)~WS_VISIBLE
;
856 // Set the frame control block
858 vFrameCtlData
.cb
= sizeof(vFrameCtlData
);
859 vFrameCtlData
.flCreateFlags
= ulCreateFlags
;
860 vFrameCtlData
.hmodResources
= 0L;
861 vFrameCtlData
.idResources
= 0;
864 // Create the frame window
866 if (!wxWindow::OS2Create( hParent
877 ,(void*)&vFrameCtlData
885 // Create the client window. We must call the API from here rather than
886 // the static base class create because we need a separate handle
888 if ((hClient
= ::WinCreateWindow( hFrame
// Frame is parent
890 ,NULL
// Window title
892 ,0, 0, 0, 0 // Window position
895 ,FID_CLIENT
// standard client ID
896 ,NULL
// Creation data
897 ,NULL
// Window Pres Params
903 // Send anything to initialize the frame
907 ,(MPARAM
)FCF_TASKLIST
912 // Now size everything. If adding a menu the client will need to be resized.
914 if (!::WinSetWindowPos( hFrame
920 ,SWP_SIZE
| SWP_MOVE
| SWP_ACTIVATE
924 WinQueryWindowPos(hFrame
, &vSwp
);
927 // Set the client window's background, otherwise it is transparent!
929 wxColour vColour
= wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW
);
931 vRgb
.bRed
= (BYTE
)vColour
.Red();
932 vRgb
.bGreen
= (BYTE
)vColour
.Green();
933 vRgb
.bBlue
= (BYTE
)vColour
.Blue();
934 WinSetPresParam( hClient
939 if (ulCreateFlags
& FCF_TITLEBAR
)
941 hTitlebar
= WinWindowFromID(hFrame
, FID_TITLEBAR
);
942 WinQueryWindowPos(hTitlebar
, &vSwpTitlebar
);
944 if (ulCreateFlags
& FCF_HORZSCROLL
)
946 hHScroll
= WinWindowFromID(hFrame
, FID_HORZSCROLL
);
947 WinQueryWindowPos(hHScroll
, &vSwpHScroll
);
949 if (ulCreateFlags
& FCF_VERTSCROLL
)
951 hVScroll
= WinWindowFromID(hFrame
, FID_VERTSCROLL
);
952 WinQueryWindowPos(hVScroll
, &vSwpVScroll
);
954 if (!::WinSetWindowPos( hClient
957 ,(SV_CYSIZEBORDER
- 1) + vSwpHScroll
.cy
958 ,vSwp
.cx
- ((SV_CXSIZEBORDER
* 2) + vSwpVScroll
.cx
)
959 ,vSwp
.cy
- ((SV_CYSIZEBORDER
* 2) + 1 + vSwpTitlebar
.cy
+ vSwpHScroll
.cy
)
963 WinQueryWindowPos(hClient
, &vSwp
);
964 ::WinShowWindow(hClient
, TRUE
);
966 } // end of wxFrame::OS2Create
969 // Default activation behaviour - set the focus for the first child
972 void wxFrame::OnActivate(
973 wxActivateEvent
& rEvent
976 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
978 pNode
= pNode
->GetNext())
980 // FIXME all this is totally bogus - we need to do the same as wxPanel,
981 // but how to do it without duplicating the code?
984 wxWindow
* pChild
= pNode
->GetData();
986 if (!pChild
->IsTopLevel()
988 && !wxDynamicCast(pChild
, wxToolBar
)
989 #endif // wxUSE_TOOLBAR
991 && !wxDynamicCast(pChild
, wxStatusBar
)
992 #endif // wxUSE_STATUSBAR
999 } // end of wxFrame::OnActivate
1001 // ----------------------------------------------------------------------------
1002 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
1003 // from the client area, so the client area is what's really available for the
1005 // ----------------------------------------------------------------------------
1007 // Checks if there is a toolbar, and returns the first free client position
1008 wxPoint
wxFrame::GetClientAreaOrigin() const
1010 wxPoint
vPoint(0, 0);
1017 GetToolBar()->GetSize( &nWidth
1021 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
1027 // PM is backwards from windows
1028 vPoint
.y
+= nHeight
;
1032 } // end of wxFrame::GetClientAreaOrigin
1034 // ----------------------------------------------------------------------------
1035 // tool/status bar stuff
1036 // ----------------------------------------------------------------------------
1040 wxToolBar
* wxFrame::CreateToolBar(
1043 , const wxString
& rName
1046 if (wxFrameBase::CreateToolBar( lStyle
1053 return m_frameToolBar
;
1054 } // end of wxFrame::CreateToolBar
1056 void wxFrame::PositionToolBar()
1061 hWndClient
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
1062 ::WinQueryWindowRect(hWndClient
, &vRect
);
1070 GetStatusBar()->GetClientSize( &nStatusX
1073 // PM is backwards from windows
1074 vRect
.yBottom
+= nStatusY
;
1076 #endif // wxUSE_STATUSBAR
1083 GetToolBar()->GetSize( &nToolbarWidth
1087 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
1089 nToolbarHeight
= vRect
.yBottom
;
1093 nToolbarWidth
= vRect
.xRight
;
1097 // Use the 'real' PM position here
1099 GetToolBar()->SetSize( 0
1103 ,wxSIZE_NO_ADJUSTMENTS
1106 } // end of wxFrame::PositionToolBar
1107 #endif // wxUSE_TOOLBAR
1109 // ----------------------------------------------------------------------------
1110 // frame state (iconized/maximized/...)
1111 // ----------------------------------------------------------------------------
1114 // propagate our state change to all child frames: this allows us to emulate X
1115 // Windows behaviour where child frames float independently of the parent one
1116 // on the desktop, but are iconized/restored with it
1118 void wxFrame::IconizeChildFrames(
1122 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
1124 pNode
= pNode
->GetNext() )
1126 wxWindow
* pWin
= pNode
->GetData();
1128 if (pWin
->IsKindOf(CLASSINFO(wxFrame
)) )
1130 ((wxFrame
*)pWin
)->Iconize(bIconize
);
1133 } // end of wxFrame::IconizeChildFrames
1135 // ===========================================================================
1136 // message processing
1137 // ===========================================================================
1139 // ---------------------------------------------------------------------------
1141 // ---------------------------------------------------------------------------
1142 bool wxFrame::OS2TranslateMessage(
1146 if (wxWindow::OS2TranslateMessage(pMsg
))
1149 // try the menu bar accels
1151 wxMenuBar
* pMenuBar
= GetMenuBar();
1156 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
1157 return rAcceleratorTable
.Translate(this, pMsg
);
1158 } // end of wxFrame::OS2TranslateMessage
1160 // ---------------------------------------------------------------------------
1161 // our private (non virtual) message handlers
1162 // ---------------------------------------------------------------------------
1163 bool wxFrame::HandlePaint()
1167 if (::WinQueryUpdateRect(GetHwnd(), &vRect
))
1172 // Icons in PM are the same as "pointers"
1177 hIcon
= (HPOINTER
)::WinSendMsg(GetHwnd(), WM_QUERYICON
, 0L, 0L);
1179 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1182 // Hold a pointer to the dc so long as the OnPaint() message
1183 // is being processed
1186 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
1189 // Erase background before painting or we get white background
1191 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
1198 hWndClient
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
1199 ::WinQueryWindowRect(hWndClient
, &vRect3
);
1201 static const int nIconWidth
= 32;
1202 static const int nIconHeight
= 32;
1203 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
1204 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
1206 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
1213 return wxWindow::HandlePaint();
1218 // nothing to paint - processed
1222 } // end of wxFrame::HandlePaint
1224 bool wxFrame::HandleSize(
1230 bool bProcessed
= FALSE
;
1236 // Only do it it if we were iconized before, otherwise resizing the
1237 // parent frame has a curious side effect of bringing it under it's
1243 // restore all child frames too
1245 IconizeChildFrames(FALSE
);
1252 m_bIconized
= FALSE
;
1257 // Iconize all child frames too
1259 IconizeChildFrames(TRUE
);
1267 // forward WM_SIZE to status bar control
1269 #if wxUSE_NATIVE_STATUSBAR
1270 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
1272 wxSizeEvent
vEvent( wxSize( nX
1275 ,m_frameStatusBar
->GetId()
1278 vEvent
.SetEventObject(m_frameStatusBar
);
1279 m_frameStatusBar
->OnSize(vEvent
);
1281 #endif // wxUSE_NATIVE_STATUSBAR
1283 PositionStatusBar();
1285 wxSizeEvent
vEvent( wxSize( nX
1291 vEvent
.SetEventObject(this);
1292 bProcessed
= GetEventHandler()->ProcessEvent(vEvent
);
1295 } // end of wxFrame::HandleSize
1297 bool wxFrame::HandleCommand(
1306 // In case it's e.g. a toolbar.
1308 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
1311 return pWin
->OS2Command( nCmd
1317 // Handle here commands from menus and accelerators
1319 if (nCmd
== 0 || nCmd
== 1)
1321 if (wxCurrentPopupMenu
)
1323 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1325 wxCurrentPopupMenu
= NULL
;
1327 return pPopupMenu
->OS2Command( nCmd
1332 if (ProcessCommand(nId
))
1338 } // end of wxFrame::HandleCommand
1340 bool wxFrame::HandleMenuSelect(
1348 if (nFlags
== 0xFFFF && hMenu
== 0)
1351 // Menu was removed from screen
1355 else if (!(nFlags
& MIS_SUBMENU
) && !(nFlags
& MIS_SEPARATOR
))
1362 // Don't give hints for separators (doesn't make sense) nor for the
1363 // items opening popup menus (they don't have them anyhow)
1367 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nMenuItem
);
1369 vEvent
.SetEventObject(this);
1370 return GetEventHandler()->ProcessEvent(vEvent
);
1371 } // end of wxFrame::HandleMenuSelect
1373 // ---------------------------------------------------------------------------
1374 // the window proc for wxFrame
1375 // ---------------------------------------------------------------------------
1377 MRESULT
wxFrame::OS2WindowProc(
1384 bool bProcessed
= FALSE
;
1390 // If we can't close, tell the system that we processed the
1391 // message - otherwise it would close us
1393 bProcessed
= !Close();
1402 UnpackCommand( (WXWPARAM
)wParam
1408 bProcessed
= HandleCommand( wId
1421 UnpackMenuSelect( wParam
1427 bProcessed
= HandleMenuSelect( wItem
1435 bProcessed
= HandlePaint();
1438 case CM_QUERYDRAGIMAGE
:
1443 hIcon
= (HPOINTER
)::WinSendMsg(GetHwnd(), WM_QUERYICON
, 0L, 0L);
1445 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1446 mRc
= (MRESULT
)hIcon
;
1447 bProcessed
= mRc
!= 0;
1452 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1457 mRc
= wxWindow::OS2WindowProc( uMessage
1462 } // wxFrame::OS2WindowProc