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(
183 wxStatusBar
* pStatusBar
= GetStatusBar();
186 // Statusbars are not part of the OS/2 Client but parent frame
187 // so no statusbar consideration
189 wxTopLevelWindow::DoSetClientSize( nWidth
192 } // end of wxFrame::DoSetClientSize
194 // ----------------------------------------------------------------------------
195 // wxFrame: various geometry-related functions
196 // ----------------------------------------------------------------------------
198 void wxFrame::Raise()
200 wxFrameBase::Raise();
201 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
212 wxStatusBar
* wxFrame::OnCreateStatusBar(
216 , const wxString
& rName
219 wxStatusBar
* pStatusBar
= NULL
;
224 pStatusBar
= wxFrameBase::OnCreateStatusBar( nNumber
233 wxClientDC
vDC(pStatusBar
);
237 // Set the height according to the font and the border size
239 vDC
.SetFont(pStatusBar
->GetFont()); // Screws up the menues for some reason
240 vDC
.GetTextExtent( "X"
245 int nHeight
= ((11 * nY
) / 10 + 2 * pStatusBar
->GetBorderY());
247 pStatusBar
->SetSize( -1
253 ::WinSetParent( pStatusBar
->GetHWND()
257 ::WinSetOwner( pStatusBar
->GetHWND()
263 if(::WinIsWindowShowing(m_hFrame
))
264 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
267 } // end of wxFrame::OnCreateStatusBar
269 void wxFrame::PositionStatusBar()
276 // Native status bar positions itself
278 if (m_frameStatusBar
)
288 ::WinQueryWindowRect(m_hFrame
, &vRect
);
290 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
292 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
293 nWidth
= vRect
.xRight
- vRect
.xLeft
;
294 nY
= nY
- (vRect
.yBottom
- vFRect
.yBottom
);
296 m_frameStatusBar
->GetSize( &nStatbarWidth
300 nY
= nY
- nStatbarHeight
;
302 // Since we wish the status bar to be directly under the client area,
303 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
305 m_frameStatusBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
310 if (!::WinQueryWindowPos(m_frameStatusBar
->GetHWND(), &vSwp
))
312 vError
= ::WinGetLastError(vHabmain
);
313 sError
= wxPMErrorToStr(vError
);
314 wxLogError("Error setting parent for StautsBar. Error: %s\n", sError
);
318 } // end of wxFrame::PositionStatusBar
319 #endif // wxUSE_STATUSBAR
322 wxToolBar
* wxFrame::OnCreateToolBar(
325 , const wxString
& rsName
328 wxToolBar
* pToolBar
= wxFrameBase::OnCreateToolBar( lStyle
333 ::WinSetParent( pToolBar
->GetHWND()
337 ::WinSetOwner( pToolBar
->GetHWND()
341 } // end of WinGuiBase_CFrame::OnCreateToolBar
344 #if wxUSE_MENUS_NATIVE
345 void wxFrame::DetachMenuBar()
349 m_frameMenuBar
->Detach();
350 m_frameMenuBar
= NULL
;
352 } // end of wxFrame::DetachMenuBar
354 void wxFrame::SetMenuBar(
360 HWND hTitlebar
= NULLHANDLE
;
361 HWND hHScroll
= NULLHANDLE
;
362 HWND hVScroll
= NULLHANDLE
;
363 HWND hMenuBar
= NULLHANDLE
;
375 // Actually remove the menu from the frame
377 m_hMenu
= (WXHMENU
)0;
378 InternalSetMenuBar();
380 else // set new non NULL menu bar
382 m_frameMenuBar
= NULL
;
385 // Can set a menubar several times.
386 // TODO: how to prevent a memory leak if you have a currently-unattached
387 // menubar? wxWindows assumes that the frame will delete the menu (otherwise
388 // there are problems for MDI).
390 if (pMenuBar
->GetHMenu())
392 m_hMenu
= pMenuBar
->GetHMenu();
397 m_hMenu
= pMenuBar
->Create();
401 InternalSetMenuBar();
402 m_frameMenuBar
= pMenuBar
;
403 pMenuBar
->Attach((wxFrame
*)this);
405 } // end of wxFrame::SetMenuBar
407 void wxFrame::AttachMenuBar(
411 wxFrameBase::AttachMenuBar(pMenubar
);
413 m_frameMenuBar
= pMenubar
;
418 // Actually remove the menu from the frame
420 m_hMenu
= (WXHMENU
)0;
421 InternalSetMenuBar();
423 else // Set new non NULL menu bar
426 // Can set a menubar several times.
428 if (pMenubar
->GetHMenu())
430 m_hMenu
= pMenubar
->GetHMenu();
434 if (pMenubar
->IsAttached())
437 m_hMenu
= pMenubar
->Create();
442 InternalSetMenuBar();
444 } // end of wxFrame::AttachMenuBar
446 void wxFrame::InternalSetMenuBar()
451 // Set the parent and owner of the menubar to be the frame
453 if (!::WinSetParent(m_hMenu
, m_hFrame
, FALSE
))
455 vError
= ::WinGetLastError(vHabmain
);
456 sError
= wxPMErrorToStr(vError
);
457 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
460 if (!::WinSetOwner(m_hMenu
, m_hFrame
))
462 vError
= ::WinGetLastError(vHabmain
);
463 sError
= wxPMErrorToStr(vError
);
464 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
466 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
467 } // end of wxFrame::InternalSetMenuBar
468 #endif // wxUSE_MENUS_NATIVE
471 // Responds to colour changes, and passes event on to children
473 void wxFrame::OnSysColourChanged(
474 wxSysColourChangedEvent
& rEvent
477 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
481 if (m_frameStatusBar
)
483 wxSysColourChangedEvent vEvent2
;
485 vEvent2
.SetEventObject(m_frameStatusBar
);
486 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
488 #endif //wxUSE_STATUSBAR
491 // Propagate the event to the non-top-level children
493 wxWindow::OnSysColourChanged(rEvent
);
494 } // end of wxFrame::OnSysColourChanged
496 // Pass TRUE to show full screen, FALSE to restore.
497 bool wxFrame::ShowFullScreen(
507 m_bFsIsShowing
= TRUE
;
511 wxToolBar
* pTheToolBar
= GetToolBar();
512 #endif //wxUSE_TOOLBAR
515 wxStatusBar
* pTheStatusBar
= GetStatusBar();
516 #endif //wxUSE_STATUSBAR
522 pTheToolBar
->GetSize(&nDummyWidth
, &m_nFsToolBarHeight
);
523 #endif //wxUSE_TOOLBAR
527 pTheStatusBar
->GetSize(&nDummyWidth
, &m_nFsStatusBarHeight
);
528 #endif //wxUSE_STATUSBAR
532 // Zap the toolbar, menubar, and statusbar
534 if ((lStyle
& wxFULLSCREEN_NOTOOLBAR
) && pTheToolBar
)
536 pTheToolBar
->SetSize(-1,0);
537 pTheToolBar
->Show(FALSE
);
539 #endif //wxUSE_TOOLBAR
541 if (lStyle
& wxFULLSCREEN_NOMENUBAR
)
543 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
544 ::WinSetOwner(m_hMenu
, m_hFrame
);
545 ::WinSendMsg((HWND
)m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
550 // Save the number of fields in the statusbar
552 if ((lStyle
& wxFULLSCREEN_NOSTATUSBAR
) && pTheStatusBar
)
554 m_nFsStatusBarFields
= pTheStatusBar
->GetFieldsCount();
555 SetStatusBar((wxStatusBar
*) NULL
);
556 delete pTheStatusBar
;
559 m_nFsStatusBarFields
= 0;
560 #endif //wxUSE_STATUSBAR
563 // Zap the frame borders
567 // Save the 'normal' window style
569 m_lFsOldWindowStyle
= ::WinQueryWindowULong(m_hFrame
, QWL_STYLE
);
572 // Save the old position, width & height, maximize state
574 m_vFsOldSize
= GetRect();
575 m_bFsIsMaximized
= IsMaximized();
578 // Decide which window style flags to turn off
580 LONG lNewStyle
= m_lFsOldWindowStyle
;
583 if (lStyle
& wxFULLSCREEN_NOBORDER
)
584 lOffFlags
|= FCF_BORDER
;
585 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
586 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
588 lNewStyle
&= (~lOffFlags
);
591 // Change our window style to be compatible with full-screen mode
593 ::WinSetWindowULong((HWND
)m_hFrame
, QWL_STYLE
, (ULONG
)lNewStyle
);
596 // Resize to the size of the desktop
602 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
603 nWidth
= vRect
.xRight
- vRect
.xLeft
;
605 // Rmember OS/2 is backwards!
607 nHeight
= vRect
.yTop
- vRect
.yBottom
;
614 // Now flush the window style cache and actually go full-screen
616 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
625 wxSizeEvent
vEvent( wxSize( nWidth
631 GetEventHandler()->ProcessEvent(vEvent
);
639 m_bFsIsShowing
= FALSE
;
642 wxToolBar
* pTheToolBar
= GetToolBar();
645 // Restore the toolbar, menubar, and statusbar
647 if (pTheToolBar
&& (m_lFsStyle
& wxFULLSCREEN_NOTOOLBAR
))
649 pTheToolBar
->SetSize(-1, m_nFsToolBarHeight
);
650 pTheToolBar
->Show(TRUE
);
652 #endif //wxUSE_TOOLBAR
655 if ((m_lFsStyle
& wxFULLSCREEN_NOSTATUSBAR
) && (m_nFsStatusBarFields
> 0))
657 CreateStatusBar(m_nFsStatusBarFields
);
658 // PositionStatusBar();
660 #endif //wxUSE_STATUSBAR
662 if ((m_lFsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
664 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
665 ::WinSetOwner(m_hMenu
, m_hFrame
);
666 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
668 Maximize(m_bFsIsMaximized
);
670 ::WinSetWindowULong( m_hFrame
672 ,(ULONG
)m_lFsOldWindowStyle
674 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
683 return wxFrameBase::ShowFullScreen(bShow
, lStyle
);
684 } // end of wxFrame::ShowFullScreen
689 // ----------------------------------------------------------------------------
690 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
691 // from the client area, so the client area is what's really available for the
693 // ----------------------------------------------------------------------------
695 // Checks if there is a toolbar, and returns the first free client position
696 wxPoint
wxFrame::GetClientAreaOrigin() const
698 wxPoint vPoint
= wxTopLevelWindow::GetClientAreaOrigin();
701 // In OS/2 the toolbar and statusbar are frame extensions so there is no
702 // adjustment. The client is supposedly resized for a toolbar in OS/2
703 // as it is for the status bar.
706 } // end of wxFrame::GetClientAreaOrigin
708 // ----------------------------------------------------------------------------
709 // tool/status bar stuff
710 // ----------------------------------------------------------------------------
714 wxToolBar
* wxFrame::CreateToolBar(
717 , const wxString
& rName
720 if (wxFrameBase::CreateToolBar( lStyle
727 return m_frameToolBar
;
728 } // end of wxFrame::CreateToolBar
730 void wxFrame::PositionToolBar()
732 wxToolBar
* pToolBar
= GetToolBar();
747 ::WinQueryWindowRect(m_hFrame
, &vRect
);
748 vPos
.y
= (wxCoord
)vRect
.yTop
;
749 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
751 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
753 vPos
.y
= (wxCoord
)(vFRect
.yTop
- vRect
.yTop
);
754 pToolBar
->GetSize( &vTWidth
758 if (pToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
760 vWidth
= (wxCoord
)(vRect
.xRight
- vRect
.xLeft
);
761 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
770 wxCoord vSheight
= 0;
772 if (m_frameStatusBar
)
773 m_frameStatusBar
->GetSize( &vSwidth
776 vHeight
= (wxCoord
)(vRect
.yTop
- vRect
.yBottom
);
777 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
783 if( ::WinIsWindowShowing(m_hFrame
) )
784 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
785 } // end of wxFrame::PositionToolBar
786 #endif // wxUSE_TOOLBAR
788 // ----------------------------------------------------------------------------
789 // frame state (iconized/maximized/...)
790 // ----------------------------------------------------------------------------
793 // propagate our state change to all child frames: this allows us to emulate X
794 // Windows behaviour where child frames float independently of the parent one
795 // on the desktop, but are iconized/restored with it
797 void wxFrame::IconizeChildFrames(
801 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
803 pNode
= pNode
->GetNext() )
805 wxWindow
* pWin
= pNode
->GetData();
806 wxFrame
* pFrame
= wxDynamicCast(pWin
, wxFrame
);
809 #if wxUSE_MDI_ARCHITECTURE
810 && !wxDynamicCast(pFrame
, wxMDIChildFrame
)
811 #endif // wxUSE_MDI_ARCHITECTURE
815 // We don't want to restore the child frames which had been
816 // iconized even before we were iconized, so save the child frame
817 // status when iconizing the parent frame and check it when
822 pFrame
->m_bWasMinimized
= pFrame
->IsIconized();
826 // This test works for both iconizing and restoring
828 if (!pFrame
->m_bWasMinimized
)
829 pFrame
->Iconize(bIconize
);
832 } // end of wxFrame::IconizeChildFrames
834 WXHICON
wxFrame::GetDefaultIcon() const
836 return (WXHICON
)(wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
837 : wxDEFAULT_FRAME_ICON
);
839 // ===========================================================================
840 // message processing
841 // ===========================================================================
843 // ---------------------------------------------------------------------------
845 // ---------------------------------------------------------------------------
846 bool wxFrame::OS2TranslateMessage(
851 // try the menu bar accels
853 wxMenuBar
* pMenuBar
= GetMenuBar();
858 #if wxUSE_ACCEL && wxUSE_MENUS_NATIVE
859 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
860 return rAcceleratorTable
.Translate(GetHWND(), pMsg
);
864 } // end of wxFrame::OS2TranslateMessage
866 // ---------------------------------------------------------------------------
867 // our private (non virtual) message handlers
868 // ---------------------------------------------------------------------------
869 bool wxFrame::HandlePaint()
873 if (::WinQueryUpdateRect(GetHWND(), &vRect
))
878 // Icons in PM are the same as "pointers"
880 const wxIcon
& vIcon
= GetIcon();
884 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
886 hIcon
= (HPOINTER
)m_hDefaultIcon
;
889 // Hold a pointer to the dc so long as the OnPaint() message
890 // is being processed
893 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
896 // Erase background before painting or we get white background
898 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
905 ::WinQueryWindowRect(GetHwnd(), &vRect3
);
907 static const int nIconWidth
= 32;
908 static const int nIconHeight
= 32;
909 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
910 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
912 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
919 if (!wxWindow::HandlePaint())
924 hPS
= ::WinBeginPaint( GetHwnd()
930 ::GpiCreateLogColorTable( hPS
934 ,(LONG
)wxTheColourDatabase
->m_nSize
935 ,(PLONG
)wxTheColourDatabase
->m_palTable
937 ::GpiCreateLogColorTable( hPS
947 ,GetBackgroundColour().GetPixel()
957 // nothing to paint - processed
961 } // end of wxFrame::HandlePaint
963 bool wxFrame::HandleSize(
969 bool bProcessed
= FALSE
;
975 // Only do it it if we were iconized before, otherwise resizing the
976 // parent frame has a curious side effect of bringing it under it's
982 // restore all child frames too
984 IconizeChildFrames(FALSE
);
985 (void)SendIconizeEvent(FALSE
);
997 // Iconize all child frames too
999 IconizeChildFrames(TRUE
);
1000 (void)SendIconizeEvent();
1008 // forward WM_SIZE to status bar control
1010 #if wxUSE_NATIVE_STATUSBAR
1011 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
1013 wxSizeEvent
vEvent( wxSize( nX
1016 ,m_frameStatusBar
->GetId()
1019 vEvent
.SetEventObject(m_frameStatusBar
);
1020 m_frameStatusBar
->OnSize(vEvent
);
1022 #endif // wxUSE_NATIVE_STATUSBAR
1024 PositionStatusBar();
1027 #endif // wxUSE_TOOLBAR
1029 bProcessed
= wxWindow::HandleSize( nX
1035 } // end of wxFrame::HandleSize
1037 bool wxFrame::HandleCommand(
1046 // In case it's e.g. a toolbar.
1048 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
1051 return pWin
->OS2Command( nCmd
1057 // Handle here commands from menus and accelerators
1059 if (nCmd
== CMDSRC_MENU
|| nCmd
== CMDSRC_ACCELERATOR
)
1061 #if wxUSE_MENUS_NATIVE
1062 if (wxCurrentPopupMenu
)
1064 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1066 wxCurrentPopupMenu
= NULL
;
1068 return pPopupMenu
->OS2Command( nCmd
1075 if (ProcessCommand(nId
))
1081 } // end of wxFrame::HandleCommand
1083 bool wxFrame::HandleMenuSelect(
1094 rc
= ::WinSendMsg(hMenu
, MM_QUERYITEM
, MPFROM2SHORT(nItem
, TRUE
), (MPARAM
)&mItem
);
1096 if(rc
&& !(mItem
.afStyle
& (MIS_SUBMENU
| MIS_SEPARATOR
)))
1098 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nItem
);
1100 vEvent
.SetEventObject(this);
1101 GetEventHandler()->ProcessEvent(vEvent
); // return value would be ignored by PM
1105 DoGiveHelp(wxEmptyString
, FALSE
);
1110 } // end of wxFrame::HandleMenuSelect
1112 // ---------------------------------------------------------------------------
1113 // Main Frame window proc
1114 // ---------------------------------------------------------------------------
1115 MRESULT EXPENTRY
wxFrameMainWndProc(
1122 MRESULT rc
= (MRESULT
)0;
1123 bool bProcessed
= FALSE
;
1124 wxFrame
* pWnd
= NULL
;
1126 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1129 case WM_QUERYFRAMECTLCOUNT
:
1130 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1132 USHORT uItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1134 rc
= MRFROMSHORT(uItemCount
);
1138 case WM_FORMATFRAME
:
1139 /////////////////////////////////////////////////////////////////////////////////
1140 // Applications that subclass frame controls may find that the frame is already
1141 // subclassed the number of frame controls is variable.
1142 // The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
1143 // subclassed by calling the previous window procedure and modifying its result.
1144 ////////////////////////////////////////////////////////////////////////////////
1156 pSWP
= (PSWP
)PVOIDFROMMP(wParam
);
1157 nItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1158 if(pWnd
->m_frameStatusBar
)
1160 ::WinQueryWindowRect(pWnd
->m_frameStatusBar
->GetHWND(), &vRstb
);
1161 pWnd
->m_frameStatusBar
->GetSize(NULL
, &nHeight
);
1163 if(pWnd
->m_frameToolBar
)
1165 ::WinQueryWindowRect(pWnd
->m_frameToolBar
->GetHWND(), &vRtlb
);
1166 pWnd
->m_frameToolBar
->GetSize(&nWidth
, &nHeight2
);
1168 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1169 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1170 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1171 ::WinMapWindowPoints(HWND_DESKTOP
, pWnd
->m_hFrame
, (PPOINTL
)&vRectl
, 2);
1172 for(i
= 0; i
< nItemCount
; i
++)
1174 if(pWnd
->m_hWnd
&& pSWP
[i
].hwnd
== pWnd
->m_hWnd
)
1176 if (pWnd
->m_frameToolBar
&& pWnd
->m_frameToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
1178 pSWP
[i
].x
= vRectl
.xLeft
;
1179 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1180 pSWP
[i
].cx
= vRectl
.xRight
- vRectl
.xLeft
;
1181 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- (nHeight
+ nHeight2
);
1185 pSWP
[i
].x
= vRectl
.xLeft
+ nWidth
;
1186 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1187 pSWP
[i
].cx
= vRectl
.xRight
- (vRectl
.xLeft
+ nWidth
);
1188 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- nHeight
;
1190 pSWP
[i
].fl
= SWP_SIZE
| SWP_MOVE
| SWP_SHOW
;
1191 pSWP
[i
].hwndInsertBehind
= HWND_TOP
;
1195 rc
= MRFROMSHORT(nItemCount
);
1200 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1201 rc
= pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
);
1203 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1206 } // end of wxFrameMainWndProc
1208 MRESULT EXPENTRY
wxFrameWndProc(
1216 // Trace all ulMsgs - useful for the debugging
1219 wxFrame
* pWnd
= NULL
;
1221 parentHwnd
= WinQueryWindow(hWnd
,QW_PARENT
);
1222 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1225 // When we get the first message for the HWND we just created, we associate
1226 // it with wxWindow stored in wxWndHook
1229 MRESULT rc
= (MRESULT
)0;
1230 bool bProcessed
= FALSE
;
1233 // Stop right here if we don't have a valid handle in our wxWindow object.
1235 if (pWnd
&& !pWnd
->GetHWND())
1237 pWnd
->SetHWND((WXHWND
) hWnd
);
1238 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
1244 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
1246 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1249 } // end of wxFrameWndProc
1251 MRESULT
wxFrame::OS2WindowProc(
1258 bool bProcessed
= FALSE
;
1264 // If we can't close, tell the system that we processed the
1265 // message - otherwise it would close us
1267 bProcessed
= !Close();
1271 bProcessed
= HandlePaint();
1272 mRc
= (MRESULT
)FALSE
;
1275 case WM_ERASEBACKGROUND
:
1277 // Returning TRUE to requests PM to paint the window background
1278 // in SYSCLR_WINDOW. We capture this here because the PS returned
1279 // in Frames is the PS for the whole frame, which we can't really
1280 // use at all. If you want to paint a different background, do it
1281 // in an OnPaint using a wxPaintDC.
1283 mRc
= (MRESULT
)(TRUE
);
1292 UnpackCommand( (WXWPARAM
)wParam
1299 bProcessed
= HandleCommand( wId
1312 UnpackMenuSelect( wParam
1318 bProcessed
= HandleMenuSelect( wItem
1322 mRc
= (MRESULT
)TRUE
;
1328 SHORT nScxold
= SHORT1FROMMP(wParam
); // Old horizontal size.
1329 SHORT nScyold
= SHORT2FROMMP(wParam
); // Old vertical size.
1330 SHORT nScxnew
= SHORT1FROMMP(lParam
); // New horizontal size.
1331 SHORT nScynew
= SHORT2FROMMP(lParam
); // New vertical size.
1333 lParam
= MRFROM2SHORT( nScxnew
- 20
1337 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1338 mRc
= (MRESULT
)FALSE
;
1341 case CM_QUERYDRAGIMAGE
:
1343 const wxIcon
& vIcon
= GetIcon();
1347 hIcon
= (HPOINTER
)::WinSendMsg(GetHWND(), WM_QUERYICON
, 0L, 0L);
1349 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1350 mRc
= (MRESULT
)hIcon
;
1351 bProcessed
= mRc
!= 0;
1357 mRc
= wxWindow::OS2WindowProc( uMessage
1361 return (MRESULT
)mRc
;
1362 } // wxFrame::OS2WindowProc
1364 void wxFrame::SetClient(WXHWND c_Hwnd
)
1366 // Duh...nothing to do under OS/2
1369 void wxFrame::SetClient(
1373 wxWindow
* pOldClient
= this->GetClient();
1374 bool bClientHasFocus
= pOldClient
&& (pOldClient
== wxWindow::FindFocus());
1376 if(pOldClient
== pWindow
) // nothing to do
1378 if(pWindow
== NULL
) // just need to remove old client
1380 if(pOldClient
== NULL
) // nothing to do
1383 if(bClientHasFocus
)
1386 pOldClient
->Enable( FALSE
);
1387 pOldClient
->Show( FALSE
);
1388 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1389 // to avoid OS/2 bug need to update frame
1390 ::WinSendMsg((HWND
)this->GetFrame(), WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1395 // Else need to change client
1400 ::WinEnableWindowUpdate((HWND
)GetHWND(), FALSE
);
1403 pOldClient
->Enable(FALSE
);
1404 pOldClient
->Show(FALSE
);
1405 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1407 pWindow
->Reparent(this);
1408 ::WinSetWindowUShort(pWindow
->GetHWND(), QWS_ID
, FID_CLIENT
);
1409 ::WinEnableWindowUpdate((HWND
)GetHWND(), TRUE
);
1411 pWindow
->Show(); // ensure client is showing
1412 if( this->IsShown() )
1415 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1419 wxWindow
* wxFrame::GetClient()
1421 return wxFindWinFromHandle((WXHWND
)::WinWindowFromID(m_hFrame
, FID_CLIENT
));