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"
36 #include "wx/os2/private.h"
38 #include "wx/generic/statusbr.h"
40 #include "wx/menuitem.h"
42 // ----------------------------------------------------------------------------
44 // ----------------------------------------------------------------------------
46 #if wxUSE_MENUS_NATIVE
47 extern wxMenu
*wxCurrentPopupMenu
;
50 // ----------------------------------------------------------------------------
52 // ----------------------------------------------------------------------------
54 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
55 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
58 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
60 // ============================================================================
62 // ============================================================================
64 // ----------------------------------------------------------------------------
65 // static class members
66 // ----------------------------------------------------------------------------
69 #if wxUSE_NATIVE_STATUSBAR
70 bool wxFrame::m_bUseNativeStatusBar
= true;
72 bool wxFrame::m_bUseNativeStatusBar
= false;
75 #endif //wxUSE_STATUSBAR
77 // ----------------------------------------------------------------------------
78 // creation/destruction
79 // ----------------------------------------------------------------------------
83 m_nFsStatusBarFields
= 0;
84 m_nFsStatusBarHeight
= 0;
85 m_nFsToolBarHeight
= 0;
87 m_bWasMinimized
= false;
90 m_frameMenuBar
= NULL
;
91 m_frameToolBar
= NULL
;
92 m_frameStatusBar
= NULL
;
94 m_hTitleBar
= NULLHANDLE
;
95 m_hHScroll
= NULLHANDLE
;
96 m_hVScroll
= NULLHANDLE
;
101 memset(&m_vSwpTitleBar
, 0, sizeof(SWP
));
102 memset(&m_vSwpMenuBar
, 0, sizeof(SWP
));
103 memset(&m_vSwpHScroll
, 0, sizeof(SWP
));
104 memset(&m_vSwpVScroll
, 0, sizeof(SWP
));
105 memset(&m_vSwpStatusBar
, 0, sizeof(SWP
));
106 memset(&m_vSwpToolBar
, 0, sizeof(SWP
));
109 } // end of wxFrame::Init
111 bool wxFrame::Create( wxWindow
* pParent
,
113 const wxString
& rsTitle
,
117 const wxString
& rsName
)
119 if (!wxTopLevelWindow::Create( pParent
129 } // end of wxFrame::Create
133 m_isBeingDeleted
= true;
135 } // end of wxFrame::~wxFrame
138 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
140 void wxFrame::DoGetClientSize(
145 wxTopLevelWindow::DoGetClientSize( pX
149 // No need to use statusbar code as in WIN32 as the FORMATFRAME
150 // window procedure ensures PM knows about the new frame client
151 // size internally. A ::WinQueryWindowRect (that is called in
152 // wxWindow's GetClient size from above) is all that is needed!
154 } // end of wxFrame::DoGetClientSize
157 // Set the client size (i.e. leave the calculation of borders etc.
160 void wxFrame::DoSetClientSize(
166 // Statusbars are not part of the OS/2 Client but parent frame
167 // so no statusbar consideration
169 wxTopLevelWindow::DoSetClientSize( nWidth
172 } // end of wxFrame::DoSetClientSize
174 // ----------------------------------------------------------------------------
175 // wxFrame: various geometry-related functions
176 // ----------------------------------------------------------------------------
178 void wxFrame::Raise()
180 wxFrameBase::Raise();
181 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
192 wxStatusBar
* wxFrame::OnCreateStatusBar(
196 , const wxString
& rName
199 wxStatusBar
* pStatusBar
= NULL
;
202 pStatusBar
= wxFrameBase::OnCreateStatusBar( nNumber
211 wxClientDC
vDC(pStatusBar
);
215 // Set the height according to the font and the border size
217 vDC
.SetFont(pStatusBar
->GetFont()); // Screws up the menues for some reason
218 vDC
.GetTextExtent( wxT("X")
223 int nHeight
= ((11 * nY
) / 10 + 2 * pStatusBar
->GetBorderY());
225 pStatusBar
->SetSize( wxDefaultCoord
231 ::WinSetParent( pStatusBar
->GetHWND(), m_hFrame
, FALSE
);
232 ::WinSetOwner( pStatusBar
->GetHWND(), m_hFrame
);
236 if(::WinIsWindowShowing(m_hFrame
))
237 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
240 } // end of wxFrame::OnCreateStatusBar
242 void wxFrame::PositionStatusBar()
249 // Native status bar positions itself
251 if (m_frameStatusBar
)
260 ::WinQueryWindowRect(m_hFrame
, &vRect
);
262 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
264 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
265 nWidth
= vRect
.xRight
- vRect
.xLeft
;
266 nY
= nY
- (vRect
.yBottom
- vFRect
.yBottom
);
268 m_frameStatusBar
->GetSize( &nStatbarWidth
272 nY
= nY
- nStatbarHeight
;
274 // Since we wish the status bar to be directly under the client area,
275 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
277 m_frameStatusBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
282 if (!::WinQueryWindowPos(m_frameStatusBar
->GetHWND(), &vSwp
))
284 vError
= ::WinGetLastError(vHabmain
);
285 sError
= wxPMErrorToStr(vError
);
286 wxLogError(_T("Error setting parent for StatusBar. Error: %s\n"), sError
.c_str());
290 } // end of wxFrame::PositionStatusBar
291 #endif // wxUSE_STATUSBAR
294 wxToolBar
* wxFrame::OnCreateToolBar( long lStyle
, wxWindowID vId
, const wxString
& rsName
)
296 wxToolBar
* pToolBar
= wxFrameBase::OnCreateToolBar( lStyle
301 ::WinSetParent( pToolBar
->GetHWND(), m_hFrame
, FALSE
);
302 ::WinSetOwner( pToolBar
->GetHWND(), m_hFrame
);
304 } // end of WinGuiBase_CFrame::OnCreateToolBar
307 #if wxUSE_MENUS_NATIVE
308 void wxFrame::DetachMenuBar()
312 m_frameMenuBar
->Detach();
313 m_frameMenuBar
= NULL
;
315 } // end of wxFrame::DetachMenuBar
317 void wxFrame::SetMenuBar(
328 // Actually remove the menu from the frame
330 m_hMenu
= (WXHMENU
)0;
331 InternalSetMenuBar();
333 else // set new non NULL menu bar
335 m_frameMenuBar
= NULL
;
338 // Can set a menubar several times.
339 // TODO: how to prevent a memory leak if you have a currently-unattached
340 // menubar? wxWidgets assumes that the frame will delete the menu (otherwise
341 // there are problems for MDI).
343 if (pMenuBar
->GetHMenu())
345 m_hMenu
= pMenuBar
->GetHMenu();
350 m_hMenu
= pMenuBar
->Create();
354 InternalSetMenuBar();
355 m_frameMenuBar
= pMenuBar
;
356 pMenuBar
->Attach((wxFrame
*)this);
358 } // end of wxFrame::SetMenuBar
360 void wxFrame::AttachMenuBar(
364 wxFrameBase::AttachMenuBar(pMenubar
);
366 m_frameMenuBar
= pMenubar
;
371 // Actually remove the menu from the frame
373 m_hMenu
= (WXHMENU
)0;
374 InternalSetMenuBar();
376 else // Set new non NULL menu bar
379 // Can set a menubar several times.
381 if (pMenubar
->GetHMenu())
383 m_hMenu
= pMenubar
->GetHMenu();
387 if (pMenubar
->IsAttached())
390 m_hMenu
= pMenubar
->Create();
395 InternalSetMenuBar();
397 } // end of wxFrame::AttachMenuBar
399 void wxFrame::InternalSetMenuBar()
404 // Set the parent and owner of the menubar to be the frame
406 if (!::WinSetParent(m_hMenu
, m_hFrame
, FALSE
))
408 vError
= ::WinGetLastError(vHabmain
);
409 sError
= wxPMErrorToStr(vError
);
410 wxLogError(_T("Error setting parent for submenu. Error: %s\n"), sError
.c_str());
413 if (!::WinSetOwner(m_hMenu
, m_hFrame
))
415 vError
= ::WinGetLastError(vHabmain
);
416 sError
= wxPMErrorToStr(vError
);
417 wxLogError(_T("Error setting parent for submenu. Error: %s\n"), sError
.c_str());
419 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
420 } // end of wxFrame::InternalSetMenuBar
421 #endif // wxUSE_MENUS_NATIVE
424 // Responds to colour changes, and passes event on to children
426 void wxFrame::OnSysColourChanged(
427 wxSysColourChangedEvent
& rEvent
430 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
434 if (m_frameStatusBar
)
436 wxSysColourChangedEvent vEvent2
;
438 vEvent2
.SetEventObject(m_frameStatusBar
);
439 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
441 #endif //wxUSE_STATUSBAR
444 // Propagate the event to the non-top-level children
446 wxWindow::OnSysColourChanged(rEvent
);
447 } // end of wxFrame::OnSysColourChanged
449 // Pass true to show full screen, false to restore.
450 bool wxFrame::ShowFullScreen( bool bShow
, long lStyle
)
457 m_bFsIsShowing
= true;
461 wxToolBar
* pTheToolBar
= GetToolBar();
462 #endif //wxUSE_TOOLBAR
465 wxStatusBar
* pTheStatusBar
= GetStatusBar();
466 #endif //wxUSE_STATUSBAR
472 pTheToolBar
->GetSize(&nDummyWidth
, &m_nFsToolBarHeight
);
473 #endif //wxUSE_TOOLBAR
477 pTheStatusBar
->GetSize(&nDummyWidth
, &m_nFsStatusBarHeight
);
478 #endif //wxUSE_STATUSBAR
482 // Zap the toolbar, menubar, and statusbar
484 if ((lStyle
& wxFULLSCREEN_NOTOOLBAR
) && pTheToolBar
)
486 pTheToolBar
->SetSize(wxDefaultCoord
,0);
487 pTheToolBar
->Show(false);
489 #endif //wxUSE_TOOLBAR
491 if (lStyle
& wxFULLSCREEN_NOMENUBAR
)
493 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
494 ::WinSetOwner(m_hMenu
, m_hFrame
);
495 ::WinSendMsg((HWND
)m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
500 // Save the number of fields in the statusbar
502 if ((lStyle
& wxFULLSCREEN_NOSTATUSBAR
) && pTheStatusBar
)
504 m_nFsStatusBarFields
= pTheStatusBar
->GetFieldsCount();
505 SetStatusBar((wxStatusBar
*) NULL
);
506 delete pTheStatusBar
;
509 m_nFsStatusBarFields
= 0;
510 #endif //wxUSE_STATUSBAR
513 // Zap the frame borders
517 // Save the 'normal' window style
519 m_lFsOldWindowStyle
= ::WinQueryWindowULong(m_hFrame
, QWL_STYLE
);
522 // Save the old position, width & height, maximize state
524 m_vFsOldSize
= GetRect();
525 m_bFsIsMaximized
= IsMaximized();
528 // Decide which window style flags to turn off
530 LONG lNewStyle
= m_lFsOldWindowStyle
;
533 if (lStyle
& wxFULLSCREEN_NOBORDER
)
534 lOffFlags
|= FCF_BORDER
;
535 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
536 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
538 lNewStyle
&= (~lOffFlags
);
541 // Change our window style to be compatible with full-screen mode
543 ::WinSetWindowULong((HWND
)m_hFrame
, QWL_STYLE
, (ULONG
)lNewStyle
);
546 // Resize to the size of the desktop
552 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
553 nWidth
= vRect
.xRight
- vRect
.xLeft
;
555 // Remember OS/2 is backwards!
557 nHeight
= vRect
.yTop
- vRect
.yBottom
;
559 SetSize( nWidth
, nHeight
);
562 // Now flush the window style cache and actually go full-screen
564 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
573 wxSize
sz( nWidth
, nHeight
);
574 wxSizeEvent
vEvent( sz
, GetId() );
576 GetEventHandler()->ProcessEvent(vEvent
);
584 m_bFsIsShowing
= false;
587 wxToolBar
* pTheToolBar
= GetToolBar();
590 // Restore the toolbar, menubar, and statusbar
592 if (pTheToolBar
&& (m_lFsStyle
& wxFULLSCREEN_NOTOOLBAR
))
594 pTheToolBar
->SetSize(wxDefaultCoord
, m_nFsToolBarHeight
);
595 pTheToolBar
->Show(true);
597 #endif //wxUSE_TOOLBAR
600 if ((m_lFsStyle
& wxFULLSCREEN_NOSTATUSBAR
) && (m_nFsStatusBarFields
> 0))
602 CreateStatusBar(m_nFsStatusBarFields
);
603 // PositionStatusBar();
605 #endif //wxUSE_STATUSBAR
607 if ((m_lFsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
609 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
610 ::WinSetOwner(m_hMenu
, m_hFrame
);
611 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
613 Maximize(m_bFsIsMaximized
);
615 ::WinSetWindowULong( m_hFrame
617 ,(ULONG
)m_lFsOldWindowStyle
619 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
628 return wxFrameBase::ShowFullScreen(bShow
, lStyle
);
629 } // end of wxFrame::ShowFullScreen
634 // ----------------------------------------------------------------------------
635 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
636 // from the client area, so the client area is what's really available for the
638 // ----------------------------------------------------------------------------
640 // Checks if there is a toolbar, and returns the first free client position
641 wxPoint
wxFrame::GetClientAreaOrigin() const
643 wxPoint vPoint
= wxTopLevelWindow::GetClientAreaOrigin();
646 // In OS/2 the toolbar and statusbar are frame extensions so there is no
647 // adjustment. The client is supposedly resized for a toolbar in OS/2
648 // as it is for the status bar.
651 } // end of wxFrame::GetClientAreaOrigin
653 // ----------------------------------------------------------------------------
654 // tool/status bar stuff
655 // ----------------------------------------------------------------------------
659 wxToolBar
* wxFrame::CreateToolBar(
662 , const wxString
& rName
665 if (wxFrameBase::CreateToolBar( lStyle
672 return m_frameToolBar
;
673 } // end of wxFrame::CreateToolBar
675 void wxFrame::PositionToolBar()
677 wxToolBar
* pToolBar
= GetToolBar();
690 ::WinQueryWindowRect(m_hFrame
, &vRect
);
691 vPos
.y
= (wxCoord
)vRect
.yTop
;
692 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
694 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
696 vPos
.y
= (wxCoord
)(vFRect
.yTop
- vRect
.yTop
);
697 pToolBar
->GetSize( &vTWidth
701 if (pToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
703 vWidth
= (wxCoord
)(vRect
.xRight
- vRect
.xLeft
);
704 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
713 wxCoord vSheight
= 0;
715 if (m_frameStatusBar
)
716 m_frameStatusBar
->GetSize( &vSwidth
719 vHeight
= (wxCoord
)(vRect
.yTop
- vRect
.yBottom
);
720 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
726 if( ::WinIsWindowShowing(m_hFrame
) )
727 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
728 } // end of wxFrame::PositionToolBar
729 #endif // wxUSE_TOOLBAR
731 // ----------------------------------------------------------------------------
732 // frame state (iconized/maximized/...)
733 // ----------------------------------------------------------------------------
736 // propagate our state change to all child frames: this allows us to emulate X
737 // Windows behaviour where child frames float independently of the parent one
738 // on the desktop, but are iconized/restored with it
740 void wxFrame::IconizeChildFrames( bool WXUNUSED(bIconize
) )
742 // FIXME: Generic MDI does not use Frames for the Childs, so this does _not_
743 // work. Possibly, the right thing is simply to eliminate this
744 // functions and all the calls to it from within this file.
746 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
748 pNode
= pNode
->GetNext() )
750 wxWindow
* pWin
= pNode
->GetData();
751 wxFrame
* pFrame
= wxDynamicCast(pWin
, wxFrame
);
754 #if wxUSE_MDI_ARCHITECTURE
755 && !wxDynamicCast(pFrame
, wxMDIChildFrame
)
756 #endif // wxUSE_MDI_ARCHITECTURE
760 // We don't want to restore the child frames which had been
761 // iconized even before we were iconized, so save the child frame
762 // status when iconizing the parent frame and check it when
767 pFrame
->m_bWasMinimized
= pFrame
->IsIconized();
771 // This test works for both iconizing and restoring
773 if (!pFrame
->m_bWasMinimized
)
774 pFrame
->Iconize(bIconize
);
778 } // end of wxFrame::IconizeChildFrames
780 WXHICON
wxFrame::GetDefaultIcon() const
782 return (WXHICON
)(wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
783 : wxDEFAULT_FRAME_ICON
);
785 // ===========================================================================
786 // message processing
787 // ===========================================================================
789 // ---------------------------------------------------------------------------
791 // ---------------------------------------------------------------------------
792 bool wxFrame::OS2TranslateMessage( WXMSG
* pMsg
)
795 // try the menu bar accels
797 wxMenuBar
* pMenuBar
= GetMenuBar();
802 #if wxUSE_ACCEL && wxUSE_MENUS_NATIVE
803 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
804 return rAcceleratorTable
.Translate(GetHWND(), pMsg
);
808 } // end of wxFrame::OS2TranslateMessage
810 // ---------------------------------------------------------------------------
811 // our private (non virtual) message handlers
812 // ---------------------------------------------------------------------------
813 bool wxFrame::HandlePaint()
817 if (::WinQueryUpdateRect(GetHWND(), &vRect
))
822 // Icons in PM are the same as "pointers"
824 const wxIcon
& vIcon
= GetIcon();
828 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
830 hIcon
= (HPOINTER
)m_hDefaultIcon
;
833 // Hold a pointer to the dc so long as the OnPaint() message
834 // is being processed
837 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
840 // Erase background before painting or we get white background
842 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
848 ::WinQueryWindowRect(GetHwnd(), &vRect3
);
850 static const int nIconWidth
= 32;
851 static const int nIconHeight
= 32;
852 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
853 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
855 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
861 if (!wxWindow::HandlePaint())
866 hPS
= ::WinBeginPaint( GetHwnd()
872 ::GpiCreateLogColorTable( hPS
876 ,(LONG
)wxTheColourDatabase
->m_nSize
877 ,(PLONG
)wxTheColourDatabase
->m_palTable
879 ::GpiCreateLogColorTable( hPS
889 ,GetBackgroundColour().GetPixel()
898 } // end of wxFrame::HandlePaint
900 bool wxFrame::HandleSize( int nX
, int nY
, WXUINT nId
)
902 bool bProcessed
= false;
908 // Only do it it if we were iconized before, otherwise resizing the
909 // parent frame has a curious side effect of bringing it under it's
915 // restore all child frames too
917 IconizeChildFrames(false);
918 (void)SendIconizeEvent(false);
930 // Iconize all child frames too
932 IconizeChildFrames(true);
933 (void)SendIconizeEvent();
941 // forward WM_SIZE to status bar control
943 #if wxUSE_NATIVE_STATUSBAR
944 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
946 wxSizeEvent
vEvent( wxSize( nX
949 ,m_frameStatusBar
->GetId()
952 vEvent
.SetEventObject(m_frameStatusBar
);
953 m_frameStatusBar
->OnSize(vEvent
);
955 #endif // wxUSE_NATIVE_STATUSBAR
960 #endif // wxUSE_TOOLBAR
962 bProcessed
= wxWindow::HandleSize( nX
968 } // end of wxFrame::HandleSize
970 bool wxFrame::HandleCommand( WXWORD nId
,
977 // In case it's e.g. a toolbar.
979 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
982 return pWin
->OS2Command( nCmd
, nId
);
986 // Handle here commands from menus and accelerators
988 if (nCmd
== CMDSRC_MENU
|| nCmd
== CMDSRC_ACCELERATOR
)
990 #if wxUSE_MENUS_NATIVE
991 if (wxCurrentPopupMenu
)
993 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
995 wxCurrentPopupMenu
= NULL
;
997 return pPopupMenu
->OS2Command( nCmd
, nId
);
1001 if (ProcessCommand(nId
))
1007 } // end of wxFrame::HandleCommand
1009 bool wxFrame::HandleMenuSelect( WXWORD nItem
,
1018 rc
= ::WinSendMsg(hMenu
, MM_QUERYITEM
, MPFROM2SHORT(nItem
, TRUE
), (MPARAM
)&mItem
);
1020 if(rc
&& !(mItem
.afStyle
& (MIS_SUBMENU
| MIS_SEPARATOR
)))
1022 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nItem
);
1024 vEvent
.SetEventObject(this);
1025 GetEventHandler()->ProcessEvent(vEvent
); // return value would be ignored by PM
1029 DoGiveHelp(wxEmptyString
, false);
1034 } // end of wxFrame::HandleMenuSelect
1036 // ---------------------------------------------------------------------------
1037 // Main Frame window proc
1038 // ---------------------------------------------------------------------------
1039 MRESULT EXPENTRY
wxFrameMainWndProc( HWND hWnd
,
1044 MRESULT rc
= (MRESULT
)0;
1045 bool bProcessed
= false;
1046 wxFrame
* pWnd
= NULL
;
1048 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1051 case WM_QUERYFRAMECTLCOUNT
:
1052 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1054 USHORT uItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1056 rc
= MRFROMSHORT(uItemCount
);
1060 case WM_FORMATFRAME
:
1061 /////////////////////////////////////////////////////////////////////////////////
1062 // Applications that subclass frame controls may find that the frame is already
1063 // subclassed the number of frame controls is variable.
1064 // The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
1065 // subclassed by calling the previous window procedure and modifying its result.
1066 ////////////////////////////////////////////////////////////////////////////////
1078 pSWP
= (PSWP
)PVOIDFROMMP(wParam
);
1079 nItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1080 if(pWnd
->m_frameStatusBar
)
1082 ::WinQueryWindowRect(pWnd
->m_frameStatusBar
->GetHWND(), &vRstb
);
1083 pWnd
->m_frameStatusBar
->GetSize(NULL
, &nHeight
);
1085 if(pWnd
->m_frameToolBar
)
1087 ::WinQueryWindowRect(pWnd
->m_frameToolBar
->GetHWND(), &vRtlb
);
1088 pWnd
->m_frameToolBar
->GetSize(&nWidth
, &nHeight2
);
1090 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1091 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1092 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1093 ::WinMapWindowPoints(HWND_DESKTOP
, pWnd
->m_hFrame
, (PPOINTL
)&vRectl
, 2);
1094 for(i
= 0; i
< nItemCount
; i
++)
1096 if(pWnd
->m_hWnd
&& pSWP
[i
].hwnd
== pWnd
->m_hWnd
)
1098 if (pWnd
->m_frameToolBar
&& pWnd
->m_frameToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
1100 pSWP
[i
].x
= vRectl
.xLeft
;
1101 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1102 pSWP
[i
].cx
= vRectl
.xRight
- vRectl
.xLeft
;
1103 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- (nHeight
+ nHeight2
);
1107 pSWP
[i
].x
= vRectl
.xLeft
+ nWidth
;
1108 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1109 pSWP
[i
].cx
= vRectl
.xRight
- (vRectl
.xLeft
+ nWidth
);
1110 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- nHeight
;
1112 pSWP
[i
].fl
= SWP_SIZE
| SWP_MOVE
| SWP_SHOW
;
1113 pSWP
[i
].hwndInsertBehind
= HWND_TOP
;
1117 rc
= MRFROMSHORT(nItemCount
);
1122 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1123 rc
= pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
);
1125 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1128 } // end of wxFrameMainWndProc
1130 MRESULT EXPENTRY
wxFrameWndProc(
1138 // Trace all ulMsgs - useful for the debugging
1141 wxFrame
* pWnd
= NULL
;
1143 parentHwnd
= WinQueryWindow(hWnd
,QW_PARENT
);
1144 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1147 // When we get the first message for the HWND we just created, we associate
1148 // it with wxWindow stored in wxWndHook
1151 MRESULT rc
= (MRESULT
)0;
1154 // Stop right here if we don't have a valid handle in our wxWindow object.
1156 if (pWnd
&& !pWnd
->GetHWND())
1158 pWnd
->SetHWND((WXHWND
) hWnd
);
1159 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
1165 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
1167 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1170 } // end of wxFrameWndProc
1172 MRESULT
wxFrame::OS2WindowProc( WXUINT uMessage
,
1177 bool bProcessed
= false;
1183 // If we can't close, tell the system that we processed the
1184 // message - otherwise it would close us
1186 bProcessed
= !Close();
1190 bProcessed
= HandlePaint();
1191 mRc
= (MRESULT
)FALSE
;
1194 case WM_ERASEBACKGROUND
:
1196 // Returning TRUE to requests PM to paint the window background
1197 // in SYSCLR_WINDOW. We capture this here because the PS returned
1198 // in Frames is the PS for the whole frame, which we can't really
1199 // use at all. If you want to paint a different background, do it
1200 // in an OnPaint using a wxPaintDC.
1202 mRc
= (MRESULT
)(TRUE
);
1211 UnpackCommand( (WXWPARAM
)wParam
1218 bProcessed
= HandleCommand( wId
1231 UnpackMenuSelect( wParam
1237 bProcessed
= HandleMenuSelect( wItem
1241 mRc
= (MRESULT
)TRUE
;
1247 SHORT nScxnew
= SHORT1FROMMP(lParam
); // New horizontal size.
1248 SHORT nScynew
= SHORT2FROMMP(lParam
); // New vertical size.
1250 lParam
= MRFROM2SHORT( nScxnew
- 20
1254 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1255 mRc
= (MRESULT
)FALSE
;
1258 case CM_QUERYDRAGIMAGE
:
1260 const wxIcon
& vIcon
= GetIcon();
1264 hIcon
= (HPOINTER
)::WinSendMsg(GetHWND(), WM_QUERYICON
, 0L, 0L);
1266 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1267 mRc
= (MRESULT
)hIcon
;
1268 bProcessed
= mRc
!= 0;
1274 mRc
= wxWindow::OS2WindowProc( uMessage
1278 return (MRESULT
)mRc
;
1279 } // wxFrame::OS2WindowProc
1281 void wxFrame::SetClient(WXHWND
WXUNUSED(c_Hwnd
))
1283 // Duh...nothing to do under OS/2
1286 void wxFrame::SetClient( wxWindow
* pWindow
)
1288 wxWindow
* pOldClient
= this->GetClient();
1289 bool bClientHasFocus
= pOldClient
&& (pOldClient
== wxWindow::FindFocus());
1291 if(pOldClient
== pWindow
) // nothing to do
1293 if(pWindow
== NULL
) // just need to remove old client
1295 if(pOldClient
== NULL
) // nothing to do
1298 if(bClientHasFocus
)
1301 pOldClient
->Enable( false );
1302 pOldClient
->Show( false );
1303 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1304 // to avoid OS/2 bug need to update frame
1305 ::WinSendMsg((HWND
)this->GetFrame(), WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1310 // Else need to change client
1315 ::WinEnableWindowUpdate((HWND
)GetHWND(), FALSE
);
1318 pOldClient
->Enable(false);
1319 pOldClient
->Show(false);
1320 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1322 pWindow
->Reparent(this);
1323 ::WinSetWindowUShort(pWindow
->GetHWND(), QWS_ID
, FID_CLIENT
);
1324 ::WinEnableWindowUpdate((HWND
)GetHWND(), TRUE
);
1326 pWindow
->Show(); // ensure client is showing
1327 if( this->IsShown() )
1330 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1334 wxWindow
* wxFrame::GetClient()
1336 return wxFindWinFromHandle((WXHWND
)::WinWindowFromID(m_hFrame
, FID_CLIENT
));
1339 void wxFrame::SendSizeEvent()
1343 RECTL vRect
= wxGetWindowRect(GetHwnd());
1345 ::WinPostMsg( GetHwnd()
1347 ,MPFROM2SHORT( vRect
.xRight
- vRect
.xLeft
1348 ,vRect
.xRight
- vRect
.xLeft
1350 ,MPFROM2SHORT( vRect
.yTop
- vRect
.yBottom
1351 ,vRect
.yTop
- vRect
.yBottom