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
)
710 wxCoord vSheight
= 0;
712 if (m_frameStatusBar
)
713 m_frameStatusBar
->GetSize( &vSwidth
716 vWidth
= (wxCoord
)(vRect
.xRight
- vRect
.xLeft
);
717 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
718 ,vFRect
.yTop
- vRect
.yBottom
- vTHeight
- vSheight
726 wxCoord vSheight
= 0;
728 if (m_frameStatusBar
)
729 m_frameStatusBar
->GetSize( &vSwidth
732 vHeight
= (wxCoord
)(vRect
.yTop
- vRect
.yBottom
);
733 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
739 if( ::WinIsWindowShowing(m_hFrame
) )
740 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
741 } // end of wxFrame::PositionToolBar
742 #endif // wxUSE_TOOLBAR
744 // ----------------------------------------------------------------------------
745 // frame state (iconized/maximized/...)
746 // ----------------------------------------------------------------------------
749 // propagate our state change to all child frames: this allows us to emulate X
750 // Windows behaviour where child frames float independently of the parent one
751 // on the desktop, but are iconized/restored with it
753 void wxFrame::IconizeChildFrames( bool WXUNUSED(bIconize
) )
755 // FIXME: Generic MDI does not use Frames for the Childs, so this does _not_
756 // work. Possibly, the right thing is simply to eliminate this
757 // functions and all the calls to it from within this file.
759 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
761 pNode
= pNode
->GetNext() )
763 wxWindow
* pWin
= pNode
->GetData();
764 wxFrame
* pFrame
= wxDynamicCast(pWin
, wxFrame
);
767 #if wxUSE_MDI_ARCHITECTURE
768 && !wxDynamicCast(pFrame
, wxMDIChildFrame
)
769 #endif // wxUSE_MDI_ARCHITECTURE
773 // We don't want to restore the child frames which had been
774 // iconized even before we were iconized, so save the child frame
775 // status when iconizing the parent frame and check it when
780 pFrame
->m_bWasMinimized
= pFrame
->IsIconized();
784 // This test works for both iconizing and restoring
786 if (!pFrame
->m_bWasMinimized
)
787 pFrame
->Iconize(bIconize
);
791 } // end of wxFrame::IconizeChildFrames
793 WXHICON
wxFrame::GetDefaultIcon() const
795 return (WXHICON
)(wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
796 : wxDEFAULT_FRAME_ICON
);
798 // ===========================================================================
799 // message processing
800 // ===========================================================================
802 // ---------------------------------------------------------------------------
804 // ---------------------------------------------------------------------------
805 bool wxFrame::OS2TranslateMessage( WXMSG
* pMsg
)
808 // try the menu bar accels
810 wxMenuBar
* pMenuBar
= GetMenuBar();
815 #if wxUSE_ACCEL && wxUSE_MENUS_NATIVE
816 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
817 return rAcceleratorTable
.Translate(GetHWND(), pMsg
);
821 } // end of wxFrame::OS2TranslateMessage
823 // ---------------------------------------------------------------------------
824 // our private (non virtual) message handlers
825 // ---------------------------------------------------------------------------
826 bool wxFrame::HandlePaint()
830 if (::WinQueryUpdateRect(GetHWND(), &vRect
))
835 // Icons in PM are the same as "pointers"
837 const wxIcon
& vIcon
= GetIcon();
841 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
843 hIcon
= (HPOINTER
)m_hDefaultIcon
;
846 // Hold a pointer to the dc so long as the OnPaint() message
847 // is being processed
850 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
853 // Erase background before painting or we get white background
855 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
861 ::WinQueryWindowRect(GetHwnd(), &vRect3
);
863 static const int nIconWidth
= 32;
864 static const int nIconHeight
= 32;
865 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
866 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
868 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
874 if (!wxWindow::HandlePaint())
879 hPS
= ::WinBeginPaint( GetHwnd()
885 ::GpiCreateLogColorTable( hPS
889 ,(LONG
)wxTheColourDatabase
->m_nSize
890 ,(PLONG
)wxTheColourDatabase
->m_palTable
892 ::GpiCreateLogColorTable( hPS
902 ,GetBackgroundColour().GetPixel()
911 } // end of wxFrame::HandlePaint
913 bool wxFrame::HandleSize( int nX
, int nY
, WXUINT nId
)
915 bool bProcessed
= false;
921 // Only do it it if we were iconized before, otherwise resizing the
922 // parent frame has a curious side effect of bringing it under it's
928 // restore all child frames too
930 IconizeChildFrames(false);
931 (void)SendIconizeEvent(false);
943 // Iconize all child frames too
945 IconizeChildFrames(true);
946 (void)SendIconizeEvent();
954 // forward WM_SIZE to status bar control
956 #if wxUSE_NATIVE_STATUSBAR
957 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
959 wxSizeEvent
vEvent( wxSize( nX
962 ,m_frameStatusBar
->GetId()
965 vEvent
.SetEventObject(m_frameStatusBar
);
966 m_frameStatusBar
->OnSize(vEvent
);
968 #endif // wxUSE_NATIVE_STATUSBAR
973 #endif // wxUSE_TOOLBAR
975 bProcessed
= wxWindow::HandleSize( nX
981 } // end of wxFrame::HandleSize
983 bool wxFrame::HandleCommand( WXWORD nId
,
990 // In case it's e.g. a toolbar.
992 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
995 return pWin
->OS2Command( nCmd
, nId
);
999 // Handle here commands from menus and accelerators
1001 if (nCmd
== CMDSRC_MENU
|| nCmd
== CMDSRC_ACCELERATOR
)
1003 #if wxUSE_MENUS_NATIVE
1004 if (wxCurrentPopupMenu
)
1006 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1008 wxCurrentPopupMenu
= NULL
;
1010 return pPopupMenu
->OS2Command( nCmd
, nId
);
1014 if (ProcessCommand(nId
))
1020 } // end of wxFrame::HandleCommand
1022 bool wxFrame::HandleMenuSelect( WXWORD nItem
,
1031 rc
= ::WinSendMsg(hMenu
, MM_QUERYITEM
, MPFROM2SHORT(nItem
, TRUE
), (MPARAM
)&mItem
);
1033 if(rc
&& !(mItem
.afStyle
& (MIS_SUBMENU
| MIS_SEPARATOR
)))
1035 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nItem
);
1037 vEvent
.SetEventObject(this);
1038 GetEventHandler()->ProcessEvent(vEvent
); // return value would be ignored by PM
1042 DoGiveHelp(wxEmptyString
, false);
1047 } // end of wxFrame::HandleMenuSelect
1049 // ---------------------------------------------------------------------------
1050 // Main Frame window proc
1051 // ---------------------------------------------------------------------------
1052 MRESULT EXPENTRY
wxFrameMainWndProc( HWND hWnd
,
1057 MRESULT rc
= (MRESULT
)0;
1058 bool bProcessed
= false;
1059 wxFrame
* pWnd
= NULL
;
1061 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1064 case WM_QUERYFRAMECTLCOUNT
:
1065 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1067 USHORT uItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1069 rc
= MRFROMSHORT(uItemCount
);
1073 case WM_FORMATFRAME
:
1074 /////////////////////////////////////////////////////////////////////////////////
1075 // Applications that subclass frame controls may find that the frame is already
1076 // subclassed the number of frame controls is variable.
1077 // The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
1078 // subclassed by calling the previous window procedure and modifying its result.
1079 ////////////////////////////////////////////////////////////////////////////////
1091 pSWP
= (PSWP
)PVOIDFROMMP(wParam
);
1092 nItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1093 if(pWnd
->m_frameStatusBar
)
1095 ::WinQueryWindowRect(pWnd
->m_frameStatusBar
->GetHWND(), &vRstb
);
1096 pWnd
->m_frameStatusBar
->GetSize(NULL
, &nHeight
);
1098 if(pWnd
->m_frameToolBar
)
1100 ::WinQueryWindowRect(pWnd
->m_frameToolBar
->GetHWND(), &vRtlb
);
1101 pWnd
->m_frameToolBar
->GetSize(&nWidth
, &nHeight2
);
1103 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1104 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1105 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1106 ::WinMapWindowPoints(HWND_DESKTOP
, pWnd
->m_hFrame
, (PPOINTL
)&vRectl
, 2);
1107 for(i
= 0; i
< nItemCount
; i
++)
1109 if(pWnd
->m_hWnd
&& pSWP
[i
].hwnd
== pWnd
->m_hWnd
)
1111 if (pWnd
->m_frameToolBar
&& pWnd
->m_frameToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
1113 pSWP
[i
].x
= vRectl
.xLeft
;
1114 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1115 pSWP
[i
].cx
= vRectl
.xRight
- vRectl
.xLeft
;
1116 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- (nHeight
+ nHeight2
);
1118 else if (pWnd
->m_frameToolBar
&& pWnd
->m_frameToolBar
->GetWindowStyleFlag() & wxTB_BOTTOM
)
1120 pSWP
[i
].x
= vRectl
.xLeft
;
1121 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
+ nHeight2
;
1122 pSWP
[i
].cx
= vRectl
.xRight
- vRectl
.xLeft
;
1123 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- (nHeight
+ nHeight2
);
1127 pSWP
[i
].x
= vRectl
.xLeft
+ nWidth
;
1128 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1129 pSWP
[i
].cx
= vRectl
.xRight
- (vRectl
.xLeft
+ nWidth
);
1130 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- nHeight
;
1132 pSWP
[i
].fl
= SWP_SIZE
| SWP_MOVE
| SWP_SHOW
;
1133 pSWP
[i
].hwndInsertBehind
= HWND_TOP
;
1137 rc
= MRFROMSHORT(nItemCount
);
1142 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1143 rc
= pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
);
1145 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1148 } // end of wxFrameMainWndProc
1150 MRESULT EXPENTRY
wxFrameWndProc(
1158 // Trace all ulMsgs - useful for the debugging
1161 wxFrame
* pWnd
= NULL
;
1163 parentHwnd
= WinQueryWindow(hWnd
,QW_PARENT
);
1164 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1167 // When we get the first message for the HWND we just created, we associate
1168 // it with wxWindow stored in wxWndHook
1171 MRESULT rc
= (MRESULT
)0;
1174 // Stop right here if we don't have a valid handle in our wxWindow object.
1176 if (pWnd
&& !pWnd
->GetHWND())
1178 pWnd
->SetHWND((WXHWND
) hWnd
);
1179 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
1185 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
1187 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1190 } // end of wxFrameWndProc
1192 MRESULT
wxFrame::OS2WindowProc( WXUINT uMessage
,
1197 bool bProcessed
= false;
1203 // If we can't close, tell the system that we processed the
1204 // message - otherwise it would close us
1206 bProcessed
= !Close();
1210 bProcessed
= HandlePaint();
1211 mRc
= (MRESULT
)FALSE
;
1214 case WM_ERASEBACKGROUND
:
1216 // Returning TRUE to requests PM to paint the window background
1217 // in SYSCLR_WINDOW. We capture this here because the PS returned
1218 // in Frames is the PS for the whole frame, which we can't really
1219 // use at all. If you want to paint a different background, do it
1220 // in an OnPaint using a wxPaintDC.
1222 mRc
= (MRESULT
)(TRUE
);
1231 UnpackCommand( (WXWPARAM
)wParam
1238 bProcessed
= HandleCommand( wId
1251 UnpackMenuSelect( wParam
1257 bProcessed
= HandleMenuSelect( wItem
1261 mRc
= (MRESULT
)TRUE
;
1267 SHORT nScxnew
= SHORT1FROMMP(lParam
); // New horizontal size.
1268 SHORT nScynew
= SHORT2FROMMP(lParam
); // New vertical size.
1270 lParam
= MRFROM2SHORT( nScxnew
- 20
1274 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1275 mRc
= (MRESULT
)FALSE
;
1278 case CM_QUERYDRAGIMAGE
:
1280 const wxIcon
& vIcon
= GetIcon();
1284 hIcon
= (HPOINTER
)::WinSendMsg(GetHWND(), WM_QUERYICON
, 0L, 0L);
1286 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1287 mRc
= (MRESULT
)hIcon
;
1288 bProcessed
= mRc
!= 0;
1294 mRc
= wxWindow::OS2WindowProc( uMessage
1298 return (MRESULT
)mRc
;
1299 } // wxFrame::OS2WindowProc
1301 void wxFrame::SetClient(WXHWND
WXUNUSED(c_Hwnd
))
1303 // Duh...nothing to do under OS/2
1306 void wxFrame::SetClient( wxWindow
* pWindow
)
1308 wxWindow
* pOldClient
= this->GetClient();
1309 bool bClientHasFocus
= pOldClient
&& (pOldClient
== wxWindow::FindFocus());
1311 if(pOldClient
== pWindow
) // nothing to do
1313 if(pWindow
== NULL
) // just need to remove old client
1315 if(pOldClient
== NULL
) // nothing to do
1318 if(bClientHasFocus
)
1321 pOldClient
->Enable( false );
1322 pOldClient
->Show( false );
1323 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1324 // to avoid OS/2 bug need to update frame
1325 ::WinSendMsg((HWND
)this->GetFrame(), WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1330 // Else need to change client
1335 ::WinEnableWindowUpdate((HWND
)GetHWND(), FALSE
);
1338 pOldClient
->Enable(false);
1339 pOldClient
->Show(false);
1340 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1342 pWindow
->Reparent(this);
1343 ::WinSetWindowUShort(pWindow
->GetHWND(), QWS_ID
, FID_CLIENT
);
1344 ::WinEnableWindowUpdate((HWND
)GetHWND(), TRUE
);
1346 pWindow
->Show(); // ensure client is showing
1347 if( this->IsShown() )
1350 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1354 wxWindow
* wxFrame::GetClient()
1356 return wxFindWinFromHandle((WXHWND
)::WinWindowFromID(m_hFrame
, FID_CLIENT
));
1359 void wxFrame::SendSizeEvent()
1363 RECTL vRect
= wxGetWindowRect(GetHwnd());
1365 ::WinPostMsg( GetHwnd()
1367 ,MPFROM2SHORT( vRect
.xRight
- vRect
.xLeft
1368 ,vRect
.xRight
- vRect
.xLeft
1370 ,MPFROM2SHORT( vRect
.yTop
- vRect
.yBottom
1371 ,vRect
.yTop
- vRect
.yBottom