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"
36 #include "wx/os2/private.h"
39 #include "wx/statusbr.h"
40 #include "wx/generic/statusbr.h"
41 #endif // wxUSE_STATUSBAR
44 #include "wx/toolbar.h"
45 #endif // wxUSE_TOOLBAR
47 #include "wx/menuitem.h"
50 // ----------------------------------------------------------------------------
52 // ----------------------------------------------------------------------------
54 extern wxWindowList wxModelessWindows
;
55 extern wxList WXDLLEXPORT wxPendingDelete
;
57 #if wxUSE_MENUS_NATIVE
58 extern wxMenu
*wxCurrentPopupMenu
;
61 extern void wxAssociateWinWithHandle( HWND hWnd
65 // ----------------------------------------------------------------------------
67 // ----------------------------------------------------------------------------
69 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
70 EVT_ACTIVATE(wxFrame::OnActivate
)
71 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
74 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
76 // ============================================================================
78 // ============================================================================
80 // ----------------------------------------------------------------------------
81 // static class members
82 // ----------------------------------------------------------------------------
85 #if wxUSE_NATIVE_STATUSBAR
86 bool wxFrame::m_bUseNativeStatusBar
= TRUE
;
88 bool wxFrame::m_bUseNativeStatusBar
= FALSE
;
91 #endif //wxUSE_STATUSBAR
93 // ----------------------------------------------------------------------------
94 // creation/destruction
95 // ----------------------------------------------------------------------------
99 m_nFsStatusBarFields
= 0;
100 m_nFsStatusBarHeight
= 0;
101 m_nFsToolBarHeight
= 0;
103 m_bWasMinimized
= FALSE
;
104 m_pWinLastFocused
= NULL
;
107 m_frameMenuBar
= NULL
;
108 m_frameToolBar
= NULL
;
109 m_frameStatusBar
= NULL
;
111 m_hTitleBar
= NULLHANDLE
;
112 m_hHScroll
= NULLHANDLE
;
113 m_hVScroll
= NULLHANDLE
;
118 memset(&m_vSwpTitleBar
, 0, sizeof(SWP
));
119 memset(&m_vSwpMenuBar
, 0, sizeof(SWP
));
120 memset(&m_vSwpHScroll
, 0, sizeof(SWP
));
121 memset(&m_vSwpVScroll
, 0, sizeof(SWP
));
122 memset(&m_vSwpStatusBar
, 0, sizeof(SWP
));
123 memset(&m_vSwpToolBar
, 0, sizeof(SWP
));
126 } // end of wxFrame::Init
128 bool wxFrame::Create(
131 , const wxString
& rsTitle
132 , const wxPoint
& rPos
133 , const wxSize
& rSize
135 , const wxString
& rsName
138 if (!wxTopLevelWindow::Create( pParent
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()
214 wxStatusBar
* wxFrame::OnCreateStatusBar(
218 , const wxString
& rName
221 wxStatusBar
* pStatusBar
= NULL
;
226 pStatusBar
= wxFrameBase::OnCreateStatusBar( nNumber
235 wxClientDC
vDC(pStatusBar
);
239 // Set the height according to the font and the border size
241 vDC
.SetFont(pStatusBar
->GetFont()); // Screws up the menues for some reason
242 vDC
.GetTextExtent( "X"
247 int nHeight
= ((11 * nY
) / 10 + 2 * pStatusBar
->GetBorderY());
249 pStatusBar
->SetSize( -1
255 ::WinSetParent( pStatusBar
->GetHWND()
259 ::WinSetOwner( pStatusBar
->GetHWND()
265 if(::WinIsWindowShowing(m_hFrame
))
266 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
269 } // end of wxFrame::OnCreateStatusBar
271 void wxFrame::PositionStatusBar()
278 // Native status bar positions itself
280 if (m_frameStatusBar
)
290 ::WinQueryWindowRect(m_hFrame
, &vRect
);
292 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
294 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
295 nWidth
= vRect
.xRight
- vRect
.xLeft
;
296 nY
= nY
- (vRect
.yBottom
- vFRect
.yBottom
);
298 m_frameStatusBar
->GetSize( &nStatbarWidth
302 nY
= nY
- nStatbarHeight
;
304 // Since we wish the status bar to be directly under the client area,
305 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
307 m_frameStatusBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
312 if (!::WinQueryWindowPos(m_frameStatusBar
->GetHWND(), &vSwp
))
314 vError
= ::WinGetLastError(vHabmain
);
315 sError
= wxPMErrorToStr(vError
);
316 wxLogError("Error setting parent for StautsBar. Error: %s\n", sError
);
320 } // end of wxFrame::PositionStatusBar
321 #endif // wxUSE_STATUSBAR
323 #if wxUSE_MENUS_NATIVE
324 void wxFrame::DetachMenuBar()
328 m_frameMenuBar
->Detach();
329 m_frameMenuBar
= NULL
;
331 } // end of wxFrame::DetachMenuBar
333 void wxFrame::SetMenuBar(
339 HWND hTitlebar
= NULLHANDLE
;
340 HWND hHScroll
= NULLHANDLE
;
341 HWND hVScroll
= NULLHANDLE
;
342 HWND hMenuBar
= NULLHANDLE
;
354 // Actually remove the menu from the frame
356 m_hMenu
= (WXHMENU
)0;
357 InternalSetMenuBar();
359 else // set new non NULL menu bar
361 m_frameMenuBar
= NULL
;
364 // Can set a menubar several times.
365 // TODO: how to prevent a memory leak if you have a currently-unattached
366 // menubar? wxWindows assumes that the frame will delete the menu (otherwise
367 // there are problems for MDI).
369 if (pMenuBar
->GetHMenu())
371 m_hMenu
= pMenuBar
->GetHMenu();
376 m_hMenu
= pMenuBar
->Create();
380 InternalSetMenuBar();
381 m_frameMenuBar
= pMenuBar
;
382 pMenuBar
->Attach((wxFrame
*)this);
384 } // end of wxFrame::SetMenuBar
386 void wxFrame::AttachMenuBar(
390 wxFrameBase::AttachMenuBar(pMenubar
);
392 m_frameMenuBar
= pMenubar
;
397 // Actually remove the menu from the frame
399 m_hMenu
= (WXHMENU
)0;
400 InternalSetMenuBar();
402 else // Set new non NULL menu bar
405 // Can set a menubar several times.
407 if (pMenubar
->GetHMenu())
409 m_hMenu
= pMenubar
->GetHMenu();
413 if (pMenubar
->IsAttached())
416 m_hMenu
= pMenubar
->Create();
421 InternalSetMenuBar();
423 } // end of wxFrame::AttachMenuBar
425 void wxFrame::InternalSetMenuBar()
430 // Set the parent and owner of the menubar to be the frame
432 if (!::WinSetParent(m_hMenu
, m_hFrame
, FALSE
))
434 vError
= ::WinGetLastError(vHabmain
);
435 sError
= wxPMErrorToStr(vError
);
436 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
439 if (!::WinSetOwner(m_hMenu
, m_hFrame
))
441 vError
= ::WinGetLastError(vHabmain
);
442 sError
= wxPMErrorToStr(vError
);
443 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
445 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
446 } // end of wxFrame::InternalSetMenuBar
447 #endif // wxUSE_MENUS_NATIVE
450 // Responds to colour changes, and passes event on to children
452 void wxFrame::OnSysColourChanged(
453 wxSysColourChangedEvent
& rEvent
456 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
460 if (m_frameStatusBar
)
462 wxSysColourChangedEvent vEvent2
;
464 vEvent2
.SetEventObject(m_frameStatusBar
);
465 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
467 #endif //wxUSE_STATUSBAR
470 // Propagate the event to the non-top-level children
472 wxWindow::OnSysColourChanged(rEvent
);
473 } // end of wxFrame::OnSysColourChanged
475 // Pass TRUE to show full screen, FALSE to restore.
476 bool wxFrame::ShowFullScreen(
486 m_bFsIsShowing
= TRUE
;
490 wxToolBar
* pTheToolBar
= GetToolBar();
491 #endif //wxUSE_TOOLBAR
494 wxStatusBar
* pTheStatusBar
= GetStatusBar();
495 #endif //wxUSE_STATUSBAR
501 pTheToolBar
->GetSize(&nDummyWidth
, &m_nFsToolBarHeight
);
502 #endif //wxUSE_TOOLBAR
506 pTheStatusBar
->GetSize(&nDummyWidth
, &m_nFsStatusBarHeight
);
507 #endif //wxUSE_STATUSBAR
511 // Zap the toolbar, menubar, and statusbar
513 if ((lStyle
& wxFULLSCREEN_NOTOOLBAR
) && pTheToolBar
)
515 pTheToolBar
->SetSize(-1,0);
516 pTheToolBar
->Show(FALSE
);
518 #endif //wxUSE_TOOLBAR
520 if (lStyle
& wxFULLSCREEN_NOMENUBAR
)
522 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
523 ::WinSetOwner(m_hMenu
, m_hFrame
);
524 ::WinSendMsg((HWND
)m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
529 // Save the number of fields in the statusbar
531 if ((lStyle
& wxFULLSCREEN_NOSTATUSBAR
) && pTheStatusBar
)
533 m_nFsStatusBarFields
= pTheStatusBar
->GetFieldsCount();
534 SetStatusBar((wxStatusBar
*) NULL
);
535 delete pTheStatusBar
;
538 m_nFsStatusBarFields
= 0;
539 #endif //wxUSE_STATUSBAR
542 // Zap the frame borders
546 // Save the 'normal' window style
548 m_lFsOldWindowStyle
= ::WinQueryWindowULong(m_hFrame
, QWL_STYLE
);
551 // Save the old position, width & height, maximize state
553 m_vFsOldSize
= GetRect();
554 m_bFsIsMaximized
= IsMaximized();
557 // Decide which window style flags to turn off
559 LONG lNewStyle
= m_lFsOldWindowStyle
;
562 if (lStyle
& wxFULLSCREEN_NOBORDER
)
563 lOffFlags
|= FCF_BORDER
;
564 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
565 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
567 lNewStyle
&= (~lOffFlags
);
570 // Change our window style to be compatible with full-screen mode
572 ::WinSetWindowULong((HWND
)m_hFrame
, QWL_STYLE
, (ULONG
)lNewStyle
);
575 // Resize to the size of the desktop
581 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
582 nWidth
= vRect
.xRight
- vRect
.xLeft
;
584 // Rmember OS/2 is backwards!
586 nHeight
= vRect
.yTop
- vRect
.yBottom
;
593 // Now flush the window style cache and actually go full-screen
595 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
604 wxSizeEvent
vEvent( wxSize( nWidth
610 GetEventHandler()->ProcessEvent(vEvent
);
618 m_bFsIsShowing
= FALSE
;
621 wxToolBar
* pTheToolBar
= GetToolBar();
624 // Restore the toolbar, menubar, and statusbar
626 if (pTheToolBar
&& (m_lFsStyle
& wxFULLSCREEN_NOTOOLBAR
))
628 pTheToolBar
->SetSize(-1, m_nFsToolBarHeight
);
629 pTheToolBar
->Show(TRUE
);
631 #endif //wxUSE_TOOLBAR
634 if ((m_lFsStyle
& wxFULLSCREEN_NOSTATUSBAR
) && (m_nFsStatusBarFields
> 0))
636 CreateStatusBar(m_nFsStatusBarFields
);
637 // PositionStatusBar();
639 #endif //wxUSE_STATUSBAR
641 if ((m_lFsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
643 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
644 ::WinSetOwner(m_hMenu
, m_hFrame
);
645 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
647 Maximize(m_bFsIsMaximized
);
649 ::WinSetWindowULong( m_hFrame
651 ,(ULONG
)m_lFsOldWindowStyle
653 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
663 } // end of wxFrame::ShowFullScreen
669 // Default activation behaviour - set the focus for the first child
672 void wxFrame::OnActivate(
673 wxActivateEvent
& rEvent
676 if ( rEvent
.GetActive() )
678 // restore focus to the child which was last focused
679 wxLogTrace(_T("focus"), _T("wxFrame %08x activated."), m_hWnd
);
681 wxWindow
* pParent
= m_pWinLastFocused
? m_pWinLastFocused
->GetParent()
688 wxSetFocusToChild( pParent
695 // Remember the last focused child if it is our child
697 m_pWinLastFocused
= FindFocus();
699 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
701 pNode
= pNode
->GetNext())
703 // FIXME all this is totally bogus - we need to do the same as wxPanel,
704 // but how to do it without duplicating the code?
707 wxWindow
* pChild
= pNode
->GetData();
709 if (!pChild
->IsTopLevel()
711 && !wxDynamicCast(pChild
, wxToolBar
)
712 #endif // wxUSE_TOOLBAR
714 && !wxDynamicCast(pChild
, wxStatusBar
)
715 #endif // wxUSE_STATUSBAR
723 } // end of wxFrame::OnActivate
725 // ----------------------------------------------------------------------------
726 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
727 // from the client area, so the client area is what's really available for the
729 // ----------------------------------------------------------------------------
731 // Checks if there is a toolbar, and returns the first free client position
732 wxPoint
wxFrame::GetClientAreaOrigin() const
734 wxPoint
vPoint(0, 0);
742 GetToolBar()->GetSize( &nWidth
746 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
752 // PM is backwards from windows
756 #endif //wxUSE_TOOLBAR
758 } // end of wxFrame::GetClientAreaOrigin
760 // ----------------------------------------------------------------------------
761 // tool/status bar stuff
762 // ----------------------------------------------------------------------------
766 wxToolBar
* wxFrame::CreateToolBar(
769 , const wxString
& rName
772 if (wxFrameBase::CreateToolBar( lStyle
779 return m_frameToolBar
;
780 } // end of wxFrame::CreateToolBar
782 void wxFrame::PositionToolBar()
787 ::WinQueryWindowRect(GetHwnd(), &vRect
);
795 GetStatusBar()->GetClientSize( &nStatusX
798 // PM is backwards from windows
799 vRect
.yBottom
+= nStatusY
;
801 #endif // wxUSE_STATUSBAR
803 if ( m_frameToolBar
)
808 m_frameToolBar
->GetSize( &nToolbarWidth
812 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
814 nToolbarHeight
= vRect
.yBottom
;
818 nToolbarWidth
= vRect
.xRight
;
822 // Use the 'real' PM position here
824 GetToolBar()->SetSize( 0
828 ,wxSIZE_NO_ADJUSTMENTS
831 } // end of wxFrame::PositionToolBar
832 #endif // wxUSE_TOOLBAR
834 // ----------------------------------------------------------------------------
835 // frame state (iconized/maximized/...)
836 // ----------------------------------------------------------------------------
839 // propagate our state change to all child frames: this allows us to emulate X
840 // Windows behaviour where child frames float independently of the parent one
841 // on the desktop, but are iconized/restored with it
843 void wxFrame::IconizeChildFrames(
847 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
849 pNode
= pNode
->GetNext() )
851 wxWindow
* pWin
= pNode
->GetData();
852 wxFrame
* pFrame
= wxDynamicCast(pWin
, wxFrame
);
855 #if wxUSE_MDI_ARCHITECTURE
856 && !wxDynamicCast(pFrame
, wxMDIChildFrame
)
857 #endif // wxUSE_MDI_ARCHITECTURE
861 // We don't want to restore the child frames which had been
862 // iconized even before we were iconized, so save the child frame
863 // status when iconizing the parent frame and check it when
868 pFrame
->m_bWasMinimized
= pFrame
->IsIconized();
872 // This test works for both iconizing and restoring
874 if (!pFrame
->m_bWasMinimized
)
875 pFrame
->Iconize(bIconize
);
878 } // end of wxFrame::IconizeChildFrames
880 WXHICON
wxFrame::GetDefaultIcon() const
882 return (WXHICON
)(wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
883 : wxDEFAULT_FRAME_ICON
);
885 // ===========================================================================
886 // message processing
887 // ===========================================================================
889 // ---------------------------------------------------------------------------
891 // ---------------------------------------------------------------------------
892 bool wxFrame::OS2TranslateMessage(
897 // try the menu bar accels
899 wxMenuBar
* pMenuBar
= GetMenuBar();
904 #if wxUSE_ACCEL && wxUSE_MENUS_NATIVE
905 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
906 return rAcceleratorTable
.Translate(GetHWND(), pMsg
);
910 } // end of wxFrame::OS2TranslateMessage
912 // ---------------------------------------------------------------------------
913 // our private (non virtual) message handlers
914 // ---------------------------------------------------------------------------
915 bool wxFrame::HandlePaint()
919 if (::WinQueryUpdateRect(GetHWND(), &vRect
))
924 // Icons in PM are the same as "pointers"
929 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
931 hIcon
= (HPOINTER
)m_hDefaultIcon
;
934 // Hold a pointer to the dc so long as the OnPaint() message
935 // is being processed
938 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
941 // Erase background before painting or we get white background
943 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
950 ::WinQueryWindowRect(GetHwnd(), &vRect3
);
952 static const int nIconWidth
= 32;
953 static const int nIconHeight
= 32;
954 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
955 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
957 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
964 if (!wxWindow::HandlePaint())
969 hPS
= ::WinBeginPaint( GetHwnd()
975 ::GpiCreateLogColorTable( hPS
979 ,(LONG
)wxTheColourDatabase
->m_nSize
980 ,(PLONG
)wxTheColourDatabase
->m_palTable
982 ::GpiCreateLogColorTable( hPS
992 ,GetBackgroundColour().GetPixel()
1002 // nothing to paint - processed
1006 } // end of wxFrame::HandlePaint
1008 bool wxFrame::HandleSize(
1014 bool bProcessed
= FALSE
;
1020 // Only do it it if we were iconized before, otherwise resizing the
1021 // parent frame has a curious side effect of bringing it under it's
1027 // restore all child frames too
1029 IconizeChildFrames(FALSE
);
1030 (void)SendIconizeEvent(FALSE
);
1037 m_bIconized
= FALSE
;
1042 // Iconize all child frames too
1044 IconizeChildFrames(TRUE
);
1045 (void)SendIconizeEvent();
1053 // forward WM_SIZE to status bar control
1055 #if wxUSE_NATIVE_STATUSBAR
1056 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
1058 wxSizeEvent
vEvent( wxSize( nX
1061 ,m_frameStatusBar
->GetId()
1064 vEvent
.SetEventObject(m_frameStatusBar
);
1065 m_frameStatusBar
->OnSize(vEvent
);
1067 #endif // wxUSE_NATIVE_STATUSBAR
1069 PositionStatusBar();
1072 #endif // wxUSE_TOOLBAR
1074 wxSizeEvent
vEvent( wxSize( nX
1080 vEvent
.SetEventObject(this);
1081 bProcessed
= GetEventHandler()->ProcessEvent(vEvent
);
1084 } // end of wxFrame::HandleSize
1086 bool wxFrame::HandleCommand(
1095 // In case it's e.g. a toolbar.
1097 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
1100 return pWin
->OS2Command( nCmd
1106 // Handle here commands from menus and accelerators
1108 if (nCmd
== CMDSRC_MENU
|| nCmd
== CMDSRC_ACCELERATOR
)
1110 #if wxUSE_MENUS_NATIVE
1111 if (wxCurrentPopupMenu
)
1113 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1115 wxCurrentPopupMenu
= NULL
;
1117 return pPopupMenu
->OS2Command( nCmd
1124 if (ProcessCommand(nId
))
1130 } // end of wxFrame::HandleCommand
1132 bool wxFrame::HandleMenuSelect(
1143 rc
= ::WinSendMsg(hMenu
, MM_QUERYITEM
, MPFROM2SHORT(nItem
, TRUE
), (MPARAM
)&mItem
);
1145 if(rc
&& !(mItem
.afStyle
& (MIS_SUBMENU
| MIS_SEPARATOR
)))
1147 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nItem
);
1149 vEvent
.SetEventObject(this);
1150 GetEventHandler()->ProcessEvent(vEvent
); // return value would be ignored by PM
1154 } // end of wxFrame::HandleMenuSelect
1156 // ---------------------------------------------------------------------------
1157 // Main Frame window proc
1158 // ---------------------------------------------------------------------------
1159 MRESULT EXPENTRY
wxFrameMainWndProc(
1166 MRESULT rc
= (MRESULT
)0;
1167 bool bProcessed
= FALSE
;
1168 wxFrame
* pWnd
= NULL
;
1170 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1173 case WM_QUERYFRAMECTLCOUNT
:
1174 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1176 USHORT uItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1178 rc
= MRFROMSHORT(uItemCount
);
1182 case WM_FORMATFRAME
:
1183 /////////////////////////////////////////////////////////////////////////////////
1184 // Applications that subclass frame controls may find that the frame is already
1185 // subclassed the number of frame controls is variable.
1186 // The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
1187 // subclassed by calling the previous window procedure and modifying its result.
1188 ////////////////////////////////////////////////////////////////////////////////
1198 pSWP
= (PSWP
)PVOIDFROMMP(wParam
);
1199 nItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1200 if(pWnd
->m_frameStatusBar
)
1202 ::WinQueryWindowRect(pWnd
->m_frameStatusBar
->GetHWND(), &vRstb
);
1203 pWnd
->m_frameStatusBar
->GetSize(NULL
, &nHeight
);
1204 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1205 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1207 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1209 vSwpStb
.x
= vRectl
.xLeft
- vRstb
.xLeft
;
1210 vSwpStb
.y
= vRectl
.yBottom
- vRstb
.yBottom
;
1211 vSwpStb
.cx
= vRectl
.xRight
- vRectl
.xLeft
- 1; //?? -1 ??
1212 vSwpStb
.cy
= nHeight
;
1213 vSwpStb
.fl
= SWP_SIZE
|SWP_MOVE
| SWP_SHOW
;
1214 vSwpStb
.hwnd
= pWnd
->m_frameStatusBar
->GetHWND();
1215 vSwpStb
.hwndInsertBehind
= HWND_TOP
;
1217 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1218 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1219 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1220 ::WinMapWindowPoints(HWND_DESKTOP
, pWnd
->m_hFrame
, (PPOINTL
)&vRectl
, 2);
1221 for(i
= 0; i
< nItemCount
; i
++)
1223 if(pWnd
->m_hWnd
&& pSWP
[i
].hwnd
== pWnd
->m_hWnd
)
1225 pSWP
[i
].x
= vRectl
.xLeft
;
1226 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1227 pSWP
[i
].cx
= vRectl
.xRight
- vRectl
.xLeft
;
1228 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- nHeight
;
1229 pSWP
[i
].fl
= SWP_SIZE
| SWP_MOVE
| SWP_SHOW
;
1230 pSWP
[i
].hwndInsertBehind
= HWND_TOP
;
1234 rc
= MRFROMSHORT(nItemCount
);
1239 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1240 rc
= pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
);
1242 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1245 } // end of wxFrameMainWndProc
1247 MRESULT EXPENTRY
wxFrameWndProc(
1255 // Trace all ulMsgs - useful for the debugging
1258 wxFrame
* pWnd
= NULL
;
1260 parentHwnd
= WinQueryWindow(hWnd
,QW_PARENT
);
1261 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1264 // When we get the first message for the HWND we just created, we associate
1265 // it with wxWindow stored in wxWndHook
1268 MRESULT rc
= (MRESULT
)0;
1269 bool bProcessed
= FALSE
;
1272 // Stop right here if we don't have a valid handle in our wxWindow object.
1274 if (pWnd
&& !pWnd
->GetHWND())
1276 pWnd
->SetHWND((WXHWND
) hWnd
);
1277 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
1283 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
1285 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1288 } // end of wxFrameWndProc
1290 MRESULT
wxFrame::OS2WindowProc(
1297 bool bProcessed
= FALSE
;
1303 // If we can't close, tell the system that we processed the
1304 // message - otherwise it would close us
1306 bProcessed
= !Close();
1310 bProcessed
= HandlePaint();
1311 mRc
= (MRESULT
)FALSE
;
1314 case WM_ERASEBACKGROUND
:
1316 // Returning TRUE to requests PM to paint the window background
1317 // in SYSCLR_WINDOW. We capture this here because the PS returned
1318 // in Frames is the PS for the whole frame, which we can't really
1319 // use at all. If you want to paint a different background, do it
1320 // in an OnPaint using a wxPaintDC.
1322 mRc
= (MRESULT
)(TRUE
);
1331 UnpackCommand( (WXWPARAM
)wParam
1338 bProcessed
= HandleCommand( wId
1351 UnpackMenuSelect( wParam
1357 bProcessed
= HandleMenuSelect( wItem
1361 mRc
= (MRESULT
)TRUE
;
1367 SHORT nScxold
= SHORT1FROMMP(wParam
); // Old horizontal size.
1368 SHORT nScyold
= SHORT2FROMMP(wParam
); // Old vertical size.
1369 SHORT nScxnew
= SHORT1FROMMP(lParam
); // New horizontal size.
1370 SHORT nScynew
= SHORT2FROMMP(lParam
); // New vertical size.
1372 lParam
= MRFROM2SHORT( nScxnew
- 20
1376 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1377 mRc
= (MRESULT
)FALSE
;
1380 case CM_QUERYDRAGIMAGE
:
1385 hIcon
= (HPOINTER
)::WinSendMsg(GetHWND(), WM_QUERYICON
, 0L, 0L);
1387 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1388 mRc
= (MRESULT
)hIcon
;
1389 bProcessed
= mRc
!= 0;
1395 mRc
= wxWindow::OS2WindowProc( uMessage
1399 return (MRESULT
)mRc
;
1400 } // wxFrame::OS2WindowProc
1402 void wxFrame::SetClient(WXHWND c_Hwnd
)
1404 // Duh...nothing to do under OS/2
1407 void wxFrame::SetClient(
1411 wxWindow
* pOldClient
= this->GetClient();
1412 bool bClientHasFocus
= pOldClient
&& (pOldClient
== wxWindow::FindFocus());
1414 if(pOldClient
== pWindow
) // nothing to do
1416 if(pWindow
== NULL
) // just need to remove old client
1418 if(pOldClient
== NULL
) // nothing to do
1421 if(bClientHasFocus
)
1424 pOldClient
->Enable( FALSE
);
1425 pOldClient
->Show( FALSE
);
1426 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1427 // to avoid OS/2 bug need to update frame
1428 ::WinSendMsg((HWND
)this->GetFrame(), WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1433 // Else need to change client
1438 ::WinEnableWindowUpdate((HWND
)GetHWND(), FALSE
);
1441 pOldClient
->Enable(FALSE
);
1442 pOldClient
->Show(FALSE
);
1443 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1445 pWindow
->Reparent(this);
1446 ::WinSetWindowUShort(pWindow
->GetHWND(), QWS_ID
, FID_CLIENT
);
1447 ::WinEnableWindowUpdate((HWND
)GetHWND(), TRUE
);
1449 pWindow
->Show(); // ensure client is showing
1450 if( this->IsShown() )
1453 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1457 wxWindow
* wxFrame::GetClient()
1459 return wxFindWinFromHandle((WXHWND
)::WinWindowFromID(m_hFrame
, FID_CLIENT
));