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"
17 #include "wx/object.h"
18 #include "wx/dynarray.h"
21 #include "wx/string.h"
30 #include "wx/dialog.h"
31 #include "wx/settings.h"
32 #include "wx/dcclient.h"
35 #include "wx/os2/private.h"
38 #include "wx/statusbr.h"
39 #include "wx/generic/statusbr.h"
40 #endif // wxUSE_STATUSBAR
43 #include "wx/toolbar.h"
44 #endif // wxUSE_TOOLBAR
46 #include "wx/menuitem.h"
49 // ----------------------------------------------------------------------------
51 // ----------------------------------------------------------------------------
53 extern wxWindowList wxModelessWindows
;
54 extern wxList WXDLLEXPORT wxPendingDelete
;
56 #if wxUSE_MENUS_NATIVE
57 extern wxMenu
*wxCurrentPopupMenu
;
60 extern void wxAssociateWinWithHandle( HWND hWnd
64 // ----------------------------------------------------------------------------
66 // ----------------------------------------------------------------------------
68 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
69 EVT_ACTIVATE(wxFrame::OnActivate
)
70 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
73 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
75 // ============================================================================
77 // ============================================================================
79 // ----------------------------------------------------------------------------
80 // static class members
81 // ----------------------------------------------------------------------------
84 #if wxUSE_NATIVE_STATUSBAR
85 bool wxFrame::m_bUseNativeStatusBar
= TRUE
;
87 bool wxFrame::m_bUseNativeStatusBar
= FALSE
;
90 #endif //wxUSE_STATUSBAR
92 // ----------------------------------------------------------------------------
93 // creation/destruction
94 // ----------------------------------------------------------------------------
98 m_nFsStatusBarFields
= 0;
99 m_nFsStatusBarHeight
= 0;
100 m_nFsToolBarHeight
= 0;
102 m_bWasMinimized
= FALSE
;
103 m_pWinLastFocused
= NULL
;
106 m_frameMenuBar
= NULL
;
107 m_frameToolBar
= NULL
;
108 m_frameStatusBar
= NULL
;
110 m_hTitleBar
= NULLHANDLE
;
111 m_hHScroll
= NULLHANDLE
;
112 m_hVScroll
= NULLHANDLE
;
117 memset(&m_vSwpTitleBar
, 0, sizeof(SWP
));
118 memset(&m_vSwpMenuBar
, 0, sizeof(SWP
));
119 memset(&m_vSwpHScroll
, 0, sizeof(SWP
));
120 memset(&m_vSwpVScroll
, 0, sizeof(SWP
));
121 memset(&m_vSwpStatusBar
, 0, sizeof(SWP
));
122 memset(&m_vSwpToolBar
, 0, sizeof(SWP
));
125 } // end of wxFrame::Init
127 bool wxFrame::Create(
130 , const wxString
& rsTitle
131 , const wxPoint
& rPos
132 , const wxSize
& rSize
134 , const wxString
& rsName
137 if (!wxTopLevelWindow::Create( pParent
146 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
147 wxModelessWindows
.Append(this);
149 } // end of wxFrame::Create
153 m_isBeingDeleted
= TRUE
;
155 } // end of wxFrame::~wxFrame
158 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
160 void wxFrame::DoGetClientSize(
165 wxTopLevelWindow::DoGetClientSize( pX
169 // No need to use statusbar code as in WIN32 as the FORMATFRAME
170 // window procedure ensures PM knows about the new frame client
171 // size internally. A ::WinQueryWindowRect (that is called in
172 // wxWindow's GetClient size from above) is all that is needed!
174 } // end of wxFrame::DoGetClientSize
177 // Set the client size (i.e. leave the calculation of borders etc.
180 void wxFrame::DoSetClientSize(
185 wxStatusBar
* pStatusBar
= GetStatusBar();
188 // Statusbars are not part of the OS/2 Client but parent frame
189 // so no statusbar consideration
191 wxTopLevelWindow::DoSetClientSize( nWidth
194 } // end of wxFrame::DoSetClientSize
196 // ----------------------------------------------------------------------------
197 // wxFrame: various geometry-related functions
198 // ----------------------------------------------------------------------------
200 void wxFrame::Raise()
202 wxFrameBase::Raise();
203 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
213 // generate an artificial resize event
214 void wxFrame::SendSizeEvent()
218 RECTL vRect
= wxGetWindowRect(GetHwnd());
220 (void)::WinPostMsg( m_hFrame
222 ,MPFROM2SHORT(vRect
.xRight
- vRect
.xLeft
, vRect
.yTop
- vRect
.yBottom
)
223 ,MPFROM2SHORT(vRect
.xRight
- vRect
.xLeft
, vRect
.yTop
- vRect
.yBottom
)
229 wxStatusBar
* wxFrame::OnCreateStatusBar(
233 , const wxString
& rName
236 wxStatusBar
* pStatusBar
= NULL
;
241 pStatusBar
= wxFrameBase::OnCreateStatusBar( nNumber
250 ::WinSetParent( pStatusBar
->GetHWND()
254 ::WinSetOwner( pStatusBar
->GetHWND()
260 if(::WinIsWindowShowing(m_hFrame
))
261 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
264 } // end of wxFrame::OnCreateStatusBar
266 void wxFrame::PositionStatusBar()
273 // Native status bar positions itself
275 if (m_frameStatusBar
)
285 ::WinQueryWindowRect(m_hFrame
, &vRect
);
287 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
289 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
290 nWidth
= vRect
.xRight
- vRect
.xLeft
;
291 nY
= nY
- (vRect
.yBottom
- vFRect
.yBottom
);
293 m_frameStatusBar
->GetSize( &nStatbarWidth
297 nY
= nY
- nStatbarHeight
;
299 // Since we wish the status bar to be directly under the client area,
300 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
302 m_frameStatusBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
307 if (!::WinQueryWindowPos(m_frameStatusBar
->GetHWND(), &vSwp
))
309 vError
= ::WinGetLastError(vHabmain
);
310 sError
= wxPMErrorToStr(vError
);
311 wxLogError("Error setting parent for StautsBar. Error: %s\n", sError
);
315 } // end of wxFrame::PositionStatusBar
316 #endif // wxUSE_STATUSBAR
318 #if wxUSE_MENUS_NATIVE
319 void wxFrame::DetachMenuBar()
323 m_frameMenuBar
->Detach();
324 m_frameMenuBar
= NULL
;
326 } // end of wxFrame::DetachMenuBar
328 void wxFrame::SetMenuBar(
334 HWND hTitlebar
= NULLHANDLE
;
335 HWND hHScroll
= NULLHANDLE
;
336 HWND hVScroll
= NULLHANDLE
;
337 HWND hMenuBar
= NULLHANDLE
;
349 // Actually remove the menu from the frame
351 m_hMenu
= (WXHMENU
)0;
352 InternalSetMenuBar();
354 else // set new non NULL menu bar
356 m_frameMenuBar
= NULL
;
359 // Can set a menubar several times.
360 // TODO: how to prevent a memory leak if you have a currently-unattached
361 // menubar? wxWindows assumes that the frame will delete the menu (otherwise
362 // there are problems for MDI).
364 if (pMenuBar
->GetHMenu())
366 m_hMenu
= pMenuBar
->GetHMenu();
371 m_hMenu
= pMenuBar
->Create();
375 InternalSetMenuBar();
376 m_frameMenuBar
= pMenuBar
;
377 pMenuBar
->Attach((wxFrame
*)this);
379 } // end of wxFrame::SetMenuBar
381 void wxFrame::AttachMenuBar(
385 wxFrameBase::AttachMenuBar(pMenubar
);
387 m_frameMenuBar
= pMenubar
;
392 // Actually remove the menu from the frame
394 m_hMenu
= (WXHMENU
)0;
395 InternalSetMenuBar();
397 else // Set new non NULL menu bar
400 // Can set a menubar several times.
402 if (pMenubar
->GetHMenu())
404 m_hMenu
= pMenubar
->GetHMenu();
408 if (pMenubar
->IsAttached())
411 m_hMenu
= pMenubar
->Create();
416 InternalSetMenuBar();
418 } // end of wxFrame::AttachMenuBar
420 void wxFrame::InternalSetMenuBar()
425 // Set the parent and owner of the menubar to be the frame
427 if (!::WinSetParent(m_hMenu
, m_hFrame
, FALSE
))
429 vError
= ::WinGetLastError(vHabmain
);
430 sError
= wxPMErrorToStr(vError
);
431 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
434 if (!::WinSetOwner(m_hMenu
, m_hFrame
))
436 vError
= ::WinGetLastError(vHabmain
);
437 sError
= wxPMErrorToStr(vError
);
438 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
440 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
441 } // end of wxFrame::InternalSetMenuBar
442 #endif // wxUSE_MENUS_NATIVE
445 // Responds to colour changes, and passes event on to children
447 void wxFrame::OnSysColourChanged(
448 wxSysColourChangedEvent
& rEvent
451 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
455 if (m_frameStatusBar
)
457 wxSysColourChangedEvent vEvent2
;
459 vEvent2
.SetEventObject(m_frameStatusBar
);
460 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
462 #endif //wxUSE_STATUSBAR
465 // Propagate the event to the non-top-level children
467 wxWindow::OnSysColourChanged(rEvent
);
468 } // end of wxFrame::OnSysColourChanged
470 // Pass TRUE to show full screen, FALSE to restore.
471 bool wxFrame::ShowFullScreen(
481 m_bFsIsShowing
= TRUE
;
485 wxToolBar
* pTheToolBar
= GetToolBar();
486 #endif //wxUSE_TOOLBAR
489 wxStatusBar
* pTheStatusBar
= GetStatusBar();
490 #endif //wxUSE_STATUSBAR
496 pTheToolBar
->GetSize(&nDummyWidth
, &m_nFsToolBarHeight
);
497 #endif //wxUSE_TOOLBAR
501 pTheStatusBar
->GetSize(&nDummyWidth
, &m_nFsStatusBarHeight
);
502 #endif //wxUSE_STATUSBAR
506 // Zap the toolbar, menubar, and statusbar
508 if ((lStyle
& wxFULLSCREEN_NOTOOLBAR
) && pTheToolBar
)
510 pTheToolBar
->SetSize(-1,0);
511 pTheToolBar
->Show(FALSE
);
513 #endif //wxUSE_TOOLBAR
515 if (lStyle
& wxFULLSCREEN_NOMENUBAR
)
517 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
518 ::WinSetOwner(m_hMenu
, m_hFrame
);
519 ::WinSendMsg((HWND
)m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
524 // Save the number of fields in the statusbar
526 if ((lStyle
& wxFULLSCREEN_NOSTATUSBAR
) && pTheStatusBar
)
528 m_nFsStatusBarFields
= pTheStatusBar
->GetFieldsCount();
529 SetStatusBar((wxStatusBar
*) NULL
);
530 delete pTheStatusBar
;
533 m_nFsStatusBarFields
= 0;
534 #endif //wxUSE_STATUSBAR
537 // Zap the frame borders
541 // Save the 'normal' window style
543 m_lFsOldWindowStyle
= ::WinQueryWindowULong(m_hFrame
, QWL_STYLE
);
546 // Save the old position, width & height, maximize state
548 m_vFsOldSize
= GetRect();
549 m_bFsIsMaximized
= IsMaximized();
552 // Decide which window style flags to turn off
554 LONG lNewStyle
= m_lFsOldWindowStyle
;
557 if (lStyle
& wxFULLSCREEN_NOBORDER
)
558 lOffFlags
|= FCF_BORDER
;
559 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
560 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
562 lNewStyle
&= (~lOffFlags
);
565 // Change our window style to be compatible with full-screen mode
567 ::WinSetWindowULong((HWND
)m_hFrame
, QWL_STYLE
, (ULONG
)lNewStyle
);
570 // Resize to the size of the desktop
576 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
577 nWidth
= vRect
.xRight
- vRect
.xLeft
;
579 // Rmember OS/2 is backwards!
581 nHeight
= vRect
.yTop
- vRect
.yBottom
;
588 // Now flush the window style cache and actually go full-screen
590 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
599 wxSizeEvent
vEvent( wxSize( nWidth
605 GetEventHandler()->ProcessEvent(vEvent
);
613 m_bFsIsShowing
= FALSE
;
616 wxToolBar
* pTheToolBar
= GetToolBar();
619 // Restore the toolbar, menubar, and statusbar
621 if (pTheToolBar
&& (m_lFsStyle
& wxFULLSCREEN_NOTOOLBAR
))
623 pTheToolBar
->SetSize(-1, m_nFsToolBarHeight
);
624 pTheToolBar
->Show(TRUE
);
626 #endif //wxUSE_TOOLBAR
629 if ((m_lFsStyle
& wxFULLSCREEN_NOSTATUSBAR
) && (m_nFsStatusBarFields
> 0))
631 CreateStatusBar(m_nFsStatusBarFields
);
632 // PositionStatusBar();
634 #endif //wxUSE_STATUSBAR
636 if ((m_lFsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
638 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
639 ::WinSetOwner(m_hMenu
, m_hFrame
);
640 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
642 Maximize(m_bFsIsMaximized
);
644 ::WinSetWindowULong( m_hFrame
646 ,(ULONG
)m_lFsOldWindowStyle
648 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
658 } // end of wxFrame::ShowFullScreen
664 // Default activation behaviour - set the focus for the first child
667 void wxFrame::OnActivate(
668 wxActivateEvent
& rEvent
671 if ( rEvent
.GetActive() )
673 // restore focus to the child which was last focused
674 wxLogTrace(_T("focus"), _T("wxFrame %08x activated."), m_hWnd
);
676 wxWindow
* pParent
= m_pWinLastFocused
? m_pWinLastFocused
->GetParent()
683 wxSetFocusToChild( pParent
690 // Remember the last focused child if it is our child
692 m_pWinLastFocused
= FindFocus();
694 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
696 pNode
= pNode
->GetNext())
698 // FIXME all this is totally bogus - we need to do the same as wxPanel,
699 // but how to do it without duplicating the code?
702 wxWindow
* pChild
= pNode
->GetData();
704 if (!pChild
->IsTopLevel()
706 && !wxDynamicCast(pChild
, wxToolBar
)
707 #endif // wxUSE_TOOLBAR
709 && !wxDynamicCast(pChild
, wxStatusBar
)
710 #endif // wxUSE_STATUSBAR
718 } // end of wxFrame::OnActivate
720 // ----------------------------------------------------------------------------
721 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
722 // from the client area, so the client area is what's really available for the
724 // ----------------------------------------------------------------------------
726 // Checks if there is a toolbar, and returns the first free client position
727 wxPoint
wxFrame::GetClientAreaOrigin() const
729 wxPoint
vPoint(0, 0);
737 GetToolBar()->GetSize( &nWidth
741 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
747 // PM is backwards from windows
751 #endif //wxUSE_TOOLBAR
753 } // end of wxFrame::GetClientAreaOrigin
755 // ----------------------------------------------------------------------------
756 // tool/status bar stuff
757 // ----------------------------------------------------------------------------
761 wxToolBar
* wxFrame::CreateToolBar(
764 , const wxString
& rName
767 if (wxFrameBase::CreateToolBar( lStyle
774 return m_frameToolBar
;
775 } // end of wxFrame::CreateToolBar
777 void wxFrame::PositionToolBar()
782 ::WinQueryWindowRect(GetHwnd(), &vRect
);
790 GetStatusBar()->GetClientSize( &nStatusX
793 // PM is backwards from windows
794 vRect
.yBottom
+= nStatusY
;
796 #endif // wxUSE_STATUSBAR
798 if ( m_frameToolBar
)
803 m_frameToolBar
->GetSize( &nToolbarWidth
807 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
809 nToolbarHeight
= vRect
.yBottom
;
813 nToolbarWidth
= vRect
.xRight
;
817 // Use the 'real' PM position here
819 GetToolBar()->SetSize( 0
823 ,wxSIZE_NO_ADJUSTMENTS
826 } // end of wxFrame::PositionToolBar
827 #endif // wxUSE_TOOLBAR
829 // ----------------------------------------------------------------------------
830 // frame state (iconized/maximized/...)
831 // ----------------------------------------------------------------------------
834 // propagate our state change to all child frames: this allows us to emulate X
835 // Windows behaviour where child frames float independently of the parent one
836 // on the desktop, but are iconized/restored with it
838 void wxFrame::IconizeChildFrames(
842 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
844 pNode
= pNode
->GetNext() )
846 wxWindow
* pWin
= pNode
->GetData();
847 wxFrame
* pFrame
= wxDynamicCast(pWin
, wxFrame
);
850 #if wxUSE_MDI_ARCHITECTURE
851 && !wxDynamicCast(pFrame
, wxMDIChildFrame
)
852 #endif // wxUSE_MDI_ARCHITECTURE
856 // We don't want to restore the child frames which had been
857 // iconized even before we were iconized, so save the child frame
858 // status when iconizing the parent frame and check it when
863 pFrame
->m_bWasMinimized
= pFrame
->IsIconized();
867 // This test works for both iconizing and restoring
869 if (!pFrame
->m_bWasMinimized
)
870 pFrame
->Iconize(bIconize
);
873 } // end of wxFrame::IconizeChildFrames
875 WXHICON
wxFrame::GetDefaultIcon() const
877 return (WXHICON
)(wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
878 : wxDEFAULT_FRAME_ICON
);
880 // ===========================================================================
881 // message processing
882 // ===========================================================================
884 // ---------------------------------------------------------------------------
886 // ---------------------------------------------------------------------------
887 bool wxFrame::OS2TranslateMessage(
892 // try the menu bar accels
894 wxMenuBar
* pMenuBar
= GetMenuBar();
899 #if wxUSE_ACCEL && wxUSE_MENUS_NATIVE
900 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
901 return rAcceleratorTable
.Translate(GetHWND(), pMsg
);
905 } // end of wxFrame::OS2TranslateMessage
907 // ---------------------------------------------------------------------------
908 // our private (non virtual) message handlers
909 // ---------------------------------------------------------------------------
910 bool wxFrame::HandlePaint()
914 if (::WinQueryUpdateRect(GetHWND(), &vRect
))
919 // Icons in PM are the same as "pointers"
924 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
926 hIcon
= (HPOINTER
)m_hDefaultIcon
;
929 // Hold a pointer to the dc so long as the OnPaint() message
930 // is being processed
933 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
936 // Erase background before painting or we get white background
938 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
945 ::WinQueryWindowRect(GetHwnd(), &vRect3
);
947 static const int nIconWidth
= 32;
948 static const int nIconHeight
= 32;
949 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
950 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
952 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
959 if (!wxWindow::HandlePaint())
964 hPS
= ::WinBeginPaint( GetHwnd()
970 ::GpiCreateLogColorTable( hPS
974 ,(LONG
)wxTheColourDatabase
->m_nSize
975 ,(PLONG
)wxTheColourDatabase
->m_palTable
977 ::GpiCreateLogColorTable( hPS
987 ,GetBackgroundColour().GetPixel()
997 // nothing to paint - processed
1001 } // end of wxFrame::HandlePaint
1003 bool wxFrame::HandleSize(
1009 bool bProcessed
= FALSE
;
1015 // Only do it it if we were iconized before, otherwise resizing the
1016 // parent frame has a curious side effect of bringing it under it's
1022 // restore all child frames too
1024 IconizeChildFrames(FALSE
);
1025 (void)SendIconizeEvent(FALSE
);
1032 m_bIconized
= FALSE
;
1037 // Iconize all child frames too
1039 IconizeChildFrames(TRUE
);
1040 (void)SendIconizeEvent();
1048 // forward WM_SIZE to status bar control
1050 #if wxUSE_NATIVE_STATUSBAR
1051 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
1053 wxSizeEvent
vEvent( wxSize( nX
1056 ,m_frameStatusBar
->GetId()
1059 vEvent
.SetEventObject(m_frameStatusBar
);
1060 m_frameStatusBar
->OnSize(vEvent
);
1062 #endif // wxUSE_NATIVE_STATUSBAR
1064 PositionStatusBar();
1067 #endif // wxUSE_TOOLBAR
1069 wxSizeEvent
vEvent( wxSize( nX
1075 vEvent
.SetEventObject(this);
1076 bProcessed
= GetEventHandler()->ProcessEvent(vEvent
);
1080 } // end of wxFrame::HandleSize
1082 bool wxFrame::HandleCommand(
1091 // In case it's e.g. a toolbar.
1093 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
1096 return pWin
->OS2Command( nCmd
1102 // Handle here commands from menus and accelerators
1104 if (nCmd
== CMDSRC_MENU
|| nCmd
== CMDSRC_ACCELERATOR
)
1106 #if wxUSE_MENUS_NATIVE
1107 if (wxCurrentPopupMenu
)
1109 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1111 wxCurrentPopupMenu
= NULL
;
1113 return pPopupMenu
->OS2Command( nCmd
1120 if (ProcessCommand(nId
))
1126 } // end of wxFrame::HandleCommand
1128 bool wxFrame::HandleMenuSelect(
1139 rc
= ::WinSendMsg(hMenu
, MM_QUERYITEM
, MPFROM2SHORT(nItem
, TRUE
), (MPARAM
)&mItem
);
1141 if(rc
&& !(mItem
.afStyle
& (MIS_SUBMENU
| MIS_SEPARATOR
)))
1143 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nItem
);
1145 vEvent
.SetEventObject(this);
1146 GetEventHandler()->ProcessEvent(vEvent
); // return value would be ignored by PM
1150 } // end of wxFrame::HandleMenuSelect
1152 // ---------------------------------------------------------------------------
1153 // Main Frame window proc
1154 // ---------------------------------------------------------------------------
1155 MRESULT EXPENTRY
wxFrameMainWndProc(
1162 MRESULT rc
= (MRESULT
)0;
1163 bool bProcessed
= FALSE
;
1164 wxFrame
* pWnd
= NULL
;
1166 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1169 case WM_QUERYFRAMECTLCOUNT
:
1170 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1172 USHORT uItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1174 rc
= MRFROMSHORT(uItemCount
);
1178 case WM_FORMATFRAME
:
1179 /////////////////////////////////////////////////////////////////////////////////
1180 // Applications that subclass frame controls may find that the frame is already
1181 // subclassed the number of frame controls is variable.
1182 // The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
1183 // subclassed by calling the previous window procedure and modifying its result.
1184 ////////////////////////////////////////////////////////////////////////////////
1194 pSWP
= (PSWP
)PVOIDFROMMP(wParam
);
1195 nItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1196 if(pWnd
->m_frameStatusBar
)
1198 ::WinQueryWindowRect(pWnd
->m_frameStatusBar
->GetHWND(), &vRstb
);
1199 pWnd
->m_frameStatusBar
->GetSize(NULL
, &nHeight
);
1200 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1201 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1203 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1205 vSwpStb
.x
= vRectl
.xLeft
- vRstb
.xLeft
;
1206 vSwpStb
.y
= vRectl
.yBottom
- vRstb
.yBottom
;
1207 vSwpStb
.cx
= vRectl
.xRight
- vRectl
.xLeft
- 1; //?? -1 ??
1208 vSwpStb
.cy
= nHeight
;
1209 vSwpStb
.fl
= SWP_SIZE
|SWP_MOVE
| SWP_SHOW
;
1210 vSwpStb
.hwnd
= pWnd
->m_frameStatusBar
->GetHWND();
1211 vSwpStb
.hwndInsertBehind
= HWND_TOP
;
1213 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1214 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1215 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1216 ::WinMapWindowPoints(HWND_DESKTOP
, pWnd
->m_hFrame
, (PPOINTL
)&vRectl
, 2);
1217 for(i
= 0; i
< nItemCount
; i
++)
1219 if(pWnd
->m_hWnd
&& pSWP
[i
].hwnd
== pWnd
->m_hWnd
)
1221 pSWP
[i
].x
= vRectl
.xLeft
;
1222 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1223 pSWP
[i
].cx
= vRectl
.xRight
- vRectl
.xLeft
;
1224 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- nHeight
;
1225 pSWP
[i
].fl
= SWP_SIZE
| SWP_MOVE
| SWP_SHOW
;
1226 pSWP
[i
].hwndInsertBehind
= HWND_TOP
;
1230 rc
= MRFROMSHORT(nItemCount
);
1235 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1236 rc
= pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
);
1238 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1241 } // end of wxFrameMainWndProc
1243 MRESULT EXPENTRY
wxFrameWndProc(
1251 // Trace all ulMsgs - useful for the debugging
1254 wxFrame
* pWnd
= NULL
;
1256 parentHwnd
= WinQueryWindow(hWnd
,QW_PARENT
);
1257 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1260 // When we get the first message for the HWND we just created, we associate
1261 // it with wxWindow stored in wxWndHook
1264 MRESULT rc
= (MRESULT
)0;
1265 bool bProcessed
= FALSE
;
1268 // Stop right here if we don't have a valid handle in our wxWindow object.
1270 if (pWnd
&& !pWnd
->GetHWND())
1272 pWnd
->SetHWND((WXHWND
) hWnd
);
1273 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
1279 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
1281 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1284 } // end of wxFrameWndProc
1286 MRESULT
wxFrame::OS2WindowProc(
1293 bool bProcessed
= FALSE
;
1299 // If we can't close, tell the system that we processed the
1300 // message - otherwise it would close us
1302 bProcessed
= !Close();
1306 bProcessed
= HandlePaint();
1307 mRc
= (MRESULT
)FALSE
;
1310 case WM_ERASEBACKGROUND
:
1312 // Returning TRUE to requests PM to paint the window background
1313 // in SYSCLR_WINDOW. We capture this here because the PS returned
1314 // in Frames is the PS for the whole frame, which we can't really
1315 // use at all. If you want to paint a different background, do it
1316 // in an OnPaint using a wxPaintDC.
1318 mRc
= (MRESULT
)(TRUE
);
1327 UnpackCommand( (WXWPARAM
)wParam
1334 bProcessed
= HandleCommand( wId
1347 UnpackMenuSelect( wParam
1353 bProcessed
= HandleMenuSelect( wItem
1357 mRc
= (MRESULT
)TRUE
;
1363 SHORT nScxold
= SHORT1FROMMP(wParam
); // Old horizontal size.
1364 SHORT nScyold
= SHORT2FROMMP(wParam
); // Old vertical size.
1365 SHORT nScxnew
= SHORT1FROMMP(lParam
); // New horizontal size.
1366 SHORT nScynew
= SHORT2FROMMP(lParam
); // New vertical size.
1368 lParam
= MRFROM2SHORT( nScxnew
- 20
1372 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1373 mRc
= (MRESULT
)FALSE
;
1376 case CM_QUERYDRAGIMAGE
:
1381 hIcon
= (HPOINTER
)::WinSendMsg(GetHWND(), WM_QUERYICON
, 0L, 0L);
1383 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1384 mRc
= (MRESULT
)hIcon
;
1385 bProcessed
= mRc
!= 0;
1391 mRc
= wxWindow::OS2WindowProc( uMessage
1395 return (MRESULT
)mRc
;
1396 } // wxFrame::OS2WindowProc
1398 void wxFrame::SetClient(WXHWND c_Hwnd
)
1400 // Duh...nothing to do under OS/2
1403 void wxFrame::SetClient(
1407 wxWindow
* pOldClient
= this->GetClient();
1408 bool bClientHasFocus
= pOldClient
&& (pOldClient
== wxWindow::FindFocus());
1410 if(pOldClient
== pWindow
) // nothing to do
1412 if(pWindow
== NULL
) // just need to remove old client
1414 if(pOldClient
== NULL
) // nothing to do
1417 if(bClientHasFocus
)
1420 pOldClient
->Enable( FALSE
);
1421 pOldClient
->Show( FALSE
);
1422 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1423 // to avoid OS/2 bug need to update frame
1424 ::WinSendMsg((HWND
)this->GetFrame(), WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1429 // Else need to change client
1434 ::WinEnableWindowUpdate((HWND
)GetHWND(), FALSE
);
1437 pOldClient
->Enable(FALSE
);
1438 pOldClient
->Show(FALSE
);
1439 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1441 pWindow
->Reparent(this);
1442 ::WinSetWindowUShort(pWindow
->GetHWND(), QWS_ID
, FID_CLIENT
);
1443 ::WinEnableWindowUpdate((HWND
)GetHWND(), TRUE
);
1445 pWindow
->Show(); // ensure client is showing
1446 if( this->IsShown() )
1449 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1453 wxWindow
* wxFrame::GetClient()
1455 return wxFindWinFromHandle((WXHWND
)::WinWindowFromID(m_hFrame
, FID_CLIENT
));