X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/96f201da8b08391fd719ad74875b87afacc8fc97..7b9da2077d0975db6c965a85c91d5aca671ab5e3:/src/motif/dcclient.cpp diff --git a/src/motif/dcclient.cpp b/src/motif/dcclient.cpp index 7e2c71d1c8..42ad9258d7 100644 --- a/src/motif/dcclient.cpp +++ b/src/motif/dcclient.cpp @@ -127,6 +127,7 @@ wxWindowDC::wxWindowDC( wxWindow *window ) wxASSERT_MSG( (window != (wxWindow*) NULL), "You must pass a valid wxWindow to wxWindowDC/wxClientDC/wxPaintDC constructor." ); m_window = window; + m_font = window->GetFont(); m_gc = (WXGC) 0; m_gcBacking = (WXGC) 0; m_backgroundPixel = -1; @@ -203,20 +204,20 @@ wxWindowDC::~wxWindowDC() m_userRegion = (WXRegion) 0; } -void wxWindowDC::DoFloodFill( long WXUNUSED(x1), long WXUNUSED(y1), +void wxWindowDC::DoFloodFill( wxCoord WXUNUSED(x1), wxCoord WXUNUSED(y1), const wxColour& WXUNUSED(col), int WXUNUSED(style) ) { wxFAIL_MSG("not implemented"); } -bool wxWindowDC::DoGetPixel( long WXUNUSED(x1), long WXUNUSED(y1), wxColour *WXUNUSED(col) ) const +bool wxWindowDC::DoGetPixel( wxCoord WXUNUSED(x1), wxCoord WXUNUSED(y1), wxColour *WXUNUSED(col) ) const { wxFAIL_MSG("not implemented"); return FALSE; } -void wxWindowDC::DoDrawLine( long x1, long y1, long x2, long y2 ) +void wxWindowDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ) { wxCHECK_RET( Ok(), "invalid dc" ); @@ -243,7 +244,7 @@ void wxWindowDC::DoDrawLine( long x1, long y1, long x2, long y2 ) CalcBoundingBox(x2, y2); } -void wxWindowDC::DoCrossHair( long x, long y ) +void wxWindowDC::DoCrossHair( wxCoord x, wxCoord y ) { wxCHECK_RET( Ok(), "invalid dc" ); @@ -272,7 +273,7 @@ void wxWindowDC::DoCrossHair( long x, long y ) } } -void wxWindowDC::DoDrawArc( long x1, long y1, long x2, long y2, long xc, long yc ) +void wxWindowDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc ) { wxCHECK_RET( Ok(), "invalid dc" ); @@ -287,10 +288,10 @@ void wxWindowDC::DoDrawArc( long x1, long y1, long x2, long y2, long xc, long yc int xxc_2 = XLOG2DEV_2 (xc); int yyc_2 = YLOG2DEV_2 (yc); - long dx = xx1 - xxc; - long dy = yy1 - yyc; + wxCoord dx = xx1 - xxc; + wxCoord dy = yy1 - yyc; double radius = sqrt (dx * dx + dy * dy); - long r = (long) radius; + wxCoord r = (wxCoord) radius; double radius1, radius2; @@ -355,7 +356,7 @@ void wxWindowDC::DoDrawArc( long x1, long y1, long x2, long y2, long xc, long yc CalcBoundingBox (x2, y2); } -void wxWindowDC::DoDrawEllipticArc( long x, long y, long width, long height, double sa, double ea ) +void wxWindowDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double sa, double ea ) { wxCHECK_RET( Ok(), "invalid dc" ); @@ -400,7 +401,7 @@ void wxWindowDC::DoDrawEllipticArc( long x, long y, long width, long height, dou CalcBoundingBox (x + width, y + height); } -void wxWindowDC::DoDrawPoint( long x, long y ) +void wxWindowDC::DoDrawPoint( wxCoord x, wxCoord y ) { wxCHECK_RET( Ok(), "invalid dc" ); @@ -416,7 +417,7 @@ void wxWindowDC::DoDrawPoint( long x, long y ) CalcBoundingBox (x, y); } -void wxWindowDC::DoDrawLines( int n, wxPoint points[], long xoffset, long yoffset ) +void wxWindowDC::DoDrawLines( int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset ) { wxCHECK_RET( Ok(), "invalid dc" ); @@ -451,7 +452,7 @@ void wxWindowDC::DoDrawLines( int n, wxPoint points[], long xoffset, long yoffse } void wxWindowDC::DoDrawPolygon( int n, wxPoint points[], - long xoffset, long yoffset, int fillStyle ) + wxCoord xoffset, wxCoord yoffset, int fillStyle ) { wxCHECK_RET( Ok(), "invalid dc" ); @@ -504,7 +505,7 @@ void wxWindowDC::DoDrawPolygon( int n, wxPoint points[], delete[]xpoints2; } -void wxWindowDC::DoDrawRectangle( long x, long y, long width, long height ) +void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) { wxCHECK_RET( Ok(), "invalid dc" ); @@ -549,7 +550,7 @@ void wxWindowDC::DoDrawRectangle( long x, long y, long width, long height ) CalcBoundingBox (x + width, y + height); } -void wxWindowDC::DoDrawRoundedRectangle( long x, long y, long width, long height, double radius ) +void wxWindowDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius ) { wxCHECK_RET( Ok(), "invalid dc" ); @@ -713,7 +714,7 @@ void wxWindowDC::DoDrawRoundedRectangle( long x, long y, long width, long height } -void wxWindowDC::DoDrawEllipse( long x, long y, long width, long height ) +void wxWindowDC::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) { wxCHECK_RET( Ok(), "invalid dc" ); @@ -776,7 +777,7 @@ bool wxWindowDC::CanDrawBitmap() const } #if 0 -void wxWindowDC::DoDrawIcon( const wxIcon &icon, long x, long y) +void wxWindowDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y) { // FreeGetPixelCache(); @@ -836,8 +837,8 @@ void wxWindowDC::DoDrawIcon( const wxIcon &icon, long x, long y) #endif // 0 // TODO: use scaled Blit e.g. as per John Price's implementation in Contrib/Utilities -bool wxWindowDC::DoBlit( long xdest, long ydest, long width, long height, - wxDC *source, long xsrc, long ysrc, int rop, bool useMask ) +bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, + wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop, bool useMask ) { wxCHECK_MSG( Ok(), FALSE, "invalid dc" ); @@ -1010,7 +1011,7 @@ bool wxWindowDC::DoBlit( long xdest, long ydest, long width, long height, return FALSE; } -void wxWindowDC::DoDrawText( const wxString &text, long x, long y ) +void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) { wxCHECK_RET( Ok(), "invalid dc" ); @@ -1154,7 +1155,7 @@ void wxWindowDC::DoDrawText( const wxString &text, long x, long y ) XLOG2DEV_2 (x), YLOG2DEV_2 (y) + ascent, (char*) (const char*) text, slen); } - long w, h; + wxCoord w, h; GetTextExtent (text, &w, &h); CalcBoundingBox (x + w, y + h); CalcBoundingBox (x, y); @@ -1165,8 +1166,8 @@ bool wxWindowDC::CanGetTextExtent() const return TRUE; } -void wxWindowDC::GetTextExtent( const wxString &string, long *width, long *height, - long *descent, long *externalLeading, +void wxWindowDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *height, + wxCoord *descent, wxCoord *externalLeading, wxFont *font ) const { wxCHECK_RET( Ok(), "invalid dc" ); @@ -1180,8 +1181,8 @@ void wxWindowDC::GetTextExtent( const wxString &string, long *width, long *heigh // TODO: this should be an error log function wxFAIL_MSG("set a valid font before calling GetTextExtent!"); - *width = -1; - *height = -1; + if (width) *width = -1; + if (height) *height = -1; return; } @@ -1207,15 +1208,15 @@ void wxWindowDC::GetTextExtent( const wxString &string, long *width, long *heigh XTextExtents((XFontStruct*) pFontStruct, (char*) (const char*) string, slen, &direction, &ascent, &descent2, &overall); - *width = XDEV2LOGREL (overall.width); - *height = YDEV2LOGREL (ascent + descent2); + if (width) *width = XDEV2LOGREL (overall.width); + if (height) *height = YDEV2LOGREL (ascent + descent2); if (descent) *descent = descent2; if (externalLeading) *externalLeading = 0; } -long wxWindowDC::GetCharWidth() const +wxCoord wxWindowDC::GetCharWidth() const { wxCHECK_MSG( Ok(), 0, "invalid dc" ); wxCHECK_MSG( m_font.Ok(), 0, "invalid font" ); @@ -1229,7 +1230,7 @@ long wxWindowDC::GetCharWidth() const return XDEV2LOGREL(overall.width); } -long wxWindowDC::GetCharHeight() const +wxCoord wxWindowDC::GetCharHeight() const { wxCHECK_MSG( Ok(), 0, "invalid dc" ); wxCHECK_MSG( m_font.Ok(), 0, "invalid font" ); @@ -1308,7 +1309,7 @@ void wxWindowDC::SetFont( const wxFont &font ) if (!m_font.Ok()) { - if ((m_oldFont != (WXFont) 0) && ((long) m_oldFont != -1)) + if ((m_oldFont != (WXFont) 0) && ((wxCoord) m_oldFont != -1)) { XSetFont ((Display*) m_display, (GC) m_gc, (Font) m_oldFont); @@ -1380,10 +1381,10 @@ void wxWindowDC::SetPen( const wxPen &pen ) int style; int join; int cap; - const static char dotted[] = {2, 5}; - const static char short_dashed[] = {4, 4}; - const static char long_dashed[] = {4, 8}; - const static char dotted_dashed[] = {6, 6, 2, 6}; + static const char dotted[] = {2, 5}; + static const char short_dashed[] = {4, 4}; + static const char long_dashed[] = {4, 8}; + static const char dotted_dashed[] = {6, 6, 2, 6}; // We express dash pattern in pen width unit, so we are // independent of zoom factor and so on... @@ -1990,9 +1991,9 @@ void wxWindowDC::SetDCClipping() } -void wxWindowDC::DoSetClippingRegion( long x, long y, long width, long height ) +void wxWindowDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) { - wxDC::SetClippingRegion( x, y, width, height ); + wxDC::DoSetClippingRegion( x, y, width, height ); if (m_userRegion) XDestroyRegion ((Region) m_userRegion); @@ -2023,7 +2024,7 @@ void wxWindowDC::DoSetClippingRegionAsRegion( const wxRegion& region ) { wxRect box = region.GetBox(); - wxDC::SetClippingRegion( box.x, box.y, box.width, box.height ); + wxDC::DoSetClippingRegion( box.x, box.y, box.width, box.height ); if (m_userRegion) XDestroyRegion ((Region) m_userRegion); @@ -2193,7 +2194,7 @@ static void wx_spline_draw_point_array(wxDC *dc) void wxWindowDC::DoDrawSpline( wxList *points ) { - wxCHECK_RET( Ok(), _T("invalid window dc") ); + wxCHECK_RET( Ok(), wxT("invalid window dc") ); wxPoint *p; double cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4; @@ -2283,6 +2284,9 @@ wxPaintDC::wxPaintDC(wxWindow* win) : wxWindowDC(win) win->SetUpdateRegion(*region); + wxRegion& theRegion(win->GetUpdateRegion()); + theRegion.SetRects(updateRects); // We also store in terms of rects, for iteration to work. + // Set the clipping region. Any user-defined region will be combined with this // one in SetDCClipping. XSetRegion ((Display*) m_display, (GC) m_gc, (Region) region->GetXRegion());