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"
33 #include "wx/statusbr.h"
34 #include "wx/menuitem.h"
37 #include "wx/os2/private.h"
39 // ----------------------------------------------------------------------------
41 // ----------------------------------------------------------------------------
43 #if wxUSE_MENUS_NATIVE
44 extern wxMenu
*wxCurrentPopupMenu
;
47 // ----------------------------------------------------------------------------
49 // ----------------------------------------------------------------------------
51 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
52 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
55 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
57 // ============================================================================
59 // ============================================================================
61 // ----------------------------------------------------------------------------
62 // static class members
63 // ----------------------------------------------------------------------------
66 #if wxUSE_NATIVE_STATUSBAR
67 bool wxFrame::m_bUseNativeStatusBar
= true;
69 bool wxFrame::m_bUseNativeStatusBar
= false;
72 #endif //wxUSE_STATUSBAR
74 // ----------------------------------------------------------------------------
75 // creation/destruction
76 // ----------------------------------------------------------------------------
80 m_nFsStatusBarFields
= 0;
81 m_nFsStatusBarHeight
= 0;
82 m_nFsToolBarHeight
= 0;
84 m_bWasMinimized
= false;
87 m_frameMenuBar
= NULL
;
88 m_frameToolBar
= NULL
;
89 m_frameStatusBar
= NULL
;
91 m_hTitleBar
= NULLHANDLE
;
92 m_hHScroll
= NULLHANDLE
;
93 m_hVScroll
= NULLHANDLE
;
98 memset(&m_vSwpTitleBar
, 0, sizeof(SWP
));
99 memset(&m_vSwpMenuBar
, 0, sizeof(SWP
));
100 memset(&m_vSwpHScroll
, 0, sizeof(SWP
));
101 memset(&m_vSwpVScroll
, 0, sizeof(SWP
));
102 memset(&m_vSwpStatusBar
, 0, sizeof(SWP
));
103 memset(&m_vSwpToolBar
, 0, sizeof(SWP
));
106 } // end of wxFrame::Init
108 bool wxFrame::Create( wxWindow
* pParent
,
110 const wxString
& rsTitle
,
114 const wxString
& rsName
)
116 if (!wxTopLevelWindow::Create( pParent
126 } // end of wxFrame::Create
130 m_isBeingDeleted
= true;
132 } // end of wxFrame::~wxFrame
135 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
137 void wxFrame::DoGetClientSize(
142 wxTopLevelWindow::DoGetClientSize( pX
146 // No need to use statusbar code as in WIN32 as the FORMATFRAME
147 // window procedure ensures PM knows about the new frame client
148 // size internally. A ::WinQueryWindowRect (that is called in
149 // wxWindow's GetClient size from above) is all that is needed!
151 } // end of wxFrame::DoGetClientSize
154 // Set the client size (i.e. leave the calculation of borders etc.
157 void wxFrame::DoSetClientSize(
163 // Statusbars are not part of the OS/2 Client but parent frame
164 // so no statusbar consideration
166 wxTopLevelWindow::DoSetClientSize( nWidth
169 } // end of wxFrame::DoSetClientSize
171 // ----------------------------------------------------------------------------
172 // wxFrame: various geometry-related functions
173 // ----------------------------------------------------------------------------
175 void wxFrame::Raise()
177 wxFrameBase::Raise();
178 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
189 wxStatusBar
* wxFrame::OnCreateStatusBar(
193 , const wxString
& rName
196 wxStatusBar
* pStatusBar
= NULL
;
199 pStatusBar
= wxFrameBase::OnCreateStatusBar( nNumber
208 wxClientDC
vDC(pStatusBar
);
212 // Set the height according to the font and the border size
214 vDC
.SetFont(pStatusBar
->GetFont()); // Screws up the menues for some reason
215 vDC
.GetTextExtent( wxT("X")
220 int nHeight
= ((11 * nY
) / 10 + 2 * pStatusBar
->GetBorderY());
222 pStatusBar
->SetSize( wxDefaultCoord
228 ::WinSetParent( pStatusBar
->GetHWND(), m_hFrame
, FALSE
);
229 ::WinSetOwner( pStatusBar
->GetHWND(), m_hFrame
);
233 if(::WinIsWindowShowing(m_hFrame
))
234 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
237 } // end of wxFrame::OnCreateStatusBar
239 void wxFrame::PositionStatusBar()
246 // Native status bar positions itself
248 if (m_frameStatusBar
)
257 ::WinQueryWindowRect(m_hFrame
, &vRect
);
259 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
261 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
262 nWidth
= vRect
.xRight
- vRect
.xLeft
;
263 nY
= nY
- (vRect
.yBottom
- vFRect
.yBottom
);
265 m_frameStatusBar
->GetSize( &nStatbarWidth
269 nY
= nY
- nStatbarHeight
;
271 // Since we wish the status bar to be directly under the client area,
272 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
274 m_frameStatusBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
279 if (!::WinQueryWindowPos(m_frameStatusBar
->GetHWND(), &vSwp
))
281 vError
= ::WinGetLastError(vHabmain
);
282 sError
= wxPMErrorToStr(vError
);
283 wxLogError(_T("Error setting parent for StatusBar. Error: %s\n"), sError
.c_str());
287 } // end of wxFrame::PositionStatusBar
288 #endif // wxUSE_STATUSBAR
291 wxToolBar
* wxFrame::OnCreateToolBar( long lStyle
, wxWindowID vId
, const wxString
& rsName
)
293 wxToolBar
* pToolBar
= wxFrameBase::OnCreateToolBar( lStyle
298 ::WinSetParent( pToolBar
->GetHWND(), m_hFrame
, FALSE
);
299 ::WinSetOwner( pToolBar
->GetHWND(), m_hFrame
);
301 } // end of WinGuiBase_CFrame::OnCreateToolBar
304 #if wxUSE_MENUS_NATIVE
305 void wxFrame::DetachMenuBar()
309 m_frameMenuBar
->Detach();
310 m_frameMenuBar
= NULL
;
312 } // end of wxFrame::DetachMenuBar
314 void wxFrame::SetMenuBar(
325 // Actually remove the menu from the frame
327 m_hMenu
= (WXHMENU
)0;
328 InternalSetMenuBar();
330 else // set new non NULL menu bar
332 m_frameMenuBar
= NULL
;
335 // Can set a menubar several times.
336 // TODO: how to prevent a memory leak if you have a currently-unattached
337 // menubar? wxWidgets assumes that the frame will delete the menu (otherwise
338 // there are problems for MDI).
340 if (pMenuBar
->GetHMenu())
342 m_hMenu
= pMenuBar
->GetHMenu();
347 m_hMenu
= pMenuBar
->Create();
351 InternalSetMenuBar();
352 m_frameMenuBar
= pMenuBar
;
353 pMenuBar
->Attach((wxFrame
*)this);
355 } // end of wxFrame::SetMenuBar
357 void wxFrame::AttachMenuBar(
361 wxFrameBase::AttachMenuBar(pMenubar
);
363 m_frameMenuBar
= pMenubar
;
368 // Actually remove the menu from the frame
370 m_hMenu
= (WXHMENU
)0;
371 InternalSetMenuBar();
373 else // Set new non NULL menu bar
376 // Can set a menubar several times.
378 if (pMenubar
->GetHMenu())
380 m_hMenu
= pMenubar
->GetHMenu();
384 if (pMenubar
->IsAttached())
387 m_hMenu
= pMenubar
->Create();
392 InternalSetMenuBar();
394 } // end of wxFrame::AttachMenuBar
396 void wxFrame::InternalSetMenuBar()
401 // Set the parent and owner of the menubar to be the frame
403 if (!::WinSetParent(m_hMenu
, m_hFrame
, FALSE
))
405 vError
= ::WinGetLastError(vHabmain
);
406 sError
= wxPMErrorToStr(vError
);
407 wxLogError(_T("Error setting parent for submenu. Error: %s\n"), sError
.c_str());
410 if (!::WinSetOwner(m_hMenu
, m_hFrame
))
412 vError
= ::WinGetLastError(vHabmain
);
413 sError
= wxPMErrorToStr(vError
);
414 wxLogError(_T("Error setting parent for submenu. Error: %s\n"), sError
.c_str());
416 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
417 } // end of wxFrame::InternalSetMenuBar
418 #endif // wxUSE_MENUS_NATIVE
421 // Responds to colour changes, and passes event on to children
423 void wxFrame::OnSysColourChanged(
424 wxSysColourChangedEvent
& rEvent
427 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
431 if (m_frameStatusBar
)
433 wxSysColourChangedEvent vEvent2
;
435 vEvent2
.SetEventObject(m_frameStatusBar
);
436 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
438 #endif //wxUSE_STATUSBAR
441 // Propagate the event to the non-top-level children
443 wxWindow::OnSysColourChanged(rEvent
);
444 } // end of wxFrame::OnSysColourChanged
446 // Pass true to show full screen, false to restore.
447 bool wxFrame::ShowFullScreen( bool bShow
, long lStyle
)
454 m_bFsIsShowing
= true;
458 wxToolBar
* pTheToolBar
= GetToolBar();
459 #endif //wxUSE_TOOLBAR
462 wxStatusBar
* pTheStatusBar
= GetStatusBar();
463 #endif //wxUSE_STATUSBAR
469 pTheToolBar
->GetSize(&nDummyWidth
, &m_nFsToolBarHeight
);
470 #endif //wxUSE_TOOLBAR
474 pTheStatusBar
->GetSize(&nDummyWidth
, &m_nFsStatusBarHeight
);
475 #endif //wxUSE_STATUSBAR
479 // Zap the toolbar, menubar, and statusbar
481 if ((lStyle
& wxFULLSCREEN_NOTOOLBAR
) && pTheToolBar
)
483 pTheToolBar
->SetSize(wxDefaultCoord
,0);
484 pTheToolBar
->Show(false);
486 #endif //wxUSE_TOOLBAR
488 if (lStyle
& wxFULLSCREEN_NOMENUBAR
)
490 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
491 ::WinSetOwner(m_hMenu
, m_hFrame
);
492 ::WinSendMsg((HWND
)m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
497 // Save the number of fields in the statusbar
499 if ((lStyle
& wxFULLSCREEN_NOSTATUSBAR
) && pTheStatusBar
)
501 m_nFsStatusBarFields
= pTheStatusBar
->GetFieldsCount();
502 SetStatusBar((wxStatusBar
*) NULL
);
503 delete pTheStatusBar
;
506 m_nFsStatusBarFields
= 0;
507 #endif //wxUSE_STATUSBAR
510 // Zap the frame borders
514 // Save the 'normal' window style
516 m_lFsOldWindowStyle
= ::WinQueryWindowULong(m_hFrame
, QWL_STYLE
);
519 // Save the old position, width & height, maximize state
521 m_vFsOldSize
= GetRect();
522 m_bFsIsMaximized
= IsMaximized();
525 // Decide which window style flags to turn off
527 LONG lNewStyle
= m_lFsOldWindowStyle
;
530 if (lStyle
& wxFULLSCREEN_NOBORDER
)
531 lOffFlags
|= FCF_BORDER
;
532 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
533 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
535 lNewStyle
&= (~lOffFlags
);
538 // Change our window style to be compatible with full-screen mode
540 ::WinSetWindowULong((HWND
)m_hFrame
, QWL_STYLE
, (ULONG
)lNewStyle
);
543 // Resize to the size of the desktop
549 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
550 nWidth
= vRect
.xRight
- vRect
.xLeft
;
552 // Remember OS/2 is backwards!
554 nHeight
= vRect
.yTop
- vRect
.yBottom
;
556 SetSize( nWidth
, nHeight
);
559 // Now flush the window style cache and actually go full-screen
561 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
570 wxSize
sz( nWidth
, nHeight
);
571 wxSizeEvent
vEvent( sz
, GetId() );
573 GetEventHandler()->ProcessEvent(vEvent
);
581 m_bFsIsShowing
= false;
584 wxToolBar
* pTheToolBar
= GetToolBar();
587 // Restore the toolbar, menubar, and statusbar
589 if (pTheToolBar
&& (m_lFsStyle
& wxFULLSCREEN_NOTOOLBAR
))
591 pTheToolBar
->SetSize(wxDefaultCoord
, m_nFsToolBarHeight
);
592 pTheToolBar
->Show(true);
594 #endif //wxUSE_TOOLBAR
597 if ((m_lFsStyle
& wxFULLSCREEN_NOSTATUSBAR
) && (m_nFsStatusBarFields
> 0))
599 CreateStatusBar(m_nFsStatusBarFields
);
600 // PositionStatusBar();
602 #endif //wxUSE_STATUSBAR
604 if ((m_lFsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
606 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
607 ::WinSetOwner(m_hMenu
, m_hFrame
);
608 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
610 Maximize(m_bFsIsMaximized
);
612 ::WinSetWindowULong( m_hFrame
614 ,(ULONG
)m_lFsOldWindowStyle
616 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
625 return wxFrameBase::ShowFullScreen(bShow
, lStyle
);
626 } // end of wxFrame::ShowFullScreen
631 // ----------------------------------------------------------------------------
632 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
633 // from the client area, so the client area is what's really available for the
635 // ----------------------------------------------------------------------------
637 // Checks if there is a toolbar, and returns the first free client position
638 wxPoint
wxFrame::GetClientAreaOrigin() const
640 wxPoint vPoint
= wxTopLevelWindow::GetClientAreaOrigin();
643 // In OS/2 the toolbar and statusbar are frame extensions so there is no
644 // adjustment. The client is supposedly resized for a toolbar in OS/2
645 // as it is for the status bar.
648 } // end of wxFrame::GetClientAreaOrigin
650 // ----------------------------------------------------------------------------
651 // tool/status bar stuff
652 // ----------------------------------------------------------------------------
656 wxToolBar
* wxFrame::CreateToolBar(
659 , const wxString
& rName
662 if (wxFrameBase::CreateToolBar( lStyle
669 return m_frameToolBar
;
670 } // end of wxFrame::CreateToolBar
672 void wxFrame::PositionToolBar()
674 wxToolBar
* pToolBar
= GetToolBar();
687 ::WinQueryWindowRect(m_hFrame
, &vRect
);
688 vPos
.y
= (wxCoord
)vRect
.yTop
;
689 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
691 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
693 vPos
.y
= (wxCoord
)(vFRect
.yTop
- vRect
.yTop
);
694 pToolBar
->GetSize( &vTWidth
698 if (pToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
700 vWidth
= (wxCoord
)(vRect
.xRight
- vRect
.xLeft
);
701 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
707 else if (pToolBar
->GetWindowStyleFlag() & wxTB_BOTTOM
)
709 vWidth
= (wxCoord
)(vRect
.xRight
- vRect
.xLeft
);
710 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
711 ,vRect
.yBottom
- vTHeight
// assuming the vRect contains the client coordinates
719 wxCoord vSheight
= 0;
721 if (m_frameStatusBar
)
722 m_frameStatusBar
->GetSize( &vSwidth
725 vHeight
= (wxCoord
)(vRect
.yTop
- vRect
.yBottom
);
726 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
732 if( ::WinIsWindowShowing(m_hFrame
) )
733 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
734 } // end of wxFrame::PositionToolBar
735 #endif // wxUSE_TOOLBAR
737 // ----------------------------------------------------------------------------
738 // frame state (iconized/maximized/...)
739 // ----------------------------------------------------------------------------
742 // propagate our state change to all child frames: this allows us to emulate X
743 // Windows behaviour where child frames float independently of the parent one
744 // on the desktop, but are iconized/restored with it
746 void wxFrame::IconizeChildFrames( bool WXUNUSED(bIconize
) )
748 // FIXME: Generic MDI does not use Frames for the Childs, so this does _not_
749 // work. Possibly, the right thing is simply to eliminate this
750 // functions and all the calls to it from within this file.
752 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
754 pNode
= pNode
->GetNext() )
756 wxWindow
* pWin
= pNode
->GetData();
757 wxFrame
* pFrame
= wxDynamicCast(pWin
, wxFrame
);
760 #if wxUSE_MDI_ARCHITECTURE
761 && !wxDynamicCast(pFrame
, wxMDIChildFrame
)
762 #endif // wxUSE_MDI_ARCHITECTURE
766 // We don't want to restore the child frames which had been
767 // iconized even before we were iconized, so save the child frame
768 // status when iconizing the parent frame and check it when
773 pFrame
->m_bWasMinimized
= pFrame
->IsIconized();
777 // This test works for both iconizing and restoring
779 if (!pFrame
->m_bWasMinimized
)
780 pFrame
->Iconize(bIconize
);
784 } // end of wxFrame::IconizeChildFrames
786 WXHICON
wxFrame::GetDefaultIcon() const
788 return (WXHICON
)(wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
789 : wxDEFAULT_FRAME_ICON
);
791 // ===========================================================================
792 // message processing
793 // ===========================================================================
795 // ---------------------------------------------------------------------------
797 // ---------------------------------------------------------------------------
798 bool wxFrame::OS2TranslateMessage( WXMSG
* pMsg
)
801 // try the menu bar accels
803 wxMenuBar
* pMenuBar
= GetMenuBar();
808 #if wxUSE_ACCEL && wxUSE_MENUS_NATIVE
809 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
810 return rAcceleratorTable
.Translate(GetHWND(), pMsg
);
814 } // end of wxFrame::OS2TranslateMessage
816 // ---------------------------------------------------------------------------
817 // our private (non virtual) message handlers
818 // ---------------------------------------------------------------------------
819 bool wxFrame::HandlePaint()
823 if (::WinQueryUpdateRect(GetHWND(), &vRect
))
828 // Icons in PM are the same as "pointers"
830 const wxIcon
& vIcon
= GetIcon();
834 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
836 hIcon
= (HPOINTER
)m_hDefaultIcon
;
839 // Hold a pointer to the dc so long as the OnPaint() message
840 // is being processed
843 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
846 // Erase background before painting or we get white background
848 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
854 ::WinQueryWindowRect(GetHwnd(), &vRect3
);
856 static const int nIconWidth
= 32;
857 static const int nIconHeight
= 32;
858 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
859 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
861 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
867 if (!wxWindow::HandlePaint())
872 hPS
= ::WinBeginPaint( GetHwnd()
878 ::GpiCreateLogColorTable( hPS
882 ,(LONG
)wxTheColourDatabase
->m_nSize
883 ,(PLONG
)wxTheColourDatabase
->m_palTable
885 ::GpiCreateLogColorTable( hPS
895 ,GetBackgroundColour().GetPixel()
904 } // end of wxFrame::HandlePaint
906 bool wxFrame::HandleSize( int nX
, int nY
, WXUINT nId
)
908 bool bProcessed
= false;
914 // Only do it it if we were iconized before, otherwise resizing the
915 // parent frame has a curious side effect of bringing it under it's
921 // restore all child frames too
923 IconizeChildFrames(false);
924 (void)SendIconizeEvent(false);
936 // Iconize all child frames too
938 IconizeChildFrames(true);
939 (void)SendIconizeEvent();
947 // forward WM_SIZE to status bar control
949 #if wxUSE_NATIVE_STATUSBAR
950 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
952 wxSizeEvent
vEvent( wxSize( nX
955 ,m_frameStatusBar
->GetId()
958 vEvent
.SetEventObject(m_frameStatusBar
);
959 m_frameStatusBar
->OnSize(vEvent
);
961 #endif // wxUSE_NATIVE_STATUSBAR
966 #endif // wxUSE_TOOLBAR
968 bProcessed
= wxWindow::HandleSize( nX
974 } // end of wxFrame::HandleSize
976 bool wxFrame::HandleCommand( WXWORD nId
,
983 // In case it's e.g. a toolbar.
985 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
988 return pWin
->OS2Command( nCmd
, nId
);
992 // Handle here commands from menus and accelerators
994 if (nCmd
== CMDSRC_MENU
|| nCmd
== CMDSRC_ACCELERATOR
)
996 #if wxUSE_MENUS_NATIVE
997 if (wxCurrentPopupMenu
)
999 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1001 wxCurrentPopupMenu
= NULL
;
1003 return pPopupMenu
->OS2Command( nCmd
, nId
);
1007 if (ProcessCommand(nId
))
1013 } // end of wxFrame::HandleCommand
1015 bool wxFrame::HandleMenuSelect( WXWORD nItem
,
1024 rc
= ::WinSendMsg(hMenu
, MM_QUERYITEM
, MPFROM2SHORT(nItem
, TRUE
), (MPARAM
)&mItem
);
1026 if(rc
&& !(mItem
.afStyle
& (MIS_SUBMENU
| MIS_SEPARATOR
)))
1028 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nItem
);
1030 vEvent
.SetEventObject(this);
1031 GetEventHandler()->ProcessEvent(vEvent
); // return value would be ignored by PM
1035 DoGiveHelp(wxEmptyString
, false);
1040 } // end of wxFrame::HandleMenuSelect
1042 // ---------------------------------------------------------------------------
1043 // Main Frame window proc
1044 // ---------------------------------------------------------------------------
1045 MRESULT EXPENTRY
wxFrameMainWndProc( HWND hWnd
,
1050 MRESULT rc
= (MRESULT
)0;
1051 bool bProcessed
= false;
1052 wxFrame
* pWnd
= NULL
;
1054 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1057 case WM_QUERYFRAMECTLCOUNT
:
1058 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1060 USHORT uItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1062 rc
= MRFROMSHORT(uItemCount
);
1066 case WM_FORMATFRAME
:
1067 /////////////////////////////////////////////////////////////////////////////////
1068 // Applications that subclass frame controls may find that the frame is already
1069 // subclassed the number of frame controls is variable.
1070 // The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
1071 // subclassed by calling the previous window procedure and modifying its result.
1072 ////////////////////////////////////////////////////////////////////////////////
1084 pSWP
= (PSWP
)PVOIDFROMMP(wParam
);
1085 nItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1086 if(pWnd
->m_frameStatusBar
)
1088 ::WinQueryWindowRect(pWnd
->m_frameStatusBar
->GetHWND(), &vRstb
);
1089 pWnd
->m_frameStatusBar
->GetSize(NULL
, &nHeight
);
1091 if(pWnd
->m_frameToolBar
)
1093 ::WinQueryWindowRect(pWnd
->m_frameToolBar
->GetHWND(), &vRtlb
);
1094 pWnd
->m_frameToolBar
->GetSize(&nWidth
, &nHeight2
);
1096 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1097 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1098 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1099 ::WinMapWindowPoints(HWND_DESKTOP
, pWnd
->m_hFrame
, (PPOINTL
)&vRectl
, 2);
1100 for(i
= 0; i
< nItemCount
; i
++)
1102 if(pWnd
->m_hWnd
&& pSWP
[i
].hwnd
== pWnd
->m_hWnd
)
1104 if (pWnd
->m_frameToolBar
&& pWnd
->m_frameToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
1106 pSWP
[i
].x
= vRectl
.xLeft
;
1107 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1108 pSWP
[i
].cx
= vRectl
.xRight
- vRectl
.xLeft
;
1109 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- (nHeight
+ nHeight2
);
1113 pSWP
[i
].x
= vRectl
.xLeft
+ nWidth
;
1114 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1115 pSWP
[i
].cx
= vRectl
.xRight
- (vRectl
.xLeft
+ nWidth
);
1116 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- nHeight
;
1118 pSWP
[i
].fl
= SWP_SIZE
| SWP_MOVE
| SWP_SHOW
;
1119 pSWP
[i
].hwndInsertBehind
= HWND_TOP
;
1123 rc
= MRFROMSHORT(nItemCount
);
1128 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1129 rc
= pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
);
1131 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1134 } // end of wxFrameMainWndProc
1136 MRESULT EXPENTRY
wxFrameWndProc(
1144 // Trace all ulMsgs - useful for the debugging
1147 wxFrame
* pWnd
= NULL
;
1149 parentHwnd
= WinQueryWindow(hWnd
,QW_PARENT
);
1150 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1153 // When we get the first message for the HWND we just created, we associate
1154 // it with wxWindow stored in wxWndHook
1157 MRESULT rc
= (MRESULT
)0;
1160 // Stop right here if we don't have a valid handle in our wxWindow object.
1162 if (pWnd
&& !pWnd
->GetHWND())
1164 pWnd
->SetHWND((WXHWND
) hWnd
);
1165 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
1171 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
1173 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1176 } // end of wxFrameWndProc
1178 MRESULT
wxFrame::OS2WindowProc( WXUINT uMessage
,
1183 bool bProcessed
= false;
1189 // If we can't close, tell the system that we processed the
1190 // message - otherwise it would close us
1192 bProcessed
= !Close();
1196 bProcessed
= HandlePaint();
1197 mRc
= (MRESULT
)FALSE
;
1200 case WM_ERASEBACKGROUND
:
1202 // Returning TRUE to requests PM to paint the window background
1203 // in SYSCLR_WINDOW. We capture this here because the PS returned
1204 // in Frames is the PS for the whole frame, which we can't really
1205 // use at all. If you want to paint a different background, do it
1206 // in an OnPaint using a wxPaintDC.
1208 mRc
= (MRESULT
)(TRUE
);
1217 UnpackCommand( (WXWPARAM
)wParam
1224 bProcessed
= HandleCommand( wId
1237 UnpackMenuSelect( wParam
1243 bProcessed
= HandleMenuSelect( wItem
1247 mRc
= (MRESULT
)TRUE
;
1253 SHORT nScxnew
= SHORT1FROMMP(lParam
); // New horizontal size.
1254 SHORT nScynew
= SHORT2FROMMP(lParam
); // New vertical size.
1256 lParam
= MRFROM2SHORT( nScxnew
- 20
1260 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1261 mRc
= (MRESULT
)FALSE
;
1264 case CM_QUERYDRAGIMAGE
:
1266 const wxIcon
& vIcon
= GetIcon();
1270 hIcon
= (HPOINTER
)::WinSendMsg(GetHWND(), WM_QUERYICON
, 0L, 0L);
1272 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1273 mRc
= (MRESULT
)hIcon
;
1274 bProcessed
= mRc
!= 0;
1280 mRc
= wxWindow::OS2WindowProc( uMessage
1284 return (MRESULT
)mRc
;
1285 } // wxFrame::OS2WindowProc
1287 void wxFrame::SetClient(WXHWND
WXUNUSED(c_Hwnd
))
1289 // Duh...nothing to do under OS/2
1292 void wxFrame::SetClient( wxWindow
* pWindow
)
1294 wxWindow
* pOldClient
= this->GetClient();
1295 bool bClientHasFocus
= pOldClient
&& (pOldClient
== wxWindow::FindFocus());
1297 if(pOldClient
== pWindow
) // nothing to do
1299 if(pWindow
== NULL
) // just need to remove old client
1301 if(pOldClient
== NULL
) // nothing to do
1304 if(bClientHasFocus
)
1307 pOldClient
->Enable( false );
1308 pOldClient
->Show( false );
1309 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1310 // to avoid OS/2 bug need to update frame
1311 ::WinSendMsg((HWND
)this->GetFrame(), WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1316 // Else need to change client
1321 ::WinEnableWindowUpdate((HWND
)GetHWND(), FALSE
);
1324 pOldClient
->Enable(false);
1325 pOldClient
->Show(false);
1326 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1328 pWindow
->Reparent(this);
1329 ::WinSetWindowUShort(pWindow
->GetHWND(), QWS_ID
, FID_CLIENT
);
1330 ::WinEnableWindowUpdate((HWND
)GetHWND(), TRUE
);
1332 pWindow
->Show(); // ensure client is showing
1333 if( this->IsShown() )
1336 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1340 wxWindow
* wxFrame::GetClient()
1342 return wxFindWinFromHandle((WXHWND
)::WinWindowFromID(m_hFrame
, FID_CLIENT
));
1345 void wxFrame::SendSizeEvent()
1349 RECTL vRect
= wxGetWindowRect(GetHwnd());
1351 ::WinPostMsg( GetHwnd()
1353 ,MPFROM2SHORT( vRect
.xRight
- vRect
.xLeft
1354 ,vRect
.xRight
- vRect
.xLeft
1356 ,MPFROM2SHORT( vRect
.yTop
- vRect
.yBottom
1357 ,vRect
.yTop
- vRect
.yBottom