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 HWND hClient
= NULLHANDLE
;
349 // Reset the window position
351 hClient
= WinWindowFromID(GetHwnd(), FID_CLIENT
);
352 WinQueryWindowPos(GetHwnd(), &vSwp
);
353 WinSetWindowPos( GetHwnd()
359 ,SWP_SIZE
| SWP_MOVE
| SWP_ACTIVATE
361 ::WinShowWindow(GetHwnd(), (BOOL
)bShowCmd
);
362 ::WinShowWindow(hClient
, (BOOL
)bShowCmd
);
363 } // end of wxFrame::DoShowWindow
371 DoShowWindow((int)bShow
);
375 wxActivateEvent
vEvent(wxEVT_ACTIVATE
, TRUE
, m_windowId
);
377 ::WinQueryWindowPos(GetHwnd(), &vSwp
);
378 m_bIconized
= vSwp
.fl
& SWP_MINIMIZE
;
379 ::WinEnableWindow(GetHwnd(), TRUE
);
380 vEvent
.SetEventObject(this);
381 GetEventHandler()->ProcessEvent(vEvent
);
386 // Try to highlight the correct window (the parent)
390 HWND hWndParent
= GetHwndOf(GetParent());
392 ::WinQueryWindowPos(hWndParent
, &vSwp
);
393 m_bIconized
= vSwp
.fl
& SWP_MINIMIZE
;
395 ::WinSetWindowPos( hWndParent
401 ,SWP_ZORDER
| SWP_ACTIVATE
| SWP_SHOW
| SWP_MOVE
403 ::WinEnableWindow(hWndParent
, TRUE
);
407 } // end of wxFrame::Show
409 void wxFrame::Iconize(
413 DoShowWindow(bIconize
? SWP_MINIMIZE
: SWP_RESTORE
);
414 } // end of wxFrame::Iconize
416 void wxFrame::Maximize(
419 DoShowWindow(bMaximize
? SWP_MAXIMIZE
: SWP_RESTORE
);
420 } // end of wxFrame::Maximize
422 void wxFrame::Restore()
424 DoShowWindow(SWP_RESTORE
);
425 } // end of wxFrame::Restore
427 bool wxFrame::IsIconized() const
432 ::WinQueryWindowPos(GetHwnd(), &vSwp
);
434 if (vSwp
.fl
& SWP_MINIMIZE
)
435 ((wxFrame
*)this)->m_bIconized
= TRUE
;
437 ((wxFrame
*)this)->m_bIconized
= FALSE
;
439 } // end of wxFrame::IsIconized
442 bool wxFrame::IsMaximized() const
447 ::WinQueryWindowPos(GetHwnd(), &vSwp
);
448 return (vSwp
.fl
& SWP_MAXIMIZE
);
449 } // end of wxFrame::IsMaximized
451 void wxFrame::SetIcon(
455 wxFrameBase::SetIcon(rIcon
);
457 if ((m_icon
.GetHICON()) != NULLHANDLE
)
459 ::WinSendMsg( GetHwnd()
461 ,(MPARAM
)((HPOINTER
)m_icon
.GetHICON())
464 ::WinSendMsg( GetHwnd()
470 } // end of wxFrame::SetIcon
473 wxStatusBar
* wxFrame::OnCreateStatusBar(
477 , const wxString
& rName
480 wxStatusBar
* pStatusBar
= NULL
;
482 pStatusBar
= wxFrameBase::OnCreateStatusBar( nNumber
488 } // end of wxFrame::OnCreateStatusBar
490 void wxFrame::PositionStatusBar()
493 // Native status bar positions itself
495 if (m_frameStatusBar
)
504 hWndClient
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
505 ::WinQueryWindowRect(hWndClient
, &vRect
);
506 nWidth
= vRect
.xRight
- vRect
.xLeft
;
507 nHeight
= vRect
.yTop
- vRect
.yBottom
;
509 m_frameStatusBar
->GetSize( &nStatbarWidth
514 // Since we wish the status bar to be directly under the client area,
515 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
517 m_frameStatusBar
->SetSize( 0
523 } // end of wxFrame::PositionStatusBar
524 #endif // wxUSE_STATUSBAR
526 void wxFrame::DetachMenuBar()
530 m_frameMenuBar
->Detach();
531 m_frameMenuBar
= NULL
;
533 } // end of wxFrame::DetachMenuBar
535 void wxFrame::SetMenuBar(
541 HWND hClient
= NULLHANDLE
;
542 HWND hFrame
= NULLHANDLE
;
543 HWND hTitlebar
= NULLHANDLE
;
544 HWND hHScroll
= NULLHANDLE
;
545 HWND hVScroll
= NULLHANDLE
;
546 HWND hMenuBar
= NULLHANDLE
;
559 m_frameMenuBar
= NULL
;
561 // Can set a menubar several times.
562 // TODO: how to prevent a memory leak if you have a currently-unattached
563 // menubar? wxWindows assumes that the frame will delete the menu (otherwise
564 // there are problems for MDI).
565 if (pMenuBar
->GetHMenu())
567 m_hMenu
= pMenuBar
->GetHMenu();
573 m_hMenu
= pMenuBar
->Create();
580 // Set the parent and owner of the menubar to be the frame
582 if (!::WinSetParent(m_hMenu
, GetHwnd(), FALSE
))
584 vError
= ::WinGetLastError(vHabmain
);
585 sError
= wxPMErrorToStr(vError
);
586 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
589 if (!::WinSetOwner(m_hMenu
, GetHwnd()))
591 vError
= ::WinGetLastError(vHabmain
);
592 sError
= wxPMErrorToStr(vError
);
593 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
595 InternalSetMenuBar();
597 m_frameMenuBar
= pMenuBar
;
598 pMenuBar
->Attach(this);
601 // Now resize the client to fit the new frame
603 WinQueryWindowPos(GetHwnd(), &vSwp
);
604 hClient
= WinWindowFromID(GetHwnd(), FID_CLIENT
);
605 hTitlebar
= WinWindowFromID(GetHwnd(), FID_TITLEBAR
);
606 WinQueryWindowPos(hTitlebar
, &vSwpTitlebar
);
607 hHScroll
= WinWindowFromID(GetHwnd(), FID_HORZSCROLL
);
608 WinQueryWindowPos(hHScroll
, &vSwpHScroll
);
609 hVScroll
= WinWindowFromID(GetHwnd(), FID_VERTSCROLL
);
610 WinQueryWindowPos(hVScroll
, &vSwpVScroll
);
611 hMenuBar
= WinWindowFromID(GetHwnd(), FID_MENU
);
612 WinQueryWindowPos(hMenuBar
, &vSwpMenu
);
613 WinSetWindowPos( hClient
616 ,(SV_CYSIZEBORDER
/2) + vSwpHScroll
.cy
/2
617 ,vSwp
.cx
- ((SV_CXSIZEBORDER
+ 1) + vSwpVScroll
.cx
)
618 ,vSwp
.cy
- ((SV_CYSIZEBORDER
+ 1) + vSwpTitlebar
.cy
+ vSwpMenu
.cy
+ vSwpHScroll
.cy
/2)
621 } // end of wxFrame::SetMenuBar
623 void wxFrame::InternalSetMenuBar()
625 WinSendMsg((HWND
)GetHwnd(), WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
626 } // end of wxFrame::InternalSetMenuBar
629 // Responds to colour changes, and passes event on to children
631 void wxFrame::OnSysColourChanged(
632 wxSysColourChangedEvent
& rEvent
635 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
638 if (m_frameStatusBar
)
640 wxSysColourChangedEvent vEvent2
;
642 vEvent2
.SetEventObject(m_frameStatusBar
);
643 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
647 // Propagate the event to the non-top-level children
649 wxWindow::OnSysColourChanged(rEvent
);
650 } // end of wxFrame::OnSysColourChanged
652 // Pass TRUE to show full screen, FALSE to restore.
653 bool wxFrame::ShowFullScreen(
665 m_fsIsShowing = TRUE;
668 wxToolBar *theToolBar = GetToolBar();
669 wxStatusBar *theStatusBar = GetStatusBar();
674 theToolBar->GetSize(&dummyWidth, &m_fsToolBarHeight);
676 theStatusBar->GetSize(&dummyWidth, &m_fsStatusBarHeight);
678 // zap the toolbar, menubar, and statusbar
680 if ((style & wxFULLSCREEN_NOTOOLBAR) && theToolBar)
682 theToolBar->SetSize(-1,0);
683 theToolBar->Show(FALSE);
686 if (style & wxFULLSCREEN_NOMENUBAR)
687 SetMenu((HWND)GetHWND(), (HMENU) NULL);
689 // Save the number of fields in the statusbar
690 if ((style & wxFULLSCREEN_NOSTATUSBAR) && theStatusBar)
692 m_fsStatusBarFields = theStatusBar->GetFieldsCount();
693 SetStatusBar((wxStatusBar*) NULL);
697 m_fsStatusBarFields = 0;
699 // zap the frame borders
701 // save the 'normal' window style
702 m_fsOldWindowStyle = GetWindowLong((HWND)GetHWND(), GWL_STYLE);
704 // save the old position, width & height, maximize state
705 m_fsOldSize = GetRect();
706 m_fsIsMaximized = IsMaximized();
708 // decide which window style flags to turn off
709 LONG newStyle = m_fsOldWindowStyle;
712 if (style & wxFULLSCREEN_NOBORDER)
713 offFlags |= WS_BORDER;
714 if (style & wxFULLSCREEN_NOCAPTION)
715 offFlags |= (WS_CAPTION | WS_SYSMENU);
717 newStyle &= (~offFlags);
719 // change our window style to be compatible with full-screen mode
720 SetWindowLong((HWND)GetHWND(), GWL_STYLE, newStyle);
722 // resize to the size of the desktop
726 ::GetWindowRect(GetDesktopWindow(), &rect);
727 width = rect.right - rect.left;
728 height = rect.bottom - rect.top;
730 SetSize(width, height);
732 // now flush the window style cache and actually go full-screen
733 SetWindowPos((HWND)GetHWND(), HWND_TOP, 0, 0, width, height, SWP_FRAMECHANGED);
735 wxSizeEvent event(wxSize(width, height), GetId());
736 GetEventHandler()->ProcessEvent(event);
745 m_fsIsShowing = FALSE;
747 wxToolBar *theToolBar = GetToolBar();
749 // restore the toolbar, menubar, and statusbar
750 if (theToolBar && (m_fsStyle & wxFULLSCREEN_NOTOOLBAR))
752 theToolBar->SetSize(-1, m_fsToolBarHeight);
753 theToolBar->Show(TRUE);
756 if ((m_fsStyle & wxFULLSCREEN_NOSTATUSBAR) && (m_fsStatusBarFields > 0))
758 CreateStatusBar(m_fsStatusBarFields);
762 if ((m_fsStyle & wxFULLSCREEN_NOMENUBAR) && (m_hMenu != 0))
763 SetMenu((HWND)GetHWND(), (HMENU)m_hMenu);
765 Maximize(m_fsIsMaximized);
766 SetWindowLong((HWND)GetHWND(),GWL_STYLE, m_fsOldWindowStyle);
767 SetWindowPos((HWND)GetHWND(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y,
768 m_fsOldSize.width, m_fsOldSize.height, SWP_FRAMECHANGED);
774 } // end of wxFrame::ShowFullScreen
779 bool wxFrame::OS2Create(
782 , const wxChar
* zWclass
784 , const wxChar
* zTitle
792 ULONG ulCreateFlags
= 0L;
793 ULONG ulStyleFlags
= 0L;
794 ULONG ulExtraFlags
= 0L;
795 FRAMECDATA vFrameCtlData
;
796 HWND hParent
= NULLHANDLE
;
797 HWND hClient
= NULLHANDLE
;
798 HWND hFrame
= NULLHANDLE
;
799 HWND hTitlebar
= NULLHANDLE
;
800 HWND hHScroll
= NULLHANDLE
;
801 HWND hVScroll
= NULLHANDLE
;
807 m_hDefaultIcon
= (WXHICON
) (wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
: wxDEFAULT_FRAME_ICON
);
810 hParent
= GetWinHwnd(pParent
);
812 hParent
= HWND_DESKTOP
;
814 if (ulStyle
== wxDEFAULT_FRAME_STYLE
)
815 ulCreateFlags
= FCF_SIZEBORDER
| FCF_TITLEBAR
| FCF_SYSMENU
|
816 FCF_MINMAX
| FCF_VERTSCROLL
| FCF_HORZSCROLL
| FCF_TASKLIST
;
819 if ((ulStyle
& wxCAPTION
) == wxCAPTION
)
820 ulCreateFlags
= FCF_TASKLIST
;
822 ulCreateFlags
= FCF_NOMOVEWITHOWNER
;
824 if (ulStyle
& wxMINIMIZE_BOX
)
825 ulCreateFlags
|= FCF_MINBUTTON
;
826 if (ulStyle
& wxMAXIMIZE_BOX
)
827 ulCreateFlags
|= FCF_MAXBUTTON
;
828 if (ulStyle
& wxTHICK_FRAME
)
829 ulCreateFlags
|= FCF_DLGBORDER
;
830 if (ulStyle
& wxSYSTEM_MENU
)
831 ulCreateFlags
|= FCF_SYSMENU
;
832 if (ulStyle
& wxCAPTION
)
833 ulCreateFlags
|= FCF_TASKLIST
;
834 if (ulStyle
& wxCLIP_CHILDREN
)
836 // Invalid for frame windows under PM
839 if (ulStyle
& wxTINY_CAPTION_VERT
)
840 ulCreateFlags
|= FCF_TASKLIST
;
841 if (ulStyle
& wxTINY_CAPTION_HORIZ
)
842 ulCreateFlags
|= FCF_TASKLIST
;
844 if ((ulStyle
& wxTHICK_FRAME
) == 0)
845 ulCreateFlags
|= FCF_BORDER
;
846 if (ulStyle
& wxFRAME_TOOL_WINDOW
)
847 ulExtraFlags
= kFrameToolWindow
;
849 if (ulStyle
& wxSTAY_ON_TOP
)
850 ulCreateFlags
|= FCF_SYSMODAL
;
852 if ((ulStyle
& wxMINIMIZE
) || (ulStyle
& wxICONIZE
))
853 ulStyleFlags
|= WS_MINIMIZED
;
854 if (ulStyle
& wxMAXIMIZE
)
855 ulStyleFlags
|= WS_MAXIMIZED
;
858 // Clear the visible flag, we always call show
860 ulStyleFlags
&= (unsigned long)~WS_VISIBLE
;
864 // Set the frame control block
866 vFrameCtlData
.cb
= sizeof(vFrameCtlData
);
867 vFrameCtlData
.flCreateFlags
= ulCreateFlags
;
868 vFrameCtlData
.hmodResources
= 0L;
869 vFrameCtlData
.idResources
= 0;
872 // Create the frame window
874 if (!wxWindow::OS2Create( hParent
885 ,(void*)&vFrameCtlData
895 // Since under PM the controling window proc is associated with the client window handle
896 // not the frame's we have to perform the hook here in order to associated the client handle,
897 // not the frame's with the window object !
902 // Create the client window. We must call the API from here rather than
903 // the static base class create because we need a separate handle
905 if ((hClient
= ::WinCreateWindow( hFrame
// Frame is parent
907 ,NULL
// Window title
909 ,0, 0, 0, 0 // Window position
912 ,FID_CLIENT
// standard client ID
913 ,NULL
// Creation data
914 ,NULL
// Window Pres Params
922 // Send anything to initialize the frame
926 ,(MPARAM
)FCF_TASKLIST
931 // Now size everything. If adding a menu the client will need to be resized.
933 if (!::WinSetWindowPos( hFrame
939 ,SWP_SIZE
| SWP_MOVE
| SWP_ACTIVATE
943 WinQueryWindowPos(GetHwnd(), &vSwp
);
944 hClient
= WinWindowFromID(GetHwnd(), FID_CLIENT
);
945 hTitlebar
= WinWindowFromID(GetHwnd(), FID_TITLEBAR
);
946 WinQueryWindowPos(hTitlebar
, &vSwpTitlebar
);
947 hHScroll
= WinWindowFromID(GetHwnd(), FID_HORZSCROLL
);
948 WinQueryWindowPos(hHScroll
, &vSwpHScroll
);
949 hVScroll
= WinWindowFromID(GetHwnd(), FID_VERTSCROLL
);
950 WinQueryWindowPos(hVScroll
, &vSwpVScroll
);
951 WinSetWindowPos( hClient
954 ,(SV_CYSIZEBORDER
/2) + vSwpHScroll
.cy
/2
955 ,vSwp
.cx
- ((SV_CXSIZEBORDER
+ 1) + vSwpVScroll
.cx
)
956 ,vSwp
.cy
- ((SV_CYSIZEBORDER
+ 1) + vSwpTitlebar
.cy
+ vSwpHScroll
.cy
/2)
961 // Set the client window's background, otherwise it is transparent!
964 } // end of wxFrame::OS2Create
967 // Default activation behaviour - set the focus for the first child
970 void wxFrame::OnActivate(
971 wxActivateEvent
& rEvent
974 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
976 pNode
= pNode
->GetNext())
978 // FIXME all this is totally bogus - we need to do the same as wxPanel,
979 // but how to do it without duplicating the code?
982 wxWindow
* pChild
= pNode
->GetData();
984 if (!pChild
->IsTopLevel()
986 && !wxDynamicCast(pChild
, wxToolBar
)
987 #endif // wxUSE_TOOLBAR
989 && !wxDynamicCast(pChild
, wxStatusBar
)
990 #endif // wxUSE_STATUSBAR
997 } // end of wxFrame::OnActivate
999 // ----------------------------------------------------------------------------
1000 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
1001 // from the client area, so the client area is what's really available for the
1003 // ----------------------------------------------------------------------------
1005 // Checks if there is a toolbar, and returns the first free client position
1006 wxPoint
wxFrame::GetClientAreaOrigin() const
1008 wxPoint
vPoint(0, 0);
1015 GetToolBar()->GetSize( &nWidth
1019 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
1025 // PM is backwards from windows
1026 vPoint
.y
+= nHeight
;
1030 } // end of wxFrame::GetClientAreaOrigin
1032 // ----------------------------------------------------------------------------
1033 // tool/status bar stuff
1034 // ----------------------------------------------------------------------------
1038 wxToolBar
* wxFrame::CreateToolBar(
1041 , const wxString
& rName
1044 if (wxFrameBase::CreateToolBar( lStyle
1051 return m_frameToolBar
;
1052 } // end of wxFrame::CreateToolBar
1054 void wxFrame::PositionToolBar()
1059 hWndClient
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
1060 ::WinQueryWindowRect(hWndClient
, &vRect
);
1068 GetStatusBar()->GetClientSize( &nStatusX
1071 // PM is backwards from windows
1072 vRect
.yBottom
+= nStatusY
;
1074 #endif // wxUSE_STATUSBAR
1081 GetToolBar()->GetSize( &nToolbarWidth
1085 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
1087 nToolbarHeight
= vRect
.yBottom
;
1091 nToolbarWidth
= vRect
.xRight
;
1095 // Use the 'real' PM position here
1097 GetToolBar()->SetSize( 0
1101 ,wxSIZE_NO_ADJUSTMENTS
1104 } // end of wxFrame::PositionToolBar
1105 #endif // wxUSE_TOOLBAR
1107 // ----------------------------------------------------------------------------
1108 // frame state (iconized/maximized/...)
1109 // ----------------------------------------------------------------------------
1112 // propagate our state change to all child frames: this allows us to emulate X
1113 // Windows behaviour where child frames float independently of the parent one
1114 // on the desktop, but are iconized/restored with it
1116 void wxFrame::IconizeChildFrames(
1120 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
1122 pNode
= pNode
->GetNext() )
1124 wxWindow
* pWin
= pNode
->GetData();
1126 if (pWin
->IsKindOf(CLASSINFO(wxFrame
)) )
1128 ((wxFrame
*)pWin
)->Iconize(bIconize
);
1131 } // end of wxFrame::IconizeChildFrames
1133 // ===========================================================================
1134 // message processing
1135 // ===========================================================================
1137 // ---------------------------------------------------------------------------
1139 // ---------------------------------------------------------------------------
1140 bool wxFrame::OS2TranslateMessage(
1144 if (wxWindow::OS2TranslateMessage(pMsg
))
1147 // try the menu bar accels
1149 wxMenuBar
* pMenuBar
= GetMenuBar();
1154 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
1155 return rAcceleratorTable
.Translate(this, pMsg
);
1156 } // end of wxFrame::OS2TranslateMessage
1158 // ---------------------------------------------------------------------------
1159 // our private (non virtual) message handlers
1160 // ---------------------------------------------------------------------------
1161 bool wxFrame::HandlePaint()
1165 if (::WinQueryUpdateRect(GetHwnd(), &vRect
))
1170 // Icons in PM are the same as "pointers"
1175 hIcon
= (HPOINTER
)::WinSendMsg(GetHwnd(), WM_QUERYICON
, 0L, 0L);
1177 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1180 // Hold a pointer to the dc so long as the OnPaint() message
1181 // is being processed
1184 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
1187 // Erase background before painting or we get white background
1189 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
1196 hWndClient
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
1197 ::WinQueryWindowRect(hWndClient
, &vRect3
);
1199 static const int nIconWidth
= 32;
1200 static const int nIconHeight
= 32;
1201 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
1202 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
1204 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
1211 return wxWindow::HandlePaint();
1216 // nothing to paint - processed
1220 } // end of wxFrame::HandlePaint
1222 bool wxFrame::HandleSize(
1228 bool bProcessed
= FALSE
;
1234 // Only do it it if we were iconized before, otherwise resizing the
1235 // parent frame has a curious side effect of bringing it under it's
1241 // restore all child frames too
1243 IconizeChildFrames(FALSE
);
1250 m_bIconized
= FALSE
;
1255 // Iconize all child frames too
1257 IconizeChildFrames(TRUE
);
1265 // forward WM_SIZE to status bar control
1267 #if wxUSE_NATIVE_STATUSBAR
1268 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
1270 wxSizeEvent
vEvent( wxSize( nX
1273 ,m_frameStatusBar
->GetId()
1276 vEvent
.SetEventObject(m_frameStatusBar
);
1277 m_frameStatusBar
->OnSize(vEvent
);
1279 #endif // wxUSE_NATIVE_STATUSBAR
1281 PositionStatusBar();
1283 wxSizeEvent
vEvent( wxSize( nX
1289 vEvent
.SetEventObject(this);
1290 bProcessed
= GetEventHandler()->ProcessEvent(vEvent
);
1293 } // end of wxFrame::HandleSize
1295 bool wxFrame::HandleCommand(
1304 // In case it's e.g. a toolbar.
1306 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
1309 return pWin
->OS2Command( nCmd
1315 // Handle here commands from menus and accelerators
1317 if (nCmd
== 0 || nCmd
== 1)
1319 if (wxCurrentPopupMenu
)
1321 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1323 wxCurrentPopupMenu
= NULL
;
1325 return pPopupMenu
->OS2Command( nCmd
1330 if (ProcessCommand(nId
))
1336 } // end of wxFrame::HandleCommand
1338 bool wxFrame::HandleMenuSelect(
1346 if (nFlags
== 0xFFFF && hMenu
== 0)
1349 // Menu was removed from screen
1353 else if (!(nFlags
& MIS_SUBMENU
) && !(nFlags
& MIS_SEPARATOR
))
1360 // Don't give hints for separators (doesn't make sense) nor for the
1361 // items opening popup menus (they don't have them anyhow)
1365 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nMenuItem
);
1367 vEvent
.SetEventObject(this);
1368 return GetEventHandler()->ProcessEvent(vEvent
);
1369 } // end of wxFrame::HandleMenuSelect
1371 // ---------------------------------------------------------------------------
1372 // the window proc for wxFrame
1373 // ---------------------------------------------------------------------------
1375 MRESULT
wxFrame::OS2WindowProc(
1382 bool bProcessed
= FALSE
;
1388 // If we can't close, tell the system that we processed the
1389 // message - otherwise it would close us
1391 bProcessed
= !Close();
1400 UnpackCommand( (WXWPARAM
)wParam
1406 bProcessed
= HandleCommand( wId
1419 UnpackMenuSelect( wParam
1425 bProcessed
= HandleMenuSelect( wItem
1433 bProcessed
= HandlePaint();
1436 case CM_QUERYDRAGIMAGE
:
1441 hIcon
= (HPOINTER
)::WinSendMsg(GetHwnd(), WM_QUERYICON
, 0L, 0L);
1443 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1444 mRc
= (MRESULT
)hIcon
;
1445 bProcessed
= mRc
!= 0;
1450 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1455 mRc
= wxWindow::OS2WindowProc( uMessage
1460 } // wxFrame::OS2WindowProc