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
;
97 memset(&m_vSwp
, 0, sizeof(SWP
));
98 memset(&m_vSwpClient
, 0, sizeof(SWP
));
99 memset(&m_vSwpTitleBar
, 0, sizeof(SWP
));
100 memset(&m_vSwpMenuBar
, 0, sizeof(SWP
));
101 memset(&m_vSwpHScroll
, 0, sizeof(SWP
));
102 memset(&m_vSwpVScroll
, 0, sizeof(SWP
));
103 memset(&m_vSwpStatusBar
, 0, sizeof(SWP
));
104 memset(&m_vSwpToolBar
, 0, sizeof(SWP
));
105 } // end of wxFrame::Init
107 bool wxFrame::Create(
110 , const wxString
& rsTitle
111 , const wxPoint
& rPos
112 , const wxSize
& rSize
114 , const wxString
& rsName
119 int nWidth
= rSize
.x
;
120 int nHeight
= rSize
.y
;
123 m_windowStyle
= lulStyle
;
124 m_frameMenuBar
= NULL
;
125 m_frameToolBar
= NULL
;
126 m_frameStatusBar
= NULL
;
128 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
133 m_windowId
= (int)NewControlId();
136 pParent
->AddChild(this);
140 if ((m_windowStyle
& wxFRAME_FLOAT_ON_PARENT
) == 0)
144 wxTopLevelWindows
.Append(this);
146 OS2Create( m_windowId
158 wxModelessWindows
.Append(this);
160 } // end of wxFrame::Create
164 m_isBeingDeleted
= TRUE
;
165 wxTopLevelWindows
.DeleteObject(this);
169 if (wxTheApp
&& (wxTopLevelWindows
.Number() == 0))
171 wxTheApp
->SetTopWindow(NULL
);
173 if (wxTheApp
->GetExitOnFrameDelete())
175 ::WinPostMsg(m_hFrame
, WM_QUIT
, 0, 0);
178 wxModelessWindows
.DeleteObject(this);
181 // For some reason, wxWindows can activate another task altogether
182 // when a frame is destroyed after a modal dialog has been invoked.
183 // Try to bring the parent to the top.
185 // MT:Only do this if this frame is currently the active window, else weird
186 // things start to happen.
188 if (wxGetActiveWindow() == this)
190 if (GetParent() && GetParent()->GetHWND())
192 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
202 } // end of wxFrame::~wxFrame
205 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
207 void wxFrame::DoGetClientSize(
213 // OS/2 PM's coordinates go from bottom-left not
214 // top-left thus the += instead of the -=
219 // PM has no GetClientRect that inherantly knows about the client window
220 // We have to explicitly go fetch it!
222 ::WinQueryWindowRect(GetHwnd(), &vRect
);
225 if ( GetStatusBar() )
230 GetStatusBar()->GetClientSize( &nStatusX
233 vRect
.yBottom
+= nStatusY
;
235 #endif // wxUSE_STATUSBAR
237 wxPoint
vPoint(GetClientAreaOrigin());
239 vRect
.yBottom
+= vPoint
.y
;
240 vRect
.xRight
-= vPoint
.x
;
246 } // end of wxFrame::DoGetClientSize
249 // Set the client size (i.e. leave the calculation of borders etc.
252 void wxFrame::DoSetClientSize(
257 HWND hWnd
= GetHwnd();
261 ::WinQueryWindowRect(GetHwnd(), &vRect
);
263 ::WinQueryWindowRect(m_hFrame
, &vRect2
);
266 // Find the difference between the entire window (title bar and all)
267 // and the client area; add this to the new client size to move the
268 // window. Remember OS/2's backwards y coord system!
270 int nActualWidth
= vRect2
.xRight
- vRect2
.xLeft
- vRect
.xRight
+ nWidth
;
271 int nActualHeight
= vRect2
.yTop
+ vRect2
.yTop
- vRect
.yTop
+ nHeight
;
274 if ( GetStatusBar() )
279 GetStatusBar()->GetClientSize( &nStatusX
282 nActualHeight
+= nStatusY
;
284 #endif // wxUSE_STATUSBAR
286 wxPoint
vPoint(GetClientAreaOrigin());
287 nActualWidth
+= vPoint
.y
;
288 nActualHeight
+= vPoint
.x
;
292 vPointl
.x
= vRect2
.xLeft
;
293 vPoint
.y
= vRect2
.yTop
;
295 ::WinSetWindowPos( m_hFrame
301 ,SWP_MOVE
| SWP_SIZE
| SWP_SHOW
304 wxSizeEvent
vEvent( wxSize( nWidth
309 vEvent
.SetEventObject(this);
310 GetEventHandler()->ProcessEvent(vEvent
);
311 } // end of wxFrame::DoSetClientSize
313 void wxFrame::DoGetSize(
320 ::WinQueryWindowRect(m_hFrame
, &vRect
);
321 *pWidth
= vRect
.xRight
- vRect
.xLeft
;
322 *pHeight
= vRect
.yTop
- vRect
.yBottom
;
323 } // end of wxFrame::DoGetSize
325 void wxFrame::DoGetPosition(
333 ::WinQueryWindowRect(m_hFrame
, &vRect
);
334 vPoint
.x
= vRect
.xLeft
;
337 // OS/2 is backwards [WIN32 it is vRect.yTop]
339 vPoint
.y
= vRect
.yBottom
;
343 } // end of wxFrame::DoGetPosition
345 // ----------------------------------------------------------------------------
346 // variations around ::ShowWindow()
347 // ----------------------------------------------------------------------------
349 void wxFrame::DoShowWindow(
353 HWND hClient
= NULLHANDLE
;
357 // Reset the window position
359 WinQueryWindowPos(m_hFrame
, &vSwp
);
360 WinSetWindowPos( GetHwnd()
366 ,SWP_SIZE
| SWP_MOVE
| SWP_ACTIVATE
368 ::WinShowWindow(m_hFrame
, (BOOL
)bShowCmd
);
369 ::WinShowWindow(GetHwnd(), (BOOL
)bShowCmd
);
370 } // end of wxFrame::DoShowWindow
378 DoShowWindow((int)bShow
);
382 wxActivateEvent
vEvent(wxEVT_ACTIVATE
, TRUE
, m_windowId
);
384 ::WinQueryWindowPos(m_hFrame
, &vSwp
);
385 m_bIconized
= vSwp
.fl
& SWP_MINIMIZE
;
386 ::WinEnableWindow(m_hFrame
, TRUE
);
387 vEvent
.SetEventObject(this);
388 GetEventHandler()->ProcessEvent(vEvent
);
393 // Try to highlight the correct window (the parent)
397 HWND hWndParent
= GetHwndOf(GetParent());
399 ::WinQueryWindowPos(hWndParent
, &vSwp
);
400 m_bIconized
= vSwp
.fl
& SWP_MINIMIZE
;
402 ::WinSetWindowPos( hWndParent
408 ,SWP_ZORDER
| SWP_ACTIVATE
| SWP_SHOW
| SWP_MOVE
410 ::WinEnableWindow(hWndParent
, TRUE
);
414 } // end of wxFrame::Show
416 void wxFrame::Iconize(
420 DoShowWindow(bIconize
? SWP_MINIMIZE
: SWP_RESTORE
);
421 } // end of wxFrame::Iconize
423 void wxFrame::Maximize(
426 DoShowWindow(bMaximize
? SWP_MAXIMIZE
: SWP_RESTORE
);
427 } // end of wxFrame::Maximize
429 void wxFrame::Restore()
431 DoShowWindow(SWP_RESTORE
);
432 } // end of wxFrame::Restore
434 bool wxFrame::IsIconized() const
439 ::WinQueryWindowPos(GetHwnd(), &vSwp
);
441 if (vSwp
.fl
& SWP_MINIMIZE
)
442 ((wxFrame
*)this)->m_bIconized
= TRUE
;
444 ((wxFrame
*)this)->m_bIconized
= FALSE
;
446 } // end of wxFrame::IsIconized
449 bool wxFrame::IsMaximized() const
454 ::WinQueryWindowPos(m_hFrame
, &vSwp
);
455 return (vSwp
.fl
& SWP_MAXIMIZE
);
456 } // end of wxFrame::IsMaximized
458 void wxFrame::SetIcon(
462 wxFrameBase::SetIcon(rIcon
);
464 if ((m_icon
.GetHICON()) != NULLHANDLE
)
466 ::WinSendMsg( m_hFrame
468 ,(MPARAM
)((HPOINTER
)m_icon
.GetHICON())
471 ::WinSendMsg( m_hFrame
477 } // end of wxFrame::SetIcon
480 wxStatusBar
* wxFrame::OnCreateStatusBar(
484 , const wxString
& rName
487 wxStatusBar
* pStatusBar
= NULL
;
489 pStatusBar
= wxFrameBase::OnCreateStatusBar( nNumber
495 } // end of wxFrame::OnCreateStatusBar
497 void wxFrame::PositionStatusBar()
500 // Native status bar positions itself
502 if (m_frameStatusBar
)
511 ::WinQueryWindowRect(GetHwnd(), &vRect
);
512 nWidth
= vRect
.xRight
- vRect
.xLeft
;
513 nHeight
= vRect
.yTop
- vRect
.yBottom
;
515 m_frameStatusBar
->GetSize( &nStatbarWidth
520 // Since we wish the status bar to be directly under the client area,
521 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
523 m_frameStatusBar
->SetSize( 0
529 } // end of wxFrame::PositionStatusBar
530 #endif // wxUSE_STATUSBAR
532 void wxFrame::DetachMenuBar()
536 m_frameMenuBar
->Detach();
537 m_frameMenuBar
= NULL
;
539 } // end of wxFrame::DetachMenuBar
541 void wxFrame::SetMenuBar(
547 HWND hClient
= NULLHANDLE
;
548 HWND hFrame
= NULLHANDLE
;
549 HWND hTitlebar
= NULLHANDLE
;
550 HWND hHScroll
= NULLHANDLE
;
551 HWND hVScroll
= NULLHANDLE
;
552 HWND hMenuBar
= NULLHANDLE
;
565 m_frameMenuBar
= NULL
;
567 // Can set a menubar several times.
568 // TODO: how to prevent a memory leak if you have a currently-unattached
569 // menubar? wxWindows assumes that the frame will delete the menu (otherwise
570 // there are problems for MDI).
571 if (pMenuBar
->GetHMenu())
573 m_hMenu
= pMenuBar
->GetHMenu();
579 m_hMenu
= pMenuBar
->Create();
586 // Set the parent and owner of the menubar to be the frame
588 if (!::WinSetParent(m_hMenu
, m_hFrame
, FALSE
))
590 vError
= ::WinGetLastError(vHabmain
);
591 sError
= wxPMErrorToStr(vError
);
592 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
595 if (!::WinSetOwner(m_hMenu
, m_hFrame
))
597 vError
= ::WinGetLastError(vHabmain
);
598 sError
= wxPMErrorToStr(vError
);
599 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
601 InternalSetMenuBar();
603 m_frameMenuBar
= pMenuBar
;
604 pMenuBar
->Attach(this);
607 // Now resize the client to fit the new frame
609 WinQueryWindowPos(m_hFrame
, &vSwp
);
610 hTitlebar
= WinWindowFromID(m_hFrame
, FID_TITLEBAR
);
611 WinQueryWindowPos(hTitlebar
, &vSwpTitlebar
);
612 hHScroll
= WinWindowFromID(m_hFrame
, FID_HORZSCROLL
);
613 WinQueryWindowPos(hHScroll
, &vSwpHScroll
);
614 hVScroll
= WinWindowFromID(m_hFrame
, FID_VERTSCROLL
);
615 WinQueryWindowPos(hVScroll
, &vSwpVScroll
);
616 hMenuBar
= WinWindowFromID(m_hFrame
, FID_MENU
);
617 WinQueryWindowPos(hMenuBar
, &vSwpMenu
);
618 WinSetWindowPos( GetHwnd()
621 ,(SV_CYSIZEBORDER
/2) + vSwpHScroll
.cy
/2
622 ,vSwp
.cx
- ((SV_CXSIZEBORDER
+ 1) + vSwpVScroll
.cx
)
623 ,vSwp
.cy
- ((SV_CYSIZEBORDER
+ 1) + vSwpTitlebar
.cy
+ vSwpMenu
.cy
+ vSwpHScroll
.cy
/2)
626 } // end of wxFrame::SetMenuBar
628 void wxFrame::InternalSetMenuBar()
630 WinSendMsg((HWND
)m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
631 } // end of wxFrame::InternalSetMenuBar
634 // Responds to colour changes, and passes event on to children
636 void wxFrame::OnSysColourChanged(
637 wxSysColourChangedEvent
& rEvent
640 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
643 if (m_frameStatusBar
)
645 wxSysColourChangedEvent vEvent2
;
647 vEvent2
.SetEventObject(m_frameStatusBar
);
648 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
652 // Propagate the event to the non-top-level children
654 wxWindow::OnSysColourChanged(rEvent
);
655 } // end of wxFrame::OnSysColourChanged
657 // Pass TRUE to show full screen, FALSE to restore.
658 bool wxFrame::ShowFullScreen(
670 m_fsIsShowing = TRUE;
673 wxToolBar *theToolBar = GetToolBar();
674 wxStatusBar *theStatusBar = GetStatusBar();
679 theToolBar->GetSize(&dummyWidth, &m_fsToolBarHeight);
681 theStatusBar->GetSize(&dummyWidth, &m_fsStatusBarHeight);
683 // zap the toolbar, menubar, and statusbar
685 if ((style & wxFULLSCREEN_NOTOOLBAR) && theToolBar)
687 theToolBar->SetSize(-1,0);
688 theToolBar->Show(FALSE);
691 if (style & wxFULLSCREEN_NOMENUBAR)
692 SetMenu((HWND)GetHWND(), (HMENU) NULL);
694 // Save the number of fields in the statusbar
695 if ((style & wxFULLSCREEN_NOSTATUSBAR) && theStatusBar)
697 m_fsStatusBarFields = theStatusBar->GetFieldsCount();
698 SetStatusBar((wxStatusBar*) NULL);
702 m_fsStatusBarFields = 0;
704 // zap the frame borders
706 // save the 'normal' window style
707 m_fsOldWindowStyle = GetWindowLong((HWND)GetHWND(), GWL_STYLE);
709 // save the old position, width & height, maximize state
710 m_fsOldSize = GetRect();
711 m_fsIsMaximized = IsMaximized();
713 // decide which window style flags to turn off
714 LONG newStyle = m_fsOldWindowStyle;
717 if (style & wxFULLSCREEN_NOBORDER)
718 offFlags |= WS_BORDER;
719 if (style & wxFULLSCREEN_NOCAPTION)
720 offFlags |= (WS_CAPTION | WS_SYSMENU);
722 newStyle &= (~offFlags);
724 // change our window style to be compatible with full-screen mode
725 SetWindowLong((HWND)GetHWND(), GWL_STYLE, newStyle);
727 // resize to the size of the desktop
731 ::GetWindowRect(GetDesktopWindow(), &rect);
732 width = rect.right - rect.left;
733 height = rect.bottom - rect.top;
735 SetSize(width, height);
737 // now flush the window style cache and actually go full-screen
738 SetWindowPos((HWND)GetHWND(), HWND_TOP, 0, 0, width, height, SWP_FRAMECHANGED);
740 wxSizeEvent event(wxSize(width, height), GetId());
741 GetEventHandler()->ProcessEvent(event);
750 m_fsIsShowing = FALSE;
752 wxToolBar *theToolBar = GetToolBar();
754 // restore the toolbar, menubar, and statusbar
755 if (theToolBar && (m_fsStyle & wxFULLSCREEN_NOTOOLBAR))
757 theToolBar->SetSize(-1, m_fsToolBarHeight);
758 theToolBar->Show(TRUE);
761 if ((m_fsStyle & wxFULLSCREEN_NOSTATUSBAR) && (m_fsStatusBarFields > 0))
763 CreateStatusBar(m_fsStatusBarFields);
767 if ((m_fsStyle & wxFULLSCREEN_NOMENUBAR) && (m_hMenu != 0))
768 SetMenu((HWND)GetHWND(), (HMENU)m_hMenu);
770 Maximize(m_fsIsMaximized);
771 SetWindowLong((HWND)GetHWND(),GWL_STYLE, m_fsOldWindowStyle);
772 SetWindowPos((HWND)GetHWND(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y,
773 m_fsOldSize.width, m_fsOldSize.height, SWP_FRAMECHANGED);
779 } // end of wxFrame::ShowFullScreen
784 bool wxFrame::OS2Create(
787 , const wxChar
* zWclass
789 , const wxChar
* zTitle
797 ULONG ulCreateFlags
= 0L;
798 ULONG ulStyleFlags
= 0L;
799 ULONG ulExtraFlags
= 0L;
800 FRAMECDATA vFrameCtlData
;
801 HWND hParent
= NULLHANDLE
;
802 HWND hClient
= NULLHANDLE
;
803 HWND hFrame
= NULLHANDLE
;
804 HWND hTitlebar
= NULLHANDLE
;
805 HWND hHScroll
= NULLHANDLE
;
806 HWND hVScroll
= NULLHANDLE
;
811 m_hDefaultIcon
= (WXHICON
) (wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
: wxDEFAULT_FRAME_ICON
);
814 hParent
= GetWinHwnd(pParent
);
816 hParent
= HWND_DESKTOP
;
818 if (ulStyle
== wxDEFAULT_FRAME_STYLE
)
819 ulCreateFlags
= FCF_SIZEBORDER
| FCF_TITLEBAR
| FCF_SYSMENU
|
820 FCF_MINMAX
| FCF_VERTSCROLL
| FCF_HORZSCROLL
| FCF_TASKLIST
;
823 if ((ulStyle
& wxCAPTION
) == wxCAPTION
)
824 ulCreateFlags
= FCF_TASKLIST
;
826 ulCreateFlags
= FCF_NOMOVEWITHOWNER
;
828 if (ulStyle
& wxMINIMIZE_BOX
)
829 ulCreateFlags
|= FCF_MINBUTTON
;
830 if (ulStyle
& wxMAXIMIZE_BOX
)
831 ulCreateFlags
|= FCF_MAXBUTTON
;
832 if (ulStyle
& wxTHICK_FRAME
)
833 ulCreateFlags
|= FCF_DLGBORDER
;
834 if (ulStyle
& wxSYSTEM_MENU
)
835 ulCreateFlags
|= FCF_SYSMENU
;
836 if (ulStyle
& wxCAPTION
)
837 ulCreateFlags
|= FCF_TASKLIST
;
838 if (ulStyle
& wxCLIP_CHILDREN
)
840 // Invalid for frame windows under PM
843 if (ulStyle
& wxTINY_CAPTION_VERT
)
844 ulCreateFlags
|= FCF_TASKLIST
;
845 if (ulStyle
& wxTINY_CAPTION_HORIZ
)
846 ulCreateFlags
|= FCF_TASKLIST
;
848 if ((ulStyle
& wxTHICK_FRAME
) == 0)
849 ulCreateFlags
|= FCF_BORDER
;
850 if (ulStyle
& wxFRAME_TOOL_WINDOW
)
851 ulExtraFlags
= kFrameToolWindow
;
853 if (ulStyle
& wxSTAY_ON_TOP
)
854 ulCreateFlags
|= FCF_SYSMODAL
;
856 if ((ulStyle
& wxMINIMIZE
) || (ulStyle
& wxICONIZE
))
857 ulStyleFlags
|= WS_MINIMIZED
;
858 if (ulStyle
& wxMAXIMIZE
)
859 ulStyleFlags
|= WS_MAXIMIZED
;
862 // Clear the visible flag, we always call show
864 ulStyleFlags
&= (unsigned long)~WS_VISIBLE
;
868 // Set the frame control block
870 vFrameCtlData
.cb
= sizeof(vFrameCtlData
);
871 vFrameCtlData
.flCreateFlags
= ulCreateFlags
;
872 vFrameCtlData
.hmodResources
= 0L;
873 vFrameCtlData
.idResources
= 0;
876 // Create the frame window
878 if ((m_hFrame
= ::WinCreateWindow( hParent
// Frame is parent
879 ,WC_FRAME
// standard frame class
880 ,(PSZ
)zTitle
// Window title
882 ,0, 0, 0, 0 // Window position
886 ,(PVOID
)&vFrameCtlData
// Creation data
887 ,NULL
// Window Pres Params
893 if (!wxWindow::OS2Create( m_hFrame
903 ,(unsigned long)FID_CLIENT
912 // Now size everything. If adding a menu the client will need to be resized.
914 if (!::WinSetWindowPos( m_hFrame
920 ,SWP_SIZE
| SWP_MOVE
| SWP_ACTIVATE
924 uCtlCount
= SHORT1FROMMP(::WinSendMsg(m_hFrame
, WM_FORMATFRAME
, (MPARAM
)vSwp
, (MPARAM
)vRect
));
925 for (int i
= 0; i
< uCtlCount
; i
++)
927 if (vSwp
[i
].hwnd
== m_hFrame
)
928 memcpy(&m_vSwp
, &vSwp
[i
], sizeof(SWP
));
929 else if (vSwp
[i
].hwnd
== m_hVScroll
)
930 memcpy(&m_vSwpVScroll
, &vSwp
[i
], sizeof(SWP
));
931 else if (vSwp
[i
].hwnd
== m_hHScroll
)
932 memcpy(&m_vSwpVScroll
, &vSwp
[i
], sizeof(SWP
));
933 else if (vSwp
[i
].hwnd
== m_hTitleBar
)
934 memcpy(&m_vSwpTitleBar
, &vSwp
[i
], sizeof(SWP
));
938 // Now set the size of the client
940 WinSetWindowPos( hClient
943 ,(SV_CYSIZEBORDER
/2) + m_vSwpHScroll
.cy
/2
944 ,m_vSwp
.cx
- ((SV_CXSIZEBORDER
+ 1) + m_vSwpVScroll
.cx
)
945 ,m_vSwp
.cy
- ((SV_CYSIZEBORDER
+ 1) + m_vSwpTitleBar
.cy
+ m_vSwpHScroll
.cy
/2)
950 // Set the client window's background, otherwise it is transparent!
953 } // end of wxFrame::OS2Create
956 // Default activation behaviour - set the focus for the first child
959 void wxFrame::OnActivate(
960 wxActivateEvent
& rEvent
963 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
965 pNode
= pNode
->GetNext())
967 // FIXME all this is totally bogus - we need to do the same as wxPanel,
968 // but how to do it without duplicating the code?
971 wxWindow
* pChild
= pNode
->GetData();
973 if (!pChild
->IsTopLevel()
975 && !wxDynamicCast(pChild
, wxToolBar
)
976 #endif // wxUSE_TOOLBAR
978 && !wxDynamicCast(pChild
, wxStatusBar
)
979 #endif // wxUSE_STATUSBAR
986 } // end of wxFrame::OnActivate
988 // ----------------------------------------------------------------------------
989 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
990 // from the client area, so the client area is what's really available for the
992 // ----------------------------------------------------------------------------
994 // Checks if there is a toolbar, and returns the first free client position
995 wxPoint
wxFrame::GetClientAreaOrigin() const
997 wxPoint
vPoint(0, 0);
1004 GetToolBar()->GetSize( &nWidth
1008 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
1014 // PM is backwards from windows
1015 vPoint
.y
+= nHeight
;
1019 } // end of wxFrame::GetClientAreaOrigin
1021 // ----------------------------------------------------------------------------
1022 // tool/status bar stuff
1023 // ----------------------------------------------------------------------------
1027 wxToolBar
* wxFrame::CreateToolBar(
1030 , const wxString
& rName
1033 if (wxFrameBase::CreateToolBar( lStyle
1040 return m_frameToolBar
;
1041 } // end of wxFrame::CreateToolBar
1043 void wxFrame::PositionToolBar()
1048 ::WinQueryWindowRect(GetHwnd(), &vRect
);
1056 GetStatusBar()->GetClientSize( &nStatusX
1059 // PM is backwards from windows
1060 vRect
.yBottom
+= nStatusY
;
1062 #endif // wxUSE_STATUSBAR
1069 GetToolBar()->GetSize( &nToolbarWidth
1073 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
1075 nToolbarHeight
= vRect
.yBottom
;
1079 nToolbarWidth
= vRect
.xRight
;
1083 // Use the 'real' PM position here
1085 GetToolBar()->SetSize( 0
1089 ,wxSIZE_NO_ADJUSTMENTS
1092 } // end of wxFrame::PositionToolBar
1093 #endif // wxUSE_TOOLBAR
1095 // ----------------------------------------------------------------------------
1096 // frame state (iconized/maximized/...)
1097 // ----------------------------------------------------------------------------
1100 // propagate our state change to all child frames: this allows us to emulate X
1101 // Windows behaviour where child frames float independently of the parent one
1102 // on the desktop, but are iconized/restored with it
1104 void wxFrame::IconizeChildFrames(
1108 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
1110 pNode
= pNode
->GetNext() )
1112 wxWindow
* pWin
= pNode
->GetData();
1114 if (pWin
->IsKindOf(CLASSINFO(wxFrame
)) )
1116 ((wxFrame
*)pWin
)->Iconize(bIconize
);
1119 } // end of wxFrame::IconizeChildFrames
1121 // ===========================================================================
1122 // message processing
1123 // ===========================================================================
1125 // ---------------------------------------------------------------------------
1127 // ---------------------------------------------------------------------------
1128 bool wxFrame::OS2TranslateMessage(
1132 if (wxWindow::OS2TranslateMessage(pMsg
))
1135 // try the menu bar accels
1137 wxMenuBar
* pMenuBar
= GetMenuBar();
1142 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
1143 return rAcceleratorTable
.Translate(this, pMsg
);
1144 } // end of wxFrame::OS2TranslateMessage
1146 // ---------------------------------------------------------------------------
1147 // our private (non virtual) message handlers
1148 // ---------------------------------------------------------------------------
1149 bool wxFrame::HandlePaint()
1153 if (::WinQueryUpdateRect(m_hFrame
, &vRect
))
1158 // Icons in PM are the same as "pointers"
1163 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
1165 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1168 // Hold a pointer to the dc so long as the OnPaint() message
1169 // is being processed
1172 HPS hPs
= ::WinBeginPaint(m_hFrame
, NULLHANDLE
, &vRect2
);
1175 // Erase background before painting or we get white background
1177 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
1184 ::WinQueryWindowRect(GetHwnd(), &vRect3
);
1186 static const int nIconWidth
= 32;
1187 static const int nIconHeight
= 32;
1188 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
1189 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
1191 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
1198 return wxWindow::HandlePaint();
1203 // nothing to paint - processed
1207 } // end of wxFrame::HandlePaint
1209 bool wxFrame::HandleSize(
1215 bool bProcessed
= FALSE
;
1221 // Only do it it if we were iconized before, otherwise resizing the
1222 // parent frame has a curious side effect of bringing it under it's
1228 // restore all child frames too
1230 IconizeChildFrames(FALSE
);
1237 m_bIconized
= FALSE
;
1242 // Iconize all child frames too
1244 IconizeChildFrames(TRUE
);
1252 // forward WM_SIZE to status bar control
1254 #if wxUSE_NATIVE_STATUSBAR
1255 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
1257 wxSizeEvent
vEvent( wxSize( nX
1260 ,m_frameStatusBar
->GetId()
1263 vEvent
.SetEventObject(m_frameStatusBar
);
1264 m_frameStatusBar
->OnSize(vEvent
);
1266 #endif // wxUSE_NATIVE_STATUSBAR
1268 PositionStatusBar();
1270 wxSizeEvent
vEvent( wxSize( nX
1276 vEvent
.SetEventObject(this);
1277 bProcessed
= GetEventHandler()->ProcessEvent(vEvent
);
1280 } // end of wxFrame::HandleSize
1282 bool wxFrame::HandleCommand(
1291 // In case it's e.g. a toolbar.
1293 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
1296 return pWin
->OS2Command( nCmd
1302 // Handle here commands from menus and accelerators
1304 if (nCmd
== 0 || nCmd
== 1)
1306 if (wxCurrentPopupMenu
)
1308 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1310 wxCurrentPopupMenu
= NULL
;
1312 return pPopupMenu
->OS2Command( nCmd
1317 if (ProcessCommand(nId
))
1323 } // end of wxFrame::HandleCommand
1325 bool wxFrame::HandleMenuSelect(
1333 if (nFlags
== 0xFFFF && hMenu
== 0)
1336 // Menu was removed from screen
1340 else if (!(nFlags
& MIS_SUBMENU
) && !(nFlags
& MIS_SEPARATOR
))
1347 // Don't give hints for separators (doesn't make sense) nor for the
1348 // items opening popup menus (they don't have them anyhow)
1352 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nMenuItem
);
1354 vEvent
.SetEventObject(this);
1355 return GetEventHandler()->ProcessEvent(vEvent
);
1356 } // end of wxFrame::HandleMenuSelect
1358 // ---------------------------------------------------------------------------
1359 // the window proc for wxFrame
1360 // ---------------------------------------------------------------------------
1362 MRESULT
wxFrame::OS2WindowProc(
1369 bool bProcessed
= FALSE
;
1375 // If we can't close, tell the system that we processed the
1376 // message - otherwise it would close us
1378 bProcessed
= !Close();
1387 UnpackCommand( (WXWPARAM
)wParam
1393 bProcessed
= HandleCommand( wId
1406 UnpackMenuSelect( wParam
1412 bProcessed
= HandleMenuSelect( wItem
1420 bProcessed
= HandlePaint();
1423 case WM_ERASEBACKGROUND
:
1425 // Return TRUE to request PM to paint the window background
1426 // in SYSCLR_WINDOW.
1429 mRc
= (MRESULT
)(TRUE
);
1432 case CM_QUERYDRAGIMAGE
:
1437 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
1439 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1440 mRc
= (MRESULT
)hIcon
;
1441 bProcessed
= mRc
!= 0;
1446 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1451 mRc
= wxWindow::OS2WindowProc( uMessage
1456 } // wxFrame::OS2WindowProc