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"
926 const wxIcon
& vIcon
= GetIcon();
930 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
932 hIcon
= (HPOINTER
)m_hDefaultIcon
;
935 // Hold a pointer to the dc so long as the OnPaint() message
936 // is being processed
939 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
942 // Erase background before painting or we get white background
944 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
951 ::WinQueryWindowRect(GetHwnd(), &vRect3
);
953 static const int nIconWidth
= 32;
954 static const int nIconHeight
= 32;
955 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
956 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
958 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
965 if (!wxWindow::HandlePaint())
970 hPS
= ::WinBeginPaint( GetHwnd()
976 ::GpiCreateLogColorTable( hPS
980 ,(LONG
)wxTheColourDatabase
->m_nSize
981 ,(PLONG
)wxTheColourDatabase
->m_palTable
983 ::GpiCreateLogColorTable( hPS
993 ,GetBackgroundColour().GetPixel()
1003 // nothing to paint - processed
1007 } // end of wxFrame::HandlePaint
1009 bool wxFrame::HandleSize(
1015 bool bProcessed
= FALSE
;
1021 // Only do it it if we were iconized before, otherwise resizing the
1022 // parent frame has a curious side effect of bringing it under it's
1028 // restore all child frames too
1030 IconizeChildFrames(FALSE
);
1031 (void)SendIconizeEvent(FALSE
);
1038 m_bIconized
= FALSE
;
1043 // Iconize all child frames too
1045 IconizeChildFrames(TRUE
);
1046 (void)SendIconizeEvent();
1054 // forward WM_SIZE to status bar control
1056 #if wxUSE_NATIVE_STATUSBAR
1057 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
1059 wxSizeEvent
vEvent( wxSize( nX
1062 ,m_frameStatusBar
->GetId()
1065 vEvent
.SetEventObject(m_frameStatusBar
);
1066 m_frameStatusBar
->OnSize(vEvent
);
1068 #endif // wxUSE_NATIVE_STATUSBAR
1070 PositionStatusBar();
1073 #endif // wxUSE_TOOLBAR
1075 bProcessed
= wxWindow::HandleSize( nX
1081 } // end of wxFrame::HandleSize
1083 bool wxFrame::HandleCommand(
1092 // In case it's e.g. a toolbar.
1094 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
1097 return pWin
->OS2Command( nCmd
1103 // Handle here commands from menus and accelerators
1105 if (nCmd
== CMDSRC_MENU
|| nCmd
== CMDSRC_ACCELERATOR
)
1107 #if wxUSE_MENUS_NATIVE
1108 if (wxCurrentPopupMenu
)
1110 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1112 wxCurrentPopupMenu
= NULL
;
1114 return pPopupMenu
->OS2Command( nCmd
1121 if (ProcessCommand(nId
))
1127 } // end of wxFrame::HandleCommand
1129 bool wxFrame::HandleMenuSelect(
1140 rc
= ::WinSendMsg(hMenu
, MM_QUERYITEM
, MPFROM2SHORT(nItem
, TRUE
), (MPARAM
)&mItem
);
1142 if(rc
&& !(mItem
.afStyle
& (MIS_SUBMENU
| MIS_SEPARATOR
)))
1144 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nItem
);
1146 vEvent
.SetEventObject(this);
1147 GetEventHandler()->ProcessEvent(vEvent
); // return value would be ignored by PM
1151 DoGiveHelp(wxEmptyString
, FALSE
);
1156 } // end of wxFrame::HandleMenuSelect
1158 // ---------------------------------------------------------------------------
1159 // Main Frame window proc
1160 // ---------------------------------------------------------------------------
1161 MRESULT EXPENTRY
wxFrameMainWndProc(
1168 MRESULT rc
= (MRESULT
)0;
1169 bool bProcessed
= FALSE
;
1170 wxFrame
* pWnd
= NULL
;
1172 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1175 case WM_QUERYFRAMECTLCOUNT
:
1176 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1178 USHORT uItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1180 rc
= MRFROMSHORT(uItemCount
);
1184 case WM_FORMATFRAME
:
1185 /////////////////////////////////////////////////////////////////////////////////
1186 // Applications that subclass frame controls may find that the frame is already
1187 // subclassed the number of frame controls is variable.
1188 // The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
1189 // subclassed by calling the previous window procedure and modifying its result.
1190 ////////////////////////////////////////////////////////////////////////////////
1200 pSWP
= (PSWP
)PVOIDFROMMP(wParam
);
1201 nItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1202 if(pWnd
->m_frameStatusBar
)
1204 ::WinQueryWindowRect(pWnd
->m_frameStatusBar
->GetHWND(), &vRstb
);
1205 pWnd
->m_frameStatusBar
->GetSize(NULL
, &nHeight
);
1206 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1207 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1209 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1211 vSwpStb
.x
= vRectl
.xLeft
- vRstb
.xLeft
;
1212 vSwpStb
.y
= vRectl
.yBottom
- vRstb
.yBottom
;
1213 vSwpStb
.cx
= vRectl
.xRight
- vRectl
.xLeft
- 1; //?? -1 ??
1214 vSwpStb
.cy
= nHeight
;
1215 vSwpStb
.fl
= SWP_SIZE
|SWP_MOVE
| SWP_SHOW
;
1216 vSwpStb
.hwnd
= pWnd
->m_frameStatusBar
->GetHWND();
1217 vSwpStb
.hwndInsertBehind
= HWND_TOP
;
1219 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1220 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1221 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1222 ::WinMapWindowPoints(HWND_DESKTOP
, pWnd
->m_hFrame
, (PPOINTL
)&vRectl
, 2);
1223 for(i
= 0; i
< nItemCount
; i
++)
1225 if(pWnd
->m_hWnd
&& pSWP
[i
].hwnd
== pWnd
->m_hWnd
)
1227 pSWP
[i
].x
= vRectl
.xLeft
;
1228 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1229 pSWP
[i
].cx
= vRectl
.xRight
- vRectl
.xLeft
;
1230 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- nHeight
;
1231 pSWP
[i
].fl
= SWP_SIZE
| SWP_MOVE
| SWP_SHOW
;
1232 pSWP
[i
].hwndInsertBehind
= HWND_TOP
;
1236 rc
= MRFROMSHORT(nItemCount
);
1241 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1242 rc
= pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
);
1244 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1247 } // end of wxFrameMainWndProc
1249 MRESULT EXPENTRY
wxFrameWndProc(
1257 // Trace all ulMsgs - useful for the debugging
1260 wxFrame
* pWnd
= NULL
;
1262 parentHwnd
= WinQueryWindow(hWnd
,QW_PARENT
);
1263 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1266 // When we get the first message for the HWND we just created, we associate
1267 // it with wxWindow stored in wxWndHook
1270 MRESULT rc
= (MRESULT
)0;
1271 bool bProcessed
= FALSE
;
1274 // Stop right here if we don't have a valid handle in our wxWindow object.
1276 if (pWnd
&& !pWnd
->GetHWND())
1278 pWnd
->SetHWND((WXHWND
) hWnd
);
1279 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
1285 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
1287 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1290 } // end of wxFrameWndProc
1292 MRESULT
wxFrame::OS2WindowProc(
1299 bool bProcessed
= FALSE
;
1305 // If we can't close, tell the system that we processed the
1306 // message - otherwise it would close us
1308 bProcessed
= !Close();
1312 bProcessed
= HandlePaint();
1313 mRc
= (MRESULT
)FALSE
;
1316 case WM_ERASEBACKGROUND
:
1318 // Returning TRUE to requests PM to paint the window background
1319 // in SYSCLR_WINDOW. We capture this here because the PS returned
1320 // in Frames is the PS for the whole frame, which we can't really
1321 // use at all. If you want to paint a different background, do it
1322 // in an OnPaint using a wxPaintDC.
1324 mRc
= (MRESULT
)(TRUE
);
1333 UnpackCommand( (WXWPARAM
)wParam
1340 bProcessed
= HandleCommand( wId
1353 UnpackMenuSelect( wParam
1359 bProcessed
= HandleMenuSelect( wItem
1363 mRc
= (MRESULT
)TRUE
;
1369 SHORT nScxold
= SHORT1FROMMP(wParam
); // Old horizontal size.
1370 SHORT nScyold
= SHORT2FROMMP(wParam
); // Old vertical size.
1371 SHORT nScxnew
= SHORT1FROMMP(lParam
); // New horizontal size.
1372 SHORT nScynew
= SHORT2FROMMP(lParam
); // New vertical size.
1374 lParam
= MRFROM2SHORT( nScxnew
- 20
1378 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1379 mRc
= (MRESULT
)FALSE
;
1382 case CM_QUERYDRAGIMAGE
:
1384 const wxIcon
& vIcon
= GetIcon();
1388 hIcon
= (HPOINTER
)::WinSendMsg(GetHWND(), WM_QUERYICON
, 0L, 0L);
1390 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1391 mRc
= (MRESULT
)hIcon
;
1392 bProcessed
= mRc
!= 0;
1398 mRc
= wxWindow::OS2WindowProc( uMessage
1402 return (MRESULT
)mRc
;
1403 } // wxFrame::OS2WindowProc
1405 void wxFrame::SetClient(WXHWND c_Hwnd
)
1407 // Duh...nothing to do under OS/2
1410 void wxFrame::SetClient(
1414 wxWindow
* pOldClient
= this->GetClient();
1415 bool bClientHasFocus
= pOldClient
&& (pOldClient
== wxWindow::FindFocus());
1417 if(pOldClient
== pWindow
) // nothing to do
1419 if(pWindow
== NULL
) // just need to remove old client
1421 if(pOldClient
== NULL
) // nothing to do
1424 if(bClientHasFocus
)
1427 pOldClient
->Enable( FALSE
);
1428 pOldClient
->Show( FALSE
);
1429 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1430 // to avoid OS/2 bug need to update frame
1431 ::WinSendMsg((HWND
)this->GetFrame(), WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1436 // Else need to change client
1441 ::WinEnableWindowUpdate((HWND
)GetHWND(), FALSE
);
1444 pOldClient
->Enable(FALSE
);
1445 pOldClient
->Show(FALSE
);
1446 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1448 pWindow
->Reparent(this);
1449 ::WinSetWindowUShort(pWindow
->GetHWND(), QWS_ID
, FID_CLIENT
);
1450 ::WinEnableWindowUpdate((HWND
)GetHWND(), TRUE
);
1452 pWindow
->Show(); // ensure client is showing
1453 if( this->IsShown() )
1456 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1460 wxWindow
* wxFrame::GetClient()
1462 return wxFindWinFromHandle((WXHWND
)::WinWindowFromID(m_hFrame
, FID_CLIENT
));