More wxWindow updates

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6253 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster
2000-02-23 23:43:03 +00:00
parent 122603f10f
commit a7ef993c98
2 changed files with 348 additions and 172 deletions

View File

@@ -253,7 +253,7 @@ void wxFrame::DoSetClientSize(
HWND hWnd = GetHwnd(); HWND hWnd = GetHwnd();
HWND hWndClient; HWND hWndClient;
RECTL vRect; RECTL vRect;
RECT vRect2; RECTL vRect2;
hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT); hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
::WinQueryWindowRect(hWndClient, &vRect); ::WinQueryWindowRect(hWndClient, &vRect);

View File

@@ -979,111 +979,153 @@ void wxWindow::DoSetToolTip(
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Get total size // Get total size
void wxWindow::DoGetSize( int *width, int *height ) const void wxWindow::DoGetSize(
int* pWidth
, int* pHeight
) const
{ {
HWND hWnd = GetHwnd(); HWND hWnd = GetHwnd();
RECT rect; RECTL vRect;
GetWindowRect(hWnd, &rect);
if ( x ) ::WinQueryWindowRect(hWnd, &vRect);
*x = rect.right - rect.left;
if ( y )
*y = rect.bottom - rect.top;
}
void wxWindow::DoGetPosition( int *x, int *y ) const if (pWidth)
*pWidth = vRect.xRight - vRect.xLeft;
if (pHeight )
// OS/2 PM is backwards from windows
*pHeight = vRect.yTop - vRect.yBottom;
} // end of wxWindow::DoGetSize
void wxWindow::DoGetPosition(
int* pX
, int* pY
) const
{ {
HWND hWnd = GetHwnd(); HWND hWnd = GetHwnd();
RECT vRect;
POINTL vPoint;
RECT rect; ::WinQueryWindowRect(hWnd, &vRect);
GetWindowRect(hWnd, &rect);
POINT point; vPoint.x = vRect.xLeft;
point.x = rect.left; vPoint.y = vRect.yBottom;
point.y = rect.top;
// we do the adjustments with respect to the parent only for the "real" //
// We do the adjustments with respect to the parent only for the "real"
// children, not for the dialogs/frames // children, not for the dialogs/frames
if ( !IsTopLevel() ) //
if (!IsTopLevel())
{ {
HWND hParentWnd = 0; HWND hParentWnd = 0;
wxWindow *parent = GetParent(); wxWindow* pParent = GetParent();
if ( parent )
hParentWnd = GetWinHwnd(parent);
if (pParent)
hParentWnd = GetWinHwnd(pParent);
//
// Since we now have the absolute screen coords, if there's a parent we // Since we now have the absolute screen coords, if there's a parent we
// must subtract its top left corner // must subtract its bottom left corner
if ( hParentWnd ) //
if (hParentWnd)
{ {
::ScreenToClient(hParentWnd, &point); RECTL vRect2;
::WinQueryWindowRect(hParentWnd, vRect2);
vPoint.x -= vRect.xLeft;
vPoint.y -= vRect.yBottom;
} }
//
// We may be faking the client origin. So a window that's really at (0, // We may be faking the client origin. So a window that's really at (0,
// 30) may appear (to wxWin apps) to be at (0, 0). // 30) may appear (to wxWin apps) to be at (0, 0).
wxPoint pt(parent->GetClientAreaOrigin()); //
point.x -= pt.x; wxPoint vPt(pParent->GetClientAreaOrigin());
point.y -= pt.y;
vPoint.x -= vPt.x;
vPoint.y -= vPt.y;
} }
if ( x ) if (pX)
*x = point.x; *pX = vPoint.x;
if ( y ) if y)
*y = point.y; *pY = vPoint.y;
} } // end of wxWindow::DoGetPosition
void wxWindow::DoScreenToClient( int *x, int *y ) const void wxWindow::DoScreenToClient(
int* pX
, int* pY
) const
{ {
POINT pt; HWND hWnd = GetHwnd();
if ( x ) RECTL vRect;
pt.x = *x;
if ( y )
pt.y = *y;
HWND hWnd = GetHwnd(); ::WinQueryWindowPos(hWnd, &vRect);
::ScreenToClient(hWnd, &pt);
if (pX)
*pX -= vRect.xLeft;
if (pY)
*pY -= vRect.yBottom;
} // end of wxWindow::DoScreenToClient
if ( x ) void wxWindow::DoClientToScreen(
*x = pt.x; int* pX
if ( y ) , int* pY
*y = pt.y; ) const
}
void wxWindow::DoClientToScreen( int *x, int *y ) const
{ {
POINT pt; HWND hWnd = GetHwnd();
if ( x ) RECTL vRect;
pt.x = *x;
if ( y )
pt.y = *y;
HWND hWnd = GetHwnd(); ::WinQueryWindowPos(hWnd, &vRect);
::ClientToScreen(hWnd, &pt);
if ( x ) if (pX)
*x = pt.x; *pX += vRect.xLeft;
if ( y ) if (pY)
*y = pt.y; *pY += vRect.yBottom;
} } // end of wxWindow::DoClientToScreen
//
// Get size *available for subwindows* i.e. excluding menu bar etc. // Get size *available for subwindows* i.e. excluding menu bar etc.
void wxWindow::DoGetClientSize( int *width, int *height ) const // Must be a frame type window
//
void wxWindow::DoGetClientSize(
int* pWidth
, int* pHeight
) const
{ {
HWND hWnd = GetHwnd(); HWND hWnd = GetHwnd();
RECT rect; HWND hWndClient;
::GetClientRect(hWnd, &rect); RECTL vRect;
if ( x )
*x = rect.right;
if ( y )
*y = rect.bottom;
}
void wxWindow::DoMoveWindow(int x, int y, int width, int height) hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
::WinQueryWindowRect(hWndClient, &vRect);
if (pX)
*pWidth = vRect.xRight;
if (pY)
*pHeight = vRect.yTop;
} // end of wxWindow::DoGetClientSize
void wxWindow::DoMoveWindow(
int nX
, int nY
, int nWidth
, int nHeight
)
{ {
if ( !::MoveWindow(GetHwnd(), x, y, width, height, TRUE) ) ::WinSetWindowPos(
if ( !::MoveWindow( GetHwnd()
,HWND_TOP
,(LONG)nX
,(LONG)nY
,(LONG)nWidth
,(LONG)nHeight
,SWP_SIZE | SWP_MOVE
,
))
{ {
wxLogLastError("MoveWindow"); wxLogLastError("MoveWindow");
} }
} } // end of wxWindow::DoMoveWindow
// //
// Set the size of the window: if the dimensions are positive, just use them, // Set the size of the window: if the dimensions are positive, just use them,
@@ -1095,150 +1137,259 @@ void wxWindow::DoMoveWindow(int x, int y, int width, int height)
// the width/height to best suit our contents, otherwise we reuse the current // the width/height to best suit our contents, otherwise we reuse the current
// width/height // width/height
// //
void wxWindow::DoSetSize(int x, int y, void wxWindow::DoSetSize(
int width, int height, int nX
int sizeFlags) , int nY
, int nWidth
, int nHeight
, int nSizeFlags
)
{ {
// get the current size and position... //
int currentX, currentY; // Get the current size and position...
GetPosition(&currentX, &currentY); //
int currentW,currentH; int nCurrentX;
GetSize(&currentW, &currentH); int nCurrentY;
int nCurrentWidth;
int nCurrentHeight;
wxSize size(-1, -1);
GetPosition( &nCurrentX
,&nCurrentY
);
GetSize( &nCurrentWidth
,&nCurrentHeight
);
//
// ... and don't do anything (avoiding flicker) if it's already ok // ... and don't do anything (avoiding flicker) if it's already ok
if ( x == currentX && y == currentY && //
width == currentW && height == currentH ) if ( nX == nCurrentX &&
nY == nCurrentY &&
nWidth == nCurrentWidth &&
nHeight == nCurrentHeight
)
{ {
return; return;
} }
if ( x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) ) if (nX == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE))
x = currentX; nX = nCurrentX;
if ( y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) ) if (y == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE))
y = currentY; nY = nCurrentY;
AdjustForParentClientOrigin(x, y, sizeFlags); AdjustForParentClientOrigin( nX
,nY
,nSizeFlags
);
wxSize size(-1, -1); if (nWidth == -1)
if ( width == -1 )
{ {
if ( sizeFlags & wxSIZE_AUTO_WIDTH ) if (nSizeFlags & wxSIZE_AUTO_WIDTH)
{ {
size = DoGetBestSize(); vSize = DoGetBestSize();
width = size.x; nWidth = vSize.x;
} }
else else
{ {
// just take the current one //
width = currentW; // Just take the current one
//
nWidth = nCurrentWidth;
} }
} }
if ( height == -1 ) if (nHeight == -1)
{ {
if ( sizeFlags & wxSIZE_AUTO_HEIGHT ) if (nSizeFlags & wxSIZE_AUTO_HEIGHT)
{ {
if ( size.x == -1 ) if (vSize.x == -1)
{ {
size = DoGetBestSize(); vSize = DoGetBestSize();
} }
//else: already called DoGetBestSize() above nHeight = vSize.y;
height = size.y;
} }
else else
{ {
// just take the current one // just take the current one
height = currentH; nHeight = nCurrentHeight;
} }
} }
DoMoveWindow(x, y, width, height); DoMoveWindow( nX
} ,nY
,nWidth
,nHeight
);
} // end of wxWindow::DoSetSize
void wxWindow::DoSetClientSize(int width, int height) void wxWindow::DoSetClientSize(
int nWidth
, int nHeight
)
{ {
wxWindow *parent = GetParent(); wxWindow* pParent = GetParent();
HWND hWnd = GetHwnd(); HWND hWnd = GetHwnd();
HWND hParentWnd = (HWND) 0; HWND hParentWnd = (HWND)0;
if ( parent ) HWND hClientWnd = (HWND)0;
hParentWnd = (HWND) parent->GetHWND(); RECTL vRect;
RECT vRect2;
RECT vRect3;
RECT rect; hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
::GetClientRect(hWnd, &rect); ::WinQueryWindowRect(hClientWnd, &vRect2);
RECT rect2; if (pParent)
GetWindowRect(hWnd, &rect2); hParentWnd = (HWND) pParent->GetHWND();
::WinQueryWindowRect(hWnd, &vRect);
::WinQueryWindowRect(hParentWnd, &vRect3);
//
// Find the difference between the entire window (title bar and all) // Find the difference between the entire window (title bar and all)
// and the client area; add this to the new client size to move the // and the client area; add this to the new client size to move the
// window // window. OS/2 is backward from windows on height
int actual_width = rect2.right - rect2.left - rect.right + width; //
int actual_height = rect2.bottom - rect2.top - rect.bottom + height; int nActualWidth = vRect2.xRight - vRect2.xLeft - vRect.xRight + nWidth;
int nActualHeight = vRect2.yTop - vRect2.yBottom - vRect.yTop + nHeight;
// If there's a parent, must subtract the parent's top left corner //
// If there's a parent, must subtract the parent's bottom left corner
// since MoveWindow moves relative to the parent // since MoveWindow moves relative to the parent
//
POINTL vPoint;
POINT point; vPoint.x = vRect2.xLeft;
point.x = rect2.left; vPoint.y = vRect2.yBottom;
point.y = rect2.top; if (pParent)
if ( parent )
{ {
::ScreenToClient(hParentWnd, &point); vPoint.x -= vRect3.xLeft;
vPoint.y -= vRect3.xBottom;
} }
DoMoveWindow(point.x, point.y, actual_width, actual_height); DoMoveWindow( vPoint.x
,vPoint.y
,nActualWidth
,nActualHeight
);
wxSizeEvent event(wxSize(width, height), m_windowId); wxSizeEvent vEvent( wxSize( nWidth
event.SetEventObject(this); ,nHeight
GetEventHandler()->ProcessEvent(event); )
} ,m_windowId
);
vEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(vEvent);
} // end of wxWindow::DoSetClientSize
wxPoint wxWindow::GetClientAreaOrigin() const wxPoint wxWindow::GetClientAreaOrigin() const
{ {
return wxPoint(0, 0); return wxPoint(0, 0);
} } // end of wxWindow::GetClientAreaOrigin
void wxWindow::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags) void wxWindow::AdjustForParentClientOrigin(
int& rX
, int& rY
, int nSizeFlags
)
{ {
// don't do it for the dialogs/frames - they float independently of their //
// Don't do it for the dialogs/frames - they float independently of their
// parent // parent
if ( !IsTopLevel() ) //
if (!IsTopLevel())
{ {
wxWindow *parent = GetParent(); wxWindow* pParent = GetParent();
if ( !(sizeFlags & wxSIZE_NO_ADJUSTMENTS) && parent )
if (!(nSizeFlags & wxSIZE_NO_ADJUSTMENTS) && pParent)
{ {
wxPoint pt(parent->GetClientAreaOrigin()); wxPoint vPoint(pParent->GetClientAreaOrigin());
x += pt.x; y += pt.y; rX += vPoint.x;
rY += vPoint.y;
} }
} }
} } // end of wxWindow::AdjustForParentClientOrigin
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// text metrics // text metrics
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
int wxWindow::GetCharHeight() const int wxWindow::GetCharHeight() const
{ {
// TODO: HPS hPs;
return(1); FONTMETRICS vFontMetrics;
} BOOL bRc;
int wxWindow::GetCharWidth() const hPs = ::WinGetPS(GetHwnd());
{
// TODO:
return(1);
}
void wxWindow::GetTextExtent( const wxString& string if(!GipQueryFontMetrics(hPs, sizeof(FONTMETIRCS), &vFontMetrics);
,int* x return (0);
,int* y else
,int* descent return(vFontMetrics.lMaxAscender + vFontMetrics.lMaxDescender);
,int* externalLeading ::WinReleasePS(hPs);
,const wxFont* theFont } // end of wxWindow::GetCharHeight
) const
int wxWindow::GetCharWidth() const
{ {
// TODO: hPs = ::WinGetPS(GetHwnd());
if(!GipQueryFontMetrics(hPs, sizeof(FONTMETIRCS), &vFontMetrics);
return (0);
else
return(vFontMetrics.lAveCharWidth);
::WinReleasePS(hPs);
} // end of wxWindow::GetCharWidth
void wxWindow::GetTextExtent(
const wxString& rString
, int* pX
, int* pY
, int* pDescent
, int* pExternalLeading
, const wxFont* pTheFont
) const
{
const wxFont* pFontToUse = pTheFont;
HPS hPs;
hPs = ::WinGetPS(GetHwnd());
/*
// TODO: Will have to play with fonts later
if (!pFontToUse)
pFontToUse = &m_font;
HFONT hFnt = 0;
HFONT hFfontOld = 0;
if (pFontToUse && pFontToUse->Ok())
{
::GpiCreateLog
hFnt = (HFONT)((wxFont *)pFontToUse)->GetResourceHandle(); // const_cast
if (hFnt)
hFontOld = (HFONT)SelectObject(dc,fnt);
}
SIZE sizeRect;
TEXTMETRIC tm;
GetTextExtentPoint(dc, string, (int)string.Length(), &sizeRect);
GetTextMetrics(dc, &tm);
if ( fontToUse && fnt && hfontOld )
SelectObject(dc, hfontOld);
ReleaseDC(hWnd, dc);
if ( x )
*x = sizeRect.cx;
if ( y )
*y = sizeRect.cy;
if ( descent )
*descent = tm.tmDescent;
if ( externalLeading )
*externalLeading = tm.tmExternalLeading;
*/
::WinReleasePS(hPs);
} }
#if wxUSE_CARET && WXWIN_COMPATIBILITY #if wxUSE_CARET && WXWIN_COMPATIBILITY
@@ -1246,35 +1397,60 @@ void wxWindow::GetTextExtent( const wxString& string
// Caret manipulation // Caret manipulation
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
void wxWindow::CreateCaret(int w, int h) void wxWindow::CreateCaret(
int nWidth
, int nHeight
)
{ {
// TODO: SetCaret(new wxCaret( this
} ,nWidth
,nHeight
));
} // end of wxWindow::CreateCaret
void wxWindow::CreateCaret(const wxBitmap *bitmap) void wxWindow::CreateCaret(
const wxBitmap* pBitmap
)
{ {
// TODO: wxFAIL_MSG("not implemented");
} } // end of wxWindow::CreateCaret
void wxWindow::ShowCaret(bool show) void wxWindow::ShowCaret(
bool bShow
)
{ {
// TODO: wxCHECK_RET( m_caret, "no caret to show" );
}
m_caret->Show(bShow);
} // end of wxWindow::ShowCaret
void wxWindow::DestroyCaret() void wxWindow::DestroyCaret()
{ {
// TODO: SetCaret(NULL);
} } // end of wxWindow::DestroyCaret
void wxWindow::SetCaretPos(int x, int y) void wxWindow::SetCaretPos(
int nX
, int nY)
{ {
// TODO: wxCHECK_RET( m_caret, "no caret to move" );
}
void wxWindow::GetCaretPos(int *x, int *y) const m_caret->Move( nX
,nY
);
} // end of wxWindow::SetCaretPos
void wxWindow::GetCaretPos(
int* pX
, int* pY
) const
{ {
// TODO: wxCHECK_RET( m_caret, "no caret to get position of" );
}
m_caret->GetPosition( pX
,pY
);
} // end of wxWindow::GetCaretPos
#endif //wxUSE_CARET #endif //wxUSE_CARET