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
);
476 bool wxGTKWindowImplDC::DoGetPixel( wxCoord x1
, wxCoord y1
, wxColour
*col
) const
479 // Generic (and therefore rather inefficient) method.
480 // Could be improved.
482 wxBitmap
bitmap(1, 1);
483 memdc
.SelectObject(bitmap
);
484 memdc
.Blit(0, 0, 1, 1, (wxDC
*) this, x1
, y1
);
485 memdc
.SelectObject(wxNullBitmap
);
487 wxImage image
= bitmap
.ConvertToImage();
488 col
->Set(image
.GetRed(0, 0), image
.GetGreen(0, 0), image
.GetBlue(0, 0));
490 #else // !wxUSE_IMAGE
492 #endif // wxUSE_IMAGE/!wxUSE_IMAGE
495 void wxGTKWindowImplDC::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
497 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
499 if (m_pen
.GetStyle() != wxTRANSPARENT
)
502 gdk_draw_line( m_window
, m_penGC
, XLOG2DEV(x1
), YLOG2DEV(y1
), XLOG2DEV(x2
), YLOG2DEV(y2
) );
504 CalcBoundingBox(x1
, y1
);
505 CalcBoundingBox(x2
, y2
);
509 void wxGTKWindowImplDC::DoCrossHair( wxCoord x
, wxCoord y
)
511 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
513 if (m_pen
.GetStyle() != wxTRANSPARENT
)
517 GetOwner()->GetSize( &w
, &h
);
518 wxCoord xx
= XLOG2DEV(x
);
519 wxCoord yy
= YLOG2DEV(y
);
522 gdk_draw_line( m_window
, m_penGC
, 0, yy
, XLOG2DEVREL(w
), yy
);
523 gdk_draw_line( m_window
, m_penGC
, xx
, 0, xx
, YLOG2DEVREL(h
) );
528 void wxGTKWindowImplDC::DoDrawArc( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
529 wxCoord xc
, wxCoord yc
)
531 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
533 wxCoord xx1
= XLOG2DEV(x1
);
534 wxCoord yy1
= YLOG2DEV(y1
);
535 wxCoord xx2
= XLOG2DEV(x2
);
536 wxCoord yy2
= YLOG2DEV(y2
);
537 wxCoord xxc
= XLOG2DEV(xc
);
538 wxCoord yyc
= YLOG2DEV(yc
);
539 double dx
= xx1
- xxc
;
540 double dy
= yy1
- yyc
;
541 double radius
= sqrt((double)(dx
*dx
+dy
*dy
));
542 wxCoord r
= (wxCoord
)radius
;
543 double radius1
, radius2
;
545 if (xx1
== xx2
&& yy1
== yy2
)
550 else if ( wxIsNullDouble(radius
) )
557 radius1
= (xx1
- xxc
== 0) ?
558 (yy1
- yyc
< 0) ? 90.0 : -90.0 :
559 -atan2(double(yy1
-yyc
), double(xx1
-xxc
)) * RAD2DEG
;
560 radius2
= (xx2
- xxc
== 0) ?
561 (yy2
- yyc
< 0) ? 90.0 : -90.0 :
562 -atan2(double(yy2
-yyc
), double(xx2
-xxc
)) * RAD2DEG
;
564 wxCoord alpha1
= wxCoord(radius1
* 64.0);
565 wxCoord alpha2
= wxCoord((radius2
- radius1
) * 64.0);
566 while (alpha2
<= 0) alpha2
+= 360*64;
567 while (alpha1
> 360*64) alpha1
-= 360*64;
571 if (m_brush
.GetStyle() != wxTRANSPARENT
)
573 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
575 gdk_gc_set_ts_origin( m_textGC
,
576 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
577 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
578 gdk_draw_arc( m_window
, m_textGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
579 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
581 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
583 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
584 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
585 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
587 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
589 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
590 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
591 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
593 if (m_brush
.GetStyle() == wxSTIPPLE
)
595 gdk_gc_set_ts_origin( m_brushGC
,
596 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
597 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
598 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
599 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
603 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
607 if (m_pen
.GetStyle() != wxTRANSPARENT
)
609 gdk_draw_arc( m_window
, m_penGC
, FALSE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
611 if ((m_brush
.GetStyle() != wxTRANSPARENT
) && (alpha2
- alpha1
!= 360*64))
613 gdk_draw_line( m_window
, m_penGC
, xx1
, yy1
, xxc
, yyc
);
614 gdk_draw_line( m_window
, m_penGC
, xxc
, yyc
, xx2
, yy2
);
619 CalcBoundingBox (x1
, y1
);
620 CalcBoundingBox (x2
, y2
);
623 void wxGTKWindowImplDC::DoDrawEllipticArc( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double sa
, double ea
)
625 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
627 wxCoord xx
= XLOG2DEV(x
);
628 wxCoord yy
= YLOG2DEV(y
);
629 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
630 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
632 // CMB: handle -ve width and/or height
633 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
634 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
638 wxCoord start
= wxCoord(sa
* 64.0);
639 wxCoord end
= wxCoord((ea
-sa
) * 64.0);
641 if (m_brush
.GetStyle() != wxTRANSPARENT
)
643 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
645 gdk_gc_set_ts_origin( m_textGC
,
646 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
647 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
648 gdk_draw_arc( m_window
, m_textGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
649 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
651 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
653 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
654 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
655 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
657 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
659 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
660 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
661 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
663 if (m_brush
.GetStyle() == wxSTIPPLE
)
665 gdk_gc_set_ts_origin( m_brushGC
,
666 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
667 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
668 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
669 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
673 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
677 if (m_pen
.GetStyle() != wxTRANSPARENT
)
678 gdk_draw_arc( m_window
, m_penGC
, FALSE
, xx
, yy
, ww
, hh
, start
, end
);
681 CalcBoundingBox (x
, y
);
682 CalcBoundingBox (x
+ width
, y
+ height
);
685 void wxGTKWindowImplDC::DoDrawPoint( wxCoord x
, wxCoord y
)
687 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
689 if ((m_pen
.GetStyle() != wxTRANSPARENT
) && m_window
)
690 gdk_draw_point( m_window
, m_penGC
, XLOG2DEV(x
), YLOG2DEV(y
) );
692 CalcBoundingBox (x
, y
);
695 void wxGTKWindowImplDC::DoDrawLines( int n
, wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
)
697 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
699 if (m_pen
.GetStyle() == wxTRANSPARENT
) return;
702 //Check, if scaling is necessary
704 xoffset
!= 0 || yoffset
!= 0 || XLOG2DEV(10) != 10 || YLOG2DEV(10) != 10;
706 // GdkPoint and wxPoint have the same memory layout, so we can cast one to the other
707 GdkPoint
* gpts
= reinterpret_cast<GdkPoint
*>(points
);
710 gpts
= new GdkPoint
[n
];
712 for (int i
= 0; i
< n
; i
++)
716 gpts
[i
].x
= XLOG2DEV(points
[i
].x
+ xoffset
);
717 gpts
[i
].y
= YLOG2DEV(points
[i
].y
+ yoffset
);
719 CalcBoundingBox(points
[i
].x
+ xoffset
, points
[i
].y
+ yoffset
);
723 gdk_draw_lines( m_window
, m_penGC
, gpts
, n
);
729 void wxGTKWindowImplDC::DoDrawPolygon( int n
, wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
, int WXUNUSED(fillStyle
) )
731 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
735 //Check, if scaling is necessary
737 xoffset
!= 0 || yoffset
!= 0 || XLOG2DEV(10) != 10 || YLOG2DEV(10) != 10;
739 // GdkPoint and wxPoint have the same memory layout, so we can cast one to the other
740 GdkPoint
* gdkpoints
= reinterpret_cast<GdkPoint
*>(points
);
743 gdkpoints
= new GdkPoint
[n
];
746 for (i
= 0 ; i
< n
; i
++)
750 gdkpoints
[i
].x
= XLOG2DEV(points
[i
].x
+ xoffset
);
751 gdkpoints
[i
].y
= YLOG2DEV(points
[i
].y
+ yoffset
);
753 CalcBoundingBox(points
[i
].x
+ xoffset
, points
[i
].y
+ yoffset
);
758 if (m_brush
.GetStyle() != wxTRANSPARENT
)
760 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
762 gdk_gc_set_ts_origin( m_textGC
,
763 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
764 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
765 gdk_draw_polygon( m_window
, m_textGC
, TRUE
, gdkpoints
, n
);
766 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
768 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
770 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
771 gdk_draw_polygon( m_window
, m_brushGC
, TRUE
, gdkpoints
, n
);
772 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
774 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
776 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
777 gdk_draw_polygon( m_window
, m_brushGC
, TRUE
, gdkpoints
, n
);
778 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
780 if (m_brush
.GetStyle() == wxSTIPPLE
)
782 gdk_gc_set_ts_origin( m_brushGC
,
783 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
784 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
785 gdk_draw_polygon( m_window
, m_brushGC
, TRUE
, gdkpoints
, n
);
786 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
790 gdk_draw_polygon( m_window
, m_brushGC
, TRUE
, gdkpoints
, n
);
794 if (m_pen
.GetStyle() != wxTRANSPARENT
)
797 for (i = 0 ; i < n ; i++)
799 gdk_draw_line( m_window, m_penGC,
802 gdkpoints[(i+1)%n].x,
803 gdkpoints[(i+1)%n].y);
806 gdk_draw_polygon( m_window
, m_penGC
, FALSE
, gdkpoints
, n
);
815 void wxGTKWindowImplDC::DoDrawRectangle( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
817 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
819 wxCoord xx
= XLOG2DEV(x
);
820 wxCoord yy
= YLOG2DEV(y
);
821 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
822 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
824 // CMB: draw nothing if transformed w or h is 0
825 if (ww
== 0 || hh
== 0) return;
827 // CMB: handle -ve width and/or height
828 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
829 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
833 if (m_brush
.GetStyle() != wxTRANSPARENT
)
835 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
837 gdk_gc_set_ts_origin( m_textGC
,
838 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
839 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
840 gdk_draw_rectangle( m_window
, m_textGC
, TRUE
, xx
, yy
, ww
, hh
);
841 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
843 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
845 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
846 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
);
847 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
849 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
851 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
852 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
);
853 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
855 if (m_brush
.GetStyle() == wxSTIPPLE
)
857 gdk_gc_set_ts_origin( m_brushGC
,
858 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
859 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
860 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
);
861 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
865 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
);
869 if (m_pen
.GetStyle() != wxTRANSPARENT
)
872 if ((m_pen
.GetWidth() == 2) && (m_pen
.GetCap() == wxCAP_ROUND
) &&
873 (m_pen
.GetJoin() == wxJOIN_ROUND
) && (m_pen
.GetStyle() == wxSOLID
))
875 // Use 2 1-line rects instead
876 gdk_gc_set_line_attributes( m_penGC
, 1, GDK_LINE_SOLID
, GDK_CAP_ROUND
, GDK_JOIN_ROUND
);
881 gdk_draw_rectangle( m_window
, m_penGC
, FALSE
, xx
+1, yy
, ww
-2, hh
-2 );
882 gdk_draw_rectangle( m_window
, m_penGC
, FALSE
, xx
, yy
-1, ww
, hh
);
886 gdk_draw_rectangle( m_window
, m_penGC
, FALSE
, xx
, yy
, ww
-2, hh
-2 );
887 gdk_draw_rectangle( m_window
, m_penGC
, FALSE
, xx
-1, yy
-1, ww
, hh
);
891 gdk_gc_set_line_attributes( m_penGC
, 2, GDK_LINE_SOLID
, GDK_CAP_ROUND
, GDK_JOIN_ROUND
);
896 // Just use X11 for other cases
897 gdk_draw_rectangle( m_window
, m_penGC
, FALSE
, xx
, yy
, ww
-1, hh
-1 );
902 CalcBoundingBox( x
, y
);
903 CalcBoundingBox( x
+ width
, y
+ height
);
906 void wxGTKWindowImplDC::DoDrawRoundedRectangle( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double radius
)
908 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
910 if (radius
< 0.0) radius
= - radius
* ((width
< height
) ? width
: height
);
912 wxCoord xx
= XLOG2DEV(x
);
913 wxCoord yy
= YLOG2DEV(y
);
914 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
915 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
916 wxCoord rr
= XLOG2DEVREL((wxCoord
)radius
);
918 // CMB: handle -ve width and/or height
919 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
920 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
922 // CMB: if radius is zero use DrawRectangle() instead to avoid
923 // X drawing errors with small radii
926 DoDrawRectangle( x
, y
, width
, height
);
930 // CMB: draw nothing if transformed w or h is 0
931 if (ww
== 0 || hh
== 0) return;
933 // CMB: adjust size if outline is drawn otherwise the result is
934 // 1 pixel too wide and high
935 if (m_pen
.GetStyle() != wxTRANSPARENT
)
943 // CMB: ensure dd is not larger than rectangle otherwise we
944 // get an hour glass shape
946 if (dd
> ww
) dd
= ww
;
947 if (dd
> hh
) dd
= hh
;
950 if (m_brush
.GetStyle() != wxTRANSPARENT
)
952 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
954 gdk_gc_set_ts_origin( m_textGC
,
955 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
956 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
957 gdk_draw_rectangle( m_window
, m_textGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
958 gdk_draw_rectangle( m_window
, m_textGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
959 gdk_draw_arc( m_window
, m_textGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
960 gdk_draw_arc( m_window
, m_textGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
961 gdk_draw_arc( m_window
, m_textGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
962 gdk_draw_arc( m_window
, m_textGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
963 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
965 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
967 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
968 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
969 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
970 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
971 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
972 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
973 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
974 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
976 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
978 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
979 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
980 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
981 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
982 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
983 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
984 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
985 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
987 if (m_brush
.GetStyle() == wxSTIPPLE
)
989 gdk_gc_set_ts_origin( m_brushGC
,
990 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
991 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
992 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
993 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
994 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
995 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
996 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
997 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
998 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
1002 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
1003 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
1004 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
1005 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
1006 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
1007 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
1011 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1013 gdk_draw_line( m_window
, m_penGC
, xx
+rr
+1, yy
, xx
+ww
-rr
, yy
);
1014 gdk_draw_line( m_window
, m_penGC
, xx
+rr
+1, yy
+hh
, xx
+ww
-rr
, yy
+hh
);
1015 gdk_draw_line( m_window
, m_penGC
, xx
, yy
+rr
+1, xx
, yy
+hh
-rr
);
1016 gdk_draw_line( m_window
, m_penGC
, xx
+ww
, yy
+rr
+1, xx
+ww
, yy
+hh
-rr
);
1017 gdk_draw_arc( m_window
, m_penGC
, FALSE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
1018 gdk_draw_arc( m_window
, m_penGC
, FALSE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
1019 gdk_draw_arc( m_window
, m_penGC
, FALSE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
1020 gdk_draw_arc( m_window
, m_penGC
, FALSE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
1024 // this ignores the radius
1025 CalcBoundingBox( x
, y
);
1026 CalcBoundingBox( x
+ width
, y
+ height
);
1029 void wxGTKWindowImplDC::DoDrawEllipse( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1031 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1033 wxCoord xx
= XLOG2DEV(x
);
1034 wxCoord yy
= YLOG2DEV(y
);
1035 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1036 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1038 // CMB: handle -ve width and/or height
1039 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
1040 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
1044 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1046 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
1048 gdk_gc_set_ts_origin( m_textGC
,
1049 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
1050 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
1051 gdk_draw_arc( m_window
, m_textGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1052 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
1054 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
1056 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
1057 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1058 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
1060 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
1062 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
1063 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1064 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
1066 if (m_brush
.GetStyle() == wxSTIPPLE
)
1068 gdk_gc_set_ts_origin( m_brushGC
,
1069 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
1070 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
1071 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1072 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
1076 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1080 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1081 gdk_draw_arc( m_window
, m_penGC
, FALSE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1084 CalcBoundingBox( x
, y
);
1085 CalcBoundingBox( x
+ width
, y
+ height
);
1088 void wxGTKWindowImplDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
1090 // VZ: egcs 1.0.3 refuses to compile this without cast, no idea why
1091 DoDrawBitmap( (const wxBitmap
&)icon
, x
, y
, true );
1094 void wxGTKWindowImplDC::DoDrawBitmap( const wxBitmap
&bitmap
,
1095 wxCoord x
, wxCoord y
,
1098 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1100 wxCHECK_RET( bitmap
.IsOk(), wxT("invalid bitmap") );
1102 bool is_mono
= bitmap
.GetDepth() == 1;
1104 // scale/translate size and position
1105 int xx
= XLOG2DEV(x
);
1106 int yy
= YLOG2DEV(y
);
1108 int w
= bitmap
.GetWidth();
1109 int h
= bitmap
.GetHeight();
1111 if (m_owningWindow
&& m_owningWindow
->GetLayoutDirection() == wxLayout_RightToLeft
)
1114 CalcBoundingBox( x
, y
);
1115 CalcBoundingBox( x
+ w
, y
+ h
);
1117 if (!m_window
) return;
1119 int ww
= XLOG2DEVREL(w
);
1120 int hh
= YLOG2DEVREL(h
);
1122 // compare to current clipping region
1123 if (!m_currentClippingRegion
.IsNull())
1125 wxRegion
tmp( xx
,yy
,ww
,hh
);
1126 tmp
.Intersect( m_currentClippingRegion
);
1131 // scale bitmap if required
1132 wxBitmap use_bitmap
= bitmap
;
1133 if ((w
!= ww
) || (h
!= hh
))
1134 use_bitmap
= use_bitmap
.Rescale( 0, 0, ww
, hh
, ww
, hh
);
1136 // apply mask if any
1137 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
1138 if (useMask
&& use_bitmap
.GetMask())
1139 mask
= use_bitmap
.GetMask()->GetBitmap();
1141 GdkGC
* use_gc
= is_mono
? m_textGC
: m_penGC
;
1143 GdkBitmap
*new_mask
= (GdkBitmap
*) NULL
;
1147 if (!m_currentClippingRegion
.IsNull())
1150 new_mask
= gdk_pixmap_new( wxGetRootWindow()->window
, ww
, hh
, 1 );
1151 GdkGC
*gc
= gdk_gc_new( new_mask
);
1153 gdk_gc_set_foreground( gc
, &col
);
1154 gdk_draw_rectangle( new_mask
, gc
, TRUE
, 0, 0, ww
, hh
);
1156 gdk_gc_set_background( gc
, &col
);
1158 gdk_gc_set_foreground( gc
, &col
);
1159 gdk_gc_set_clip_region( gc
, m_currentClippingRegion
.GetRegion() );
1160 gdk_gc_set_clip_origin( gc
, -xx
, -yy
);
1161 gdk_gc_set_fill( gc
, GDK_OPAQUE_STIPPLED
);
1162 gdk_gc_set_stipple( gc
, mask
);
1163 gdk_draw_rectangle( new_mask
, gc
, TRUE
, 0, 0, ww
, hh
);
1165 g_object_unref (gc
);
1168 gdk_gc_set_clip_mask(use_gc
, mask
);
1169 gdk_gc_set_clip_origin(use_gc
, xx
, yy
);
1172 // Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For
1173 // drawing a mono-bitmap (XBitmap) we use the current text GC
1176 GdkPixmap
*bitmap2
= gdk_pixmap_new( wxGetRootWindow()->window
, ww
, hh
, -1 );
1177 GdkGC
*gc
= gdk_gc_new( bitmap2
);
1178 gdk_gc_set_foreground( gc
, m_textForegroundColour
.GetColor() );
1179 gdk_gc_set_background( gc
, m_textBackgroundColour
.GetColor() );
1180 gdk_wx_draw_bitmap(bitmap2
, gc
, use_bitmap
.GetPixmap(), 0, 0);
1182 gdk_draw_drawable(m_window
, use_gc
, bitmap2
, 0, 0, xx
, yy
, -1, -1);
1184 g_object_unref (bitmap2
);
1185 g_object_unref (gc
);
1189 if (use_bitmap
.HasPixbuf())
1191 gdk_draw_pixbuf(m_window
, use_gc
,
1192 use_bitmap
.GetPixbuf(),
1193 0, 0, xx
, yy
, -1, -1,
1194 GDK_RGB_DITHER_NORMAL
, xx
, yy
);
1198 gdk_draw_drawable(m_window
, use_gc
,
1199 use_bitmap
.GetPixmap(),
1200 0, 0, xx
, yy
, -1, -1);
1204 // remove mask again if any
1207 gdk_gc_set_clip_mask(use_gc
, NULL
);
1208 gdk_gc_set_clip_origin(use_gc
, 0, 0);
1209 if (!m_currentClippingRegion
.IsNull())
1210 gdk_gc_set_clip_region(use_gc
, m_currentClippingRegion
.GetRegion());
1211 if (new_mask
!= NULL
)
1212 g_object_unref(new_mask
);
1216 bool wxGTKWindowImplDC::DoBlit( wxCoord xdest
, wxCoord ydest
,
1217 wxCoord width
, wxCoord height
,
1219 wxCoord xsrc
, wxCoord ysrc
,
1222 wxCoord xsrcMask
, wxCoord ysrcMask
)
1224 wxCHECK_MSG( IsOk(), false, wxT("invalid window dc") );
1226 wxCHECK_MSG( source
, false, wxT("invalid source dc") );
1228 if (!m_window
) return false;
1230 // transform the source DC coords to the device ones
1231 xsrc
= source
->LogicalToDeviceX(xsrc
);
1232 ysrc
= source
->LogicalToDeviceY(ysrc
);
1235 wxMemoryDC
*memDC
= wxDynamicCast(source
, wxMemoryDC
);
1238 selected
= memDC
->GetSelectedBitmap();
1239 if ( !selected
.IsOk() )
1243 bool use_bitmap_method
= false;
1244 bool is_mono
= false;
1246 if (xsrcMask
== -1 && ysrcMask
== -1)
1252 if (selected
.IsOk())
1254 is_mono
= (selected
.GetDepth() == 1);
1256 // we use the "XCopyArea" way to copy a memory dc into
1257 // a different window if the memory dc BOTH
1258 // a) doesn't have any mask or its mask isn't used
1262 if (useMask
&& (selected
.GetMask()))
1264 // we HAVE TO use the direct way for memory dcs
1265 // that have mask since the XCopyArea doesn't know
1267 use_bitmap_method
= true;
1271 // we HAVE TO use the direct way for memory dcs
1272 // that are bitmaps because XCopyArea doesn't cope
1273 // with different bit depths
1274 use_bitmap_method
= true;
1276 else if ((xsrc
== 0) && (ysrc
== 0) &&
1277 (width
== selected
.GetWidth()) &&
1278 (height
== selected
.GetHeight()))
1280 // we SHOULD use the direct way if all of the bitmap
1281 // in the memory dc is copied in which case XCopyArea
1282 // wouldn't be able able to boost performace by reducing
1283 // the area to be scaled
1284 use_bitmap_method
= true;
1288 CalcBoundingBox( xdest
, ydest
);
1289 CalcBoundingBox( xdest
+ width
, ydest
+ height
);
1291 // scale/translate size and position
1292 wxCoord xx
= XLOG2DEV(xdest
);
1293 wxCoord yy
= YLOG2DEV(ydest
);
1295 wxCoord ww
= XLOG2DEVREL(width
);
1296 wxCoord hh
= YLOG2DEVREL(height
);
1298 // compare to current clipping region
1299 if (!m_currentClippingRegion
.IsNull())
1301 wxRegion
tmp( xx
,yy
,ww
,hh
);
1302 tmp
.Intersect( m_currentClippingRegion
);
1307 int old_logical_func
= m_logicalFunction
;
1308 SetLogicalFunction( logical_func
);
1310 if (use_bitmap_method
)
1312 // scale/translate bitmap size
1313 wxCoord bm_width
= selected
.GetWidth();
1314 wxCoord bm_height
= selected
.GetHeight();
1316 // Get clip coords for the bitmap. If we don't
1317 // use wxBitmap::Rescale(), which can clip the
1318 // bitmap, these are the same as the original
1325 // interpret userscale of src too
1327 memDC
->GetUserScale(&xsc
,&ysc
);
1328 bm_width
= (int) (bm_width
/ xsc
);
1329 bm_height
= (int) (bm_height
/ ysc
);
1331 wxCoord bm_ww
= XLOG2DEVREL( bm_width
);
1332 wxCoord bm_hh
= YLOG2DEVREL( bm_height
);
1334 // Scale bitmap if required
1335 wxBitmap use_bitmap
= selected
;
1336 if ((selected
.GetWidth()!= bm_ww
) || ( selected
.GetHeight()!= bm_hh
))
1338 // This indicates that the blitting code below will get
1339 // a clipped bitmap and therefore needs to move the origin
1341 wxRegion
tmp( xx
,yy
,ww
,hh
);
1342 if (!m_currentClippingRegion
.IsNull())
1343 tmp
.Intersect( m_currentClippingRegion
);
1344 tmp
.GetBox(cx
,cy
,cw
,ch
);
1346 // Scale and clipped bitmap
1347 use_bitmap
= selected
.Rescale(cx
-xx
,cy
-yy
,cw
,ch
,bm_ww
,bm_hh
);
1350 // apply mask if any
1351 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
1352 if (useMask
&& use_bitmap
.GetMask())
1353 mask
= use_bitmap
.GetMask()->GetBitmap();
1355 GdkGC
* use_gc
= is_mono
? m_textGC
: m_penGC
;
1357 GdkBitmap
*new_mask
= (GdkBitmap
*) NULL
;
1361 if (!m_currentClippingRegion
.IsNull())
1364 new_mask
= gdk_pixmap_new( wxGetRootWindow()->window
, bm_ww
, bm_hh
, 1 );
1365 GdkGC
*gc
= gdk_gc_new( new_mask
);
1367 gdk_gc_set_foreground( gc
, &col
);
1368 gdk_gc_set_ts_origin( gc
, -xsrcMask
, -ysrcMask
);
1369 gdk_draw_rectangle( new_mask
, gc
, TRUE
, 0, 0, bm_ww
, bm_hh
);
1371 gdk_gc_set_background( gc
, &col
);
1373 gdk_gc_set_foreground( gc
, &col
);
1374 gdk_gc_set_clip_region( gc
, m_currentClippingRegion
.GetRegion() );
1375 // was: gdk_gc_set_clip_origin( gc, -xx, -yy );
1376 gdk_gc_set_clip_origin( gc
, -cx
, -cy
);
1377 gdk_gc_set_fill( gc
, GDK_OPAQUE_STIPPLED
);
1378 gdk_gc_set_stipple( gc
, mask
);
1379 gdk_draw_rectangle( new_mask
, gc
, TRUE
, 0, 0, bm_ww
, bm_hh
);
1381 g_object_unref (gc
);
1384 gdk_gc_set_clip_mask(use_gc
, mask
);
1385 if (new_mask
!= NULL
)
1386 gdk_gc_set_clip_origin(use_gc
, cx
, cy
);
1388 gdk_gc_set_clip_origin(use_gc
, cx
- xsrcMask
, cy
- ysrcMask
);
1391 // Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For
1392 // drawing a mono-bitmap (XBitmap) we use the current text GC
1396 GdkPixmap
*bitmap
= gdk_pixmap_new( wxGetRootWindow()->window
, bm_ww
, bm_hh
, -1 );
1397 GdkGC
*gc
= gdk_gc_new( bitmap
);
1398 gdk_gc_set_foreground( gc
, m_textForegroundColour
.GetColor() );
1399 gdk_gc_set_background( gc
, m_textBackgroundColour
.GetColor() );
1400 gdk_wx_draw_bitmap(bitmap
, gc
, use_bitmap
.GetPixmap(), 0, 0);
1402 gdk_draw_drawable(m_window
, use_gc
, bitmap
, xsrc
, ysrc
, cx
, cy
, cw
, ch
);
1404 g_object_unref (bitmap
);
1405 g_object_unref (gc
);
1409 // was: gdk_draw_drawable( m_window, m_penGC, use_bitmap.GetPixmap(), xsrc, ysrc, xx, yy, ww, hh );
1410 gdk_draw_drawable(m_window
, use_gc
, use_bitmap
.GetPixmap(), xsrc
, ysrc
, cx
, cy
, cw
, ch
);
1413 // remove mask again if any
1416 gdk_gc_set_clip_mask(use_gc
, NULL
);
1417 gdk_gc_set_clip_origin(use_gc
, 0, 0);
1418 if (!m_currentClippingRegion
.IsNull())
1419 gdk_gc_set_clip_region(use_gc
, m_currentClippingRegion
.GetRegion());
1423 g_object_unref (new_mask
);
1425 else // use_bitmap_method
1427 if (selected
.IsOk() && ((width
!= ww
) || (height
!= hh
)))
1430 wxRegion
tmp( xx
,yy
,ww
,hh
);
1431 tmp
.Intersect( m_currentClippingRegion
);
1432 wxCoord cx
,cy
,cw
,ch
;
1433 tmp
.GetBox(cx
,cy
,cw
,ch
);
1436 wxBitmap bitmap
= selected
.Rescale( cx
-xx
, cy
-yy
, cw
, ch
, ww
, hh
);
1438 // draw scaled bitmap
1439 // was: gdk_draw_drawable( m_window, m_penGC, bitmap.GetPixmap(), 0, 0, xx, yy, -1, -1 );
1440 gdk_draw_drawable( m_window
, m_penGC
, bitmap
.GetPixmap(), 0, 0, cx
, cy
, -1, -1 );
1444 // No scaling and not a memory dc with a mask either
1446 GdkWindow
* window
= NULL
;
1447 wxImplDC
*impl
= source
->GetImpl();
1448 wxGTKWindowImplDC
*gtk_impl
= wxDynamicCast(impl
, wxGTKWindowImplDC
);
1450 window
= gtk_impl
->GetGDKWindow();
1452 GdkWindow
* window
= source
->GetGDKWindow();
1457 // copy including child window contents
1458 gdk_gc_set_subwindow( m_penGC
, GDK_INCLUDE_INFERIORS
);
1459 gdk_draw_drawable( m_window
, m_penGC
,
1463 gdk_gc_set_subwindow( m_penGC
, GDK_CLIP_BY_CHILDREN
);
1467 SetLogicalFunction( old_logical_func
);
1472 void wxGTKWindowImplDC::DoDrawText( const wxString
&text
, wxCoord x
, wxCoord y
)
1474 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1476 if (!m_window
) return;
1478 if (text
.empty()) return;
1483 wxCHECK_RET( m_context
, wxT("no Pango context") );
1484 wxCHECK_RET( m_layout
, wxT("no Pango layout") );
1485 wxCHECK_RET( m_fontdesc
, wxT("no Pango font description") );
1487 gdk_pango_context_set_colormap( m_context
, m_cmap
);
1489 bool underlined
= m_font
.IsOk() && m_font
.GetUnderlined();
1491 const wxCharBuffer data
= wxGTK_CONV( text
);
1494 size_t datalen
= strlen(data
);
1496 // in Pango >= 1.16 the "underline of leading/trailing spaces" bug
1497 // has been fixed and thus the hack implemented below should never be used
1498 static bool pangoOk
= !wx_pango_version_check(1, 16, 0);
1500 bool needshack
= underlined
&& !pangoOk
;
1501 char *hackstring
= NULL
;
1505 // a PangoLayout which has leading/trailing spaces with underlined font
1506 // is not correctly drawn by this pango version: Pango won't underline the spaces.
1507 // This can be a problem; e.g. wxHTML rendering of underlined text relies on
1508 // this behaviour. To workaround this problem, we use a special hack here
1509 // suggested by pango maintainer Behdad Esfahbod: we prepend and append two
1510 // empty space characters and give them a dummy colour attribute.
1511 // This will force Pango to underline the leading/trailing spaces, too.
1513 // need to realloc the string to prepend & append our special characters
1514 hackstring
= (char*)malloc((datalen
+7)*sizeof(char));
1516 // copy the leading U+200C ZERO WIDTH NON-JOINER encoded in UTF8 format
1517 strcpy(hackstring
, "\342\200\214");
1519 // copy the user string
1520 memcpy(&hackstring
[3], data
, datalen
);
1522 // copy the trailing U+200C ZERO WIDTH NON-JOINER encoded in UTF8 format
1523 strcpy(&hackstring
[datalen
+3], "\342\200\214");
1525 // the special characters that we added require 6 additional bytes:
1528 pango_layout_set_text(m_layout
, hackstring
, datalen
);
1532 pango_layout_set_text(m_layout
, data
, datalen
);
1537 PangoAttrList
*attrs
= pango_attr_list_new();
1538 PangoAttribute
*a
= pango_attr_underline_new(PANGO_UNDERLINE_SINGLE
);
1540 a
->end_index
= datalen
;
1541 pango_attr_list_insert(attrs
, a
);
1545 // dummy colour for the leading space
1546 a
= pango_attr_foreground_new (0x0057, 0x52A9, 0xD614);
1549 pango_attr_list_insert(attrs
, a
);
1551 // dummy colour for the trailing space
1552 a
= pango_attr_foreground_new (0x0057, 0x52A9, 0xD614);
1553 a
->start_index
= datalen
- 1;
1554 a
->end_index
= datalen
;
1555 pango_attr_list_insert(attrs
, a
);
1558 pango_layout_set_attributes(m_layout
, attrs
);
1559 pango_attr_list_unref(attrs
);
1564 if (fabs(m_scaleY
- 1.0) > 0.00001)
1566 // If there is a user or actually any scale applied to
1567 // the device context, scale the font.
1569 // scale font description
1570 gint oldSize
= pango_font_description_get_size( m_fontdesc
);
1571 double size
= oldSize
;
1572 size
= size
* m_scaleY
;
1573 pango_font_description_set_size( m_fontdesc
, (gint
)size
);
1575 // actually apply scaled font
1576 pango_layout_set_font_description( m_layout
, m_fontdesc
);
1578 pango_layout_get_pixel_size( m_layout
, &w
, &h
);
1579 if ( m_backgroundMode
== wxSOLID
)
1581 gdk_gc_set_foreground(m_textGC
, m_textBackgroundColour
.GetColor());
1582 gdk_draw_rectangle(m_window
, m_textGC
, TRUE
, x
, y
, w
, h
);
1583 gdk_gc_set_foreground(m_textGC
, m_textForegroundColour
.GetColor());
1587 if (m_owningWindow
&& m_owningWindow
->GetLayoutDirection() == wxLayout_RightToLeft
)
1588 gdk_draw_layout( m_window
, m_textGC
, x
-w
, y
, m_layout
);
1590 gdk_draw_layout( m_window
, m_textGC
, x
, y
, m_layout
);
1592 // reset unscaled size
1593 pango_font_description_set_size( m_fontdesc
, oldSize
);
1595 // actually apply unscaled font
1596 pango_layout_set_font_description( m_layout
, m_fontdesc
);
1600 pango_layout_get_pixel_size( m_layout
, &w
, &h
);
1601 if ( m_backgroundMode
== wxSOLID
)
1603 gdk_gc_set_foreground(m_textGC
, m_textBackgroundColour
.GetColor());
1604 gdk_draw_rectangle(m_window
, m_textGC
, TRUE
, x
, y
, w
, h
);
1605 gdk_gc_set_foreground(m_textGC
, m_textForegroundColour
.GetColor());
1609 if (m_owningWindow
&& m_owningWindow
->GetLayoutDirection() == wxLayout_RightToLeft
)
1610 gdk_draw_layout( m_window
, m_textGC
, x
-w
, y
, m_layout
);
1612 gdk_draw_layout( m_window
, m_textGC
, x
, y
, m_layout
);
1617 // undo underline attributes setting:
1618 pango_layout_set_attributes(m_layout
, NULL
);
1624 width
= wxCoord(width
/ m_scaleX
);
1625 height
= wxCoord(height
/ m_scaleY
);
1626 CalcBoundingBox (x
+ width
, y
+ height
);
1627 CalcBoundingBox (x
, y
);
1634 // TODO: There is an example of rotating text with GTK2 that would probably be
1635 // a better approach here:
1636 // http://www.daa.com.au/pipermail/pygtk/2003-April/005052.html
1638 void wxGTKWindowImplDC::DoDrawRotatedText( const wxString
&text
, wxCoord x
, wxCoord y
, double angle
)
1641 if (!m_window
|| text
.empty())
1644 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1646 if ( wxIsNullDouble(angle
) )
1648 DoDrawText(text
, x
, y
);
1655 // TODO: implement later without GdkFont for GTK 2.0
1656 DoGetTextExtent(text
, &w
, &h
, NULL
,NULL
, &m_font
);
1658 // draw the string normally
1661 dc
.SelectObject(src
);
1662 dc
.SetFont(GetFont());
1663 dc
.SetBackground(*wxBLACK_BRUSH
);
1664 dc
.SetBrush(*wxBLACK_BRUSH
);
1666 dc
.SetTextForeground( *wxWHITE
);
1667 dc
.DrawText(text
, 0, 0);
1668 dc
.SelectObject(wxNullBitmap
);
1670 // Calculate the size of the rotated bounding box.
1671 double rad
= DegToRad(angle
);
1672 double dx
= cos(rad
),
1675 // the rectngle vertices are counted clockwise with the first one being at
1676 // (0, 0) (or, rather, at (x, y))
1678 y2
= -w
*dy
; // y axis points to the bottom, hence minus
1681 double x3
= x4
+ x2
,
1685 wxCoord maxX
= (wxCoord
)(dmax(x2
, dmax(x3
, x4
)) + 0.5),
1686 maxY
= (wxCoord
)(dmax(y2
, dmax(y3
, y4
)) + 0.5),
1687 minX
= (wxCoord
)(dmin(x2
, dmin(x3
, x4
)) - 0.5),
1688 minY
= (wxCoord
)(dmin(y2
, dmin(y3
, y4
)) - 0.5);
1691 wxImage image
= src
.ConvertToImage();
1693 image
.ConvertColourToAlpha( m_textForegroundColour
.Red(),
1694 m_textForegroundColour
.Green(),
1695 m_textForegroundColour
.Blue() );
1696 image
= image
.Rotate( rad
, wxPoint(0,0) );
1698 int i_angle
= (int) angle
;
1699 i_angle
= i_angle
% 360;
1703 if ((i_angle
>= 90.0) && (i_angle
< 270.0))
1704 xoffset
= image
.GetWidth();
1706 if ((i_angle
>= 0.0) && (i_angle
< 180.0))
1707 yoffset
= image
.GetHeight();
1709 if ((i_angle
>= 0) && (i_angle
< 90))
1710 yoffset
-= (int)( cos(rad
)*h
);
1711 if ((i_angle
>= 90) && (i_angle
< 180))
1712 xoffset
-= (int)( sin(rad
)*h
);
1713 if ((i_angle
>= 180) && (i_angle
< 270))
1714 yoffset
-= (int)( cos(rad
)*h
);
1715 if ((i_angle
>= 270) && (i_angle
< 360))
1716 xoffset
-= (int)( sin(rad
)*h
);
1718 int i_x
= x
- xoffset
;
1719 int i_y
= y
- yoffset
;
1722 DoDrawBitmap( src
, i_x
, i_y
, true );
1725 // it would be better to draw with non underlined font and draw the line
1726 // manually here (it would be more straight...)
1728 if ( m_font
.GetUnderlined() )
1730 gdk_draw_line( m_window
, m_textGC
,
1731 XLOG2DEV(x
+ x4
), YLOG2DEV(y
+ y4
+ font
->descent
),
1732 XLOG2DEV(x
+ x3
), YLOG2DEV(y
+ y3
+ font
->descent
));
1736 // update the bounding box
1737 CalcBoundingBox(x
+ minX
, y
+ minY
);
1738 CalcBoundingBox(x
+ maxX
, y
+ maxY
);
1739 #endif // wxUSE_IMAGE
1742 void wxGTKWindowImplDC::DoGetTextExtent(const wxString
&string
,
1743 wxCoord
*width
, wxCoord
*height
,
1744 wxCoord
*descent
, wxCoord
*externalLeading
,
1745 const wxFont
*theFont
) const
1753 if ( externalLeading
)
1754 *externalLeading
= 0;
1759 // ensure that theFont is always non-NULL
1760 if ( !theFont
|| !theFont
->IsOk() )
1761 theFont
= wx_const_cast(wxFont
*, &m_font
);
1763 // and use it if it's valid
1764 if ( theFont
->IsOk() )
1766 pango_layout_set_font_description
1769 theFont
->GetNativeFontInfo()->description
1773 // Set layout's text
1774 const wxCharBuffer dataUTF8
= wxGTK_CONV_FONT(string
, *theFont
);
1777 // hardly ideal, but what else can we do if conversion failed?
1781 pango_layout_set_text( m_layout
, dataUTF8
, strlen(dataUTF8
) );
1786 pango_layout_get_pixel_size( m_layout
, width
, &h
);
1787 PangoLayoutIter
*iter
= pango_layout_get_iter(m_layout
);
1788 int baseline
= pango_layout_iter_get_baseline(iter
);
1789 pango_layout_iter_free(iter
);
1790 *descent
= h
- PANGO_PIXELS(baseline
);
1793 *height
= (wxCoord
) h
;
1797 pango_layout_get_pixel_size( m_layout
, width
, height
);
1800 // Reset old font description
1801 if (theFont
->IsOk())
1802 pango_layout_set_font_description( m_layout
, m_fontdesc
);
1806 bool wxGTKWindowImplDC::DoGetPartialTextExtents(const wxString
& text
,
1807 wxArrayInt
& widths
) const
1809 const size_t len
= text
.length();
1816 // Set layout's text
1817 const wxCharBuffer dataUTF8
= wxGTK_CONV_FONT(text
, m_font
);
1820 // hardly ideal, but what else can we do if conversion failed?
1821 wxLogLastError(wxT("DoGetPartialTextExtents"));
1825 pango_layout_set_text( m_layout
, dataUTF8
, strlen(dataUTF8
) );
1827 // Calculate the position of each character based on the widths of
1828 // the previous characters
1830 // Code borrowed from Scintilla's PlatGTK
1831 PangoLayoutIter
*iter
= pango_layout_get_iter(m_layout
);
1833 pango_layout_iter_get_cluster_extents(iter
, NULL
, &pos
);
1835 while (pango_layout_iter_next_cluster(iter
))
1837 pango_layout_iter_get_cluster_extents(iter
, NULL
, &pos
);
1838 int position
= PANGO_PIXELS(pos
.x
);
1839 widths
[i
++] = position
;
1842 widths
[i
++] = PANGO_PIXELS(pos
.x
+ pos
.width
);
1843 pango_layout_iter_free(iter
);
1849 wxCoord
wxGTKWindowImplDC::GetCharWidth() const
1851 pango_layout_set_text( m_layout
, "H", 1 );
1853 pango_layout_get_pixel_size( m_layout
, &w
, NULL
);
1857 wxCoord
wxGTKWindowImplDC::GetCharHeight() const
1859 PangoFontMetrics
*metrics
= pango_context_get_metrics (m_context
, m_fontdesc
, pango_context_get_language(m_context
));
1860 wxCHECK_MSG( metrics
, -1, _T("failed to get pango font metrics") );
1862 wxCoord h
= PANGO_PIXELS (pango_font_metrics_get_descent (metrics
) +
1863 pango_font_metrics_get_ascent (metrics
));
1864 pango_font_metrics_unref (metrics
);
1868 void wxGTKWindowImplDC::Clear()
1870 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1872 if (!m_window
) return;
1875 DoGetSize( &width
, &height
);
1876 gdk_draw_rectangle( m_window
, m_bgGC
, TRUE
, 0, 0, width
, height
);
1879 void wxGTKWindowImplDC::SetFont( const wxFont
&font
)
1886 pango_font_description_free( m_fontdesc
);
1888 m_fontdesc
= pango_font_description_copy( m_font
.GetNativeFontInfo()->description
);
1893 PangoContext
*oldContext
= m_context
;
1895 m_context
= m_owningWindow
->GtkGetPangoDefaultContext();
1897 // If we switch back/forth between different contexts
1898 // we also have to create a new layout. I think so,
1899 // at least, and it doesn't hurt to do it.
1900 if (oldContext
!= m_context
)
1903 g_object_unref (m_layout
);
1905 m_layout
= pango_layout_new( m_context
);
1909 pango_layout_set_font_description( m_layout
, m_fontdesc
);
1913 void wxGTKWindowImplDC::SetPen( const wxPen
&pen
)
1915 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1917 if (m_pen
== pen
) return;
1921 if (!m_pen
.IsOk()) return;
1923 if (!m_window
) return;
1925 gint width
= m_pen
.GetWidth();
1928 // CMB: if width is non-zero scale it with the dc
1933 // X doesn't allow different width in x and y and so we take
1936 ( fabs((double) XLOG2DEVREL(width
)) +
1937 fabs((double) YLOG2DEVREL(width
)) ) / 2.0;
1941 // width can't be 0 or an internal GTK error occurs inside
1942 // gdk_gc_set_dashes() below
1947 static const wxGTKDash dotted
[] = {1, 1};
1948 static const wxGTKDash short_dashed
[] = {2, 2};
1949 static const wxGTKDash wxCoord_dashed
[] = {2, 4};
1950 static const wxGTKDash dotted_dashed
[] = {3, 3, 1, 3};
1952 // We express dash pattern in pen width unit, so we are
1953 // independent of zoom factor and so on...
1955 const wxGTKDash
*req_dash
;
1957 GdkLineStyle lineStyle
= GDK_LINE_SOLID
;
1958 switch (m_pen
.GetStyle())
1962 lineStyle
= GDK_LINE_ON_OFF_DASH
;
1963 req_nb_dash
= m_pen
.GetDashCount();
1964 req_dash
= (wxGTKDash
*)m_pen
.GetDash();
1969 lineStyle
= GDK_LINE_ON_OFF_DASH
;
1976 lineStyle
= GDK_LINE_ON_OFF_DASH
;
1978 req_dash
= wxCoord_dashed
;
1983 lineStyle
= GDK_LINE_ON_OFF_DASH
;
1985 req_dash
= short_dashed
;
1990 // lineStyle = GDK_LINE_DOUBLE_DASH;
1991 lineStyle
= GDK_LINE_ON_OFF_DASH
;
1993 req_dash
= dotted_dashed
;
1998 case wxSTIPPLE_MASK_OPAQUE
:
2003 lineStyle
= GDK_LINE_SOLID
;
2004 req_dash
= (wxGTKDash
*)NULL
;
2010 if (req_dash
&& req_nb_dash
)
2012 wxGTKDash
*real_req_dash
= new wxGTKDash
[req_nb_dash
];
2015 for (int i
= 0; i
< req_nb_dash
; i
++)
2016 real_req_dash
[i
] = req_dash
[i
] * width
;
2017 gdk_gc_set_dashes( m_penGC
, 0, real_req_dash
, req_nb_dash
);
2018 delete[] real_req_dash
;
2022 // No Memory. We use non-scaled dash pattern...
2023 gdk_gc_set_dashes( m_penGC
, 0, (wxGTKDash
*)req_dash
, req_nb_dash
);
2027 GdkCapStyle capStyle
= GDK_CAP_ROUND
;
2028 switch (m_pen
.GetCap())
2030 case wxCAP_PROJECTING
: { capStyle
= GDK_CAP_PROJECTING
; break; }
2031 case wxCAP_BUTT
: { capStyle
= GDK_CAP_BUTT
; break; }
2038 capStyle
= GDK_CAP_NOT_LAST
;
2042 capStyle
= GDK_CAP_ROUND
;
2048 GdkJoinStyle joinStyle
= GDK_JOIN_ROUND
;
2049 switch (m_pen
.GetJoin())
2051 case wxJOIN_BEVEL
: { joinStyle
= GDK_JOIN_BEVEL
; break; }
2052 case wxJOIN_MITER
: { joinStyle
= GDK_JOIN_MITER
; break; }
2054 default: { joinStyle
= GDK_JOIN_ROUND
; break; }
2057 gdk_gc_set_line_attributes( m_penGC
, width
, lineStyle
, capStyle
, joinStyle
);
2059 m_pen
.GetColour().CalcPixel( m_cmap
);
2060 gdk_gc_set_foreground( m_penGC
, m_pen
.GetColour().GetColor() );
2063 void wxGTKWindowImplDC::SetBrush( const wxBrush
&brush
)
2065 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2067 if (m_brush
== brush
) return;
2071 if (!m_brush
.IsOk()) return;
2073 if (!m_window
) return;
2075 m_brush
.GetColour().CalcPixel( m_cmap
);
2076 gdk_gc_set_foreground( m_brushGC
, m_brush
.GetColour().GetColor() );
2078 gdk_gc_set_fill( m_brushGC
, GDK_SOLID
);
2080 if ((m_brush
.GetStyle() == wxSTIPPLE
) && (m_brush
.GetStipple()->IsOk()))
2082 if (m_brush
.GetStipple()->GetDepth() != 1)
2084 gdk_gc_set_fill( m_brushGC
, GDK_TILED
);
2085 gdk_gc_set_tile( m_brushGC
, m_brush
.GetStipple()->GetPixmap() );
2089 gdk_gc_set_fill( m_brushGC
, GDK_STIPPLED
);
2090 gdk_gc_set_stipple( m_brushGC
, m_brush
.GetStipple()->GetPixmap() );
2094 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
2096 gdk_gc_set_fill( m_textGC
, GDK_OPAQUE_STIPPLED
);
2097 gdk_gc_set_stipple( m_textGC
, m_brush
.GetStipple()->GetMask()->GetBitmap() );
2100 if (m_brush
.IsHatch())
2102 gdk_gc_set_fill( m_brushGC
, GDK_STIPPLED
);
2103 int num
= m_brush
.GetStyle() - wxBDIAGONAL_HATCH
;
2104 gdk_gc_set_stipple( m_brushGC
, hatches
[num
] );
2108 void wxGTKWindowImplDC::SetBackground( const wxBrush
&brush
)
2110 /* CMB 21/7/98: Added SetBackground. Sets background brush
2111 * for Clear() and bg colour for shapes filled with cross-hatch brush */
2113 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2115 if (m_backgroundBrush
== brush
) return;
2117 m_backgroundBrush
= brush
;
2119 if (!m_backgroundBrush
.IsOk()) return;
2121 if (!m_window
) return;
2123 m_backgroundBrush
.GetColour().CalcPixel( m_cmap
);
2124 gdk_gc_set_background( m_brushGC
, m_backgroundBrush
.GetColour().GetColor() );
2125 gdk_gc_set_background( m_penGC
, m_backgroundBrush
.GetColour().GetColor() );
2126 gdk_gc_set_background( m_bgGC
, m_backgroundBrush
.GetColour().GetColor() );
2127 gdk_gc_set_foreground( m_bgGC
, m_backgroundBrush
.GetColour().GetColor() );
2129 gdk_gc_set_fill( m_bgGC
, GDK_SOLID
);
2131 if ((m_backgroundBrush
.GetStyle() == wxSTIPPLE
) && (m_backgroundBrush
.GetStipple()->IsOk()))
2133 if (m_backgroundBrush
.GetStipple()->GetDepth() != 1)
2135 gdk_gc_set_fill( m_bgGC
, GDK_TILED
);
2136 gdk_gc_set_tile( m_bgGC
, m_backgroundBrush
.GetStipple()->GetPixmap() );
2140 gdk_gc_set_fill( m_bgGC
, GDK_STIPPLED
);
2141 gdk_gc_set_stipple( m_bgGC
, m_backgroundBrush
.GetStipple()->GetPixmap() );
2145 if (m_backgroundBrush
.IsHatch())
2147 gdk_gc_set_fill( m_bgGC
, GDK_STIPPLED
);
2148 int num
= m_backgroundBrush
.GetStyle() - wxBDIAGONAL_HATCH
;
2149 gdk_gc_set_stipple( m_bgGC
, hatches
[num
] );
2153 void wxGTKWindowImplDC::SetLogicalFunction( int function
)
2155 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2157 if (m_logicalFunction
== function
)
2160 // VZ: shouldn't this be a CHECK?
2167 case wxXOR
: mode
= GDK_XOR
; break;
2168 case wxINVERT
: mode
= GDK_INVERT
; break;
2169 case wxOR_REVERSE
: mode
= GDK_OR_REVERSE
; break;
2170 case wxAND_REVERSE
: mode
= GDK_AND_REVERSE
; break;
2171 case wxCLEAR
: mode
= GDK_CLEAR
; break;
2172 case wxSET
: mode
= GDK_SET
; break;
2173 case wxOR_INVERT
: mode
= GDK_OR_INVERT
; break;
2174 case wxAND
: mode
= GDK_AND
; break;
2175 case wxOR
: mode
= GDK_OR
; break;
2176 case wxEQUIV
: mode
= GDK_EQUIV
; break;
2177 case wxNAND
: mode
= GDK_NAND
; break;
2178 case wxAND_INVERT
: mode
= GDK_AND_INVERT
; break;
2179 case wxCOPY
: mode
= GDK_COPY
; break;
2180 case wxNO_OP
: mode
= GDK_NOOP
; break;
2181 case wxSRC_INVERT
: mode
= GDK_COPY_INVERT
; break;
2183 // unsupported by GTK
2184 case wxNOR
: mode
= GDK_COPY
; break;
2186 wxFAIL_MSG( wxT("unsupported logical function") );
2190 m_logicalFunction
= function
;
2192 gdk_gc_set_function( m_penGC
, mode
);
2193 gdk_gc_set_function( m_brushGC
, mode
);
2195 // to stay compatible with wxMSW, we don't apply ROPs to the text
2196 // operations (i.e. DrawText/DrawRotatedText).
2197 // True, but mono-bitmaps use the m_textGC and they use ROPs as well.
2198 gdk_gc_set_function( m_textGC
, mode
);
2201 void wxGTKWindowImplDC::SetTextForeground( const wxColour
&col
)
2203 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2205 // don't set m_textForegroundColour to an invalid colour as we'd crash
2206 // later then (we use m_textForegroundColour.GetColor() without checking
2208 if ( !col
.IsOk() || (m_textForegroundColour
== col
) )
2211 m_textForegroundColour
= col
;
2215 m_textForegroundColour
.CalcPixel( m_cmap
);
2216 gdk_gc_set_foreground( m_textGC
, m_textForegroundColour
.GetColor() );
2220 void wxGTKWindowImplDC::SetTextBackground( const wxColour
&col
)
2222 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2225 if ( !col
.IsOk() || (m_textBackgroundColour
== col
) )
2228 m_textBackgroundColour
= col
;
2232 m_textBackgroundColour
.CalcPixel( m_cmap
);
2233 gdk_gc_set_background( m_textGC
, m_textBackgroundColour
.GetColor() );
2237 void wxGTKWindowImplDC::SetBackgroundMode( int mode
)
2239 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2241 m_backgroundMode
= mode
;
2243 if (!m_window
) return;
2245 // CMB 21/7/98: fill style of cross-hatch brushes is affected by
2246 // transparent/solid background mode
2248 if (m_brush
.GetStyle() != wxSOLID
&& m_brush
.GetStyle() != wxTRANSPARENT
)
2250 gdk_gc_set_fill( m_brushGC
,
2251 (m_backgroundMode
== wxTRANSPARENT
) ? GDK_STIPPLED
: GDK_OPAQUE_STIPPLED
);
2255 void wxGTKWindowImplDC::SetPalette( const wxPalette
& WXUNUSED(palette
) )
2257 wxFAIL_MSG( wxT("wxGTKWindowImplDC::SetPalette not implemented") );
2260 void wxGTKWindowImplDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
2262 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2264 if (!m_window
) return;
2267 rect
.x
= XLOG2DEV(x
);
2268 rect
.y
= YLOG2DEV(y
);
2269 rect
.width
= XLOG2DEVREL(width
);
2270 rect
.height
= YLOG2DEVREL(height
);
2272 if (m_owningWindow
&& m_owningWindow
->m_wxwindow
&&
2273 (m_owningWindow
->GetLayoutDirection() == wxLayout_RightToLeft
))
2275 rect
.x
-= rect
.width
;
2278 if (!m_currentClippingRegion
.IsNull())
2279 m_currentClippingRegion
.Intersect( rect
);
2281 m_currentClippingRegion
.Union( rect
);
2283 #if USE_PAINT_REGION
2284 if (!m_paintClippingRegion
.IsNull())
2285 m_currentClippingRegion
.Intersect( m_paintClippingRegion
);
2288 wxCoord xx
, yy
, ww
, hh
;
2289 m_currentClippingRegion
.GetBox( xx
, yy
, ww
, hh
);
2291 wxImplDC::DoSetClippingRegion( xx
, yy
, ww
, hh
);
2293 wxDC::DoSetClippingRegion( xx
, yy
, ww
, hh
);
2296 gdk_gc_set_clip_region( m_penGC
, m_currentClippingRegion
.GetRegion() );
2297 gdk_gc_set_clip_region( m_brushGC
, m_currentClippingRegion
.GetRegion() );
2298 gdk_gc_set_clip_region( m_textGC
, m_currentClippingRegion
.GetRegion() );
2299 gdk_gc_set_clip_region( m_bgGC
, m_currentClippingRegion
.GetRegion() );
2302 void wxGTKWindowImplDC::DoSetClippingRegionAsRegion( const wxRegion
®ion
)
2304 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2308 DestroyClippingRegion();
2312 if (!m_window
) return;
2314 if (!m_currentClippingRegion
.IsNull())
2315 m_currentClippingRegion
.Intersect( region
);
2317 m_currentClippingRegion
.Union( region
);
2319 #if USE_PAINT_REGION
2320 if (!m_paintClippingRegion
.IsNull())
2321 m_currentClippingRegion
.Intersect( m_paintClippingRegion
);
2324 wxCoord xx
, yy
, ww
, hh
;
2325 m_currentClippingRegion
.GetBox( xx
, yy
, ww
, hh
);
2327 wxImplDC::DoSetClippingRegion( xx
, yy
, ww
, hh
);
2329 wxDC::DoSetClippingRegion( xx
, yy
, ww
, hh
);
2332 gdk_gc_set_clip_region( m_penGC
, m_currentClippingRegion
.GetRegion() );
2333 gdk_gc_set_clip_region( m_brushGC
, m_currentClippingRegion
.GetRegion() );
2334 gdk_gc_set_clip_region( m_textGC
, m_currentClippingRegion
.GetRegion() );
2335 gdk_gc_set_clip_region( m_bgGC
, m_currentClippingRegion
.GetRegion() );
2338 void wxGTKWindowImplDC::DestroyClippingRegion()
2340 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2343 wxImplDC::DestroyClippingRegion();
2345 wxDC::DestroyClippingRegion();
2348 m_currentClippingRegion
.Clear();
2350 #if USE_PAINT_REGION
2351 if (!m_paintClippingRegion
.IsEmpty())
2352 m_currentClippingRegion
.Union( m_paintClippingRegion
);
2355 if (!m_window
) return;
2357 if (m_currentClippingRegion
.IsEmpty())
2359 gdk_gc_set_clip_rectangle( m_penGC
, (GdkRectangle
*) NULL
);
2360 gdk_gc_set_clip_rectangle( m_brushGC
, (GdkRectangle
*) NULL
);
2361 gdk_gc_set_clip_rectangle( m_textGC
, (GdkRectangle
*) NULL
);
2362 gdk_gc_set_clip_rectangle( m_bgGC
, (GdkRectangle
*) NULL
);
2366 gdk_gc_set_clip_region( m_penGC
, m_currentClippingRegion
.GetRegion() );
2367 gdk_gc_set_clip_region( m_brushGC
, m_currentClippingRegion
.GetRegion() );
2368 gdk_gc_set_clip_region( m_textGC
, m_currentClippingRegion
.GetRegion() );
2369 gdk_gc_set_clip_region( m_bgGC
, m_currentClippingRegion
.GetRegion() );
2373 void wxGTKWindowImplDC::Destroy()
2375 if (m_penGC
) wxFreePoolGC( m_penGC
);
2376 m_penGC
= (GdkGC
*) NULL
;
2377 if (m_brushGC
) wxFreePoolGC( m_brushGC
);
2378 m_brushGC
= (GdkGC
*) NULL
;
2379 if (m_textGC
) wxFreePoolGC( m_textGC
);
2380 m_textGC
= (GdkGC
*) NULL
;
2381 if (m_bgGC
) wxFreePoolGC( m_bgGC
);
2382 m_bgGC
= (GdkGC
*) NULL
;
2385 void wxGTKWindowImplDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
2387 m_deviceOriginX
= x
;
2388 m_deviceOriginY
= y
;
2390 ComputeScaleAndOrigin();
2393 void wxGTKWindowImplDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
2395 m_signX
= (xLeftRight
? 1 : -1);
2396 m_signY
= (yBottomUp
? -1 : 1);
2398 if (m_owningWindow
&& m_owningWindow
->m_wxwindow
&&
2399 (m_owningWindow
->GetLayoutDirection() == wxLayout_RightToLeft
))
2402 ComputeScaleAndOrigin();
2405 void wxGTKWindowImplDC::ComputeScaleAndOrigin()
2407 const wxRealPoint
origScale(m_scaleX
, m_scaleY
);
2410 wxImplDC::ComputeScaleAndOrigin();
2412 wxDC::ComputeScaleAndOrigin();
2415 // if scale has changed call SetPen to recalulate the line width
2416 if ( wxRealPoint(m_scaleX
, m_scaleY
) != origScale
&& m_pen
.IsOk() )
2418 // this is a bit artificial, but we need to force wxDC to think the pen
2426 // Resolution in pixels per logical inch
2427 wxSize
wxGTKWindowImplDC::GetPPI() const
2429 return wxSize( (int) (m_mm_to_pix_x
* 25.4 + 0.5), (int) (m_mm_to_pix_y
* 25.4 + 0.5));
2432 int wxGTKWindowImplDC::GetDepth() const
2434 return gdk_drawable_get_depth(m_window
);
2438 //-----------------------------------------------------------------------------
2440 //-----------------------------------------------------------------------------
2443 IMPLEMENT_ABSTRACT_CLASS(wxGTKClientImplDC
, wxGTKWindowImplDC
)
2445 IMPLEMENT_ABSTRACT_CLASS(wxClientDC
, wxWindowDC
)
2449 wxGTKClientImplDC::wxGTKClientImplDC( wxDC
*owner
)
2450 : wxGTKWindowImplDC( owner
)
2454 wxGTKClientImplDC::wxGTKClientImplDC( wxDC
*owner
, wxWindow
*win
)
2455 : wxGTKWindowImplDC( owner
, win
)
2457 wxClientDC::wxClientDC()
2461 wxClientDC::wxClientDC( wxWindow
*win
)
2466 wxCHECK_RET( win
, _T("NULL window in wxGTKClientImplDC::wxClientDC") );
2468 #ifdef __WXUNIVERSAL__
2469 wxPoint ptOrigin
= win
->GetClientAreaOrigin();
2470 SetDeviceOrigin(ptOrigin
.x
, ptOrigin
.y
);
2471 wxSize size
= win
->GetClientSize();
2472 SetClippingRegion(wxPoint(0, 0), size
);
2473 #endif // __WXUNIVERSAL__
2476 void wxGTKClientImplDC::DoGetSize(int *width
, int *height
) const
2478 wxCHECK_RET( m_owningWindow
, _T("GetSize() doesn't work without window") );
2480 m_owningWindow
->GetClientSize( width
, height
);
2483 //-----------------------------------------------------------------------------
2485 //-----------------------------------------------------------------------------
2488 IMPLEMENT_ABSTRACT_CLASS(wxGTKPaintImplDC
, wxGTKClientImplDC
)
2490 IMPLEMENT_ABSTRACT_CLASS(wxPaintDC
, wxClientDC
)
2493 // Limit the paint region to the window size. Sometimes
2494 // the paint region is too big, and this risks X11 errors
2495 static void wxLimitRegionToSize(wxRegion
& region
, const wxSize
& sz
)
2497 wxRect originalRect
= region
.GetBox();
2498 wxRect
rect(originalRect
);
2499 if (rect
.width
+ rect
.x
> sz
.x
)
2500 rect
.width
= sz
.x
- rect
.x
;
2501 if (rect
.height
+ rect
.y
> sz
.y
)
2502 rect
.height
= sz
.y
- rect
.y
;
2503 if (rect
!= originalRect
)
2505 region
= wxRegion(rect
);
2506 wxLogTrace(wxT("painting"), wxT("Limiting region from %d, %d, %d, %d to %d, %d, %d, %d\n"),
2507 originalRect
.x
, originalRect
.y
, originalRect
.width
, originalRect
.height
,
2508 rect
.x
, rect
.y
, rect
.width
, rect
.height
);
2513 wxGTKPaintImplDC::wxGTKPaintImplDC( wxDC
*owner
)
2514 : wxGTKClientImplDC( owner
)
2518 wxGTKPaintImplDC::wxGTKPaintImplDC( wxDC
*owner
, wxWindow
*win
)
2519 : wxGTKClientImplDC( owner
, win
)
2521 wxPaintDC::wxPaintDC()
2526 wxPaintDC::wxPaintDC( wxWindow
*win
)
2530 #if USE_PAINT_REGION
2531 if (!win
->m_clipPaintRegion
)
2534 wxSize sz
= win
->GetSize();
2535 m_paintClippingRegion
= win
->m_nativeUpdateRegion
;
2536 wxLimitRegionToSize(m_paintClippingRegion
, sz
);
2538 GdkRegion
*region
= m_paintClippingRegion
.GetRegion();
2541 m_currentClippingRegion
.Union( m_paintClippingRegion
);
2542 wxLimitRegionToSize(m_currentClippingRegion
, sz
);
2544 if (sz
.x
<= 0 || sz
.y
<= 0)
2547 gdk_gc_set_clip_region( m_penGC
, region
);
2548 gdk_gc_set_clip_region( m_brushGC
, region
);
2549 gdk_gc_set_clip_region( m_textGC
, region
);
2550 gdk_gc_set_clip_region( m_bgGC
, region
);
2552 #endif // USE_PAINT_REGION
2555 // ----------------------------------------------------------------------------
2557 // ----------------------------------------------------------------------------
2559 class wxDCModule
: public wxModule
2566 DECLARE_DYNAMIC_CLASS(wxDCModule
)
2569 IMPLEMENT_DYNAMIC_CLASS(wxDCModule
, wxModule
)
2571 bool wxDCModule::OnInit()
2577 void wxDCModule::OnExit()