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()
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 wxClientDC
vDC(pStatusBar
);
254 // Set the height according to the font and the border size
256 vDC
.SetFont(pStatusBar
->GetFont()); // Screws up the menues for some reason
257 vDC
.GetTextExtent( "X"
262 int nHeight
= ((11 * nY
) / 10 + 2 * pStatusBar
->GetBorderY());
264 pStatusBar
->SetSize( -1
270 ::WinSetParent( pStatusBar
->GetHWND()
274 ::WinSetOwner( pStatusBar
->GetHWND()
280 if(::WinIsWindowShowing(m_hFrame
))
281 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
284 } // end of wxFrame::OnCreateStatusBar
286 void wxFrame::PositionStatusBar()
293 // Native status bar positions itself
295 if (m_frameStatusBar
)
305 ::WinQueryWindowRect(m_hFrame
, &vRect
);
307 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
309 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
310 nWidth
= vRect
.xRight
- vRect
.xLeft
;
311 nY
= nY
- (vRect
.yBottom
- vFRect
.yBottom
);
313 m_frameStatusBar
->GetSize( &nStatbarWidth
317 nY
= nY
- nStatbarHeight
;
319 // Since we wish the status bar to be directly under the client area,
320 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
322 m_frameStatusBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
327 if (!::WinQueryWindowPos(m_frameStatusBar
->GetHWND(), &vSwp
))
329 vError
= ::WinGetLastError(vHabmain
);
330 sError
= wxPMErrorToStr(vError
);
331 wxLogError("Error setting parent for StautsBar. Error: %s\n", sError
);
335 } // end of wxFrame::PositionStatusBar
336 #endif // wxUSE_STATUSBAR
338 #if wxUSE_MENUS_NATIVE
339 void wxFrame::DetachMenuBar()
343 m_frameMenuBar
->Detach();
344 m_frameMenuBar
= NULL
;
346 } // end of wxFrame::DetachMenuBar
348 void wxFrame::SetMenuBar(
354 HWND hTitlebar
= NULLHANDLE
;
355 HWND hHScroll
= NULLHANDLE
;
356 HWND hVScroll
= NULLHANDLE
;
357 HWND hMenuBar
= NULLHANDLE
;
369 // Actually remove the menu from the frame
371 m_hMenu
= (WXHMENU
)0;
372 InternalSetMenuBar();
374 else // set new non NULL menu bar
376 m_frameMenuBar
= NULL
;
379 // Can set a menubar several times.
380 // TODO: how to prevent a memory leak if you have a currently-unattached
381 // menubar? wxWindows assumes that the frame will delete the menu (otherwise
382 // there are problems for MDI).
384 if (pMenuBar
->GetHMenu())
386 m_hMenu
= pMenuBar
->GetHMenu();
391 m_hMenu
= pMenuBar
->Create();
395 InternalSetMenuBar();
396 m_frameMenuBar
= pMenuBar
;
397 pMenuBar
->Attach((wxFrame
*)this);
399 } // end of wxFrame::SetMenuBar
401 void wxFrame::AttachMenuBar(
405 wxFrameBase::AttachMenuBar(pMenubar
);
407 m_frameMenuBar
= pMenubar
;
412 // Actually remove the menu from the frame
414 m_hMenu
= (WXHMENU
)0;
415 InternalSetMenuBar();
417 else // Set new non NULL menu bar
420 // Can set a menubar several times.
422 if (pMenubar
->GetHMenu())
424 m_hMenu
= pMenubar
->GetHMenu();
428 if (pMenubar
->IsAttached())
431 m_hMenu
= pMenubar
->Create();
436 InternalSetMenuBar();
438 } // end of wxFrame::AttachMenuBar
440 void wxFrame::InternalSetMenuBar()
445 // Set the parent and owner of the menubar to be the frame
447 if (!::WinSetParent(m_hMenu
, m_hFrame
, FALSE
))
449 vError
= ::WinGetLastError(vHabmain
);
450 sError
= wxPMErrorToStr(vError
);
451 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
454 if (!::WinSetOwner(m_hMenu
, m_hFrame
))
456 vError
= ::WinGetLastError(vHabmain
);
457 sError
= wxPMErrorToStr(vError
);
458 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
460 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
461 } // end of wxFrame::InternalSetMenuBar
462 #endif // wxUSE_MENUS_NATIVE
465 // Responds to colour changes, and passes event on to children
467 void wxFrame::OnSysColourChanged(
468 wxSysColourChangedEvent
& rEvent
471 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
475 if (m_frameStatusBar
)
477 wxSysColourChangedEvent vEvent2
;
479 vEvent2
.SetEventObject(m_frameStatusBar
);
480 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
482 #endif //wxUSE_STATUSBAR
485 // Propagate the event to the non-top-level children
487 wxWindow::OnSysColourChanged(rEvent
);
488 } // end of wxFrame::OnSysColourChanged
490 // Pass TRUE to show full screen, FALSE to restore.
491 bool wxFrame::ShowFullScreen(
501 m_bFsIsShowing
= TRUE
;
505 wxToolBar
* pTheToolBar
= GetToolBar();
506 #endif //wxUSE_TOOLBAR
509 wxStatusBar
* pTheStatusBar
= GetStatusBar();
510 #endif //wxUSE_STATUSBAR
516 pTheToolBar
->GetSize(&nDummyWidth
, &m_nFsToolBarHeight
);
517 #endif //wxUSE_TOOLBAR
521 pTheStatusBar
->GetSize(&nDummyWidth
, &m_nFsStatusBarHeight
);
522 #endif //wxUSE_STATUSBAR
526 // Zap the toolbar, menubar, and statusbar
528 if ((lStyle
& wxFULLSCREEN_NOTOOLBAR
) && pTheToolBar
)
530 pTheToolBar
->SetSize(-1,0);
531 pTheToolBar
->Show(FALSE
);
533 #endif //wxUSE_TOOLBAR
535 if (lStyle
& wxFULLSCREEN_NOMENUBAR
)
537 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
538 ::WinSetOwner(m_hMenu
, m_hFrame
);
539 ::WinSendMsg((HWND
)m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
544 // Save the number of fields in the statusbar
546 if ((lStyle
& wxFULLSCREEN_NOSTATUSBAR
) && pTheStatusBar
)
548 m_nFsStatusBarFields
= pTheStatusBar
->GetFieldsCount();
549 SetStatusBar((wxStatusBar
*) NULL
);
550 delete pTheStatusBar
;
553 m_nFsStatusBarFields
= 0;
554 #endif //wxUSE_STATUSBAR
557 // Zap the frame borders
561 // Save the 'normal' window style
563 m_lFsOldWindowStyle
= ::WinQueryWindowULong(m_hFrame
, QWL_STYLE
);
566 // Save the old position, width & height, maximize state
568 m_vFsOldSize
= GetRect();
569 m_bFsIsMaximized
= IsMaximized();
572 // Decide which window style flags to turn off
574 LONG lNewStyle
= m_lFsOldWindowStyle
;
577 if (lStyle
& wxFULLSCREEN_NOBORDER
)
578 lOffFlags
|= FCF_BORDER
;
579 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
580 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
582 lNewStyle
&= (~lOffFlags
);
585 // Change our window style to be compatible with full-screen mode
587 ::WinSetWindowULong((HWND
)m_hFrame
, QWL_STYLE
, (ULONG
)lNewStyle
);
590 // Resize to the size of the desktop
596 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
597 nWidth
= vRect
.xRight
- vRect
.xLeft
;
599 // Rmember OS/2 is backwards!
601 nHeight
= vRect
.yTop
- vRect
.yBottom
;
608 // Now flush the window style cache and actually go full-screen
610 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
619 wxSizeEvent
vEvent( wxSize( nWidth
625 GetEventHandler()->ProcessEvent(vEvent
);
633 m_bFsIsShowing
= FALSE
;
636 wxToolBar
* pTheToolBar
= GetToolBar();
639 // Restore the toolbar, menubar, and statusbar
641 if (pTheToolBar
&& (m_lFsStyle
& wxFULLSCREEN_NOTOOLBAR
))
643 pTheToolBar
->SetSize(-1, m_nFsToolBarHeight
);
644 pTheToolBar
->Show(TRUE
);
646 #endif //wxUSE_TOOLBAR
649 if ((m_lFsStyle
& wxFULLSCREEN_NOSTATUSBAR
) && (m_nFsStatusBarFields
> 0))
651 CreateStatusBar(m_nFsStatusBarFields
);
652 // PositionStatusBar();
654 #endif //wxUSE_STATUSBAR
656 if ((m_lFsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
658 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
659 ::WinSetOwner(m_hMenu
, m_hFrame
);
660 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
662 Maximize(m_bFsIsMaximized
);
664 ::WinSetWindowULong( m_hFrame
666 ,(ULONG
)m_lFsOldWindowStyle
668 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
678 } // end of wxFrame::ShowFullScreen
684 // Default activation behaviour - set the focus for the first child
687 void wxFrame::OnActivate(
688 wxActivateEvent
& rEvent
691 if ( rEvent
.GetActive() )
693 // restore focus to the child which was last focused
694 wxLogTrace(_T("focus"), _T("wxFrame %08x activated."), m_hWnd
);
696 wxWindow
* pParent
= m_pWinLastFocused
? m_pWinLastFocused
->GetParent()
703 wxSetFocusToChild( pParent
710 // Remember the last focused child if it is our child
712 m_pWinLastFocused
= FindFocus();
714 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
716 pNode
= pNode
->GetNext())
718 // FIXME all this is totally bogus - we need to do the same as wxPanel,
719 // but how to do it without duplicating the code?
722 wxWindow
* pChild
= pNode
->GetData();
724 if (!pChild
->IsTopLevel()
726 && !wxDynamicCast(pChild
, wxToolBar
)
727 #endif // wxUSE_TOOLBAR
729 && !wxDynamicCast(pChild
, wxStatusBar
)
730 #endif // wxUSE_STATUSBAR
738 } // end of wxFrame::OnActivate
740 // ----------------------------------------------------------------------------
741 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
742 // from the client area, so the client area is what's really available for the
744 // ----------------------------------------------------------------------------
746 // Checks if there is a toolbar, and returns the first free client position
747 wxPoint
wxFrame::GetClientAreaOrigin() const
749 wxPoint
vPoint(0, 0);
757 GetToolBar()->GetSize( &nWidth
761 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
767 // PM is backwards from windows
771 #endif //wxUSE_TOOLBAR
773 } // end of wxFrame::GetClientAreaOrigin
775 // ----------------------------------------------------------------------------
776 // tool/status bar stuff
777 // ----------------------------------------------------------------------------
781 wxToolBar
* wxFrame::CreateToolBar(
784 , const wxString
& rName
787 if (wxFrameBase::CreateToolBar( lStyle
794 return m_frameToolBar
;
795 } // end of wxFrame::CreateToolBar
797 void wxFrame::PositionToolBar()
802 ::WinQueryWindowRect(GetHwnd(), &vRect
);
810 GetStatusBar()->GetClientSize( &nStatusX
813 // PM is backwards from windows
814 vRect
.yBottom
+= nStatusY
;
816 #endif // wxUSE_STATUSBAR
818 if ( m_frameToolBar
)
823 m_frameToolBar
->GetSize( &nToolbarWidth
827 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
829 nToolbarHeight
= vRect
.yBottom
;
833 nToolbarWidth
= vRect
.xRight
;
837 // Use the 'real' PM position here
839 GetToolBar()->SetSize( 0
843 ,wxSIZE_NO_ADJUSTMENTS
846 } // end of wxFrame::PositionToolBar
847 #endif // wxUSE_TOOLBAR
849 // ----------------------------------------------------------------------------
850 // frame state (iconized/maximized/...)
851 // ----------------------------------------------------------------------------
854 // propagate our state change to all child frames: this allows us to emulate X
855 // Windows behaviour where child frames float independently of the parent one
856 // on the desktop, but are iconized/restored with it
858 void wxFrame::IconizeChildFrames(
862 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
864 pNode
= pNode
->GetNext() )
866 wxWindow
* pWin
= pNode
->GetData();
867 wxFrame
* pFrame
= wxDynamicCast(pWin
, wxFrame
);
870 #if wxUSE_MDI_ARCHITECTURE
871 && !wxDynamicCast(pFrame
, wxMDIChildFrame
)
872 #endif // wxUSE_MDI_ARCHITECTURE
876 // We don't want to restore the child frames which had been
877 // iconized even before we were iconized, so save the child frame
878 // status when iconizing the parent frame and check it when
883 pFrame
->m_bWasMinimized
= pFrame
->IsIconized();
887 // This test works for both iconizing and restoring
889 if (!pFrame
->m_bWasMinimized
)
890 pFrame
->Iconize(bIconize
);
893 } // end of wxFrame::IconizeChildFrames
895 WXHICON
wxFrame::GetDefaultIcon() const
897 return (WXHICON
)(wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
898 : wxDEFAULT_FRAME_ICON
);
900 // ===========================================================================
901 // message processing
902 // ===========================================================================
904 // ---------------------------------------------------------------------------
906 // ---------------------------------------------------------------------------
907 bool wxFrame::OS2TranslateMessage(
912 // try the menu bar accels
914 wxMenuBar
* pMenuBar
= GetMenuBar();
919 #if wxUSE_ACCEL && wxUSE_MENUS_NATIVE
920 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
921 return rAcceleratorTable
.Translate(GetHWND(), pMsg
);
925 } // end of wxFrame::OS2TranslateMessage
927 // ---------------------------------------------------------------------------
928 // our private (non virtual) message handlers
929 // ---------------------------------------------------------------------------
930 bool wxFrame::HandlePaint()
934 if (::WinQueryUpdateRect(GetHWND(), &vRect
))
939 // Icons in PM are the same as "pointers"
944 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
946 hIcon
= (HPOINTER
)m_hDefaultIcon
;
949 // Hold a pointer to the dc so long as the OnPaint() message
950 // is being processed
953 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
956 // Erase background before painting or we get white background
958 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
965 ::WinQueryWindowRect(GetHwnd(), &vRect3
);
967 static const int nIconWidth
= 32;
968 static const int nIconHeight
= 32;
969 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
970 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
972 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
979 if (!wxWindow::HandlePaint())
984 hPS
= ::WinBeginPaint( GetHwnd()
990 ::GpiCreateLogColorTable( hPS
994 ,(LONG
)wxTheColourDatabase
->m_nSize
995 ,(PLONG
)wxTheColourDatabase
->m_palTable
997 ::GpiCreateLogColorTable( hPS
1007 ,GetBackgroundColour().GetPixel()
1017 // nothing to paint - processed
1021 } // end of wxFrame::HandlePaint
1023 bool wxFrame::HandleSize(
1029 bool bProcessed
= FALSE
;
1035 // Only do it it if we were iconized before, otherwise resizing the
1036 // parent frame has a curious side effect of bringing it under it's
1042 // restore all child frames too
1044 IconizeChildFrames(FALSE
);
1045 (void)SendIconizeEvent(FALSE
);
1052 m_bIconized
= FALSE
;
1057 // Iconize all child frames too
1059 IconizeChildFrames(TRUE
);
1060 (void)SendIconizeEvent();
1068 // forward WM_SIZE to status bar control
1070 #if wxUSE_NATIVE_STATUSBAR
1071 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
1073 wxSizeEvent
vEvent( wxSize( nX
1076 ,m_frameStatusBar
->GetId()
1079 vEvent
.SetEventObject(m_frameStatusBar
);
1080 m_frameStatusBar
->OnSize(vEvent
);
1082 #endif // wxUSE_NATIVE_STATUSBAR
1084 PositionStatusBar();
1087 #endif // wxUSE_TOOLBAR
1089 wxSizeEvent
vEvent( wxSize( nX
1095 vEvent
.SetEventObject(this);
1096 bProcessed
= GetEventHandler()->ProcessEvent(vEvent
);
1100 } // end of wxFrame::HandleSize
1102 bool wxFrame::HandleCommand(
1111 // In case it's e.g. a toolbar.
1113 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
1116 return pWin
->OS2Command( nCmd
1122 // Handle here commands from menus and accelerators
1124 if (nCmd
== CMDSRC_MENU
|| nCmd
== CMDSRC_ACCELERATOR
)
1126 #if wxUSE_MENUS_NATIVE
1127 if (wxCurrentPopupMenu
)
1129 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1131 wxCurrentPopupMenu
= NULL
;
1133 return pPopupMenu
->OS2Command( nCmd
1140 if (ProcessCommand(nId
))
1146 } // end of wxFrame::HandleCommand
1148 bool wxFrame::HandleMenuSelect(
1159 rc
= ::WinSendMsg(hMenu
, MM_QUERYITEM
, MPFROM2SHORT(nItem
, TRUE
), (MPARAM
)&mItem
);
1161 if(rc
&& !(mItem
.afStyle
& (MIS_SUBMENU
| MIS_SEPARATOR
)))
1163 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nItem
);
1165 vEvent
.SetEventObject(this);
1166 GetEventHandler()->ProcessEvent(vEvent
); // return value would be ignored by PM
1170 } // end of wxFrame::HandleMenuSelect
1172 // ---------------------------------------------------------------------------
1173 // Main Frame window proc
1174 // ---------------------------------------------------------------------------
1175 MRESULT EXPENTRY
wxFrameMainWndProc(
1182 MRESULT rc
= (MRESULT
)0;
1183 bool bProcessed
= FALSE
;
1184 wxFrame
* pWnd
= NULL
;
1186 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1189 case WM_QUERYFRAMECTLCOUNT
:
1190 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1192 USHORT uItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1194 rc
= MRFROMSHORT(uItemCount
);
1198 case WM_FORMATFRAME
:
1199 /////////////////////////////////////////////////////////////////////////////////
1200 // Applications that subclass frame controls may find that the frame is already
1201 // subclassed the number of frame controls is variable.
1202 // The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
1203 // subclassed by calling the previous window procedure and modifying its result.
1204 ////////////////////////////////////////////////////////////////////////////////
1214 pSWP
= (PSWP
)PVOIDFROMMP(wParam
);
1215 nItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1216 if(pWnd
->m_frameStatusBar
)
1218 ::WinQueryWindowRect(pWnd
->m_frameStatusBar
->GetHWND(), &vRstb
);
1219 pWnd
->m_frameStatusBar
->GetSize(NULL
, &nHeight
);
1220 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1221 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1223 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1225 vSwpStb
.x
= vRectl
.xLeft
- vRstb
.xLeft
;
1226 vSwpStb
.y
= vRectl
.yBottom
- vRstb
.yBottom
;
1227 vSwpStb
.cx
= vRectl
.xRight
- vRectl
.xLeft
- 1; //?? -1 ??
1228 vSwpStb
.cy
= nHeight
;
1229 vSwpStb
.fl
= SWP_SIZE
|SWP_MOVE
| SWP_SHOW
;
1230 vSwpStb
.hwnd
= pWnd
->m_frameStatusBar
->GetHWND();
1231 vSwpStb
.hwndInsertBehind
= HWND_TOP
;
1233 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1234 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1235 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1236 ::WinMapWindowPoints(HWND_DESKTOP
, pWnd
->m_hFrame
, (PPOINTL
)&vRectl
, 2);
1237 for(i
= 0; i
< nItemCount
; i
++)
1239 if(pWnd
->m_hWnd
&& pSWP
[i
].hwnd
== pWnd
->m_hWnd
)
1241 pSWP
[i
].x
= vRectl
.xLeft
;
1242 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1243 pSWP
[i
].cx
= vRectl
.xRight
- vRectl
.xLeft
;
1244 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- nHeight
;
1245 pSWP
[i
].fl
= SWP_SIZE
| SWP_MOVE
| SWP_SHOW
;
1246 pSWP
[i
].hwndInsertBehind
= HWND_TOP
;
1250 rc
= MRFROMSHORT(nItemCount
);
1255 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1256 rc
= pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
);
1258 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1261 } // end of wxFrameMainWndProc
1263 MRESULT EXPENTRY
wxFrameWndProc(
1271 // Trace all ulMsgs - useful for the debugging
1274 wxFrame
* pWnd
= NULL
;
1276 parentHwnd
= WinQueryWindow(hWnd
,QW_PARENT
);
1277 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1280 // When we get the first message for the HWND we just created, we associate
1281 // it with wxWindow stored in wxWndHook
1284 MRESULT rc
= (MRESULT
)0;
1285 bool bProcessed
= FALSE
;
1288 // Stop right here if we don't have a valid handle in our wxWindow object.
1290 if (pWnd
&& !pWnd
->GetHWND())
1292 pWnd
->SetHWND((WXHWND
) hWnd
);
1293 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
1299 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
1301 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1304 } // end of wxFrameWndProc
1306 MRESULT
wxFrame::OS2WindowProc(
1313 bool bProcessed
= FALSE
;
1319 // If we can't close, tell the system that we processed the
1320 // message - otherwise it would close us
1322 bProcessed
= !Close();
1326 bProcessed
= HandlePaint();
1327 mRc
= (MRESULT
)FALSE
;
1330 case WM_ERASEBACKGROUND
:
1332 // Returning TRUE to requests PM to paint the window background
1333 // in SYSCLR_WINDOW. We capture this here because the PS returned
1334 // in Frames is the PS for the whole frame, which we can't really
1335 // use at all. If you want to paint a different background, do it
1336 // in an OnPaint using a wxPaintDC.
1338 mRc
= (MRESULT
)(TRUE
);
1347 UnpackCommand( (WXWPARAM
)wParam
1354 bProcessed
= HandleCommand( wId
1367 UnpackMenuSelect( wParam
1373 bProcessed
= HandleMenuSelect( wItem
1377 mRc
= (MRESULT
)TRUE
;
1383 SHORT nScxold
= SHORT1FROMMP(wParam
); // Old horizontal size.
1384 SHORT nScyold
= SHORT2FROMMP(wParam
); // Old vertical size.
1385 SHORT nScxnew
= SHORT1FROMMP(lParam
); // New horizontal size.
1386 SHORT nScynew
= SHORT2FROMMP(lParam
); // New vertical size.
1388 lParam
= MRFROM2SHORT( nScxnew
- 20
1392 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1393 mRc
= (MRESULT
)FALSE
;
1396 case CM_QUERYDRAGIMAGE
:
1401 hIcon
= (HPOINTER
)::WinSendMsg(GetHWND(), WM_QUERYICON
, 0L, 0L);
1403 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1404 mRc
= (MRESULT
)hIcon
;
1405 bProcessed
= mRc
!= 0;
1411 mRc
= wxWindow::OS2WindowProc( uMessage
1415 return (MRESULT
)mRc
;
1416 } // wxFrame::OS2WindowProc
1418 void wxFrame::SetClient(WXHWND c_Hwnd
)
1420 // Duh...nothing to do under OS/2
1423 void wxFrame::SetClient(
1427 wxWindow
* pOldClient
= this->GetClient();
1428 bool bClientHasFocus
= pOldClient
&& (pOldClient
== wxWindow::FindFocus());
1430 if(pOldClient
== pWindow
) // nothing to do
1432 if(pWindow
== NULL
) // just need to remove old client
1434 if(pOldClient
== NULL
) // nothing to do
1437 if(bClientHasFocus
)
1440 pOldClient
->Enable( FALSE
);
1441 pOldClient
->Show( FALSE
);
1442 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1443 // to avoid OS/2 bug need to update frame
1444 ::WinSendMsg((HWND
)this->GetFrame(), WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1449 // Else need to change client
1454 ::WinEnableWindowUpdate((HWND
)GetHWND(), FALSE
);
1457 pOldClient
->Enable(FALSE
);
1458 pOldClient
->Show(FALSE
);
1459 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1461 pWindow
->Reparent(this);
1462 ::WinSetWindowUShort(pWindow
->GetHWND(), QWS_ID
, FID_CLIENT
);
1463 ::WinEnableWindowUpdate((HWND
)GetHWND(), TRUE
);
1465 pWindow
->Show(); // ensure client is showing
1466 if( this->IsShown() )
1469 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1473 wxWindow
* wxFrame::GetClient()
1475 return wxFindWinFromHandle((WXHWND
)::WinWindowFromID(m_hFrame
, FID_CLIENT
));