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"
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 // ----------------------------------------------------------------------------
62 // ----------------------------------------------------------------------------
64 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
65 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
68 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
70 // ============================================================================
72 // ============================================================================
74 // ----------------------------------------------------------------------------
75 // static class members
76 // ----------------------------------------------------------------------------
79 #if wxUSE_NATIVE_STATUSBAR
80 bool wxFrame::m_bUseNativeStatusBar
= true;
82 bool wxFrame::m_bUseNativeStatusBar
= false;
85 #endif //wxUSE_STATUSBAR
87 // ----------------------------------------------------------------------------
88 // creation/destruction
89 // ----------------------------------------------------------------------------
93 m_nFsStatusBarFields
= 0;
94 m_nFsStatusBarHeight
= 0;
95 m_nFsToolBarHeight
= 0;
97 m_bWasMinimized
= false;
100 m_frameMenuBar
= NULL
;
101 m_frameToolBar
= NULL
;
102 m_frameStatusBar
= NULL
;
104 m_hTitleBar
= NULLHANDLE
;
105 m_hHScroll
= NULLHANDLE
;
106 m_hVScroll
= NULLHANDLE
;
111 memset(&m_vSwpTitleBar
, 0, sizeof(SWP
));
112 memset(&m_vSwpMenuBar
, 0, sizeof(SWP
));
113 memset(&m_vSwpHScroll
, 0, sizeof(SWP
));
114 memset(&m_vSwpVScroll
, 0, sizeof(SWP
));
115 memset(&m_vSwpStatusBar
, 0, sizeof(SWP
));
116 memset(&m_vSwpToolBar
, 0, sizeof(SWP
));
119 } // end of wxFrame::Init
121 bool wxFrame::Create( wxWindow
* pParent
,
123 const wxString
& rsTitle
,
127 const wxString
& rsName
)
129 if (!wxTopLevelWindow::Create( pParent
139 } // end of wxFrame::Create
143 m_isBeingDeleted
= true;
145 } // end of wxFrame::~wxFrame
148 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
150 void wxFrame::DoGetClientSize(
155 wxTopLevelWindow::DoGetClientSize( pX
159 // No need to use statusbar code as in WIN32 as the FORMATFRAME
160 // window procedure ensures PM knows about the new frame client
161 // size internally. A ::WinQueryWindowRect (that is called in
162 // wxWindow's GetClient size from above) is all that is needed!
164 } // end of wxFrame::DoGetClientSize
167 // Set the client size (i.e. leave the calculation of borders etc.
170 void wxFrame::DoSetClientSize(
176 // Statusbars are not part of the OS/2 Client but parent frame
177 // so no statusbar consideration
179 wxTopLevelWindow::DoSetClientSize( nWidth
182 } // end of wxFrame::DoSetClientSize
184 // ----------------------------------------------------------------------------
185 // wxFrame: various geometry-related functions
186 // ----------------------------------------------------------------------------
188 void wxFrame::Raise()
190 wxFrameBase::Raise();
191 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
202 wxStatusBar
* wxFrame::OnCreateStatusBar(
206 , const wxString
& rName
209 wxStatusBar
* pStatusBar
= NULL
;
212 pStatusBar
= wxFrameBase::OnCreateStatusBar( nNumber
221 wxClientDC
vDC(pStatusBar
);
225 // Set the height according to the font and the border size
227 vDC
.SetFont(pStatusBar
->GetFont()); // Screws up the menues for some reason
228 vDC
.GetTextExtent( wxT("X")
233 int nHeight
= ((11 * nY
) / 10 + 2 * pStatusBar
->GetBorderY());
235 pStatusBar
->SetSize( wxDefaultCoord
241 ::WinSetParent( pStatusBar
->GetHWND(), m_hFrame
, FALSE
);
242 ::WinSetOwner( pStatusBar
->GetHWND(), m_hFrame
);
246 if(::WinIsWindowShowing(m_hFrame
))
247 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
250 } // end of wxFrame::OnCreateStatusBar
252 void wxFrame::PositionStatusBar()
259 // Native status bar positions itself
261 if (m_frameStatusBar
)
270 ::WinQueryWindowRect(m_hFrame
, &vRect
);
272 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
274 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
275 nWidth
= vRect
.xRight
- vRect
.xLeft
;
276 nY
= nY
- (vRect
.yBottom
- vFRect
.yBottom
);
278 m_frameStatusBar
->GetSize( &nStatbarWidth
282 nY
= nY
- nStatbarHeight
;
284 // Since we wish the status bar to be directly under the client area,
285 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
287 m_frameStatusBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
292 if (!::WinQueryWindowPos(m_frameStatusBar
->GetHWND(), &vSwp
))
294 vError
= ::WinGetLastError(vHabmain
);
295 sError
= wxPMErrorToStr(vError
);
296 wxLogError(_T("Error setting parent for StatusBar. Error: %s\n"), sError
.c_str());
300 } // end of wxFrame::PositionStatusBar
301 #endif // wxUSE_STATUSBAR
304 wxToolBar
* wxFrame::OnCreateToolBar( long lStyle
, wxWindowID vId
, const wxString
& rsName
)
306 wxToolBar
* pToolBar
= wxFrameBase::OnCreateToolBar( lStyle
311 ::WinSetParent( pToolBar
->GetHWND(), m_hFrame
, FALSE
);
312 ::WinSetOwner( pToolBar
->GetHWND(), m_hFrame
);
314 } // end of WinGuiBase_CFrame::OnCreateToolBar
317 #if wxUSE_MENUS_NATIVE
318 void wxFrame::DetachMenuBar()
322 m_frameMenuBar
->Detach();
323 m_frameMenuBar
= NULL
;
325 } // end of wxFrame::DetachMenuBar
327 void wxFrame::SetMenuBar(
338 // Actually remove the menu from the frame
340 m_hMenu
= (WXHMENU
)0;
341 InternalSetMenuBar();
343 else // set new non NULL menu bar
345 m_frameMenuBar
= NULL
;
348 // Can set a menubar several times.
349 // TODO: how to prevent a memory leak if you have a currently-unattached
350 // menubar? wxWidgets assumes that the frame will delete the menu (otherwise
351 // there are problems for MDI).
353 if (pMenuBar
->GetHMenu())
355 m_hMenu
= pMenuBar
->GetHMenu();
360 m_hMenu
= pMenuBar
->Create();
364 InternalSetMenuBar();
365 m_frameMenuBar
= pMenuBar
;
366 pMenuBar
->Attach((wxFrame
*)this);
368 } // end of wxFrame::SetMenuBar
370 void wxFrame::AttachMenuBar(
374 wxFrameBase::AttachMenuBar(pMenubar
);
376 m_frameMenuBar
= pMenubar
;
381 // Actually remove the menu from the frame
383 m_hMenu
= (WXHMENU
)0;
384 InternalSetMenuBar();
386 else // Set new non NULL menu bar
389 // Can set a menubar several times.
391 if (pMenubar
->GetHMenu())
393 m_hMenu
= pMenubar
->GetHMenu();
397 if (pMenubar
->IsAttached())
400 m_hMenu
= pMenubar
->Create();
405 InternalSetMenuBar();
407 } // end of wxFrame::AttachMenuBar
409 void wxFrame::InternalSetMenuBar()
414 // Set the parent and owner of the menubar to be the frame
416 if (!::WinSetParent(m_hMenu
, m_hFrame
, FALSE
))
418 vError
= ::WinGetLastError(vHabmain
);
419 sError
= wxPMErrorToStr(vError
);
420 wxLogError(_T("Error setting parent for submenu. Error: %s\n"), sError
.c_str());
423 if (!::WinSetOwner(m_hMenu
, m_hFrame
))
425 vError
= ::WinGetLastError(vHabmain
);
426 sError
= wxPMErrorToStr(vError
);
427 wxLogError(_T("Error setting parent for submenu. Error: %s\n"), sError
.c_str());
429 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
430 } // end of wxFrame::InternalSetMenuBar
431 #endif // wxUSE_MENUS_NATIVE
434 // Responds to colour changes, and passes event on to children
436 void wxFrame::OnSysColourChanged(
437 wxSysColourChangedEvent
& rEvent
440 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
444 if (m_frameStatusBar
)
446 wxSysColourChangedEvent vEvent2
;
448 vEvent2
.SetEventObject(m_frameStatusBar
);
449 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
451 #endif //wxUSE_STATUSBAR
454 // Propagate the event to the non-top-level children
456 wxWindow::OnSysColourChanged(rEvent
);
457 } // end of wxFrame::OnSysColourChanged
459 // Pass true to show full screen, false to restore.
460 bool wxFrame::ShowFullScreen( bool bShow
, long lStyle
)
467 m_bFsIsShowing
= true;
471 wxToolBar
* pTheToolBar
= GetToolBar();
472 #endif //wxUSE_TOOLBAR
475 wxStatusBar
* pTheStatusBar
= GetStatusBar();
476 #endif //wxUSE_STATUSBAR
482 pTheToolBar
->GetSize(&nDummyWidth
, &m_nFsToolBarHeight
);
483 #endif //wxUSE_TOOLBAR
487 pTheStatusBar
->GetSize(&nDummyWidth
, &m_nFsStatusBarHeight
);
488 #endif //wxUSE_STATUSBAR
492 // Zap the toolbar, menubar, and statusbar
494 if ((lStyle
& wxFULLSCREEN_NOTOOLBAR
) && pTheToolBar
)
496 pTheToolBar
->SetSize(wxDefaultCoord
,0);
497 pTheToolBar
->Show(false);
499 #endif //wxUSE_TOOLBAR
501 if (lStyle
& wxFULLSCREEN_NOMENUBAR
)
503 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
504 ::WinSetOwner(m_hMenu
, m_hFrame
);
505 ::WinSendMsg((HWND
)m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
510 // Save the number of fields in the statusbar
512 if ((lStyle
& wxFULLSCREEN_NOSTATUSBAR
) && pTheStatusBar
)
514 m_nFsStatusBarFields
= pTheStatusBar
->GetFieldsCount();
515 SetStatusBar((wxStatusBar
*) NULL
);
516 delete pTheStatusBar
;
519 m_nFsStatusBarFields
= 0;
520 #endif //wxUSE_STATUSBAR
523 // Zap the frame borders
527 // Save the 'normal' window style
529 m_lFsOldWindowStyle
= ::WinQueryWindowULong(m_hFrame
, QWL_STYLE
);
532 // Save the old position, width & height, maximize state
534 m_vFsOldSize
= GetRect();
535 m_bFsIsMaximized
= IsMaximized();
538 // Decide which window style flags to turn off
540 LONG lNewStyle
= m_lFsOldWindowStyle
;
543 if (lStyle
& wxFULLSCREEN_NOBORDER
)
544 lOffFlags
|= FCF_BORDER
;
545 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
546 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
548 lNewStyle
&= (~lOffFlags
);
551 // Change our window style to be compatible with full-screen mode
553 ::WinSetWindowULong((HWND
)m_hFrame
, QWL_STYLE
, (ULONG
)lNewStyle
);
556 // Resize to the size of the desktop
562 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
563 nWidth
= vRect
.xRight
- vRect
.xLeft
;
565 // Remember OS/2 is backwards!
567 nHeight
= vRect
.yTop
- vRect
.yBottom
;
569 SetSize( nWidth
, nHeight
);
572 // Now flush the window style cache and actually go full-screen
574 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
583 wxSize
sz( nWidth
, nHeight
);
584 wxSizeEvent
vEvent( sz
, GetId() );
586 GetEventHandler()->ProcessEvent(vEvent
);
594 m_bFsIsShowing
= false;
597 wxToolBar
* pTheToolBar
= GetToolBar();
600 // Restore the toolbar, menubar, and statusbar
602 if (pTheToolBar
&& (m_lFsStyle
& wxFULLSCREEN_NOTOOLBAR
))
604 pTheToolBar
->SetSize(wxDefaultCoord
, m_nFsToolBarHeight
);
605 pTheToolBar
->Show(true);
607 #endif //wxUSE_TOOLBAR
610 if ((m_lFsStyle
& wxFULLSCREEN_NOSTATUSBAR
) && (m_nFsStatusBarFields
> 0))
612 CreateStatusBar(m_nFsStatusBarFields
);
613 // PositionStatusBar();
615 #endif //wxUSE_STATUSBAR
617 if ((m_lFsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
619 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
620 ::WinSetOwner(m_hMenu
, m_hFrame
);
621 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
623 Maximize(m_bFsIsMaximized
);
625 ::WinSetWindowULong( m_hFrame
627 ,(ULONG
)m_lFsOldWindowStyle
629 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
638 return wxFrameBase::ShowFullScreen(bShow
, lStyle
);
639 } // end of wxFrame::ShowFullScreen
644 // ----------------------------------------------------------------------------
645 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
646 // from the client area, so the client area is what's really available for the
648 // ----------------------------------------------------------------------------
650 // Checks if there is a toolbar, and returns the first free client position
651 wxPoint
wxFrame::GetClientAreaOrigin() const
653 wxPoint vPoint
= wxTopLevelWindow::GetClientAreaOrigin();
656 // In OS/2 the toolbar and statusbar are frame extensions so there is no
657 // adjustment. The client is supposedly resized for a toolbar in OS/2
658 // as it is for the status bar.
661 } // end of wxFrame::GetClientAreaOrigin
663 // ----------------------------------------------------------------------------
664 // tool/status bar stuff
665 // ----------------------------------------------------------------------------
669 wxToolBar
* wxFrame::CreateToolBar(
672 , const wxString
& rName
675 if (wxFrameBase::CreateToolBar( lStyle
682 return m_frameToolBar
;
683 } // end of wxFrame::CreateToolBar
685 void wxFrame::PositionToolBar()
687 wxToolBar
* pToolBar
= GetToolBar();
700 ::WinQueryWindowRect(m_hFrame
, &vRect
);
701 vPos
.y
= (wxCoord
)vRect
.yTop
;
702 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
704 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
706 vPos
.y
= (wxCoord
)(vFRect
.yTop
- vRect
.yTop
);
707 pToolBar
->GetSize( &vTWidth
711 if (pToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
713 vWidth
= (wxCoord
)(vRect
.xRight
- vRect
.xLeft
);
714 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
723 wxCoord vSheight
= 0;
725 if (m_frameStatusBar
)
726 m_frameStatusBar
->GetSize( &vSwidth
729 vHeight
= (wxCoord
)(vRect
.yTop
- vRect
.yBottom
);
730 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
736 if( ::WinIsWindowShowing(m_hFrame
) )
737 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
738 } // end of wxFrame::PositionToolBar
739 #endif // wxUSE_TOOLBAR
741 // ----------------------------------------------------------------------------
742 // frame state (iconized/maximized/...)
743 // ----------------------------------------------------------------------------
746 // propagate our state change to all child frames: this allows us to emulate X
747 // Windows behaviour where child frames float independently of the parent one
748 // on the desktop, but are iconized/restored with it
750 void wxFrame::IconizeChildFrames( bool WXUNUSED(bIconize
) )
752 // FIXME: Generic MDI does not use Frames for the Childs, so this does _not_
753 // work. Possibly, the right thing is simply to eliminate this
754 // functions and all the calls to it from within this file.
756 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
758 pNode
= pNode
->GetNext() )
760 wxWindow
* pWin
= pNode
->GetData();
761 wxFrame
* pFrame
= wxDynamicCast(pWin
, wxFrame
);
764 #if wxUSE_MDI_ARCHITECTURE
765 && !wxDynamicCast(pFrame
, wxMDIChildFrame
)
766 #endif // wxUSE_MDI_ARCHITECTURE
770 // We don't want to restore the child frames which had been
771 // iconized even before we were iconized, so save the child frame
772 // status when iconizing the parent frame and check it when
777 pFrame
->m_bWasMinimized
= pFrame
->IsIconized();
781 // This test works for both iconizing and restoring
783 if (!pFrame
->m_bWasMinimized
)
784 pFrame
->Iconize(bIconize
);
788 } // end of wxFrame::IconizeChildFrames
790 WXHICON
wxFrame::GetDefaultIcon() const
792 return (WXHICON
)(wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
793 : wxDEFAULT_FRAME_ICON
);
795 // ===========================================================================
796 // message processing
797 // ===========================================================================
799 // ---------------------------------------------------------------------------
801 // ---------------------------------------------------------------------------
802 bool wxFrame::OS2TranslateMessage( WXMSG
* pMsg
)
805 // try the menu bar accels
807 wxMenuBar
* pMenuBar
= GetMenuBar();
812 #if wxUSE_ACCEL && wxUSE_MENUS_NATIVE
813 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
814 return rAcceleratorTable
.Translate(GetHWND(), pMsg
);
818 } // end of wxFrame::OS2TranslateMessage
820 // ---------------------------------------------------------------------------
821 // our private (non virtual) message handlers
822 // ---------------------------------------------------------------------------
823 bool wxFrame::HandlePaint()
827 if (::WinQueryUpdateRect(GetHWND(), &vRect
))
832 // Icons in PM are the same as "pointers"
834 const wxIcon
& vIcon
= GetIcon();
838 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
840 hIcon
= (HPOINTER
)m_hDefaultIcon
;
843 // Hold a pointer to the dc so long as the OnPaint() message
844 // is being processed
847 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
850 // Erase background before painting or we get white background
852 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
858 ::WinQueryWindowRect(GetHwnd(), &vRect3
);
860 static const int nIconWidth
= 32;
861 static const int nIconHeight
= 32;
862 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
863 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
865 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
871 if (!wxWindow::HandlePaint())
876 hPS
= ::WinBeginPaint( GetHwnd()
882 ::GpiCreateLogColorTable( hPS
886 ,(LONG
)wxTheColourDatabase
->m_nSize
887 ,(PLONG
)wxTheColourDatabase
->m_palTable
889 ::GpiCreateLogColorTable( hPS
899 ,GetBackgroundColour().GetPixel()
908 } // end of wxFrame::HandlePaint
910 bool wxFrame::HandleSize( int nX
, int nY
, WXUINT nId
)
912 bool bProcessed
= false;
918 // Only do it it if we were iconized before, otherwise resizing the
919 // parent frame has a curious side effect of bringing it under it's
925 // restore all child frames too
927 IconizeChildFrames(false);
928 (void)SendIconizeEvent(false);
940 // Iconize all child frames too
942 IconizeChildFrames(true);
943 (void)SendIconizeEvent();
951 // forward WM_SIZE to status bar control
953 #if wxUSE_NATIVE_STATUSBAR
954 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
956 wxSizeEvent
vEvent( wxSize( nX
959 ,m_frameStatusBar
->GetId()
962 vEvent
.SetEventObject(m_frameStatusBar
);
963 m_frameStatusBar
->OnSize(vEvent
);
965 #endif // wxUSE_NATIVE_STATUSBAR
970 #endif // wxUSE_TOOLBAR
972 bProcessed
= wxWindow::HandleSize( nX
978 } // end of wxFrame::HandleSize
980 bool wxFrame::HandleCommand( WXWORD nId
,
987 // In case it's e.g. a toolbar.
989 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
992 return pWin
->OS2Command( nCmd
, nId
);
996 // Handle here commands from menus and accelerators
998 if (nCmd
== CMDSRC_MENU
|| nCmd
== CMDSRC_ACCELERATOR
)
1000 #if wxUSE_MENUS_NATIVE
1001 if (wxCurrentPopupMenu
)
1003 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1005 wxCurrentPopupMenu
= NULL
;
1007 return pPopupMenu
->OS2Command( nCmd
, nId
);
1011 if (ProcessCommand(nId
))
1017 } // end of wxFrame::HandleCommand
1019 bool wxFrame::HandleMenuSelect( WXWORD nItem
,
1028 rc
= ::WinSendMsg(hMenu
, MM_QUERYITEM
, MPFROM2SHORT(nItem
, TRUE
), (MPARAM
)&mItem
);
1030 if(rc
&& !(mItem
.afStyle
& (MIS_SUBMENU
| MIS_SEPARATOR
)))
1032 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nItem
);
1034 vEvent
.SetEventObject(this);
1035 GetEventHandler()->ProcessEvent(vEvent
); // return value would be ignored by PM
1039 DoGiveHelp(wxEmptyString
, false);
1044 } // end of wxFrame::HandleMenuSelect
1046 // ---------------------------------------------------------------------------
1047 // Main Frame window proc
1048 // ---------------------------------------------------------------------------
1049 MRESULT EXPENTRY
wxFrameMainWndProc( HWND hWnd
,
1054 MRESULT rc
= (MRESULT
)0;
1055 bool bProcessed
= false;
1056 wxFrame
* pWnd
= NULL
;
1058 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1061 case WM_QUERYFRAMECTLCOUNT
:
1062 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1064 USHORT uItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1066 rc
= MRFROMSHORT(uItemCount
);
1070 case WM_FORMATFRAME
:
1071 /////////////////////////////////////////////////////////////////////////////////
1072 // Applications that subclass frame controls may find that the frame is already
1073 // subclassed the number of frame controls is variable.
1074 // The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
1075 // subclassed by calling the previous window procedure and modifying its result.
1076 ////////////////////////////////////////////////////////////////////////////////
1088 pSWP
= (PSWP
)PVOIDFROMMP(wParam
);
1089 nItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1090 if(pWnd
->m_frameStatusBar
)
1092 ::WinQueryWindowRect(pWnd
->m_frameStatusBar
->GetHWND(), &vRstb
);
1093 pWnd
->m_frameStatusBar
->GetSize(NULL
, &nHeight
);
1095 if(pWnd
->m_frameToolBar
)
1097 ::WinQueryWindowRect(pWnd
->m_frameToolBar
->GetHWND(), &vRtlb
);
1098 pWnd
->m_frameToolBar
->GetSize(&nWidth
, &nHeight2
);
1100 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1101 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1102 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1103 ::WinMapWindowPoints(HWND_DESKTOP
, pWnd
->m_hFrame
, (PPOINTL
)&vRectl
, 2);
1104 for(i
= 0; i
< nItemCount
; i
++)
1106 if(pWnd
->m_hWnd
&& pSWP
[i
].hwnd
== pWnd
->m_hWnd
)
1108 if (pWnd
->m_frameToolBar
&& pWnd
->m_frameToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
1110 pSWP
[i
].x
= vRectl
.xLeft
;
1111 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1112 pSWP
[i
].cx
= vRectl
.xRight
- vRectl
.xLeft
;
1113 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- (nHeight
+ nHeight2
);
1117 pSWP
[i
].x
= vRectl
.xLeft
+ nWidth
;
1118 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1119 pSWP
[i
].cx
= vRectl
.xRight
- (vRectl
.xLeft
+ nWidth
);
1120 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- nHeight
;
1122 pSWP
[i
].fl
= SWP_SIZE
| SWP_MOVE
| SWP_SHOW
;
1123 pSWP
[i
].hwndInsertBehind
= HWND_TOP
;
1127 rc
= MRFROMSHORT(nItemCount
);
1132 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1133 rc
= pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
);
1135 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1138 } // end of wxFrameMainWndProc
1140 MRESULT EXPENTRY
wxFrameWndProc(
1148 // Trace all ulMsgs - useful for the debugging
1151 wxFrame
* pWnd
= NULL
;
1153 parentHwnd
= WinQueryWindow(hWnd
,QW_PARENT
);
1154 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1157 // When we get the first message for the HWND we just created, we associate
1158 // it with wxWindow stored in wxWndHook
1161 MRESULT rc
= (MRESULT
)0;
1164 // Stop right here if we don't have a valid handle in our wxWindow object.
1166 if (pWnd
&& !pWnd
->GetHWND())
1168 pWnd
->SetHWND((WXHWND
) hWnd
);
1169 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
1175 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
1177 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1180 } // end of wxFrameWndProc
1182 MRESULT
wxFrame::OS2WindowProc( WXUINT uMessage
,
1187 bool bProcessed
= false;
1193 // If we can't close, tell the system that we processed the
1194 // message - otherwise it would close us
1196 bProcessed
= !Close();
1200 bProcessed
= HandlePaint();
1201 mRc
= (MRESULT
)FALSE
;
1204 case WM_ERASEBACKGROUND
:
1206 // Returning TRUE to requests PM to paint the window background
1207 // in SYSCLR_WINDOW. We capture this here because the PS returned
1208 // in Frames is the PS for the whole frame, which we can't really
1209 // use at all. If you want to paint a different background, do it
1210 // in an OnPaint using a wxPaintDC.
1212 mRc
= (MRESULT
)(TRUE
);
1221 UnpackCommand( (WXWPARAM
)wParam
1228 bProcessed
= HandleCommand( wId
1241 UnpackMenuSelect( wParam
1247 bProcessed
= HandleMenuSelect( wItem
1251 mRc
= (MRESULT
)TRUE
;
1257 SHORT nScxnew
= SHORT1FROMMP(lParam
); // New horizontal size.
1258 SHORT nScynew
= SHORT2FROMMP(lParam
); // New vertical size.
1260 lParam
= MRFROM2SHORT( nScxnew
- 20
1264 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1265 mRc
= (MRESULT
)FALSE
;
1268 case CM_QUERYDRAGIMAGE
:
1270 const wxIcon
& vIcon
= GetIcon();
1274 hIcon
= (HPOINTER
)::WinSendMsg(GetHWND(), WM_QUERYICON
, 0L, 0L);
1276 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1277 mRc
= (MRESULT
)hIcon
;
1278 bProcessed
= mRc
!= 0;
1284 mRc
= wxWindow::OS2WindowProc( uMessage
1288 return (MRESULT
)mRc
;
1289 } // wxFrame::OS2WindowProc
1291 void wxFrame::SetClient(WXHWND
WXUNUSED(c_Hwnd
))
1293 // Duh...nothing to do under OS/2
1296 void wxFrame::SetClient( wxWindow
* pWindow
)
1298 wxWindow
* pOldClient
= this->GetClient();
1299 bool bClientHasFocus
= pOldClient
&& (pOldClient
== wxWindow::FindFocus());
1301 if(pOldClient
== pWindow
) // nothing to do
1303 if(pWindow
== NULL
) // just need to remove old client
1305 if(pOldClient
== NULL
) // nothing to do
1308 if(bClientHasFocus
)
1311 pOldClient
->Enable( false );
1312 pOldClient
->Show( false );
1313 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1314 // to avoid OS/2 bug need to update frame
1315 ::WinSendMsg((HWND
)this->GetFrame(), WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1320 // Else need to change client
1325 ::WinEnableWindowUpdate((HWND
)GetHWND(), FALSE
);
1328 pOldClient
->Enable(false);
1329 pOldClient
->Show(false);
1330 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1332 pWindow
->Reparent(this);
1333 ::WinSetWindowUShort(pWindow
->GetHWND(), QWS_ID
, FID_CLIENT
);
1334 ::WinEnableWindowUpdate((HWND
)GetHWND(), TRUE
);
1336 pWindow
->Show(); // ensure client is showing
1337 if( this->IsShown() )
1340 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1344 wxWindow
* wxFrame::GetClient()
1346 return wxFindWinFromHandle((WXHWND
)::WinWindowFromID(m_hFrame
, FID_CLIENT
));
1349 void wxFrame::SendSizeEvent()
1353 RECTL vRect
= wxGetWindowRect(GetHwnd());
1355 ::WinPostMsg( GetHwnd()
1357 ,MPFROM2SHORT( vRect
.xRight
- vRect
.xLeft
1358 ,vRect
.xRight
- vRect
.xLeft
1360 ,MPFROM2SHORT( vRect
.yTop
- vRect
.yBottom
1361 ,vRect
.yTop
- vRect
.yBottom