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"
29 #include "wx/dialog.h"
30 #include "wx/settings.h"
31 #include "wx/dcclient.h"
35 #include "wx/os2/private.h"
38 #include "wx/statusbr.h"
39 #include "wx/generic/statusbr.h"
40 #endif // wxUSE_STATUSBAR
43 #include "wx/toolbar.h"
44 #endif // wxUSE_TOOLBAR
46 #include "wx/menuitem.h"
49 // ----------------------------------------------------------------------------
51 // ----------------------------------------------------------------------------
53 extern wxList WXDLLEXPORT wxPendingDelete
;
55 #if wxUSE_MENUS_NATIVE
56 extern wxMenu
*wxCurrentPopupMenu
;
59 // ----------------------------------------------------------------------------
61 // ----------------------------------------------------------------------------
63 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
64 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
67 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
69 // ============================================================================
71 // ============================================================================
73 // ----------------------------------------------------------------------------
74 // static class members
75 // ----------------------------------------------------------------------------
78 #if wxUSE_NATIVE_STATUSBAR
79 bool wxFrame::m_bUseNativeStatusBar
= true;
81 bool wxFrame::m_bUseNativeStatusBar
= false;
84 #endif //wxUSE_STATUSBAR
86 // ----------------------------------------------------------------------------
87 // creation/destruction
88 // ----------------------------------------------------------------------------
92 m_nFsStatusBarFields
= 0;
93 m_nFsStatusBarHeight
= 0;
94 m_nFsToolBarHeight
= 0;
96 m_bWasMinimized
= false;
99 m_frameMenuBar
= NULL
;
100 m_frameToolBar
= NULL
;
101 m_frameStatusBar
= NULL
;
103 m_hTitleBar
= NULLHANDLE
;
104 m_hHScroll
= NULLHANDLE
;
105 m_hVScroll
= NULLHANDLE
;
110 memset(&m_vSwpTitleBar
, 0, sizeof(SWP
));
111 memset(&m_vSwpMenuBar
, 0, sizeof(SWP
));
112 memset(&m_vSwpHScroll
, 0, sizeof(SWP
));
113 memset(&m_vSwpVScroll
, 0, sizeof(SWP
));
114 memset(&m_vSwpStatusBar
, 0, sizeof(SWP
));
115 memset(&m_vSwpToolBar
, 0, sizeof(SWP
));
118 } // end of wxFrame::Init
120 bool wxFrame::Create( wxWindow
* pParent
,
122 const wxString
& rsTitle
,
126 const wxString
& rsName
)
128 if (!wxTopLevelWindow::Create( pParent
138 } // end of wxFrame::Create
142 m_isBeingDeleted
= true;
144 } // end of wxFrame::~wxFrame
147 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
149 void wxFrame::DoGetClientSize(
154 wxTopLevelWindow::DoGetClientSize( pX
158 // No need to use statusbar code as in WIN32 as the FORMATFRAME
159 // window procedure ensures PM knows about the new frame client
160 // size internally. A ::WinQueryWindowRect (that is called in
161 // wxWindow's GetClient size from above) is all that is needed!
163 } // end of wxFrame::DoGetClientSize
166 // Set the client size (i.e. leave the calculation of borders etc.
169 void wxFrame::DoSetClientSize(
175 // Statusbars are not part of the OS/2 Client but parent frame
176 // so no statusbar consideration
178 wxTopLevelWindow::DoSetClientSize( nWidth
181 } // end of wxFrame::DoSetClientSize
183 // ----------------------------------------------------------------------------
184 // wxFrame: various geometry-related functions
185 // ----------------------------------------------------------------------------
187 void wxFrame::Raise()
189 wxFrameBase::Raise();
190 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
201 wxStatusBar
* wxFrame::OnCreateStatusBar(
205 , const wxString
& rName
208 wxStatusBar
* pStatusBar
= NULL
;
211 pStatusBar
= wxFrameBase::OnCreateStatusBar( nNumber
220 wxClientDC
vDC(pStatusBar
);
224 // Set the height according to the font and the border size
226 vDC
.SetFont(pStatusBar
->GetFont()); // Screws up the menues for some reason
227 vDC
.GetTextExtent( wxT("X")
232 int nHeight
= ((11 * nY
) / 10 + 2 * pStatusBar
->GetBorderY());
234 pStatusBar
->SetSize( wxDefaultCoord
240 ::WinSetParent( pStatusBar
->GetHWND(), m_hFrame
, FALSE
);
241 ::WinSetOwner( pStatusBar
->GetHWND(), m_hFrame
);
245 if(::WinIsWindowShowing(m_hFrame
))
246 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
249 } // end of wxFrame::OnCreateStatusBar
251 void wxFrame::PositionStatusBar()
258 // Native status bar positions itself
260 if (m_frameStatusBar
)
269 ::WinQueryWindowRect(m_hFrame
, &vRect
);
271 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
273 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
274 nWidth
= vRect
.xRight
- vRect
.xLeft
;
275 nY
= nY
- (vRect
.yBottom
- vFRect
.yBottom
);
277 m_frameStatusBar
->GetSize( &nStatbarWidth
281 nY
= nY
- nStatbarHeight
;
283 // Since we wish the status bar to be directly under the client area,
284 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
286 m_frameStatusBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
291 if (!::WinQueryWindowPos(m_frameStatusBar
->GetHWND(), &vSwp
))
293 vError
= ::WinGetLastError(vHabmain
);
294 sError
= wxPMErrorToStr(vError
);
295 wxLogError(_T("Error setting parent for StatusBar. Error: %s\n"), sError
.c_str());
299 } // end of wxFrame::PositionStatusBar
300 #endif // wxUSE_STATUSBAR
303 wxToolBar
* wxFrame::OnCreateToolBar( long lStyle
, wxWindowID vId
, const wxString
& rsName
)
305 wxToolBar
* pToolBar
= wxFrameBase::OnCreateToolBar( lStyle
310 ::WinSetParent( pToolBar
->GetHWND(), m_hFrame
, FALSE
);
311 ::WinSetOwner( pToolBar
->GetHWND(), m_hFrame
);
313 } // end of WinGuiBase_CFrame::OnCreateToolBar
316 #if wxUSE_MENUS_NATIVE
317 void wxFrame::DetachMenuBar()
321 m_frameMenuBar
->Detach();
322 m_frameMenuBar
= NULL
;
324 } // end of wxFrame::DetachMenuBar
326 void wxFrame::SetMenuBar(
337 // Actually remove the menu from the frame
339 m_hMenu
= (WXHMENU
)0;
340 InternalSetMenuBar();
342 else // set new non NULL menu bar
344 m_frameMenuBar
= NULL
;
347 // Can set a menubar several times.
348 // TODO: how to prevent a memory leak if you have a currently-unattached
349 // menubar? wxWidgets assumes that the frame will delete the menu (otherwise
350 // there are problems for MDI).
352 if (pMenuBar
->GetHMenu())
354 m_hMenu
= pMenuBar
->GetHMenu();
359 m_hMenu
= pMenuBar
->Create();
363 InternalSetMenuBar();
364 m_frameMenuBar
= pMenuBar
;
365 pMenuBar
->Attach((wxFrame
*)this);
367 } // end of wxFrame::SetMenuBar
369 void wxFrame::AttachMenuBar(
373 wxFrameBase::AttachMenuBar(pMenubar
);
375 m_frameMenuBar
= pMenubar
;
380 // Actually remove the menu from the frame
382 m_hMenu
= (WXHMENU
)0;
383 InternalSetMenuBar();
385 else // Set new non NULL menu bar
388 // Can set a menubar several times.
390 if (pMenubar
->GetHMenu())
392 m_hMenu
= pMenubar
->GetHMenu();
396 if (pMenubar
->IsAttached())
399 m_hMenu
= pMenubar
->Create();
404 InternalSetMenuBar();
406 } // end of wxFrame::AttachMenuBar
408 void wxFrame::InternalSetMenuBar()
413 // Set the parent and owner of the menubar to be the frame
415 if (!::WinSetParent(m_hMenu
, m_hFrame
, FALSE
))
417 vError
= ::WinGetLastError(vHabmain
);
418 sError
= wxPMErrorToStr(vError
);
419 wxLogError(_T("Error setting parent for submenu. Error: %s\n"), sError
.c_str());
422 if (!::WinSetOwner(m_hMenu
, m_hFrame
))
424 vError
= ::WinGetLastError(vHabmain
);
425 sError
= wxPMErrorToStr(vError
);
426 wxLogError(_T("Error setting parent for submenu. Error: %s\n"), sError
.c_str());
428 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
429 } // end of wxFrame::InternalSetMenuBar
430 #endif // wxUSE_MENUS_NATIVE
433 // Responds to colour changes, and passes event on to children
435 void wxFrame::OnSysColourChanged(
436 wxSysColourChangedEvent
& rEvent
439 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
443 if (m_frameStatusBar
)
445 wxSysColourChangedEvent vEvent2
;
447 vEvent2
.SetEventObject(m_frameStatusBar
);
448 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
450 #endif //wxUSE_STATUSBAR
453 // Propagate the event to the non-top-level children
455 wxWindow::OnSysColourChanged(rEvent
);
456 } // end of wxFrame::OnSysColourChanged
458 // Pass true to show full screen, false to restore.
459 bool wxFrame::ShowFullScreen( bool bShow
, long lStyle
)
466 m_bFsIsShowing
= true;
470 wxToolBar
* pTheToolBar
= GetToolBar();
471 #endif //wxUSE_TOOLBAR
474 wxStatusBar
* pTheStatusBar
= GetStatusBar();
475 #endif //wxUSE_STATUSBAR
481 pTheToolBar
->GetSize(&nDummyWidth
, &m_nFsToolBarHeight
);
482 #endif //wxUSE_TOOLBAR
486 pTheStatusBar
->GetSize(&nDummyWidth
, &m_nFsStatusBarHeight
);
487 #endif //wxUSE_STATUSBAR
491 // Zap the toolbar, menubar, and statusbar
493 if ((lStyle
& wxFULLSCREEN_NOTOOLBAR
) && pTheToolBar
)
495 pTheToolBar
->SetSize(wxDefaultCoord
,0);
496 pTheToolBar
->Show(false);
498 #endif //wxUSE_TOOLBAR
500 if (lStyle
& wxFULLSCREEN_NOMENUBAR
)
502 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
503 ::WinSetOwner(m_hMenu
, m_hFrame
);
504 ::WinSendMsg((HWND
)m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
509 // Save the number of fields in the statusbar
511 if ((lStyle
& wxFULLSCREEN_NOSTATUSBAR
) && pTheStatusBar
)
513 m_nFsStatusBarFields
= pTheStatusBar
->GetFieldsCount();
514 SetStatusBar((wxStatusBar
*) NULL
);
515 delete pTheStatusBar
;
518 m_nFsStatusBarFields
= 0;
519 #endif //wxUSE_STATUSBAR
522 // Zap the frame borders
526 // Save the 'normal' window style
528 m_lFsOldWindowStyle
= ::WinQueryWindowULong(m_hFrame
, QWL_STYLE
);
531 // Save the old position, width & height, maximize state
533 m_vFsOldSize
= GetRect();
534 m_bFsIsMaximized
= IsMaximized();
537 // Decide which window style flags to turn off
539 LONG lNewStyle
= m_lFsOldWindowStyle
;
542 if (lStyle
& wxFULLSCREEN_NOBORDER
)
543 lOffFlags
|= FCF_BORDER
;
544 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
545 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
547 lNewStyle
&= (~lOffFlags
);
550 // Change our window style to be compatible with full-screen mode
552 ::WinSetWindowULong((HWND
)m_hFrame
, QWL_STYLE
, (ULONG
)lNewStyle
);
555 // Resize to the size of the desktop
561 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
562 nWidth
= vRect
.xRight
- vRect
.xLeft
;
564 // Remember OS/2 is backwards!
566 nHeight
= vRect
.yTop
- vRect
.yBottom
;
568 SetSize( nWidth
, nHeight
);
571 // Now flush the window style cache and actually go full-screen
573 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
582 wxSize
sz( nWidth
, nHeight
);
583 wxSizeEvent
vEvent( sz
, GetId() );
585 GetEventHandler()->ProcessEvent(vEvent
);
593 m_bFsIsShowing
= false;
596 wxToolBar
* pTheToolBar
= GetToolBar();
599 // Restore the toolbar, menubar, and statusbar
601 if (pTheToolBar
&& (m_lFsStyle
& wxFULLSCREEN_NOTOOLBAR
))
603 pTheToolBar
->SetSize(wxDefaultCoord
, m_nFsToolBarHeight
);
604 pTheToolBar
->Show(true);
606 #endif //wxUSE_TOOLBAR
609 if ((m_lFsStyle
& wxFULLSCREEN_NOSTATUSBAR
) && (m_nFsStatusBarFields
> 0))
611 CreateStatusBar(m_nFsStatusBarFields
);
612 // PositionStatusBar();
614 #endif //wxUSE_STATUSBAR
616 if ((m_lFsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
618 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
619 ::WinSetOwner(m_hMenu
, m_hFrame
);
620 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
622 Maximize(m_bFsIsMaximized
);
624 ::WinSetWindowULong( m_hFrame
626 ,(ULONG
)m_lFsOldWindowStyle
628 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
637 return wxFrameBase::ShowFullScreen(bShow
, lStyle
);
638 } // end of wxFrame::ShowFullScreen
643 // ----------------------------------------------------------------------------
644 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
645 // from the client area, so the client area is what's really available for the
647 // ----------------------------------------------------------------------------
649 // Checks if there is a toolbar, and returns the first free client position
650 wxPoint
wxFrame::GetClientAreaOrigin() const
652 wxPoint vPoint
= wxTopLevelWindow::GetClientAreaOrigin();
655 // In OS/2 the toolbar and statusbar are frame extensions so there is no
656 // adjustment. The client is supposedly resized for a toolbar in OS/2
657 // as it is for the status bar.
660 } // end of wxFrame::GetClientAreaOrigin
662 // ----------------------------------------------------------------------------
663 // tool/status bar stuff
664 // ----------------------------------------------------------------------------
668 wxToolBar
* wxFrame::CreateToolBar(
671 , const wxString
& rName
674 if (wxFrameBase::CreateToolBar( lStyle
681 return m_frameToolBar
;
682 } // end of wxFrame::CreateToolBar
684 void wxFrame::PositionToolBar()
686 wxToolBar
* pToolBar
= GetToolBar();
699 ::WinQueryWindowRect(m_hFrame
, &vRect
);
700 vPos
.y
= (wxCoord
)vRect
.yTop
;
701 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
703 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
705 vPos
.y
= (wxCoord
)(vFRect
.yTop
- vRect
.yTop
);
706 pToolBar
->GetSize( &vTWidth
710 if (pToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
712 vWidth
= (wxCoord
)(vRect
.xRight
- vRect
.xLeft
);
713 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
722 wxCoord vSheight
= 0;
724 if (m_frameStatusBar
)
725 m_frameStatusBar
->GetSize( &vSwidth
728 vHeight
= (wxCoord
)(vRect
.yTop
- vRect
.yBottom
);
729 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
735 if( ::WinIsWindowShowing(m_hFrame
) )
736 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
737 } // end of wxFrame::PositionToolBar
738 #endif // wxUSE_TOOLBAR
740 // ----------------------------------------------------------------------------
741 // frame state (iconized/maximized/...)
742 // ----------------------------------------------------------------------------
745 // propagate our state change to all child frames: this allows us to emulate X
746 // Windows behaviour where child frames float independently of the parent one
747 // on the desktop, but are iconized/restored with it
749 void wxFrame::IconizeChildFrames( bool WXUNUSED(bIconize
) )
751 // FIXME: Generic MDI does not use Frames for the Childs, so this does _not_
752 // work. Possibly, the right thing is simply to eliminate this
753 // functions and all the calls to it from within this file.
755 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
757 pNode
= pNode
->GetNext() )
759 wxWindow
* pWin
= pNode
->GetData();
760 wxFrame
* pFrame
= wxDynamicCast(pWin
, wxFrame
);
763 #if wxUSE_MDI_ARCHITECTURE
764 && !wxDynamicCast(pFrame
, wxMDIChildFrame
)
765 #endif // wxUSE_MDI_ARCHITECTURE
769 // We don't want to restore the child frames which had been
770 // iconized even before we were iconized, so save the child frame
771 // status when iconizing the parent frame and check it when
776 pFrame
->m_bWasMinimized
= pFrame
->IsIconized();
780 // This test works for both iconizing and restoring
782 if (!pFrame
->m_bWasMinimized
)
783 pFrame
->Iconize(bIconize
);
787 } // end of wxFrame::IconizeChildFrames
789 WXHICON
wxFrame::GetDefaultIcon() const
791 return (WXHICON
)(wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
792 : wxDEFAULT_FRAME_ICON
);
794 // ===========================================================================
795 // message processing
796 // ===========================================================================
798 // ---------------------------------------------------------------------------
800 // ---------------------------------------------------------------------------
801 bool wxFrame::OS2TranslateMessage( WXMSG
* pMsg
)
804 // try the menu bar accels
806 wxMenuBar
* pMenuBar
= GetMenuBar();
811 #if wxUSE_ACCEL && wxUSE_MENUS_NATIVE
812 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
813 return rAcceleratorTable
.Translate(GetHWND(), pMsg
);
817 } // end of wxFrame::OS2TranslateMessage
819 // ---------------------------------------------------------------------------
820 // our private (non virtual) message handlers
821 // ---------------------------------------------------------------------------
822 bool wxFrame::HandlePaint()
826 if (::WinQueryUpdateRect(GetHWND(), &vRect
))
831 // Icons in PM are the same as "pointers"
833 const wxIcon
& vIcon
= GetIcon();
837 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
839 hIcon
= (HPOINTER
)m_hDefaultIcon
;
842 // Hold a pointer to the dc so long as the OnPaint() message
843 // is being processed
846 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
849 // Erase background before painting or we get white background
851 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
857 ::WinQueryWindowRect(GetHwnd(), &vRect3
);
859 static const int nIconWidth
= 32;
860 static const int nIconHeight
= 32;
861 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
862 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
864 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
870 if (!wxWindow::HandlePaint())
875 hPS
= ::WinBeginPaint( GetHwnd()
881 ::GpiCreateLogColorTable( hPS
885 ,(LONG
)wxTheColourDatabase
->m_nSize
886 ,(PLONG
)wxTheColourDatabase
->m_palTable
888 ::GpiCreateLogColorTable( hPS
898 ,GetBackgroundColour().GetPixel()
907 } // end of wxFrame::HandlePaint
909 bool wxFrame::HandleSize( int nX
, int nY
, WXUINT nId
)
911 bool bProcessed
= false;
917 // Only do it it if we were iconized before, otherwise resizing the
918 // parent frame has a curious side effect of bringing it under it's
924 // restore all child frames too
926 IconizeChildFrames(false);
927 (void)SendIconizeEvent(false);
939 // Iconize all child frames too
941 IconizeChildFrames(true);
942 (void)SendIconizeEvent();
950 // forward WM_SIZE to status bar control
952 #if wxUSE_NATIVE_STATUSBAR
953 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
955 wxSizeEvent
vEvent( wxSize( nX
958 ,m_frameStatusBar
->GetId()
961 vEvent
.SetEventObject(m_frameStatusBar
);
962 m_frameStatusBar
->OnSize(vEvent
);
964 #endif // wxUSE_NATIVE_STATUSBAR
969 #endif // wxUSE_TOOLBAR
971 bProcessed
= wxWindow::HandleSize( nX
977 } // end of wxFrame::HandleSize
979 bool wxFrame::HandleCommand( WXWORD nId
,
986 // In case it's e.g. a toolbar.
988 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
991 return pWin
->OS2Command( nCmd
, nId
);
995 // Handle here commands from menus and accelerators
997 if (nCmd
== CMDSRC_MENU
|| nCmd
== CMDSRC_ACCELERATOR
)
999 #if wxUSE_MENUS_NATIVE
1000 if (wxCurrentPopupMenu
)
1002 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1004 wxCurrentPopupMenu
= NULL
;
1006 return pPopupMenu
->OS2Command( nCmd
, nId
);
1010 if (ProcessCommand(nId
))
1016 } // end of wxFrame::HandleCommand
1018 bool wxFrame::HandleMenuSelect( WXWORD nItem
,
1027 rc
= ::WinSendMsg(hMenu
, MM_QUERYITEM
, MPFROM2SHORT(nItem
, TRUE
), (MPARAM
)&mItem
);
1029 if(rc
&& !(mItem
.afStyle
& (MIS_SUBMENU
| MIS_SEPARATOR
)))
1031 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nItem
);
1033 vEvent
.SetEventObject(this);
1034 GetEventHandler()->ProcessEvent(vEvent
); // return value would be ignored by PM
1038 DoGiveHelp(wxEmptyString
, false);
1043 } // end of wxFrame::HandleMenuSelect
1045 // ---------------------------------------------------------------------------
1046 // Main Frame window proc
1047 // ---------------------------------------------------------------------------
1048 MRESULT EXPENTRY
wxFrameMainWndProc( HWND hWnd
,
1053 MRESULT rc
= (MRESULT
)0;
1054 bool bProcessed
= false;
1055 wxFrame
* pWnd
= NULL
;
1057 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1060 case WM_QUERYFRAMECTLCOUNT
:
1061 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1063 USHORT uItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1065 rc
= MRFROMSHORT(uItemCount
);
1069 case WM_FORMATFRAME
:
1070 /////////////////////////////////////////////////////////////////////////////////
1071 // Applications that subclass frame controls may find that the frame is already
1072 // subclassed the number of frame controls is variable.
1073 // The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
1074 // subclassed by calling the previous window procedure and modifying its result.
1075 ////////////////////////////////////////////////////////////////////////////////
1087 pSWP
= (PSWP
)PVOIDFROMMP(wParam
);
1088 nItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1089 if(pWnd
->m_frameStatusBar
)
1091 ::WinQueryWindowRect(pWnd
->m_frameStatusBar
->GetHWND(), &vRstb
);
1092 pWnd
->m_frameStatusBar
->GetSize(NULL
, &nHeight
);
1094 if(pWnd
->m_frameToolBar
)
1096 ::WinQueryWindowRect(pWnd
->m_frameToolBar
->GetHWND(), &vRtlb
);
1097 pWnd
->m_frameToolBar
->GetSize(&nWidth
, &nHeight2
);
1099 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1100 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1101 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1102 ::WinMapWindowPoints(HWND_DESKTOP
, pWnd
->m_hFrame
, (PPOINTL
)&vRectl
, 2);
1103 for(i
= 0; i
< nItemCount
; i
++)
1105 if(pWnd
->m_hWnd
&& pSWP
[i
].hwnd
== pWnd
->m_hWnd
)
1107 if (pWnd
->m_frameToolBar
&& pWnd
->m_frameToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
1109 pSWP
[i
].x
= vRectl
.xLeft
;
1110 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1111 pSWP
[i
].cx
= vRectl
.xRight
- vRectl
.xLeft
;
1112 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- (nHeight
+ nHeight2
);
1116 pSWP
[i
].x
= vRectl
.xLeft
+ nWidth
;
1117 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1118 pSWP
[i
].cx
= vRectl
.xRight
- (vRectl
.xLeft
+ nWidth
);
1119 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- nHeight
;
1121 pSWP
[i
].fl
= SWP_SIZE
| SWP_MOVE
| SWP_SHOW
;
1122 pSWP
[i
].hwndInsertBehind
= HWND_TOP
;
1126 rc
= MRFROMSHORT(nItemCount
);
1131 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1132 rc
= pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
);
1134 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1137 } // end of wxFrameMainWndProc
1139 MRESULT EXPENTRY
wxFrameWndProc(
1147 // Trace all ulMsgs - useful for the debugging
1150 wxFrame
* pWnd
= NULL
;
1152 parentHwnd
= WinQueryWindow(hWnd
,QW_PARENT
);
1153 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1156 // When we get the first message for the HWND we just created, we associate
1157 // it with wxWindow stored in wxWndHook
1160 MRESULT rc
= (MRESULT
)0;
1163 // Stop right here if we don't have a valid handle in our wxWindow object.
1165 if (pWnd
&& !pWnd
->GetHWND())
1167 pWnd
->SetHWND((WXHWND
) hWnd
);
1168 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
1174 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
1176 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1179 } // end of wxFrameWndProc
1181 MRESULT
wxFrame::OS2WindowProc( WXUINT uMessage
,
1186 bool bProcessed
= false;
1192 // If we can't close, tell the system that we processed the
1193 // message - otherwise it would close us
1195 bProcessed
= !Close();
1199 bProcessed
= HandlePaint();
1200 mRc
= (MRESULT
)FALSE
;
1203 case WM_ERASEBACKGROUND
:
1205 // Returning TRUE to requests PM to paint the window background
1206 // in SYSCLR_WINDOW. We capture this here because the PS returned
1207 // in Frames is the PS for the whole frame, which we can't really
1208 // use at all. If you want to paint a different background, do it
1209 // in an OnPaint using a wxPaintDC.
1211 mRc
= (MRESULT
)(TRUE
);
1220 UnpackCommand( (WXWPARAM
)wParam
1227 bProcessed
= HandleCommand( wId
1240 UnpackMenuSelect( wParam
1246 bProcessed
= HandleMenuSelect( wItem
1250 mRc
= (MRESULT
)TRUE
;
1256 SHORT nScxnew
= SHORT1FROMMP(lParam
); // New horizontal size.
1257 SHORT nScynew
= SHORT2FROMMP(lParam
); // New vertical size.
1259 lParam
= MRFROM2SHORT( nScxnew
- 20
1263 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1264 mRc
= (MRESULT
)FALSE
;
1267 case CM_QUERYDRAGIMAGE
:
1269 const wxIcon
& vIcon
= GetIcon();
1273 hIcon
= (HPOINTER
)::WinSendMsg(GetHWND(), WM_QUERYICON
, 0L, 0L);
1275 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1276 mRc
= (MRESULT
)hIcon
;
1277 bProcessed
= mRc
!= 0;
1283 mRc
= wxWindow::OS2WindowProc( uMessage
1287 return (MRESULT
)mRc
;
1288 } // wxFrame::OS2WindowProc
1290 void wxFrame::SetClient(WXHWND
WXUNUSED(c_Hwnd
))
1292 // Duh...nothing to do under OS/2
1295 void wxFrame::SetClient( wxWindow
* pWindow
)
1297 wxWindow
* pOldClient
= this->GetClient();
1298 bool bClientHasFocus
= pOldClient
&& (pOldClient
== wxWindow::FindFocus());
1300 if(pOldClient
== pWindow
) // nothing to do
1302 if(pWindow
== NULL
) // just need to remove old client
1304 if(pOldClient
== NULL
) // nothing to do
1307 if(bClientHasFocus
)
1310 pOldClient
->Enable( false );
1311 pOldClient
->Show( false );
1312 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1313 // to avoid OS/2 bug need to update frame
1314 ::WinSendMsg((HWND
)this->GetFrame(), WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1319 // Else need to change client
1324 ::WinEnableWindowUpdate((HWND
)GetHWND(), FALSE
);
1327 pOldClient
->Enable(false);
1328 pOldClient
->Show(false);
1329 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1331 pWindow
->Reparent(this);
1332 ::WinSetWindowUShort(pWindow
->GetHWND(), QWS_ID
, FID_CLIENT
);
1333 ::WinEnableWindowUpdate((HWND
)GetHWND(), TRUE
);
1335 pWindow
->Show(); // ensure client is showing
1336 if( this->IsShown() )
1339 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1343 wxWindow
* wxFrame::GetClient()
1345 return wxFindWinFromHandle((WXHWND
)::WinWindowFromID(m_hFrame
, FID_CLIENT
));
1348 void wxFrame::SendSizeEvent()
1352 RECTL vRect
= wxGetWindowRect(GetHwnd());
1354 ::WinPostMsg( GetHwnd()
1356 ,MPFROM2SHORT( vRect
.xRight
- vRect
.xLeft
1357 ,vRect
.xRight
- vRect
.xLeft
1359 ,MPFROM2SHORT( vRect
.yTop
- vRect
.yBottom
1360 ,vRect
.yTop
- vRect
.yBottom