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_ACTIVATE(wxFrame::OnActivate
)
71 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
74 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
76 // ============================================================================
78 // ============================================================================
80 // ----------------------------------------------------------------------------
81 // static class members
82 // ----------------------------------------------------------------------------
85 #if wxUSE_NATIVE_STATUSBAR
86 bool wxFrame::m_bUseNativeStatusBar
= TRUE
;
88 bool wxFrame::m_bUseNativeStatusBar
= FALSE
;
91 #endif //wxUSE_STATUSBAR
93 // ----------------------------------------------------------------------------
94 // creation/destruction
95 // ----------------------------------------------------------------------------
99 m_nFsStatusBarFields
= 0;
100 m_nFsStatusBarHeight
= 0;
101 m_nFsToolBarHeight
= 0;
103 m_bWasMinimized
= FALSE
;
104 m_pWinLastFocused
= NULL
;
107 m_frameMenuBar
= NULL
;
108 m_frameToolBar
= NULL
;
109 m_frameStatusBar
= NULL
;
111 m_hTitleBar
= NULLHANDLE
;
112 m_hHScroll
= NULLHANDLE
;
113 m_hVScroll
= NULLHANDLE
;
118 memset(&m_vSwpTitleBar
, 0, sizeof(SWP
));
119 memset(&m_vSwpMenuBar
, 0, sizeof(SWP
));
120 memset(&m_vSwpHScroll
, 0, sizeof(SWP
));
121 memset(&m_vSwpVScroll
, 0, sizeof(SWP
));
122 memset(&m_vSwpStatusBar
, 0, sizeof(SWP
));
123 memset(&m_vSwpToolBar
, 0, sizeof(SWP
));
126 } // end of wxFrame::Init
128 bool wxFrame::Create(
131 , const wxString
& rsTitle
132 , const wxPoint
& rPos
133 , const wxSize
& rSize
135 , const wxString
& rsName
138 if (!wxTopLevelWindow::Create( pParent
147 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
148 wxModelessWindows
.Append(this);
150 } // end of wxFrame::Create
154 m_isBeingDeleted
= TRUE
;
156 } // end of wxFrame::~wxFrame
159 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
161 void wxFrame::DoGetClientSize(
166 wxTopLevelWindow::DoGetClientSize( pX
170 // No need to use statusbar code as in WIN32 as the FORMATFRAME
171 // window procedure ensures PM knows about the new frame client
172 // size internally. A ::WinQueryWindowRect (that is called in
173 // wxWindow's GetClient size from above) is all that is needed!
175 } // end of wxFrame::DoGetClientSize
178 // Set the client size (i.e. leave the calculation of borders etc.
181 void wxFrame::DoSetClientSize(
186 wxStatusBar
* pStatusBar
= GetStatusBar();
189 // Statusbars are not part of the OS/2 Client but parent frame
190 // so no statusbar consideration
192 wxTopLevelWindow::DoSetClientSize( nWidth
195 } // end of wxFrame::DoSetClientSize
197 // ----------------------------------------------------------------------------
198 // wxFrame: various geometry-related functions
199 // ----------------------------------------------------------------------------
201 void wxFrame::Raise()
203 wxFrameBase::Raise();
204 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
214 // generate an artificial resize event
215 void wxFrame::SendSizeEvent()
219 RECTL vRect
= wxGetWindowRect(GetHwnd());
221 (void)::WinPostMsg( m_hFrame
223 ,MPFROM2SHORT(vRect
.xRight
- vRect
.xLeft
, vRect
.yTop
- vRect
.yBottom
)
224 ,MPFROM2SHORT(vRect
.xRight
- vRect
.xLeft
, vRect
.yTop
- vRect
.yBottom
)
230 wxStatusBar
* wxFrame::OnCreateStatusBar(
234 , const wxString
& rName
237 wxStatusBar
* pStatusBar
= NULL
;
242 pStatusBar
= wxFrameBase::OnCreateStatusBar( nNumber
251 wxClientDC
vDC(pStatusBar
);
255 // Set the height according to the font and the border size
257 vDC
.SetFont(pStatusBar
->GetFont()); // Screws up the menues for some reason
258 vDC
.GetTextExtent( "X"
263 int nHeight
= ((11 * nY
) / 10 + 2 * pStatusBar
->GetBorderY());
265 pStatusBar
->SetSize( -1
271 ::WinSetParent( pStatusBar
->GetHWND()
275 ::WinSetOwner( pStatusBar
->GetHWND()
281 if(::WinIsWindowShowing(m_hFrame
))
282 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
285 } // end of wxFrame::OnCreateStatusBar
287 void wxFrame::PositionStatusBar()
294 // Native status bar positions itself
296 if (m_frameStatusBar
)
306 ::WinQueryWindowRect(m_hFrame
, &vRect
);
308 ::WinMapWindowPoints(m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
310 ::WinCalcFrameRect(m_hFrame
, &vRect
, TRUE
);
311 nWidth
= vRect
.xRight
- vRect
.xLeft
;
312 nY
= nY
- (vRect
.yBottom
- vFRect
.yBottom
);
314 m_frameStatusBar
->GetSize( &nStatbarWidth
318 nY
= nY
- nStatbarHeight
;
320 // Since we wish the status bar to be directly under the client area,
321 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
323 m_frameStatusBar
->SetSize( vRect
.xLeft
- vFRect
.xLeft
328 if (!::WinQueryWindowPos(m_frameStatusBar
->GetHWND(), &vSwp
))
330 vError
= ::WinGetLastError(vHabmain
);
331 sError
= wxPMErrorToStr(vError
);
332 wxLogError("Error setting parent for StautsBar. Error: %s\n", sError
);
336 } // end of wxFrame::PositionStatusBar
337 #endif // wxUSE_STATUSBAR
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(
355 HWND hTitlebar
= NULLHANDLE
;
356 HWND hHScroll
= NULLHANDLE
;
357 HWND hVScroll
= NULLHANDLE
;
358 HWND hMenuBar
= NULLHANDLE
;
370 // Actually remove the menu from the frame
372 m_hMenu
= (WXHMENU
)0;
373 InternalSetMenuBar();
375 else // set new non NULL menu bar
377 m_frameMenuBar
= NULL
;
380 // Can set a menubar several times.
381 // TODO: how to prevent a memory leak if you have a currently-unattached
382 // menubar? wxWindows assumes that the frame will delete the menu (otherwise
383 // there are problems for MDI).
385 if (pMenuBar
->GetHMenu())
387 m_hMenu
= pMenuBar
->GetHMenu();
392 m_hMenu
= pMenuBar
->Create();
396 InternalSetMenuBar();
397 m_frameMenuBar
= pMenuBar
;
398 pMenuBar
->Attach((wxFrame
*)this);
400 } // end of wxFrame::SetMenuBar
402 void wxFrame::AttachMenuBar(
406 wxFrameBase::AttachMenuBar(pMenubar
);
408 m_frameMenuBar
= pMenubar
;
413 // Actually remove the menu from the frame
415 m_hMenu
= (WXHMENU
)0;
416 InternalSetMenuBar();
418 else // Set new non NULL menu bar
421 // Can set a menubar several times.
423 if (pMenubar
->GetHMenu())
425 m_hMenu
= pMenubar
->GetHMenu();
429 if (pMenubar
->IsAttached())
432 m_hMenu
= pMenubar
->Create();
437 InternalSetMenuBar();
439 } // end of wxFrame::AttachMenuBar
441 void wxFrame::InternalSetMenuBar()
446 // Set the parent and owner of the menubar to be the frame
448 if (!::WinSetParent(m_hMenu
, m_hFrame
, FALSE
))
450 vError
= ::WinGetLastError(vHabmain
);
451 sError
= wxPMErrorToStr(vError
);
452 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
455 if (!::WinSetOwner(m_hMenu
, m_hFrame
))
457 vError
= ::WinGetLastError(vHabmain
);
458 sError
= wxPMErrorToStr(vError
);
459 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
461 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
462 } // end of wxFrame::InternalSetMenuBar
463 #endif // wxUSE_MENUS_NATIVE
466 // Responds to colour changes, and passes event on to children
468 void wxFrame::OnSysColourChanged(
469 wxSysColourChangedEvent
& rEvent
472 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
476 if (m_frameStatusBar
)
478 wxSysColourChangedEvent vEvent2
;
480 vEvent2
.SetEventObject(m_frameStatusBar
);
481 m_frameStatusBar
->GetEventHandler()->ProcessEvent(vEvent2
);
483 #endif //wxUSE_STATUSBAR
486 // Propagate the event to the non-top-level children
488 wxWindow::OnSysColourChanged(rEvent
);
489 } // end of wxFrame::OnSysColourChanged
491 // Pass TRUE to show full screen, FALSE to restore.
492 bool wxFrame::ShowFullScreen(
502 m_bFsIsShowing
= TRUE
;
506 wxToolBar
* pTheToolBar
= GetToolBar();
507 #endif //wxUSE_TOOLBAR
510 wxStatusBar
* pTheStatusBar
= GetStatusBar();
511 #endif //wxUSE_STATUSBAR
517 pTheToolBar
->GetSize(&nDummyWidth
, &m_nFsToolBarHeight
);
518 #endif //wxUSE_TOOLBAR
522 pTheStatusBar
->GetSize(&nDummyWidth
, &m_nFsStatusBarHeight
);
523 #endif //wxUSE_STATUSBAR
527 // Zap the toolbar, menubar, and statusbar
529 if ((lStyle
& wxFULLSCREEN_NOTOOLBAR
) && pTheToolBar
)
531 pTheToolBar
->SetSize(-1,0);
532 pTheToolBar
->Show(FALSE
);
534 #endif //wxUSE_TOOLBAR
536 if (lStyle
& wxFULLSCREEN_NOMENUBAR
)
538 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
539 ::WinSetOwner(m_hMenu
, m_hFrame
);
540 ::WinSendMsg((HWND
)m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
545 // Save the number of fields in the statusbar
547 if ((lStyle
& wxFULLSCREEN_NOSTATUSBAR
) && pTheStatusBar
)
549 m_nFsStatusBarFields
= pTheStatusBar
->GetFieldsCount();
550 SetStatusBar((wxStatusBar
*) NULL
);
551 delete pTheStatusBar
;
554 m_nFsStatusBarFields
= 0;
555 #endif //wxUSE_STATUSBAR
558 // Zap the frame borders
562 // Save the 'normal' window style
564 m_lFsOldWindowStyle
= ::WinQueryWindowULong(m_hFrame
, QWL_STYLE
);
567 // Save the old position, width & height, maximize state
569 m_vFsOldSize
= GetRect();
570 m_bFsIsMaximized
= IsMaximized();
573 // Decide which window style flags to turn off
575 LONG lNewStyle
= m_lFsOldWindowStyle
;
578 if (lStyle
& wxFULLSCREEN_NOBORDER
)
579 lOffFlags
|= FCF_BORDER
;
580 if (lStyle
& wxFULLSCREEN_NOCAPTION
)
581 lOffFlags
|= (FCF_TASKLIST
| FCF_SYSMENU
);
583 lNewStyle
&= (~lOffFlags
);
586 // Change our window style to be compatible with full-screen mode
588 ::WinSetWindowULong((HWND
)m_hFrame
, QWL_STYLE
, (ULONG
)lNewStyle
);
591 // Resize to the size of the desktop
597 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
598 nWidth
= vRect
.xRight
- vRect
.xLeft
;
600 // Rmember OS/2 is backwards!
602 nHeight
= vRect
.yTop
- vRect
.yBottom
;
609 // Now flush the window style cache and actually go full-screen
611 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
620 wxSizeEvent
vEvent( wxSize( nWidth
626 GetEventHandler()->ProcessEvent(vEvent
);
634 m_bFsIsShowing
= FALSE
;
637 wxToolBar
* pTheToolBar
= GetToolBar();
640 // Restore the toolbar, menubar, and statusbar
642 if (pTheToolBar
&& (m_lFsStyle
& wxFULLSCREEN_NOTOOLBAR
))
644 pTheToolBar
->SetSize(-1, m_nFsToolBarHeight
);
645 pTheToolBar
->Show(TRUE
);
647 #endif //wxUSE_TOOLBAR
650 if ((m_lFsStyle
& wxFULLSCREEN_NOSTATUSBAR
) && (m_nFsStatusBarFields
> 0))
652 CreateStatusBar(m_nFsStatusBarFields
);
653 // PositionStatusBar();
655 #endif //wxUSE_STATUSBAR
657 if ((m_lFsStyle
& wxFULLSCREEN_NOMENUBAR
) && (m_hMenu
!= 0))
659 ::WinSetParent(m_hMenu
, m_hFrame
, FALSE
);
660 ::WinSetOwner(m_hMenu
, m_hFrame
);
661 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
663 Maximize(m_bFsIsMaximized
);
665 ::WinSetWindowULong( m_hFrame
667 ,(ULONG
)m_lFsOldWindowStyle
669 ::WinSetWindowPos( (HWND
) GetParent()->GetHWND()
679 } // end of wxFrame::ShowFullScreen
685 // Default activation behaviour - set the focus for the first child
688 void wxFrame::OnActivate(
689 wxActivateEvent
& rEvent
692 if ( rEvent
.GetActive() )
694 // restore focus to the child which was last focused
695 wxLogTrace(_T("focus"), _T("wxFrame %08x activated."), m_hWnd
);
697 wxWindow
* pParent
= m_pWinLastFocused
? m_pWinLastFocused
->GetParent()
704 wxSetFocusToChild( pParent
711 // Remember the last focused child if it is our child
713 m_pWinLastFocused
= FindFocus();
715 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
717 pNode
= pNode
->GetNext())
719 // FIXME all this is totally bogus - we need to do the same as wxPanel,
720 // but how to do it without duplicating the code?
723 wxWindow
* pChild
= pNode
->GetData();
725 if (!pChild
->IsTopLevel()
727 && !wxDynamicCast(pChild
, wxToolBar
)
728 #endif // wxUSE_TOOLBAR
730 && !wxDynamicCast(pChild
, wxStatusBar
)
731 #endif // wxUSE_STATUSBAR
739 } // end of wxFrame::OnActivate
741 // ----------------------------------------------------------------------------
742 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
743 // from the client area, so the client area is what's really available for the
745 // ----------------------------------------------------------------------------
747 // Checks if there is a toolbar, and returns the first free client position
748 wxPoint
wxFrame::GetClientAreaOrigin() const
750 wxPoint
vPoint(0, 0);
758 GetToolBar()->GetSize( &nWidth
762 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
768 // PM is backwards from windows
772 #endif //wxUSE_TOOLBAR
774 } // end of wxFrame::GetClientAreaOrigin
776 // ----------------------------------------------------------------------------
777 // tool/status bar stuff
778 // ----------------------------------------------------------------------------
782 wxToolBar
* wxFrame::CreateToolBar(
785 , const wxString
& rName
788 if (wxFrameBase::CreateToolBar( lStyle
795 return m_frameToolBar
;
796 } // end of wxFrame::CreateToolBar
798 void wxFrame::PositionToolBar()
803 ::WinQueryWindowRect(GetHwnd(), &vRect
);
811 GetStatusBar()->GetClientSize( &nStatusX
814 // PM is backwards from windows
815 vRect
.yBottom
+= nStatusY
;
817 #endif // wxUSE_STATUSBAR
819 if ( m_frameToolBar
)
824 m_frameToolBar
->GetSize( &nToolbarWidth
828 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
830 nToolbarHeight
= vRect
.yBottom
;
834 nToolbarWidth
= vRect
.xRight
;
838 // Use the 'real' PM position here
840 GetToolBar()->SetSize( 0
844 ,wxSIZE_NO_ADJUSTMENTS
847 } // end of wxFrame::PositionToolBar
848 #endif // wxUSE_TOOLBAR
850 // ----------------------------------------------------------------------------
851 // frame state (iconized/maximized/...)
852 // ----------------------------------------------------------------------------
855 // propagate our state change to all child frames: this allows us to emulate X
856 // Windows behaviour where child frames float independently of the parent one
857 // on the desktop, but are iconized/restored with it
859 void wxFrame::IconizeChildFrames(
863 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
865 pNode
= pNode
->GetNext() )
867 wxWindow
* pWin
= pNode
->GetData();
868 wxFrame
* pFrame
= wxDynamicCast(pWin
, wxFrame
);
871 #if wxUSE_MDI_ARCHITECTURE
872 && !wxDynamicCast(pFrame
, wxMDIChildFrame
)
873 #endif // wxUSE_MDI_ARCHITECTURE
877 // We don't want to restore the child frames which had been
878 // iconized even before we were iconized, so save the child frame
879 // status when iconizing the parent frame and check it when
884 pFrame
->m_bWasMinimized
= pFrame
->IsIconized();
888 // This test works for both iconizing and restoring
890 if (!pFrame
->m_bWasMinimized
)
891 pFrame
->Iconize(bIconize
);
894 } // end of wxFrame::IconizeChildFrames
896 WXHICON
wxFrame::GetDefaultIcon() const
898 return (WXHICON
)(wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
899 : wxDEFAULT_FRAME_ICON
);
901 // ===========================================================================
902 // message processing
903 // ===========================================================================
905 // ---------------------------------------------------------------------------
907 // ---------------------------------------------------------------------------
908 bool wxFrame::OS2TranslateMessage(
913 // try the menu bar accels
915 wxMenuBar
* pMenuBar
= GetMenuBar();
920 #if wxUSE_ACCEL && wxUSE_MENUS_NATIVE
921 const wxAcceleratorTable
& rAcceleratorTable
= pMenuBar
->GetAccelTable();
922 return rAcceleratorTable
.Translate(GetHWND(), pMsg
);
926 } // end of wxFrame::OS2TranslateMessage
928 // ---------------------------------------------------------------------------
929 // our private (non virtual) message handlers
930 // ---------------------------------------------------------------------------
931 bool wxFrame::HandlePaint()
935 if (::WinQueryUpdateRect(GetHWND(), &vRect
))
940 // Icons in PM are the same as "pointers"
945 hIcon
= (HPOINTER
)::WinSendMsg(m_hFrame
, WM_QUERYICON
, 0L, 0L);
947 hIcon
= (HPOINTER
)m_hDefaultIcon
;
950 // Hold a pointer to the dc so long as the OnPaint() message
951 // is being processed
954 HPS hPs
= ::WinBeginPaint(GetHwnd(), NULLHANDLE
, &vRect2
);
957 // Erase background before painting or we get white background
959 OS2DefWindowProc(WM_ERASEBACKGROUND
, (MPARAM
)hPs
, (MPARAM
)&vRect2
);
966 ::WinQueryWindowRect(GetHwnd(), &vRect3
);
968 static const int nIconWidth
= 32;
969 static const int nIconHeight
= 32;
970 int nIconX
= (int)((vRect3
.xRight
- nIconWidth
)/2);
971 int nIconY
= (int)((vRect3
.yBottom
+ nIconHeight
)/2);
973 ::WinDrawPointer(hPs
, nIconX
, nIconY
, hIcon
, DP_NORMAL
);
980 if (!wxWindow::HandlePaint())
985 hPS
= ::WinBeginPaint( GetHwnd()
991 ::GpiCreateLogColorTable( hPS
995 ,(LONG
)wxTheColourDatabase
->m_nSize
996 ,(PLONG
)wxTheColourDatabase
->m_palTable
998 ::GpiCreateLogColorTable( hPS
1008 ,GetBackgroundColour().GetPixel()
1018 // nothing to paint - processed
1022 } // end of wxFrame::HandlePaint
1024 bool wxFrame::HandleSize(
1030 bool bProcessed
= FALSE
;
1036 // Only do it it if we were iconized before, otherwise resizing the
1037 // parent frame has a curious side effect of bringing it under it's
1043 // restore all child frames too
1045 IconizeChildFrames(FALSE
);
1046 (void)SendIconizeEvent(FALSE
);
1053 m_bIconized
= FALSE
;
1058 // Iconize all child frames too
1060 IconizeChildFrames(TRUE
);
1061 (void)SendIconizeEvent();
1069 // forward WM_SIZE to status bar control
1071 #if wxUSE_NATIVE_STATUSBAR
1072 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
1074 wxSizeEvent
vEvent( wxSize( nX
1077 ,m_frameStatusBar
->GetId()
1080 vEvent
.SetEventObject(m_frameStatusBar
);
1081 m_frameStatusBar
->OnSize(vEvent
);
1083 #endif // wxUSE_NATIVE_STATUSBAR
1085 PositionStatusBar();
1088 #endif // wxUSE_TOOLBAR
1090 wxSizeEvent
vEvent( wxSize( nX
1096 vEvent
.SetEventObject(this);
1097 bProcessed
= GetEventHandler()->ProcessEvent(vEvent
);
1101 } // end of wxFrame::HandleSize
1103 bool wxFrame::HandleCommand(
1112 // In case it's e.g. a toolbar.
1114 wxWindow
* pWin
= wxFindWinFromHandle(hControl
);
1117 return pWin
->OS2Command( nCmd
1123 // Handle here commands from menus and accelerators
1125 if (nCmd
== CMDSRC_MENU
|| nCmd
== CMDSRC_ACCELERATOR
)
1127 #if wxUSE_MENUS_NATIVE
1128 if (wxCurrentPopupMenu
)
1130 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
1132 wxCurrentPopupMenu
= NULL
;
1134 return pPopupMenu
->OS2Command( nCmd
1141 if (ProcessCommand(nId
))
1147 } // end of wxFrame::HandleCommand
1149 bool wxFrame::HandleMenuSelect(
1160 rc
= ::WinSendMsg(hMenu
, MM_QUERYITEM
, MPFROM2SHORT(nItem
, TRUE
), (MPARAM
)&mItem
);
1162 if(rc
&& !(mItem
.afStyle
& (MIS_SUBMENU
| MIS_SEPARATOR
)))
1164 wxMenuEvent
vEvent(wxEVT_MENU_HIGHLIGHT
, nItem
);
1166 vEvent
.SetEventObject(this);
1167 GetEventHandler()->ProcessEvent(vEvent
); // return value would be ignored by PM
1171 } // end of wxFrame::HandleMenuSelect
1173 // ---------------------------------------------------------------------------
1174 // Main Frame window proc
1175 // ---------------------------------------------------------------------------
1176 MRESULT EXPENTRY
wxFrameMainWndProc(
1183 MRESULT rc
= (MRESULT
)0;
1184 bool bProcessed
= FALSE
;
1185 wxFrame
* pWnd
= NULL
;
1187 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1190 case WM_QUERYFRAMECTLCOUNT
:
1191 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1193 USHORT uItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1195 rc
= MRFROMSHORT(uItemCount
);
1199 case WM_FORMATFRAME
:
1200 /////////////////////////////////////////////////////////////////////////////////
1201 // Applications that subclass frame controls may find that the frame is already
1202 // subclassed the number of frame controls is variable.
1203 // The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
1204 // subclassed by calling the previous window procedure and modifying its result.
1205 ////////////////////////////////////////////////////////////////////////////////
1215 pSWP
= (PSWP
)PVOIDFROMMP(wParam
);
1216 nItemCount
= SHORT1FROMMR(pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
));
1217 if(pWnd
->m_frameStatusBar
)
1219 ::WinQueryWindowRect(pWnd
->m_frameStatusBar
->GetHWND(), &vRstb
);
1220 pWnd
->m_frameStatusBar
->GetSize(NULL
, &nHeight
);
1221 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1222 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1224 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1226 vSwpStb
.x
= vRectl
.xLeft
- vRstb
.xLeft
;
1227 vSwpStb
.y
= vRectl
.yBottom
- vRstb
.yBottom
;
1228 vSwpStb
.cx
= vRectl
.xRight
- vRectl
.xLeft
- 1; //?? -1 ??
1229 vSwpStb
.cy
= nHeight
;
1230 vSwpStb
.fl
= SWP_SIZE
|SWP_MOVE
| SWP_SHOW
;
1231 vSwpStb
.hwnd
= pWnd
->m_frameStatusBar
->GetHWND();
1232 vSwpStb
.hwndInsertBehind
= HWND_TOP
;
1234 ::WinQueryWindowRect(pWnd
->m_hFrame
, &vRectl
);
1235 ::WinMapWindowPoints(pWnd
->m_hFrame
, HWND_DESKTOP
, (PPOINTL
)&vRectl
, 2);
1236 ::WinCalcFrameRect(pWnd
->m_hFrame
, &vRectl
, TRUE
);
1237 ::WinMapWindowPoints(HWND_DESKTOP
, pWnd
->m_hFrame
, (PPOINTL
)&vRectl
, 2);
1238 for(i
= 0; i
< nItemCount
; i
++)
1240 if(pWnd
->m_hWnd
&& pSWP
[i
].hwnd
== pWnd
->m_hWnd
)
1242 pSWP
[i
].x
= vRectl
.xLeft
;
1243 pSWP
[i
].y
= vRectl
.yBottom
+ nHeight
;
1244 pSWP
[i
].cx
= vRectl
.xRight
- vRectl
.xLeft
;
1245 pSWP
[i
].cy
= vRectl
.yTop
- vRectl
.yBottom
- nHeight
;
1246 pSWP
[i
].fl
= SWP_SIZE
| SWP_MOVE
| SWP_SHOW
;
1247 pSWP
[i
].hwndInsertBehind
= HWND_TOP
;
1251 rc
= MRFROMSHORT(nItemCount
);
1256 if(pWnd
&& pWnd
->m_fnOldWndProc
)
1257 rc
= pWnd
->m_fnOldWndProc(hWnd
, ulMsg
, wParam
, lParam
);
1259 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1262 } // end of wxFrameMainWndProc
1264 MRESULT EXPENTRY
wxFrameWndProc(
1272 // Trace all ulMsgs - useful for the debugging
1275 wxFrame
* pWnd
= NULL
;
1277 parentHwnd
= WinQueryWindow(hWnd
,QW_PARENT
);
1278 pWnd
= (wxFrame
*) wxFindWinFromHandle((WXHWND
) hWnd
);
1281 // When we get the first message for the HWND we just created, we associate
1282 // it with wxWindow stored in wxWndHook
1285 MRESULT rc
= (MRESULT
)0;
1286 bool bProcessed
= FALSE
;
1289 // Stop right here if we don't have a valid handle in our wxWindow object.
1291 if (pWnd
&& !pWnd
->GetHWND())
1293 pWnd
->SetHWND((WXHWND
) hWnd
);
1294 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
1300 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
1302 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1305 } // end of wxFrameWndProc
1307 MRESULT
wxFrame::OS2WindowProc(
1314 bool bProcessed
= FALSE
;
1320 // If we can't close, tell the system that we processed the
1321 // message - otherwise it would close us
1323 bProcessed
= !Close();
1327 bProcessed
= HandlePaint();
1328 mRc
= (MRESULT
)FALSE
;
1331 case WM_ERASEBACKGROUND
:
1333 // Returning TRUE to requests PM to paint the window background
1334 // in SYSCLR_WINDOW. We capture this here because the PS returned
1335 // in Frames is the PS for the whole frame, which we can't really
1336 // use at all. If you want to paint a different background, do it
1337 // in an OnPaint using a wxPaintDC.
1339 mRc
= (MRESULT
)(TRUE
);
1348 UnpackCommand( (WXWPARAM
)wParam
1355 bProcessed
= HandleCommand( wId
1368 UnpackMenuSelect( wParam
1374 bProcessed
= HandleMenuSelect( wItem
1378 mRc
= (MRESULT
)TRUE
;
1384 SHORT nScxold
= SHORT1FROMMP(wParam
); // Old horizontal size.
1385 SHORT nScyold
= SHORT2FROMMP(wParam
); // Old vertical size.
1386 SHORT nScxnew
= SHORT1FROMMP(lParam
); // New horizontal size.
1387 SHORT nScynew
= SHORT2FROMMP(lParam
); // New vertical size.
1389 lParam
= MRFROM2SHORT( nScxnew
- 20
1393 bProcessed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), (WXUINT
)wParam
);
1394 mRc
= (MRESULT
)FALSE
;
1397 case CM_QUERYDRAGIMAGE
:
1402 hIcon
= (HPOINTER
)::WinSendMsg(GetHWND(), WM_QUERYICON
, 0L, 0L);
1404 hIcon
= (HPOINTER
)m_hDefaultIcon
;
1405 mRc
= (MRESULT
)hIcon
;
1406 bProcessed
= mRc
!= 0;
1412 mRc
= wxWindow::OS2WindowProc( uMessage
1416 return (MRESULT
)mRc
;
1417 } // wxFrame::OS2WindowProc
1419 void wxFrame::SetClient(WXHWND c_Hwnd
)
1421 // Duh...nothing to do under OS/2
1424 void wxFrame::SetClient(
1428 wxWindow
* pOldClient
= this->GetClient();
1429 bool bClientHasFocus
= pOldClient
&& (pOldClient
== wxWindow::FindFocus());
1431 if(pOldClient
== pWindow
) // nothing to do
1433 if(pWindow
== NULL
) // just need to remove old client
1435 if(pOldClient
== NULL
) // nothing to do
1438 if(bClientHasFocus
)
1441 pOldClient
->Enable( FALSE
);
1442 pOldClient
->Show( FALSE
);
1443 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1444 // to avoid OS/2 bug need to update frame
1445 ::WinSendMsg((HWND
)this->GetFrame(), WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1450 // Else need to change client
1455 ::WinEnableWindowUpdate((HWND
)GetHWND(), FALSE
);
1458 pOldClient
->Enable(FALSE
);
1459 pOldClient
->Show(FALSE
);
1460 ::WinSetWindowUShort(pOldClient
->GetHWND(), QWS_ID
, (USHORT
)pOldClient
->GetId());
1462 pWindow
->Reparent(this);
1463 ::WinSetWindowUShort(pWindow
->GetHWND(), QWS_ID
, FID_CLIENT
);
1464 ::WinEnableWindowUpdate((HWND
)GetHWND(), TRUE
);
1466 pWindow
->Show(); // ensure client is showing
1467 if( this->IsShown() )
1470 ::WinSendMsg(m_hFrame
, WM_UPDATEFRAME
, (MPARAM
)~0, 0);
1474 wxWindow
* wxFrame::GetClient()
1476 return wxFindWinFromHandle((WXHWND
)::WinWindowFromID(m_hFrame
, FID_CLIENT
));