return wxGCPool[i].m_gc;
}
}
-
+
wxFAIL_MSG( wxT("No GC available") );
-
+
return (GdkGC*) NULL;
}
return;
}
}
-
+
wxFAIL_MSG( wxT("Wrong GC") );
}
void wxWindowDC::SetUpDC()
{
m_ok = TRUE;
-
+
wxASSERT_MSG( !m_penGC, wxT("GCs already created") );
-
+
if (m_isMemDC && (((wxMemoryDC*)this)->m_selected.GetDepth() == 1))
{
m_penGC = wxGetPoolGC( m_window, wxPEN_MONO );
m_pen.GetColour().CalcPixel( m_cmap );
gdk_gc_set_foreground( m_penGC, m_pen.GetColour().GetColor() );
gdk_gc_set_background( m_penGC, bg_col );
-
+
gdk_gc_set_line_attributes( m_penGC, 0, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_ROUND );
-
+
/* m_brushGC */
m_brush.GetColour().CalcPixel( m_cmap );
gdk_gc_set_foreground( m_brushGC, m_brush.GetColour().GetColor() );
gdk_gc_set_background( m_brushGC, bg_col );
-
+
gdk_gc_set_fill( m_brushGC, GDK_SOLID );
-
+
/* m_bgGC */
gdk_gc_set_background( m_bgGC, bg_col );
gdk_gc_set_foreground( m_bgGC, bg_col );
gdk_gc_set_fill( m_bgGC, GDK_SOLID );
-
+
/* ROPs */
gdk_gc_set_function( m_textGC, GDK_COPY );
gdk_gc_set_function( m_brushGC, GDK_COPY );
gdk_gc_set_function( m_penGC, GDK_COPY );
-
+
/* clipping */
gdk_gc_set_clip_rectangle( m_penGC, (GdkRectangle *) NULL );
gdk_gc_set_clip_rectangle( m_brushGC, (GdkRectangle *) NULL );
{
if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
{
- gdk_gc_set_ts_origin( m_textGC,
- m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
+ gdk_gc_set_ts_origin( m_textGC,
+ m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
gdk_draw_polygon( m_window, m_textGC, TRUE, gdkpoints, n );
gdk_gc_set_ts_origin( m_textGC, 0, 0 );
} else
if (m_brush.GetStyle() == wxSTIPPLE)
{
- gdk_gc_set_ts_origin( m_brushGC,
- m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
+ gdk_gc_set_ts_origin( m_brushGC,
+ m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
gdk_draw_polygon( m_window, m_brushGC, TRUE, gdkpoints, n );
gdk_gc_set_ts_origin( m_brushGC, 0, 0 );
{
if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
{
- gdk_gc_set_ts_origin( m_textGC,
- m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
+ gdk_gc_set_ts_origin( m_textGC,
+ m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
gdk_draw_rectangle( m_window, m_textGC, TRUE, xx, yy, ww, hh );
gdk_gc_set_ts_origin( m_textGC, 0, 0 );
}
else if (m_brush.GetStyle() == wxSTIPPLE)
{
- gdk_gc_set_ts_origin( m_brushGC,
- m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
+ gdk_gc_set_ts_origin( m_brushGC,
+ m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy, ww, hh );
gdk_gc_set_ts_origin( m_brushGC, 0, 0 );
{
if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
{
- gdk_gc_set_ts_origin( m_textGC,
- m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
+ gdk_gc_set_ts_origin( m_textGC,
+ m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
gdk_draw_rectangle( m_window, m_textGC, TRUE, xx+rr, yy, ww-dd+1, hh );
gdk_draw_rectangle( m_window, m_textGC, TRUE, xx, yy+rr, ww, hh-dd+1 );
}
else if (m_brush.GetStyle() == wxSTIPPLE)
{
- gdk_gc_set_ts_origin( m_brushGC,
- m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
+ gdk_gc_set_ts_origin( m_brushGC,
+ m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx+rr, yy, ww-dd+1, hh );
gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy+rr, ww, hh-dd+1 );
{
if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
{
- gdk_gc_set_ts_origin( m_textGC,
- m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
+ gdk_gc_set_ts_origin( m_textGC,
+ m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
gdk_draw_arc( m_window, m_textGC, TRUE, xx, yy, ww, hh, 0, 360*64 );
gdk_gc_set_ts_origin( m_textGC, 0, 0 );
}
else if (m_brush.GetStyle() == wxSTIPPLE)
{
- gdk_gc_set_ts_origin( m_brushGC,
- m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
+ gdk_gc_set_ts_origin( m_brushGC,
+ m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, 0, 360*64 );
gdk_gc_set_ts_origin( m_brushGC, 0, 0 );
if (tmp.IsEmpty())
return;
}
-
+
/* scale bitmap if required */
wxBitmap use_bitmap;
if ((w != ww) || (h != hh))
gdk_draw_rectangle( new_mask, gc, TRUE, 0, 0, ww, hh );
gdk_gc_unref( gc );
}
-
+
if (is_mono)
{
if (new_mask)
int old_logical_func = m_logicalFunction;
SetLogicalFunction( logical_func );
-
+
if (use_bitmap_method)
{
/* scale/translate bitmap size */
gdk_draw_rectangle( new_mask, gc, TRUE, 0, 0, bm_ww, bm_hh );
gdk_gc_unref( gc );
}
-
+
if (is_mono)
{
if (new_mask)
/* Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For
drawing a mono-bitmap (XBitmap) we use the current text GC */
-
+
if (is_mono)
gdk_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), xsrc, ysrc, xx, yy, ww, hh );
else
for a different implementation of the same problem. */
wxBitmap bitmap( width, height );
-
+
/* copy including child window contents */
gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS );
gdk_window_copy_area( bitmap.GetPixmap(), m_penGC, 0, 0,
srcDC->GetWindow(),
xsrc, ysrc, width, height );
gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN );
-
+
/* scale image */
wxImage image( bitmap );
image = image.Scale( ww, hh );
width = (int)w;
}
- static const char dotted[] = {1, 1};
- static const char short_dashed[] = {2, 2};
- static const char wxCoord_dashed[] = {2, 4};
- static const char dotted_dashed[] = {3, 3, 1, 3};
+ static const wxGTKDash dotted[] = {1, 1};
+ static const wxGTKDash short_dashed[] = {2, 2};
+ static const wxGTKDash wxCoord_dashed[] = {2, 4};
+ static const wxGTKDash 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;
+ const wxGTKDash *req_dash;
GdkLineStyle lineStyle = GDK_LINE_SOLID;
switch (m_pen.GetStyle())
{
lineStyle = GDK_LINE_ON_OFF_DASH;
req_nb_dash = m_pen.GetDashCount();
- req_dash = m_pen.GetDash();
+ req_dash = (wxGTKDash*)m_pen.GetDash();
break;
}
case wxDOT:
default:
{
lineStyle = GDK_LINE_SOLID;
- req_dash = (wxDash*)NULL;
+ req_dash = (wxGTKDash*)NULL;
req_nb_dash = 0;
break;
}
}
-#if (GTK_MINOR_VERSION > 0)
+#if (GTK_MINOR_VERSION > 0) || (GTK_MAJOR_VERSION > 1)
if (req_dash && req_nb_dash)
{
- char *real_req_dash = new char[req_nb_dash];
+ wxGTKDash *real_req_dash = new wxGTKDash[req_nb_dash];
if (real_req_dash)
{
for (int i = 0; i < req_nb_dash; i++)
else
{
// No Memory. We use non-scaled dash pattern...
- gdk_gc_set_dashes( m_penGC, 0, (char*)req_dash, req_nb_dash );
+ gdk_gc_set_dashes( m_penGC, 0, (wxGTKDash*)req_dash, req_nb_dash );
}
}
#endif
{
wxCHECK_RET( Ok(), wxT("invalid window dc") );
- wxDC::DoSetClippingRegion( x, y, width, height );
-
if (!m_window) return;
wxRect rect;
rect.y = YLOG2DEV(y);
rect.width = XLOG2DEVREL(width);
rect.height = YLOG2DEVREL(height);
-
+
if (!m_currentClippingRegion.IsNull())
m_currentClippingRegion.Intersect( rect );
else
m_currentClippingRegion.Union( rect );
-
-#if USE_PAINT_REGION
+
+#if USE_PAINT_REGION
if (!m_paintClippingRegion.IsNull())
m_currentClippingRegion.Intersect( m_paintClippingRegion );
#endif
+ wxCoord xx, yy, ww, hh;
+ m_currentClippingRegion.GetBox( xx, yy, ww, hh );
+ wxDC::DoSetClippingRegion( xx, yy, ww, hh );
+
gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() );
gdk_gc_set_clip_region( m_brushGC, m_currentClippingRegion.GetRegion() );
gdk_gc_set_clip_region( m_textGC, m_currentClippingRegion.GetRegion() );
return;
}
- wxCoord x,y,w,h;
- region.GetBox( x, y, w, h );
-
- wxDC::DoSetClippingRegion( x, y, w, h );
-
if (!m_window) return;
-
+
if (!m_currentClippingRegion.IsNull())
m_currentClippingRegion.Intersect( region );
else
m_currentClippingRegion.Union( region );
-
-#if USE_PAINT_REGION
+
+#if USE_PAINT_REGION
if (!m_paintClippingRegion.IsNull())
m_currentClippingRegion.Intersect( m_paintClippingRegion );
#endif
+ wxCoord xx, yy, ww, hh;
+ m_currentClippingRegion.GetBox( xx, yy, ww, hh );
+ wxDC::DoSetClippingRegion( xx, yy, ww, hh );
+
gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() );
gdk_gc_set_clip_region( m_brushGC, m_currentClippingRegion.GetRegion() );
gdk_gc_set_clip_region( m_textGC, m_currentClippingRegion.GetRegion() );
wxDC::DestroyClippingRegion();
m_currentClippingRegion.Clear();
-
-#if USE_PAINT_REGION
+
+#if USE_PAINT_REGION
if (!m_paintClippingRegion.IsEmpty())
m_currentClippingRegion.Union( m_paintClippingRegion );
#endif
wxPaintDC::wxPaintDC( wxWindow *win )
: wxWindowDC( win )
{
-#if USE_PAINT_REGION
- m_paintClippingRegion = win->GetUpdateRegion();
- m_currentClippingRegion.Union( m_paintClippingRegion );
+#if USE_PAINT_REGION
+ if (!win->m_clipPaintRegion)
+ return;
- gdk_gc_set_clip_region( m_penGC, m_paintClippingRegion.GetRegion() );
- gdk_gc_set_clip_region( m_brushGC, m_paintClippingRegion.GetRegion() );
- gdk_gc_set_clip_region( m_textGC, m_paintClippingRegion.GetRegion() );
- gdk_gc_set_clip_region( m_bgGC, m_paintClippingRegion.GetRegion() );
+ m_paintClippingRegion = win->GetUpdateRegion();
+ GdkRegion *region = m_paintClippingRegion.GetRegion();
+ if ( region )
+ {
+ m_currentClippingRegion.Union( m_paintClippingRegion );
+
+ gdk_gc_set_clip_region( m_penGC, region );
+ gdk_gc_set_clip_region( m_brushGC, region );
+ gdk_gc_set_clip_region( m_textGC, region );
+ gdk_gc_set_clip_region( m_bgGC, region );
+ }
#endif
}