#include <math.h> // for floating-point functions
#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
#include <gtk/gtk.h>
+//-----------------------------------------------------------------------------
+// local defines
+//-----------------------------------------------------------------------------
+
+#define USE_PAINT_REGION 1
+
//-----------------------------------------------------------------------------
// local data
//-----------------------------------------------------------------------------
// Implement Pool of Graphic contexts. Creating them takes too much time.
//-----------------------------------------------------------------------------
+#define GC_POOL_SIZE 200
+
enum wxPoolGCType
{
wxGC_ERROR = 0,
bool m_used;
};
-static wxGC wxGCPool[200];
+static wxGC wxGCPool[GC_POOL_SIZE];
static void wxInitGCPool()
{
- memset( wxGCPool, 0, 200*sizeof(wxGC) );
+ memset( wxGCPool, 0, GC_POOL_SIZE*sizeof(wxGC) );
}
static void wxCleanUpGCPool()
{
- for (int i = 0; i < 200; i++)
+ for (int i = 0; i < GC_POOL_SIZE; i++)
{
if (wxGCPool[i].m_gc)
gdk_gc_unref( wxGCPool[i].m_gc );
static GdkGC* wxGetPoolGC( GdkWindow *window, wxPoolGCType type )
{
- for (int i = 0; i < 200; i++)
+ for (int i = 0; i < GC_POOL_SIZE; i++)
{
if (!wxGCPool[i].m_gc)
{
static void wxFreePoolGC( GdkGC *gc )
{
- for (int i = 0; i < 200; i++)
+ for (int i = 0; i < GC_POOL_SIZE; i++)
{
if (wxGCPool[i].m_gc == gc)
{
m_bgGC = (GdkGC *) NULL;
m_cmap = (GdkColormap *) NULL;
m_isMemDC = FALSE;
+ m_isScreenDC = FALSE;
m_owner = (wxWindow *)NULL;
}
m_cmap = (GdkColormap *) NULL;
m_owner = (wxWindow *)NULL;
m_isMemDC = FALSE;
+ m_isScreenDC = FALSE;
m_font = window->GetFont();
wxASSERT_MSG( window, wxT("DC needs a window") );
Destroy();
}
+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_brushGC = wxGetPoolGC( m_window, wxBRUSH_MONO );
+ m_textGC = wxGetPoolGC( m_window, wxTEXT_MONO );
+ m_bgGC = wxGetPoolGC( m_window, wxBG_MONO );
+ }
+ else
+ {
+ m_penGC = wxGetPoolGC( m_window, wxPEN_COLOUR );
+ m_brushGC = wxGetPoolGC( m_window, wxBRUSH_COLOUR );
+ m_textGC = wxGetPoolGC( m_window, wxTEXT_COLOUR );
+ m_bgGC = wxGetPoolGC( m_window, wxBG_COLOUR );
+ }
+
+ /* background colour */
+ m_backgroundBrush = *wxWHITE_BRUSH;
+ m_backgroundBrush.GetColour().CalcPixel( m_cmap );
+ GdkColor *bg_col = m_backgroundBrush.GetColour().GetColor();
+
+ /* m_textGC */
+ m_textForegroundColour.CalcPixel( m_cmap );
+ gdk_gc_set_foreground( m_textGC, m_textForegroundColour.GetColor() );
+
+ m_textBackgroundColour.CalcPixel( m_cmap );
+ gdk_gc_set_background( m_textGC, m_textBackgroundColour.GetColor() );
+
+ gdk_gc_set_fill( m_textGC, GDK_SOLID );
+
+ /* m_penGC */
+ 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 );
+ gdk_gc_set_clip_rectangle( m_textGC, (GdkRectangle *) NULL );
+ gdk_gc_set_clip_rectangle( m_bgGC, (GdkRectangle *) NULL );
+
+ if (!hatch_bitmap)
+ {
+ hatch_bitmap = hatches;
+ hatch_bitmap[0] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, bdiag_bits, bdiag_width, bdiag_height );
+ hatch_bitmap[1] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, cdiag_bits, cdiag_width, cdiag_height );
+ hatch_bitmap[2] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, fdiag_bits, fdiag_width, fdiag_height );
+ hatch_bitmap[3] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, cross_bits, cross_width, cross_height );
+ hatch_bitmap[4] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, horiz_bits, horiz_width, horiz_height );
+ hatch_bitmap[5] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, verti_bits, verti_width, verti_height );
+ }
+}
+
void wxWindowDC::DoFloodFill( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
const wxColour &WXUNUSED(col), int WXUNUSED(style) )
{
wxFAIL_MSG( wxT("wxWindowDC::DoFloodFill not implemented") );
}
-bool wxWindowDC::DoGetPixel( wxCoord WXUNUSED(x1), wxCoord WXUNUSED(y1), wxColour *WXUNUSED(col) ) const
+bool wxWindowDC::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const
{
- wxFAIL_MSG( wxT("wxWindowDC::DoGetPixel not implemented") );
- return FALSE;
+ // Generic (and therefore rather inefficient) method.
+ // Could be improved.
+ wxMemoryDC memdc;
+ wxBitmap bitmap(1, 1);
+ memdc.SelectObject(bitmap);
+ memdc.Blit(0, 0, 1, 1, (wxDC*) this, x1, y1);
+ memdc.SelectObject(wxNullBitmap);
+ wxImage image(bitmap);
+ col->Set(image.GetRed(0, 0), image.GetGreen(0, 0), image.GetBlue(0, 0));
+ return TRUE;
}
void wxWindowDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
if (m_window)
{
- if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
- gdk_draw_polygon (m_window, m_textGC, TRUE, gdkpoints, n);
- else
+ if (m_brush.GetStyle() != wxTRANSPARENT)
{
- if ((m_brush.GetStyle() != wxTRANSPARENT))
- gdk_draw_polygon (m_window, m_brushGC, TRUE, gdkpoints, n);
+ if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
+ {
+ 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(),
+ 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 );
+ }
+ else
+ {
+ gdk_draw_polygon( m_window, m_brushGC, TRUE, gdkpoints, n );
+ }
}
- }
-
- // To do: Fillstyle
- if ((m_pen.GetStyle() != wxTRANSPARENT) && m_window)
- {
- for (i = 0 ; i < n ; i++)
+ if (m_pen.GetStyle() != wxTRANSPARENT)
{
- gdk_draw_line( m_window, m_penGC,
- gdkpoints[i%n].x,
- gdkpoints[i%n].y,
- gdkpoints[(i+1)%n].x,
- gdkpoints[(i+1)%n].y);
+ for (i = 0 ; i < n ; i++)
+ {
+ gdk_draw_line( m_window, m_penGC,
+ gdkpoints[i%n].x,
+ gdkpoints[i%n].y,
+ gdkpoints[(i+1)%n].x,
+ gdkpoints[(i+1)%n].y);
+ }
}
}
if (m_window)
{
- if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
- {
- gdk_draw_rectangle( m_window, m_textGC, TRUE, xx, yy, ww, hh );
- gdk_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-1, hh-1 );
- }
- else
+ if (m_brush.GetStyle() != wxTRANSPARENT)
{
- if (m_brush.GetStyle() != wxTRANSPARENT)
+ if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
+ {
+ 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(),
+ m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy, ww, hh );
-
- if (m_pen.GetStyle() != wxTRANSPARENT)
- gdk_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-1, hh-1 );
+ gdk_gc_set_ts_origin( m_brushGC, 0, 0 );
+ }
+ else
+ {
+ gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy, ww, hh );
+ }
}
+
+ if (m_pen.GetStyle() != wxTRANSPARENT)
+ gdk_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-1, hh-1 );
}
CalcBoundingBox( x, y );
if (m_brush.GetStyle() != wxTRANSPARENT)
{
- 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 );
- gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 );
- gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 );
- gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 );
- gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 );
+ if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
+ {
+ 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 );
+ gdk_draw_arc( m_window, m_textGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 );
+ gdk_draw_arc( m_window, m_textGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 );
+ gdk_draw_arc( m_window, m_textGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 );
+ gdk_draw_arc( m_window, m_textGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*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(),
+ 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 );
+ gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 );
+ gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 );
+ gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 );
+ gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 );
+ gdk_gc_set_ts_origin( m_brushGC, 0, 0 );
+ }
+ else
+ {
+ 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 );
+ gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 );
+ gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 );
+ gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 );
+ gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 );
+ }
}
if (m_pen.GetStyle() != wxTRANSPARENT)
if (m_window)
{
if (m_brush.GetStyle() != wxTRANSPARENT)
- gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, 0, 360*64 );
+ {
+ if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
+ {
+ 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(),
+ 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 );
+ }
+ else
+ {
+ gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, 0, 360*64 );
+ }
+ }
if (m_pen.GetStyle() != wxTRANSPARENT)
gdk_draw_arc( m_window, m_penGC, FALSE, xx, yy, ww, hh, 0, 360*64 );
int hh = YLOG2DEVREL(h);
/* compare to current clipping region */
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
{
wxRegion tmp( xx,yy,ww,hh );
tmp.Intersect( m_currentClippingRegion );
if (useMask && mask)
{
GdkBitmap *new_mask = (GdkBitmap*) NULL;
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
{
GdkColor col;
new_mask = gdk_pixmap_new( wxRootWindow->window, ww, hh, 1 );
gdk_gc_set_fill( gc, GDK_OPAQUE_STIPPLED );
gdk_gc_set_stipple( gc, mask );
gdk_draw_rectangle( new_mask, gc, TRUE, 0, 0, ww, hh );
-/*
- gdk_gc_set_clip_mask( m_brushGC, NULL );
- gdk_gc_set_clip_mask( m_textGC, NULL );
- SetBrush( *wxRED_BRUSH );
- DrawRectangle( 70, 0, 70, 1000 );
- gdk_draw_bitmap( m_window, m_textGC, new_mask, 0, 0, 100, 5, ww, hh );
- gdk_draw_bitmap( m_window, m_textGC, mask, 0, 0, 80, 5, ww, hh );
-*/
gdk_gc_unref( gc );
}
{
gdk_gc_set_clip_mask( m_textGC, (GdkBitmap *) NULL );
gdk_gc_set_clip_origin( m_textGC, 0, 0 );
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
gdk_gc_set_clip_region( m_textGC, m_currentClippingRegion.GetRegion() );
}
else
{
gdk_gc_set_clip_mask( m_penGC, (GdkBitmap *) NULL );
gdk_gc_set_clip_origin( m_penGC, 0, 0 );
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() );
}
}
wxCoord hh = YLOG2DEVREL(height);
/* compare to current clipping region */
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
{
wxRegion tmp( xx,yy,ww,hh );
tmp.Intersect( m_currentClippingRegion );
int old_logical_func = m_logicalFunction;
SetLogicalFunction( logical_func );
-
+
if (use_bitmap_method)
{
/* scale/translate bitmap size */
if (useMask && mask)
{
GdkBitmap *new_mask = (GdkBitmap*) NULL;
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
{
GdkColor col;
new_mask = gdk_pixmap_new( wxRootWindow->window, bm_ww, bm_hh, 1 );
/* 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
{
gdk_gc_set_clip_mask( m_textGC, (GdkBitmap *) NULL );
gdk_gc_set_clip_origin( m_textGC, 0, 0 );
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
gdk_gc_set_clip_region( m_textGC, m_currentClippingRegion.GetRegion() );
}
else
{
gdk_gc_set_clip_mask( m_penGC, (GdkBitmap *) NULL );
gdk_gc_set_clip_origin( m_penGC, 0, 0 );
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() );
}
}
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 );
/* convert to bitmap */
-
bitmap = image.ConvertToBitmap();
/* draw scaled bitmap */
-
gdk_draw_pixmap( m_window, m_penGC, bitmap.GetPixmap(), 0, 0, xx, yy, -1, -1 );
}
else
{
- /* no scaling and not a memory dc with a mask either */
+ /* No scaling and not a memory dc with a mask either */
+ /* copy including child window contents */
+ gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS );
gdk_window_copy_area( m_window, m_penGC, xx, yy,
srcDC->GetWindow(),
xsrc, ysrc, width, height );
+ gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN );
}
}
{
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 );
+ gdk_gc_set_dashes( m_penGC, 0, (gint8*) 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 );
+ gdk_gc_set_dashes( m_penGC, 0, (gint8*)req_dash, req_nb_dash );
}
}
#endif
if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
{
- gdk_gc_set_fill( m_textGC, GDK_OPAQUE_STIPPLED);
- gdk_gc_set_stipple( m_textGC, m_brush.GetStipple()->GetMask()->GetBitmap() );
+ gdk_gc_set_fill( m_textGC, GDK_OPAQUE_STIPPLED);
+ gdk_gc_set_stipple( m_textGC, m_brush.GetStipple()->GetMask()->GetBitmap() );
}
if (IS_HATCH(m_brush.GetStyle()))
{
wxCHECK_RET( Ok(), wxT("invalid window dc") );
- wxDC::DoSetClippingRegion( x, y, width, height );
-
if (!m_window) return;
wxRect rect;
rect.width = XLOG2DEVREL(width);
rect.height = YLOG2DEVREL(height);
- m_currentClippingRegion.Clear();
- m_currentClippingRegion.Union( rect );
- if (!m_paintClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
+ m_currentClippingRegion.Intersect( rect );
+ else
+ m_currentClippingRegion.Union( rect );
+
+#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() );
return;
}
- wxCoord x,y,w,h;
- region.GetBox( x, y, w, h );
-
- wxDC::DoSetClippingRegion( x, y, w, h );
-
if (!m_window) return;
- m_currentClippingRegion.Clear();
- m_currentClippingRegion.Union( region );
- if (!m_paintClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
+ m_currentClippingRegion.Intersect( region );
+ else
+ m_currentClippingRegion.Union( 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() );
m_currentClippingRegion.Clear();
+#if USE_PAINT_REGION
if (!m_paintClippingRegion.IsEmpty())
m_currentClippingRegion.Union( m_paintClippingRegion );
+#endif
if (!m_window) return;
}
}
-void wxWindowDC::SetUpDC()
-{
- m_ok = TRUE;
-
- if (!m_penGC)
- {
- m_penGC = wxGetPoolGC( m_window, wxPEN_COLOUR );
- m_brushGC = wxGetPoolGC( m_window, wxBRUSH_COLOUR );
- m_textGC = wxGetPoolGC( m_window, wxTEXT_COLOUR );
- m_bgGC = wxGetPoolGC( m_window, wxBG_COLOUR );
- }
-
- /* background colour */
- m_backgroundBrush = *wxWHITE_BRUSH;
- m_backgroundBrush.GetColour().CalcPixel( m_cmap );
- GdkColor *bg_col = m_backgroundBrush.GetColour().GetColor();
-
- /* m_textGC */
- m_textForegroundColour.CalcPixel( m_cmap );
- gdk_gc_set_foreground( m_textGC, m_textForegroundColour.GetColor() );
-
- m_textBackgroundColour.CalcPixel( m_cmap );
- gdk_gc_set_background( m_textGC, m_textBackgroundColour.GetColor() );
-
- gdk_gc_set_fill( m_textGC, GDK_SOLID );
-
- /* m_penGC */
- 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 );
- gdk_gc_set_clip_rectangle( m_textGC, (GdkRectangle *) NULL );
- gdk_gc_set_clip_rectangle( m_bgGC, (GdkRectangle *) NULL );
-
- if (!hatch_bitmap)
- {
- hatch_bitmap = hatches;
- hatch_bitmap[0] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, bdiag_bits, bdiag_width, bdiag_height );
- hatch_bitmap[1] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, cdiag_bits, cdiag_width, cdiag_height );
- hatch_bitmap[2] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, fdiag_bits, fdiag_width, fdiag_height );
- hatch_bitmap[3] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, cross_bits, cross_width, cross_height );
- hatch_bitmap[4] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, horiz_bits, horiz_width, horiz_height );
- hatch_bitmap[5] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, verti_bits, verti_width, verti_height );
- }
-}
-
void wxWindowDC::Destroy()
{
if (m_penGC) wxFreePoolGC( m_penGC );
wxPaintDC::wxPaintDC( wxWindow *win )
: wxWindowDC( win )
{
- if (!win->GetUpdateRegion().IsEmpty())
- {
- m_paintClippingRegion = win->GetUpdateRegion();
- m_currentClippingRegion.Union( m_paintClippingRegion );
+#if USE_PAINT_REGION
+ m_paintClippingRegion = win->GetUpdateRegion();
+ m_currentClippingRegion.Union( m_paintClippingRegion );
- 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() );
- }
+ 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() );
+#endif
}
//-----------------------------------------------------------------------------