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
& 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
& 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
855 // Now size everything. If adding a menu the client will need to be resized.
857 if (!::WinSetWindowPos( GetHwnd()
863 ,SWP_SIZE
| SWP_MOVE
| SWP_ACTIVATE
867 WinQueryWindowPos(GetHwnd(), &vSwp
);
869 if (ulCreateFlags
& FCF_TITLEBAR
)
871 hTitlebar
= WinWindowFromID(GetHwnd(), FID_TITLEBAR
);
872 WinQueryWindowPos(hTitlebar
, &vSwpTitlebar
);
874 if (ulCreateFlags
& FCF_HORZSCROLL
)
876 hHScroll
= WinWindowFromID(GetHwnd(), FID_HORZSCROLL
);
877 WinQueryWindowPos(hHScroll
, &vSwpHScroll
);
879 if (ulCreateFlags
& FCF_VERTSCROLL
)
881 hVScroll
= WinWindowFromID(GetHwnd(), FID_VERTSCROLL
);
882 WinQueryWindowPos(hVScroll
, &vSwpVScroll
);
884 if (!::WinSetWindowPos( hClient
887 ,(SV_CYSIZEBORDER
- 1) + vSwpHScroll
.cy
888 ,vSwp
.cx
- ((SV_CXSIZEBORDER
* 2) + vSwpVScroll
.cx
)
889 ,vSwp
.cy
- ((SV_CYSIZEBORDER
* 2) + 1 + vSwpTitlebar
.cy
+ vSwpHScroll
.cy
)
894 } // end of wxFrame::OS2Create
897 // Default activation behaviour - set the focus for the first child
900 void wxFrame::OnActivate(
901 wxActivateEvent
& rEvent
904 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
906 pNode
= pNode
->GetNext())
908 // FIXME all this is totally bogus - we need to do the same as wxPanel,
909 // but how to do it without duplicating the code?
912 wxWindow
* pChild
= pNode
->GetData();
914 if (!pChild
->IsTopLevel()
916 && !wxDynamicCast(pChild
, wxToolBar
)
917 #endif // wxUSE_TOOLBAR
919 && !wxDynamicCast(pChild
, wxStatusBar
)
920 #endif // wxUSE_STATUSBAR
927 } // end of wxFrame::OnActivate
929 // ----------------------------------------------------------------------------
930 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
931 // from the client area, so the client area is what's really available for the
933 // ----------------------------------------------------------------------------
935 // Checks if there is a toolbar, and returns the first free client position
936 wxPoint
wxFrame::GetClientAreaOrigin() const
938 wxPoint
vPoint(0, 0);
945 GetToolBar()->GetSize( &nWidth
949 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
955 // PM is backwards from windows
960 } // end of wxFrame::GetClientAreaOrigin
962 // ----------------------------------------------------------------------------
963 // tool/status bar stuff
964 // ----------------------------------------------------------------------------
968 wxToolBar
* wxFrame::CreateToolBar(
971 , const wxString
& rName
974 if (wxFrameBase::CreateToolBar( lStyle
981 return m_frameToolBar
;
982 } // end of wxFrame::CreateToolBar
984 void wxFrame::PositionToolBar()
989 hWndClient
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
990 ::WinQueryWindowRect(hWndClient
, &vRect
);
998 GetStatusBar()->GetClientSize( &nStatusX
1001 // PM is backwards from windows
1002 vRect
.yBottom
+= nStatusY
;
1004 #endif // wxUSE_STATUSBAR
1011 GetToolBar()->GetSize( &nToolbarWidth
1015 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
1017 nToolbarHeight
= vRect
.yBottom
;
1021 nToolbarWidth
= vRect
.xRight
;
1025 // Use the 'real' PM position here
1027 GetToolBar()->SetSize( 0
1031 ,wxSIZE_NO_ADJUSTMENTS
1034 } // end of wxFrame::PositionToolBar
1035 #endif // wxUSE_TOOLBAR
1037 // ----------------------------------------------------------------------------
1038 // frame state (iconized/maximized/...)
1039 // ----------------------------------------------------------------------------
1042 // propagate our state change to all child frames: this allows us to emulate X
1043 // Windows behaviour where child frames float independently of the parent one
1044 // on the desktop, but are iconized/restored with it
1046 void wxFrame::IconizeChildFrames(
1050 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
1052 pNode
= pNode
->GetNext() )
1054 wxWindow
* pWin
= pNode
->GetData();
1056 if (pWin
->IsKindOf(CLASSINFO(wxFrame
)) )
1058 ((wxFrame
*)pWin
)->Iconize(bIconize
);
1061 } // end of wxFrame::IconizeChildFrames
1063 // ===========================================================================
1064 // message processing
1065 // ===========================================================================
1067 // ---------------------------------------------------------------------------
1069 // ---------------------------------------------------------------------------
1070 bool wxFrame::OS2TranslateMessage(
1074 if (wxWindow::OS2TranslateMessage(pMsg
))
1077 // try the menu bar accels
1079 wxMenuBar
* pMenuBar
= GetMenuBar();
1084 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
1085 return rAcceleratorTable
.Translate(this, pMsg
);
1086 } // end of wxFrame::OS2TranslateMessage
1088 // ---------------------------------------------------------------------------
1089 // our private (non virtual) message handlers
1090 // ---------------------------------------------------------------------------
1091 bool wxFrame::HandlePaint()
1095 if (::WinQueryUpdateRect(GetHwnd(), &vRect
))
1100 // Icons in PM are the same as "pointers"
1105 hIcon
= (HPOINTER
)::WinSendMsg(GetHwnd(), WM_QUERYICON
, 0L, 0L);
1107 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1110 // Hold a pointer to the dc so long as the OnPaint() message
1111 // is being processed
1114 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
1117 // Erase background before painting or we get white background
1119 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
1126 hWndClient
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
1127 ::WinQueryWindowRect(hWndClient
, &vRect3
);
1129 static const int nIconWidth
= 32;
1130 static const int nIconHeight
= 32;
1131 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
1132 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
1134 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
1141 return wxWindow::HandlePaint();
1146 // nothing to paint - processed
1150 } // end of wxFrame::HandlePaint
1152 bool wxFrame::HandleSize(
1158 bool bProcessed
= FALSE
;
1164 // Only do it it if we were iconized before, otherwise resizing the
1165 // parent frame has a curious side effect of bringing it under it's
1171 // restore all child frames too
1173 IconizeChildFrames(FALSE
);
1180 m_bIconized
= FALSE
;
1185 // Iconize all child frames too
1187 IconizeChildFrames(TRUE
);
1195 // forward WM_SIZE to status bar control
1197 #if wxUSE_NATIVE_STATUSBAR
1198 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
1200 wxSizeEvent
vEvent( wxSize( nX
1203 ,m_frameStatusBar
->GetId()
1206 vEvent
.SetEventObject(m_frameStatusBar
);
1207 m_frameStatusBar
->OnSize(vEvent
);
1209 #endif // wxUSE_NATIVE_STATUSBAR
1211 PositionStatusBar();
1213 wxSizeEvent
vEvent( wxSize( nX
1219 vEvent
.SetEventObject(this);
1220 bProcessed
= GetEventHandler()->ProcessEvent(vEvent
);
1223 } // end of wxFrame::HandleSize
1225 bool wxFrame::HandleCommand(
1234 // In case it's e.g. a toolbar.
1236 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
1239 return pWin
->OS2Command( nCmd
1245 // Handle here commands from menus and accelerators
1247 if (nCmd
== 0 || nCmd
== 1)
1249 if (wxCurrentPopupMenu
)
1251 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1253 wxCurrentPopupMenu
= NULL
;
1255 return pPopupMenu
->OS2Command( nCmd
1260 if (ProcessCommand(nId
))
1266 } // end of wxFrame::HandleCommand
1268 bool wxFrame::HandleMenuSelect(
1276 if (nFlags
== 0xFFFF && hMenu
== 0)
1279 // Menu was removed from screen
1283 else if (!(nFlags
& MIS_SUBMENU
) && !(nFlags
& MIS_SEPARATOR
))
1290 // Don't give hints for separators (doesn't make sense) nor for the
1291 // items opening popup menus (they don't have them anyhow)
1295 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nMenuItem
);
1297 vEvent
.SetEventObject(this);
1298 return GetEventHandler()->ProcessEvent(vEvent
);
1299 } // end of wxFrame::HandleMenuSelect
1301 // ---------------------------------------------------------------------------
1302 // the window proc for wxFrame
1303 // ---------------------------------------------------------------------------
1305 MRESULT
wxFrame::OS2WindowProc(
1312 bool bProcessed
= FALSE
;
1318 // If we can't close, tell the system that we processed the
1319 // message - otherwise it would close us
1321 bProcessed
= !Close();
1330 UnpackCommand( (WXWPARAM
)wParam
1336 bProcessed
= HandleCommand( wId
1349 UnpackMenuSelect( wParam
1355 bProcessed
= HandleMenuSelect( wItem
1363 bProcessed
= HandlePaint();
1366 case CM_QUERYDRAGIMAGE
:
1371 hIcon
= (HPOINTER
)::WinSendMsg(GetHwnd(), WM_QUERYICON
, 0L, 0L);
1373 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1374 mRc
= (MRESULT
)hIcon
;
1375 bProcessed
= mRc
!= 0;
1380 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1385 mRc
= wxWindow::OS2WindowProc( uMessage
1390 } // wxFrame::OS2WindowProc