1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/dcclient.cpp
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling, Chris Breeze
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
14 #define XCopyPlane XCOPYPLANE
17 #include "wx/dcclient.h"
20 #include "wx/window.h"
22 #include "wx/dcmemory.h"
23 #include "wx/math.h" // for floating-point functions
25 #include "wx/module.h"
28 #include "wx/fontutil.h"
29 #include "wx/scrolwin.h"
31 #include "wx/gtk/private.h"
35 //-----------------------------------------------------------------------------
37 //-----------------------------------------------------------------------------
39 #define XLOG2DEV(x) LogicalToDeviceX(x)
40 #define XLOG2DEVREL(x) LogicalToDeviceXRel(x)
41 #define YLOG2DEV(y) LogicalToDeviceY(y)
42 #define YLOG2DEVREL(y) LogicalToDeviceYRel(y)
44 #define USE_PAINT_REGION 1
46 //-----------------------------------------------------------------------------
48 //-----------------------------------------------------------------------------
58 #define IS_15_PIX_HATCH(s) ((s)==wxCROSSDIAG_HATCH || (s)==wxHORIZONTAL_HATCH || (s)==wxVERTICAL_HATCH)
59 #define IS_16_PIX_HATCH(s) ((s)!=wxCROSSDIAG_HATCH && (s)!=wxHORIZONTAL_HATCH && (s)!=wxVERTICAL_HATCH)
62 static GdkPixmap
*hatches
[num_hatches
];
63 static GdkPixmap
**hatch_bitmap
= (GdkPixmap
**) NULL
;
65 extern GtkWidget
*wxGetRootWindow();
67 //-----------------------------------------------------------------------------
69 //-----------------------------------------------------------------------------
71 const double RAD2DEG
= 180.0 / M_PI
;
73 // ----------------------------------------------------------------------------
75 // ----------------------------------------------------------------------------
77 static inline double dmax(double a
, double b
) { return a
> b
? a
: b
; }
78 static inline double dmin(double a
, double b
) { return a
< b
? a
: b
; }
80 static inline double DegToRad(double deg
) { return (deg
* M_PI
) / 180.0; }
82 //-----------------------------------------------------------------------------
83 // temporary implementation of the missing GDK function
84 //-----------------------------------------------------------------------------
86 #include "gdk/gdkprivate.h"
89 void gdk_wx_draw_bitmap(GdkDrawable
*drawable
,
95 wxCHECK_RET( drawable
, _T("NULL drawable in gdk_wx_draw_bitmap") );
96 wxCHECK_RET( src
, _T("NULL src in gdk_wx_draw_bitmap") );
97 wxCHECK_RET( gc
, _T("NULL gc in gdk_wx_draw_bitmap") );
99 gint src_width
, src_height
;
100 gdk_drawable_get_size(src
, &src_width
, &src_height
);
102 XCopyPlane( GDK_WINDOW_XDISPLAY(drawable
),
104 GDK_WINDOW_XID(drawable
),
107 src_width
, src_height
,
112 //-----------------------------------------------------------------------------
113 // Implement Pool of Graphic contexts. Creating them takes too much time.
114 //-----------------------------------------------------------------------------
140 #define GC_POOL_ALLOC_SIZE 100
142 static int wxGCPoolSize
= 0;
144 static wxGC
*wxGCPool
= NULL
;
146 static void wxInitGCPool()
148 // This really could wait until the first call to
149 // wxGetPoolGC, but we will make the first allocation
150 // now when other initialization is being performed.
152 // Set initial pool size.
153 wxGCPoolSize
= GC_POOL_ALLOC_SIZE
;
155 // Allocate initial pool.
156 wxGCPool
= (wxGC
*)malloc(wxGCPoolSize
* sizeof(wxGC
));
157 if (wxGCPool
== NULL
)
159 // If we cannot malloc, then fail with error
160 // when debug is enabled. If debug is not enabled,
161 // the problem will eventually get caught
163 wxFAIL_MSG( wxT("Cannot allocate GC pool") );
167 // Zero initial pool.
168 memset(wxGCPool
, 0, wxGCPoolSize
* sizeof(wxGC
));
171 static void wxCleanUpGCPool()
173 for (int i
= 0; i
< wxGCPoolSize
; i
++)
175 if (wxGCPool
[i
].m_gc
)
176 g_object_unref (wxGCPool
[i
].m_gc
);
184 static GdkGC
* wxGetPoolGC( GdkWindow
*window
, wxPoolGCType type
)
188 // Look for an available GC.
189 for (int i
= 0; i
< wxGCPoolSize
; i
++)
191 if (!wxGCPool
[i
].m_gc
)
193 wxGCPool
[i
].m_gc
= gdk_gc_new( window
);
194 gdk_gc_set_exposures( wxGCPool
[i
].m_gc
, FALSE
);
195 wxGCPool
[i
].m_type
= type
;
196 wxGCPool
[i
].m_used
= false;
198 if ((!wxGCPool
[i
].m_used
) && (wxGCPool
[i
].m_type
== type
))
200 wxGCPool
[i
].m_used
= true;
201 return wxGCPool
[i
].m_gc
;
205 // We did not find an available GC.
206 // We need to grow the GC pool.
207 pptr
= (wxGC
*)realloc(wxGCPool
,
208 (wxGCPoolSize
+ GC_POOL_ALLOC_SIZE
)*sizeof(wxGC
));
211 // Initialize newly allocated pool.
213 memset(&wxGCPool
[wxGCPoolSize
], 0,
214 GC_POOL_ALLOC_SIZE
*sizeof(wxGC
));
216 // Initialize entry we will return.
217 wxGCPool
[wxGCPoolSize
].m_gc
= gdk_gc_new( window
);
218 gdk_gc_set_exposures( wxGCPool
[wxGCPoolSize
].m_gc
, FALSE
);
219 wxGCPool
[wxGCPoolSize
].m_type
= type
;
220 wxGCPool
[wxGCPoolSize
].m_used
= true;
222 // Set new value of pool size.
223 wxGCPoolSize
+= GC_POOL_ALLOC_SIZE
;
225 // Return newly allocated entry.
226 return wxGCPool
[wxGCPoolSize
-GC_POOL_ALLOC_SIZE
].m_gc
;
229 // The realloc failed. Fall through to error.
230 wxFAIL_MSG( wxT("No GC available") );
232 return (GdkGC
*) NULL
;
235 static void wxFreePoolGC( GdkGC
*gc
)
237 for (int i
= 0; i
< wxGCPoolSize
; i
++)
239 if (wxGCPool
[i
].m_gc
== gc
)
241 wxGCPool
[i
].m_used
= false;
246 wxFAIL_MSG( wxT("Wrong GC") );
249 //-----------------------------------------------------------------------------
251 //-----------------------------------------------------------------------------
254 IMPLEMENT_ABSTRACT_CLASS(wxGTKWindowImplDC
, wxGTKImplDC
)
256 IMPLEMENT_ABSTRACT_CLASS(wxWindowDC
, wxDC
)
260 wxGTKWindowImplDC::wxGTKWindowImplDC( wxDC
*owner
) :
263 wxWindowDC::wxWindowDC()
266 m_penGC
= (GdkGC
*) NULL
;
267 m_brushGC
= (GdkGC
*) NULL
;
268 m_textGC
= (GdkGC
*) NULL
;
269 m_bgGC
= (GdkGC
*) NULL
;
270 m_cmap
= (GdkColormap
*) NULL
;
271 m_isScreenDC
= false;
272 m_owningWindow
= (wxWindow
*)NULL
;
273 m_context
= (PangoContext
*)NULL
;
274 m_layout
= (PangoLayout
*)NULL
;
275 m_fontdesc
= (PangoFontDescription
*)NULL
;
279 wxGTKWindowImplDC::wxGTKWindowImplDC( wxDC
*owner
, wxWindow
*window
) :
282 wxWindowDC::wxWindowDC( wxWindow
*window
)
285 wxASSERT_MSG( window
, wxT("DC needs a window") );
287 m_penGC
= (GdkGC
*) NULL
;
288 m_brushGC
= (GdkGC
*) NULL
;
289 m_textGC
= (GdkGC
*) NULL
;
290 m_bgGC
= (GdkGC
*) NULL
;
291 m_cmap
= (GdkColormap
*) NULL
;
292 m_owningWindow
= (wxWindow
*)NULL
;
293 m_isScreenDC
= false;
294 m_font
= window
->GetFont();
296 GtkWidget
*widget
= window
->m_wxwindow
;
298 // Some controls don't have m_wxwindow - like wxStaticBox, but the user
299 // code should still be able to create wxClientDCs for them, so we will
300 // use the parent window here then.
303 window
= window
->GetParent();
304 widget
= window
->m_wxwindow
;
307 wxASSERT_MSG( widget
, wxT("DC needs a widget") );
309 m_context
= window
->GtkGetPangoDefaultContext();
310 m_layout
= pango_layout_new( m_context
);
311 m_fontdesc
= pango_font_description_copy( widget
->style
->font_desc
);
313 m_window
= widget
->window
;
315 // Window not realized ?
318 // Don't report problems as per MSW.
324 m_cmap
= gtk_widget_get_colormap( widget
? widget
: window
->m_widget
);
328 /* this must be done after SetUpDC, bacause SetUpDC calls the
329 repective SetBrush, SetPen, SetBackground etc functions
330 to set up the DC. SetBackground call m_owner->SetBackground
331 and this might not be desired as the standard dc background
332 is white whereas a window might assume gray to be the
333 standard (as e.g. wxStatusBar) */
335 m_owningWindow
= window
;
337 if (m_owningWindow
&& m_owningWindow
->m_wxwindow
&&
338 (m_owningWindow
->GetLayoutDirection() == wxLayout_RightToLeft
))
343 // origin in the upper right corner
344 m_deviceOriginX
= m_owningWindow
->GetClientSize().x
;
348 wxGTKWindowImplDC::~wxGTKWindowImplDC()
353 g_object_unref (m_layout
);
355 pango_font_description_free( m_fontdesc
);
358 void wxGTKWindowImplDC::SetUpDC( bool isMemDC
)
362 wxASSERT_MSG( !m_penGC
, wxT("GCs already created") );
368 wxGTKMemoryImplDC
*mem_dc
= (wxGTKMemoryImplDC
*) this;
369 if (mem_dc
->GetSelectedBitmap().GetDepth() == 1)
371 m_penGC
= wxGetPoolGC( m_window
, wxPEN_MONO
);
372 m_brushGC
= wxGetPoolGC( m_window
, wxBRUSH_MONO
);
373 m_textGC
= wxGetPoolGC( m_window
, wxTEXT_MONO
);
374 m_bgGC
= wxGetPoolGC( m_window
, wxBG_MONO
);
383 m_penGC
= wxGetPoolGC( m_window
, wxPEN_SCREEN
);
384 m_brushGC
= wxGetPoolGC( m_window
, wxBRUSH_SCREEN
);
385 m_textGC
= wxGetPoolGC( m_window
, wxTEXT_SCREEN
);
386 m_bgGC
= wxGetPoolGC( m_window
, wxBG_SCREEN
);
390 m_penGC
= wxGetPoolGC( m_window
, wxPEN_COLOUR
);
391 m_brushGC
= wxGetPoolGC( m_window
, wxBRUSH_COLOUR
);
392 m_textGC
= wxGetPoolGC( m_window
, wxTEXT_COLOUR
);
393 m_bgGC
= wxGetPoolGC( m_window
, wxBG_COLOUR
);
397 /* background colour */
398 m_backgroundBrush
= *wxWHITE_BRUSH
;
399 m_backgroundBrush
.GetColour().CalcPixel( m_cmap
);
400 const GdkColor
*bg_col
= m_backgroundBrush
.GetColour().GetColor();
403 m_textForegroundColour
.CalcPixel( m_cmap
);
404 gdk_gc_set_foreground( m_textGC
, m_textForegroundColour
.GetColor() );
406 m_textBackgroundColour
.CalcPixel( m_cmap
);
407 gdk_gc_set_background( m_textGC
, m_textBackgroundColour
.GetColor() );
409 gdk_gc_set_fill( m_textGC
, GDK_SOLID
);
411 gdk_gc_set_colormap( m_textGC
, m_cmap
);
414 m_pen
.GetColour().CalcPixel( m_cmap
);
415 gdk_gc_set_foreground( m_penGC
, m_pen
.GetColour().GetColor() );
416 gdk_gc_set_background( m_penGC
, bg_col
);
418 gdk_gc_set_line_attributes( m_penGC
, 0, GDK_LINE_SOLID
, GDK_CAP_NOT_LAST
, GDK_JOIN_ROUND
);
421 m_brush
.GetColour().CalcPixel( m_cmap
);
422 gdk_gc_set_foreground( m_brushGC
, m_brush
.GetColour().GetColor() );
423 gdk_gc_set_background( m_brushGC
, bg_col
);
425 gdk_gc_set_fill( m_brushGC
, GDK_SOLID
);
428 gdk_gc_set_background( m_bgGC
, bg_col
);
429 gdk_gc_set_foreground( m_bgGC
, bg_col
);
431 gdk_gc_set_fill( m_bgGC
, GDK_SOLID
);
434 gdk_gc_set_function( m_textGC
, GDK_COPY
);
435 gdk_gc_set_function( m_brushGC
, GDK_COPY
);
436 gdk_gc_set_function( m_penGC
, GDK_COPY
);
439 gdk_gc_set_clip_rectangle( m_penGC
, (GdkRectangle
*) NULL
);
440 gdk_gc_set_clip_rectangle( m_brushGC
, (GdkRectangle
*) NULL
);
441 gdk_gc_set_clip_rectangle( m_textGC
, (GdkRectangle
*) NULL
);
442 gdk_gc_set_clip_rectangle( m_bgGC
, (GdkRectangle
*) NULL
);
446 hatch_bitmap
= hatches
;
447 hatch_bitmap
[0] = gdk_bitmap_create_from_data( (GdkWindow
*) NULL
, bdiag_bits
, bdiag_width
, bdiag_height
);
448 hatch_bitmap
[1] = gdk_bitmap_create_from_data( (GdkWindow
*) NULL
, cdiag_bits
, cdiag_width
, cdiag_height
);
449 hatch_bitmap
[2] = gdk_bitmap_create_from_data( (GdkWindow
*) NULL
, fdiag_bits
, fdiag_width
, fdiag_height
);
450 hatch_bitmap
[3] = gdk_bitmap_create_from_data( (GdkWindow
*) NULL
, cross_bits
, cross_width
, cross_height
);
451 hatch_bitmap
[4] = gdk_bitmap_create_from_data( (GdkWindow
*) NULL
, horiz_bits
, horiz_width
, horiz_height
);
452 hatch_bitmap
[5] = gdk_bitmap_create_from_data( (GdkWindow
*) NULL
, verti_bits
, verti_width
, verti_height
);
456 void wxGTKWindowImplDC::DoGetSize( int* width
, int* height
) const
458 wxCHECK_RET( m_owningWindow
, _T("GetSize() doesn't work without window") );
460 m_owningWindow
->GetSize(width
, height
);
463 bool wxGTKWindowImplDC::DoFloodFill(wxCoord x
, wxCoord y
,
464 const wxColour
& col
, int style
)
467 extern bool wxDoFloodFill(wxDC
*dc
, wxCoord x
, wxCoord y
,
468 const wxColour
& col
, int style
);
470 return wxDoFloodFill( GetOwner(), x
, y
, col
, style
);
481 bool wxGTKWindowImplDC::DoGetPixel( wxCoord x1
, wxCoord y1
, wxColour
*col
) const
484 // Generic (and therefore rather inefficient) method.
485 // Could be improved.
487 wxBitmap
bitmap(1, 1);
488 memdc
.SelectObject(bitmap
);
489 memdc
.Blit(0, 0, 1, 1, (wxDC
*) this, x1
, y1
);
490 memdc
.SelectObject(wxNullBitmap
);
492 wxImage image
= bitmap
.ConvertToImage();
493 col
->Set(image
.GetRed(0, 0), image
.GetGreen(0, 0), image
.GetBlue(0, 0));
495 #else // !wxUSE_IMAGE
501 #endif // wxUSE_IMAGE/!wxUSE_IMAGE
504 void wxGTKWindowImplDC::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
506 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
508 if (m_pen
.GetStyle() != wxTRANSPARENT
)
511 gdk_draw_line( m_window
, m_penGC
, XLOG2DEV(x1
), YLOG2DEV(y1
), XLOG2DEV(x2
), YLOG2DEV(y2
) );
513 CalcBoundingBox(x1
, y1
);
514 CalcBoundingBox(x2
, y2
);
518 void wxGTKWindowImplDC::DoCrossHair( wxCoord x
, wxCoord y
)
520 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
522 if (m_pen
.GetStyle() != wxTRANSPARENT
)
526 GetOwner()->GetSize( &w
, &h
);
527 wxCoord xx
= XLOG2DEV(x
);
528 wxCoord yy
= YLOG2DEV(y
);
531 gdk_draw_line( m_window
, m_penGC
, 0, yy
, XLOG2DEVREL(w
), yy
);
532 gdk_draw_line( m_window
, m_penGC
, xx
, 0, xx
, YLOG2DEVREL(h
) );
537 void wxGTKWindowImplDC::DoDrawArc( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
538 wxCoord xc
, wxCoord yc
)
540 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
542 wxCoord xx1
= XLOG2DEV(x1
);
543 wxCoord yy1
= YLOG2DEV(y1
);
544 wxCoord xx2
= XLOG2DEV(x2
);
545 wxCoord yy2
= YLOG2DEV(y2
);
546 wxCoord xxc
= XLOG2DEV(xc
);
547 wxCoord yyc
= YLOG2DEV(yc
);
548 double dx
= xx1
- xxc
;
549 double dy
= yy1
- yyc
;
550 double radius
= sqrt((double)(dx
*dx
+dy
*dy
));
551 wxCoord r
= (wxCoord
)radius
;
552 double radius1
, radius2
;
554 if (xx1
== xx2
&& yy1
== yy2
)
559 else if ( wxIsNullDouble(radius
) )
566 radius1
= (xx1
- xxc
== 0) ?
567 (yy1
- yyc
< 0) ? 90.0 : -90.0 :
568 -atan2(double(yy1
-yyc
), double(xx1
-xxc
)) * RAD2DEG
;
569 radius2
= (xx2
- xxc
== 0) ?
570 (yy2
- yyc
< 0) ? 90.0 : -90.0 :
571 -atan2(double(yy2
-yyc
), double(xx2
-xxc
)) * RAD2DEG
;
573 wxCoord alpha1
= wxCoord(radius1
* 64.0);
574 wxCoord alpha2
= wxCoord((radius2
- radius1
) * 64.0);
575 while (alpha2
<= 0) alpha2
+= 360*64;
576 while (alpha1
> 360*64) alpha1
-= 360*64;
580 if (m_brush
.GetStyle() != wxTRANSPARENT
)
582 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
584 gdk_gc_set_ts_origin( m_textGC
,
585 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
586 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
587 gdk_draw_arc( m_window
, m_textGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
588 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
590 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
592 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
593 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
594 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
596 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
598 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
599 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
600 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
602 if (m_brush
.GetStyle() == wxSTIPPLE
)
604 gdk_gc_set_ts_origin( m_brushGC
,
605 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
606 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
607 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
608 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
612 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
616 if (m_pen
.GetStyle() != wxTRANSPARENT
)
618 gdk_draw_arc( m_window
, m_penGC
, FALSE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
620 if ((m_brush
.GetStyle() != wxTRANSPARENT
) && (alpha2
- alpha1
!= 360*64))
622 gdk_draw_line( m_window
, m_penGC
, xx1
, yy1
, xxc
, yyc
);
623 gdk_draw_line( m_window
, m_penGC
, xxc
, yyc
, xx2
, yy2
);
628 CalcBoundingBox (x1
, y1
);
629 CalcBoundingBox (x2
, y2
);
632 void wxGTKWindowImplDC::DoDrawEllipticArc( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double sa
, double ea
)
634 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
636 wxCoord xx
= XLOG2DEV(x
);
637 wxCoord yy
= YLOG2DEV(y
);
638 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
639 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
641 // CMB: handle -ve width and/or height
642 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
643 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
647 wxCoord start
= wxCoord(sa
* 64.0);
648 wxCoord end
= wxCoord((ea
-sa
) * 64.0);
650 if (m_brush
.GetStyle() != wxTRANSPARENT
)
652 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
654 gdk_gc_set_ts_origin( m_textGC
,
655 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
656 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
657 gdk_draw_arc( m_window
, m_textGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
658 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
660 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
662 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
663 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
664 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
666 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
668 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
669 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
670 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
672 if (m_brush
.GetStyle() == wxSTIPPLE
)
674 gdk_gc_set_ts_origin( m_brushGC
,
675 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
676 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
677 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
678 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
682 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
686 if (m_pen
.GetStyle() != wxTRANSPARENT
)
687 gdk_draw_arc( m_window
, m_penGC
, FALSE
, xx
, yy
, ww
, hh
, start
, end
);
690 CalcBoundingBox (x
, y
);
691 CalcBoundingBox (x
+ width
, y
+ height
);
694 void wxGTKWindowImplDC::DoDrawPoint( wxCoord x
, wxCoord y
)
696 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
698 if ((m_pen
.GetStyle() != wxTRANSPARENT
) && m_window
)
699 gdk_draw_point( m_window
, m_penGC
, XLOG2DEV(x
), YLOG2DEV(y
) );
701 CalcBoundingBox (x
, y
);
704 void wxGTKWindowImplDC::DoDrawLines( int n
, wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
)
706 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
708 if (m_pen
.GetStyle() == wxTRANSPARENT
) return;
711 //Check, if scaling is necessary
713 xoffset
!= 0 || yoffset
!= 0 || XLOG2DEV(10) != 10 || YLOG2DEV(10) != 10;
715 // GdkPoint and wxPoint have the same memory layout, so we can cast one to the other
716 GdkPoint
* gpts
= reinterpret_cast<GdkPoint
*>(points
);
719 gpts
= new GdkPoint
[n
];
721 for (int i
= 0; i
< n
; i
++)
725 gpts
[i
].x
= XLOG2DEV(points
[i
].x
+ xoffset
);
726 gpts
[i
].y
= YLOG2DEV(points
[i
].y
+ yoffset
);
728 CalcBoundingBox(points
[i
].x
+ xoffset
, points
[i
].y
+ yoffset
);
732 gdk_draw_lines( m_window
, m_penGC
, gpts
, n
);
738 void wxGTKWindowImplDC::DoDrawPolygon( int n
, wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
, int WXUNUSED(fillStyle
) )
740 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
744 //Check, if scaling is necessary
746 xoffset
!= 0 || yoffset
!= 0 || XLOG2DEV(10) != 10 || YLOG2DEV(10) != 10;
748 // GdkPoint and wxPoint have the same memory layout, so we can cast one to the other
749 GdkPoint
* gdkpoints
= reinterpret_cast<GdkPoint
*>(points
);
752 gdkpoints
= new GdkPoint
[n
];
755 for (i
= 0 ; i
< n
; i
++)
759 gdkpoints
[i
].x
= XLOG2DEV(points
[i
].x
+ xoffset
);
760 gdkpoints
[i
].y
= YLOG2DEV(points
[i
].y
+ yoffset
);
762 CalcBoundingBox(points
[i
].x
+ xoffset
, points
[i
].y
+ yoffset
);
767 if (m_brush
.GetStyle() != wxTRANSPARENT
)
769 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
771 gdk_gc_set_ts_origin( m_textGC
,
772 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
773 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
774 gdk_draw_polygon( m_window
, m_textGC
, TRUE
, gdkpoints
, n
);
775 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
777 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
779 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
780 gdk_draw_polygon( m_window
, m_brushGC
, TRUE
, gdkpoints
, n
);
781 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
783 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
785 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
786 gdk_draw_polygon( m_window
, m_brushGC
, TRUE
, gdkpoints
, n
);
787 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
789 if (m_brush
.GetStyle() == wxSTIPPLE
)
791 gdk_gc_set_ts_origin( m_brushGC
,
792 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
793 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
794 gdk_draw_polygon( m_window
, m_brushGC
, TRUE
, gdkpoints
, n
);
795 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
799 gdk_draw_polygon( m_window
, m_brushGC
, TRUE
, gdkpoints
, n
);
803 if (m_pen
.GetStyle() != wxTRANSPARENT
)
806 for (i = 0 ; i < n ; i++)
808 gdk_draw_line( m_window, m_penGC,
811 gdkpoints[(i+1)%n].x,
812 gdkpoints[(i+1)%n].y);
815 gdk_draw_polygon( m_window
, m_penGC
, FALSE
, gdkpoints
, n
);
824 void wxGTKWindowImplDC::DoDrawRectangle( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
826 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
828 wxCoord xx
= XLOG2DEV(x
);
829 wxCoord yy
= YLOG2DEV(y
);
830 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
831 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
833 // CMB: draw nothing if transformed w or h is 0
834 if (ww
== 0 || hh
== 0) return;
836 // CMB: handle -ve width and/or height
837 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
838 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
842 if (m_brush
.GetStyle() != wxTRANSPARENT
)
844 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
846 gdk_gc_set_ts_origin( m_textGC
,
847 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
848 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
849 gdk_draw_rectangle( m_window
, m_textGC
, TRUE
, xx
, yy
, ww
, hh
);
850 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
852 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
854 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
855 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
);
856 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
858 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
860 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
861 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
);
862 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
864 if (m_brush
.GetStyle() == wxSTIPPLE
)
866 gdk_gc_set_ts_origin( m_brushGC
,
867 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
868 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
869 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
);
870 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
874 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
);
878 if (m_pen
.GetStyle() != wxTRANSPARENT
)
881 if ((m_pen
.GetWidth() == 2) && (m_pen
.GetCap() == wxCAP_ROUND
) &&
882 (m_pen
.GetJoin() == wxJOIN_ROUND
) && (m_pen
.GetStyle() == wxSOLID
))
884 // Use 2 1-line rects instead
885 gdk_gc_set_line_attributes( m_penGC
, 1, GDK_LINE_SOLID
, GDK_CAP_ROUND
, GDK_JOIN_ROUND
);
890 gdk_draw_rectangle( m_window
, m_penGC
, FALSE
, xx
+1, yy
, ww
-2, hh
-2 );
891 gdk_draw_rectangle( m_window
, m_penGC
, FALSE
, xx
, yy
-1, ww
, hh
);
895 gdk_draw_rectangle( m_window
, m_penGC
, FALSE
, xx
, yy
, ww
-2, hh
-2 );
896 gdk_draw_rectangle( m_window
, m_penGC
, FALSE
, xx
-1, yy
-1, ww
, hh
);
900 gdk_gc_set_line_attributes( m_penGC
, 2, GDK_LINE_SOLID
, GDK_CAP_ROUND
, GDK_JOIN_ROUND
);
905 // Just use X11 for other cases
906 gdk_draw_rectangle( m_window
, m_penGC
, FALSE
, xx
, yy
, ww
-1, hh
-1 );
911 CalcBoundingBox( x
, y
);
912 CalcBoundingBox( x
+ width
, y
+ height
);
915 void wxGTKWindowImplDC::DoDrawRoundedRectangle( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double radius
)
917 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
919 if (radius
< 0.0) radius
= - radius
* ((width
< height
) ? width
: height
);
921 wxCoord xx
= XLOG2DEV(x
);
922 wxCoord yy
= YLOG2DEV(y
);
923 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
924 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
925 wxCoord rr
= XLOG2DEVREL((wxCoord
)radius
);
927 // CMB: handle -ve width and/or height
928 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
929 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
931 // CMB: if radius is zero use DrawRectangle() instead to avoid
932 // X drawing errors with small radii
935 DoDrawRectangle( x
, y
, width
, height
);
939 // CMB: draw nothing if transformed w or h is 0
940 if (ww
== 0 || hh
== 0) return;
942 // CMB: adjust size if outline is drawn otherwise the result is
943 // 1 pixel too wide and high
944 if (m_pen
.GetStyle() != wxTRANSPARENT
)
952 // CMB: ensure dd is not larger than rectangle otherwise we
953 // get an hour glass shape
955 if (dd
> ww
) dd
= ww
;
956 if (dd
> hh
) dd
= hh
;
959 if (m_brush
.GetStyle() != wxTRANSPARENT
)
961 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
963 gdk_gc_set_ts_origin( m_textGC
,
964 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
965 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
966 gdk_draw_rectangle( m_window
, m_textGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
967 gdk_draw_rectangle( m_window
, m_textGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
968 gdk_draw_arc( m_window
, m_textGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
969 gdk_draw_arc( m_window
, m_textGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
970 gdk_draw_arc( m_window
, m_textGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
971 gdk_draw_arc( m_window
, m_textGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
972 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
974 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
976 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
977 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
978 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
979 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
980 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
981 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
982 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
983 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
985 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
987 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
988 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
989 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
990 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
991 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
992 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
993 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
994 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
996 if (m_brush
.GetStyle() == wxSTIPPLE
)
998 gdk_gc_set_ts_origin( m_brushGC
,
999 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
1000 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
1001 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
1002 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
1003 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
1004 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
1005 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
1006 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
1007 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
1011 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
1012 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
1013 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
1014 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
1015 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
1016 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
1020 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1022 gdk_draw_line( m_window
, m_penGC
, xx
+rr
+1, yy
, xx
+ww
-rr
, yy
);
1023 gdk_draw_line( m_window
, m_penGC
, xx
+rr
+1, yy
+hh
, xx
+ww
-rr
, yy
+hh
);
1024 gdk_draw_line( m_window
, m_penGC
, xx
, yy
+rr
+1, xx
, yy
+hh
-rr
);
1025 gdk_draw_line( m_window
, m_penGC
, xx
+ww
, yy
+rr
+1, xx
+ww
, yy
+hh
-rr
);
1026 gdk_draw_arc( m_window
, m_penGC
, FALSE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
1027 gdk_draw_arc( m_window
, m_penGC
, FALSE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
1028 gdk_draw_arc( m_window
, m_penGC
, FALSE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
1029 gdk_draw_arc( m_window
, m_penGC
, FALSE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
1033 // this ignores the radius
1034 CalcBoundingBox( x
, y
);
1035 CalcBoundingBox( x
+ width
, y
+ height
);
1038 void wxGTKWindowImplDC::DoDrawEllipse( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1040 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1042 wxCoord xx
= XLOG2DEV(x
);
1043 wxCoord yy
= YLOG2DEV(y
);
1044 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1045 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1047 // CMB: handle -ve width and/or height
1048 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
1049 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
1053 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1055 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
1057 gdk_gc_set_ts_origin( m_textGC
,
1058 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
1059 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
1060 gdk_draw_arc( m_window
, m_textGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1061 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
1063 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
1065 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
1066 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1067 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
1069 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
1071 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
1072 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1073 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
1075 if (m_brush
.GetStyle() == wxSTIPPLE
)
1077 gdk_gc_set_ts_origin( m_brushGC
,
1078 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
1079 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
1080 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1081 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
1085 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1089 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1090 gdk_draw_arc( m_window
, m_penGC
, FALSE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1093 CalcBoundingBox( x
, y
);
1094 CalcBoundingBox( x
+ width
, y
+ height
);
1097 void wxGTKWindowImplDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
1099 // VZ: egcs 1.0.3 refuses to compile this without cast, no idea why
1100 DoDrawBitmap( (const wxBitmap
&)icon
, x
, y
, true );
1103 void wxGTKWindowImplDC::DoDrawBitmap( const wxBitmap
&bitmap
,
1104 wxCoord x
, wxCoord y
,
1107 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1109 wxCHECK_RET( bitmap
.IsOk(), wxT("invalid bitmap") );
1111 bool is_mono
= bitmap
.GetDepth() == 1;
1113 // scale/translate size and position
1114 int xx
= XLOG2DEV(x
);
1115 int yy
= YLOG2DEV(y
);
1117 int w
= bitmap
.GetWidth();
1118 int h
= bitmap
.GetHeight();
1120 if (m_owningWindow
&& m_owningWindow
->GetLayoutDirection() == wxLayout_RightToLeft
)
1123 CalcBoundingBox( x
, y
);
1124 CalcBoundingBox( x
+ w
, y
+ h
);
1126 if (!m_window
) return;
1128 int ww
= XLOG2DEVREL(w
);
1129 int hh
= YLOG2DEVREL(h
);
1131 // compare to current clipping region
1132 if (!m_currentClippingRegion
.IsNull())
1134 wxRegion
tmp( xx
,yy
,ww
,hh
);
1135 tmp
.Intersect( m_currentClippingRegion
);
1140 // scale bitmap if required
1141 wxBitmap use_bitmap
= bitmap
;
1142 if ((w
!= ww
) || (h
!= hh
))
1143 use_bitmap
= use_bitmap
.Rescale( 0, 0, ww
, hh
, ww
, hh
);
1145 // apply mask if any
1146 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
1147 if (useMask
&& use_bitmap
.GetMask())
1148 mask
= use_bitmap
.GetMask()->GetBitmap();
1150 GdkGC
* use_gc
= is_mono
? m_textGC
: m_penGC
;
1152 GdkBitmap
*new_mask
= (GdkBitmap
*) NULL
;
1156 if (!m_currentClippingRegion
.IsNull())
1159 new_mask
= gdk_pixmap_new( wxGetRootWindow()->window
, ww
, hh
, 1 );
1160 GdkGC
*gc
= gdk_gc_new( new_mask
);
1162 gdk_gc_set_foreground( gc
, &col
);
1163 gdk_draw_rectangle( new_mask
, gc
, TRUE
, 0, 0, ww
, hh
);
1165 gdk_gc_set_background( gc
, &col
);
1167 gdk_gc_set_foreground( gc
, &col
);
1168 gdk_gc_set_clip_region( gc
, m_currentClippingRegion
.GetRegion() );
1169 gdk_gc_set_clip_origin( gc
, -xx
, -yy
);
1170 gdk_gc_set_fill( gc
, GDK_OPAQUE_STIPPLED
);
1171 gdk_gc_set_stipple( gc
, mask
);
1172 gdk_draw_rectangle( new_mask
, gc
, TRUE
, 0, 0, ww
, hh
);
1174 g_object_unref (gc
);
1177 gdk_gc_set_clip_mask(use_gc
, mask
);
1178 gdk_gc_set_clip_origin(use_gc
, xx
, yy
);
1181 // Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For
1182 // drawing a mono-bitmap (XBitmap) we use the current text GC
1185 GdkPixmap
*bitmap2
= gdk_pixmap_new( wxGetRootWindow()->window
, ww
, hh
, -1 );
1186 GdkGC
*gc
= gdk_gc_new( bitmap2
);
1187 gdk_gc_set_foreground( gc
, m_textForegroundColour
.GetColor() );
1188 gdk_gc_set_background( gc
, m_textBackgroundColour
.GetColor() );
1189 gdk_wx_draw_bitmap(bitmap2
, gc
, use_bitmap
.GetPixmap(), 0, 0);
1191 gdk_draw_drawable(m_window
, use_gc
, bitmap2
, 0, 0, xx
, yy
, -1, -1);
1193 g_object_unref (bitmap2
);
1194 g_object_unref (gc
);
1198 if (use_bitmap
.HasPixbuf())
1200 gdk_draw_pixbuf(m_window
, use_gc
,
1201 use_bitmap
.GetPixbuf(),
1202 0, 0, xx
, yy
, -1, -1,
1203 GDK_RGB_DITHER_NORMAL
, xx
, yy
);
1207 gdk_draw_drawable(m_window
, use_gc
,
1208 use_bitmap
.GetPixmap(),
1209 0, 0, xx
, yy
, -1, -1);
1213 // remove mask again if any
1216 gdk_gc_set_clip_mask(use_gc
, NULL
);
1217 gdk_gc_set_clip_origin(use_gc
, 0, 0);
1218 if (!m_currentClippingRegion
.IsNull())
1219 gdk_gc_set_clip_region(use_gc
, m_currentClippingRegion
.GetRegion());
1220 if (new_mask
!= NULL
)
1221 g_object_unref(new_mask
);
1225 bool wxGTKWindowImplDC::DoBlit( wxCoord xdest
, wxCoord ydest
,
1226 wxCoord width
, wxCoord height
,
1228 wxCoord xsrc
, wxCoord ysrc
,
1231 wxCoord xsrcMask
, wxCoord ysrcMask
)
1233 wxCHECK_MSG( IsOk(), false, wxT("invalid window dc") );
1235 wxCHECK_MSG( source
, false, wxT("invalid source dc") );
1237 if (!m_window
) return false;
1239 // transform the source DC coords to the device ones
1240 xsrc
= source
->LogicalToDeviceX(xsrc
);
1241 ysrc
= source
->LogicalToDeviceY(ysrc
);
1244 wxMemoryDC
*memDC
= wxDynamicCast(source
, wxMemoryDC
);
1247 selected
= memDC
->GetSelectedBitmap();
1248 if ( !selected
.IsOk() )
1252 bool use_bitmap_method
= false;
1253 bool is_mono
= false;
1255 if (xsrcMask
== -1 && ysrcMask
== -1)
1261 if (selected
.IsOk())
1263 is_mono
= (selected
.GetDepth() == 1);
1265 // we use the "XCopyArea" way to copy a memory dc into
1266 // a different window if the memory dc BOTH
1267 // a) doesn't have any mask or its mask isn't used
1271 if (useMask
&& (selected
.GetMask()))
1273 // we HAVE TO use the direct way for memory dcs
1274 // that have mask since the XCopyArea doesn't know
1276 use_bitmap_method
= true;
1280 // we HAVE TO use the direct way for memory dcs
1281 // that are bitmaps because XCopyArea doesn't cope
1282 // with different bit depths
1283 use_bitmap_method
= true;
1285 else if ((xsrc
== 0) && (ysrc
== 0) &&
1286 (width
== selected
.GetWidth()) &&
1287 (height
== selected
.GetHeight()))
1289 // we SHOULD use the direct way if all of the bitmap
1290 // in the memory dc is copied in which case XCopyArea
1291 // wouldn't be able able to boost performace by reducing
1292 // the area to be scaled
1293 use_bitmap_method
= true;
1297 CalcBoundingBox( xdest
, ydest
);
1298 CalcBoundingBox( xdest
+ width
, ydest
+ height
);
1300 // scale/translate size and position
1301 wxCoord xx
= XLOG2DEV(xdest
);
1302 wxCoord yy
= YLOG2DEV(ydest
);
1304 wxCoord ww
= XLOG2DEVREL(width
);
1305 wxCoord hh
= YLOG2DEVREL(height
);
1307 // compare to current clipping region
1308 if (!m_currentClippingRegion
.IsNull())
1310 wxRegion
tmp( xx
,yy
,ww
,hh
);
1311 tmp
.Intersect( m_currentClippingRegion
);
1316 int old_logical_func
= m_logicalFunction
;
1317 SetLogicalFunction( logical_func
);
1319 if (use_bitmap_method
)
1321 // scale/translate bitmap size
1322 wxCoord bm_width
= selected
.GetWidth();
1323 wxCoord bm_height
= selected
.GetHeight();
1325 // Get clip coords for the bitmap. If we don't
1326 // use wxBitmap::Rescale(), which can clip the
1327 // bitmap, these are the same as the original
1334 // interpret userscale of src too
1336 memDC
->GetUserScale(&xsc
,&ysc
);
1337 bm_width
= (int) (bm_width
/ xsc
);
1338 bm_height
= (int) (bm_height
/ ysc
);
1340 wxCoord bm_ww
= XLOG2DEVREL( bm_width
);
1341 wxCoord bm_hh
= YLOG2DEVREL( bm_height
);
1343 // Scale bitmap if required
1344 wxBitmap use_bitmap
= selected
;
1345 if ((selected
.GetWidth()!= bm_ww
) || ( selected
.GetHeight()!= bm_hh
))
1347 // This indicates that the blitting code below will get
1348 // a clipped bitmap and therefore needs to move the origin
1350 wxRegion
tmp( xx
,yy
,ww
,hh
);
1351 if (!m_currentClippingRegion
.IsNull())
1352 tmp
.Intersect( m_currentClippingRegion
);
1353 tmp
.GetBox(cx
,cy
,cw
,ch
);
1355 // Scale and clipped bitmap
1356 use_bitmap
= selected
.Rescale(cx
-xx
,cy
-yy
,cw
,ch
,bm_ww
,bm_hh
);
1359 // apply mask if any
1360 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
1361 if (useMask
&& use_bitmap
.GetMask())
1362 mask
= use_bitmap
.GetMask()->GetBitmap();
1364 GdkGC
* use_gc
= is_mono
? m_textGC
: m_penGC
;
1366 GdkBitmap
*new_mask
= (GdkBitmap
*) NULL
;
1370 if (!m_currentClippingRegion
.IsNull())
1373 new_mask
= gdk_pixmap_new( wxGetRootWindow()->window
, bm_ww
, bm_hh
, 1 );
1374 GdkGC
*gc
= gdk_gc_new( new_mask
);
1376 gdk_gc_set_foreground( gc
, &col
);
1377 gdk_gc_set_ts_origin( gc
, -xsrcMask
, -ysrcMask
);
1378 gdk_draw_rectangle( new_mask
, gc
, TRUE
, 0, 0, bm_ww
, bm_hh
);
1380 gdk_gc_set_background( gc
, &col
);
1382 gdk_gc_set_foreground( gc
, &col
);
1383 gdk_gc_set_clip_region( gc
, m_currentClippingRegion
.GetRegion() );
1384 // was: gdk_gc_set_clip_origin( gc, -xx, -yy );
1385 gdk_gc_set_clip_origin( gc
, -cx
, -cy
);
1386 gdk_gc_set_fill( gc
, GDK_OPAQUE_STIPPLED
);
1387 gdk_gc_set_stipple( gc
, mask
);
1388 gdk_draw_rectangle( new_mask
, gc
, TRUE
, 0, 0, bm_ww
, bm_hh
);
1390 g_object_unref (gc
);
1393 gdk_gc_set_clip_mask(use_gc
, mask
);
1394 if (new_mask
!= NULL
)
1395 gdk_gc_set_clip_origin(use_gc
, cx
, cy
);
1397 gdk_gc_set_clip_origin(use_gc
, cx
- xsrcMask
, cy
- ysrcMask
);
1400 // Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For
1401 // drawing a mono-bitmap (XBitmap) we use the current text GC
1405 GdkPixmap
*bitmap
= gdk_pixmap_new( wxGetRootWindow()->window
, bm_ww
, bm_hh
, -1 );
1406 GdkGC
*gc
= gdk_gc_new( bitmap
);
1407 gdk_gc_set_foreground( gc
, m_textForegroundColour
.GetColor() );
1408 gdk_gc_set_background( gc
, m_textBackgroundColour
.GetColor() );
1409 gdk_wx_draw_bitmap(bitmap
, gc
, use_bitmap
.GetPixmap(), 0, 0);
1411 gdk_draw_drawable(m_window
, use_gc
, bitmap
, xsrc
, ysrc
, cx
, cy
, cw
, ch
);
1413 g_object_unref (bitmap
);
1414 g_object_unref (gc
);
1418 // was: gdk_draw_drawable( m_window, m_penGC, use_bitmap.GetPixmap(), xsrc, ysrc, xx, yy, ww, hh );
1419 gdk_draw_drawable(m_window
, use_gc
, use_bitmap
.GetPixmap(), xsrc
, ysrc
, cx
, cy
, cw
, ch
);
1422 // remove mask again if any
1425 gdk_gc_set_clip_mask(use_gc
, NULL
);
1426 gdk_gc_set_clip_origin(use_gc
, 0, 0);
1427 if (!m_currentClippingRegion
.IsNull())
1428 gdk_gc_set_clip_region(use_gc
, m_currentClippingRegion
.GetRegion());
1432 g_object_unref (new_mask
);
1434 else // use_bitmap_method
1436 if (selected
.IsOk() && ((width
!= ww
) || (height
!= hh
)))
1439 wxRegion
tmp( xx
,yy
,ww
,hh
);
1440 tmp
.Intersect( m_currentClippingRegion
);
1441 wxCoord cx
,cy
,cw
,ch
;
1442 tmp
.GetBox(cx
,cy
,cw
,ch
);
1445 wxBitmap bitmap
= selected
.Rescale( cx
-xx
, cy
-yy
, cw
, ch
, ww
, hh
);
1447 // draw scaled bitmap
1448 // was: gdk_draw_drawable( m_window, m_penGC, bitmap.GetPixmap(), 0, 0, xx, yy, -1, -1 );
1449 gdk_draw_drawable( m_window
, m_penGC
, bitmap
.GetPixmap(), 0, 0, cx
, cy
, -1, -1 );
1453 // No scaling and not a memory dc with a mask either
1455 GdkWindow
* window
= NULL
;
1456 wxImplDC
*impl
= source
->GetImpl();
1457 wxGTKWindowImplDC
*gtk_impl
= wxDynamicCast(impl
, wxGTKWindowImplDC
);
1459 window
= gtk_impl
->GetGDKWindow();
1461 GdkWindow
* window
= source
->GetGDKWindow();
1466 // copy including child window contents
1467 gdk_gc_set_subwindow( m_penGC
, GDK_INCLUDE_INFERIORS
);
1468 gdk_draw_drawable( m_window
, m_penGC
,
1472 gdk_gc_set_subwindow( m_penGC
, GDK_CLIP_BY_CHILDREN
);
1476 SetLogicalFunction( old_logical_func
);
1481 void wxGTKWindowImplDC::DoDrawText( const wxString
&text
, wxCoord x
, wxCoord y
)
1483 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1485 if (!m_window
) return;
1487 if (text
.empty()) return;
1492 wxCHECK_RET( m_context
, wxT("no Pango context") );
1493 wxCHECK_RET( m_layout
, wxT("no Pango layout") );
1494 wxCHECK_RET( m_fontdesc
, wxT("no Pango font description") );
1496 gdk_pango_context_set_colormap( m_context
, m_cmap
);
1498 bool underlined
= m_font
.IsOk() && m_font
.GetUnderlined();
1500 const wxCharBuffer data
= wxGTK_CONV( text
);
1503 size_t datalen
= strlen(data
);
1505 // in Pango >= 1.16 the "underline of leading/trailing spaces" bug
1506 // has been fixed and thus the hack implemented below should never be used
1507 static bool pangoOk
= !wx_pango_version_check(1, 16, 0);
1509 bool needshack
= underlined
&& !pangoOk
;
1510 char *hackstring
= NULL
;
1514 // a PangoLayout which has leading/trailing spaces with underlined font
1515 // is not correctly drawn by this pango version: Pango won't underline the spaces.
1516 // This can be a problem; e.g. wxHTML rendering of underlined text relies on
1517 // this behaviour. To workaround this problem, we use a special hack here
1518 // suggested by pango maintainer Behdad Esfahbod: we prepend and append two
1519 // empty space characters and give them a dummy colour attribute.
1520 // This will force Pango to underline the leading/trailing spaces, too.
1522 // need to realloc the string to prepend & append our special characters
1523 hackstring
= (char*)malloc((datalen
+7)*sizeof(char));
1525 // copy the leading U+200C ZERO WIDTH NON-JOINER encoded in UTF8 format
1526 strcpy(hackstring
, "\342\200\214");
1528 // copy the user string
1529 memcpy(&hackstring
[3], data
, datalen
);
1531 // copy the trailing U+200C ZERO WIDTH NON-JOINER encoded in UTF8 format
1532 strcpy(&hackstring
[datalen
+3], "\342\200\214");
1534 // the special characters that we added require 6 additional bytes:
1537 pango_layout_set_text(m_layout
, hackstring
, datalen
);
1541 pango_layout_set_text(m_layout
, data
, datalen
);
1546 PangoAttrList
*attrs
= pango_attr_list_new();
1547 PangoAttribute
*a
= pango_attr_underline_new(PANGO_UNDERLINE_SINGLE
);
1549 a
->end_index
= datalen
;
1550 pango_attr_list_insert(attrs
, a
);
1554 // dummy colour for the leading space
1555 a
= pango_attr_foreground_new (0x0057, 0x52A9, 0xD614);
1558 pango_attr_list_insert(attrs
, a
);
1560 // dummy colour for the trailing space
1561 a
= pango_attr_foreground_new (0x0057, 0x52A9, 0xD614);
1562 a
->start_index
= datalen
- 1;
1563 a
->end_index
= datalen
;
1564 pango_attr_list_insert(attrs
, a
);
1567 pango_layout_set_attributes(m_layout
, attrs
);
1568 pango_attr_list_unref(attrs
);
1573 if (fabs(m_scaleY
- 1.0) > 0.00001)
1575 // If there is a user or actually any scale applied to
1576 // the device context, scale the font.
1578 // scale font description
1579 gint oldSize
= pango_font_description_get_size( m_fontdesc
);
1580 double size
= oldSize
;
1581 size
= size
* m_scaleY
;
1582 pango_font_description_set_size( m_fontdesc
, (gint
)size
);
1584 // actually apply scaled font
1585 pango_layout_set_font_description( m_layout
, m_fontdesc
);
1587 pango_layout_get_pixel_size( m_layout
, &w
, &h
);
1588 if ( m_backgroundMode
== wxSOLID
)
1590 gdk_gc_set_foreground(m_textGC
, m_textBackgroundColour
.GetColor());
1591 gdk_draw_rectangle(m_window
, m_textGC
, TRUE
, x
, y
, w
, h
);
1592 gdk_gc_set_foreground(m_textGC
, m_textForegroundColour
.GetColor());
1596 if (m_owningWindow
&& m_owningWindow
->GetLayoutDirection() == wxLayout_RightToLeft
)
1597 gdk_draw_layout( m_window
, m_textGC
, x
-w
, y
, m_layout
);
1599 gdk_draw_layout( m_window
, m_textGC
, x
, y
, m_layout
);
1601 // reset unscaled size
1602 pango_font_description_set_size( m_fontdesc
, oldSize
);
1604 // actually apply unscaled font
1605 pango_layout_set_font_description( m_layout
, m_fontdesc
);
1609 pango_layout_get_pixel_size( m_layout
, &w
, &h
);
1610 if ( m_backgroundMode
== wxSOLID
)
1612 gdk_gc_set_foreground(m_textGC
, m_textBackgroundColour
.GetColor());
1613 gdk_draw_rectangle(m_window
, m_textGC
, TRUE
, x
, y
, w
, h
);
1614 gdk_gc_set_foreground(m_textGC
, m_textForegroundColour
.GetColor());
1618 if (m_owningWindow
&& m_owningWindow
->GetLayoutDirection() == wxLayout_RightToLeft
)
1619 gdk_draw_layout( m_window
, m_textGC
, x
-w
, y
, m_layout
);
1621 gdk_draw_layout( m_window
, m_textGC
, x
, y
, m_layout
);
1626 // undo underline attributes setting:
1627 pango_layout_set_attributes(m_layout
, NULL
);
1633 width
= wxCoord(width
/ m_scaleX
);
1634 height
= wxCoord(height
/ m_scaleY
);
1635 CalcBoundingBox (x
+ width
, y
+ height
);
1636 CalcBoundingBox (x
, y
);
1643 // TODO: There is an example of rotating text with GTK2 that would probably be
1644 // a better approach here:
1645 // http://www.daa.com.au/pipermail/pygtk/2003-April/005052.html
1647 void wxGTKWindowImplDC::DoDrawRotatedText( const wxString
&text
, wxCoord x
, wxCoord y
, double angle
)
1650 if (!m_window
|| text
.empty())
1653 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1655 if ( wxIsNullDouble(angle
) )
1657 DoDrawText(text
, x
, y
);
1664 // TODO: implement later without GdkFont for GTK 2.0
1665 DoGetTextExtent(text
, &w
, &h
, NULL
,NULL
, &m_font
);
1667 // draw the string normally
1670 dc
.SelectObject(src
);
1671 dc
.SetFont(GetFont());
1672 dc
.SetBackground(*wxBLACK_BRUSH
);
1673 dc
.SetBrush(*wxBLACK_BRUSH
);
1675 dc
.SetTextForeground( *wxWHITE
);
1676 dc
.DrawText(text
, 0, 0);
1677 dc
.SelectObject(wxNullBitmap
);
1679 // Calculate the size of the rotated bounding box.
1680 double rad
= DegToRad(angle
);
1681 double dx
= cos(rad
),
1684 // the rectngle vertices are counted clockwise with the first one being at
1685 // (0, 0) (or, rather, at (x, y))
1687 y2
= -w
*dy
; // y axis points to the bottom, hence minus
1690 double x3
= x4
+ x2
,
1694 wxCoord maxX
= (wxCoord
)(dmax(x2
, dmax(x3
, x4
)) + 0.5),
1695 maxY
= (wxCoord
)(dmax(y2
, dmax(y3
, y4
)) + 0.5),
1696 minX
= (wxCoord
)(dmin(x2
, dmin(x3
, x4
)) - 0.5),
1697 minY
= (wxCoord
)(dmin(y2
, dmin(y3
, y4
)) - 0.5);
1700 wxImage image
= src
.ConvertToImage();
1702 image
.ConvertColourToAlpha( m_textForegroundColour
.Red(),
1703 m_textForegroundColour
.Green(),
1704 m_textForegroundColour
.Blue() );
1705 image
= image
.Rotate( rad
, wxPoint(0,0) );
1707 int i_angle
= (int) angle
;
1708 i_angle
= i_angle
% 360;
1712 if ((i_angle
>= 90.0) && (i_angle
< 270.0))
1713 xoffset
= image
.GetWidth();
1715 if ((i_angle
>= 0.0) && (i_angle
< 180.0))
1716 yoffset
= image
.GetHeight();
1718 if ((i_angle
>= 0) && (i_angle
< 90))
1719 yoffset
-= (int)( cos(rad
)*h
);
1720 if ((i_angle
>= 90) && (i_angle
< 180))
1721 xoffset
-= (int)( sin(rad
)*h
);
1722 if ((i_angle
>= 180) && (i_angle
< 270))
1723 yoffset
-= (int)( cos(rad
)*h
);
1724 if ((i_angle
>= 270) && (i_angle
< 360))
1725 xoffset
-= (int)( sin(rad
)*h
);
1727 int i_x
= x
- xoffset
;
1728 int i_y
= y
- yoffset
;
1731 DoDrawBitmap( src
, i_x
, i_y
, true );
1734 // it would be better to draw with non underlined font and draw the line
1735 // manually here (it would be more straight...)
1737 if ( m_font
.GetUnderlined() )
1739 gdk_draw_line( m_window
, m_textGC
,
1740 XLOG2DEV(x
+ x4
), YLOG2DEV(y
+ y4
+ font
->descent
),
1741 XLOG2DEV(x
+ x3
), YLOG2DEV(y
+ y3
+ font
->descent
));
1745 // update the bounding box
1746 CalcBoundingBox(x
+ minX
, y
+ minY
);
1747 CalcBoundingBox(x
+ maxX
, y
+ maxY
);
1748 #else // !wxUSE_IMAGE
1753 #endif // wxUSE_IMAGE/!wxUSE_IMAGE
1756 void wxGTKWindowImplDC::DoGetTextExtent(const wxString
&string
,
1757 wxCoord
*width
, wxCoord
*height
,
1758 wxCoord
*descent
, wxCoord
*externalLeading
,
1759 const wxFont
*theFont
) const
1767 if ( externalLeading
)
1768 *externalLeading
= 0;
1773 // ensure that theFont is always non-NULL
1774 if ( !theFont
|| !theFont
->IsOk() )
1775 theFont
= wx_const_cast(wxFont
*, &m_font
);
1777 // and use it if it's valid
1778 if ( theFont
->IsOk() )
1780 pango_layout_set_font_description
1783 theFont
->GetNativeFontInfo()->description
1787 // Set layout's text
1788 const wxCharBuffer dataUTF8
= wxGTK_CONV_FONT(string
, *theFont
);
1791 // hardly ideal, but what else can we do if conversion failed?
1795 pango_layout_set_text( m_layout
, dataUTF8
, strlen(dataUTF8
) );
1800 pango_layout_get_pixel_size( m_layout
, width
, &h
);
1801 PangoLayoutIter
*iter
= pango_layout_get_iter(m_layout
);
1802 int baseline
= pango_layout_iter_get_baseline(iter
);
1803 pango_layout_iter_free(iter
);
1804 *descent
= h
- PANGO_PIXELS(baseline
);
1807 *height
= (wxCoord
) h
;
1811 pango_layout_get_pixel_size( m_layout
, width
, height
);
1814 // Reset old font description
1815 if (theFont
->IsOk())
1816 pango_layout_set_font_description( m_layout
, m_fontdesc
);
1820 bool wxGTKWindowImplDC::DoGetPartialTextExtents(const wxString
& text
,
1821 wxArrayInt
& widths
) const
1823 const size_t len
= text
.length();
1830 // Set layout's text
1831 const wxCharBuffer dataUTF8
= wxGTK_CONV_FONT(text
, m_font
);
1834 // hardly ideal, but what else can we do if conversion failed?
1835 wxLogLastError(wxT("DoGetPartialTextExtents"));
1839 pango_layout_set_text( m_layout
, dataUTF8
, strlen(dataUTF8
) );
1841 // Calculate the position of each character based on the widths of
1842 // the previous characters
1844 // Code borrowed from Scintilla's PlatGTK
1845 PangoLayoutIter
*iter
= pango_layout_get_iter(m_layout
);
1847 pango_layout_iter_get_cluster_extents(iter
, NULL
, &pos
);
1849 while (pango_layout_iter_next_cluster(iter
))
1851 pango_layout_iter_get_cluster_extents(iter
, NULL
, &pos
);
1852 int position
= PANGO_PIXELS(pos
.x
);
1853 widths
[i
++] = position
;
1856 widths
[i
++] = PANGO_PIXELS(pos
.x
+ pos
.width
);
1857 pango_layout_iter_free(iter
);
1863 wxCoord
wxGTKWindowImplDC::GetCharWidth() const
1865 pango_layout_set_text( m_layout
, "H", 1 );
1867 pango_layout_get_pixel_size( m_layout
, &w
, NULL
);
1871 wxCoord
wxGTKWindowImplDC::GetCharHeight() const
1873 PangoFontMetrics
*metrics
= pango_context_get_metrics (m_context
, m_fontdesc
, pango_context_get_language(m_context
));
1874 wxCHECK_MSG( metrics
, -1, _T("failed to get pango font metrics") );
1876 wxCoord h
= PANGO_PIXELS (pango_font_metrics_get_descent (metrics
) +
1877 pango_font_metrics_get_ascent (metrics
));
1878 pango_font_metrics_unref (metrics
);
1882 void wxGTKWindowImplDC::Clear()
1884 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1886 if (!m_window
) return;
1889 DoGetSize( &width
, &height
);
1890 gdk_draw_rectangle( m_window
, m_bgGC
, TRUE
, 0, 0, width
, height
);
1893 void wxGTKWindowImplDC::SetFont( const wxFont
&font
)
1900 pango_font_description_free( m_fontdesc
);
1902 m_fontdesc
= pango_font_description_copy( m_font
.GetNativeFontInfo()->description
);
1907 PangoContext
*oldContext
= m_context
;
1909 m_context
= m_owningWindow
->GtkGetPangoDefaultContext();
1911 // If we switch back/forth between different contexts
1912 // we also have to create a new layout. I think so,
1913 // at least, and it doesn't hurt to do it.
1914 if (oldContext
!= m_context
)
1917 g_object_unref (m_layout
);
1919 m_layout
= pango_layout_new( m_context
);
1923 pango_layout_set_font_description( m_layout
, m_fontdesc
);
1927 void wxGTKWindowImplDC::SetPen( const wxPen
&pen
)
1929 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1931 if (m_pen
== pen
) return;
1935 if (!m_pen
.IsOk()) return;
1937 if (!m_window
) return;
1939 gint width
= m_pen
.GetWidth();
1942 // CMB: if width is non-zero scale it with the dc
1947 // X doesn't allow different width in x and y and so we take
1950 ( fabs((double) XLOG2DEVREL(width
)) +
1951 fabs((double) YLOG2DEVREL(width
)) ) / 2.0;
1955 // width can't be 0 or an internal GTK error occurs inside
1956 // gdk_gc_set_dashes() below
1961 static const wxGTKDash dotted
[] = {1, 1};
1962 static const wxGTKDash short_dashed
[] = {2, 2};
1963 static const wxGTKDash wxCoord_dashed
[] = {2, 4};
1964 static const wxGTKDash dotted_dashed
[] = {3, 3, 1, 3};
1966 // We express dash pattern in pen width unit, so we are
1967 // independent of zoom factor and so on...
1969 const wxGTKDash
*req_dash
;
1971 GdkLineStyle lineStyle
= GDK_LINE_SOLID
;
1972 switch (m_pen
.GetStyle())
1976 lineStyle
= GDK_LINE_ON_OFF_DASH
;
1977 req_nb_dash
= m_pen
.GetDashCount();
1978 req_dash
= (wxGTKDash
*)m_pen
.GetDash();
1983 lineStyle
= GDK_LINE_ON_OFF_DASH
;
1990 lineStyle
= GDK_LINE_ON_OFF_DASH
;
1992 req_dash
= wxCoord_dashed
;
1997 lineStyle
= GDK_LINE_ON_OFF_DASH
;
1999 req_dash
= short_dashed
;
2004 // lineStyle = GDK_LINE_DOUBLE_DASH;
2005 lineStyle
= GDK_LINE_ON_OFF_DASH
;
2007 req_dash
= dotted_dashed
;
2012 case wxSTIPPLE_MASK_OPAQUE
:
2017 lineStyle
= GDK_LINE_SOLID
;
2018 req_dash
= (wxGTKDash
*)NULL
;
2024 if (req_dash
&& req_nb_dash
)
2026 wxGTKDash
*real_req_dash
= new wxGTKDash
[req_nb_dash
];
2029 for (int i
= 0; i
< req_nb_dash
; i
++)
2030 real_req_dash
[i
] = req_dash
[i
] * width
;
2031 gdk_gc_set_dashes( m_penGC
, 0, real_req_dash
, req_nb_dash
);
2032 delete[] real_req_dash
;
2036 // No Memory. We use non-scaled dash pattern...
2037 gdk_gc_set_dashes( m_penGC
, 0, (wxGTKDash
*)req_dash
, req_nb_dash
);
2041 GdkCapStyle capStyle
= GDK_CAP_ROUND
;
2042 switch (m_pen
.GetCap())
2044 case wxCAP_PROJECTING
: { capStyle
= GDK_CAP_PROJECTING
; break; }
2045 case wxCAP_BUTT
: { capStyle
= GDK_CAP_BUTT
; break; }
2052 capStyle
= GDK_CAP_NOT_LAST
;
2056 capStyle
= GDK_CAP_ROUND
;
2062 GdkJoinStyle joinStyle
= GDK_JOIN_ROUND
;
2063 switch (m_pen
.GetJoin())
2065 case wxJOIN_BEVEL
: { joinStyle
= GDK_JOIN_BEVEL
; break; }
2066 case wxJOIN_MITER
: { joinStyle
= GDK_JOIN_MITER
; break; }
2068 default: { joinStyle
= GDK_JOIN_ROUND
; break; }
2071 gdk_gc_set_line_attributes( m_penGC
, width
, lineStyle
, capStyle
, joinStyle
);
2073 m_pen
.GetColour().CalcPixel( m_cmap
);
2074 gdk_gc_set_foreground( m_penGC
, m_pen
.GetColour().GetColor() );
2077 void wxGTKWindowImplDC::SetBrush( const wxBrush
&brush
)
2079 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2081 if (m_brush
== brush
) return;
2085 if (!m_brush
.IsOk()) return;
2087 if (!m_window
) return;
2089 m_brush
.GetColour().CalcPixel( m_cmap
);
2090 gdk_gc_set_foreground( m_brushGC
, m_brush
.GetColour().GetColor() );
2092 gdk_gc_set_fill( m_brushGC
, GDK_SOLID
);
2094 if ((m_brush
.GetStyle() == wxSTIPPLE
) && (m_brush
.GetStipple()->IsOk()))
2096 if (m_brush
.GetStipple()->GetDepth() != 1)
2098 gdk_gc_set_fill( m_brushGC
, GDK_TILED
);
2099 gdk_gc_set_tile( m_brushGC
, m_brush
.GetStipple()->GetPixmap() );
2103 gdk_gc_set_fill( m_brushGC
, GDK_STIPPLED
);
2104 gdk_gc_set_stipple( m_brushGC
, m_brush
.GetStipple()->GetPixmap() );
2108 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
2110 gdk_gc_set_fill( m_textGC
, GDK_OPAQUE_STIPPLED
);
2111 gdk_gc_set_stipple( m_textGC
, m_brush
.GetStipple()->GetMask()->GetBitmap() );
2114 if (m_brush
.IsHatch())
2116 gdk_gc_set_fill( m_brushGC
, GDK_STIPPLED
);
2117 int num
= m_brush
.GetStyle() - wxBDIAGONAL_HATCH
;
2118 gdk_gc_set_stipple( m_brushGC
, hatches
[num
] );
2122 void wxGTKWindowImplDC::SetBackground( const wxBrush
&brush
)
2124 /* CMB 21/7/98: Added SetBackground. Sets background brush
2125 * for Clear() and bg colour for shapes filled with cross-hatch brush */
2127 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2129 if (m_backgroundBrush
== brush
) return;
2131 m_backgroundBrush
= brush
;
2133 if (!m_backgroundBrush
.IsOk()) return;
2135 if (!m_window
) return;
2137 m_backgroundBrush
.GetColour().CalcPixel( m_cmap
);
2138 gdk_gc_set_background( m_brushGC
, m_backgroundBrush
.GetColour().GetColor() );
2139 gdk_gc_set_background( m_penGC
, m_backgroundBrush
.GetColour().GetColor() );
2140 gdk_gc_set_background( m_bgGC
, m_backgroundBrush
.GetColour().GetColor() );
2141 gdk_gc_set_foreground( m_bgGC
, m_backgroundBrush
.GetColour().GetColor() );
2143 gdk_gc_set_fill( m_bgGC
, GDK_SOLID
);
2145 if ((m_backgroundBrush
.GetStyle() == wxSTIPPLE
) && (m_backgroundBrush
.GetStipple()->IsOk()))
2147 if (m_backgroundBrush
.GetStipple()->GetDepth() != 1)
2149 gdk_gc_set_fill( m_bgGC
, GDK_TILED
);
2150 gdk_gc_set_tile( m_bgGC
, m_backgroundBrush
.GetStipple()->GetPixmap() );
2154 gdk_gc_set_fill( m_bgGC
, GDK_STIPPLED
);
2155 gdk_gc_set_stipple( m_bgGC
, m_backgroundBrush
.GetStipple()->GetPixmap() );
2159 if (m_backgroundBrush
.IsHatch())
2161 gdk_gc_set_fill( m_bgGC
, GDK_STIPPLED
);
2162 int num
= m_backgroundBrush
.GetStyle() - wxBDIAGONAL_HATCH
;
2163 gdk_gc_set_stipple( m_bgGC
, hatches
[num
] );
2167 void wxGTKWindowImplDC::SetLogicalFunction( int function
)
2169 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2171 if (m_logicalFunction
== function
)
2174 // VZ: shouldn't this be a CHECK?
2181 case wxXOR
: mode
= GDK_XOR
; break;
2182 case wxINVERT
: mode
= GDK_INVERT
; break;
2183 case wxOR_REVERSE
: mode
= GDK_OR_REVERSE
; break;
2184 case wxAND_REVERSE
: mode
= GDK_AND_REVERSE
; break;
2185 case wxCLEAR
: mode
= GDK_CLEAR
; break;
2186 case wxSET
: mode
= GDK_SET
; break;
2187 case wxOR_INVERT
: mode
= GDK_OR_INVERT
; break;
2188 case wxAND
: mode
= GDK_AND
; break;
2189 case wxOR
: mode
= GDK_OR
; break;
2190 case wxEQUIV
: mode
= GDK_EQUIV
; break;
2191 case wxNAND
: mode
= GDK_NAND
; break;
2192 case wxAND_INVERT
: mode
= GDK_AND_INVERT
; break;
2193 case wxCOPY
: mode
= GDK_COPY
; break;
2194 case wxNO_OP
: mode
= GDK_NOOP
; break;
2195 case wxSRC_INVERT
: mode
= GDK_COPY_INVERT
; break;
2197 // unsupported by GTK
2198 case wxNOR
: mode
= GDK_COPY
; break;
2200 wxFAIL_MSG( wxT("unsupported logical function") );
2204 m_logicalFunction
= function
;
2206 gdk_gc_set_function( m_penGC
, mode
);
2207 gdk_gc_set_function( m_brushGC
, mode
);
2209 // to stay compatible with wxMSW, we don't apply ROPs to the text
2210 // operations (i.e. DrawText/DrawRotatedText).
2211 // True, but mono-bitmaps use the m_textGC and they use ROPs as well.
2212 gdk_gc_set_function( m_textGC
, mode
);
2215 void wxGTKWindowImplDC::SetTextForeground( const wxColour
&col
)
2217 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2219 // don't set m_textForegroundColour to an invalid colour as we'd crash
2220 // later then (we use m_textForegroundColour.GetColor() without checking
2222 if ( !col
.IsOk() || (m_textForegroundColour
== col
) )
2225 m_textForegroundColour
= col
;
2229 m_textForegroundColour
.CalcPixel( m_cmap
);
2230 gdk_gc_set_foreground( m_textGC
, m_textForegroundColour
.GetColor() );
2234 void wxGTKWindowImplDC::SetTextBackground( const wxColour
&col
)
2236 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2239 if ( !col
.IsOk() || (m_textBackgroundColour
== col
) )
2242 m_textBackgroundColour
= col
;
2246 m_textBackgroundColour
.CalcPixel( m_cmap
);
2247 gdk_gc_set_background( m_textGC
, m_textBackgroundColour
.GetColor() );
2251 void wxGTKWindowImplDC::SetBackgroundMode( int mode
)
2253 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2255 m_backgroundMode
= mode
;
2257 if (!m_window
) return;
2259 // CMB 21/7/98: fill style of cross-hatch brushes is affected by
2260 // transparent/solid background mode
2262 if (m_brush
.GetStyle() != wxSOLID
&& m_brush
.GetStyle() != wxTRANSPARENT
)
2264 gdk_gc_set_fill( m_brushGC
,
2265 (m_backgroundMode
== wxTRANSPARENT
) ? GDK_STIPPLED
: GDK_OPAQUE_STIPPLED
);
2269 void wxGTKWindowImplDC::SetPalette( const wxPalette
& WXUNUSED(palette
) )
2271 wxFAIL_MSG( wxT("wxGTKWindowImplDC::SetPalette not implemented") );
2274 void wxGTKWindowImplDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
2276 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2278 if (!m_window
) return;
2281 rect
.x
= XLOG2DEV(x
);
2282 rect
.y
= YLOG2DEV(y
);
2283 rect
.width
= XLOG2DEVREL(width
);
2284 rect
.height
= YLOG2DEVREL(height
);
2286 if (m_owningWindow
&& m_owningWindow
->m_wxwindow
&&
2287 (m_owningWindow
->GetLayoutDirection() == wxLayout_RightToLeft
))
2289 rect
.x
-= rect
.width
;
2292 if (!m_currentClippingRegion
.IsNull())
2293 m_currentClippingRegion
.Intersect( rect
);
2295 m_currentClippingRegion
.Union( rect
);
2297 #if USE_PAINT_REGION
2298 if (!m_paintClippingRegion
.IsNull())
2299 m_currentClippingRegion
.Intersect( m_paintClippingRegion
);
2302 wxCoord xx
, yy
, ww
, hh
;
2303 m_currentClippingRegion
.GetBox( xx
, yy
, ww
, hh
);
2305 wxImplDC::DoSetClippingRegion( xx
, yy
, ww
, hh
);
2307 wxDC::DoSetClippingRegion( xx
, yy
, ww
, hh
);
2310 gdk_gc_set_clip_region( m_penGC
, m_currentClippingRegion
.GetRegion() );
2311 gdk_gc_set_clip_region( m_brushGC
, m_currentClippingRegion
.GetRegion() );
2312 gdk_gc_set_clip_region( m_textGC
, m_currentClippingRegion
.GetRegion() );
2313 gdk_gc_set_clip_region( m_bgGC
, m_currentClippingRegion
.GetRegion() );
2316 void wxGTKWindowImplDC::DoSetClippingRegionAsRegion( const wxRegion
®ion
)
2318 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2322 DestroyClippingRegion();
2326 if (!m_window
) return;
2328 if (!m_currentClippingRegion
.IsNull())
2329 m_currentClippingRegion
.Intersect( region
);
2331 m_currentClippingRegion
.Union( region
);
2333 #if USE_PAINT_REGION
2334 if (!m_paintClippingRegion
.IsNull())
2335 m_currentClippingRegion
.Intersect( m_paintClippingRegion
);
2338 wxCoord xx
, yy
, ww
, hh
;
2339 m_currentClippingRegion
.GetBox( xx
, yy
, ww
, hh
);
2341 wxImplDC::DoSetClippingRegion( xx
, yy
, ww
, hh
);
2343 wxDC::DoSetClippingRegion( xx
, yy
, ww
, hh
);
2346 gdk_gc_set_clip_region( m_penGC
, m_currentClippingRegion
.GetRegion() );
2347 gdk_gc_set_clip_region( m_brushGC
, m_currentClippingRegion
.GetRegion() );
2348 gdk_gc_set_clip_region( m_textGC
, m_currentClippingRegion
.GetRegion() );
2349 gdk_gc_set_clip_region( m_bgGC
, m_currentClippingRegion
.GetRegion() );
2352 void wxGTKWindowImplDC::DestroyClippingRegion()
2354 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2357 wxImplDC::DestroyClippingRegion();
2359 wxDC::DestroyClippingRegion();
2362 m_currentClippingRegion
.Clear();
2364 #if USE_PAINT_REGION
2365 if (!m_paintClippingRegion
.IsEmpty())
2366 m_currentClippingRegion
.Union( m_paintClippingRegion
);
2369 if (!m_window
) return;
2371 if (m_currentClippingRegion
.IsEmpty())
2373 gdk_gc_set_clip_rectangle( m_penGC
, (GdkRectangle
*) NULL
);
2374 gdk_gc_set_clip_rectangle( m_brushGC
, (GdkRectangle
*) NULL
);
2375 gdk_gc_set_clip_rectangle( m_textGC
, (GdkRectangle
*) NULL
);
2376 gdk_gc_set_clip_rectangle( m_bgGC
, (GdkRectangle
*) NULL
);
2380 gdk_gc_set_clip_region( m_penGC
, m_currentClippingRegion
.GetRegion() );
2381 gdk_gc_set_clip_region( m_brushGC
, m_currentClippingRegion
.GetRegion() );
2382 gdk_gc_set_clip_region( m_textGC
, m_currentClippingRegion
.GetRegion() );
2383 gdk_gc_set_clip_region( m_bgGC
, m_currentClippingRegion
.GetRegion() );
2387 void wxGTKWindowImplDC::Destroy()
2389 if (m_penGC
) wxFreePoolGC( m_penGC
);
2390 m_penGC
= (GdkGC
*) NULL
;
2391 if (m_brushGC
) wxFreePoolGC( m_brushGC
);
2392 m_brushGC
= (GdkGC
*) NULL
;
2393 if (m_textGC
) wxFreePoolGC( m_textGC
);
2394 m_textGC
= (GdkGC
*) NULL
;
2395 if (m_bgGC
) wxFreePoolGC( m_bgGC
);
2396 m_bgGC
= (GdkGC
*) NULL
;
2399 void wxGTKWindowImplDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
2401 m_deviceOriginX
= x
;
2402 m_deviceOriginY
= y
;
2404 ComputeScaleAndOrigin();
2407 void wxGTKWindowImplDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
2409 m_signX
= (xLeftRight
? 1 : -1);
2410 m_signY
= (yBottomUp
? -1 : 1);
2412 if (m_owningWindow
&& m_owningWindow
->m_wxwindow
&&
2413 (m_owningWindow
->GetLayoutDirection() == wxLayout_RightToLeft
))
2416 ComputeScaleAndOrigin();
2419 void wxGTKWindowImplDC::ComputeScaleAndOrigin()
2421 const wxRealPoint
origScale(m_scaleX
, m_scaleY
);
2424 wxImplDC::ComputeScaleAndOrigin();
2426 wxDC::ComputeScaleAndOrigin();
2429 // if scale has changed call SetPen to recalulate the line width
2430 if ( wxRealPoint(m_scaleX
, m_scaleY
) != origScale
&& m_pen
.IsOk() )
2432 // this is a bit artificial, but we need to force wxDC to think the pen
2440 // Resolution in pixels per logical inch
2441 wxSize
wxGTKWindowImplDC::GetPPI() const
2443 return wxSize( (int) (m_mm_to_pix_x
* 25.4 + 0.5), (int) (m_mm_to_pix_y
* 25.4 + 0.5));
2446 int wxGTKWindowImplDC::GetDepth() const
2448 return gdk_drawable_get_depth(m_window
);
2452 //-----------------------------------------------------------------------------
2454 //-----------------------------------------------------------------------------
2457 IMPLEMENT_ABSTRACT_CLASS(wxGTKClientImplDC
, wxGTKWindowImplDC
)
2459 IMPLEMENT_ABSTRACT_CLASS(wxClientDC
, wxWindowDC
)
2463 wxGTKClientImplDC::wxGTKClientImplDC( wxDC
*owner
)
2464 : wxGTKWindowImplDC( owner
)
2468 wxGTKClientImplDC::wxGTKClientImplDC( wxDC
*owner
, wxWindow
*win
)
2469 : wxGTKWindowImplDC( owner
, win
)
2471 wxClientDC::wxClientDC()
2475 wxClientDC::wxClientDC( wxWindow
*win
)
2480 wxCHECK_RET( win
, _T("NULL window in wxGTKClientImplDC::wxClientDC") );
2482 #ifdef __WXUNIVERSAL__
2483 wxPoint ptOrigin
= win
->GetClientAreaOrigin();
2484 SetDeviceOrigin(ptOrigin
.x
, ptOrigin
.y
);
2485 wxSize size
= win
->GetClientSize();
2486 SetClippingRegion(wxPoint(0, 0), size
);
2487 #endif // __WXUNIVERSAL__
2490 void wxGTKClientImplDC::DoGetSize(int *width
, int *height
) const
2492 wxCHECK_RET( m_owningWindow
, _T("GetSize() doesn't work without window") );
2494 m_owningWindow
->GetClientSize( width
, height
);
2497 //-----------------------------------------------------------------------------
2499 //-----------------------------------------------------------------------------
2502 IMPLEMENT_ABSTRACT_CLASS(wxGTKPaintImplDC
, wxGTKClientImplDC
)
2504 IMPLEMENT_ABSTRACT_CLASS(wxPaintDC
, wxClientDC
)
2507 // Limit the paint region to the window size. Sometimes
2508 // the paint region is too big, and this risks X11 errors
2509 static void wxLimitRegionToSize(wxRegion
& region
, const wxSize
& sz
)
2511 wxRect originalRect
= region
.GetBox();
2512 wxRect
rect(originalRect
);
2513 if (rect
.width
+ rect
.x
> sz
.x
)
2514 rect
.width
= sz
.x
- rect
.x
;
2515 if (rect
.height
+ rect
.y
> sz
.y
)
2516 rect
.height
= sz
.y
- rect
.y
;
2517 if (rect
!= originalRect
)
2519 region
= wxRegion(rect
);
2520 wxLogTrace(wxT("painting"), wxT("Limiting region from %d, %d, %d, %d to %d, %d, %d, %d\n"),
2521 originalRect
.x
, originalRect
.y
, originalRect
.width
, originalRect
.height
,
2522 rect
.x
, rect
.y
, rect
.width
, rect
.height
);
2527 wxGTKPaintImplDC::wxGTKPaintImplDC( wxDC
*owner
)
2528 : wxGTKClientImplDC( owner
)
2532 wxGTKPaintImplDC::wxGTKPaintImplDC( wxDC
*owner
, wxWindow
*win
)
2533 : wxGTKClientImplDC( owner
, win
)
2535 wxPaintDC::wxPaintDC()
2540 wxPaintDC::wxPaintDC( wxWindow
*win
)
2544 #if USE_PAINT_REGION
2545 if (!win
->m_clipPaintRegion
)
2548 wxSize sz
= win
->GetSize();
2549 m_paintClippingRegion
= win
->m_nativeUpdateRegion
;
2550 wxLimitRegionToSize(m_paintClippingRegion
, sz
);
2552 GdkRegion
*region
= m_paintClippingRegion
.GetRegion();
2555 m_currentClippingRegion
.Union( m_paintClippingRegion
);
2556 wxLimitRegionToSize(m_currentClippingRegion
, sz
);
2558 if (sz
.x
<= 0 || sz
.y
<= 0)
2561 gdk_gc_set_clip_region( m_penGC
, region
);
2562 gdk_gc_set_clip_region( m_brushGC
, region
);
2563 gdk_gc_set_clip_region( m_textGC
, region
);
2564 gdk_gc_set_clip_region( m_bgGC
, region
);
2566 #endif // USE_PAINT_REGION
2569 // ----------------------------------------------------------------------------
2571 // ----------------------------------------------------------------------------
2573 class wxDCModule
: public wxModule
2580 DECLARE_DYNAMIC_CLASS(wxDCModule
)
2583 IMPLEMENT_DYNAMIC_CLASS(wxDCModule
, wxModule
)
2585 bool wxDCModule::OnInit()
2591 void wxDCModule::OnExit()