X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a44f67c38235b3bf11cfd8c95b194b2d2ad74237..b636c599e732992304d8de6ec569392e7c83a7dc:/src/motif/window.cpp diff --git a/src/motif/window.cpp b/src/motif/window.cpp index feda98f8ec..63a644d310 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -364,7 +364,7 @@ wxWindow::~wxWindow() g_captureWindow = NULL; m_isBeingDeleted = true; - + // Motif-specific actions first WXWidget wMain = GetMainWidget(); if ( wMain ) @@ -1436,6 +1436,8 @@ void wxWindow::DoMoveWindowIntr(int xx, int yy, int w, int h, } else { + if( xx < 0 ) xx = 0; + if( yy < 0 ) yy = 0; if( w < 1 ) w = 1; if( h < 1 ) h = 1; @@ -1462,29 +1464,24 @@ int wxWindow::GetCharHeight() const { wxCHECK_MSG( m_font.Ok(), 0, "valid window font needed" ); - WXFontStructPtr pFontStruct = m_font.GetFontStruct(1.0, GetXDisplay()); - - int direction, ascent, descent; - XCharStruct overall; - XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent, - &descent, &overall); + int height; + + wxGetTextExtent (GetXDisplay(), m_font, 1.0, + "x", NULL, &height, NULL, NULL); - // return (overall.ascent + overall.descent); - return (ascent + descent); + return height; } int wxWindow::GetCharWidth() const { wxCHECK_MSG( m_font.Ok(), 0, "valid window font needed" ); - WXFontStructPtr pFontStruct = m_font.GetFontStruct(1.0, GetXDisplay()); - - int direction, ascent, descent; - XCharStruct overall; - XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent, - &descent, &overall); + int width; + + wxGetTextExtent (GetXDisplay(), m_font, 1.0, + "x", &width, NULL, NULL, NULL); - return overall.width; + return width; } void wxWindow::GetTextExtent(const wxString& string, @@ -1492,36 +1489,14 @@ void wxWindow::GetTextExtent(const wxString& string, int *descent, int *externalLeading, const wxFont *theFont) const { - wxFont *fontToUse = (wxFont *)theFont; - if (!fontToUse) - fontToUse = (wxFont *) & m_font; + const wxFont *fontToUse = theFont ? theFont : &m_font; wxCHECK_RET( fontToUse->Ok(), "valid window font needed" ); - - WXFontStructPtr pFontStruct = fontToUse->GetFontStruct(1.0, GetXDisplay()); - int direction, ascent, descent2; - XCharStruct overall; - int slen = string.Len(); - -#if 0 - if (use16) - XTextExtents16((XFontStruct*) pFontStruct, (XChar2b *) (char*) (const char*) string, slen, &direction, - &ascent, &descent2, &overall); -#endif - - XTextExtents((XFontStruct*) pFontStruct, string, slen, - &direction, &ascent, &descent2, &overall); - - if ( x ) - *x = (overall.width); - if ( y ) - *y = (ascent + descent2); - if (descent) - *descent = descent2; if (externalLeading) *externalLeading = 0; - + wxGetTextExtent (GetXDisplay(), *fontToUse, 1.0, + string, x, y, NULL, descent); } // ---------------------------------------------------------------------------- @@ -1832,13 +1807,18 @@ bool wxWindow::AttachWidget (wxWindow* WXUNUSED(parent), WXWidget mainWidget, XtFree ((char *) ptr); } - if (x == -1) - x = 0; - if (y == -1) - y = 0; - SetSize (x, y, width, height); + SetInitialBestSize(wxSize(width, height)); - return TRUE; + if (x != -1 || y != -1) + { + if (x == -1) + x = 0; + if (y == -1) + y = 0; + Move(x, y); + } + + return true; } // Remove event handler, remove from hash table