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_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
73 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
75 // ============================================================================
77 // ============================================================================
79 // ----------------------------------------------------------------------------
80 // static class members
81 // ----------------------------------------------------------------------------
84 #if wxUSE_NATIVE_STATUSBAR
85 bool wxFrame::m_bUseNativeStatusBar
= TRUE
;
87 bool wxFrame::m_bUseNativeStatusBar
= FALSE
;
90 #endif //wxUSE_STATUSBAR
92 // ----------------------------------------------------------------------------
93 // creation/destruction
94 // ----------------------------------------------------------------------------
98 m_nFsStatusBarFields
= 0;
99 m_nFsStatusBarHeight
= 0;
100 m_nFsToolBarHeight
= 0;
102 m_bWasMinimized
= FALSE
;
105 m_frameMenuBar
= NULL
;
106 m_frameToolBar
= NULL
;
107 m_frameStatusBar
= NULL
;
109 m_hTitleBar
= NULLHANDLE
;
110 m_hHScroll
= NULLHANDLE
;
111 m_hVScroll
= NULLHANDLE
;
116 memset(&m_vSwpTitleBar
, 0, sizeof(SWP
));
117 memset(&m_vSwpMenuBar
, 0, sizeof(SWP
));
118 memset(&m_vSwpHScroll
, 0, sizeof(SWP
));
119 memset(&m_vSwpVScroll
, 0, sizeof(SWP
));
120 memset(&m_vSwpStatusBar
, 0, sizeof(SWP
));
121 memset(&m_vSwpToolBar
, 0, sizeof(SWP
));
124 } // end of wxFrame::Init
126 bool wxFrame::Create(
129 , const wxString
& rsTitle
130 , const wxPoint
& rPos
131 , const wxSize
& rSize
133 , const wxString
& rsName
136 if (!wxTopLevelWindow::Create( pParent
145 wxModelessWindows
.Append(this);
147 } // end of wxFrame::Create
151 m_isBeingDeleted
= TRUE
;
153 } // end of wxFrame::~wxFrame
156 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
158 void wxFrame::DoGetClientSize(
163 wxTopLevelWindow::DoGetClientSize( pX
167 // No need to use statusbar code as in WIN32 as the FORMATFRAME
168 // window procedure ensures PM knows about the new frame client
169 // size internally. A ::WinQueryWindowRect (that is called in
170 // wxWindow's GetClient size from above) is all that is needed!
172 } // end of wxFrame::DoGetClientSize
175 // Set the client size (i.e. leave the calculation of borders etc.
178 void wxFrame::DoSetClientSize(
184 // Statusbars are not part of the OS/2 Client but parent frame
185 // so no statusbar consideration
187 wxTopLevelWindow::DoSetClientSize( nWidth
190 } // end of wxFrame::DoSetClientSize
192 // ----------------------------------------------------------------------------
193 // wxFrame: various geometry-related functions
194 // ----------------------------------------------------------------------------
196 void wxFrame::Raise()
198 wxFrameBase::Raise();
199 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
210 wxStatusBar
* wxFrame::OnCreateStatusBar(
214 , const wxString
& rName
217 wxStatusBar
* pStatusBar
= NULL
;
220 pStatusBar
= wxFrameBase::OnCreateStatusBar( nNumber
229 wxClientDC
vDC(pStatusBar
);
233 // Set the height according to the font and the border size
235 vDC
.SetFont(pStatusBar
->GetFont()); // Screws up the menues for some reason
236 vDC
.GetTextExtent( "X"
241 int nHeight
= ((11 * nY
) / 10 + 2 * pStatusBar
->GetBorderY());
243 pStatusBar
->SetSize( -1
249 ::WinSetParent( pStatusBar
->GetHWND()
253 ::WinSetOwner( pStatusBar
->GetHWND()
259 if(::WinIsWindowShowing(m_hFrame
))
260 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
263 } // end of wxFrame::OnCreateStatusBar
265 void wxFrame::PositionStatusBar()
272 // Native status bar positions itself
274 if (m_frameStatusBar
)
283 ::WinQueryWindowRect(m_hFrame
, &vRect
);
285 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
287 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
288 nWidth
= vRect
.xRight
- vRect
.xLeft
;
289 nY
= nY
- (vRect
.yBottom
- vFRect
.yBottom
);
291 m_frameStatusBar
->GetSize( &nStatbarWidth
295 nY
= nY
- nStatbarHeight
;
297 // Since we wish the status bar to be directly under the client area,
298 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
300 m_frameStatusBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
305 if (!::WinQueryWindowPos(m_frameStatusBar
->GetHWND(), &vSwp
))
307 vError
= ::WinGetLastError(vHabmain
);
308 sError
= wxPMErrorToStr(vError
);
309 wxLogError("Error setting parent for StautsBar. Error: %s\n", sError
.c_str());
313 } // end of wxFrame::PositionStatusBar
314 #endif // wxUSE_STATUSBAR
317 wxToolBar
* wxFrame::OnCreateToolBar(
320 , const wxString
& rsName
323 wxToolBar
* pToolBar
= wxFrameBase::OnCreateToolBar( lStyle
328 ::WinSetParent( pToolBar
->GetHWND()
332 ::WinSetOwner( pToolBar
->GetHWND()
336 } // end of WinGuiBase_CFrame::OnCreateToolBar
339 #if wxUSE_MENUS_NATIVE
340 void wxFrame::DetachMenuBar()
344 m_frameMenuBar
->Detach();
345 m_frameMenuBar
= NULL
;
347 } // end of wxFrame::DetachMenuBar
349 void wxFrame::SetMenuBar(
360 // Actually remove the menu from the frame
362 m_hMenu
= (WXHMENU
)0;
363 InternalSetMenuBar();
365 else // set new non NULL menu bar
367 m_frameMenuBar
= NULL
;
370 // Can set a menubar several times.
371 // TODO: how to prevent a memory leak if you have a currently-unattached
372 // menubar? wxWindows assumes that the frame will delete the menu (otherwise
373 // there are problems for MDI).
375 if (pMenuBar
->GetHMenu())
377 m_hMenu
= pMenuBar
->GetHMenu();
382 m_hMenu
= pMenuBar
->Create();
386 InternalSetMenuBar();
387 m_frameMenuBar
= pMenuBar
;
388 pMenuBar
->Attach((wxFrame
*)this);
390 } // end of wxFrame::SetMenuBar
392 void wxFrame::AttachMenuBar(
396 wxFrameBase::AttachMenuBar(pMenubar
);
398 m_frameMenuBar
= pMenubar
;
403 // Actually remove the menu from the frame
405 m_hMenu
= (WXHMENU
)0;
406 InternalSetMenuBar();
408 else // Set new non NULL menu bar
411 // Can set a menubar several times.
413 if (pMenubar
->GetHMenu())
415 m_hMenu
= pMenubar
->GetHMenu();
419 if (pMenubar
->IsAttached())
422 m_hMenu
= pMenubar
->Create();
427 InternalSetMenuBar();
429 } // end of wxFrame::AttachMenuBar
431 void wxFrame::InternalSetMenuBar()
436 // Set the parent and owner of the menubar to be the frame
438 if (!::WinSetParent(m_hMenu
, m_hFrame
, FALSE
))
440 vError
= ::WinGetLastError(vHabmain
);
441 sError
= wxPMErrorToStr(vError
);
442 wxLogError("Error setting parent for submenu. Error: %s\n", sError
.c_str());
445 if (!::WinSetOwner(m_hMenu
, m_hFrame
))
447 vError
= ::WinGetLastError(vHabmain
);
448 sError
= wxPMErrorToStr(vError
);
449 wxLogError("Error setting parent for submenu. Error: %s\n", sError
.c_str());
451 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
452 } // end of wxFrame::InternalSetMenuBar
453 #endif // wxUSE_MENUS_NATIVE
456 // Responds to colour changes, and passes event on to children
458 void wxFrame::OnSysColourChanged(
459 wxSysColourChangedEvent
& rEvent
462 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
466 if (m_frameStatusBar
)
468 wxSysColourChangedEvent vEvent2
;
470 vEvent2
.SetEventObject(m_frameStatusBar
);
471 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
473 #endif //wxUSE_STATUSBAR
476 // Propagate the event to the non-top-level children
478 wxWindow::OnSysColourChanged(rEvent
);
479 } // end of wxFrame::OnSysColourChanged
481 // Pass TRUE to show full screen, FALSE to restore.
482 bool wxFrame::ShowFullScreen(
492 m_bFsIsShowing
= TRUE
;
496 wxToolBar
* pTheToolBar
= GetToolBar();
497 #endif //wxUSE_TOOLBAR
500 wxStatusBar
* pTheStatusBar
= GetStatusBar();
501 #endif //wxUSE_STATUSBAR
507 pTheToolBar
->GetSize(&nDummyWidth
, &m_nFsToolBarHeight
);
508 #endif //wxUSE_TOOLBAR
512 pTheStatusBar
->GetSize(&nDummyWidth
, &m_nFsStatusBarHeight
);
513 #endif //wxUSE_STATUSBAR
517 // Zap the toolbar, menubar, and statusbar
519 if ((lStyle
& wxFULLSCREEN_NOTOOLBAR
) && pTheToolBar
)
521 pTheToolBar
->SetSize(-1,0);
522 pTheToolBar
->Show(FALSE
);
524 #endif //wxUSE_TOOLBAR
526 if (lStyle
& wxFULLSCREEN_NOMENUBAR
)
528 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
529 ::WinSetOwner(m_hMenu
, m_hFrame
);
530 ::WinSendMsg((HWND
)m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
535 // Save the number of fields in the statusbar
537 if ((lStyle
& wxFULLSCREEN_NOSTATUSBAR
) && pTheStatusBar
)
539 m_nFsStatusBarFields
= pTheStatusBar
->GetFieldsCount();
540 SetStatusBar((wxStatusBar
*) NULL
);
541 delete pTheStatusBar
;
544 m_nFsStatusBarFields
= 0;
545 #endif //wxUSE_STATUSBAR
548 // Zap the frame borders
552 // Save the 'normal' window style
554 m_lFsOldWindowStyle
= ::WinQueryWindowULong(m_hFrame
, QWL_STYLE
);
557 // Save the old position, width & height, maximize state
559 m_vFsOldSize
= GetRect();
560 m_bFsIsMaximized
= IsMaximized();
563 // Decide which window style flags to turn off
565 LONG lNewStyle
= m_lFsOldWindowStyle
;
568 if (lStyle
& wxFULLSCREEN_NOBORDER
)
569 lOffFlags
|= FCF_BORDER
;
570 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
571 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
573 lNewStyle
&= (~lOffFlags
);
576 // Change our window style to be compatible with full-screen mode
578 ::WinSetWindowULong((HWND
)m_hFrame
, QWL_STYLE
, (ULONG
)lNewStyle
);
581 // Resize to the size of the desktop
587 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
588 nWidth
= vRect
.xRight
- vRect
.xLeft
;
590 // Rmember OS/2 is backwards!
592 nHeight
= vRect
.yTop
- vRect
.yBottom
;
599 // Now flush the window style cache and actually go full-screen
601 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
610 wxSizeEvent
vEvent( wxSize( nWidth
616 GetEventHandler()->ProcessEvent(vEvent
);
624 m_bFsIsShowing
= FALSE
;
627 wxToolBar
* pTheToolBar
= GetToolBar();
630 // Restore the toolbar, menubar, and statusbar
632 if (pTheToolBar
&& (m_lFsStyle
& wxFULLSCREEN_NOTOOLBAR
))
634 pTheToolBar
->SetSize(-1, m_nFsToolBarHeight
);
635 pTheToolBar
->Show(TRUE
);
637 #endif //wxUSE_TOOLBAR
640 if ((m_lFsStyle
& wxFULLSCREEN_NOSTATUSBAR
) && (m_nFsStatusBarFields
> 0))
642 CreateStatusBar(m_nFsStatusBarFields
);
643 // PositionStatusBar();
645 #endif //wxUSE_STATUSBAR
647 if ((m_lFsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
649 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
650 ::WinSetOwner(m_hMenu
, m_hFrame
);
651 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
653 Maximize(m_bFsIsMaximized
);
655 ::WinSetWindowULong( m_hFrame
657 ,(ULONG
)m_lFsOldWindowStyle
659 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
668 return wxFrameBase::ShowFullScreen(bShow
, lStyle
);
669 } // end of wxFrame::ShowFullScreen
674 // ----------------------------------------------------------------------------
675 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
676 // from the client area, so the client area is what's really available for the
678 // ----------------------------------------------------------------------------
680 // Checks if there is a toolbar, and returns the first free client position
681 wxPoint
wxFrame::GetClientAreaOrigin() const
683 wxPoint vPoint
= wxTopLevelWindow::GetClientAreaOrigin();
686 // In OS/2 the toolbar and statusbar are frame extensions so there is no
687 // adjustment. The client is supposedly resized for a toolbar in OS/2
688 // as it is for the status bar.
691 } // end of wxFrame::GetClientAreaOrigin
693 // ----------------------------------------------------------------------------
694 // tool/status bar stuff
695 // ----------------------------------------------------------------------------
699 wxToolBar
* wxFrame::CreateToolBar(
702 , const wxString
& rName
705 if (wxFrameBase::CreateToolBar( lStyle
712 return m_frameToolBar
;
713 } // end of wxFrame::CreateToolBar
715 void wxFrame::PositionToolBar()
717 wxToolBar
* pToolBar
= GetToolBar();
730 ::WinQueryWindowRect(m_hFrame
, &vRect
);
731 vPos
.y
= (wxCoord
)vRect
.yTop
;
732 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
734 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
736 vPos
.y
= (wxCoord
)(vFRect
.yTop
- vRect
.yTop
);
737 pToolBar
->GetSize( &vTWidth
741 if (pToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
743 vWidth
= (wxCoord
)(vRect
.xRight
- vRect
.xLeft
);
744 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
753 wxCoord vSheight
= 0;
755 if (m_frameStatusBar
)
756 m_frameStatusBar
->GetSize( &vSwidth
759 vHeight
= (wxCoord
)(vRect
.yTop
- vRect
.yBottom
);
760 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
766 if( ::WinIsWindowShowing(m_hFrame
) )
767 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
768 } // end of wxFrame::PositionToolBar
769 #endif // wxUSE_TOOLBAR
771 // ----------------------------------------------------------------------------
772 // frame state (iconized/maximized/...)
773 // ----------------------------------------------------------------------------
776 // propagate our state change to all child frames: this allows us to emulate X
777 // Windows behaviour where child frames float independently of the parent one
778 // on the desktop, but are iconized/restored with it
780 void wxFrame::IconizeChildFrames(
784 // FIXME: Generic MDI does not use Frames for the Childs, so this does _not_
785 // work. Possibly, the right thing is simply to eliminate this
786 // functions and all the calls to it from within this file.
788 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
790 pNode
= pNode
->GetNext() )
792 wxWindow
* pWin
= pNode
->GetData();
793 wxFrame
* pFrame
= wxDynamicCast(pWin
, wxFrame
);
796 #if wxUSE_MDI_ARCHITECTURE
797 && !wxDynamicCast(pFrame
, wxMDIChildFrame
)
798 #endif // wxUSE_MDI_ARCHITECTURE
802 // We don't want to restore the child frames which had been
803 // iconized even before we were iconized, so save the child frame
804 // status when iconizing the parent frame and check it when
809 pFrame
->m_bWasMinimized
= pFrame
->IsIconized();
813 // This test works for both iconizing and restoring
815 if (!pFrame
->m_bWasMinimized
)
816 pFrame
->Iconize(bIconize
);
820 } // end of wxFrame::IconizeChildFrames
822 WXHICON
wxFrame::GetDefaultIcon() const
824 return (WXHICON
)(wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
825 : wxDEFAULT_FRAME_ICON
);
827 // ===========================================================================
828 // message processing
829 // ===========================================================================
831 // ---------------------------------------------------------------------------
833 // ---------------------------------------------------------------------------
834 bool wxFrame::OS2TranslateMessage(
839 // try the menu bar accels
841 wxMenuBar
* pMenuBar
= GetMenuBar();
846 #if wxUSE_ACCEL && wxUSE_MENUS_NATIVE
847 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
848 return rAcceleratorTable
.Translate(GetHWND(), pMsg
);
852 } // end of wxFrame::OS2TranslateMessage
854 // ---------------------------------------------------------------------------
855 // our private (non virtual) message handlers
856 // ---------------------------------------------------------------------------
857 bool wxFrame::HandlePaint()
861 if (::WinQueryUpdateRect(GetHWND(), &vRect
))
866 // Icons in PM are the same as "pointers"
868 const wxIcon
& vIcon
= GetIcon();
872 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
874 hIcon
= (HPOINTER
)m_hDefaultIcon
;
877 // Hold a pointer to the dc so long as the OnPaint() message
878 // is being processed
881 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
884 // Erase background before painting or we get white background
886 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
892 ::WinQueryWindowRect(GetHwnd(), &vRect3
);
894 static const int nIconWidth
= 32;
895 static const int nIconHeight
= 32;
896 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
897 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
899 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
906 if (!wxWindow::HandlePaint())
911 hPS
= ::WinBeginPaint( GetHwnd()
917 ::GpiCreateLogColorTable( hPS
921 ,(LONG
)wxTheColourDatabase
->m_nSize
922 ,(PLONG
)wxTheColourDatabase
->m_palTable
924 ::GpiCreateLogColorTable( hPS
934 ,GetBackgroundColour().GetPixel()
944 // nothing to paint - processed
948 } // end of wxFrame::HandlePaint
950 bool wxFrame::HandleSize(
956 bool bProcessed
= FALSE
;
962 // Only do it it if we were iconized before, otherwise resizing the
963 // parent frame has a curious side effect of bringing it under it's
969 // restore all child frames too
971 IconizeChildFrames(FALSE
);
972 (void)SendIconizeEvent(FALSE
);
984 // Iconize all child frames too
986 IconizeChildFrames(TRUE
);
987 (void)SendIconizeEvent();
995 // forward WM_SIZE to status bar control
997 #if wxUSE_NATIVE_STATUSBAR
998 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
1000 wxSizeEvent
vEvent( wxSize( nX
1003 ,m_frameStatusBar
->GetId()
1006 vEvent
.SetEventObject(m_frameStatusBar
);
1007 m_frameStatusBar
->OnSize(vEvent
);
1009 #endif // wxUSE_NATIVE_STATUSBAR
1011 PositionStatusBar();
1014 #endif // wxUSE_TOOLBAR
1016 bProcessed
= wxWindow::HandleSize( nX
1022 } // end of wxFrame::HandleSize
1024 bool wxFrame::HandleCommand(
1033 // In case it's e.g. a toolbar.
1035 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
1038 return pWin
->OS2Command( nCmd
1044 // Handle here commands from menus and accelerators
1046 if (nCmd
== CMDSRC_MENU
|| nCmd
== CMDSRC_ACCELERATOR
)
1048 #if wxUSE_MENUS_NATIVE
1049 if (wxCurrentPopupMenu
)
1051 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1053 wxCurrentPopupMenu
= NULL
;
1055 return pPopupMenu
->OS2Command( nCmd
1062 if (ProcessCommand(nId
))
1068 } // end of wxFrame::HandleCommand
1070 bool wxFrame::HandleMenuSelect(
1081 rc
= ::WinSendMsg(hMenu
, MM_QUERYITEM
, MPFROM2SHORT(nItem
, TRUE
), (MPARAM
)&mItem
);
1083 if(rc
&& !(mItem
.afStyle
& (MIS_SUBMENU
| MIS_SEPARATOR
)))
1085 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nItem
);
1087 vEvent
.SetEventObject(this);
1088 GetEventHandler()->ProcessEvent(vEvent
); // return value would be ignored by PM
1092 DoGiveHelp(wxEmptyString
, FALSE
);
1097 } // end of wxFrame::HandleMenuSelect
1099 // ---------------------------------------------------------------------------
1100 // Main Frame window proc
1101 // ---------------------------------------------------------------------------
1102 MRESULT EXPENTRY
wxFrameMainWndProc(
1109 MRESULT rc
= (MRESULT
)0;
1110 bool bProcessed
= FALSE
;
1111 wxFrame
* pWnd
= NULL
;
1113 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1116 case WM_QUERYFRAMECTLCOUNT
:
1117 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1119 USHORT uItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1121 rc
= MRFROMSHORT(uItemCount
);
1125 case WM_FORMATFRAME
:
1126 /////////////////////////////////////////////////////////////////////////////////
1127 // Applications that subclass frame controls may find that the frame is already
1128 // subclassed the number of frame controls is variable.
1129 // The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
1130 // subclassed by calling the previous window procedure and modifying its result.
1131 ////////////////////////////////////////////////////////////////////////////////
1143 pSWP
= (PSWP
)PVOIDFROMMP(wParam
);
1144 nItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1145 if(pWnd
->m_frameStatusBar
)
1147 ::WinQueryWindowRect(pWnd
->m_frameStatusBar
->GetHWND(), &vRstb
);
1148 pWnd
->m_frameStatusBar
->GetSize(NULL
, &nHeight
);
1150 if(pWnd
->m_frameToolBar
)
1152 ::WinQueryWindowRect(pWnd
->m_frameToolBar
->GetHWND(), &vRtlb
);
1153 pWnd
->m_frameToolBar
->GetSize(&nWidth
, &nHeight2
);
1155 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1156 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1157 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1158 ::WinMapWindowPoints(HWND_DESKTOP
, pWnd
->m_hFrame
, (PPOINTL
)&vRectl
, 2);
1159 for(i
= 0; i
< nItemCount
; i
++)
1161 if(pWnd
->m_hWnd
&& pSWP
[i
].hwnd
== pWnd
->m_hWnd
)
1163 if (pWnd
->m_frameToolBar
&& pWnd
->m_frameToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
1165 pSWP
[i
].x
= vRectl
.xLeft
;
1166 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1167 pSWP
[i
].cx
= vRectl
.xRight
- vRectl
.xLeft
;
1168 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- (nHeight
+ nHeight2
);
1172 pSWP
[i
].x
= vRectl
.xLeft
+ nWidth
;
1173 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1174 pSWP
[i
].cx
= vRectl
.xRight
- (vRectl
.xLeft
+ nWidth
);
1175 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- nHeight
;
1177 pSWP
[i
].fl
= SWP_SIZE
| SWP_MOVE
| SWP_SHOW
;
1178 pSWP
[i
].hwndInsertBehind
= HWND_TOP
;
1182 rc
= MRFROMSHORT(nItemCount
);
1187 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1188 rc
= pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
);
1190 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1193 } // end of wxFrameMainWndProc
1195 MRESULT EXPENTRY
wxFrameWndProc(
1203 // Trace all ulMsgs - useful for the debugging
1206 wxFrame
* pWnd
= NULL
;
1208 parentHwnd
= WinQueryWindow(hWnd
,QW_PARENT
);
1209 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1212 // When we get the first message for the HWND we just created, we associate
1213 // it with wxWindow stored in wxWndHook
1216 MRESULT rc
= (MRESULT
)0;
1219 // Stop right here if we don't have a valid handle in our wxWindow object.
1221 if (pWnd
&& !pWnd
->GetHWND())
1223 pWnd
->SetHWND((WXHWND
) hWnd
);
1224 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
1230 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
1232 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1235 } // end of wxFrameWndProc
1237 MRESULT
wxFrame::OS2WindowProc(
1244 bool bProcessed
= FALSE
;
1250 // If we can't close, tell the system that we processed the
1251 // message - otherwise it would close us
1253 bProcessed
= !Close();
1257 bProcessed
= HandlePaint();
1258 mRc
= (MRESULT
)FALSE
;
1261 case WM_ERASEBACKGROUND
:
1263 // Returning TRUE to requests PM to paint the window background
1264 // in SYSCLR_WINDOW. We capture this here because the PS returned
1265 // in Frames is the PS for the whole frame, which we can't really
1266 // use at all. If you want to paint a different background, do it
1267 // in an OnPaint using a wxPaintDC.
1269 mRc
= (MRESULT
)(TRUE
);
1278 UnpackCommand( (WXWPARAM
)wParam
1285 bProcessed
= HandleCommand( wId
1298 UnpackMenuSelect( wParam
1304 bProcessed
= HandleMenuSelect( wItem
1308 mRc
= (MRESULT
)TRUE
;
1314 SHORT nScxnew
= SHORT1FROMMP(lParam
); // New horizontal size.
1315 SHORT nScynew
= SHORT2FROMMP(lParam
); // New vertical size.
1317 lParam
= MRFROM2SHORT( nScxnew
- 20
1321 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1322 mRc
= (MRESULT
)FALSE
;
1325 case CM_QUERYDRAGIMAGE
:
1327 const wxIcon
& vIcon
= GetIcon();
1331 hIcon
= (HPOINTER
)::WinSendMsg(GetHWND(), WM_QUERYICON
, 0L, 0L);
1333 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1334 mRc
= (MRESULT
)hIcon
;
1335 bProcessed
= mRc
!= 0;
1341 mRc
= wxWindow::OS2WindowProc( uMessage
1345 return (MRESULT
)mRc
;
1346 } // wxFrame::OS2WindowProc
1348 void wxFrame::SetClient(WXHWND c_Hwnd
)
1350 // Duh...nothing to do under OS/2
1353 void wxFrame::SetClient(
1357 wxWindow
* pOldClient
= this->GetClient();
1358 bool bClientHasFocus
= pOldClient
&& (pOldClient
== wxWindow::FindFocus());
1360 if(pOldClient
== pWindow
) // nothing to do
1362 if(pWindow
== NULL
) // just need to remove old client
1364 if(pOldClient
== NULL
) // nothing to do
1367 if(bClientHasFocus
)
1370 pOldClient
->Enable( FALSE
);
1371 pOldClient
->Show( FALSE
);
1372 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1373 // to avoid OS/2 bug need to update frame
1374 ::WinSendMsg((HWND
)this->GetFrame(), WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1379 // Else need to change client
1384 ::WinEnableWindowUpdate((HWND
)GetHWND(), FALSE
);
1387 pOldClient
->Enable(FALSE
);
1388 pOldClient
->Show(FALSE
);
1389 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1391 pWindow
->Reparent(this);
1392 ::WinSetWindowUShort(pWindow
->GetHWND(), QWS_ID
, FID_CLIENT
);
1393 ::WinEnableWindowUpdate((HWND
)GetHWND(), TRUE
);
1395 pWindow
->Show(); // ensure client is showing
1396 if( this->IsShown() )
1399 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1403 wxWindow
* wxFrame::GetClient()
1405 return wxFindWinFromHandle((WXHWND
)::WinWindowFromID(m_hFrame
, FID_CLIENT
));
1408 void wxFrame::SendSizeEvent()
1412 RECTL vRect
= wxGetWindowRect(GetHwnd());
1414 ::WinPostMsg( GetHwnd()
1416 ,MPFROM2SHORT( vRect
.xRight
- vRect
.xLeft
1417 ,vRect
.xRight
- vRect
.xLeft
1419 ,MPFROM2SHORT( vRect
.yTop
- vRect
.yBottom
1420 ,vRect
.yTop
- vRect
.yBottom