X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6db90681cf0b58209a061561f5d3624f6eda8024..1ecffbff714ff707ded9266bf27c3347946cbcd9:/src/gtk1/dcclient.cpp?ds=inline diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index 560c4162ef..6505cb6786 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -110,12 +110,13 @@ wxWindowDC::wxWindowDC( wxWindow *window ) m_cmap = (GdkColormap *) NULL; m_owner = (wxWindow *)NULL; m_isMemDC = FALSE; + m_font = window->GetFont(); - wxASSERT_MSG( window, "DC needs a window" ); + wxASSERT_MSG( window, _T("DC needs a window") ); GtkWidget *widget = window->m_wxwindow; - wxASSERT_MSG( widget, "DC needs a widget" ); + wxASSERT_MSG( widget, _T("DC needs a widget") ); m_window = widget->window; @@ -487,8 +488,6 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, wxCHECK_RET( bitmap.Ok(), _T("invalid bitmap") ); - if (!m_window) return; - /* scale/translate size and position */ int xx = XLOG2DEV(x); @@ -497,6 +496,11 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, int w = bitmap.GetWidth(); int h = bitmap.GetHeight(); + CalcBoundingBox( x, y ); + CalcBoundingBox( x + w, y + h ); + + if (!m_window) return; + int ww = XLOG2DEVREL(w); int hh = YLOG2DEVREL(h); @@ -550,9 +554,6 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, gdk_gc_set_clip_mask( m_penGC, (GdkBitmap *) NULL ); gdk_gc_set_clip_origin( m_penGC, 0, 0 ); } - - CalcBoundingBox( x, y ); - CalcBoundingBox( x + w, y + h ); } bool wxWindowDC::DoBlit( long xdest, long ydest, long width, long height, @@ -863,9 +864,9 @@ void wxWindowDC::SetPen( const wxPen &pen ) if (!m_window) return; gint width = m_pen.GetWidth(); - // CMB: if width is non-zero scale it with the dc if (width <= 0) { + // CMB: if width is non-zero scale it with the dc width = 1; } else @@ -876,16 +877,85 @@ void wxWindowDC::SetPen( const wxPen &pen ) width = (int)w; } + const static char dotted[] = {1, 1}; + const static char short_dashed[] = {2, 2}; + const static char long_dashed[] = {2, 4}; + const static char dotted_dashed[] = {3, 3, 1, 3}; + + // We express dash pattern in pen width unit, so we are + // independent of zoom factor and so on... + int req_nb_dash; + const char *req_dash; + GdkLineStyle lineStyle = GDK_LINE_SOLID; switch (m_pen.GetStyle()) { - case wxSOLID: { lineStyle = GDK_LINE_SOLID; break; } - case wxDOT: { lineStyle = GDK_LINE_ON_OFF_DASH; break; } - case wxLONG_DASH: { lineStyle = GDK_LINE_ON_OFF_DASH; break; } - case wxSHORT_DASH: { lineStyle = GDK_LINE_ON_OFF_DASH; break; } - case wxDOT_DASH: { lineStyle = GDK_LINE_DOUBLE_DASH; break; } + case wxUSER_DASH: + { + lineStyle = GDK_LINE_ON_OFF_DASH; + req_nb_dash = m_pen.GetDashCount(); + req_dash = m_pen.GetDash(); + break; + } + case wxDOT: + { + lineStyle = GDK_LINE_ON_OFF_DASH; + req_nb_dash = 2; + req_dash = dotted; + break; + } + case wxLONG_DASH: + { + lineStyle = GDK_LINE_ON_OFF_DASH; + req_nb_dash = 2; + req_dash = long_dashed; + break; + } + case wxSHORT_DASH: + { + lineStyle = GDK_LINE_ON_OFF_DASH; + req_nb_dash = 2; + req_dash = short_dashed; + break; + } + case wxDOT_DASH: + { +// lineStyle = GDK_LINE_DOUBLE_DASH; + lineStyle = GDK_LINE_ON_OFF_DASH; + req_nb_dash = 4; + req_dash = dotted_dashed; + break; + } + + case wxTRANSPARENT: + case wxSTIPPLE: + case wxSOLID: + default: + { + lineStyle = GDK_LINE_SOLID; + req_dash = (wxDash*)NULL; + req_nb_dash = 0; + break; + } } + if (req_dash && req_nb_dash) + { + char *real_req_dash = new char[req_nb_dash]; + if (real_req_dash) + { + for (int i = 0; i < req_nb_dash; i++) + real_req_dash[i] = req_dash[i] * width; + gdk_gc_set_dashes( m_penGC, 0, real_req_dash, req_nb_dash ); + delete[] real_req_dash; + } + else + { + // No Memory. We use non-scaled dash pattern... + gdk_gc_set_dashes( m_penGC, 0, (char*)req_dash, req_nb_dash ); + } + } + GdkCapStyle capStyle = GDK_CAP_ROUND; switch (m_pen.GetCap()) { @@ -1025,7 +1095,7 @@ void wxWindowDC::SetLogicalFunction( int function ) #endif default: { - wxFAIL_MSG( "unsupported logical function" ); + wxFAIL_MSG( _T("unsupported logical function") ); break; } } @@ -1172,9 +1242,15 @@ void wxWindowDC::SetUpDC() m_brush = wxNullBrush; SetBrush( tmp_brush ); +/* tmp_brush = m_backgroundBrush; m_backgroundBrush = wxNullBrush; SetBackground( tmp_brush ); +*/ + tmp_brush = m_backgroundBrush; + m_backgroundBrush = wxNullBrush; + SetBackground( *wxWHITE_BRUSH ); + m_backgroundBrush = tmp_brush; if (!hatch_bitmap) { @@ -1200,6 +1276,26 @@ void wxWindowDC::Destroy() m_bgGC = (GdkGC*) NULL; } +void wxWindowDC::ComputeScaleAndOrigin() +{ + /* CMB: copy scale to see if it changes */ + double origScaleX = m_scaleX; + double origScaleY = m_scaleY; + + wxDC::ComputeScaleAndOrigin(); + + /* CMB: if scale has changed call SetPen to recalulate the line width */ + if ((m_scaleX != origScaleX || m_scaleY != origScaleY) && + (m_pen.Ok())) + { + /* this is a bit artificial, but we need to force wxDC to think + the pen has changed */ + wxPen pen = m_pen; + m_pen = wxNullPen; + SetPen( pen ); + } +} + // Resolution in pixels per logical inch wxSize wxWindowDC::GetPPI() const {