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"
34 #include "wx/os2/private.h"
37 #include "wx/statusbr.h"
38 #include "wx/generic/statusbr.h"
39 #endif // wxUSE_STATUSBAR
42 #include "wx/toolbar.h"
43 #endif // wxUSE_TOOLBAR
45 #include "wx/menuitem.h"
47 // ----------------------------------------------------------------------------
49 // ----------------------------------------------------------------------------
51 extern wxList WXDLLEXPORT wxPendingDelete
;
53 #if wxUSE_MENUS_NATIVE
54 extern wxMenu
*wxCurrentPopupMenu
;
57 // ----------------------------------------------------------------------------
59 // ----------------------------------------------------------------------------
61 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
62 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
65 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
67 // ============================================================================
69 // ============================================================================
71 // ----------------------------------------------------------------------------
72 // static class members
73 // ----------------------------------------------------------------------------
76 #if wxUSE_NATIVE_STATUSBAR
77 bool wxFrame::m_bUseNativeStatusBar
= true;
79 bool wxFrame::m_bUseNativeStatusBar
= false;
82 #endif //wxUSE_STATUSBAR
84 // ----------------------------------------------------------------------------
85 // creation/destruction
86 // ----------------------------------------------------------------------------
90 m_nFsStatusBarFields
= 0;
91 m_nFsStatusBarHeight
= 0;
92 m_nFsToolBarHeight
= 0;
94 m_bWasMinimized
= false;
97 m_frameMenuBar
= NULL
;
98 m_frameToolBar
= NULL
;
99 m_frameStatusBar
= NULL
;
101 m_hTitleBar
= NULLHANDLE
;
102 m_hHScroll
= NULLHANDLE
;
103 m_hVScroll
= NULLHANDLE
;
108 memset(&m_vSwpTitleBar
, 0, sizeof(SWP
));
109 memset(&m_vSwpMenuBar
, 0, sizeof(SWP
));
110 memset(&m_vSwpHScroll
, 0, sizeof(SWP
));
111 memset(&m_vSwpVScroll
, 0, sizeof(SWP
));
112 memset(&m_vSwpStatusBar
, 0, sizeof(SWP
));
113 memset(&m_vSwpToolBar
, 0, sizeof(SWP
));
116 } // end of wxFrame::Init
118 bool wxFrame::Create( wxWindow
* pParent
,
120 const wxString
& rsTitle
,
124 const wxString
& rsName
)
126 if (!wxTopLevelWindow::Create( pParent
136 } // end of wxFrame::Create
140 m_isBeingDeleted
= true;
142 } // end of wxFrame::~wxFrame
145 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
147 void wxFrame::DoGetClientSize(
152 wxTopLevelWindow::DoGetClientSize( pX
156 // No need to use statusbar code as in WIN32 as the FORMATFRAME
157 // window procedure ensures PM knows about the new frame client
158 // size internally. A ::WinQueryWindowRect (that is called in
159 // wxWindow's GetClient size from above) is all that is needed!
161 } // end of wxFrame::DoGetClientSize
164 // Set the client size (i.e. leave the calculation of borders etc.
167 void wxFrame::DoSetClientSize(
173 // Statusbars are not part of the OS/2 Client but parent frame
174 // so no statusbar consideration
176 wxTopLevelWindow::DoSetClientSize( nWidth
179 } // end of wxFrame::DoSetClientSize
181 // ----------------------------------------------------------------------------
182 // wxFrame: various geometry-related functions
183 // ----------------------------------------------------------------------------
185 void wxFrame::Raise()
187 wxFrameBase::Raise();
188 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
199 wxStatusBar
* wxFrame::OnCreateStatusBar(
203 , const wxString
& rName
206 wxStatusBar
* pStatusBar
= NULL
;
209 pStatusBar
= wxFrameBase::OnCreateStatusBar( nNumber
218 wxClientDC
vDC(pStatusBar
);
222 // Set the height according to the font and the border size
224 vDC
.SetFont(pStatusBar
->GetFont()); // Screws up the menues for some reason
225 vDC
.GetTextExtent( wxT("X")
230 int nHeight
= ((11 * nY
) / 10 + 2 * pStatusBar
->GetBorderY());
232 pStatusBar
->SetSize( wxDefaultCoord
238 ::WinSetParent( pStatusBar
->GetHWND(), m_hFrame
, FALSE
);
239 ::WinSetOwner( pStatusBar
->GetHWND(), m_hFrame
);
243 if(::WinIsWindowShowing(m_hFrame
))
244 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
247 } // end of wxFrame::OnCreateStatusBar
249 void wxFrame::PositionStatusBar()
256 // Native status bar positions itself
258 if (m_frameStatusBar
)
267 ::WinQueryWindowRect(m_hFrame
, &vRect
);
269 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
271 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
272 nWidth
= vRect
.xRight
- vRect
.xLeft
;
273 nY
= nY
- (vRect
.yBottom
- vFRect
.yBottom
);
275 m_frameStatusBar
->GetSize( &nStatbarWidth
279 nY
= nY
- nStatbarHeight
;
281 // Since we wish the status bar to be directly under the client area,
282 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
284 m_frameStatusBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
289 if (!::WinQueryWindowPos(m_frameStatusBar
->GetHWND(), &vSwp
))
291 vError
= ::WinGetLastError(vHabmain
);
292 sError
= wxPMErrorToStr(vError
);
293 wxLogError(_T("Error setting parent for StatusBar. Error: %s\n"), sError
.c_str());
297 } // end of wxFrame::PositionStatusBar
298 #endif // wxUSE_STATUSBAR
301 wxToolBar
* wxFrame::OnCreateToolBar( long lStyle
, wxWindowID vId
, const wxString
& rsName
)
303 wxToolBar
* pToolBar
= wxFrameBase::OnCreateToolBar( lStyle
308 ::WinSetParent( pToolBar
->GetHWND(), m_hFrame
, FALSE
);
309 ::WinSetOwner( pToolBar
->GetHWND(), m_hFrame
);
311 } // end of WinGuiBase_CFrame::OnCreateToolBar
314 #if wxUSE_MENUS_NATIVE
315 void wxFrame::DetachMenuBar()
319 m_frameMenuBar
->Detach();
320 m_frameMenuBar
= NULL
;
322 } // end of wxFrame::DetachMenuBar
324 void wxFrame::SetMenuBar(
335 // Actually remove the menu from the frame
337 m_hMenu
= (WXHMENU
)0;
338 InternalSetMenuBar();
340 else // set new non NULL menu bar
342 m_frameMenuBar
= NULL
;
345 // Can set a menubar several times.
346 // TODO: how to prevent a memory leak if you have a currently-unattached
347 // menubar? wxWidgets assumes that the frame will delete the menu (otherwise
348 // there are problems for MDI).
350 if (pMenuBar
->GetHMenu())
352 m_hMenu
= pMenuBar
->GetHMenu();
357 m_hMenu
= pMenuBar
->Create();
361 InternalSetMenuBar();
362 m_frameMenuBar
= pMenuBar
;
363 pMenuBar
->Attach((wxFrame
*)this);
365 } // end of wxFrame::SetMenuBar
367 void wxFrame::AttachMenuBar(
371 wxFrameBase::AttachMenuBar(pMenubar
);
373 m_frameMenuBar
= pMenubar
;
378 // Actually remove the menu from the frame
380 m_hMenu
= (WXHMENU
)0;
381 InternalSetMenuBar();
383 else // Set new non NULL menu bar
386 // Can set a menubar several times.
388 if (pMenubar
->GetHMenu())
390 m_hMenu
= pMenubar
->GetHMenu();
394 if (pMenubar
->IsAttached())
397 m_hMenu
= pMenubar
->Create();
402 InternalSetMenuBar();
404 } // end of wxFrame::AttachMenuBar
406 void wxFrame::InternalSetMenuBar()
411 // Set the parent and owner of the menubar to be the frame
413 if (!::WinSetParent(m_hMenu
, m_hFrame
, FALSE
))
415 vError
= ::WinGetLastError(vHabmain
);
416 sError
= wxPMErrorToStr(vError
);
417 wxLogError(_T("Error setting parent for submenu. Error: %s\n"), sError
.c_str());
420 if (!::WinSetOwner(m_hMenu
, m_hFrame
))
422 vError
= ::WinGetLastError(vHabmain
);
423 sError
= wxPMErrorToStr(vError
);
424 wxLogError(_T("Error setting parent for submenu. Error: %s\n"), sError
.c_str());
426 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
427 } // end of wxFrame::InternalSetMenuBar
428 #endif // wxUSE_MENUS_NATIVE
431 // Responds to colour changes, and passes event on to children
433 void wxFrame::OnSysColourChanged(
434 wxSysColourChangedEvent
& rEvent
437 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
441 if (m_frameStatusBar
)
443 wxSysColourChangedEvent vEvent2
;
445 vEvent2
.SetEventObject(m_frameStatusBar
);
446 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
448 #endif //wxUSE_STATUSBAR
451 // Propagate the event to the non-top-level children
453 wxWindow::OnSysColourChanged(rEvent
);
454 } // end of wxFrame::OnSysColourChanged
456 // Pass true to show full screen, false to restore.
457 bool wxFrame::ShowFullScreen( bool bShow
, long lStyle
)
464 m_bFsIsShowing
= true;
468 wxToolBar
* pTheToolBar
= GetToolBar();
469 #endif //wxUSE_TOOLBAR
472 wxStatusBar
* pTheStatusBar
= GetStatusBar();
473 #endif //wxUSE_STATUSBAR
479 pTheToolBar
->GetSize(&nDummyWidth
, &m_nFsToolBarHeight
);
480 #endif //wxUSE_TOOLBAR
484 pTheStatusBar
->GetSize(&nDummyWidth
, &m_nFsStatusBarHeight
);
485 #endif //wxUSE_STATUSBAR
489 // Zap the toolbar, menubar, and statusbar
491 if ((lStyle
& wxFULLSCREEN_NOTOOLBAR
) && pTheToolBar
)
493 pTheToolBar
->SetSize(wxDefaultCoord
,0);
494 pTheToolBar
->Show(false);
496 #endif //wxUSE_TOOLBAR
498 if (lStyle
& wxFULLSCREEN_NOMENUBAR
)
500 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
501 ::WinSetOwner(m_hMenu
, m_hFrame
);
502 ::WinSendMsg((HWND
)m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
507 // Save the number of fields in the statusbar
509 if ((lStyle
& wxFULLSCREEN_NOSTATUSBAR
) && pTheStatusBar
)
511 m_nFsStatusBarFields
= pTheStatusBar
->GetFieldsCount();
512 SetStatusBar((wxStatusBar
*) NULL
);
513 delete pTheStatusBar
;
516 m_nFsStatusBarFields
= 0;
517 #endif //wxUSE_STATUSBAR
520 // Zap the frame borders
524 // Save the 'normal' window style
526 m_lFsOldWindowStyle
= ::WinQueryWindowULong(m_hFrame
, QWL_STYLE
);
529 // Save the old position, width & height, maximize state
531 m_vFsOldSize
= GetRect();
532 m_bFsIsMaximized
= IsMaximized();
535 // Decide which window style flags to turn off
537 LONG lNewStyle
= m_lFsOldWindowStyle
;
540 if (lStyle
& wxFULLSCREEN_NOBORDER
)
541 lOffFlags
|= FCF_BORDER
;
542 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
543 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
545 lNewStyle
&= (~lOffFlags
);
548 // Change our window style to be compatible with full-screen mode
550 ::WinSetWindowULong((HWND
)m_hFrame
, QWL_STYLE
, (ULONG
)lNewStyle
);
553 // Resize to the size of the desktop
559 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
560 nWidth
= vRect
.xRight
- vRect
.xLeft
;
562 // Remember OS/2 is backwards!
564 nHeight
= vRect
.yTop
- vRect
.yBottom
;
566 SetSize( nWidth
, nHeight
);
569 // Now flush the window style cache and actually go full-screen
571 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
580 wxSize
sz( nWidth
, nHeight
);
581 wxSizeEvent
vEvent( sz
, GetId() );
583 GetEventHandler()->ProcessEvent(vEvent
);
591 m_bFsIsShowing
= false;
594 wxToolBar
* pTheToolBar
= GetToolBar();
597 // Restore the toolbar, menubar, and statusbar
599 if (pTheToolBar
&& (m_lFsStyle
& wxFULLSCREEN_NOTOOLBAR
))
601 pTheToolBar
->SetSize(wxDefaultCoord
, m_nFsToolBarHeight
);
602 pTheToolBar
->Show(true);
604 #endif //wxUSE_TOOLBAR
607 if ((m_lFsStyle
& wxFULLSCREEN_NOSTATUSBAR
) && (m_nFsStatusBarFields
> 0))
609 CreateStatusBar(m_nFsStatusBarFields
);
610 // PositionStatusBar();
612 #endif //wxUSE_STATUSBAR
614 if ((m_lFsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
616 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
617 ::WinSetOwner(m_hMenu
, m_hFrame
);
618 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
620 Maximize(m_bFsIsMaximized
);
622 ::WinSetWindowULong( m_hFrame
624 ,(ULONG
)m_lFsOldWindowStyle
626 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
635 return wxFrameBase::ShowFullScreen(bShow
, lStyle
);
636 } // end of wxFrame::ShowFullScreen
641 // ----------------------------------------------------------------------------
642 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
643 // from the client area, so the client area is what's really available for the
645 // ----------------------------------------------------------------------------
647 // Checks if there is a toolbar, and returns the first free client position
648 wxPoint
wxFrame::GetClientAreaOrigin() const
650 wxPoint vPoint
= wxTopLevelWindow::GetClientAreaOrigin();
653 // In OS/2 the toolbar and statusbar are frame extensions so there is no
654 // adjustment. The client is supposedly resized for a toolbar in OS/2
655 // as it is for the status bar.
658 } // end of wxFrame::GetClientAreaOrigin
660 // ----------------------------------------------------------------------------
661 // tool/status bar stuff
662 // ----------------------------------------------------------------------------
666 wxToolBar
* wxFrame::CreateToolBar(
669 , const wxString
& rName
672 if (wxFrameBase::CreateToolBar( lStyle
679 return m_frameToolBar
;
680 } // end of wxFrame::CreateToolBar
682 void wxFrame::PositionToolBar()
684 wxToolBar
* pToolBar
= GetToolBar();
697 ::WinQueryWindowRect(m_hFrame
, &vRect
);
698 vPos
.y
= (wxCoord
)vRect
.yTop
;
699 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
701 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
703 vPos
.y
= (wxCoord
)(vFRect
.yTop
- vRect
.yTop
);
704 pToolBar
->GetSize( &vTWidth
708 if (pToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
710 vWidth
= (wxCoord
)(vRect
.xRight
- vRect
.xLeft
);
711 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
720 wxCoord vSheight
= 0;
722 if (m_frameStatusBar
)
723 m_frameStatusBar
->GetSize( &vSwidth
726 vHeight
= (wxCoord
)(vRect
.yTop
- vRect
.yBottom
);
727 pToolBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
733 if( ::WinIsWindowShowing(m_hFrame
) )
734 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
735 } // end of wxFrame::PositionToolBar
736 #endif // wxUSE_TOOLBAR
738 // ----------------------------------------------------------------------------
739 // frame state (iconized/maximized/...)
740 // ----------------------------------------------------------------------------
743 // propagate our state change to all child frames: this allows us to emulate X
744 // Windows behaviour where child frames float independently of the parent one
745 // on the desktop, but are iconized/restored with it
747 void wxFrame::IconizeChildFrames( bool WXUNUSED(bIconize
) )
749 // FIXME: Generic MDI does not use Frames for the Childs, so this does _not_
750 // work. Possibly, the right thing is simply to eliminate this
751 // functions and all the calls to it from within this file.
753 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
755 pNode
= pNode
->GetNext() )
757 wxWindow
* pWin
= pNode
->GetData();
758 wxFrame
* pFrame
= wxDynamicCast(pWin
, wxFrame
);
761 #if wxUSE_MDI_ARCHITECTURE
762 && !wxDynamicCast(pFrame
, wxMDIChildFrame
)
763 #endif // wxUSE_MDI_ARCHITECTURE
767 // We don't want to restore the child frames which had been
768 // iconized even before we were iconized, so save the child frame
769 // status when iconizing the parent frame and check it when
774 pFrame
->m_bWasMinimized
= pFrame
->IsIconized();
778 // This test works for both iconizing and restoring
780 if (!pFrame
->m_bWasMinimized
)
781 pFrame
->Iconize(bIconize
);
785 } // end of wxFrame::IconizeChildFrames
787 WXHICON
wxFrame::GetDefaultIcon() const
789 return (WXHICON
)(wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
790 : wxDEFAULT_FRAME_ICON
);
792 // ===========================================================================
793 // message processing
794 // ===========================================================================
796 // ---------------------------------------------------------------------------
798 // ---------------------------------------------------------------------------
799 bool wxFrame::OS2TranslateMessage( WXMSG
* pMsg
)
802 // try the menu bar accels
804 wxMenuBar
* pMenuBar
= GetMenuBar();
809 #if wxUSE_ACCEL && wxUSE_MENUS_NATIVE
810 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
811 return rAcceleratorTable
.Translate(GetHWND(), pMsg
);
815 } // end of wxFrame::OS2TranslateMessage
817 // ---------------------------------------------------------------------------
818 // our private (non virtual) message handlers
819 // ---------------------------------------------------------------------------
820 bool wxFrame::HandlePaint()
824 if (::WinQueryUpdateRect(GetHWND(), &vRect
))
829 // Icons in PM are the same as "pointers"
831 const wxIcon
& vIcon
= GetIcon();
835 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
837 hIcon
= (HPOINTER
)m_hDefaultIcon
;
840 // Hold a pointer to the dc so long as the OnPaint() message
841 // is being processed
844 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
847 // Erase background before painting or we get white background
849 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
855 ::WinQueryWindowRect(GetHwnd(), &vRect3
);
857 static const int nIconWidth
= 32;
858 static const int nIconHeight
= 32;
859 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
860 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
862 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
868 if (!wxWindow::HandlePaint())
873 hPS
= ::WinBeginPaint( GetHwnd()
879 ::GpiCreateLogColorTable( hPS
883 ,(LONG
)wxTheColourDatabase
->m_nSize
884 ,(PLONG
)wxTheColourDatabase
->m_palTable
886 ::GpiCreateLogColorTable( hPS
896 ,GetBackgroundColour().GetPixel()
905 } // end of wxFrame::HandlePaint
907 bool wxFrame::HandleSize( int nX
, int nY
, WXUINT nId
)
909 bool bProcessed
= false;
915 // Only do it it if we were iconized before, otherwise resizing the
916 // parent frame has a curious side effect of bringing it under it's
922 // restore all child frames too
924 IconizeChildFrames(false);
925 (void)SendIconizeEvent(false);
937 // Iconize all child frames too
939 IconizeChildFrames(true);
940 (void)SendIconizeEvent();
948 // forward WM_SIZE to status bar control
950 #if wxUSE_NATIVE_STATUSBAR
951 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
953 wxSizeEvent
vEvent( wxSize( nX
956 ,m_frameStatusBar
->GetId()
959 vEvent
.SetEventObject(m_frameStatusBar
);
960 m_frameStatusBar
->OnSize(vEvent
);
962 #endif // wxUSE_NATIVE_STATUSBAR
967 #endif // wxUSE_TOOLBAR
969 bProcessed
= wxWindow::HandleSize( nX
975 } // end of wxFrame::HandleSize
977 bool wxFrame::HandleCommand( WXWORD nId
,
984 // In case it's e.g. a toolbar.
986 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
989 return pWin
->OS2Command( nCmd
, nId
);
993 // Handle here commands from menus and accelerators
995 if (nCmd
== CMDSRC_MENU
|| nCmd
== CMDSRC_ACCELERATOR
)
997 #if wxUSE_MENUS_NATIVE
998 if (wxCurrentPopupMenu
)
1000 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1002 wxCurrentPopupMenu
= NULL
;
1004 return pPopupMenu
->OS2Command( nCmd
, nId
);
1008 if (ProcessCommand(nId
))
1014 } // end of wxFrame::HandleCommand
1016 bool wxFrame::HandleMenuSelect( WXWORD nItem
,
1025 rc
= ::WinSendMsg(hMenu
, MM_QUERYITEM
, MPFROM2SHORT(nItem
, TRUE
), (MPARAM
)&mItem
);
1027 if(rc
&& !(mItem
.afStyle
& (MIS_SUBMENU
| MIS_SEPARATOR
)))
1029 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nItem
);
1031 vEvent
.SetEventObject(this);
1032 GetEventHandler()->ProcessEvent(vEvent
); // return value would be ignored by PM
1036 DoGiveHelp(wxEmptyString
, false);
1041 } // end of wxFrame::HandleMenuSelect
1043 // ---------------------------------------------------------------------------
1044 // Main Frame window proc
1045 // ---------------------------------------------------------------------------
1046 MRESULT EXPENTRY
wxFrameMainWndProc( HWND hWnd
,
1051 MRESULT rc
= (MRESULT
)0;
1052 bool bProcessed
= false;
1053 wxFrame
* pWnd
= NULL
;
1055 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1058 case WM_QUERYFRAMECTLCOUNT
:
1059 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1061 USHORT uItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1063 rc
= MRFROMSHORT(uItemCount
);
1067 case WM_FORMATFRAME
:
1068 /////////////////////////////////////////////////////////////////////////////////
1069 // Applications that subclass frame controls may find that the frame is already
1070 // subclassed the number of frame controls is variable.
1071 // The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
1072 // subclassed by calling the previous window procedure and modifying its result.
1073 ////////////////////////////////////////////////////////////////////////////////
1085 pSWP
= (PSWP
)PVOIDFROMMP(wParam
);
1086 nItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1087 if(pWnd
->m_frameStatusBar
)
1089 ::WinQueryWindowRect(pWnd
->m_frameStatusBar
->GetHWND(), &vRstb
);
1090 pWnd
->m_frameStatusBar
->GetSize(NULL
, &nHeight
);
1092 if(pWnd
->m_frameToolBar
)
1094 ::WinQueryWindowRect(pWnd
->m_frameToolBar
->GetHWND(), &vRtlb
);
1095 pWnd
->m_frameToolBar
->GetSize(&nWidth
, &nHeight2
);
1097 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1098 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1099 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1100 ::WinMapWindowPoints(HWND_DESKTOP
, pWnd
->m_hFrame
, (PPOINTL
)&vRectl
, 2);
1101 for(i
= 0; i
< nItemCount
; i
++)
1103 if(pWnd
->m_hWnd
&& pSWP
[i
].hwnd
== pWnd
->m_hWnd
)
1105 if (pWnd
->m_frameToolBar
&& pWnd
->m_frameToolBar
->GetWindowStyleFlag() & wxTB_HORIZONTAL
)
1107 pSWP
[i
].x
= vRectl
.xLeft
;
1108 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1109 pSWP
[i
].cx
= vRectl
.xRight
- vRectl
.xLeft
;
1110 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- (nHeight
+ nHeight2
);
1114 pSWP
[i
].x
= vRectl
.xLeft
+ nWidth
;
1115 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1116 pSWP
[i
].cx
= vRectl
.xRight
- (vRectl
.xLeft
+ nWidth
);
1117 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- nHeight
;
1119 pSWP
[i
].fl
= SWP_SIZE
| SWP_MOVE
| SWP_SHOW
;
1120 pSWP
[i
].hwndInsertBehind
= HWND_TOP
;
1124 rc
= MRFROMSHORT(nItemCount
);
1129 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1130 rc
= pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
);
1132 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1135 } // end of wxFrameMainWndProc
1137 MRESULT EXPENTRY
wxFrameWndProc(
1145 // Trace all ulMsgs - useful for the debugging
1148 wxFrame
* pWnd
= NULL
;
1150 parentHwnd
= WinQueryWindow(hWnd
,QW_PARENT
);
1151 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1154 // When we get the first message for the HWND we just created, we associate
1155 // it with wxWindow stored in wxWndHook
1158 MRESULT rc
= (MRESULT
)0;
1161 // Stop right here if we don't have a valid handle in our wxWindow object.
1163 if (pWnd
&& !pWnd
->GetHWND())
1165 pWnd
->SetHWND((WXHWND
) hWnd
);
1166 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
1172 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
1174 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1177 } // end of wxFrameWndProc
1179 MRESULT
wxFrame::OS2WindowProc( WXUINT uMessage
,
1184 bool bProcessed
= false;
1190 // If we can't close, tell the system that we processed the
1191 // message - otherwise it would close us
1193 bProcessed
= !Close();
1197 bProcessed
= HandlePaint();
1198 mRc
= (MRESULT
)FALSE
;
1201 case WM_ERASEBACKGROUND
:
1203 // Returning TRUE to requests PM to paint the window background
1204 // in SYSCLR_WINDOW. We capture this here because the PS returned
1205 // in Frames is the PS for the whole frame, which we can't really
1206 // use at all. If you want to paint a different background, do it
1207 // in an OnPaint using a wxPaintDC.
1209 mRc
= (MRESULT
)(TRUE
);
1218 UnpackCommand( (WXWPARAM
)wParam
1225 bProcessed
= HandleCommand( wId
1238 UnpackMenuSelect( wParam
1244 bProcessed
= HandleMenuSelect( wItem
1248 mRc
= (MRESULT
)TRUE
;
1254 SHORT nScxnew
= SHORT1FROMMP(lParam
); // New horizontal size.
1255 SHORT nScynew
= SHORT2FROMMP(lParam
); // New vertical size.
1257 lParam
= MRFROM2SHORT( nScxnew
- 20
1261 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1262 mRc
= (MRESULT
)FALSE
;
1265 case CM_QUERYDRAGIMAGE
:
1267 const wxIcon
& vIcon
= GetIcon();
1271 hIcon
= (HPOINTER
)::WinSendMsg(GetHWND(), WM_QUERYICON
, 0L, 0L);
1273 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1274 mRc
= (MRESULT
)hIcon
;
1275 bProcessed
= mRc
!= 0;
1281 mRc
= wxWindow::OS2WindowProc( uMessage
1285 return (MRESULT
)mRc
;
1286 } // wxFrame::OS2WindowProc
1288 void wxFrame::SetClient(WXHWND
WXUNUSED(c_Hwnd
))
1290 // Duh...nothing to do under OS/2
1293 void wxFrame::SetClient( wxWindow
* pWindow
)
1295 wxWindow
* pOldClient
= this->GetClient();
1296 bool bClientHasFocus
= pOldClient
&& (pOldClient
== wxWindow::FindFocus());
1298 if(pOldClient
== pWindow
) // nothing to do
1300 if(pWindow
== NULL
) // just need to remove old client
1302 if(pOldClient
== NULL
) // nothing to do
1305 if(bClientHasFocus
)
1308 pOldClient
->Enable( false );
1309 pOldClient
->Show( false );
1310 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1311 // to avoid OS/2 bug need to update frame
1312 ::WinSendMsg((HWND
)this->GetFrame(), WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1317 // Else need to change client
1322 ::WinEnableWindowUpdate((HWND
)GetHWND(), FALSE
);
1325 pOldClient
->Enable(false);
1326 pOldClient
->Show(false);
1327 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1329 pWindow
->Reparent(this);
1330 ::WinSetWindowUShort(pWindow
->GetHWND(), QWS_ID
, FID_CLIENT
);
1331 ::WinEnableWindowUpdate((HWND
)GetHWND(), TRUE
);
1333 pWindow
->Show(); // ensure client is showing
1334 if( this->IsShown() )
1337 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1341 wxWindow
* wxFrame::GetClient()
1343 return wxFindWinFromHandle((WXHWND
)::WinWindowFromID(m_hFrame
, FID_CLIENT
));
1346 void wxFrame::SendSizeEvent()
1350 RECTL vRect
= wxGetWindowRect(GetHwnd());
1352 ::WinPostMsg( GetHwnd()
1354 ,MPFROM2SHORT( vRect
.xRight
- vRect
.xLeft
1355 ,vRect
.xRight
- vRect
.xLeft
1357 ,MPFROM2SHORT( vRect
.yTop
- vRect
.yBottom
1358 ,vRect
.yTop
- vRect
.yBottom