1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/frame.cpp
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"
16 #include "wx/object.h"
17 #include "wx/dynarray.h"
20 #include "wx/string.h"
28 #include "wx/dialog.h"
29 #include "wx/settings.h"
30 #include "wx/dcclient.h"
34 #include "wx/os2/private.h"
37 #include "wx/statusbr.h"
38 #include "wx/generic/statusbr.h"
39 #endif // wxUSE_STATUSBAR
42 #include "wx/toolbar.h"
43 #endif // wxUSE_TOOLBAR
45 #include "wx/menuitem.h"
48 // ----------------------------------------------------------------------------
50 // ----------------------------------------------------------------------------
52 extern wxList WXDLLEXPORT wxPendingDelete
;
54 #if wxUSE_MENUS_NATIVE
55 extern wxMenu
*wxCurrentPopupMenu
;
58 // ----------------------------------------------------------------------------
60 // ----------------------------------------------------------------------------
62 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
63 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
66 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
68 // ============================================================================
70 // ============================================================================
72 // ----------------------------------------------------------------------------
73 // static class members
74 // ----------------------------------------------------------------------------
77 #if wxUSE_NATIVE_STATUSBAR
78 bool wxFrame::m_bUseNativeStatusBar
= true;
80 bool wxFrame::m_bUseNativeStatusBar
= false;
83 #endif //wxUSE_STATUSBAR
85 // ----------------------------------------------------------------------------
86 // creation/destruction
87 // ----------------------------------------------------------------------------
91 m_nFsStatusBarFields
= 0;
92 m_nFsStatusBarHeight
= 0;
93 m_nFsToolBarHeight
= 0;
95 m_bWasMinimized
= false;
98 m_frameMenuBar
= NULL
;
99 m_frameToolBar
= NULL
;
100 m_frameStatusBar
= NULL
;
102 m_hTitleBar
= NULLHANDLE
;
103 m_hHScroll
= NULLHANDLE
;
104 m_hVScroll
= NULLHANDLE
;
109 memset(&m_vSwpTitleBar
, 0, sizeof(SWP
));
110 memset(&m_vSwpMenuBar
, 0, sizeof(SWP
));
111 memset(&m_vSwpHScroll
, 0, sizeof(SWP
));
112 memset(&m_vSwpVScroll
, 0, sizeof(SWP
));
113 memset(&m_vSwpStatusBar
, 0, sizeof(SWP
));
114 memset(&m_vSwpToolBar
, 0, sizeof(SWP
));
117 } // end of wxFrame::Init
119 bool wxFrame::Create( wxWindow
* pParent
,
121 const wxString
& rsTitle
,
125 const wxString
& rsName
)
127 if (!wxTopLevelWindow::Create( pParent
137 } // end of wxFrame::Create
141 m_isBeingDeleted
= true;
143 } // end of wxFrame::~wxFrame
146 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
148 void wxFrame::DoGetClientSize(
153 wxTopLevelWindow::DoGetClientSize( pX
157 // No need to use statusbar code as in WIN32 as the FORMATFRAME
158 // window procedure ensures PM knows about the new frame client
159 // size internally. A ::WinQueryWindowRect (that is called in
160 // wxWindow's GetClient size from above) is all that is needed!
162 } // end of wxFrame::DoGetClientSize
165 // Set the client size (i.e. leave the calculation of borders etc.
168 void wxFrame::DoSetClientSize(
174 // Statusbars are not part of the OS/2 Client but parent frame
175 // so no statusbar consideration
177 wxTopLevelWindow::DoSetClientSize( nWidth
180 } // end of wxFrame::DoSetClientSize
182 // ----------------------------------------------------------------------------
183 // wxFrame: various geometry-related functions
184 // ----------------------------------------------------------------------------
186 void wxFrame::Raise()
188 wxFrameBase::Raise();
189 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
200 wxStatusBar
* wxFrame::OnCreateStatusBar(
204 , const wxString
& rName
207 wxStatusBar
* pStatusBar
= NULL
;
210 pStatusBar
= wxFrameBase::OnCreateStatusBar( nNumber
219 wxClientDC
vDC(pStatusBar
);
223 // Set the height according to the font and the border size
225 vDC
.SetFont(pStatusBar
->GetFont()); // Screws up the menues for some reason
226 vDC
.GetTextExtent( wxT("X")
231 int nHeight
= ((11 * nY
) / 10 + 2 * pStatusBar
->GetBorderY());
233 pStatusBar
->SetSize( wxDefaultCoord
239 ::WinSetParent( pStatusBar
->GetHWND(), m_hFrame
, FALSE
);
240 ::WinSetOwner( pStatusBar
->GetHWND(), m_hFrame
);
244 if(::WinIsWindowShowing(m_hFrame
))
245 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
248 } // end of wxFrame::OnCreateStatusBar
250 void wxFrame::PositionStatusBar()
257 // Native status bar positions itself
259 if (m_frameStatusBar
)
268 ::WinQueryWindowRect(m_hFrame
, &vRect
);
270 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
272 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
273 nWidth
= vRect
.xRight
- vRect
.xLeft
;
274 nY
= nY
- (vRect
.yBottom
- vFRect
.yBottom
);
276 m_frameStatusBar
->GetSize( &nStatbarWidth
280 nY
= nY
- nStatbarHeight
;
282 // Since we wish the status bar to be directly under the client area,
283 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
285 m_frameStatusBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
290 if (!::WinQueryWindowPos(m_frameStatusBar
->GetHWND(), &vSwp
))
292 vError
= ::WinGetLastError(vHabmain
);
293 sError
= wxPMErrorToStr(vError
);
294 wxLogError(_T("Error setting parent for StatusBar. Error: %s\n"), sError
.c_str());
298 } // end of wxFrame::PositionStatusBar
299 #endif // wxUSE_STATUSBAR
302 wxToolBar
* wxFrame::OnCreateToolBar( long lStyle
, wxWindowID vId
, const wxString
& rsName
)
304 wxToolBar
* pToolBar
= wxFrameBase::OnCreateToolBar( lStyle
309 ::WinSetParent( pToolBar
->GetHWND(), m_hFrame
, FALSE
);
310 ::WinSetOwner( pToolBar
->GetHWND(), m_hFrame
);
312 } // end of WinGuiBase_CFrame::OnCreateToolBar
315 #if wxUSE_MENUS_NATIVE
316 void wxFrame::DetachMenuBar()
320 m_frameMenuBar
->Detach();
321 m_frameMenuBar
= NULL
;
323 } // end of wxFrame::DetachMenuBar
325 void wxFrame::SetMenuBar(
336 // Actually remove the menu from the frame
338 m_hMenu
= (WXHMENU
)0;
339 InternalSetMenuBar();
341 else // set new non NULL menu bar
343 m_frameMenuBar
= NULL
;
346 // Can set a menubar several times.
347 // TODO: how to prevent a memory leak if you have a currently-unattached
348 // menubar? wxWidgets assumes that the frame will delete the menu (otherwise
349 // there are problems for MDI).
351 if (pMenuBar
->GetHMenu())
353 m_hMenu
= pMenuBar
->GetHMenu();
358 m_hMenu
= pMenuBar
->Create();
362 InternalSetMenuBar();
363 m_frameMenuBar
= pMenuBar
;
364 pMenuBar
->Attach((wxFrame
*)this);
366 } // end of wxFrame::SetMenuBar
368 void wxFrame::AttachMenuBar(
372 wxFrameBase::AttachMenuBar(pMenubar
);
374 m_frameMenuBar
= pMenubar
;
379 // Actually remove the menu from the frame
381 m_hMenu
= (WXHMENU
)0;
382 InternalSetMenuBar();
384 else // Set new non NULL menu bar
387 // Can set a menubar several times.
389 if (pMenubar
->GetHMenu())
391 m_hMenu
= pMenubar
->GetHMenu();
395 if (pMenubar
->IsAttached())
398 m_hMenu
= pMenubar
->Create();
403 InternalSetMenuBar();
405 } // end of wxFrame::AttachMenuBar
407 void wxFrame::InternalSetMenuBar()
412 // Set the parent and owner of the menubar to be the frame
414 if (!::WinSetParent(m_hMenu
, m_hFrame
, FALSE
))
416 vError
= ::WinGetLastError(vHabmain
);
417 sError
= wxPMErrorToStr(vError
);
418 wxLogError(_T("Error setting parent for submenu. Error: %s\n"), sError
.c_str());
421 if (!::WinSetOwner(m_hMenu
, m_hFrame
))
423 vError
= ::WinGetLastError(vHabmain
);
424 sError
= wxPMErrorToStr(vError
);
425 wxLogError(_T("Error setting parent for submenu. Error: %s\n"), sError
.c_str());
427 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
428 } // end of wxFrame::InternalSetMenuBar
429 #endif // wxUSE_MENUS_NATIVE
432 // Responds to colour changes, and passes event on to children
434 void wxFrame::OnSysColourChanged(
435 wxSysColourChangedEvent
& rEvent
438 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
442 if (m_frameStatusBar
)
444 wxSysColourChangedEvent vEvent2
;
446 vEvent2
.SetEventObject(m_frameStatusBar
);
447 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
449 #endif //wxUSE_STATUSBAR
452 // Propagate the event to the non-top-level children
454 wxWindow::OnSysColourChanged(rEvent
);
455 } // end of wxFrame::OnSysColourChanged
457 // Pass true to show full screen, false to restore.
458 bool wxFrame::ShowFullScreen( bool bShow
, long lStyle
)
465 m_bFsIsShowing
= true;
469 wxToolBar
* pTheToolBar
= GetToolBar();
470 #endif //wxUSE_TOOLBAR
473 wxStatusBar
* pTheStatusBar
= GetStatusBar();
474 #endif //wxUSE_STATUSBAR
480 pTheToolBar
->GetSize(&nDummyWidth
, &m_nFsToolBarHeight
);
481 #endif //wxUSE_TOOLBAR
485 pTheStatusBar
->GetSize(&nDummyWidth
, &m_nFsStatusBarHeight
);
486 #endif //wxUSE_STATUSBAR
490 // Zap the toolbar, menubar, and statusbar
492 if ((lStyle
& wxFULLSCREEN_NOTOOLBAR
) && pTheToolBar
)
494 pTheToolBar
->SetSize(wxDefaultCoord
,0);
495 pTheToolBar
->Show(false);
497 #endif //wxUSE_TOOLBAR
499 if (lStyle
& wxFULLSCREEN_NOMENUBAR
)
501 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
502 ::WinSetOwner(m_hMenu
, m_hFrame
);
503 ::WinSendMsg((HWND
)m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
508 // Save the number of fields in the statusbar
510 if ((lStyle
& wxFULLSCREEN_NOSTATUSBAR
) && pTheStatusBar
)
512 m_nFsStatusBarFields
= pTheStatusBar
->GetFieldsCount();
513 SetStatusBar((wxStatusBar
*) NULL
);
514 delete pTheStatusBar
;
517 m_nFsStatusBarFields
= 0;
518 #endif //wxUSE_STATUSBAR
521 // Zap the frame borders
525 // Save the 'normal' window style
527 m_lFsOldWindowStyle
= ::WinQueryWindowULong(m_hFrame
, QWL_STYLE
);
530 // Save the old position, width & height, maximize state
532 m_vFsOldSize
= GetRect();
533 m_bFsIsMaximized
= IsMaximized();
536 // Decide which window style flags to turn off
538 LONG lNewStyle
= m_lFsOldWindowStyle
;
541 if (lStyle
& wxFULLSCREEN_NOBORDER
)
542 lOffFlags
|= FCF_BORDER
;
543 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
544 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
546 lNewStyle
&= (~lOffFlags
);
549 // Change our window style to be compatible with full-screen mode
551 ::WinSetWindowULong((HWND
)m_hFrame
, QWL_STYLE
, (ULONG
)lNewStyle
);
554 // Resize to the size of the desktop
560 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
561 nWidth
= vRect
.xRight
- vRect
.xLeft
;
563 // Remember OS/2 is backwards!
565 nHeight
= vRect
.yTop
- vRect
.yBottom
;
567 SetSize( nWidth
, nHeight
);
570 // Now flush the window style cache and actually go full-screen
572 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
581 wxSize
sz( nWidth
, nHeight
);
582 wxSizeEvent
vEvent( sz
, GetId() );
584 GetEventHandler()->ProcessEvent(vEvent
);
592 m_bFsIsShowing
= false;
595 wxToolBar
* pTheToolBar
= GetToolBar();
598 // Restore the toolbar, menubar, and statusbar
600 if (pTheToolBar
&& (m_lFsStyle
& wxFULLSCREEN_NOTOOLBAR
))
602 pTheToolBar
->SetSize(wxDefaultCoord
, m_nFsToolBarHeight
);
603 pTheToolBar
->Show(true);
605 #endif //wxUSE_TOOLBAR
608 if ((m_lFsStyle
& wxFULLSCREEN_NOSTATUSBAR
) && (m_nFsStatusBarFields
> 0))
610 CreateStatusBar(m_nFsStatusBarFields
);
611 // PositionStatusBar();
613 #endif //wxUSE_STATUSBAR
615 if ((m_lFsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
617 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
618 ::WinSetOwner(m_hMenu
, m_hFrame
);
619 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
621 Maximize(m_bFsIsMaximized
);
623 ::WinSetWindowULong( m_hFrame
625 ,(ULONG
)m_lFsOldWindowStyle
627 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
636 return wxFrameBase::ShowFullScreen(bShow
, lStyle
);
637 } // end of wxFrame::ShowFullScreen
642 // ----------------------------------------------------------------------------
643 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
644 // from the client area, so the client area is what's really available for the
646 // ----------------------------------------------------------------------------
648 // Checks if there is a toolbar, and returns the first free client position
649 wxPoint
wxFrame::GetClientAreaOrigin() const
651 wxPoint vPoint
= wxTopLevelWindow::GetClientAreaOrigin();
654 // In OS/2 the toolbar and statusbar are frame extensions so there is no
655 // adjustment. The client is supposedly resized for a toolbar in OS/2
656 // as it is for the status bar.
659 } // end of wxFrame::GetClientAreaOrigin
661 // ----------------------------------------------------------------------------
662 // tool/status bar stuff
663 // ----------------------------------------------------------------------------
667 wxToolBar
* wxFrame::CreateToolBar(
670 , const wxString
& rName
673 if (wxFrameBase::CreateToolBar( lStyle
680 return m_frameToolBar
;
681 } // end of wxFrame::CreateToolBar
683 void wxFrame::PositionToolBar()
685 wxToolBar
* pToolBar
= GetToolBar();
698 ::WinQueryWindowRect(m_hFrame
, &vRect
);
699 vPos
.y
= (wxCoord
)vRect
.yTop
;
700 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
702 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
704 vPos
.y
= (wxCoord
)(vFRect
.yTop
- vRect
.yTop
);
705 pToolBar
->GetSize( &vTWidth
709 if (pToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
711 vWidth
= (wxCoord
)(vRect
.xRight
- vRect
.xLeft
);
712 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
721 wxCoord vSheight
= 0;
723 if (m_frameStatusBar
)
724 m_frameStatusBar
->GetSize( &vSwidth
727 vHeight
= (wxCoord
)(vRect
.yTop
- vRect
.yBottom
);
728 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
734 if( ::WinIsWindowShowing(m_hFrame
) )
735 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
736 } // end of wxFrame::PositionToolBar
737 #endif // wxUSE_TOOLBAR
739 // ----------------------------------------------------------------------------
740 // frame state (iconized/maximized/...)
741 // ----------------------------------------------------------------------------
744 // propagate our state change to all child frames: this allows us to emulate X
745 // Windows behaviour where child frames float independently of the parent one
746 // on the desktop, but are iconized/restored with it
748 void wxFrame::IconizeChildFrames( bool WXUNUSED(bIconize
) )
750 // FIXME: Generic MDI does not use Frames for the Childs, so this does _not_
751 // work. Possibly, the right thing is simply to eliminate this
752 // functions and all the calls to it from within this file.
754 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
756 pNode
= pNode
->GetNext() )
758 wxWindow
* pWin
= pNode
->GetData();
759 wxFrame
* pFrame
= wxDynamicCast(pWin
, wxFrame
);
762 #if wxUSE_MDI_ARCHITECTURE
763 && !wxDynamicCast(pFrame
, wxMDIChildFrame
)
764 #endif // wxUSE_MDI_ARCHITECTURE
768 // We don't want to restore the child frames which had been
769 // iconized even before we were iconized, so save the child frame
770 // status when iconizing the parent frame and check it when
775 pFrame
->m_bWasMinimized
= pFrame
->IsIconized();
779 // This test works for both iconizing and restoring
781 if (!pFrame
->m_bWasMinimized
)
782 pFrame
->Iconize(bIconize
);
786 } // end of wxFrame::IconizeChildFrames
788 WXHICON
wxFrame::GetDefaultIcon() const
790 return (WXHICON
)(wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
791 : wxDEFAULT_FRAME_ICON
);
793 // ===========================================================================
794 // message processing
795 // ===========================================================================
797 // ---------------------------------------------------------------------------
799 // ---------------------------------------------------------------------------
800 bool wxFrame::OS2TranslateMessage( WXMSG
* pMsg
)
803 // try the menu bar accels
805 wxMenuBar
* pMenuBar
= GetMenuBar();
810 #if wxUSE_ACCEL && wxUSE_MENUS_NATIVE
811 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
812 return rAcceleratorTable
.Translate(GetHWND(), pMsg
);
816 } // end of wxFrame::OS2TranslateMessage
818 // ---------------------------------------------------------------------------
819 // our private (non virtual) message handlers
820 // ---------------------------------------------------------------------------
821 bool wxFrame::HandlePaint()
825 if (::WinQueryUpdateRect(GetHWND(), &vRect
))
830 // Icons in PM are the same as "pointers"
832 const wxIcon
& vIcon
= GetIcon();
836 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
838 hIcon
= (HPOINTER
)m_hDefaultIcon
;
841 // Hold a pointer to the dc so long as the OnPaint() message
842 // is being processed
845 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
848 // Erase background before painting or we get white background
850 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
856 ::WinQueryWindowRect(GetHwnd(), &vRect3
);
858 static const int nIconWidth
= 32;
859 static const int nIconHeight
= 32;
860 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
861 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
863 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
869 if (!wxWindow::HandlePaint())
874 hPS
= ::WinBeginPaint( GetHwnd()
880 ::GpiCreateLogColorTable( hPS
884 ,(LONG
)wxTheColourDatabase
->m_nSize
885 ,(PLONG
)wxTheColourDatabase
->m_palTable
887 ::GpiCreateLogColorTable( hPS
897 ,GetBackgroundColour().GetPixel()
906 } // end of wxFrame::HandlePaint
908 bool wxFrame::HandleSize( int nX
, int nY
, WXUINT nId
)
910 bool bProcessed
= false;
916 // Only do it it if we were iconized before, otherwise resizing the
917 // parent frame has a curious side effect of bringing it under it's
923 // restore all child frames too
925 IconizeChildFrames(false);
926 (void)SendIconizeEvent(false);
938 // Iconize all child frames too
940 IconizeChildFrames(true);
941 (void)SendIconizeEvent();
949 // forward WM_SIZE to status bar control
951 #if wxUSE_NATIVE_STATUSBAR
952 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
954 wxSizeEvent
vEvent( wxSize( nX
957 ,m_frameStatusBar
->GetId()
960 vEvent
.SetEventObject(m_frameStatusBar
);
961 m_frameStatusBar
->OnSize(vEvent
);
963 #endif // wxUSE_NATIVE_STATUSBAR
968 #endif // wxUSE_TOOLBAR
970 bProcessed
= wxWindow::HandleSize( nX
976 } // end of wxFrame::HandleSize
978 bool wxFrame::HandleCommand( WXWORD nId
,
985 // In case it's e.g. a toolbar.
987 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
990 return pWin
->OS2Command( nCmd
, nId
);
994 // Handle here commands from menus and accelerators
996 if (nCmd
== CMDSRC_MENU
|| nCmd
== CMDSRC_ACCELERATOR
)
998 #if wxUSE_MENUS_NATIVE
999 if (wxCurrentPopupMenu
)
1001 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1003 wxCurrentPopupMenu
= NULL
;
1005 return pPopupMenu
->OS2Command( nCmd
, nId
);
1009 if (ProcessCommand(nId
))
1015 } // end of wxFrame::HandleCommand
1017 bool wxFrame::HandleMenuSelect( WXWORD nItem
,
1026 rc
= ::WinSendMsg(hMenu
, MM_QUERYITEM
, MPFROM2SHORT(nItem
, TRUE
), (MPARAM
)&mItem
);
1028 if(rc
&& !(mItem
.afStyle
& (MIS_SUBMENU
| MIS_SEPARATOR
)))
1030 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nItem
);
1032 vEvent
.SetEventObject(this);
1033 GetEventHandler()->ProcessEvent(vEvent
); // return value would be ignored by PM
1037 DoGiveHelp(wxEmptyString
, false);
1042 } // end of wxFrame::HandleMenuSelect
1044 // ---------------------------------------------------------------------------
1045 // Main Frame window proc
1046 // ---------------------------------------------------------------------------
1047 MRESULT EXPENTRY
wxFrameMainWndProc( HWND hWnd
,
1052 MRESULT rc
= (MRESULT
)0;
1053 bool bProcessed
= false;
1054 wxFrame
* pWnd
= NULL
;
1056 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1059 case WM_QUERYFRAMECTLCOUNT
:
1060 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1062 USHORT uItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1064 rc
= MRFROMSHORT(uItemCount
);
1068 case WM_FORMATFRAME
:
1069 /////////////////////////////////////////////////////////////////////////////////
1070 // Applications that subclass frame controls may find that the frame is already
1071 // subclassed the number of frame controls is variable.
1072 // The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
1073 // subclassed by calling the previous window procedure and modifying its result.
1074 ////////////////////////////////////////////////////////////////////////////////
1086 pSWP
= (PSWP
)PVOIDFROMMP(wParam
);
1087 nItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1088 if(pWnd
->m_frameStatusBar
)
1090 ::WinQueryWindowRect(pWnd
->m_frameStatusBar
->GetHWND(), &vRstb
);
1091 pWnd
->m_frameStatusBar
->GetSize(NULL
, &nHeight
);
1093 if(pWnd
->m_frameToolBar
)
1095 ::WinQueryWindowRect(pWnd
->m_frameToolBar
->GetHWND(), &vRtlb
);
1096 pWnd
->m_frameToolBar
->GetSize(&nWidth
, &nHeight2
);
1098 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1099 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1100 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1101 ::WinMapWindowPoints(HWND_DESKTOP
, pWnd
->m_hFrame
, (PPOINTL
)&vRectl
, 2);
1102 for(i
= 0; i
< nItemCount
; i
++)
1104 if(pWnd
->m_hWnd
&& pSWP
[i
].hwnd
== pWnd
->m_hWnd
)
1106 if (pWnd
->m_frameToolBar
&& pWnd
->m_frameToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
1108 pSWP
[i
].x
= vRectl
.xLeft
;
1109 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1110 pSWP
[i
].cx
= vRectl
.xRight
- vRectl
.xLeft
;
1111 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- (nHeight
+ nHeight2
);
1115 pSWP
[i
].x
= vRectl
.xLeft
+ nWidth
;
1116 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1117 pSWP
[i
].cx
= vRectl
.xRight
- (vRectl
.xLeft
+ nWidth
);
1118 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- nHeight
;
1120 pSWP
[i
].fl
= SWP_SIZE
| SWP_MOVE
| SWP_SHOW
;
1121 pSWP
[i
].hwndInsertBehind
= HWND_TOP
;
1125 rc
= MRFROMSHORT(nItemCount
);
1130 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1131 rc
= pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
);
1133 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1136 } // end of wxFrameMainWndProc
1138 MRESULT EXPENTRY
wxFrameWndProc(
1146 // Trace all ulMsgs - useful for the debugging
1149 wxFrame
* pWnd
= NULL
;
1151 parentHwnd
= WinQueryWindow(hWnd
,QW_PARENT
);
1152 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1155 // When we get the first message for the HWND we just created, we associate
1156 // it with wxWindow stored in wxWndHook
1159 MRESULT rc
= (MRESULT
)0;
1162 // Stop right here if we don't have a valid handle in our wxWindow object.
1164 if (pWnd
&& !pWnd
->GetHWND())
1166 pWnd
->SetHWND((WXHWND
) hWnd
);
1167 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
1173 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
1175 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1178 } // end of wxFrameWndProc
1180 MRESULT
wxFrame::OS2WindowProc( WXUINT uMessage
,
1185 bool bProcessed
= false;
1191 // If we can't close, tell the system that we processed the
1192 // message - otherwise it would close us
1194 bProcessed
= !Close();
1198 bProcessed
= HandlePaint();
1199 mRc
= (MRESULT
)FALSE
;
1202 case WM_ERASEBACKGROUND
:
1204 // Returning TRUE to requests PM to paint the window background
1205 // in SYSCLR_WINDOW. We capture this here because the PS returned
1206 // in Frames is the PS for the whole frame, which we can't really
1207 // use at all. If you want to paint a different background, do it
1208 // in an OnPaint using a wxPaintDC.
1210 mRc
= (MRESULT
)(TRUE
);
1219 UnpackCommand( (WXWPARAM
)wParam
1226 bProcessed
= HandleCommand( wId
1239 UnpackMenuSelect( wParam
1245 bProcessed
= HandleMenuSelect( wItem
1249 mRc
= (MRESULT
)TRUE
;
1255 SHORT nScxnew
= SHORT1FROMMP(lParam
); // New horizontal size.
1256 SHORT nScynew
= SHORT2FROMMP(lParam
); // New vertical size.
1258 lParam
= MRFROM2SHORT( nScxnew
- 20
1262 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1263 mRc
= (MRESULT
)FALSE
;
1266 case CM_QUERYDRAGIMAGE
:
1268 const wxIcon
& vIcon
= GetIcon();
1272 hIcon
= (HPOINTER
)::WinSendMsg(GetHWND(), WM_QUERYICON
, 0L, 0L);
1274 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1275 mRc
= (MRESULT
)hIcon
;
1276 bProcessed
= mRc
!= 0;
1282 mRc
= wxWindow::OS2WindowProc( uMessage
1286 return (MRESULT
)mRc
;
1287 } // wxFrame::OS2WindowProc
1289 void wxFrame::SetClient(WXHWND
WXUNUSED(c_Hwnd
))
1291 // Duh...nothing to do under OS/2
1294 void wxFrame::SetClient( wxWindow
* pWindow
)
1296 wxWindow
* pOldClient
= this->GetClient();
1297 bool bClientHasFocus
= pOldClient
&& (pOldClient
== wxWindow::FindFocus());
1299 if(pOldClient
== pWindow
) // nothing to do
1301 if(pWindow
== NULL
) // just need to remove old client
1303 if(pOldClient
== NULL
) // nothing to do
1306 if(bClientHasFocus
)
1309 pOldClient
->Enable( false );
1310 pOldClient
->Show( false );
1311 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1312 // to avoid OS/2 bug need to update frame
1313 ::WinSendMsg((HWND
)this->GetFrame(), WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1318 // Else need to change client
1323 ::WinEnableWindowUpdate((HWND
)GetHWND(), FALSE
);
1326 pOldClient
->Enable(false);
1327 pOldClient
->Show(false);
1328 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1330 pWindow
->Reparent(this);
1331 ::WinSetWindowUShort(pWindow
->GetHWND(), QWS_ID
, FID_CLIENT
);
1332 ::WinEnableWindowUpdate((HWND
)GetHWND(), TRUE
);
1334 pWindow
->Show(); // ensure client is showing
1335 if( this->IsShown() )
1338 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1342 wxWindow
* wxFrame::GetClient()
1344 return wxFindWinFromHandle((WXHWND
)::WinWindowFromID(m_hFrame
, FID_CLIENT
));
1347 void wxFrame::SendSizeEvent()
1351 RECTL vRect
= wxGetWindowRect(GetHwnd());
1353 ::WinPostMsg( GetHwnd()
1355 ,MPFROM2SHORT( vRect
.xRight
- vRect
.xLeft
1356 ,vRect
.xRight
- vRect
.xLeft
1358 ,MPFROM2SHORT( vRect
.yTop
- vRect
.yBottom
1359 ,vRect
.yTop
- vRect
.yBottom