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
;
814 m_hDefaultIcon
= (WXHICON
) (wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
: wxDEFAULT_FRAME_ICON
);
817 hParent
= GetWinHwnd(pParent
);
819 hParent
= HWND_DESKTOP
;
821 if (ulStyle
== wxDEFAULT_FRAME_STYLE
)
822 ulCreateFlags
= FCF_SIZEBORDER
| FCF_TITLEBAR
| FCF_SYSMENU
|
823 FCF_MINMAX
| FCF_VERTSCROLL
| FCF_HORZSCROLL
| FCF_TASKLIST
;
826 if ((ulStyle
& wxCAPTION
) == wxCAPTION
)
827 ulCreateFlags
= FCF_TASKLIST
;
829 ulCreateFlags
= FCF_NOMOVEWITHOWNER
;
831 if (ulStyle
& wxMINIMIZE_BOX
)
832 ulCreateFlags
|= FCF_MINBUTTON
;
833 if (ulStyle
& wxMAXIMIZE_BOX
)
834 ulCreateFlags
|= FCF_MAXBUTTON
;
835 if (ulStyle
& wxTHICK_FRAME
)
836 ulCreateFlags
|= FCF_DLGBORDER
;
837 if (ulStyle
& wxSYSTEM_MENU
)
838 ulCreateFlags
|= FCF_SYSMENU
;
839 if (ulStyle
& wxCAPTION
)
840 ulCreateFlags
|= FCF_TASKLIST
;
841 if (ulStyle
& wxCLIP_CHILDREN
)
843 // Invalid for frame windows under PM
846 if (ulStyle
& wxTINY_CAPTION_VERT
)
847 ulCreateFlags
|= FCF_TASKLIST
;
848 if (ulStyle
& wxTINY_CAPTION_HORIZ
)
849 ulCreateFlags
|= FCF_TASKLIST
;
851 if ((ulStyle
& wxTHICK_FRAME
) == 0)
852 ulCreateFlags
|= FCF_BORDER
;
853 if (ulStyle
& wxFRAME_TOOL_WINDOW
)
854 ulExtraFlags
= kFrameToolWindow
;
856 if (ulStyle
& wxSTAY_ON_TOP
)
857 ulCreateFlags
|= FCF_SYSMODAL
;
859 if ((ulStyle
& wxMINIMIZE
) || (ulStyle
& wxICONIZE
))
860 ulStyleFlags
|= WS_MINIMIZED
;
861 if (ulStyle
& wxMAXIMIZE
)
862 ulStyleFlags
|= WS_MAXIMIZED
;
865 // Clear the visible flag, we always call show
867 ulStyleFlags
&= (unsigned long)~WS_VISIBLE
;
871 // Set the frame control block
873 vFrameCtlData
.cb
= sizeof(vFrameCtlData
);
874 vFrameCtlData
.flCreateFlags
= ulCreateFlags
;
875 vFrameCtlData
.hmodResources
= 0L;
876 vFrameCtlData
.idResources
= 0;
879 // Create the frame window
881 if ((m_hFrame
= ::WinCreateWindow( hParent
// Frame is parent
882 ,WC_FRAME
// standard frame class
883 ,(PSZ
)zTitle
// Window title
885 ,0, 0, 0, 0 // Window position
889 ,(PVOID
)&flFrameCtlData
// Creation data
890 ,NULL
// Window Pres Params
896 if (!wxWindow::OS2Create( m_hFrame
906 ,(unsigned long)FID_CLIENT
915 // Now size everything. If adding a menu the client will need to be resized.
917 if (!::WinSetWindowPos( m_hFrame
923 ,SWP_SIZE
| SWP_MOVE
| SWP_ACTIVATE
927 uCtlCount
= ::WinSendMsg(m_hFrame
, WM_FORMATFRAME
, (MPARAM
)pSwp
, (MPARAM
)pRect
);
928 for (int i
= 0; i
< uCtlCount
; i
++)
930 if (pSwp
[i
].hwnd
== m_hFrame
)
931 memcpy(m_vSwp
, pSwp
[i
], sizeof(SWP
));
932 else if (pSwp
[i
].hwnd
== m_hVScroll
)
933 memcpy(m_vSwpVScroll
, pSwp
[i
], sizeof(SWP
));
934 else if (pSwp
[i
].hwnd
== m_hHScroll
)
935 memcpy(m_vSwpVScroll
, pSwp
[i
], sizeof(SWP
));
936 else if (pSwp
[i
].hwnd
== m_hTitleBar
)
937 memcpy(m_vSwpTitleBar
, pSwp
[i
], sizeof(SWP
));
941 // Now set the size of the client
943 WinSetWindowPos( hClient
946 ,(SV_CYSIZEBORDER
/2) + m_vSwpHScroll
.cy
/2
947 ,m_vSwp
.cx
- ((SV_CXSIZEBORDER
+ 1) + m_vSwpVScroll
.cx
)
948 ,m_vSwp
.cy
- ((SV_CYSIZEBORDER
+ 1) + m_vSwpTitlebar
.cy
+ m_vSwpHScroll
.cy
/2)
953 // Set the client window's background, otherwise it is transparent!
956 } // end of wxFrame::OS2Create
959 // Default activation behaviour - set the focus for the first child
962 void wxFrame::OnActivate(
963 wxActivateEvent
& rEvent
966 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
968 pNode
= pNode
->GetNext())
970 // FIXME all this is totally bogus - we need to do the same as wxPanel,
971 // but how to do it without duplicating the code?
974 wxWindow
* pChild
= pNode
->GetData();
976 if (!pChild
->IsTopLevel()
978 && !wxDynamicCast(pChild
, wxToolBar
)
979 #endif // wxUSE_TOOLBAR
981 && !wxDynamicCast(pChild
, wxStatusBar
)
982 #endif // wxUSE_STATUSBAR
989 } // end of wxFrame::OnActivate
991 // ----------------------------------------------------------------------------
992 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
993 // from the client area, so the client area is what's really available for the
995 // ----------------------------------------------------------------------------
997 // Checks if there is a toolbar, and returns the first free client position
998 wxPoint
wxFrame::GetClientAreaOrigin() const
1000 wxPoint
vPoint(0, 0);
1007 GetToolBar()->GetSize( &nWidth
1011 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
1017 // PM is backwards from windows
1018 vPoint
.y
+= nHeight
;
1022 } // end of wxFrame::GetClientAreaOrigin
1024 // ----------------------------------------------------------------------------
1025 // tool/status bar stuff
1026 // ----------------------------------------------------------------------------
1030 wxToolBar
* wxFrame::CreateToolBar(
1033 , const wxString
& rName
1036 if (wxFrameBase::CreateToolBar( lStyle
1043 return m_frameToolBar
;
1044 } // end of wxFrame::CreateToolBar
1046 void wxFrame::PositionToolBar()
1051 ::WinQueryWindowRect(GetHwnd(), &vRect
);
1059 GetStatusBar()->GetClientSize( &nStatusX
1062 // PM is backwards from windows
1063 vRect
.yBottom
+= nStatusY
;
1065 #endif // wxUSE_STATUSBAR
1072 GetToolBar()->GetSize( &nToolbarWidth
1076 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
1078 nToolbarHeight
= vRect
.yBottom
;
1082 nToolbarWidth
= vRect
.xRight
;
1086 // Use the 'real' PM position here
1088 GetToolBar()->SetSize( 0
1092 ,wxSIZE_NO_ADJUSTMENTS
1095 } // end of wxFrame::PositionToolBar
1096 #endif // wxUSE_TOOLBAR
1098 // ----------------------------------------------------------------------------
1099 // frame state (iconized/maximized/...)
1100 // ----------------------------------------------------------------------------
1103 // propagate our state change to all child frames: this allows us to emulate X
1104 // Windows behaviour where child frames float independently of the parent one
1105 // on the desktop, but are iconized/restored with it
1107 void wxFrame::IconizeChildFrames(
1111 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
1113 pNode
= pNode
->GetNext() )
1115 wxWindow
* pWin
= pNode
->GetData();
1117 if (pWin
->IsKindOf(CLASSINFO(wxFrame
)) )
1119 ((wxFrame
*)pWin
)->Iconize(bIconize
);
1122 } // end of wxFrame::IconizeChildFrames
1124 // ===========================================================================
1125 // message processing
1126 // ===========================================================================
1128 // ---------------------------------------------------------------------------
1130 // ---------------------------------------------------------------------------
1131 bool wxFrame::OS2TranslateMessage(
1135 if (wxWindow::OS2TranslateMessage(pMsg
))
1138 // try the menu bar accels
1140 wxMenuBar
* pMenuBar
= GetMenuBar();
1145 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
1146 return rAcceleratorTable
.Translate(this, pMsg
);
1147 } // end of wxFrame::OS2TranslateMessage
1149 // ---------------------------------------------------------------------------
1150 // our private (non virtual) message handlers
1151 // ---------------------------------------------------------------------------
1152 bool wxFrame::HandlePaint()
1156 if (::WinQueryUpdateRect(m_hFrame
, &vRect
))
1161 // Icons in PM are the same as "pointers"
1166 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
1168 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1171 // Hold a pointer to the dc so long as the OnPaint() message
1172 // is being processed
1175 HPS hPs
= ::WinBeginPaint(m_hFrame
, NULLHANDLE
, &vRect2
);
1178 // Erase background before painting or we get white background
1180 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
1187 ::WinQueryWindowRect(GetHwnd(), &vRect3
);
1189 static const int nIconWidth
= 32;
1190 static const int nIconHeight
= 32;
1191 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
1192 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
1194 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
1201 return wxWindow::HandlePaint();
1206 // nothing to paint - processed
1210 } // end of wxFrame::HandlePaint
1212 bool wxFrame::HandleSize(
1218 bool bProcessed
= FALSE
;
1224 // Only do it it if we were iconized before, otherwise resizing the
1225 // parent frame has a curious side effect of bringing it under it's
1231 // restore all child frames too
1233 IconizeChildFrames(FALSE
);
1240 m_bIconized
= FALSE
;
1245 // Iconize all child frames too
1247 IconizeChildFrames(TRUE
);
1255 // forward WM_SIZE to status bar control
1257 #if wxUSE_NATIVE_STATUSBAR
1258 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
1260 wxSizeEvent
vEvent( wxSize( nX
1263 ,m_frameStatusBar
->GetId()
1266 vEvent
.SetEventObject(m_frameStatusBar
);
1267 m_frameStatusBar
->OnSize(vEvent
);
1269 #endif // wxUSE_NATIVE_STATUSBAR
1271 PositionStatusBar();
1273 wxSizeEvent
vEvent( wxSize( nX
1279 vEvent
.SetEventObject(this);
1280 bProcessed
= GetEventHandler()->ProcessEvent(vEvent
);
1283 } // end of wxFrame::HandleSize
1285 bool wxFrame::HandleCommand(
1294 // In case it's e.g. a toolbar.
1296 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
1299 return pWin
->OS2Command( nCmd
1305 // Handle here commands from menus and accelerators
1307 if (nCmd
== 0 || nCmd
== 1)
1309 if (wxCurrentPopupMenu
)
1311 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1313 wxCurrentPopupMenu
= NULL
;
1315 return pPopupMenu
->OS2Command( nCmd
1320 if (ProcessCommand(nId
))
1326 } // end of wxFrame::HandleCommand
1328 bool wxFrame::HandleMenuSelect(
1336 if (nFlags
== 0xFFFF && hMenu
== 0)
1339 // Menu was removed from screen
1343 else if (!(nFlags
& MIS_SUBMENU
) && !(nFlags
& MIS_SEPARATOR
))
1350 // Don't give hints for separators (doesn't make sense) nor for the
1351 // items opening popup menus (they don't have them anyhow)
1355 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nMenuItem
);
1357 vEvent
.SetEventObject(this);
1358 return GetEventHandler()->ProcessEvent(vEvent
);
1359 } // end of wxFrame::HandleMenuSelect
1361 // ---------------------------------------------------------------------------
1362 // the window proc for wxFrame
1363 // ---------------------------------------------------------------------------
1365 MRESULT
wxFrame::OS2WindowProc(
1372 bool bProcessed
= FALSE
;
1378 // If we can't close, tell the system that we processed the
1379 // message - otherwise it would close us
1381 bProcessed
= !Close();
1390 UnpackCommand( (WXWPARAM
)wParam
1396 bProcessed
= HandleCommand( wId
1409 UnpackMenuSelect( wParam
1415 bProcessed
= HandleMenuSelect( wItem
1423 bProcessed
= HandlePaint();
1426 case WM_ERASEBACKGROUND
:
1428 // Return TRUE to request PM to paint the window background
1429 // in SYSCLR_WINDOW.
1432 mRc
= (MRESULT
)(TRUE
);
1435 case CM_QUERYDRAGIMAGE
:
1440 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
1442 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1443 mRc
= (MRESULT
)hIcon
;
1444 bProcessed
= mRc
!= 0;
1449 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1454 mRc
= wxWindow::OS2WindowProc( uMessage
1459 } // wxFrame::OS2WindowProc