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"
32 #include "wx/toolbar.h"
35 #include "wx/os2/private.h"
38 #include "wx/statusbr.h"
39 #include "wx/generic/statusbr.h"
40 #endif // wxUSE_STATUSBAR
42 #include "wx/menuitem.h"
44 // ----------------------------------------------------------------------------
46 // ----------------------------------------------------------------------------
48 #if wxUSE_MENUS_NATIVE
49 extern wxMenu
*wxCurrentPopupMenu
;
52 // ----------------------------------------------------------------------------
54 // ----------------------------------------------------------------------------
56 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
57 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
60 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
62 // ============================================================================
64 // ============================================================================
66 // ----------------------------------------------------------------------------
67 // static class members
68 // ----------------------------------------------------------------------------
71 #if wxUSE_NATIVE_STATUSBAR
72 bool wxFrame::m_bUseNativeStatusBar
= true;
74 bool wxFrame::m_bUseNativeStatusBar
= false;
77 #endif //wxUSE_STATUSBAR
79 // ----------------------------------------------------------------------------
80 // creation/destruction
81 // ----------------------------------------------------------------------------
85 m_nFsStatusBarFields
= 0;
86 m_nFsStatusBarHeight
= 0;
87 m_nFsToolBarHeight
= 0;
89 m_bWasMinimized
= false;
92 m_frameMenuBar
= NULL
;
93 m_frameToolBar
= NULL
;
94 m_frameStatusBar
= NULL
;
96 m_hTitleBar
= NULLHANDLE
;
97 m_hHScroll
= NULLHANDLE
;
98 m_hVScroll
= NULLHANDLE
;
103 memset(&m_vSwpTitleBar
, 0, sizeof(SWP
));
104 memset(&m_vSwpMenuBar
, 0, sizeof(SWP
));
105 memset(&m_vSwpHScroll
, 0, sizeof(SWP
));
106 memset(&m_vSwpVScroll
, 0, sizeof(SWP
));
107 memset(&m_vSwpStatusBar
, 0, sizeof(SWP
));
108 memset(&m_vSwpToolBar
, 0, sizeof(SWP
));
111 } // end of wxFrame::Init
113 bool wxFrame::Create( wxWindow
* pParent
,
115 const wxString
& rsTitle
,
119 const wxString
& rsName
)
121 if (!wxTopLevelWindow::Create( pParent
131 } // end of wxFrame::Create
135 m_isBeingDeleted
= true;
137 } // end of wxFrame::~wxFrame
140 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
142 void wxFrame::DoGetClientSize(
147 wxTopLevelWindow::DoGetClientSize( pX
151 // No need to use statusbar code as in WIN32 as the FORMATFRAME
152 // window procedure ensures PM knows about the new frame client
153 // size internally. A ::WinQueryWindowRect (that is called in
154 // wxWindow's GetClient size from above) is all that is needed!
156 } // end of wxFrame::DoGetClientSize
159 // Set the client size (i.e. leave the calculation of borders etc.
162 void wxFrame::DoSetClientSize(
168 // Statusbars are not part of the OS/2 Client but parent frame
169 // so no statusbar consideration
171 wxTopLevelWindow::DoSetClientSize( nWidth
174 } // end of wxFrame::DoSetClientSize
176 // ----------------------------------------------------------------------------
177 // wxFrame: various geometry-related functions
178 // ----------------------------------------------------------------------------
180 void wxFrame::Raise()
182 wxFrameBase::Raise();
183 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
194 wxStatusBar
* wxFrame::OnCreateStatusBar(
198 , const wxString
& rName
201 wxStatusBar
* pStatusBar
= NULL
;
204 pStatusBar
= wxFrameBase::OnCreateStatusBar( nNumber
213 wxClientDC
vDC(pStatusBar
);
217 // Set the height according to the font and the border size
219 vDC
.SetFont(pStatusBar
->GetFont()); // Screws up the menues for some reason
220 vDC
.GetTextExtent( wxT("X")
225 int nHeight
= ((11 * nY
) / 10 + 2 * pStatusBar
->GetBorderY());
227 pStatusBar
->SetSize( wxDefaultCoord
233 ::WinSetParent( pStatusBar
->GetHWND(), m_hFrame
, FALSE
);
234 ::WinSetOwner( pStatusBar
->GetHWND(), m_hFrame
);
238 if(::WinIsWindowShowing(m_hFrame
))
239 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
242 } // end of wxFrame::OnCreateStatusBar
244 void wxFrame::PositionStatusBar()
251 // Native status bar positions itself
253 if (m_frameStatusBar
)
262 ::WinQueryWindowRect(m_hFrame
, &vRect
);
264 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
266 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
267 nWidth
= vRect
.xRight
- vRect
.xLeft
;
268 nY
= nY
- (vRect
.yBottom
- vFRect
.yBottom
);
270 m_frameStatusBar
->GetSize( &nStatbarWidth
274 nY
= nY
- nStatbarHeight
;
276 // Since we wish the status bar to be directly under the client area,
277 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
279 m_frameStatusBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
284 if (!::WinQueryWindowPos(m_frameStatusBar
->GetHWND(), &vSwp
))
286 vError
= ::WinGetLastError(vHabmain
);
287 sError
= wxPMErrorToStr(vError
);
288 wxLogError(_T("Error setting parent for StatusBar. Error: %s\n"), sError
.c_str());
292 } // end of wxFrame::PositionStatusBar
293 #endif // wxUSE_STATUSBAR
296 wxToolBar
* wxFrame::OnCreateToolBar( long lStyle
, wxWindowID vId
, const wxString
& rsName
)
298 wxToolBar
* pToolBar
= wxFrameBase::OnCreateToolBar( lStyle
303 ::WinSetParent( pToolBar
->GetHWND(), m_hFrame
, FALSE
);
304 ::WinSetOwner( pToolBar
->GetHWND(), m_hFrame
);
306 } // end of WinGuiBase_CFrame::OnCreateToolBar
309 #if wxUSE_MENUS_NATIVE
310 void wxFrame::DetachMenuBar()
314 m_frameMenuBar
->Detach();
315 m_frameMenuBar
= NULL
;
317 } // end of wxFrame::DetachMenuBar
319 void wxFrame::SetMenuBar(
330 // Actually remove the menu from the frame
332 m_hMenu
= (WXHMENU
)0;
333 InternalSetMenuBar();
335 else // set new non NULL menu bar
337 m_frameMenuBar
= NULL
;
340 // Can set a menubar several times.
341 // TODO: how to prevent a memory leak if you have a currently-unattached
342 // menubar? wxWidgets assumes that the frame will delete the menu (otherwise
343 // there are problems for MDI).
345 if (pMenuBar
->GetHMenu())
347 m_hMenu
= pMenuBar
->GetHMenu();
352 m_hMenu
= pMenuBar
->Create();
356 InternalSetMenuBar();
357 m_frameMenuBar
= pMenuBar
;
358 pMenuBar
->Attach((wxFrame
*)this);
360 } // end of wxFrame::SetMenuBar
362 void wxFrame::AttachMenuBar(
366 wxFrameBase::AttachMenuBar(pMenubar
);
368 m_frameMenuBar
= pMenubar
;
373 // Actually remove the menu from the frame
375 m_hMenu
= (WXHMENU
)0;
376 InternalSetMenuBar();
378 else // Set new non NULL menu bar
381 // Can set a menubar several times.
383 if (pMenubar
->GetHMenu())
385 m_hMenu
= pMenubar
->GetHMenu();
389 if (pMenubar
->IsAttached())
392 m_hMenu
= pMenubar
->Create();
397 InternalSetMenuBar();
399 } // end of wxFrame::AttachMenuBar
401 void wxFrame::InternalSetMenuBar()
406 // Set the parent and owner of the menubar to be the frame
408 if (!::WinSetParent(m_hMenu
, m_hFrame
, FALSE
))
410 vError
= ::WinGetLastError(vHabmain
);
411 sError
= wxPMErrorToStr(vError
);
412 wxLogError(_T("Error setting parent for submenu. Error: %s\n"), sError
.c_str());
415 if (!::WinSetOwner(m_hMenu
, m_hFrame
))
417 vError
= ::WinGetLastError(vHabmain
);
418 sError
= wxPMErrorToStr(vError
);
419 wxLogError(_T("Error setting parent for submenu. Error: %s\n"), sError
.c_str());
421 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
422 } // end of wxFrame::InternalSetMenuBar
423 #endif // wxUSE_MENUS_NATIVE
426 // Responds to colour changes, and passes event on to children
428 void wxFrame::OnSysColourChanged(
429 wxSysColourChangedEvent
& rEvent
432 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
436 if (m_frameStatusBar
)
438 wxSysColourChangedEvent vEvent2
;
440 vEvent2
.SetEventObject(m_frameStatusBar
);
441 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
443 #endif //wxUSE_STATUSBAR
446 // Propagate the event to the non-top-level children
448 wxWindow::OnSysColourChanged(rEvent
);
449 } // end of wxFrame::OnSysColourChanged
451 // Pass true to show full screen, false to restore.
452 bool wxFrame::ShowFullScreen( bool bShow
, long lStyle
)
459 m_bFsIsShowing
= true;
463 wxToolBar
* pTheToolBar
= GetToolBar();
464 #endif //wxUSE_TOOLBAR
467 wxStatusBar
* pTheStatusBar
= GetStatusBar();
468 #endif //wxUSE_STATUSBAR
474 pTheToolBar
->GetSize(&nDummyWidth
, &m_nFsToolBarHeight
);
475 #endif //wxUSE_TOOLBAR
479 pTheStatusBar
->GetSize(&nDummyWidth
, &m_nFsStatusBarHeight
);
480 #endif //wxUSE_STATUSBAR
484 // Zap the toolbar, menubar, and statusbar
486 if ((lStyle
& wxFULLSCREEN_NOTOOLBAR
) && pTheToolBar
)
488 pTheToolBar
->SetSize(wxDefaultCoord
,0);
489 pTheToolBar
->Show(false);
491 #endif //wxUSE_TOOLBAR
493 if (lStyle
& wxFULLSCREEN_NOMENUBAR
)
495 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
496 ::WinSetOwner(m_hMenu
, m_hFrame
);
497 ::WinSendMsg((HWND
)m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
502 // Save the number of fields in the statusbar
504 if ((lStyle
& wxFULLSCREEN_NOSTATUSBAR
) && pTheStatusBar
)
506 m_nFsStatusBarFields
= pTheStatusBar
->GetFieldsCount();
507 SetStatusBar((wxStatusBar
*) NULL
);
508 delete pTheStatusBar
;
511 m_nFsStatusBarFields
= 0;
512 #endif //wxUSE_STATUSBAR
515 // Zap the frame borders
519 // Save the 'normal' window style
521 m_lFsOldWindowStyle
= ::WinQueryWindowULong(m_hFrame
, QWL_STYLE
);
524 // Save the old position, width & height, maximize state
526 m_vFsOldSize
= GetRect();
527 m_bFsIsMaximized
= IsMaximized();
530 // Decide which window style flags to turn off
532 LONG lNewStyle
= m_lFsOldWindowStyle
;
535 if (lStyle
& wxFULLSCREEN_NOBORDER
)
536 lOffFlags
|= FCF_BORDER
;
537 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
538 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
540 lNewStyle
&= (~lOffFlags
);
543 // Change our window style to be compatible with full-screen mode
545 ::WinSetWindowULong((HWND
)m_hFrame
, QWL_STYLE
, (ULONG
)lNewStyle
);
548 // Resize to the size of the desktop
554 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
555 nWidth
= vRect
.xRight
- vRect
.xLeft
;
557 // Remember OS/2 is backwards!
559 nHeight
= vRect
.yTop
- vRect
.yBottom
;
561 SetSize( nWidth
, nHeight
);
564 // Now flush the window style cache and actually go full-screen
566 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
575 wxSize
sz( nWidth
, nHeight
);
576 wxSizeEvent
vEvent( sz
, GetId() );
578 GetEventHandler()->ProcessEvent(vEvent
);
586 m_bFsIsShowing
= false;
589 wxToolBar
* pTheToolBar
= GetToolBar();
592 // Restore the toolbar, menubar, and statusbar
594 if (pTheToolBar
&& (m_lFsStyle
& wxFULLSCREEN_NOTOOLBAR
))
596 pTheToolBar
->SetSize(wxDefaultCoord
, m_nFsToolBarHeight
);
597 pTheToolBar
->Show(true);
599 #endif //wxUSE_TOOLBAR
602 if ((m_lFsStyle
& wxFULLSCREEN_NOSTATUSBAR
) && (m_nFsStatusBarFields
> 0))
604 CreateStatusBar(m_nFsStatusBarFields
);
605 // PositionStatusBar();
607 #endif //wxUSE_STATUSBAR
609 if ((m_lFsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
611 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
612 ::WinSetOwner(m_hMenu
, m_hFrame
);
613 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
615 Maximize(m_bFsIsMaximized
);
617 ::WinSetWindowULong( m_hFrame
619 ,(ULONG
)m_lFsOldWindowStyle
621 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
630 return wxFrameBase::ShowFullScreen(bShow
, lStyle
);
631 } // end of wxFrame::ShowFullScreen
636 // ----------------------------------------------------------------------------
637 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
638 // from the client area, so the client area is what's really available for the
640 // ----------------------------------------------------------------------------
642 // Checks if there is a toolbar, and returns the first free client position
643 wxPoint
wxFrame::GetClientAreaOrigin() const
645 wxPoint vPoint
= wxTopLevelWindow::GetClientAreaOrigin();
648 // In OS/2 the toolbar and statusbar are frame extensions so there is no
649 // adjustment. The client is supposedly resized for a toolbar in OS/2
650 // as it is for the status bar.
653 } // end of wxFrame::GetClientAreaOrigin
655 // ----------------------------------------------------------------------------
656 // tool/status bar stuff
657 // ----------------------------------------------------------------------------
661 wxToolBar
* wxFrame::CreateToolBar(
664 , const wxString
& rName
667 if (wxFrameBase::CreateToolBar( lStyle
674 return m_frameToolBar
;
675 } // end of wxFrame::CreateToolBar
677 void wxFrame::PositionToolBar()
679 wxToolBar
* pToolBar
= GetToolBar();
692 ::WinQueryWindowRect(m_hFrame
, &vRect
);
693 vPos
.y
= (wxCoord
)vRect
.yTop
;
694 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
696 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
698 vPos
.y
= (wxCoord
)(vFRect
.yTop
- vRect
.yTop
);
699 pToolBar
->GetSize( &vTWidth
703 if (pToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
705 vWidth
= (wxCoord
)(vRect
.xRight
- vRect
.xLeft
);
706 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
715 wxCoord vSheight
= 0;
717 if (m_frameStatusBar
)
718 m_frameStatusBar
->GetSize( &vSwidth
721 vHeight
= (wxCoord
)(vRect
.yTop
- vRect
.yBottom
);
722 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
728 if( ::WinIsWindowShowing(m_hFrame
) )
729 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
730 } // end of wxFrame::PositionToolBar
731 #endif // wxUSE_TOOLBAR
733 // ----------------------------------------------------------------------------
734 // frame state (iconized/maximized/...)
735 // ----------------------------------------------------------------------------
738 // propagate our state change to all child frames: this allows us to emulate X
739 // Windows behaviour where child frames float independently of the parent one
740 // on the desktop, but are iconized/restored with it
742 void wxFrame::IconizeChildFrames( bool WXUNUSED(bIconize
) )
744 // FIXME: Generic MDI does not use Frames for the Childs, so this does _not_
745 // work. Possibly, the right thing is simply to eliminate this
746 // functions and all the calls to it from within this file.
748 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
750 pNode
= pNode
->GetNext() )
752 wxWindow
* pWin
= pNode
->GetData();
753 wxFrame
* pFrame
= wxDynamicCast(pWin
, wxFrame
);
756 #if wxUSE_MDI_ARCHITECTURE
757 && !wxDynamicCast(pFrame
, wxMDIChildFrame
)
758 #endif // wxUSE_MDI_ARCHITECTURE
762 // We don't want to restore the child frames which had been
763 // iconized even before we were iconized, so save the child frame
764 // status when iconizing the parent frame and check it when
769 pFrame
->m_bWasMinimized
= pFrame
->IsIconized();
773 // This test works for both iconizing and restoring
775 if (!pFrame
->m_bWasMinimized
)
776 pFrame
->Iconize(bIconize
);
780 } // end of wxFrame::IconizeChildFrames
782 WXHICON
wxFrame::GetDefaultIcon() const
784 return (WXHICON
)(wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
785 : wxDEFAULT_FRAME_ICON
);
787 // ===========================================================================
788 // message processing
789 // ===========================================================================
791 // ---------------------------------------------------------------------------
793 // ---------------------------------------------------------------------------
794 bool wxFrame::OS2TranslateMessage( WXMSG
* pMsg
)
797 // try the menu bar accels
799 wxMenuBar
* pMenuBar
= GetMenuBar();
804 #if wxUSE_ACCEL && wxUSE_MENUS_NATIVE
805 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
806 return rAcceleratorTable
.Translate(GetHWND(), pMsg
);
810 } // end of wxFrame::OS2TranslateMessage
812 // ---------------------------------------------------------------------------
813 // our private (non virtual) message handlers
814 // ---------------------------------------------------------------------------
815 bool wxFrame::HandlePaint()
819 if (::WinQueryUpdateRect(GetHWND(), &vRect
))
824 // Icons in PM are the same as "pointers"
826 const wxIcon
& vIcon
= GetIcon();
830 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
832 hIcon
= (HPOINTER
)m_hDefaultIcon
;
835 // Hold a pointer to the dc so long as the OnPaint() message
836 // is being processed
839 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
842 // Erase background before painting or we get white background
844 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
850 ::WinQueryWindowRect(GetHwnd(), &vRect3
);
852 static const int nIconWidth
= 32;
853 static const int nIconHeight
= 32;
854 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
855 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
857 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
863 if (!wxWindow::HandlePaint())
868 hPS
= ::WinBeginPaint( GetHwnd()
874 ::GpiCreateLogColorTable( hPS
878 ,(LONG
)wxTheColourDatabase
->m_nSize
879 ,(PLONG
)wxTheColourDatabase
->m_palTable
881 ::GpiCreateLogColorTable( hPS
891 ,GetBackgroundColour().GetPixel()
900 } // end of wxFrame::HandlePaint
902 bool wxFrame::HandleSize( int nX
, int nY
, WXUINT nId
)
904 bool bProcessed
= false;
910 // Only do it it if we were iconized before, otherwise resizing the
911 // parent frame has a curious side effect of bringing it under it's
917 // restore all child frames too
919 IconizeChildFrames(false);
920 (void)SendIconizeEvent(false);
932 // Iconize all child frames too
934 IconizeChildFrames(true);
935 (void)SendIconizeEvent();
943 // forward WM_SIZE to status bar control
945 #if wxUSE_NATIVE_STATUSBAR
946 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
948 wxSizeEvent
vEvent( wxSize( nX
951 ,m_frameStatusBar
->GetId()
954 vEvent
.SetEventObject(m_frameStatusBar
);
955 m_frameStatusBar
->OnSize(vEvent
);
957 #endif // wxUSE_NATIVE_STATUSBAR
962 #endif // wxUSE_TOOLBAR
964 bProcessed
= wxWindow::HandleSize( nX
970 } // end of wxFrame::HandleSize
972 bool wxFrame::HandleCommand( WXWORD nId
,
979 // In case it's e.g. a toolbar.
981 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
984 return pWin
->OS2Command( nCmd
, nId
);
988 // Handle here commands from menus and accelerators
990 if (nCmd
== CMDSRC_MENU
|| nCmd
== CMDSRC_ACCELERATOR
)
992 #if wxUSE_MENUS_NATIVE
993 if (wxCurrentPopupMenu
)
995 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
997 wxCurrentPopupMenu
= NULL
;
999 return pPopupMenu
->OS2Command( nCmd
, nId
);
1003 if (ProcessCommand(nId
))
1009 } // end of wxFrame::HandleCommand
1011 bool wxFrame::HandleMenuSelect( WXWORD nItem
,
1020 rc
= ::WinSendMsg(hMenu
, MM_QUERYITEM
, MPFROM2SHORT(nItem
, TRUE
), (MPARAM
)&mItem
);
1022 if(rc
&& !(mItem
.afStyle
& (MIS_SUBMENU
| MIS_SEPARATOR
)))
1024 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nItem
);
1026 vEvent
.SetEventObject(this);
1027 GetEventHandler()->ProcessEvent(vEvent
); // return value would be ignored by PM
1031 DoGiveHelp(wxEmptyString
, false);
1036 } // end of wxFrame::HandleMenuSelect
1038 // ---------------------------------------------------------------------------
1039 // Main Frame window proc
1040 // ---------------------------------------------------------------------------
1041 MRESULT EXPENTRY
wxFrameMainWndProc( HWND hWnd
,
1046 MRESULT rc
= (MRESULT
)0;
1047 bool bProcessed
= false;
1048 wxFrame
* pWnd
= NULL
;
1050 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1053 case WM_QUERYFRAMECTLCOUNT
:
1054 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1056 USHORT uItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1058 rc
= MRFROMSHORT(uItemCount
);
1062 case WM_FORMATFRAME
:
1063 /////////////////////////////////////////////////////////////////////////////////
1064 // Applications that subclass frame controls may find that the frame is already
1065 // subclassed the number of frame controls is variable.
1066 // The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
1067 // subclassed by calling the previous window procedure and modifying its result.
1068 ////////////////////////////////////////////////////////////////////////////////
1080 pSWP
= (PSWP
)PVOIDFROMMP(wParam
);
1081 nItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1082 if(pWnd
->m_frameStatusBar
)
1084 ::WinQueryWindowRect(pWnd
->m_frameStatusBar
->GetHWND(), &vRstb
);
1085 pWnd
->m_frameStatusBar
->GetSize(NULL
, &nHeight
);
1087 if(pWnd
->m_frameToolBar
)
1089 ::WinQueryWindowRect(pWnd
->m_frameToolBar
->GetHWND(), &vRtlb
);
1090 pWnd
->m_frameToolBar
->GetSize(&nWidth
, &nHeight2
);
1092 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1093 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1094 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1095 ::WinMapWindowPoints(HWND_DESKTOP
, pWnd
->m_hFrame
, (PPOINTL
)&vRectl
, 2);
1096 for(i
= 0; i
< nItemCount
; i
++)
1098 if(pWnd
->m_hWnd
&& pSWP
[i
].hwnd
== pWnd
->m_hWnd
)
1100 if (pWnd
->m_frameToolBar
&& pWnd
->m_frameToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
1102 pSWP
[i
].x
= vRectl
.xLeft
;
1103 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1104 pSWP
[i
].cx
= vRectl
.xRight
- vRectl
.xLeft
;
1105 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- (nHeight
+ nHeight2
);
1109 pSWP
[i
].x
= vRectl
.xLeft
+ nWidth
;
1110 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1111 pSWP
[i
].cx
= vRectl
.xRight
- (vRectl
.xLeft
+ nWidth
);
1112 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- nHeight
;
1114 pSWP
[i
].fl
= SWP_SIZE
| SWP_MOVE
| SWP_SHOW
;
1115 pSWP
[i
].hwndInsertBehind
= HWND_TOP
;
1119 rc
= MRFROMSHORT(nItemCount
);
1124 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1125 rc
= pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
);
1127 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1130 } // end of wxFrameMainWndProc
1132 MRESULT EXPENTRY
wxFrameWndProc(
1140 // Trace all ulMsgs - useful for the debugging
1143 wxFrame
* pWnd
= NULL
;
1145 parentHwnd
= WinQueryWindow(hWnd
,QW_PARENT
);
1146 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1149 // When we get the first message for the HWND we just created, we associate
1150 // it with wxWindow stored in wxWndHook
1153 MRESULT rc
= (MRESULT
)0;
1156 // Stop right here if we don't have a valid handle in our wxWindow object.
1158 if (pWnd
&& !pWnd
->GetHWND())
1160 pWnd
->SetHWND((WXHWND
) hWnd
);
1161 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
1167 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
1169 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1172 } // end of wxFrameWndProc
1174 MRESULT
wxFrame::OS2WindowProc( WXUINT uMessage
,
1179 bool bProcessed
= false;
1185 // If we can't close, tell the system that we processed the
1186 // message - otherwise it would close us
1188 bProcessed
= !Close();
1192 bProcessed
= HandlePaint();
1193 mRc
= (MRESULT
)FALSE
;
1196 case WM_ERASEBACKGROUND
:
1198 // Returning TRUE to requests PM to paint the window background
1199 // in SYSCLR_WINDOW. We capture this here because the PS returned
1200 // in Frames is the PS for the whole frame, which we can't really
1201 // use at all. If you want to paint a different background, do it
1202 // in an OnPaint using a wxPaintDC.
1204 mRc
= (MRESULT
)(TRUE
);
1213 UnpackCommand( (WXWPARAM
)wParam
1220 bProcessed
= HandleCommand( wId
1233 UnpackMenuSelect( wParam
1239 bProcessed
= HandleMenuSelect( wItem
1243 mRc
= (MRESULT
)TRUE
;
1249 SHORT nScxnew
= SHORT1FROMMP(lParam
); // New horizontal size.
1250 SHORT nScynew
= SHORT2FROMMP(lParam
); // New vertical size.
1252 lParam
= MRFROM2SHORT( nScxnew
- 20
1256 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1257 mRc
= (MRESULT
)FALSE
;
1260 case CM_QUERYDRAGIMAGE
:
1262 const wxIcon
& vIcon
= GetIcon();
1266 hIcon
= (HPOINTER
)::WinSendMsg(GetHWND(), WM_QUERYICON
, 0L, 0L);
1268 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1269 mRc
= (MRESULT
)hIcon
;
1270 bProcessed
= mRc
!= 0;
1276 mRc
= wxWindow::OS2WindowProc( uMessage
1280 return (MRESULT
)mRc
;
1281 } // wxFrame::OS2WindowProc
1283 void wxFrame::SetClient(WXHWND
WXUNUSED(c_Hwnd
))
1285 // Duh...nothing to do under OS/2
1288 void wxFrame::SetClient( wxWindow
* pWindow
)
1290 wxWindow
* pOldClient
= this->GetClient();
1291 bool bClientHasFocus
= pOldClient
&& (pOldClient
== wxWindow::FindFocus());
1293 if(pOldClient
== pWindow
) // nothing to do
1295 if(pWindow
== NULL
) // just need to remove old client
1297 if(pOldClient
== NULL
) // nothing to do
1300 if(bClientHasFocus
)
1303 pOldClient
->Enable( false );
1304 pOldClient
->Show( false );
1305 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1306 // to avoid OS/2 bug need to update frame
1307 ::WinSendMsg((HWND
)this->GetFrame(), WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1312 // Else need to change client
1317 ::WinEnableWindowUpdate((HWND
)GetHWND(), FALSE
);
1320 pOldClient
->Enable(false);
1321 pOldClient
->Show(false);
1322 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1324 pWindow
->Reparent(this);
1325 ::WinSetWindowUShort(pWindow
->GetHWND(), QWS_ID
, FID_CLIENT
);
1326 ::WinEnableWindowUpdate((HWND
)GetHWND(), TRUE
);
1328 pWindow
->Show(); // ensure client is showing
1329 if( this->IsShown() )
1332 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1336 wxWindow
* wxFrame::GetClient()
1338 return wxFindWinFromHandle((WXHWND
)::WinWindowFromID(m_hFrame
, FID_CLIENT
));
1341 void wxFrame::SendSizeEvent()
1345 RECTL vRect
= wxGetWindowRect(GetHwnd());
1347 ::WinPostMsg( GetHwnd()
1349 ,MPFROM2SHORT( vRect
.xRight
- vRect
.xLeft
1350 ,vRect
.xRight
- vRect
.xLeft
1352 ,MPFROM2SHORT( vRect
.yTop
- vRect
.yBottom
1353 ,vRect
.yTop
- vRect
.yBottom