1 /////////////////////////////////////////////////////////////////////////////
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
17 #include "wx/object.h"
18 #include "wx/dynarray.h"
21 #include "wx/string.h"
30 #include "wx/dialog.h"
31 #include "wx/settings.h"
32 #include "wx/dcclient.h"
36 #include "wx/os2/private.h"
39 #include "wx/statusbr.h"
40 #include "wx/generic/statusbr.h"
41 #endif // wxUSE_STATUSBAR
44 #include "wx/toolbar.h"
45 #endif // wxUSE_TOOLBAR
47 #include "wx/menuitem.h"
50 // ----------------------------------------------------------------------------
52 // ----------------------------------------------------------------------------
54 extern wxList WXDLLEXPORT wxPendingDelete
;
56 #if wxUSE_MENUS_NATIVE
57 extern wxMenu
*wxCurrentPopupMenu
;
60 extern void wxAssociateWinWithHandle( HWND hWnd
64 // ----------------------------------------------------------------------------
66 // ----------------------------------------------------------------------------
68 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
69 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
72 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
74 // ============================================================================
76 // ============================================================================
78 // ----------------------------------------------------------------------------
79 // static class members
80 // ----------------------------------------------------------------------------
83 #if wxUSE_NATIVE_STATUSBAR
84 bool wxFrame::m_bUseNativeStatusBar
= true;
86 bool wxFrame::m_bUseNativeStatusBar
= false;
89 #endif //wxUSE_STATUSBAR
91 // ----------------------------------------------------------------------------
92 // creation/destruction
93 // ----------------------------------------------------------------------------
97 m_nFsStatusBarFields
= 0;
98 m_nFsStatusBarHeight
= 0;
99 m_nFsToolBarHeight
= 0;
101 m_bWasMinimized
= false;
104 m_frameMenuBar
= NULL
;
105 m_frameToolBar
= NULL
;
106 m_frameStatusBar
= NULL
;
108 m_hTitleBar
= NULLHANDLE
;
109 m_hHScroll
= NULLHANDLE
;
110 m_hVScroll
= NULLHANDLE
;
115 memset(&m_vSwpTitleBar
, 0, sizeof(SWP
));
116 memset(&m_vSwpMenuBar
, 0, sizeof(SWP
));
117 memset(&m_vSwpHScroll
, 0, sizeof(SWP
));
118 memset(&m_vSwpVScroll
, 0, sizeof(SWP
));
119 memset(&m_vSwpStatusBar
, 0, sizeof(SWP
));
120 memset(&m_vSwpToolBar
, 0, sizeof(SWP
));
123 } // end of wxFrame::Init
125 bool wxFrame::Create( wxWindow
* pParent
,
127 const wxString
& rsTitle
,
131 const wxString
& rsName
)
133 if (!wxTopLevelWindow::Create( pParent
143 } // end of wxFrame::Create
147 m_isBeingDeleted
= true;
149 } // end of wxFrame::~wxFrame
152 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
154 void wxFrame::DoGetClientSize(
159 wxTopLevelWindow::DoGetClientSize( pX
163 // No need to use statusbar code as in WIN32 as the FORMATFRAME
164 // window procedure ensures PM knows about the new frame client
165 // size internally. A ::WinQueryWindowRect (that is called in
166 // wxWindow's GetClient size from above) is all that is needed!
168 } // end of wxFrame::DoGetClientSize
171 // Set the client size (i.e. leave the calculation of borders etc.
174 void wxFrame::DoSetClientSize(
180 // Statusbars are not part of the OS/2 Client but parent frame
181 // so no statusbar consideration
183 wxTopLevelWindow::DoSetClientSize( nWidth
186 } // end of wxFrame::DoSetClientSize
188 // ----------------------------------------------------------------------------
189 // wxFrame: various geometry-related functions
190 // ----------------------------------------------------------------------------
192 void wxFrame::Raise()
194 wxFrameBase::Raise();
195 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
206 wxStatusBar
* wxFrame::OnCreateStatusBar(
210 , const wxString
& rName
213 wxStatusBar
* pStatusBar
= NULL
;
216 pStatusBar
= wxFrameBase::OnCreateStatusBar( nNumber
225 wxClientDC
vDC(pStatusBar
);
229 // Set the height according to the font and the border size
231 vDC
.SetFont(pStatusBar
->GetFont()); // Screws up the menues for some reason
232 vDC
.GetTextExtent( wxT("X")
237 int nHeight
= ((11 * nY
) / 10 + 2 * pStatusBar
->GetBorderY());
239 pStatusBar
->SetSize( wxDefaultCoord
245 ::WinSetParent( pStatusBar
->GetHWND()
249 ::WinSetOwner( pStatusBar
->GetHWND()
255 if(::WinIsWindowShowing(m_hFrame
))
256 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
259 } // end of wxFrame::OnCreateStatusBar
261 void wxFrame::PositionStatusBar()
268 // Native status bar positions itself
270 if (m_frameStatusBar
)
279 ::WinQueryWindowRect(m_hFrame
, &vRect
);
281 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
283 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
284 nWidth
= vRect
.xRight
- vRect
.xLeft
;
285 nY
= nY
- (vRect
.yBottom
- vFRect
.yBottom
);
287 m_frameStatusBar
->GetSize( &nStatbarWidth
291 nY
= nY
- nStatbarHeight
;
293 // Since we wish the status bar to be directly under the client area,
294 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
296 m_frameStatusBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
301 if (!::WinQueryWindowPos(m_frameStatusBar
->GetHWND(), &vSwp
))
303 vError
= ::WinGetLastError(vHabmain
);
304 sError
= wxPMErrorToStr(vError
);
305 wxLogError(_T("Error setting parent for StautsBar. Error: %s\n"), sError
.c_str());
309 } // end of wxFrame::PositionStatusBar
310 #endif // wxUSE_STATUSBAR
313 wxToolBar
* wxFrame::OnCreateToolBar(
316 , const wxString
& rsName
319 wxToolBar
* pToolBar
= wxFrameBase::OnCreateToolBar( lStyle
324 ::WinSetParent( pToolBar
->GetHWND()
328 ::WinSetOwner( pToolBar
->GetHWND()
332 } // end of WinGuiBase_CFrame::OnCreateToolBar
335 #if wxUSE_MENUS_NATIVE
336 void wxFrame::DetachMenuBar()
340 m_frameMenuBar
->Detach();
341 m_frameMenuBar
= NULL
;
343 } // end of wxFrame::DetachMenuBar
345 void wxFrame::SetMenuBar(
356 // Actually remove the menu from the frame
358 m_hMenu
= (WXHMENU
)0;
359 InternalSetMenuBar();
361 else // set new non NULL menu bar
363 m_frameMenuBar
= NULL
;
366 // Can set a menubar several times.
367 // TODO: how to prevent a memory leak if you have a currently-unattached
368 // menubar? wxWidgets assumes that the frame will delete the menu (otherwise
369 // there are problems for MDI).
371 if (pMenuBar
->GetHMenu())
373 m_hMenu
= pMenuBar
->GetHMenu();
378 m_hMenu
= pMenuBar
->Create();
382 InternalSetMenuBar();
383 m_frameMenuBar
= pMenuBar
;
384 pMenuBar
->Attach((wxFrame
*)this);
386 } // end of wxFrame::SetMenuBar
388 void wxFrame::AttachMenuBar(
392 wxFrameBase::AttachMenuBar(pMenubar
);
394 m_frameMenuBar
= pMenubar
;
399 // Actually remove the menu from the frame
401 m_hMenu
= (WXHMENU
)0;
402 InternalSetMenuBar();
404 else // Set new non NULL menu bar
407 // Can set a menubar several times.
409 if (pMenubar
->GetHMenu())
411 m_hMenu
= pMenubar
->GetHMenu();
415 if (pMenubar
->IsAttached())
418 m_hMenu
= pMenubar
->Create();
423 InternalSetMenuBar();
425 } // end of wxFrame::AttachMenuBar
427 void wxFrame::InternalSetMenuBar()
432 // Set the parent and owner of the menubar to be the frame
434 if (!::WinSetParent(m_hMenu
, m_hFrame
, FALSE
))
436 vError
= ::WinGetLastError(vHabmain
);
437 sError
= wxPMErrorToStr(vError
);
438 wxLogError(_T("Error setting parent for submenu. Error: %s\n"), sError
.c_str());
441 if (!::WinSetOwner(m_hMenu
, m_hFrame
))
443 vError
= ::WinGetLastError(vHabmain
);
444 sError
= wxPMErrorToStr(vError
);
445 wxLogError(_T("Error setting parent for submenu. Error: %s\n"), sError
.c_str());
447 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
448 } // end of wxFrame::InternalSetMenuBar
449 #endif // wxUSE_MENUS_NATIVE
452 // Responds to colour changes, and passes event on to children
454 void wxFrame::OnSysColourChanged(
455 wxSysColourChangedEvent
& rEvent
458 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
462 if (m_frameStatusBar
)
464 wxSysColourChangedEvent vEvent2
;
466 vEvent2
.SetEventObject(m_frameStatusBar
);
467 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
469 #endif //wxUSE_STATUSBAR
472 // Propagate the event to the non-top-level children
474 wxWindow::OnSysColourChanged(rEvent
);
475 } // end of wxFrame::OnSysColourChanged
477 // Pass true to show full screen, false to restore.
478 bool wxFrame::ShowFullScreen( bool bShow
, long lStyle
)
485 m_bFsIsShowing
= true;
489 wxToolBar
* pTheToolBar
= GetToolBar();
490 #endif //wxUSE_TOOLBAR
493 wxStatusBar
* pTheStatusBar
= GetStatusBar();
494 #endif //wxUSE_STATUSBAR
500 pTheToolBar
->GetSize(&nDummyWidth
, &m_nFsToolBarHeight
);
501 #endif //wxUSE_TOOLBAR
505 pTheStatusBar
->GetSize(&nDummyWidth
, &m_nFsStatusBarHeight
);
506 #endif //wxUSE_STATUSBAR
510 // Zap the toolbar, menubar, and statusbar
512 if ((lStyle
& wxFULLSCREEN_NOTOOLBAR
) && pTheToolBar
)
514 pTheToolBar
->SetSize(wxDefaultCoord
,0);
515 pTheToolBar
->Show(false);
517 #endif //wxUSE_TOOLBAR
519 if (lStyle
& wxFULLSCREEN_NOMENUBAR
)
521 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
522 ::WinSetOwner(m_hMenu
, m_hFrame
);
523 ::WinSendMsg((HWND
)m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
528 // Save the number of fields in the statusbar
530 if ((lStyle
& wxFULLSCREEN_NOSTATUSBAR
) && pTheStatusBar
)
532 m_nFsStatusBarFields
= pTheStatusBar
->GetFieldsCount();
533 SetStatusBar((wxStatusBar
*) NULL
);
534 delete pTheStatusBar
;
537 m_nFsStatusBarFields
= 0;
538 #endif //wxUSE_STATUSBAR
541 // Zap the frame borders
545 // Save the 'normal' window style
547 m_lFsOldWindowStyle
= ::WinQueryWindowULong(m_hFrame
, QWL_STYLE
);
550 // Save the old position, width & height, maximize state
552 m_vFsOldSize
= GetRect();
553 m_bFsIsMaximized
= IsMaximized();
556 // Decide which window style flags to turn off
558 LONG lNewStyle
= m_lFsOldWindowStyle
;
561 if (lStyle
& wxFULLSCREEN_NOBORDER
)
562 lOffFlags
|= FCF_BORDER
;
563 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
564 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
566 lNewStyle
&= (~lOffFlags
);
569 // Change our window style to be compatible with full-screen mode
571 ::WinSetWindowULong((HWND
)m_hFrame
, QWL_STYLE
, (ULONG
)lNewStyle
);
574 // Resize to the size of the desktop
580 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
581 nWidth
= vRect
.xRight
- vRect
.xLeft
;
583 // Rmember OS/2 is backwards!
585 nHeight
= vRect
.yTop
- vRect
.yBottom
;
587 SetSize( nWidth
, nHeight
);
590 // Now flush the window style cache and actually go full-screen
592 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
601 wxSize
sz( nWidth
, nHeight
);
602 wxSizeEvent
vEvent( sz
, GetId() );
604 GetEventHandler()->ProcessEvent(vEvent
);
612 m_bFsIsShowing
= false;
615 wxToolBar
* pTheToolBar
= GetToolBar();
618 // Restore the toolbar, menubar, and statusbar
620 if (pTheToolBar
&& (m_lFsStyle
& wxFULLSCREEN_NOTOOLBAR
))
622 pTheToolBar
->SetSize(wxDefaultCoord
, m_nFsToolBarHeight
);
623 pTheToolBar
->Show(true);
625 #endif //wxUSE_TOOLBAR
628 if ((m_lFsStyle
& wxFULLSCREEN_NOSTATUSBAR
) && (m_nFsStatusBarFields
> 0))
630 CreateStatusBar(m_nFsStatusBarFields
);
631 // PositionStatusBar();
633 #endif //wxUSE_STATUSBAR
635 if ((m_lFsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
637 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
638 ::WinSetOwner(m_hMenu
, m_hFrame
);
639 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
641 Maximize(m_bFsIsMaximized
);
643 ::WinSetWindowULong( m_hFrame
645 ,(ULONG
)m_lFsOldWindowStyle
647 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
656 return wxFrameBase::ShowFullScreen(bShow
, lStyle
);
657 } // end of wxFrame::ShowFullScreen
662 // ----------------------------------------------------------------------------
663 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
664 // from the client area, so the client area is what's really available for the
666 // ----------------------------------------------------------------------------
668 // Checks if there is a toolbar, and returns the first free client position
669 wxPoint
wxFrame::GetClientAreaOrigin() const
671 wxPoint vPoint
= wxTopLevelWindow::GetClientAreaOrigin();
674 // In OS/2 the toolbar and statusbar are frame extensions so there is no
675 // adjustment. The client is supposedly resized for a toolbar in OS/2
676 // as it is for the status bar.
679 } // end of wxFrame::GetClientAreaOrigin
681 // ----------------------------------------------------------------------------
682 // tool/status bar stuff
683 // ----------------------------------------------------------------------------
687 wxToolBar
* wxFrame::CreateToolBar(
690 , const wxString
& rName
693 if (wxFrameBase::CreateToolBar( lStyle
700 return m_frameToolBar
;
701 } // end of wxFrame::CreateToolBar
703 void wxFrame::PositionToolBar()
705 wxToolBar
* pToolBar
= GetToolBar();
718 ::WinQueryWindowRect(m_hFrame
, &vRect
);
719 vPos
.y
= (wxCoord
)vRect
.yTop
;
720 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
722 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
724 vPos
.y
= (wxCoord
)(vFRect
.yTop
- vRect
.yTop
);
725 pToolBar
->GetSize( &vTWidth
729 if (pToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
731 vWidth
= (wxCoord
)(vRect
.xRight
- vRect
.xLeft
);
732 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
741 wxCoord vSheight
= 0;
743 if (m_frameStatusBar
)
744 m_frameStatusBar
->GetSize( &vSwidth
747 vHeight
= (wxCoord
)(vRect
.yTop
- vRect
.yBottom
);
748 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
754 if( ::WinIsWindowShowing(m_hFrame
) )
755 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
756 } // end of wxFrame::PositionToolBar
757 #endif // wxUSE_TOOLBAR
759 // ----------------------------------------------------------------------------
760 // frame state (iconized/maximized/...)
761 // ----------------------------------------------------------------------------
764 // propagate our state change to all child frames: this allows us to emulate X
765 // Windows behaviour where child frames float independently of the parent one
766 // on the desktop, but are iconized/restored with it
768 void wxFrame::IconizeChildFrames( bool WXUNUSED(bIconize
) )
770 // FIXME: Generic MDI does not use Frames for the Childs, so this does _not_
771 // work. Possibly, the right thing is simply to eliminate this
772 // functions and all the calls to it from within this file.
774 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
776 pNode
= pNode
->GetNext() )
778 wxWindow
* pWin
= pNode
->GetData();
779 wxFrame
* pFrame
= wxDynamicCast(pWin
, wxFrame
);
782 #if wxUSE_MDI_ARCHITECTURE
783 && !wxDynamicCast(pFrame
, wxMDIChildFrame
)
784 #endif // wxUSE_MDI_ARCHITECTURE
788 // We don't want to restore the child frames which had been
789 // iconized even before we were iconized, so save the child frame
790 // status when iconizing the parent frame and check it when
795 pFrame
->m_bWasMinimized
= pFrame
->IsIconized();
799 // This test works for both iconizing and restoring
801 if (!pFrame
->m_bWasMinimized
)
802 pFrame
->Iconize(bIconize
);
806 } // end of wxFrame::IconizeChildFrames
808 WXHICON
wxFrame::GetDefaultIcon() const
810 return (WXHICON
)(wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
811 : wxDEFAULT_FRAME_ICON
);
813 // ===========================================================================
814 // message processing
815 // ===========================================================================
817 // ---------------------------------------------------------------------------
819 // ---------------------------------------------------------------------------
820 bool wxFrame::OS2TranslateMessage( WXMSG
* pMsg
)
823 // try the menu bar accels
825 wxMenuBar
* pMenuBar
= GetMenuBar();
830 #if wxUSE_ACCEL && wxUSE_MENUS_NATIVE
831 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
832 return rAcceleratorTable
.Translate(GetHWND(), pMsg
);
836 } // end of wxFrame::OS2TranslateMessage
838 // ---------------------------------------------------------------------------
839 // our private (non virtual) message handlers
840 // ---------------------------------------------------------------------------
841 bool wxFrame::HandlePaint()
845 if (::WinQueryUpdateRect(GetHWND(), &vRect
))
850 // Icons in PM are the same as "pointers"
852 const wxIcon
& vIcon
= GetIcon();
856 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
858 hIcon
= (HPOINTER
)m_hDefaultIcon
;
861 // Hold a pointer to the dc so long as the OnPaint() message
862 // is being processed
865 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
868 // Erase background before painting or we get white background
870 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
876 ::WinQueryWindowRect(GetHwnd(), &vRect3
);
878 #if !(defined(__WATCOMC__) && __WATCOMC__ < 1240 )
879 // Open Watcom 1.3 had incomplete headers
880 // that's reported and should be fixed for OW 1.4
882 static const int nIconWidth
= 32;
883 static const int nIconHeight
= 32;
884 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
885 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
887 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
894 if (!wxWindow::HandlePaint())
899 hPS
= ::WinBeginPaint( GetHwnd()
905 ::GpiCreateLogColorTable( hPS
909 ,(LONG
)wxTheColourDatabase
->m_nSize
910 ,(PLONG
)wxTheColourDatabase
->m_palTable
912 ::GpiCreateLogColorTable( hPS
922 ,GetBackgroundColour().GetPixel()
931 } // end of wxFrame::HandlePaint
933 bool wxFrame::HandleSize( int nX
, int nY
, WXUINT nId
)
935 bool bProcessed
= false;
941 // Only do it it if we were iconized before, otherwise resizing the
942 // parent frame has a curious side effect of bringing it under it's
948 // restore all child frames too
950 IconizeChildFrames(false);
951 (void)SendIconizeEvent(false);
963 // Iconize all child frames too
965 IconizeChildFrames(true);
966 (void)SendIconizeEvent();
974 // forward WM_SIZE to status bar control
976 #if wxUSE_NATIVE_STATUSBAR
977 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
979 wxSizeEvent
vEvent( wxSize( nX
982 ,m_frameStatusBar
->GetId()
985 vEvent
.SetEventObject(m_frameStatusBar
);
986 m_frameStatusBar
->OnSize(vEvent
);
988 #endif // wxUSE_NATIVE_STATUSBAR
993 #endif // wxUSE_TOOLBAR
995 bProcessed
= wxWindow::HandleSize( nX
1001 } // end of wxFrame::HandleSize
1003 bool wxFrame::HandleCommand( WXWORD nId
,
1010 // In case it's e.g. a toolbar.
1012 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
1015 return pWin
->OS2Command( nCmd
, nId
);
1019 // Handle here commands from menus and accelerators
1021 if (nCmd
== CMDSRC_MENU
|| nCmd
== CMDSRC_ACCELERATOR
)
1023 #if wxUSE_MENUS_NATIVE
1024 if (wxCurrentPopupMenu
)
1026 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1028 wxCurrentPopupMenu
= NULL
;
1030 return pPopupMenu
->OS2Command( nCmd
, nId
);
1034 if (ProcessCommand(nId
))
1040 } // end of wxFrame::HandleCommand
1042 bool wxFrame::HandleMenuSelect( WXWORD nItem
,
1051 rc
= ::WinSendMsg(hMenu
, MM_QUERYITEM
, MPFROM2SHORT(nItem
, TRUE
), (MPARAM
)&mItem
);
1053 if(rc
&& !(mItem
.afStyle
& (MIS_SUBMENU
| MIS_SEPARATOR
)))
1055 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nItem
);
1057 vEvent
.SetEventObject(this);
1058 GetEventHandler()->ProcessEvent(vEvent
); // return value would be ignored by PM
1062 DoGiveHelp(wxEmptyString
, false);
1067 } // end of wxFrame::HandleMenuSelect
1069 // ---------------------------------------------------------------------------
1070 // Main Frame window proc
1071 // ---------------------------------------------------------------------------
1072 MRESULT EXPENTRY
wxFrameMainWndProc( HWND hWnd
,
1077 MRESULT rc
= (MRESULT
)0;
1078 bool bProcessed
= false;
1079 wxFrame
* pWnd
= NULL
;
1081 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1084 case WM_QUERYFRAMECTLCOUNT
:
1085 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1087 USHORT uItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1089 rc
= MRFROMSHORT(uItemCount
);
1093 case WM_FORMATFRAME
:
1094 /////////////////////////////////////////////////////////////////////////////////
1095 // Applications that subclass frame controls may find that the frame is already
1096 // subclassed the number of frame controls is variable.
1097 // The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
1098 // subclassed by calling the previous window procedure and modifying its result.
1099 ////////////////////////////////////////////////////////////////////////////////
1111 pSWP
= (PSWP
)PVOIDFROMMP(wParam
);
1112 nItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1113 if(pWnd
->m_frameStatusBar
)
1115 ::WinQueryWindowRect(pWnd
->m_frameStatusBar
->GetHWND(), &vRstb
);
1116 pWnd
->m_frameStatusBar
->GetSize(NULL
, &nHeight
);
1118 if(pWnd
->m_frameToolBar
)
1120 ::WinQueryWindowRect(pWnd
->m_frameToolBar
->GetHWND(), &vRtlb
);
1121 pWnd
->m_frameToolBar
->GetSize(&nWidth
, &nHeight2
);
1123 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1124 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1125 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1126 ::WinMapWindowPoints(HWND_DESKTOP
, pWnd
->m_hFrame
, (PPOINTL
)&vRectl
, 2);
1127 for(i
= 0; i
< nItemCount
; i
++)
1129 if(pWnd
->m_hWnd
&& pSWP
[i
].hwnd
== pWnd
->m_hWnd
)
1131 if (pWnd
->m_frameToolBar
&& pWnd
->m_frameToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
1133 pSWP
[i
].x
= vRectl
.xLeft
;
1134 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1135 pSWP
[i
].cx
= vRectl
.xRight
- vRectl
.xLeft
;
1136 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- (nHeight
+ nHeight2
);
1140 pSWP
[i
].x
= vRectl
.xLeft
+ nWidth
;
1141 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1142 pSWP
[i
].cx
= vRectl
.xRight
- (vRectl
.xLeft
+ nWidth
);
1143 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- nHeight
;
1145 pSWP
[i
].fl
= SWP_SIZE
| SWP_MOVE
| SWP_SHOW
;
1146 pSWP
[i
].hwndInsertBehind
= HWND_TOP
;
1150 rc
= MRFROMSHORT(nItemCount
);
1155 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1156 rc
= pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
);
1158 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1161 } // end of wxFrameMainWndProc
1163 MRESULT EXPENTRY
wxFrameWndProc(
1171 // Trace all ulMsgs - useful for the debugging
1174 wxFrame
* pWnd
= NULL
;
1176 parentHwnd
= WinQueryWindow(hWnd
,QW_PARENT
);
1177 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1180 // When we get the first message for the HWND we just created, we associate
1181 // it with wxWindow stored in wxWndHook
1184 MRESULT rc
= (MRESULT
)0;
1187 // Stop right here if we don't have a valid handle in our wxWindow object.
1189 if (pWnd
&& !pWnd
->GetHWND())
1191 pWnd
->SetHWND((WXHWND
) hWnd
);
1192 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
1198 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
1200 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1203 } // end of wxFrameWndProc
1205 MRESULT
wxFrame::OS2WindowProc( WXUINT uMessage
,
1210 bool bProcessed
= false;
1216 // If we can't close, tell the system that we processed the
1217 // message - otherwise it would close us
1219 bProcessed
= !Close();
1223 bProcessed
= HandlePaint();
1224 mRc
= (MRESULT
)FALSE
;
1227 case WM_ERASEBACKGROUND
:
1229 // Returning TRUE to requests PM to paint the window background
1230 // in SYSCLR_WINDOW. We capture this here because the PS returned
1231 // in Frames is the PS for the whole frame, which we can't really
1232 // use at all. If you want to paint a different background, do it
1233 // in an OnPaint using a wxPaintDC.
1235 mRc
= (MRESULT
)(TRUE
);
1244 UnpackCommand( (WXWPARAM
)wParam
1251 bProcessed
= HandleCommand( wId
1264 UnpackMenuSelect( wParam
1270 bProcessed
= HandleMenuSelect( wItem
1274 mRc
= (MRESULT
)TRUE
;
1280 SHORT nScxnew
= SHORT1FROMMP(lParam
); // New horizontal size.
1281 SHORT nScynew
= SHORT2FROMMP(lParam
); // New vertical size.
1283 lParam
= MRFROM2SHORT( nScxnew
- 20
1287 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1288 mRc
= (MRESULT
)FALSE
;
1291 case CM_QUERYDRAGIMAGE
:
1293 const wxIcon
& vIcon
= GetIcon();
1297 hIcon
= (HPOINTER
)::WinSendMsg(GetHWND(), WM_QUERYICON
, 0L, 0L);
1299 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1300 mRc
= (MRESULT
)hIcon
;
1301 bProcessed
= mRc
!= 0;
1307 mRc
= wxWindow::OS2WindowProc( uMessage
1311 return (MRESULT
)mRc
;
1312 } // wxFrame::OS2WindowProc
1314 void wxFrame::SetClient(WXHWND
WXUNUSED(c_Hwnd
))
1316 // Duh...nothing to do under OS/2
1319 void wxFrame::SetClient( wxWindow
* pWindow
)
1321 wxWindow
* pOldClient
= this->GetClient();
1322 bool bClientHasFocus
= pOldClient
&& (pOldClient
== wxWindow::FindFocus());
1324 if(pOldClient
== pWindow
) // nothing to do
1326 if(pWindow
== NULL
) // just need to remove old client
1328 if(pOldClient
== NULL
) // nothing to do
1331 if(bClientHasFocus
)
1334 pOldClient
->Enable( false );
1335 pOldClient
->Show( false );
1336 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1337 // to avoid OS/2 bug need to update frame
1338 ::WinSendMsg((HWND
)this->GetFrame(), WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1343 // Else need to change client
1348 ::WinEnableWindowUpdate((HWND
)GetHWND(), FALSE
);
1351 pOldClient
->Enable(false);
1352 pOldClient
->Show(false);
1353 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1355 pWindow
->Reparent(this);
1356 ::WinSetWindowUShort(pWindow
->GetHWND(), QWS_ID
, FID_CLIENT
);
1357 ::WinEnableWindowUpdate((HWND
)GetHWND(), TRUE
);
1359 pWindow
->Show(); // ensure client is showing
1360 if( this->IsShown() )
1363 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1367 wxWindow
* wxFrame::GetClient()
1369 return wxFindWinFromHandle((WXHWND
)::WinWindowFromID(m_hFrame
, FID_CLIENT
));
1372 void wxFrame::SendSizeEvent()
1376 RECTL vRect
= wxGetWindowRect(GetHwnd());
1378 ::WinPostMsg( GetHwnd()
1380 ,MPFROM2SHORT( vRect
.xRight
- vRect
.xLeft
1381 ,vRect
.xRight
- vRect
.xLeft
1383 ,MPFROM2SHORT( vRect
.yTop
- vRect
.yBottom
1384 ,vRect
.yTop
- vRect
.yBottom