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 wxList WXDLLEXPORT wxPendingDelete
;
56 #if wxUSE_MENUS_NATIVE
57 extern wxMenu
*wxCurrentPopupMenu
;
60 extern void wxAssociateWinWithHandle( HWND hWnd
64 // ----------------------------------------------------------------------------
66 // ----------------------------------------------------------------------------
68 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
69 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
72 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
74 // ============================================================================
76 // ============================================================================
78 // ----------------------------------------------------------------------------
79 // static class members
80 // ----------------------------------------------------------------------------
83 #if wxUSE_NATIVE_STATUSBAR
84 bool wxFrame::m_bUseNativeStatusBar
= TRUE
;
86 bool wxFrame::m_bUseNativeStatusBar
= FALSE
;
89 #endif //wxUSE_STATUSBAR
91 // ----------------------------------------------------------------------------
92 // creation/destruction
93 // ----------------------------------------------------------------------------
97 m_nFsStatusBarFields
= 0;
98 m_nFsStatusBarHeight
= 0;
99 m_nFsToolBarHeight
= 0;
101 m_bWasMinimized
= FALSE
;
104 m_frameMenuBar
= NULL
;
105 m_frameToolBar
= NULL
;
106 m_frameStatusBar
= NULL
;
108 m_hTitleBar
= NULLHANDLE
;
109 m_hHScroll
= NULLHANDLE
;
110 m_hVScroll
= NULLHANDLE
;
115 memset(&m_vSwpTitleBar
, 0, sizeof(SWP
));
116 memset(&m_vSwpMenuBar
, 0, sizeof(SWP
));
117 memset(&m_vSwpHScroll
, 0, sizeof(SWP
));
118 memset(&m_vSwpVScroll
, 0, sizeof(SWP
));
119 memset(&m_vSwpStatusBar
, 0, sizeof(SWP
));
120 memset(&m_vSwpToolBar
, 0, sizeof(SWP
));
123 } // end of wxFrame::Init
125 bool wxFrame::Create(
128 , const wxString
& rsTitle
129 , const wxPoint
& rPos
130 , const wxSize
& rSize
132 , const wxString
& rsName
135 if (!wxTopLevelWindow::Create( pParent
145 } // end of wxFrame::Create
149 m_isBeingDeleted
= TRUE
;
151 } // end of wxFrame::~wxFrame
154 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
156 void wxFrame::DoGetClientSize(
161 wxTopLevelWindow::DoGetClientSize( pX
165 // No need to use statusbar code as in WIN32 as the FORMATFRAME
166 // window procedure ensures PM knows about the new frame client
167 // size internally. A ::WinQueryWindowRect (that is called in
168 // wxWindow's GetClient size from above) is all that is needed!
170 } // end of wxFrame::DoGetClientSize
173 // Set the client size (i.e. leave the calculation of borders etc.
176 void wxFrame::DoSetClientSize(
182 // Statusbars are not part of the OS/2 Client but parent frame
183 // so no statusbar consideration
185 wxTopLevelWindow::DoSetClientSize( nWidth
188 } // end of wxFrame::DoSetClientSize
190 // ----------------------------------------------------------------------------
191 // wxFrame: various geometry-related functions
192 // ----------------------------------------------------------------------------
194 void wxFrame::Raise()
196 wxFrameBase::Raise();
197 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
208 wxStatusBar
* wxFrame::OnCreateStatusBar(
212 , const wxString
& rName
215 wxStatusBar
* pStatusBar
= NULL
;
218 pStatusBar
= wxFrameBase::OnCreateStatusBar( nNumber
227 wxClientDC
vDC(pStatusBar
);
231 // Set the height according to the font and the border size
233 vDC
.SetFont(pStatusBar
->GetFont()); // Screws up the menues for some reason
234 vDC
.GetTextExtent( "X"
239 int nHeight
= ((11 * nY
) / 10 + 2 * pStatusBar
->GetBorderY());
241 pStatusBar
->SetSize( -1
247 ::WinSetParent( pStatusBar
->GetHWND()
251 ::WinSetOwner( pStatusBar
->GetHWND()
257 if(::WinIsWindowShowing(m_hFrame
))
258 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
261 } // end of wxFrame::OnCreateStatusBar
263 void wxFrame::PositionStatusBar()
270 // Native status bar positions itself
272 if (m_frameStatusBar
)
281 ::WinQueryWindowRect(m_hFrame
, &vRect
);
283 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
285 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
286 nWidth
= vRect
.xRight
- vRect
.xLeft
;
287 nY
= nY
- (vRect
.yBottom
- vFRect
.yBottom
);
289 m_frameStatusBar
->GetSize( &nStatbarWidth
293 nY
= nY
- nStatbarHeight
;
295 // Since we wish the status bar to be directly under the client area,
296 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
298 m_frameStatusBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
303 if (!::WinQueryWindowPos(m_frameStatusBar
->GetHWND(), &vSwp
))
305 vError
= ::WinGetLastError(vHabmain
);
306 sError
= wxPMErrorToStr(vError
);
307 wxLogError("Error setting parent for StautsBar. Error: %s\n", sError
.c_str());
311 } // end of wxFrame::PositionStatusBar
312 #endif // wxUSE_STATUSBAR
315 wxToolBar
* wxFrame::OnCreateToolBar(
318 , const wxString
& rsName
321 wxToolBar
* pToolBar
= wxFrameBase::OnCreateToolBar( lStyle
326 ::WinSetParent( pToolBar
->GetHWND()
330 ::WinSetOwner( pToolBar
->GetHWND()
334 } // end of WinGuiBase_CFrame::OnCreateToolBar
337 #if wxUSE_MENUS_NATIVE
338 void wxFrame::DetachMenuBar()
342 m_frameMenuBar
->Detach();
343 m_frameMenuBar
= NULL
;
345 } // end of wxFrame::DetachMenuBar
347 void wxFrame::SetMenuBar(
358 // Actually remove the menu from the frame
360 m_hMenu
= (WXHMENU
)0;
361 InternalSetMenuBar();
363 else // set new non NULL menu bar
365 m_frameMenuBar
= NULL
;
368 // Can set a menubar several times.
369 // TODO: how to prevent a memory leak if you have a currently-unattached
370 // menubar? wxWidgets assumes that the frame will delete the menu (otherwise
371 // there are problems for MDI).
373 if (pMenuBar
->GetHMenu())
375 m_hMenu
= pMenuBar
->GetHMenu();
380 m_hMenu
= pMenuBar
->Create();
384 InternalSetMenuBar();
385 m_frameMenuBar
= pMenuBar
;
386 pMenuBar
->Attach((wxFrame
*)this);
388 } // end of wxFrame::SetMenuBar
390 void wxFrame::AttachMenuBar(
394 wxFrameBase::AttachMenuBar(pMenubar
);
396 m_frameMenuBar
= pMenubar
;
401 // Actually remove the menu from the frame
403 m_hMenu
= (WXHMENU
)0;
404 InternalSetMenuBar();
406 else // Set new non NULL menu bar
409 // Can set a menubar several times.
411 if (pMenubar
->GetHMenu())
413 m_hMenu
= pMenubar
->GetHMenu();
417 if (pMenubar
->IsAttached())
420 m_hMenu
= pMenubar
->Create();
425 InternalSetMenuBar();
427 } // end of wxFrame::AttachMenuBar
429 void wxFrame::InternalSetMenuBar()
434 // Set the parent and owner of the menubar to be the frame
436 if (!::WinSetParent(m_hMenu
, m_hFrame
, FALSE
))
438 vError
= ::WinGetLastError(vHabmain
);
439 sError
= wxPMErrorToStr(vError
);
440 wxLogError("Error setting parent for submenu. Error: %s\n", sError
.c_str());
443 if (!::WinSetOwner(m_hMenu
, m_hFrame
))
445 vError
= ::WinGetLastError(vHabmain
);
446 sError
= wxPMErrorToStr(vError
);
447 wxLogError("Error setting parent for submenu. Error: %s\n", sError
.c_str());
449 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
450 } // end of wxFrame::InternalSetMenuBar
451 #endif // wxUSE_MENUS_NATIVE
454 // Responds to colour changes, and passes event on to children
456 void wxFrame::OnSysColourChanged(
457 wxSysColourChangedEvent
& rEvent
460 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
464 if (m_frameStatusBar
)
466 wxSysColourChangedEvent vEvent2
;
468 vEvent2
.SetEventObject(m_frameStatusBar
);
469 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
471 #endif //wxUSE_STATUSBAR
474 // Propagate the event to the non-top-level children
476 wxWindow::OnSysColourChanged(rEvent
);
477 } // end of wxFrame::OnSysColourChanged
479 // Pass TRUE to show full screen, FALSE to restore.
480 bool wxFrame::ShowFullScreen(
490 m_bFsIsShowing
= TRUE
;
494 wxToolBar
* pTheToolBar
= GetToolBar();
495 #endif //wxUSE_TOOLBAR
498 wxStatusBar
* pTheStatusBar
= GetStatusBar();
499 #endif //wxUSE_STATUSBAR
505 pTheToolBar
->GetSize(&nDummyWidth
, &m_nFsToolBarHeight
);
506 #endif //wxUSE_TOOLBAR
510 pTheStatusBar
->GetSize(&nDummyWidth
, &m_nFsStatusBarHeight
);
511 #endif //wxUSE_STATUSBAR
515 // Zap the toolbar, menubar, and statusbar
517 if ((lStyle
& wxFULLSCREEN_NOTOOLBAR
) && pTheToolBar
)
519 pTheToolBar
->SetSize(-1,0);
520 pTheToolBar
->Show(FALSE
);
522 #endif //wxUSE_TOOLBAR
524 if (lStyle
& wxFULLSCREEN_NOMENUBAR
)
526 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
527 ::WinSetOwner(m_hMenu
, m_hFrame
);
528 ::WinSendMsg((HWND
)m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
533 // Save the number of fields in the statusbar
535 if ((lStyle
& wxFULLSCREEN_NOSTATUSBAR
) && pTheStatusBar
)
537 m_nFsStatusBarFields
= pTheStatusBar
->GetFieldsCount();
538 SetStatusBar((wxStatusBar
*) NULL
);
539 delete pTheStatusBar
;
542 m_nFsStatusBarFields
= 0;
543 #endif //wxUSE_STATUSBAR
546 // Zap the frame borders
550 // Save the 'normal' window style
552 m_lFsOldWindowStyle
= ::WinQueryWindowULong(m_hFrame
, QWL_STYLE
);
555 // Save the old position, width & height, maximize state
557 m_vFsOldSize
= GetRect();
558 m_bFsIsMaximized
= IsMaximized();
561 // Decide which window style flags to turn off
563 LONG lNewStyle
= m_lFsOldWindowStyle
;
566 if (lStyle
& wxFULLSCREEN_NOBORDER
)
567 lOffFlags
|= FCF_BORDER
;
568 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
569 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
571 lNewStyle
&= (~lOffFlags
);
574 // Change our window style to be compatible with full-screen mode
576 ::WinSetWindowULong((HWND
)m_hFrame
, QWL_STYLE
, (ULONG
)lNewStyle
);
579 // Resize to the size of the desktop
585 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
586 nWidth
= vRect
.xRight
- vRect
.xLeft
;
588 // Rmember OS/2 is backwards!
590 nHeight
= vRect
.yTop
- vRect
.yBottom
;
597 // Now flush the window style cache and actually go full-screen
599 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
608 wxSizeEvent
vEvent( wxSize( nWidth
614 GetEventHandler()->ProcessEvent(vEvent
);
622 m_bFsIsShowing
= FALSE
;
625 wxToolBar
* pTheToolBar
= GetToolBar();
628 // Restore the toolbar, menubar, and statusbar
630 if (pTheToolBar
&& (m_lFsStyle
& wxFULLSCREEN_NOTOOLBAR
))
632 pTheToolBar
->SetSize(-1, m_nFsToolBarHeight
);
633 pTheToolBar
->Show(TRUE
);
635 #endif //wxUSE_TOOLBAR
638 if ((m_lFsStyle
& wxFULLSCREEN_NOSTATUSBAR
) && (m_nFsStatusBarFields
> 0))
640 CreateStatusBar(m_nFsStatusBarFields
);
641 // PositionStatusBar();
643 #endif //wxUSE_STATUSBAR
645 if ((m_lFsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
647 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
648 ::WinSetOwner(m_hMenu
, m_hFrame
);
649 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
651 Maximize(m_bFsIsMaximized
);
653 ::WinSetWindowULong( m_hFrame
655 ,(ULONG
)m_lFsOldWindowStyle
657 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
666 return wxFrameBase::ShowFullScreen(bShow
, lStyle
);
667 } // end of wxFrame::ShowFullScreen
672 // ----------------------------------------------------------------------------
673 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
674 // from the client area, so the client area is what's really available for the
676 // ----------------------------------------------------------------------------
678 // Checks if there is a toolbar, and returns the first free client position
679 wxPoint
wxFrame::GetClientAreaOrigin() const
681 wxPoint vPoint
= wxTopLevelWindow::GetClientAreaOrigin();
684 // In OS/2 the toolbar and statusbar are frame extensions so there is no
685 // adjustment. The client is supposedly resized for a toolbar in OS/2
686 // as it is for the status bar.
689 } // end of wxFrame::GetClientAreaOrigin
691 // ----------------------------------------------------------------------------
692 // tool/status bar stuff
693 // ----------------------------------------------------------------------------
697 wxToolBar
* wxFrame::CreateToolBar(
700 , const wxString
& rName
703 if (wxFrameBase::CreateToolBar( lStyle
710 return m_frameToolBar
;
711 } // end of wxFrame::CreateToolBar
713 void wxFrame::PositionToolBar()
715 wxToolBar
* pToolBar
= GetToolBar();
728 ::WinQueryWindowRect(m_hFrame
, &vRect
);
729 vPos
.y
= (wxCoord
)vRect
.yTop
;
730 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
732 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
734 vPos
.y
= (wxCoord
)(vFRect
.yTop
- vRect
.yTop
);
735 pToolBar
->GetSize( &vTWidth
739 if (pToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
741 vWidth
= (wxCoord
)(vRect
.xRight
- vRect
.xLeft
);
742 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
751 wxCoord vSheight
= 0;
753 if (m_frameStatusBar
)
754 m_frameStatusBar
->GetSize( &vSwidth
757 vHeight
= (wxCoord
)(vRect
.yTop
- vRect
.yBottom
);
758 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
764 if( ::WinIsWindowShowing(m_hFrame
) )
765 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
766 } // end of wxFrame::PositionToolBar
767 #endif // wxUSE_TOOLBAR
769 // ----------------------------------------------------------------------------
770 // frame state (iconized/maximized/...)
771 // ----------------------------------------------------------------------------
774 // propagate our state change to all child frames: this allows us to emulate X
775 // Windows behaviour where child frames float independently of the parent one
776 // on the desktop, but are iconized/restored with it
778 void wxFrame::IconizeChildFrames(
782 // FIXME: Generic MDI does not use Frames for the Childs, so this does _not_
783 // work. Possibly, the right thing is simply to eliminate this
784 // functions and all the calls to it from within this file.
786 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
788 pNode
= pNode
->GetNext() )
790 wxWindow
* pWin
= pNode
->GetData();
791 wxFrame
* pFrame
= wxDynamicCast(pWin
, wxFrame
);
794 #if wxUSE_MDI_ARCHITECTURE
795 && !wxDynamicCast(pFrame
, wxMDIChildFrame
)
796 #endif // wxUSE_MDI_ARCHITECTURE
800 // We don't want to restore the child frames which had been
801 // iconized even before we were iconized, so save the child frame
802 // status when iconizing the parent frame and check it when
807 pFrame
->m_bWasMinimized
= pFrame
->IsIconized();
811 // This test works for both iconizing and restoring
813 if (!pFrame
->m_bWasMinimized
)
814 pFrame
->Iconize(bIconize
);
818 } // end of wxFrame::IconizeChildFrames
820 WXHICON
wxFrame::GetDefaultIcon() const
822 return (WXHICON
)(wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
823 : wxDEFAULT_FRAME_ICON
);
825 // ===========================================================================
826 // message processing
827 // ===========================================================================
829 // ---------------------------------------------------------------------------
831 // ---------------------------------------------------------------------------
832 bool wxFrame::OS2TranslateMessage(
837 // try the menu bar accels
839 wxMenuBar
* pMenuBar
= GetMenuBar();
844 #if wxUSE_ACCEL && wxUSE_MENUS_NATIVE
845 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
846 return rAcceleratorTable
.Translate(GetHWND(), pMsg
);
850 } // end of wxFrame::OS2TranslateMessage
852 // ---------------------------------------------------------------------------
853 // our private (non virtual) message handlers
854 // ---------------------------------------------------------------------------
855 bool wxFrame::HandlePaint()
859 if (::WinQueryUpdateRect(GetHWND(), &vRect
))
864 // Icons in PM are the same as "pointers"
866 const wxIcon
& vIcon
= GetIcon();
870 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
872 hIcon
= (HPOINTER
)m_hDefaultIcon
;
875 // Hold a pointer to the dc so long as the OnPaint() message
876 // is being processed
879 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
882 // Erase background before painting or we get white background
884 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
890 ::WinQueryWindowRect(GetHwnd(), &vRect3
);
892 static const int nIconWidth
= 32;
893 static const int nIconHeight
= 32;
894 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
895 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
897 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
904 if (!wxWindow::HandlePaint())
909 hPS
= ::WinBeginPaint( GetHwnd()
915 ::GpiCreateLogColorTable( hPS
919 ,(LONG
)wxTheColourDatabase
->m_nSize
920 ,(PLONG
)wxTheColourDatabase
->m_palTable
922 ::GpiCreateLogColorTable( hPS
932 ,GetBackgroundColour().GetPixel()
942 // nothing to paint - processed
946 } // end of wxFrame::HandlePaint
948 bool wxFrame::HandleSize(
954 bool bProcessed
= FALSE
;
960 // Only do it it if we were iconized before, otherwise resizing the
961 // parent frame has a curious side effect of bringing it under it's
967 // restore all child frames too
969 IconizeChildFrames(FALSE
);
970 (void)SendIconizeEvent(FALSE
);
982 // Iconize all child frames too
984 IconizeChildFrames(TRUE
);
985 (void)SendIconizeEvent();
993 // forward WM_SIZE to status bar control
995 #if wxUSE_NATIVE_STATUSBAR
996 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
998 wxSizeEvent
vEvent( wxSize( nX
1001 ,m_frameStatusBar
->GetId()
1004 vEvent
.SetEventObject(m_frameStatusBar
);
1005 m_frameStatusBar
->OnSize(vEvent
);
1007 #endif // wxUSE_NATIVE_STATUSBAR
1009 PositionStatusBar();
1012 #endif // wxUSE_TOOLBAR
1014 bProcessed
= wxWindow::HandleSize( nX
1020 } // end of wxFrame::HandleSize
1022 bool wxFrame::HandleCommand(
1031 // In case it's e.g. a toolbar.
1033 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
1036 return pWin
->OS2Command( nCmd
1042 // Handle here commands from menus and accelerators
1044 if (nCmd
== CMDSRC_MENU
|| nCmd
== CMDSRC_ACCELERATOR
)
1046 #if wxUSE_MENUS_NATIVE
1047 if (wxCurrentPopupMenu
)
1049 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1051 wxCurrentPopupMenu
= NULL
;
1053 return pPopupMenu
->OS2Command( nCmd
1060 if (ProcessCommand(nId
))
1066 } // end of wxFrame::HandleCommand
1068 bool wxFrame::HandleMenuSelect(
1079 rc
= ::WinSendMsg(hMenu
, MM_QUERYITEM
, MPFROM2SHORT(nItem
, TRUE
), (MPARAM
)&mItem
);
1081 if(rc
&& !(mItem
.afStyle
& (MIS_SUBMENU
| MIS_SEPARATOR
)))
1083 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nItem
);
1085 vEvent
.SetEventObject(this);
1086 GetEventHandler()->ProcessEvent(vEvent
); // return value would be ignored by PM
1090 DoGiveHelp(wxEmptyString
, FALSE
);
1095 } // end of wxFrame::HandleMenuSelect
1097 // ---------------------------------------------------------------------------
1098 // Main Frame window proc
1099 // ---------------------------------------------------------------------------
1100 MRESULT EXPENTRY
wxFrameMainWndProc(
1107 MRESULT rc
= (MRESULT
)0;
1108 bool bProcessed
= FALSE
;
1109 wxFrame
* pWnd
= NULL
;
1111 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1114 case WM_QUERYFRAMECTLCOUNT
:
1115 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1117 USHORT uItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1119 rc
= MRFROMSHORT(uItemCount
);
1123 case WM_FORMATFRAME
:
1124 /////////////////////////////////////////////////////////////////////////////////
1125 // Applications that subclass frame controls may find that the frame is already
1126 // subclassed the number of frame controls is variable.
1127 // The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
1128 // subclassed by calling the previous window procedure and modifying its result.
1129 ////////////////////////////////////////////////////////////////////////////////
1141 pSWP
= (PSWP
)PVOIDFROMMP(wParam
);
1142 nItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1143 if(pWnd
->m_frameStatusBar
)
1145 ::WinQueryWindowRect(pWnd
->m_frameStatusBar
->GetHWND(), &vRstb
);
1146 pWnd
->m_frameStatusBar
->GetSize(NULL
, &nHeight
);
1148 if(pWnd
->m_frameToolBar
)
1150 ::WinQueryWindowRect(pWnd
->m_frameToolBar
->GetHWND(), &vRtlb
);
1151 pWnd
->m_frameToolBar
->GetSize(&nWidth
, &nHeight2
);
1153 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1154 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1155 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1156 ::WinMapWindowPoints(HWND_DESKTOP
, pWnd
->m_hFrame
, (PPOINTL
)&vRectl
, 2);
1157 for(i
= 0; i
< nItemCount
; i
++)
1159 if(pWnd
->m_hWnd
&& pSWP
[i
].hwnd
== pWnd
->m_hWnd
)
1161 if (pWnd
->m_frameToolBar
&& pWnd
->m_frameToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
1163 pSWP
[i
].x
= vRectl
.xLeft
;
1164 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1165 pSWP
[i
].cx
= vRectl
.xRight
- vRectl
.xLeft
;
1166 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- (nHeight
+ nHeight2
);
1170 pSWP
[i
].x
= vRectl
.xLeft
+ nWidth
;
1171 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1172 pSWP
[i
].cx
= vRectl
.xRight
- (vRectl
.xLeft
+ nWidth
);
1173 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- nHeight
;
1175 pSWP
[i
].fl
= SWP_SIZE
| SWP_MOVE
| SWP_SHOW
;
1176 pSWP
[i
].hwndInsertBehind
= HWND_TOP
;
1180 rc
= MRFROMSHORT(nItemCount
);
1185 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1186 rc
= pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
);
1188 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1191 } // end of wxFrameMainWndProc
1193 MRESULT EXPENTRY
wxFrameWndProc(
1201 // Trace all ulMsgs - useful for the debugging
1204 wxFrame
* pWnd
= NULL
;
1206 parentHwnd
= WinQueryWindow(hWnd
,QW_PARENT
);
1207 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1210 // When we get the first message for the HWND we just created, we associate
1211 // it with wxWindow stored in wxWndHook
1214 MRESULT rc
= (MRESULT
)0;
1217 // Stop right here if we don't have a valid handle in our wxWindow object.
1219 if (pWnd
&& !pWnd
->GetHWND())
1221 pWnd
->SetHWND((WXHWND
) hWnd
);
1222 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
1228 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
1230 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1233 } // end of wxFrameWndProc
1235 MRESULT
wxFrame::OS2WindowProc(
1242 bool bProcessed
= FALSE
;
1248 // If we can't close, tell the system that we processed the
1249 // message - otherwise it would close us
1251 bProcessed
= !Close();
1255 bProcessed
= HandlePaint();
1256 mRc
= (MRESULT
)FALSE
;
1259 case WM_ERASEBACKGROUND
:
1261 // Returning TRUE to requests PM to paint the window background
1262 // in SYSCLR_WINDOW. We capture this here because the PS returned
1263 // in Frames is the PS for the whole frame, which we can't really
1264 // use at all. If you want to paint a different background, do it
1265 // in an OnPaint using a wxPaintDC.
1267 mRc
= (MRESULT
)(TRUE
);
1276 UnpackCommand( (WXWPARAM
)wParam
1283 bProcessed
= HandleCommand( wId
1296 UnpackMenuSelect( wParam
1302 bProcessed
= HandleMenuSelect( wItem
1306 mRc
= (MRESULT
)TRUE
;
1312 SHORT nScxnew
= SHORT1FROMMP(lParam
); // New horizontal size.
1313 SHORT nScynew
= SHORT2FROMMP(lParam
); // New vertical size.
1315 lParam
= MRFROM2SHORT( nScxnew
- 20
1319 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1320 mRc
= (MRESULT
)FALSE
;
1323 case CM_QUERYDRAGIMAGE
:
1325 const wxIcon
& vIcon
= GetIcon();
1329 hIcon
= (HPOINTER
)::WinSendMsg(GetHWND(), WM_QUERYICON
, 0L, 0L);
1331 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1332 mRc
= (MRESULT
)hIcon
;
1333 bProcessed
= mRc
!= 0;
1339 mRc
= wxWindow::OS2WindowProc( uMessage
1343 return (MRESULT
)mRc
;
1344 } // wxFrame::OS2WindowProc
1346 void wxFrame::SetClient(WXHWND c_Hwnd
)
1348 // Duh...nothing to do under OS/2
1351 void wxFrame::SetClient(
1355 wxWindow
* pOldClient
= this->GetClient();
1356 bool bClientHasFocus
= pOldClient
&& (pOldClient
== wxWindow::FindFocus());
1358 if(pOldClient
== pWindow
) // nothing to do
1360 if(pWindow
== NULL
) // just need to remove old client
1362 if(pOldClient
== NULL
) // nothing to do
1365 if(bClientHasFocus
)
1368 pOldClient
->Enable( FALSE
);
1369 pOldClient
->Show( FALSE
);
1370 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1371 // to avoid OS/2 bug need to update frame
1372 ::WinSendMsg((HWND
)this->GetFrame(), WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1377 // Else need to change client
1382 ::WinEnableWindowUpdate((HWND
)GetHWND(), FALSE
);
1385 pOldClient
->Enable(FALSE
);
1386 pOldClient
->Show(FALSE
);
1387 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1389 pWindow
->Reparent(this);
1390 ::WinSetWindowUShort(pWindow
->GetHWND(), QWS_ID
, FID_CLIENT
);
1391 ::WinEnableWindowUpdate((HWND
)GetHWND(), TRUE
);
1393 pWindow
->Show(); // ensure client is showing
1394 if( this->IsShown() )
1397 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1401 wxWindow
* wxFrame::GetClient()
1403 return wxFindWinFromHandle((WXHWND
)::WinWindowFromID(m_hFrame
, FID_CLIENT
));
1406 void wxFrame::SendSizeEvent()
1410 RECTL vRect
= wxGetWindowRect(GetHwnd());
1412 ::WinPostMsg( GetHwnd()
1414 ,MPFROM2SHORT( vRect
.xRight
- vRect
.xLeft
1415 ,vRect
.xRight
- vRect
.xLeft
1417 ,MPFROM2SHORT( vRect
.yTop
- vRect
.yBottom
1418 ,vRect
.yTop
- vRect
.yBottom