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
;
55 extern const wxChar
* wxFrameClassName
;
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 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
148 wxModelessWindows
.Append(this);
150 } // end of wxFrame::Create
154 m_isBeingDeleted
= TRUE
;
156 } // end of wxFrame::~wxFrame
159 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
161 void wxFrame::DoGetClientSize(
166 wxTopLevelWindow::DoGetClientSize( pX
170 // No need to use statusbar code as in WIN32 as the FORMATFRAME
171 // window procedure ensures PM knows about the new frame client
172 // size internally. A ::WinQueryWindowRect (that is called in
173 // wxWindow's GetClient size from above) is all that is needed!
175 } // end of wxFrame::DoGetClientSize
178 // Set the client size (i.e. leave the calculation of borders etc.
181 void wxFrame::DoSetClientSize(
186 wxStatusBar
* pStatusBar
= GetStatusBar();
189 // Statusbars are not part of the OS/2 Client but parent frame
190 // so no statusbar consideration
192 wxTopLevelWindow::DoSetClientSize( nWidth
195 } // end of wxFrame::DoSetClientSize
197 // ----------------------------------------------------------------------------
198 // wxFrame: various geometry-related functions
199 // ----------------------------------------------------------------------------
201 void wxFrame::Raise()
203 wxFrameBase::Raise();
204 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
214 // generate an artificial resize event
215 void wxFrame::SendSizeEvent()
219 RECTL vRect
= wxGetWindowRect(GetHwnd());
221 (void)::WinPostMsg( m_hFrame
223 ,MPFROM2SHORT(vRect
.xRight
- vRect
.xLeft
, vRect
.yTop
- vRect
.yBottom
)
224 ,MPFROM2SHORT(vRect
.xRight
- vRect
.xLeft
, vRect
.yTop
- vRect
.yBottom
)
230 wxStatusBar
* wxFrame::OnCreateStatusBar(
234 , const wxString
& rName
237 wxStatusBar
* pStatusBar
= NULL
;
242 pStatusBar
= wxFrameBase::OnCreateStatusBar( nNumber
251 ::WinSetParent( pStatusBar
->GetHWND()
255 ::WinSetOwner( pStatusBar
->GetHWND()
261 if(::WinIsWindowShowing(m_hFrame
))
262 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
265 } // end of wxFrame::OnCreateStatusBar
267 void wxFrame::PositionStatusBar()
274 // Native status bar positions itself
276 if (m_frameStatusBar
)
286 ::WinQueryWindowRect(m_hFrame
, &vRect
);
288 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
290 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
291 nWidth
= vRect
.xRight
- vRect
.xLeft
;
292 nY
= nY
- (vRect
.yBottom
- vFRect
.yBottom
);
294 m_frameStatusBar
->GetSize( &nStatbarWidth
298 nY
= nY
- nStatbarHeight
;
300 // Since we wish the status bar to be directly under the client area,
301 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
303 m_frameStatusBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
308 if (!::WinQueryWindowPos(m_frameStatusBar
->GetHWND(), &vSwp
))
310 vError
= ::WinGetLastError(vHabmain
);
311 sError
= wxPMErrorToStr(vError
);
312 wxLogError("Error setting parent for StautsBar. Error: %s\n", sError
);
316 } // end of wxFrame::PositionStatusBar
317 #endif // wxUSE_STATUSBAR
319 #if wxUSE_MENUS_NATIVE
320 void wxFrame::DetachMenuBar()
324 m_frameMenuBar
->Detach();
325 m_frameMenuBar
= NULL
;
327 } // end of wxFrame::DetachMenuBar
329 void wxFrame::SetMenuBar(
335 HWND hTitlebar
= NULLHANDLE
;
336 HWND hHScroll
= NULLHANDLE
;
337 HWND hVScroll
= NULLHANDLE
;
338 HWND hMenuBar
= NULLHANDLE
;
350 // Actually remove the menu from the frame
352 m_hMenu
= (WXHMENU
)0;
353 InternalSetMenuBar();
355 else // set new non NULL menu bar
357 m_frameMenuBar
= NULL
;
360 // Can set a menubar several times.
361 // TODO: how to prevent a memory leak if you have a currently-unattached
362 // menubar? wxWindows assumes that the frame will delete the menu (otherwise
363 // there are problems for MDI).
365 if (pMenuBar
->GetHMenu())
367 m_hMenu
= pMenuBar
->GetHMenu();
372 m_hMenu
= pMenuBar
->Create();
376 InternalSetMenuBar();
377 m_frameMenuBar
= pMenuBar
;
378 pMenuBar
->Attach((wxFrame
*)this);
380 } // end of wxFrame::SetMenuBar
382 void wxFrame::AttachMenuBar(
386 wxFrameBase::AttachMenuBar(pMenubar
);
388 m_frameMenuBar
= pMenubar
;
393 // Actually remove the menu from the frame
395 m_hMenu
= (WXHMENU
)0;
396 InternalSetMenuBar();
398 else // Set new non NULL menu bar
401 // Can set a menubar several times.
403 if (pMenubar
->GetHMenu())
405 m_hMenu
= pMenubar
->GetHMenu();
409 if (pMenubar
->IsAttached())
412 m_hMenu
= pMenubar
->Create();
417 InternalSetMenuBar();
419 } // end of wxFrame::AttachMenuBar
421 void wxFrame::InternalSetMenuBar()
426 // Set the parent and owner of the menubar to be the frame
428 if (!::WinSetParent(m_hMenu
, m_hFrame
, FALSE
))
430 vError
= ::WinGetLastError(vHabmain
);
431 sError
= wxPMErrorToStr(vError
);
432 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
435 if (!::WinSetOwner(m_hMenu
, m_hFrame
))
437 vError
= ::WinGetLastError(vHabmain
);
438 sError
= wxPMErrorToStr(vError
);
439 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
441 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
442 } // end of wxFrame::InternalSetMenuBar
443 #endif // wxUSE_MENUS_NATIVE
446 // Responds to colour changes, and passes event on to children
448 void wxFrame::OnSysColourChanged(
449 wxSysColourChangedEvent
& rEvent
452 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
456 if (m_frameStatusBar
)
458 wxSysColourChangedEvent vEvent2
;
460 vEvent2
.SetEventObject(m_frameStatusBar
);
461 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
463 #endif //wxUSE_STATUSBAR
466 // Propagate the event to the non-top-level children
468 wxWindow::OnSysColourChanged(rEvent
);
469 } // end of wxFrame::OnSysColourChanged
471 // Pass TRUE to show full screen, FALSE to restore.
472 bool wxFrame::ShowFullScreen(
482 m_bFsIsShowing
= TRUE
;
486 wxToolBar
* pTheToolBar
= GetToolBar();
487 #endif //wxUSE_TOOLBAR
490 wxStatusBar
* pTheStatusBar
= GetStatusBar();
491 #endif //wxUSE_STATUSBAR
497 pTheToolBar
->GetSize(&nDummyWidth
, &m_nFsToolBarHeight
);
498 #endif //wxUSE_TOOLBAR
502 pTheStatusBar
->GetSize(&nDummyWidth
, &m_nFsStatusBarHeight
);
503 #endif //wxUSE_STATUSBAR
507 // Zap the toolbar, menubar, and statusbar
509 if ((lStyle
& wxFULLSCREEN_NOTOOLBAR
) && pTheToolBar
)
511 pTheToolBar
->SetSize(-1,0);
512 pTheToolBar
->Show(FALSE
);
514 #endif //wxUSE_TOOLBAR
516 if (lStyle
& wxFULLSCREEN_NOMENUBAR
)
518 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
519 ::WinSetOwner(m_hMenu
, m_hFrame
);
520 ::WinSendMsg((HWND
)m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
525 // Save the number of fields in the statusbar
527 if ((lStyle
& wxFULLSCREEN_NOSTATUSBAR
) && pTheStatusBar
)
529 m_nFsStatusBarFields
= pTheStatusBar
->GetFieldsCount();
530 SetStatusBar((wxStatusBar
*) NULL
);
531 delete pTheStatusBar
;
534 m_nFsStatusBarFields
= 0;
535 #endif //wxUSE_STATUSBAR
538 // Zap the frame borders
542 // Save the 'normal' window style
544 m_lFsOldWindowStyle
= ::WinQueryWindowULong(m_hFrame
, QWL_STYLE
);
547 // Save the old position, width & height, maximize state
549 m_vFsOldSize
= GetRect();
550 m_bFsIsMaximized
= IsMaximized();
553 // Decide which window style flags to turn off
555 LONG lNewStyle
= m_lFsOldWindowStyle
;
558 if (lStyle
& wxFULLSCREEN_NOBORDER
)
559 lOffFlags
|= FCF_BORDER
;
560 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
561 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
563 lNewStyle
&= (~lOffFlags
);
566 // Change our window style to be compatible with full-screen mode
568 ::WinSetWindowULong((HWND
)m_hFrame
, QWL_STYLE
, (ULONG
)lNewStyle
);
571 // Resize to the size of the desktop
577 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
578 nWidth
= vRect
.xRight
- vRect
.xLeft
;
580 // Rmember OS/2 is backwards!
582 nHeight
= vRect
.yTop
- vRect
.yBottom
;
589 // Now flush the window style cache and actually go full-screen
591 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
600 wxSizeEvent
vEvent( wxSize( nWidth
606 GetEventHandler()->ProcessEvent(vEvent
);
614 m_bFsIsShowing
= FALSE
;
617 wxToolBar
* pTheToolBar
= GetToolBar();
620 // Restore the toolbar, menubar, and statusbar
622 if (pTheToolBar
&& (m_lFsStyle
& wxFULLSCREEN_NOTOOLBAR
))
624 pTheToolBar
->SetSize(-1, m_nFsToolBarHeight
);
625 pTheToolBar
->Show(TRUE
);
627 #endif //wxUSE_TOOLBAR
630 if ((m_lFsStyle
& wxFULLSCREEN_NOSTATUSBAR
) && (m_nFsStatusBarFields
> 0))
632 CreateStatusBar(m_nFsStatusBarFields
);
633 // PositionStatusBar();
635 #endif //wxUSE_STATUSBAR
637 if ((m_lFsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
639 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
640 ::WinSetOwner(m_hMenu
, m_hFrame
);
641 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
643 Maximize(m_bFsIsMaximized
);
645 ::WinSetWindowULong( m_hFrame
647 ,(ULONG
)m_lFsOldWindowStyle
649 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
659 } // end of wxFrame::ShowFullScreen
665 // Default activation behaviour - set the focus for the first child
668 void wxFrame::OnActivate(
669 wxActivateEvent
& rEvent
672 if ( rEvent
.GetActive() )
674 // restore focus to the child which was last focused
675 wxLogTrace(_T("focus"), _T("wxFrame %08x activated."), m_hWnd
);
677 wxWindow
* pParent
= m_pWinLastFocused
? m_pWinLastFocused
->GetParent()
684 wxSetFocusToChild( pParent
691 // Remember the last focused child if it is our child
693 m_pWinLastFocused
= FindFocus();
695 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
697 pNode
= pNode
->GetNext())
699 // FIXME all this is totally bogus - we need to do the same as wxPanel,
700 // but how to do it without duplicating the code?
703 wxWindow
* pChild
= pNode
->GetData();
705 if (!pChild
->IsTopLevel()
707 && !wxDynamicCast(pChild
, wxToolBar
)
708 #endif // wxUSE_TOOLBAR
710 && !wxDynamicCast(pChild
, wxStatusBar
)
711 #endif // wxUSE_STATUSBAR
719 } // end of wxFrame::OnActivate
721 // ----------------------------------------------------------------------------
722 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
723 // from the client area, so the client area is what's really available for the
725 // ----------------------------------------------------------------------------
727 // Checks if there is a toolbar, and returns the first free client position
728 wxPoint
wxFrame::GetClientAreaOrigin() const
730 wxPoint
vPoint(0, 0);
738 GetToolBar()->GetSize( &nWidth
742 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
748 // PM is backwards from windows
752 #endif //wxUSE_TOOLBAR
754 } // end of wxFrame::GetClientAreaOrigin
756 // ----------------------------------------------------------------------------
757 // tool/status bar stuff
758 // ----------------------------------------------------------------------------
762 wxToolBar
* wxFrame::CreateToolBar(
765 , const wxString
& rName
768 if (wxFrameBase::CreateToolBar( lStyle
775 return m_frameToolBar
;
776 } // end of wxFrame::CreateToolBar
778 void wxFrame::PositionToolBar()
783 ::WinQueryWindowRect(GetHwnd(), &vRect
);
791 GetStatusBar()->GetClientSize( &nStatusX
794 // PM is backwards from windows
795 vRect
.yBottom
+= nStatusY
;
797 #endif // wxUSE_STATUSBAR
799 if ( m_frameToolBar
)
804 m_frameToolBar
->GetSize( &nToolbarWidth
808 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
810 nToolbarHeight
= vRect
.yBottom
;
814 nToolbarWidth
= vRect
.xRight
;
818 // Use the 'real' PM position here
820 GetToolBar()->SetSize( 0
824 ,wxSIZE_NO_ADJUSTMENTS
827 } // end of wxFrame::PositionToolBar
828 #endif // wxUSE_TOOLBAR
830 // ----------------------------------------------------------------------------
831 // frame state (iconized/maximized/...)
832 // ----------------------------------------------------------------------------
835 // propagate our state change to all child frames: this allows us to emulate X
836 // Windows behaviour where child frames float independently of the parent one
837 // on the desktop, but are iconized/restored with it
839 void wxFrame::IconizeChildFrames(
843 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
845 pNode
= pNode
->GetNext() )
847 wxWindow
* pWin
= pNode
->GetData();
848 wxFrame
* pFrame
= wxDynamicCast(pWin
, wxFrame
);
851 #if wxUSE_MDI_ARCHITECTURE
852 && !wxDynamicCast(pFrame
, wxMDIChildFrame
)
853 #endif // wxUSE_MDI_ARCHITECTURE
857 // We don't want to restore the child frames which had been
858 // iconized even before we were iconized, so save the child frame
859 // status when iconizing the parent frame and check it when
864 pFrame
->m_bWasMinimized
= pFrame
->IsIconized();
868 // This test works for both iconizing and restoring
870 if (!pFrame
->m_bWasMinimized
)
871 pFrame
->Iconize(bIconize
);
874 } // end of wxFrame::IconizeChildFrames
876 WXHICON
wxFrame::GetDefaultIcon() const
878 return (WXHICON
)(wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
879 : wxDEFAULT_FRAME_ICON
);
881 // ===========================================================================
882 // message processing
883 // ===========================================================================
885 // ---------------------------------------------------------------------------
887 // ---------------------------------------------------------------------------
888 bool wxFrame::OS2TranslateMessage(
893 // try the menu bar accels
895 wxMenuBar
* pMenuBar
= GetMenuBar();
900 #if wxUSE_ACCEL && wxUSE_MENUS_NATIVE
901 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
902 return rAcceleratorTable
.Translate(GetHWND(), pMsg
);
906 } // end of wxFrame::OS2TranslateMessage
908 // ---------------------------------------------------------------------------
909 // our private (non virtual) message handlers
910 // ---------------------------------------------------------------------------
911 bool wxFrame::HandlePaint()
915 if (::WinQueryUpdateRect(GetHWND(), &vRect
))
920 // Icons in PM are the same as "pointers"
925 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
927 hIcon
= (HPOINTER
)m_hDefaultIcon
;
930 // Hold a pointer to the dc so long as the OnPaint() message
931 // is being processed
934 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
937 // Erase background before painting or we get white background
939 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
946 ::WinQueryWindowRect(GetHwnd(), &vRect3
);
948 static const int nIconWidth
= 32;
949 static const int nIconHeight
= 32;
950 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
951 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
953 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
960 if (!wxWindow::HandlePaint())
965 hPS
= ::WinBeginPaint( GetHwnd()
971 ::GpiCreateLogColorTable( hPS
975 ,(LONG
)wxTheColourDatabase
->m_nSize
976 ,(PLONG
)wxTheColourDatabase
->m_palTable
978 ::GpiCreateLogColorTable( hPS
988 ,GetBackgroundColour().GetPixel()
998 // nothing to paint - processed
1002 } // end of wxFrame::HandlePaint
1004 bool wxFrame::HandleSize(
1010 bool bProcessed
= FALSE
;
1016 // Only do it it if we were iconized before, otherwise resizing the
1017 // parent frame has a curious side effect of bringing it under it's
1023 // restore all child frames too
1025 IconizeChildFrames(FALSE
);
1026 (void)SendIconizeEvent(FALSE
);
1033 m_bIconized
= FALSE
;
1038 // Iconize all child frames too
1040 IconizeChildFrames(TRUE
);
1041 (void)SendIconizeEvent();
1049 // forward WM_SIZE to status bar control
1051 #if wxUSE_NATIVE_STATUSBAR
1052 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
1054 wxSizeEvent
vEvent( wxSize( nX
1057 ,m_frameStatusBar
->GetId()
1060 vEvent
.SetEventObject(m_frameStatusBar
);
1061 m_frameStatusBar
->OnSize(vEvent
);
1063 #endif // wxUSE_NATIVE_STATUSBAR
1065 PositionStatusBar();
1068 #endif // wxUSE_TOOLBAR
1070 wxSizeEvent
vEvent( wxSize( nX
1076 vEvent
.SetEventObject(this);
1077 bProcessed
= GetEventHandler()->ProcessEvent(vEvent
);
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 } // end of wxFrame::HandleMenuSelect
1153 // ---------------------------------------------------------------------------
1154 // Main Frame window proc
1155 // ---------------------------------------------------------------------------
1156 MRESULT EXPENTRY
wxFrameMainWndProc(
1163 MRESULT rc
= (MRESULT
)0;
1164 bool bProcessed
= FALSE
;
1165 wxFrame
* pWnd
= NULL
;
1167 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1170 case WM_QUERYFRAMECTLCOUNT
:
1171 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1173 USHORT uItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1175 rc
= MRFROMSHORT(uItemCount
);
1179 case WM_FORMATFRAME
:
1180 /////////////////////////////////////////////////////////////////////////////////
1181 // Applications that subclass frame controls may find that the frame is already
1182 // subclassed the number of frame controls is variable.
1183 // The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
1184 // subclassed by calling the previous window procedure and modifying its result.
1185 ////////////////////////////////////////////////////////////////////////////////
1195 pSWP
= (PSWP
)PVOIDFROMMP(wParam
);
1196 nItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1197 if(pWnd
->m_frameStatusBar
)
1199 ::WinQueryWindowRect(pWnd
->m_frameStatusBar
->GetHWND(), &vRstb
);
1200 pWnd
->m_frameStatusBar
->GetSize(NULL
, &nHeight
);
1201 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1202 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1204 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1206 vSwpStb
.x
= vRectl
.xLeft
- vRstb
.xLeft
;
1207 vSwpStb
.y
= vRectl
.yBottom
- vRstb
.yBottom
;
1208 vSwpStb
.cx
= vRectl
.xRight
- vRectl
.xLeft
- 1; //?? -1 ??
1209 vSwpStb
.cy
= nHeight
;
1210 vSwpStb
.fl
= SWP_SIZE
|SWP_MOVE
| SWP_SHOW
;
1211 vSwpStb
.hwnd
= pWnd
->m_frameStatusBar
->GetHWND();
1212 vSwpStb
.hwndInsertBehind
= HWND_TOP
;
1214 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1215 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1216 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1217 ::WinMapWindowPoints(HWND_DESKTOP
, pWnd
->m_hFrame
, (PPOINTL
)&vRectl
, 2);
1218 for(i
= 0; i
< nItemCount
; i
++)
1220 if(pWnd
->m_hWnd
&& pSWP
[i
].hwnd
== pWnd
->m_hWnd
)
1222 pSWP
[i
].x
= vRectl
.xLeft
;
1223 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1224 pSWP
[i
].cx
= vRectl
.xRight
- vRectl
.xLeft
;
1225 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- nHeight
;
1226 pSWP
[i
].fl
= SWP_SIZE
| SWP_MOVE
| SWP_SHOW
;
1227 pSWP
[i
].hwndInsertBehind
= HWND_TOP
;
1231 rc
= MRFROMSHORT(nItemCount
);
1236 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1237 rc
= pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
);
1239 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1242 } // end of wxFrameMainWndProc
1244 MRESULT EXPENTRY
wxFrameWndProc(
1252 // Trace all ulMsgs - useful for the debugging
1255 wxFrame
* pWnd
= NULL
;
1257 parentHwnd
= WinQueryWindow(hWnd
,QW_PARENT
);
1258 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1261 // When we get the first message for the HWND we just created, we associate
1262 // it with wxWindow stored in wxWndHook
1265 MRESULT rc
= (MRESULT
)0;
1266 bool bProcessed
= FALSE
;
1269 // Stop right here if we don't have a valid handle in our wxWindow object.
1271 if (pWnd
&& !pWnd
->GetHWND())
1273 pWnd
->SetHWND((WXHWND
) hWnd
);
1274 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
1280 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
1282 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1285 } // end of wxFrameWndProc
1287 MRESULT
wxFrame::OS2WindowProc(
1294 bool bProcessed
= FALSE
;
1300 // If we can't close, tell the system that we processed the
1301 // message - otherwise it would close us
1303 bProcessed
= !Close();
1307 bProcessed
= HandlePaint();
1308 mRc
= (MRESULT
)FALSE
;
1311 case WM_ERASEBACKGROUND
:
1313 // Returning TRUE to requests PM to paint the window background
1314 // in SYSCLR_WINDOW. We capture this here because the PS returned
1315 // in Frames is the PS for the whole frame, which we can't really
1316 // use at all. If you want to paint a different background, do it
1317 // in an OnPaint using a wxPaintDC.
1319 mRc
= (MRESULT
)(TRUE
);
1328 UnpackCommand( (WXWPARAM
)wParam
1335 bProcessed
= HandleCommand( wId
1348 UnpackMenuSelect( wParam
1354 bProcessed
= HandleMenuSelect( wItem
1358 mRc
= (MRESULT
)TRUE
;
1364 SHORT nScxold
= SHORT1FROMMP(wParam
); // Old horizontal size.
1365 SHORT nScyold
= SHORT2FROMMP(wParam
); // Old vertical size.
1366 SHORT nScxnew
= SHORT1FROMMP(lParam
); // New horizontal size.
1367 SHORT nScynew
= SHORT2FROMMP(lParam
); // New vertical size.
1369 lParam
= MRFROM2SHORT( nScxnew
- 20
1373 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1374 mRc
= (MRESULT
)FALSE
;
1377 case CM_QUERYDRAGIMAGE
:
1382 hIcon
= (HPOINTER
)::WinSendMsg(GetHWND(), WM_QUERYICON
, 0L, 0L);
1384 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1385 mRc
= (MRESULT
)hIcon
;
1386 bProcessed
= mRc
!= 0;
1392 mRc
= wxWindow::OS2WindowProc( uMessage
1396 return (MRESULT
)mRc
;
1397 } // wxFrame::OS2WindowProc
1399 void wxFrame::SetClient(WXHWND c_Hwnd
)
1401 // Duh...nothing to do under OS/2
1404 void wxFrame::SetClient(
1408 wxWindow
* pOldClient
= this->GetClient();
1409 bool bClientHasFocus
= pOldClient
&& (pOldClient
== wxWindow::FindFocus());
1411 if(pOldClient
== pWindow
) // nothing to do
1413 if(pWindow
== NULL
) // just need to remove old client
1415 if(pOldClient
== NULL
) // nothing to do
1418 if(bClientHasFocus
)
1421 pOldClient
->Enable( FALSE
);
1422 pOldClient
->Show( FALSE
);
1423 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1424 // to avoid OS/2 bug need to update frame
1425 ::WinSendMsg((HWND
)this->GetFrame(), WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1430 // Else need to change client
1435 ::WinEnableWindowUpdate((HWND
)GetHWND(), FALSE
);
1438 pOldClient
->Enable(FALSE
);
1439 pOldClient
->Show(FALSE
);
1440 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1442 pWindow
->Reparent(this);
1443 ::WinSetWindowUShort(pWindow
->GetHWND(), QWS_ID
, FID_CLIENT
);
1444 ::WinEnableWindowUpdate((HWND
)GetHWND(), TRUE
);
1446 pWindow
->Show(); // ensure client is showing
1447 if( this->IsShown() )
1450 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1454 wxWindow
* wxFrame::GetClient()
1456 return wxFindWinFromHandle((WXHWND
)::WinWindowFromID(m_hFrame
, FID_CLIENT
));