Reworked Frame class

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6910 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster
2000-03-22 23:22:48 +00:00
parent 96525e629a
commit 40bd6154f1
3 changed files with 132 additions and 101 deletions

View File

@@ -202,6 +202,33 @@ private:
WXHWND m_hWndToolTip; WXHWND m_hWndToolTip;
#endif // tooltips #endif // tooltips
//
// The main handle of a frame window, that used for message processing
// is the client handle under PM. But we still need the frame handle
// as well
//
WXHWND m_hFrame;
//
// Handles to child windows of the Frame that we don't have child objects for
//
WXHWND m_hTitleBar;
WXHWND m_hHScroll;
WXHWND m_hVScroll;
//
// Swp structures for various client data
// DW: Better off in attached RefData?
//
SWP m_vSwp;
SWP m_vSwpClient;
SWP m_vSwpTitleBar;
SWP m_vSwpMenuBar;
SWP m_vSwpHScroll;
SWP m_vSwpVScroll;
SWP m_vSwpStatusBar;
SWP m_vSwpToolBar;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxFrame) DECLARE_DYNAMIC_CLASS(wxFrame)
}; };

View File

@@ -90,6 +90,18 @@ void wxFrame::Init()
m_nFsToolBarHeight = 0; m_nFsToolBarHeight = 0;
m_bFsIsMaximized = FALSE; m_bFsIsMaximized = FALSE;
m_bFsIsShowing = FALSE; m_bFsIsShowing = FALSE;
//
// Initialize SWP's
//
memset(&m_vSwp, 0, sizeof(SWP));
memset(&m_vSwpClient, 0, sizeof(SWP));
memset(&m_vSwpTitleBar, 0, sizeof(SWP));
memset(&m_vSwpMenuBar, 0, sizeof(SWP));
memset(&m_vSwpHScroll, 0, sizeof(SWP));
memset(&m_vSwpVScroll, 0, sizeof(SWP));
memset(&m_vSwpStatusBar, 0, sizeof(SWP));
memset(&m_vSwpToolBar, 0, sizeof(SWP));
} // end of wxFrame::Init } // end of wxFrame::Init
bool wxFrame::Create( bool wxFrame::Create(
@@ -160,7 +172,7 @@ wxFrame::~wxFrame()
if (wxTheApp->GetExitOnFrameDelete()) if (wxTheApp->GetExitOnFrameDelete())
{ {
::WinPostMsg(GetHwnd(), WM_QUIT, 0, 0); ::WinPostMsg(m_hFrame, WM_QUIT, 0, 0);
} }
} }
wxModelessWindows.DeleteObject(this); wxModelessWindows.DeleteObject(this);
@@ -202,14 +214,12 @@ void wxFrame::DoGetClientSize(
// top-left thus the += instead of the -= // top-left thus the += instead of the -=
// //
RECTL vRect; RECTL vRect;
HWND hWndClient;
// //
// PM has no GetClientRect that inherantly knows about the client window // PM has no GetClientRect that inherantly knows about the client window
// We have to explicitly go fetch it! // We have to explicitly go fetch it!
// //
hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT); ::WinQueryWindowRect(GetHwnd(), &vRect);
::WinQueryWindowRect(hWndClient, &vRect);
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
if ( GetStatusBar() ) if ( GetStatusBar() )
@@ -245,14 +255,12 @@ void wxFrame::DoSetClientSize(
) )
{ {
HWND hWnd = GetHwnd(); HWND hWnd = GetHwnd();
HWND hWndClient;
RECTL vRect; RECTL vRect;
RECTL vRect2; RECTL vRect2;
hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT); ::WinQueryWindowRect(GetHwnd(), &vRect);
::WinQueryWindowRect(hWndClient, &vRect);
::WinQueryWindowRect(hWnd, &vRect2); ::WinQueryWindowRect(m_hFrame, &vRect2);
// //
// Find the difference between the entire window (title bar and all) // Find the difference between the entire window (title bar and all)
@@ -284,7 +292,7 @@ void wxFrame::DoSetClientSize(
vPointl.x = vRect2.xLeft; vPointl.x = vRect2.xLeft;
vPoint.y = vRect2.yTop; vPoint.y = vRect2.yTop;
::WinSetWindowPos( hWnd ::WinSetWindowPos( m_hFrame
,HWND_TOP ,HWND_TOP
,vPointl.x ,vPointl.x
,vPointl.y ,vPointl.y
@@ -309,7 +317,7 @@ void wxFrame::DoGetSize(
{ {
RECTL vRect; RECTL vRect;
::WinQueryWindowRect(GetHwnd(), &vRect); ::WinQueryWindowRect(m_hFrame, &vRect);
*pWidth = vRect.xRight - vRect.xLeft; *pWidth = vRect.xRight - vRect.xLeft;
*pHeight = vRect.yTop - vRect.yBottom; *pHeight = vRect.yTop - vRect.yBottom;
} // end of wxFrame::DoGetSize } // end of wxFrame::DoGetSize
@@ -322,7 +330,7 @@ void wxFrame::DoGetPosition(
RECTL vRect; RECTL vRect;
POINTL vPoint; POINTL vPoint;
::WinQueryWindowRect(GetHwnd(), &vRect); ::WinQueryWindowRect(m_hFrame, &vRect);
vPoint.x = vRect.xLeft; vPoint.x = vRect.xLeft;
// //
@@ -348,8 +356,7 @@ void wxFrame::DoShowWindow(
// //
// Reset the window position // Reset the window position
// //
hClient = WinWindowFromID(GetHwnd(), FID_CLIENT); WinQueryWindowPos(m_hFrame, &vSwp);
WinQueryWindowPos(GetHwnd(), &vSwp);
WinSetWindowPos( GetHwnd() WinSetWindowPos( GetHwnd()
,HWND_TOP ,HWND_TOP
,vSwp.x ,vSwp.x
@@ -358,8 +365,8 @@ void wxFrame::DoShowWindow(
,vSwp.cy ,vSwp.cy
,SWP_SIZE | SWP_MOVE | SWP_ACTIVATE ,SWP_SIZE | SWP_MOVE | SWP_ACTIVATE
); );
::WinShowWindow(m_hFrame, (BOOL)bShowCmd);
::WinShowWindow(GetHwnd(), (BOOL)bShowCmd); ::WinShowWindow(GetHwnd(), (BOOL)bShowCmd);
::WinShowWindow(hClient, (BOOL)bShowCmd);
} // end of wxFrame::DoShowWindow } // end of wxFrame::DoShowWindow
bool wxFrame::Show( bool wxFrame::Show(
@@ -374,9 +381,9 @@ bool wxFrame::Show(
{ {
wxActivateEvent vEvent(wxEVT_ACTIVATE, TRUE, m_windowId); wxActivateEvent vEvent(wxEVT_ACTIVATE, TRUE, m_windowId);
::WinQueryWindowPos(GetHwnd(), &vSwp); ::WinQueryWindowPos(m_hFrame, &vSwp);
m_bIconized = vSwp.fl & SWP_MINIMIZE; m_bIconized = vSwp.fl & SWP_MINIMIZE;
::WinEnableWindow(GetHwnd(), TRUE); ::WinEnableWindow(m_hFrame, TRUE);
vEvent.SetEventObject(this); vEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(vEvent); GetEventHandler()->ProcessEvent(vEvent);
} }
@@ -444,7 +451,7 @@ bool wxFrame::IsMaximized() const
SWP vSwp; SWP vSwp;
bool bIconic; bool bIconic;
::WinQueryWindowPos(GetHwnd(), &vSwp); ::WinQueryWindowPos(m_hFrame, &vSwp);
return (vSwp.fl & SWP_MAXIMIZE); return (vSwp.fl & SWP_MAXIMIZE);
} // end of wxFrame::IsMaximized } // end of wxFrame::IsMaximized
@@ -456,12 +463,12 @@ void wxFrame::SetIcon(
if ((m_icon.GetHICON()) != NULLHANDLE) if ((m_icon.GetHICON()) != NULLHANDLE)
{ {
::WinSendMsg( GetHwnd() ::WinSendMsg( m_hFrame
,WM_SETICON ,WM_SETICON
,(MPARAM)((HPOINTER)m_icon.GetHICON()) ,(MPARAM)((HPOINTER)m_icon.GetHICON())
,NULL ,NULL
); );
::WinSendMsg( GetHwnd() ::WinSendMsg( m_hFrame
,WM_UPDATEFRAME ,WM_UPDATEFRAME
,(MPARAM)FCF_ICON ,(MPARAM)FCF_ICON
,(MPARAM)0 ,(MPARAM)0
@@ -501,8 +508,7 @@ void wxFrame::PositionStatusBar()
HWND hWndClient; HWND hWndClient;
RECTL vRect; RECTL vRect;
hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT); ::WinQueryWindowRect(GetHwnd(), &vRect);
::WinQueryWindowRect(hWndClient, &vRect);
nWidth = vRect.xRight - vRect.xLeft; nWidth = vRect.xRight - vRect.xLeft;
nHeight = vRect.yTop - vRect.yBottom; nHeight = vRect.yTop - vRect.yBottom;
@@ -579,14 +585,14 @@ void wxFrame::SetMenuBar(
// //
// Set the parent and owner of the menubar to be the frame // Set the parent and owner of the menubar to be the frame
// //
if (!::WinSetParent(m_hMenu, GetHwnd(), FALSE)) if (!::WinSetParent(m_hMenu, m_hFrame, FALSE))
{ {
vError = ::WinGetLastError(vHabmain); vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError); sError = wxPMErrorToStr(vError);
wxLogError("Error setting parent for submenu. Error: %s\n", sError); wxLogError("Error setting parent for submenu. Error: %s\n", sError);
} }
if (!::WinSetOwner(m_hMenu, GetHwnd())) if (!::WinSetOwner(m_hMenu, m_hFrame))
{ {
vError = ::WinGetLastError(vHabmain); vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError); sError = wxPMErrorToStr(vError);
@@ -600,17 +606,16 @@ void wxFrame::SetMenuBar(
// //
// Now resize the client to fit the new frame // Now resize the client to fit the new frame
// //
WinQueryWindowPos(GetHwnd(), &vSwp); WinQueryWindowPos(m_hFrame, &vSwp);
hClient = WinWindowFromID(GetHwnd(), FID_CLIENT); hTitlebar = WinWindowFromID(m_hFrame, FID_TITLEBAR);
hTitlebar = WinWindowFromID(GetHwnd(), FID_TITLEBAR);
WinQueryWindowPos(hTitlebar, &vSwpTitlebar); WinQueryWindowPos(hTitlebar, &vSwpTitlebar);
hHScroll = WinWindowFromID(GetHwnd(), FID_HORZSCROLL); hHScroll = WinWindowFromID(m_hFrame, FID_HORZSCROLL);
WinQueryWindowPos(hHScroll, &vSwpHScroll); WinQueryWindowPos(hHScroll, &vSwpHScroll);
hVScroll = WinWindowFromID(GetHwnd(), FID_VERTSCROLL); hVScroll = WinWindowFromID(m_hFrame, FID_VERTSCROLL);
WinQueryWindowPos(hVScroll, &vSwpVScroll); WinQueryWindowPos(hVScroll, &vSwpVScroll);
hMenuBar = WinWindowFromID(GetHwnd(), FID_MENU); hMenuBar = WinWindowFromID(m_hFrame, FID_MENU);
WinQueryWindowPos(hMenuBar, &vSwpMenu); WinQueryWindowPos(hMenuBar, &vSwpMenu);
WinSetWindowPos( hClient WinSetWindowPos( GetHwnd()
,HWND_TOP ,HWND_TOP
,SV_CXSIZEBORDER/2 ,SV_CXSIZEBORDER/2
,(SV_CYSIZEBORDER/2) + vSwpHScroll.cy/2 ,(SV_CYSIZEBORDER/2) + vSwpHScroll.cy/2
@@ -622,7 +627,7 @@ void wxFrame::SetMenuBar(
void wxFrame::InternalSetMenuBar() void wxFrame::InternalSetMenuBar()
{ {
WinSendMsg((HWND)GetHwnd(), WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0); WinSendMsg((HWND)m_hFrame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
} // end of wxFrame::InternalSetMenuBar } // end of wxFrame::InternalSetMenuBar
// //
@@ -800,9 +805,11 @@ bool wxFrame::OS2Create(
HWND hHScroll = NULLHANDLE; HWND hHScroll = NULLHANDLE;
HWND hVScroll = NULLHANDLE; HWND hVScroll = NULLHANDLE;
SWP vSwp; SWP vSwp;
SWP vSwpClient;
SWP vSwpTitlebar; SWP vSwpTitlebar;
SWP vSwpVScroll; SWP vSwpVScroll;
SWP vSwpHScroll; SWP vSwpHScroll;
USHORT uCtlCount;
m_hDefaultIcon = (WXHICON) (wxSTD_FRAME_ICON ? wxSTD_FRAME_ICON : wxDEFAULT_FRAME_ICON); m_hDefaultIcon = (WXHICON) (wxSTD_FRAME_ICON ? wxSTD_FRAME_ICON : wxDEFAULT_FRAME_ICON);
@@ -871,66 +878,43 @@ bool wxFrame::OS2Create(
// //
// Create the frame window // Create the frame window
// //
if (!wxWindow::OS2Create( hParent if ((m_hFrame = ::WinCreateWindow( hParent // Frame is parent
,WC_FRAME ,WC_FRAME // standard frame class
,zTitle ,(PSZ)zTitle // Window title
,ulStyleFlags ,0 // No styles
,(long)nX ,0, 0, 0, 0 // Window position
,(long)nY ,NULLHANDLE // Owner
,(long)nWidth ,HWND_TOP // Sibling
,(long)nHeight ,(ULONG)nId // ID
,(PVOID)&flFrameCtlData // Creation data
,NULL // Window Pres Params
)) == 0L)
{
return FALSE;
}
if (!wxWindow::OS2Create( m_hFrame
,wxFrameClassName
,NULL
,0L
,0L
,0L
,0L
,0L
,NULLHANDLE ,NULLHANDLE
,HWND_TOP ,HWND_TOP
,(long)nId ,(unsigned long)FID_CLIENT
,(void*)&vFrameCtlData ,NULL
,NULL ,NULL
)) ))
{ {
return FALSE; return FALSE;
} }
hFrame = GetHwnd();
//
// Since under PM the controling window proc is associated with the client window handle
// not the frame's we have to perform the hook here in order to associated the client handle,
// not the frame's with the window object !
//
wxWndHook = this;
//
// Create the client window. We must call the API from here rather than
// the static base class create because we need a separate handle
//
if ((hClient = ::WinCreateWindow( hFrame // Frame is parent
,wxFrameClassName
,NULL // Window title
,0 // No styles
,0, 0, 0, 0 // Window position
,NULLHANDLE // Owner
,HWND_TOP // Sibling
,FID_CLIENT // standard client ID
,NULL // Creation data
,NULL // Window Pres Params
)) == 0L)
{
return FALSE;
}
wxWndHook = NULL;
//
// Send anything to initialize the frame
//
::WinSendMsg( hFrame
,WM_UPDATEFRAME
,(MPARAM)FCF_TASKLIST
,(MPARAM)0
);
// //
// Now size everything. If adding a menu the client will need to be resized. // Now size everything. If adding a menu the client will need to be resized.
// //
if (!::WinSetWindowPos( hFrame if (!::WinSetWindowPos( m_hFrame
,HWND_TOP ,HWND_TOP
,nX ,nX
,nY ,nY
@@ -940,20 +924,28 @@ bool wxFrame::OS2Create(
)) ))
return FALSE; return FALSE;
WinQueryWindowPos(GetHwnd(), &vSwp); uCtlCount = ::WinSendMsg(m_hFrame, WM_FORMATFRAME, (MPARAM)pSwp, (MPARAM)pRect);
hClient = WinWindowFromID(GetHwnd(), FID_CLIENT); for (int i = 0; i < uCtlCount; i++)
hTitlebar = WinWindowFromID(GetHwnd(), FID_TITLEBAR); {
WinQueryWindowPos(hTitlebar, &vSwpTitlebar); if (pSwp[i].hwnd == m_hFrame)
hHScroll = WinWindowFromID(GetHwnd(), FID_HORZSCROLL); memcpy(m_vSwp, pSwp[i], sizeof(SWP));
WinQueryWindowPos(hHScroll, &vSwpHScroll); else if (pSwp[i].hwnd == m_hVScroll)
hVScroll = WinWindowFromID(GetHwnd(), FID_VERTSCROLL); memcpy(m_vSwpVScroll, pSwp[i], sizeof(SWP));
WinQueryWindowPos(hVScroll, &vSwpVScroll); else if (pSwp[i].hwnd == m_hHScroll)
memcpy(m_vSwpVScroll, pSwp[i], sizeof(SWP));
else if (pSwp[i].hwnd == m_hTitleBar)
memcpy(m_vSwpTitleBar, pSwp[i], sizeof(SWP));
}
//
// Now set the size of the client
//
WinSetWindowPos( hClient WinSetWindowPos( hClient
,HWND_TOP ,HWND_TOP
,SV_CXSIZEBORDER/2 ,SV_CXSIZEBORDER/2
,(SV_CYSIZEBORDER/2) + vSwpHScroll.cy/2 ,(SV_CYSIZEBORDER/2) + m_vSwpHScroll.cy/2
,vSwp.cx - ((SV_CXSIZEBORDER + 1) + vSwpVScroll.cx) ,m_vSwp.cx - ((SV_CXSIZEBORDER + 1) + m_vSwpVScroll.cx)
,vSwp.cy - ((SV_CYSIZEBORDER + 1) + vSwpTitlebar.cy + vSwpHScroll.cy/2) ,m_vSwp.cy - ((SV_CYSIZEBORDER + 1) + m_vSwpTitlebar.cy + m_vSwpHScroll.cy/2)
,SWP_SIZE | SWP_MOVE ,SWP_SIZE | SWP_MOVE
); );
@@ -1056,8 +1048,7 @@ void wxFrame::PositionToolBar()
HWND hWndClient; HWND hWndClient;
RECTL vRect; RECTL vRect;
hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT); ::WinQueryWindowRect(GetHwnd(), &vRect);
::WinQueryWindowRect(hWndClient, &vRect);
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
if (GetStatusBar()) if (GetStatusBar())
@@ -1162,7 +1153,7 @@ bool wxFrame::HandlePaint()
{ {
RECTL vRect; RECTL vRect;
if (::WinQueryUpdateRect(GetHwnd(), &vRect)) if (::WinQueryUpdateRect(m_hFrame, &vRect))
{ {
if (m_bIconized) if (m_bIconized)
{ {
@@ -1172,7 +1163,7 @@ bool wxFrame::HandlePaint()
HPOINTER hIcon; HPOINTER hIcon;
if (m_icon.Ok()) if (m_icon.Ok())
hIcon = (HPOINTER)::WinSendMsg(GetHwnd(), WM_QUERYICON, 0L, 0L); hIcon = (HPOINTER)::WinSendMsg(m_hFrame, WM_QUERYICON, 0L, 0L);
else else
hIcon = (HPOINTER)m_hDefaultIcon; hIcon = (HPOINTER)m_hDefaultIcon;
@@ -1181,7 +1172,7 @@ bool wxFrame::HandlePaint()
// is being processed // is being processed
// //
RECTL vRect2; RECTL vRect2;
HPS hPs = ::WinBeginPaint(GetHwnd(), NULLHANDLE, &vRect2); HPS hPs = ::WinBeginPaint(m_hFrame, NULLHANDLE, &vRect2);
// //
// Erase background before painting or we get white background // Erase background before painting or we get white background
@@ -1193,8 +1184,7 @@ bool wxFrame::HandlePaint()
HWND hWndClient; HWND hWndClient;
RECTL vRect3; RECTL vRect3;
hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT); ::WinQueryWindowRect(GetHwnd(), &vRect3);
::WinQueryWindowRect(hWndClient, &vRect3);
static const int nIconWidth = 32; static const int nIconWidth = 32;
static const int nIconHeight = 32; static const int nIconHeight = 32;
@@ -1433,12 +1423,21 @@ MRESULT wxFrame::OS2WindowProc(
bProcessed = HandlePaint(); bProcessed = HandlePaint();
break; break;
case WM_ERASEBACKGROUND:
//
// Return TRUE to request PM to paint the window background
// in SYSCLR_WINDOW.
//
bProcessed = TRUE;
mRc = (MRESULT)(TRUE);
break;
case CM_QUERYDRAGIMAGE: case CM_QUERYDRAGIMAGE:
{ {
HPOINTER hIcon; HPOINTER hIcon;
if (m_icon.Ok()) if (m_icon.Ok())
hIcon = (HPOINTER)::WinSendMsg(GetHwnd(), WM_QUERYICON, 0L, 0L); hIcon = (HPOINTER)::WinSendMsg(m_hFrame, WM_QUERYICON, 0L, 0L);
else else
hIcon = (HPOINTER)m_hDefaultIcon; hIcon = (HPOINTER)m_hDefaultIcon;
mRc = (MRESULT)hIcon; mRc = (MRESULT)hIcon;

View File

@@ -2357,7 +2357,7 @@ bool wxWindow::OS2Create(
(ULONG)zClass == (ULONG)WC_COMBOBOX || (ULONG)zClass == (ULONG)WC_COMBOBOX ||
(ULONG)zClass == (ULONG)WC_CONTAINER || (ULONG)zClass == (ULONG)WC_CONTAINER ||
(ULONG)zClass == (ULONG)WC_ENTRYFIELD || (ULONG)zClass == (ULONG)WC_ENTRYFIELD ||
(ULONG)zClass == (ULONG)WC_FRAME || (ULONG)zClass == (ULONG)WC_FRAME ||
(ULONG)zClass == (ULONG)WC_LISTBOX || (ULONG)zClass == (ULONG)WC_LISTBOX ||
(ULONG)zClass == (ULONG)WC_MENU || (ULONG)zClass == (ULONG)WC_MENU ||
(ULONG)zClass == (ULONG)WC_NOTEBOOK || (ULONG)zClass == (ULONG)WC_NOTEBOOK ||
@@ -2796,6 +2796,9 @@ void wxWindow::OnSysColourChanged(
bool wxWindow::HandlePaint() bool wxWindow::HandlePaint()
{ {
HRGN hRgn = NULLHANDLE; HRGN hRgn = NULLHANDLE;
wxPaintEvent vEvent;
HPS hPS;
RECTL vRect;
if (::WinQueryUpdateRegion(GetHwnd(), hRgn) == RGN_NULL) if (::WinQueryUpdateRegion(GetHwnd(), hRgn) == RGN_NULL)
{ {
@@ -2804,7 +2807,9 @@ bool wxWindow::HandlePaint()
} }
m_updateRegion = wxRegion(hRgn); m_updateRegion = wxRegion(hRgn);
wxPaintEvent vEvent; hPS = WinBeginPaint(GetHwnd(), 0L, &vRect);
WinFillRect(hPS, &vRect, SYSCLR_WINDOW);
WinEndPaint(hPS);
vEvent.SetEventObject(this); vEvent.SetEventObject(this);
return (GetEventHandler()->ProcessEvent(vEvent)); return (GetEventHandler()->ProcessEvent(vEvent));