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 wxWindowList wxModelessWindows
;
55 extern wxList WXDLLEXPORT wxPendingDelete
;
57 #if wxUSE_MENUS_NATIVE
58 extern wxMenu
*wxCurrentPopupMenu
;
61 extern void wxAssociateWinWithHandle( HWND hWnd
65 // ----------------------------------------------------------------------------
67 // ----------------------------------------------------------------------------
69 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
70 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
73 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
75 // ============================================================================
77 // ============================================================================
79 // ----------------------------------------------------------------------------
80 // static class members
81 // ----------------------------------------------------------------------------
84 #if wxUSE_NATIVE_STATUSBAR
85 bool wxFrame::m_bUseNativeStatusBar
= TRUE
;
87 bool wxFrame::m_bUseNativeStatusBar
= FALSE
;
90 #endif //wxUSE_STATUSBAR
92 // ----------------------------------------------------------------------------
93 // creation/destruction
94 // ----------------------------------------------------------------------------
98 m_nFsStatusBarFields
= 0;
99 m_nFsStatusBarHeight
= 0;
100 m_nFsToolBarHeight
= 0;
102 m_bWasMinimized
= FALSE
;
105 m_frameMenuBar
= NULL
;
106 m_frameToolBar
= NULL
;
107 m_frameStatusBar
= NULL
;
109 m_hTitleBar
= NULLHANDLE
;
110 m_hHScroll
= NULLHANDLE
;
111 m_hVScroll
= NULLHANDLE
;
116 memset(&m_vSwpTitleBar
, 0, sizeof(SWP
));
117 memset(&m_vSwpMenuBar
, 0, sizeof(SWP
));
118 memset(&m_vSwpHScroll
, 0, sizeof(SWP
));
119 memset(&m_vSwpVScroll
, 0, sizeof(SWP
));
120 memset(&m_vSwpStatusBar
, 0, sizeof(SWP
));
121 memset(&m_vSwpToolBar
, 0, sizeof(SWP
));
124 } // end of wxFrame::Init
126 bool wxFrame::Create(
129 , const wxString
& rsTitle
130 , const wxPoint
& rPos
131 , const wxSize
& rSize
133 , const wxString
& rsName
136 if (!wxTopLevelWindow::Create( pParent
145 wxModelessWindows
.Append(this);
147 } // end of wxFrame::Create
151 m_isBeingDeleted
= TRUE
;
153 } // end of wxFrame::~wxFrame
156 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
158 void wxFrame::DoGetClientSize(
163 wxTopLevelWindow::DoGetClientSize( pX
167 // No need to use statusbar code as in WIN32 as the FORMATFRAME
168 // window procedure ensures PM knows about the new frame client
169 // size internally. A ::WinQueryWindowRect (that is called in
170 // wxWindow's GetClient size from above) is all that is needed!
172 } // end of wxFrame::DoGetClientSize
175 // Set the client size (i.e. leave the calculation of borders etc.
178 void wxFrame::DoSetClientSize(
184 // Statusbars are not part of the OS/2 Client but parent frame
185 // so no statusbar consideration
187 wxTopLevelWindow::DoSetClientSize( nWidth
190 } // end of wxFrame::DoSetClientSize
192 // ----------------------------------------------------------------------------
193 // wxFrame: various geometry-related functions
194 // ----------------------------------------------------------------------------
196 void wxFrame::Raise()
198 wxFrameBase::Raise();
199 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
210 wxStatusBar
* wxFrame::OnCreateStatusBar(
214 , const wxString
& rName
217 wxStatusBar
* pStatusBar
= NULL
;
220 pStatusBar
= wxFrameBase::OnCreateStatusBar( nNumber
229 wxClientDC
vDC(pStatusBar
);
233 // Set the height according to the font and the border size
235 vDC
.SetFont(pStatusBar
->GetFont()); // Screws up the menues for some reason
236 vDC
.GetTextExtent( "X"
241 int nHeight
= ((11 * nY
) / 10 + 2 * pStatusBar
->GetBorderY());
243 pStatusBar
->SetSize( -1
249 ::WinSetParent( pStatusBar
->GetHWND()
253 ::WinSetOwner( pStatusBar
->GetHWND()
259 if(::WinIsWindowShowing(m_hFrame
))
260 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
263 } // end of wxFrame::OnCreateStatusBar
265 void wxFrame::PositionStatusBar()
272 // Native status bar positions itself
274 if (m_frameStatusBar
)
283 ::WinQueryWindowRect(m_hFrame
, &vRect
);
285 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
287 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
288 nWidth
= vRect
.xRight
- vRect
.xLeft
;
289 nY
= nY
- (vRect
.yBottom
- vFRect
.yBottom
);
291 m_frameStatusBar
->GetSize( &nStatbarWidth
295 nY
= nY
- nStatbarHeight
;
297 // Since we wish the status bar to be directly under the client area,
298 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
300 m_frameStatusBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
305 if (!::WinQueryWindowPos(m_frameStatusBar
->GetHWND(), &vSwp
))
307 vError
= ::WinGetLastError(vHabmain
);
308 sError
= wxPMErrorToStr(vError
);
309 wxLogError("Error setting parent for StautsBar. Error: %s\n", sError
.c_str());
313 } // end of wxFrame::PositionStatusBar
314 #endif // wxUSE_STATUSBAR
317 wxToolBar
* wxFrame::OnCreateToolBar(
320 , const wxString
& rsName
323 wxToolBar
* pToolBar
= wxFrameBase::OnCreateToolBar( lStyle
328 ::WinSetParent( pToolBar
->GetHWND()
332 ::WinSetOwner( pToolBar
->GetHWND()
336 } // end of WinGuiBase_CFrame::OnCreateToolBar
339 #if wxUSE_MENUS_NATIVE
340 void wxFrame::DetachMenuBar()
344 m_frameMenuBar
->Detach();
345 m_frameMenuBar
= NULL
;
347 } // end of wxFrame::DetachMenuBar
349 void wxFrame::SetMenuBar(
360 // Actually remove the menu from the frame
362 m_hMenu
= (WXHMENU
)0;
363 InternalSetMenuBar();
365 else // set new non NULL menu bar
367 m_frameMenuBar
= NULL
;
370 // Can set a menubar several times.
371 // TODO: how to prevent a memory leak if you have a currently-unattached
372 // menubar? wxWindows assumes that the frame will delete the menu (otherwise
373 // there are problems for MDI).
375 if (pMenuBar
->GetHMenu())
377 m_hMenu
= pMenuBar
->GetHMenu();
382 m_hMenu
= pMenuBar
->Create();
386 InternalSetMenuBar();
387 m_frameMenuBar
= pMenuBar
;
388 pMenuBar
->Attach((wxFrame
*)this);
390 } // end of wxFrame::SetMenuBar
392 void wxFrame::AttachMenuBar(
396 wxFrameBase::AttachMenuBar(pMenubar
);
398 m_frameMenuBar
= pMenubar
;
403 // Actually remove the menu from the frame
405 m_hMenu
= (WXHMENU
)0;
406 InternalSetMenuBar();
408 else // Set new non NULL menu bar
411 // Can set a menubar several times.
413 if (pMenubar
->GetHMenu())
415 m_hMenu
= pMenubar
->GetHMenu();
419 if (pMenubar
->IsAttached())
422 m_hMenu
= pMenubar
->Create();
427 InternalSetMenuBar();
429 } // end of wxFrame::AttachMenuBar
431 void wxFrame::InternalSetMenuBar()
436 // Set the parent and owner of the menubar to be the frame
438 if (!::WinSetParent(m_hMenu
, m_hFrame
, FALSE
))
440 vError
= ::WinGetLastError(vHabmain
);
441 sError
= wxPMErrorToStr(vError
);
442 wxLogError("Error setting parent for submenu. Error: %s\n", sError
.c_str());
445 if (!::WinSetOwner(m_hMenu
, m_hFrame
))
447 vError
= ::WinGetLastError(vHabmain
);
448 sError
= wxPMErrorToStr(vError
);
449 wxLogError("Error setting parent for submenu. Error: %s\n", sError
.c_str());
451 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
452 } // end of wxFrame::InternalSetMenuBar
453 #endif // wxUSE_MENUS_NATIVE
456 // Responds to colour changes, and passes event on to children
458 void wxFrame::OnSysColourChanged(
459 wxSysColourChangedEvent
& rEvent
462 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
466 if (m_frameStatusBar
)
468 wxSysColourChangedEvent vEvent2
;
470 vEvent2
.SetEventObject(m_frameStatusBar
);
471 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
473 #endif //wxUSE_STATUSBAR
476 // Propagate the event to the non-top-level children
478 wxWindow::OnSysColourChanged(rEvent
);
479 } // end of wxFrame::OnSysColourChanged
481 // Pass TRUE to show full screen, FALSE to restore.
482 bool wxFrame::ShowFullScreen(
492 m_bFsIsShowing
= TRUE
;
496 wxToolBar
* pTheToolBar
= GetToolBar();
497 #endif //wxUSE_TOOLBAR
500 wxStatusBar
* pTheStatusBar
= GetStatusBar();
501 #endif //wxUSE_STATUSBAR
507 pTheToolBar
->GetSize(&nDummyWidth
, &m_nFsToolBarHeight
);
508 #endif //wxUSE_TOOLBAR
512 pTheStatusBar
->GetSize(&nDummyWidth
, &m_nFsStatusBarHeight
);
513 #endif //wxUSE_STATUSBAR
517 // Zap the toolbar, menubar, and statusbar
519 if ((lStyle
& wxFULLSCREEN_NOTOOLBAR
) && pTheToolBar
)
521 pTheToolBar
->SetSize(-1,0);
522 pTheToolBar
->Show(FALSE
);
524 #endif //wxUSE_TOOLBAR
526 if (lStyle
& wxFULLSCREEN_NOMENUBAR
)
528 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
529 ::WinSetOwner(m_hMenu
, m_hFrame
);
530 ::WinSendMsg((HWND
)m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
535 // Save the number of fields in the statusbar
537 if ((lStyle
& wxFULLSCREEN_NOSTATUSBAR
) && pTheStatusBar
)
539 m_nFsStatusBarFields
= pTheStatusBar
->GetFieldsCount();
540 SetStatusBar((wxStatusBar
*) NULL
);
541 delete pTheStatusBar
;
544 m_nFsStatusBarFields
= 0;
545 #endif //wxUSE_STATUSBAR
548 // Zap the frame borders
552 // Save the 'normal' window style
554 m_lFsOldWindowStyle
= ::WinQueryWindowULong(m_hFrame
, QWL_STYLE
);
557 // Save the old position, width & height, maximize state
559 m_vFsOldSize
= GetRect();
560 m_bFsIsMaximized
= IsMaximized();
563 // Decide which window style flags to turn off
565 LONG lNewStyle
= m_lFsOldWindowStyle
;
568 if (lStyle
& wxFULLSCREEN_NOBORDER
)
569 lOffFlags
|= FCF_BORDER
;
570 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
571 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
573 lNewStyle
&= (~lOffFlags
);
576 // Change our window style to be compatible with full-screen mode
578 ::WinSetWindowULong((HWND
)m_hFrame
, QWL_STYLE
, (ULONG
)lNewStyle
);
581 // Resize to the size of the desktop
587 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
588 nWidth
= vRect
.xRight
- vRect
.xLeft
;
590 // Rmember OS/2 is backwards!
592 nHeight
= vRect
.yTop
- vRect
.yBottom
;
599 // Now flush the window style cache and actually go full-screen
601 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
610 wxSizeEvent
vEvent( wxSize( nWidth
616 GetEventHandler()->ProcessEvent(vEvent
);
624 m_bFsIsShowing
= FALSE
;
627 wxToolBar
* pTheToolBar
= GetToolBar();
630 // Restore the toolbar, menubar, and statusbar
632 if (pTheToolBar
&& (m_lFsStyle
& wxFULLSCREEN_NOTOOLBAR
))
634 pTheToolBar
->SetSize(-1, m_nFsToolBarHeight
);
635 pTheToolBar
->Show(TRUE
);
637 #endif //wxUSE_TOOLBAR
640 if ((m_lFsStyle
& wxFULLSCREEN_NOSTATUSBAR
) && (m_nFsStatusBarFields
> 0))
642 CreateStatusBar(m_nFsStatusBarFields
);
643 // PositionStatusBar();
645 #endif //wxUSE_STATUSBAR
647 if ((m_lFsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
649 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
650 ::WinSetOwner(m_hMenu
, m_hFrame
);
651 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
653 Maximize(m_bFsIsMaximized
);
655 ::WinSetWindowULong( m_hFrame
657 ,(ULONG
)m_lFsOldWindowStyle
659 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
668 return wxFrameBase::ShowFullScreen(bShow
, lStyle
);
669 } // end of wxFrame::ShowFullScreen
674 // ----------------------------------------------------------------------------
675 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
676 // from the client area, so the client area is what's really available for the
678 // ----------------------------------------------------------------------------
680 // Checks if there is a toolbar, and returns the first free client position
681 wxPoint
wxFrame::GetClientAreaOrigin() const
683 wxPoint vPoint
= wxTopLevelWindow::GetClientAreaOrigin();
686 // In OS/2 the toolbar and statusbar are frame extensions so there is no
687 // adjustment. The client is supposedly resized for a toolbar in OS/2
688 // as it is for the status bar.
691 } // end of wxFrame::GetClientAreaOrigin
693 // ----------------------------------------------------------------------------
694 // tool/status bar stuff
695 // ----------------------------------------------------------------------------
699 wxToolBar
* wxFrame::CreateToolBar(
702 , const wxString
& rName
705 if (wxFrameBase::CreateToolBar( lStyle
712 return m_frameToolBar
;
713 } // end of wxFrame::CreateToolBar
715 void wxFrame::PositionToolBar()
717 wxToolBar
* pToolBar
= GetToolBar();
730 ::WinQueryWindowRect(m_hFrame
, &vRect
);
731 vPos
.y
= (wxCoord
)vRect
.yTop
;
732 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
734 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
736 vPos
.y
= (wxCoord
)(vFRect
.yTop
- vRect
.yTop
);
737 pToolBar
->GetSize( &vTWidth
741 if (pToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
743 vWidth
= (wxCoord
)(vRect
.xRight
- vRect
.xLeft
);
744 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
753 wxCoord vSheight
= 0;
755 if (m_frameStatusBar
)
756 m_frameStatusBar
->GetSize( &vSwidth
759 vHeight
= (wxCoord
)(vRect
.yTop
- vRect
.yBottom
);
760 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
766 if( ::WinIsWindowShowing(m_hFrame
) )
767 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
768 } // end of wxFrame::PositionToolBar
769 #endif // wxUSE_TOOLBAR
771 // ----------------------------------------------------------------------------
772 // frame state (iconized/maximized/...)
773 // ----------------------------------------------------------------------------
776 // propagate our state change to all child frames: this allows us to emulate X
777 // Windows behaviour where child frames float independently of the parent one
778 // on the desktop, but are iconized/restored with it
780 void wxFrame::IconizeChildFrames(
784 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
786 pNode
= pNode
->GetNext() )
788 wxWindow
* pWin
= pNode
->GetData();
789 wxFrame
* pFrame
= wxDynamicCast(pWin
, wxFrame
);
792 #if wxUSE_MDI_ARCHITECTURE
793 && !wxDynamicCast(pFrame
, wxMDIChildFrame
)
794 #endif // wxUSE_MDI_ARCHITECTURE
798 // We don't want to restore the child frames which had been
799 // iconized even before we were iconized, so save the child frame
800 // status when iconizing the parent frame and check it when
805 pFrame
->m_bWasMinimized
= pFrame
->IsIconized();
809 // This test works for both iconizing and restoring
811 if (!pFrame
->m_bWasMinimized
)
812 pFrame
->Iconize(bIconize
);
815 } // end of wxFrame::IconizeChildFrames
817 WXHICON
wxFrame::GetDefaultIcon() const
819 return (WXHICON
)(wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
820 : wxDEFAULT_FRAME_ICON
);
822 // ===========================================================================
823 // message processing
824 // ===========================================================================
826 // ---------------------------------------------------------------------------
828 // ---------------------------------------------------------------------------
829 bool wxFrame::OS2TranslateMessage(
834 // try the menu bar accels
836 wxMenuBar
* pMenuBar
= GetMenuBar();
841 #if wxUSE_ACCEL && wxUSE_MENUS_NATIVE
842 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
843 return rAcceleratorTable
.Translate(GetHWND(), pMsg
);
847 } // end of wxFrame::OS2TranslateMessage
849 // ---------------------------------------------------------------------------
850 // our private (non virtual) message handlers
851 // ---------------------------------------------------------------------------
852 bool wxFrame::HandlePaint()
856 if (::WinQueryUpdateRect(GetHWND(), &vRect
))
861 // Icons in PM are the same as "pointers"
863 const wxIcon
& vIcon
= GetIcon();
867 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
869 hIcon
= (HPOINTER
)m_hDefaultIcon
;
872 // Hold a pointer to the dc so long as the OnPaint() message
873 // is being processed
876 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
879 // Erase background before painting or we get white background
881 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
887 ::WinQueryWindowRect(GetHwnd(), &vRect3
);
889 static const int nIconWidth
= 32;
890 static const int nIconHeight
= 32;
891 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
892 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
894 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
901 if (!wxWindow::HandlePaint())
906 hPS
= ::WinBeginPaint( GetHwnd()
912 ::GpiCreateLogColorTable( hPS
916 ,(LONG
)wxTheColourDatabase
->m_nSize
917 ,(PLONG
)wxTheColourDatabase
->m_palTable
919 ::GpiCreateLogColorTable( hPS
929 ,GetBackgroundColour().GetPixel()
939 // nothing to paint - processed
943 } // end of wxFrame::HandlePaint
945 bool wxFrame::HandleSize(
951 bool bProcessed
= FALSE
;
957 // Only do it it if we were iconized before, otherwise resizing the
958 // parent frame has a curious side effect of bringing it under it's
964 // restore all child frames too
966 IconizeChildFrames(FALSE
);
967 (void)SendIconizeEvent(FALSE
);
979 // Iconize all child frames too
981 IconizeChildFrames(TRUE
);
982 (void)SendIconizeEvent();
990 // forward WM_SIZE to status bar control
992 #if wxUSE_NATIVE_STATUSBAR
993 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
995 wxSizeEvent
vEvent( wxSize( nX
998 ,m_frameStatusBar
->GetId()
1001 vEvent
.SetEventObject(m_frameStatusBar
);
1002 m_frameStatusBar
->OnSize(vEvent
);
1004 #endif // wxUSE_NATIVE_STATUSBAR
1006 PositionStatusBar();
1009 #endif // wxUSE_TOOLBAR
1011 bProcessed
= wxWindow::HandleSize( nX
1017 } // end of wxFrame::HandleSize
1019 bool wxFrame::HandleCommand(
1028 // In case it's e.g. a toolbar.
1030 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
1033 return pWin
->OS2Command( nCmd
1039 // Handle here commands from menus and accelerators
1041 if (nCmd
== CMDSRC_MENU
|| nCmd
== CMDSRC_ACCELERATOR
)
1043 #if wxUSE_MENUS_NATIVE
1044 if (wxCurrentPopupMenu
)
1046 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1048 wxCurrentPopupMenu
= NULL
;
1050 return pPopupMenu
->OS2Command( nCmd
1057 if (ProcessCommand(nId
))
1063 } // end of wxFrame::HandleCommand
1065 bool wxFrame::HandleMenuSelect(
1076 rc
= ::WinSendMsg(hMenu
, MM_QUERYITEM
, MPFROM2SHORT(nItem
, TRUE
), (MPARAM
)&mItem
);
1078 if(rc
&& !(mItem
.afStyle
& (MIS_SUBMENU
| MIS_SEPARATOR
)))
1080 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nItem
);
1082 vEvent
.SetEventObject(this);
1083 GetEventHandler()->ProcessEvent(vEvent
); // return value would be ignored by PM
1087 DoGiveHelp(wxEmptyString
, FALSE
);
1092 } // end of wxFrame::HandleMenuSelect
1094 // ---------------------------------------------------------------------------
1095 // Main Frame window proc
1096 // ---------------------------------------------------------------------------
1097 MRESULT EXPENTRY
wxFrameMainWndProc(
1104 MRESULT rc
= (MRESULT
)0;
1105 bool bProcessed
= FALSE
;
1106 wxFrame
* pWnd
= NULL
;
1108 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1111 case WM_QUERYFRAMECTLCOUNT
:
1112 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1114 USHORT uItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1116 rc
= MRFROMSHORT(uItemCount
);
1120 case WM_FORMATFRAME
:
1121 /////////////////////////////////////////////////////////////////////////////////
1122 // Applications that subclass frame controls may find that the frame is already
1123 // subclassed the number of frame controls is variable.
1124 // The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
1125 // subclassed by calling the previous window procedure and modifying its result.
1126 ////////////////////////////////////////////////////////////////////////////////
1138 pSWP
= (PSWP
)PVOIDFROMMP(wParam
);
1139 nItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1140 if(pWnd
->m_frameStatusBar
)
1142 ::WinQueryWindowRect(pWnd
->m_frameStatusBar
->GetHWND(), &vRstb
);
1143 pWnd
->m_frameStatusBar
->GetSize(NULL
, &nHeight
);
1145 if(pWnd
->m_frameToolBar
)
1147 ::WinQueryWindowRect(pWnd
->m_frameToolBar
->GetHWND(), &vRtlb
);
1148 pWnd
->m_frameToolBar
->GetSize(&nWidth
, &nHeight2
);
1150 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1151 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1152 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1153 ::WinMapWindowPoints(HWND_DESKTOP
, pWnd
->m_hFrame
, (PPOINTL
)&vRectl
, 2);
1154 for(i
= 0; i
< nItemCount
; i
++)
1156 if(pWnd
->m_hWnd
&& pSWP
[i
].hwnd
== pWnd
->m_hWnd
)
1158 if (pWnd
->m_frameToolBar
&& pWnd
->m_frameToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
1160 pSWP
[i
].x
= vRectl
.xLeft
;
1161 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1162 pSWP
[i
].cx
= vRectl
.xRight
- vRectl
.xLeft
;
1163 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- (nHeight
+ nHeight2
);
1167 pSWP
[i
].x
= vRectl
.xLeft
+ nWidth
;
1168 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1169 pSWP
[i
].cx
= vRectl
.xRight
- (vRectl
.xLeft
+ nWidth
);
1170 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- nHeight
;
1172 pSWP
[i
].fl
= SWP_SIZE
| SWP_MOVE
| SWP_SHOW
;
1173 pSWP
[i
].hwndInsertBehind
= HWND_TOP
;
1177 rc
= MRFROMSHORT(nItemCount
);
1182 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1183 rc
= pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
);
1185 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1188 } // end of wxFrameMainWndProc
1190 MRESULT EXPENTRY
wxFrameWndProc(
1198 // Trace all ulMsgs - useful for the debugging
1201 wxFrame
* pWnd
= NULL
;
1203 parentHwnd
= WinQueryWindow(hWnd
,QW_PARENT
);
1204 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1207 // When we get the first message for the HWND we just created, we associate
1208 // it with wxWindow stored in wxWndHook
1211 MRESULT rc
= (MRESULT
)0;
1214 // Stop right here if we don't have a valid handle in our wxWindow object.
1216 if (pWnd
&& !pWnd
->GetHWND())
1218 pWnd
->SetHWND((WXHWND
) hWnd
);
1219 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
1225 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
1227 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1230 } // end of wxFrameWndProc
1232 MRESULT
wxFrame::OS2WindowProc(
1239 bool bProcessed
= FALSE
;
1245 // If we can't close, tell the system that we processed the
1246 // message - otherwise it would close us
1248 bProcessed
= !Close();
1252 bProcessed
= HandlePaint();
1253 mRc
= (MRESULT
)FALSE
;
1256 case WM_ERASEBACKGROUND
:
1258 // Returning TRUE to requests PM to paint the window background
1259 // in SYSCLR_WINDOW. We capture this here because the PS returned
1260 // in Frames is the PS for the whole frame, which we can't really
1261 // use at all. If you want to paint a different background, do it
1262 // in an OnPaint using a wxPaintDC.
1264 mRc
= (MRESULT
)(TRUE
);
1273 UnpackCommand( (WXWPARAM
)wParam
1280 bProcessed
= HandleCommand( wId
1293 UnpackMenuSelect( wParam
1299 bProcessed
= HandleMenuSelect( wItem
1303 mRc
= (MRESULT
)TRUE
;
1309 SHORT nScxnew
= SHORT1FROMMP(lParam
); // New horizontal size.
1310 SHORT nScynew
= SHORT2FROMMP(lParam
); // New vertical size.
1312 lParam
= MRFROM2SHORT( nScxnew
- 20
1316 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1317 mRc
= (MRESULT
)FALSE
;
1320 case CM_QUERYDRAGIMAGE
:
1322 const wxIcon
& vIcon
= GetIcon();
1326 hIcon
= (HPOINTER
)::WinSendMsg(GetHWND(), WM_QUERYICON
, 0L, 0L);
1328 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1329 mRc
= (MRESULT
)hIcon
;
1330 bProcessed
= mRc
!= 0;
1336 mRc
= wxWindow::OS2WindowProc( uMessage
1340 return (MRESULT
)mRc
;
1341 } // wxFrame::OS2WindowProc
1343 void wxFrame::SetClient(WXHWND c_Hwnd
)
1345 // Duh...nothing to do under OS/2
1348 void wxFrame::SetClient(
1352 wxWindow
* pOldClient
= this->GetClient();
1353 bool bClientHasFocus
= pOldClient
&& (pOldClient
== wxWindow::FindFocus());
1355 if(pOldClient
== pWindow
) // nothing to do
1357 if(pWindow
== NULL
) // just need to remove old client
1359 if(pOldClient
== NULL
) // nothing to do
1362 if(bClientHasFocus
)
1365 pOldClient
->Enable( FALSE
);
1366 pOldClient
->Show( FALSE
);
1367 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1368 // to avoid OS/2 bug need to update frame
1369 ::WinSendMsg((HWND
)this->GetFrame(), WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1374 // Else need to change client
1379 ::WinEnableWindowUpdate((HWND
)GetHWND(), FALSE
);
1382 pOldClient
->Enable(FALSE
);
1383 pOldClient
->Show(FALSE
);
1384 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1386 pWindow
->Reparent(this);
1387 ::WinSetWindowUShort(pWindow
->GetHWND(), QWS_ID
, FID_CLIENT
);
1388 ::WinEnableWindowUpdate((HWND
)GetHWND(), TRUE
);
1390 pWindow
->Show(); // ensure client is showing
1391 if( this->IsShown() )
1394 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1398 wxWindow
* wxFrame::GetClient()
1400 return wxFindWinFromHandle((WXHWND
)::WinWindowFromID(m_hFrame
, FID_CLIENT
));
1403 void wxFrame::SendSizeEvent()
1407 RECTL vRect
= wxGetWindowRect(GetHwnd());
1409 ::WinPostMsg( GetHwnd()
1411 ,MPFROM2SHORT( vRect
.xRight
- vRect
.xLeft
1412 ,vRect
.xRight
- vRect
.xLeft
1414 ,MPFROM2SHORT( vRect
.yTop
- vRect
.yBottom
1415 ,vRect
.yTop
- vRect
.yBottom