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(
347 hClient
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
348 ::WinShowWindow(GetHwnd(), (BOOL
)bShowCmd
);
349 ::WinShowWindow(hClient
, (BOOL
)bShowCmd
);
350 } // end of wxFrame::DoShowWindow
358 DoShowWindow((int)bShow
);
362 wxActivateEvent
vEvent(wxEVT_ACTIVATE
, TRUE
, m_windowId
);
364 ::WinQueryWindowPos(GetHwnd(), &vSwp
);
365 m_bIconized
= vSwp
.fl
& SWP_MINIMIZE
;
366 ::WinSetWindowPos( (HWND
) GetHWND()
372 ,SWP_ZORDER
| SWP_ACTIVATE
| SWP_SHOW
| SWP_MOVE
374 vEvent
.SetEventObject(this);
375 GetEventHandler()->ProcessEvent(vEvent
);
380 // Try to highlight the correct window (the parent)
384 HWND hWndParent
= GetHwndOf(GetParent());
386 ::WinQueryWindowPos(hWndParent
, &vSwp
);
387 m_bIconized
= vSwp
.fl
& SWP_MINIMIZE
;
389 ::WinSetWindowPos( hWndParent
395 ,SWP_ZORDER
| SWP_ACTIVATE
| SWP_SHOW
| SWP_MOVE
400 } // end of wxFrame::Show
402 void wxFrame::Iconize(
406 DoShowWindow(bIconize
? SWP_MINIMIZE
: SWP_RESTORE
);
407 } // end of wxFrame::Iconize
409 void wxFrame::Maximize(
412 DoShowWindow(bMaximize
? SWP_MAXIMIZE
: SWP_RESTORE
);
413 } // end of wxFrame::Maximize
415 void wxFrame::Restore()
417 DoShowWindow(SWP_RESTORE
);
418 } // end of wxFrame::Restore
420 bool wxFrame::IsIconized() const
425 ::WinQueryWindowPos(GetHwnd(), &vSwp
);
427 if (vSwp
.fl
& SWP_MINIMIZE
)
428 ((wxFrame
*)this)->m_bIconized
= TRUE
;
430 ((wxFrame
*)this)->m_bIconized
= FALSE
;
432 } // end of wxFrame::IsIconized
435 bool wxFrame::IsMaximized() const
440 ::WinQueryWindowPos(GetHwnd(), &vSwp
);
441 return (vSwp
.fl
& SWP_MAXIMIZE
);
442 } // end of wxFrame::IsMaximized
444 void wxFrame::SetIcon(
448 wxFrameBase::SetIcon(rIcon
);
450 if ((m_icon
.GetHICON()) != NULLHANDLE
)
452 ::WinSendMsg( GetHwnd()
454 ,(MPARAM
)((HPOINTER
)m_icon
.GetHICON())
457 ::WinSendMsg( GetHwnd()
463 } // end of wxFrame::SetIcon
466 wxStatusBar
* wxFrame::OnCreateStatusBar(
470 , const wxString
& rName
473 wxStatusBar
* pStatusBar
= NULL
;
475 pStatusBar
= wxFrameBase::OnCreateStatusBar( nNumber
481 } // end of wxFrame::OnCreateStatusBar
483 void wxFrame::PositionStatusBar()
486 // Native status bar positions itself
488 if (m_frameStatusBar
)
497 hWndClient
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
498 ::WinQueryWindowRect(hWndClient
, &vRect
);
499 nWidth
= vRect
.xRight
- vRect
.xLeft
;
500 nHeight
= vRect
.yTop
- vRect
.yBottom
;
502 m_frameStatusBar
->GetSize( &nStatbarWidth
507 // Since we wish the status bar to be directly under the client area,
508 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
510 m_frameStatusBar
->SetSize( 0
516 } // end of wxFrame::PositionStatusBar
517 #endif // wxUSE_STATUSBAR
519 void wxFrame::DetachMenuBar()
523 m_frameMenuBar
->Detach();
524 m_frameMenuBar
= NULL
;
526 } // end of wxFrame::DetachMenuBar
528 void wxFrame::SetMenuBar(
538 m_frameMenuBar
= NULL
;
540 // Can set a menubar several times.
541 // TODO: how to prevent a memory leak if you have a currently-unattached
542 // menubar? wxWindows assumes that the frame will delete the menu (otherwise
543 // there are problems for MDI).
544 if (pMenuBar
->GetHMenu())
546 m_hMenu
= pMenuBar
->GetHMenu();
552 m_hMenu
= pMenuBar
->Create();
558 InternalSetMenuBar();
560 m_frameMenuBar
= pMenuBar
;
561 pMenuBar
->Attach(this);
562 } // end of wxFrame::SetMenuBar
564 void wxFrame::InternalSetMenuBar()
566 WinSendMsg((HWND
)GetHwnd(), WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
567 } // end of wxFrame::InternalSetMenuBar
570 // Responds to colour changes, and passes event on to children
572 void wxFrame::OnSysColourChanged(
573 wxSysColourChangedEvent
& rEvent
576 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
579 if (m_frameStatusBar
)
581 wxSysColourChangedEvent vEvent2
;
583 vEvent2
.SetEventObject(m_frameStatusBar
);
584 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
588 // Propagate the event to the non-top-level children
590 wxWindow::OnSysColourChanged(rEvent
);
591 } // end of wxFrame::OnSysColourChanged
593 // Pass TRUE to show full screen, FALSE to restore.
594 bool wxFrame::ShowFullScreen(
606 m_fsIsShowing = TRUE;
609 wxToolBar *theToolBar = GetToolBar();
610 wxStatusBar *theStatusBar = GetStatusBar();
615 theToolBar->GetSize(&dummyWidth, &m_fsToolBarHeight);
617 theStatusBar->GetSize(&dummyWidth, &m_fsStatusBarHeight);
619 // zap the toolbar, menubar, and statusbar
621 if ((style & wxFULLSCREEN_NOTOOLBAR) && theToolBar)
623 theToolBar->SetSize(-1,0);
624 theToolBar->Show(FALSE);
627 if (style & wxFULLSCREEN_NOMENUBAR)
628 SetMenu((HWND)GetHWND(), (HMENU) NULL);
630 // Save the number of fields in the statusbar
631 if ((style & wxFULLSCREEN_NOSTATUSBAR) && theStatusBar)
633 m_fsStatusBarFields = theStatusBar->GetFieldsCount();
634 SetStatusBar((wxStatusBar*) NULL);
638 m_fsStatusBarFields = 0;
640 // zap the frame borders
642 // save the 'normal' window style
643 m_fsOldWindowStyle = GetWindowLong((HWND)GetHWND(), GWL_STYLE);
645 // save the old position, width & height, maximize state
646 m_fsOldSize = GetRect();
647 m_fsIsMaximized = IsMaximized();
649 // decide which window style flags to turn off
650 LONG newStyle = m_fsOldWindowStyle;
653 if (style & wxFULLSCREEN_NOBORDER)
654 offFlags |= WS_BORDER;
655 if (style & wxFULLSCREEN_NOCAPTION)
656 offFlags |= (WS_CAPTION | WS_SYSMENU);
658 newStyle &= (~offFlags);
660 // change our window style to be compatible with full-screen mode
661 SetWindowLong((HWND)GetHWND(), GWL_STYLE, newStyle);
663 // resize to the size of the desktop
667 ::GetWindowRect(GetDesktopWindow(), &rect);
668 width = rect.right - rect.left;
669 height = rect.bottom - rect.top;
671 SetSize(width, height);
673 // now flush the window style cache and actually go full-screen
674 SetWindowPos((HWND)GetHWND(), HWND_TOP, 0, 0, width, height, SWP_FRAMECHANGED);
676 wxSizeEvent event(wxSize(width, height), GetId());
677 GetEventHandler()->ProcessEvent(event);
686 m_fsIsShowing = FALSE;
688 wxToolBar *theToolBar = GetToolBar();
690 // restore the toolbar, menubar, and statusbar
691 if (theToolBar && (m_fsStyle & wxFULLSCREEN_NOTOOLBAR))
693 theToolBar->SetSize(-1, m_fsToolBarHeight);
694 theToolBar->Show(TRUE);
697 if ((m_fsStyle & wxFULLSCREEN_NOSTATUSBAR) && (m_fsStatusBarFields > 0))
699 CreateStatusBar(m_fsStatusBarFields);
703 if ((m_fsStyle & wxFULLSCREEN_NOMENUBAR) && (m_hMenu != 0))
704 SetMenu((HWND)GetHWND(), (HMENU)m_hMenu);
706 Maximize(m_fsIsMaximized);
707 SetWindowLong((HWND)GetHWND(),GWL_STYLE, m_fsOldWindowStyle);
708 SetWindowPos((HWND)GetHWND(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y,
709 m_fsOldSize.width, m_fsOldSize.height, SWP_FRAMECHANGED);
715 } // end of wxFrame::ShowFullScreen
720 bool wxFrame::OS2Create(
723 , const wxChar
* zWclass
725 , const wxChar
* zTitle
733 ULONG ulCreateFlags
= 0L;
734 ULONG ulStyleFlags
= 0L;
735 ULONG ulExtraFlags
= 0L;
736 FRAMECDATA vFrameCtlData
;
737 HWND hParent
= NULLHANDLE
;
738 HWND hClient
= NULLHANDLE
;
739 HWND hTitlebar
= NULLHANDLE
;
740 HWND hHScroll
= NULLHANDLE
;
741 HWND hVScroll
= NULLHANDLE
;
747 m_hDefaultIcon
= (WXHICON
) (wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
: wxDEFAULT_FRAME_ICON
);
748 memset(&vSwp
, '\0', sizeof(SWP
));
749 memset(&vSwpTitlebar
, '\0', sizeof(SWP
));
750 memset(&vSwpVScroll
, '\0', sizeof(SWP
));
751 memset(&vSwpHScroll
, '\0', sizeof(SWP
));
753 hParent
= GetWinHwnd(pParent
);
755 hParent
= HWND_DESKTOP
;
757 if (ulStyle
== wxDEFAULT_FRAME_STYLE
)
758 ulCreateFlags
= FCF_SIZEBORDER
| FCF_TITLEBAR
| FCF_SYSMENU
|
759 FCF_MINMAX
| FCF_VERTSCROLL
| FCF_HORZSCROLL
| FCF_TASKLIST
;
762 if ((ulStyle
& wxCAPTION
) == wxCAPTION
)
763 ulCreateFlags
= FCF_TASKLIST
;
765 ulCreateFlags
= FCF_NOMOVEWITHOWNER
;
767 if (ulStyle
& wxMINIMIZE_BOX
)
768 ulCreateFlags
|= FCF_MINBUTTON
;
769 if (ulStyle
& wxMAXIMIZE_BOX
)
770 ulCreateFlags
|= FCF_MAXBUTTON
;
771 if (ulStyle
& wxTHICK_FRAME
)
772 ulCreateFlags
|= FCF_DLGBORDER
;
773 if (ulStyle
& wxSYSTEM_MENU
)
774 ulCreateFlags
|= FCF_SYSMENU
;
775 if (ulStyle
& wxCAPTION
)
776 ulCreateFlags
|= FCF_TASKLIST
;
777 if (ulStyle
& wxCLIP_CHILDREN
)
779 // Invalid for frame windows under PM
782 if (ulStyle
& wxTINY_CAPTION_VERT
)
783 ulCreateFlags
|= FCF_TASKLIST
;
784 if (ulStyle
& wxTINY_CAPTION_HORIZ
)
785 ulCreateFlags
|= FCF_TASKLIST
;
787 if ((ulStyle
& wxTHICK_FRAME
) == 0)
788 ulCreateFlags
|= FCF_BORDER
;
789 if (ulStyle
& wxFRAME_TOOL_WINDOW
)
790 ulExtraFlags
= kFrameToolWindow
;
792 if (ulStyle
& wxSTAY_ON_TOP
)
793 ulCreateFlags
|= FCF_SYSMODAL
;
795 if ((ulStyle
& wxMINIMIZE
) || (ulStyle
& wxICONIZE
))
796 ulStyleFlags
|= WS_MINIMIZED
;
797 if (ulStyle
& wxMAXIMIZE
)
798 ulStyleFlags
|= WS_MAXIMIZED
;
801 // Clear the visible flag, we always call show
803 ulStyleFlags
&= (unsigned long)~WS_VISIBLE
;
807 // Set the frame control block
809 vFrameCtlData
.cb
= sizeof(vFrameCtlData
);
810 vFrameCtlData
.flCreateFlags
= ulCreateFlags
;
811 vFrameCtlData
.hmodResources
= 0L;
812 vFrameCtlData
.idResources
= 0;
815 // Create the frame window
817 if (!wxWindow::OS2Create( hParent
828 ,(void*)&vFrameCtlData
836 // Create the client window. We must call the API from here rather than
837 // the static base class create because we need a separate handle
839 if ((hClient
= ::WinCreateWindow( GetHwnd() // Frame is parent
840 ,zWclass
// Custom client class
841 ,NULL
// Window title
843 ,0, 0, 0, 0 // Window position
846 ,FID_CLIENT
// standard client ID
847 ,NULL
// Creation data
848 ,NULL
// Window Pres Params
854 // Send anything to initialize the frame
856 ::WinSendMsg( GetHwnd()
858 ,(MPARAM
)FCF_TASKLIST
863 // Now size everything. If adding a menu the client will need to be resized.
865 if (!::WinSetWindowPos( GetHwnd()
871 ,SWP_SIZE
| SWP_MOVE
| SWP_ACTIVATE
875 WinQueryWindowPos(GetHwnd(), &vSwp
);
877 if (ulCreateFlags
& FCF_TITLEBAR
)
879 hTitlebar
= WinWindowFromID(GetHwnd(), FID_TITLEBAR
);
880 WinQueryWindowPos(hTitlebar
, &vSwpTitlebar
);
882 if (ulCreateFlags
& FCF_HORZSCROLL
)
884 hHScroll
= WinWindowFromID(GetHwnd(), FID_HORZSCROLL
);
885 WinQueryWindowPos(hHScroll
, &vSwpHScroll
);
887 if (ulCreateFlags
& FCF_VERTSCROLL
)
889 hVScroll
= WinWindowFromID(GetHwnd(), FID_VERTSCROLL
);
890 WinQueryWindowPos(hVScroll
, &vSwpVScroll
);
892 if (!::WinSetWindowPos( hClient
895 ,(SV_CYSIZEBORDER
- 1) + vSwpHScroll
.cy
896 ,vSwp
.cx
- ((SV_CXSIZEBORDER
* 2) + vSwpVScroll
.cx
)
897 ,vSwp
.cy
- ((SV_CYSIZEBORDER
* 2) + 1 + vSwpTitlebar
.cy
+ vSwpHScroll
.cy
)
902 } // end of wxFrame::OS2Create
905 // Default activation behaviour - set the focus for the first child
908 void wxFrame::OnActivate(
909 wxActivateEvent
& rEvent
912 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
914 pNode
= pNode
->GetNext())
916 // FIXME all this is totally bogus - we need to do the same as wxPanel,
917 // but how to do it without duplicating the code?
920 wxWindow
* pChild
= pNode
->GetData();
922 if (!pChild
->IsTopLevel()
924 && !wxDynamicCast(pChild
, wxToolBar
)
925 #endif // wxUSE_TOOLBAR
927 && !wxDynamicCast(pChild
, wxStatusBar
)
928 #endif // wxUSE_STATUSBAR
935 } // end of wxFrame::OnActivate
937 // ----------------------------------------------------------------------------
938 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
939 // from the client area, so the client area is what's really available for the
941 // ----------------------------------------------------------------------------
943 // Checks if there is a toolbar, and returns the first free client position
944 wxPoint
wxFrame::GetClientAreaOrigin() const
946 wxPoint
vPoint(0, 0);
953 GetToolBar()->GetSize( &nWidth
957 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
963 // PM is backwards from windows
968 } // end of wxFrame::GetClientAreaOrigin
970 // ----------------------------------------------------------------------------
971 // tool/status bar stuff
972 // ----------------------------------------------------------------------------
976 wxToolBar
* wxFrame::CreateToolBar(
979 , const wxString
& rName
982 if (wxFrameBase::CreateToolBar( lStyle
989 return m_frameToolBar
;
990 } // end of wxFrame::CreateToolBar
992 void wxFrame::PositionToolBar()
997 hWndClient
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
998 ::WinQueryWindowRect(hWndClient
, &vRect
);
1006 GetStatusBar()->GetClientSize( &nStatusX
1009 // PM is backwards from windows
1010 vRect
.yBottom
+= nStatusY
;
1012 #endif // wxUSE_STATUSBAR
1019 GetToolBar()->GetSize( &nToolbarWidth
1023 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
1025 nToolbarHeight
= vRect
.yBottom
;
1029 nToolbarWidth
= vRect
.xRight
;
1033 // Use the 'real' PM position here
1035 GetToolBar()->SetSize( 0
1039 ,wxSIZE_NO_ADJUSTMENTS
1042 } // end of wxFrame::PositionToolBar
1043 #endif // wxUSE_TOOLBAR
1045 // ----------------------------------------------------------------------------
1046 // frame state (iconized/maximized/...)
1047 // ----------------------------------------------------------------------------
1050 // propagate our state change to all child frames: this allows us to emulate X
1051 // Windows behaviour where child frames float independently of the parent one
1052 // on the desktop, but are iconized/restored with it
1054 void wxFrame::IconizeChildFrames(
1058 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
1060 pNode
= pNode
->GetNext() )
1062 wxWindow
* pWin
= pNode
->GetData();
1064 if (pWin
->IsKindOf(CLASSINFO(wxFrame
)) )
1066 ((wxFrame
*)pWin
)->Iconize(bIconize
);
1069 } // end of wxFrame::IconizeChildFrames
1071 // ===========================================================================
1072 // message processing
1073 // ===========================================================================
1075 // ---------------------------------------------------------------------------
1077 // ---------------------------------------------------------------------------
1078 bool wxFrame::OS2TranslateMessage(
1082 if (wxWindow::OS2TranslateMessage(pMsg
))
1085 // try the menu bar accels
1087 wxMenuBar
* pMenuBar
= GetMenuBar();
1092 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
1093 return rAcceleratorTable
.Translate(this, pMsg
);
1094 } // end of wxFrame::OS2TranslateMessage
1096 // ---------------------------------------------------------------------------
1097 // our private (non virtual) message handlers
1098 // ---------------------------------------------------------------------------
1099 bool wxFrame::HandlePaint()
1103 if (::WinQueryUpdateRect(GetHwnd(), &vRect
))
1108 // Icons in PM are the same as "pointers"
1113 hIcon
= (HPOINTER
)::WinSendMsg(GetHwnd(), WM_QUERYICON
, 0L, 0L);
1115 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1118 // Hold a pointer to the dc so long as the OnPaint() message
1119 // is being processed
1122 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
1125 // Erase background before painting or we get white background
1127 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
1134 hWndClient
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
1135 ::WinQueryWindowRect(hWndClient
, &vRect3
);
1137 static const int nIconWidth
= 32;
1138 static const int nIconHeight
= 32;
1139 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
1140 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
1142 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
1149 return wxWindow::HandlePaint();
1154 // nothing to paint - processed
1158 } // end of wxFrame::HandlePaint
1160 bool wxFrame::HandleSize(
1166 bool bProcessed
= FALSE
;
1172 // Only do it it if we were iconized before, otherwise resizing the
1173 // parent frame has a curious side effect of bringing it under it's
1179 // restore all child frames too
1181 IconizeChildFrames(FALSE
);
1188 m_bIconized
= FALSE
;
1193 // Iconize all child frames too
1195 IconizeChildFrames(TRUE
);
1203 // forward WM_SIZE to status bar control
1205 #if wxUSE_NATIVE_STATUSBAR
1206 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
1208 wxSizeEvent
vEvent( wxSize( nX
1211 ,m_frameStatusBar
->GetId()
1214 vEvent
.SetEventObject(m_frameStatusBar
);
1215 m_frameStatusBar
->OnSize(vEvent
);
1217 #endif // wxUSE_NATIVE_STATUSBAR
1219 PositionStatusBar();
1221 wxSizeEvent
vEvent( wxSize( nX
1227 vEvent
.SetEventObject(this);
1228 bProcessed
= GetEventHandler()->ProcessEvent(vEvent
);
1231 } // end of wxFrame::HandleSize
1233 bool wxFrame::HandleCommand(
1242 // In case it's e.g. a toolbar.
1244 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
1247 return pWin
->OS2Command( nCmd
1253 // Handle here commands from menus and accelerators
1255 if (nCmd
== 0 || nCmd
== 1)
1257 if (wxCurrentPopupMenu
)
1259 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1261 wxCurrentPopupMenu
= NULL
;
1263 return pPopupMenu
->OS2Command( nCmd
1268 if (ProcessCommand(nId
))
1274 } // end of wxFrame::HandleCommand
1276 bool wxFrame::HandleMenuSelect(
1284 if (nFlags
== 0xFFFF && hMenu
== 0)
1287 // Menu was removed from screen
1291 else if (!(nFlags
& MIS_SUBMENU
) && !(nFlags
& MIS_SEPARATOR
))
1298 // Don't give hints for separators (doesn't make sense) nor for the
1299 // items opening popup menus (they don't have them anyhow)
1303 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nMenuItem
);
1305 vEvent
.SetEventObject(this);
1306 return GetEventHandler()->ProcessEvent(vEvent
);
1307 } // end of wxFrame::HandleMenuSelect
1309 // ---------------------------------------------------------------------------
1310 // the window proc for wxFrame
1311 // ---------------------------------------------------------------------------
1313 MRESULT
wxFrame::OS2WindowProc(
1320 bool bProcessed
= FALSE
;
1326 // If we can't close, tell the system that we processed the
1327 // message - otherwise it would close us
1329 bProcessed
= !Close();
1338 UnpackCommand( (WXWPARAM
)wParam
1344 bProcessed
= HandleCommand( wId
1357 UnpackMenuSelect( wParam
1363 bProcessed
= HandleMenuSelect( wItem
1371 bProcessed
= HandlePaint();
1374 case CM_QUERYDRAGIMAGE
:
1379 hIcon
= (HPOINTER
)::WinSendMsg(GetHwnd(), WM_QUERYICON
, 0L, 0L);
1381 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1382 mRc
= (MRESULT
)hIcon
;
1383 bProcessed
= mRc
!= 0;
1388 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1393 mRc
= wxWindow::OS2WindowProc( uMessage
1398 } // wxFrame::OS2WindowProc