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/win_gtk.h"
32 #include "wx/gtk/private.h"
36 //-----------------------------------------------------------------------------
38 //-----------------------------------------------------------------------------
40 #define XLOG2DEV(x) LogicalToDeviceX(x)
41 #define XLOG2DEVREL(x) LogicalToDeviceXRel(x)
42 #define YLOG2DEV(y) LogicalToDeviceY(y)
43 #define YLOG2DEVREL(y) LogicalToDeviceYRel(y)
45 #define USE_PAINT_REGION 1
47 //-----------------------------------------------------------------------------
49 //-----------------------------------------------------------------------------
59 #define IS_15_PIX_HATCH(s) ((s)==wxCROSSDIAG_HATCH || (s)==wxHORIZONTAL_HATCH || (s)==wxVERTICAL_HATCH)
60 #define IS_16_PIX_HATCH(s) ((s)!=wxCROSSDIAG_HATCH && (s)!=wxHORIZONTAL_HATCH && (s)!=wxVERTICAL_HATCH)
63 static GdkPixmap
*hatches
[num_hatches
];
64 static GdkPixmap
**hatch_bitmap
= (GdkPixmap
**) NULL
;
66 extern GtkWidget
*wxGetRootWindow();
68 //-----------------------------------------------------------------------------
70 //-----------------------------------------------------------------------------
72 const double RAD2DEG
= 180.0 / M_PI
;
74 // ----------------------------------------------------------------------------
76 // ----------------------------------------------------------------------------
78 static inline double dmax(double a
, double b
) { return a
> b
? a
: b
; }
79 static inline double dmin(double a
, double b
) { return a
< b
? a
: b
; }
81 static inline double DegToRad(double deg
) { return (deg
* M_PI
) / 180.0; }
83 //-----------------------------------------------------------------------------
84 // temporary implementation of the missing GDK function
85 //-----------------------------------------------------------------------------
87 #include "gdk/gdkprivate.h"
90 void gdk_wx_draw_bitmap(GdkDrawable
*drawable
,
96 wxCHECK_RET( drawable
, _T("NULL drawable in gdk_wx_draw_bitmap") );
97 wxCHECK_RET( src
, _T("NULL src in gdk_wx_draw_bitmap") );
98 wxCHECK_RET( gc
, _T("NULL gc in gdk_wx_draw_bitmap") );
100 gint src_width
, src_height
;
101 gdk_drawable_get_size(src
, &src_width
, &src_height
);
103 XCopyPlane( GDK_WINDOW_XDISPLAY(drawable
),
105 GDK_WINDOW_XID(drawable
),
108 src_width
, src_height
,
113 //-----------------------------------------------------------------------------
114 // Implement Pool of Graphic contexts. Creating them takes too much time.
115 //-----------------------------------------------------------------------------
141 #define GC_POOL_ALLOC_SIZE 100
143 static int wxGCPoolSize
= 0;
145 static wxGC
*wxGCPool
= NULL
;
147 static void wxInitGCPool()
149 // This really could wait until the first call to
150 // wxGetPoolGC, but we will make the first allocation
151 // now when other initialization is being performed.
153 // Set initial pool size.
154 wxGCPoolSize
= GC_POOL_ALLOC_SIZE
;
156 // Allocate initial pool.
157 wxGCPool
= (wxGC
*)malloc(wxGCPoolSize
* sizeof(wxGC
));
158 if (wxGCPool
== NULL
)
160 // If we cannot malloc, then fail with error
161 // when debug is enabled. If debug is not enabled,
162 // the problem will eventually get caught
164 wxFAIL_MSG( wxT("Cannot allocate GC pool") );
168 // Zero initial pool.
169 memset(wxGCPool
, 0, wxGCPoolSize
* sizeof(wxGC
));
172 static void wxCleanUpGCPool()
174 for (int i
= 0; i
< wxGCPoolSize
; i
++)
176 if (wxGCPool
[i
].m_gc
)
177 g_object_unref (wxGCPool
[i
].m_gc
);
185 static GdkGC
* wxGetPoolGC( GdkWindow
*window
, wxPoolGCType type
)
189 // Look for an available GC.
190 for (int i
= 0; i
< wxGCPoolSize
; i
++)
192 if (!wxGCPool
[i
].m_gc
)
194 wxGCPool
[i
].m_gc
= gdk_gc_new( window
);
195 gdk_gc_set_exposures( wxGCPool
[i
].m_gc
, FALSE
);
196 wxGCPool
[i
].m_type
= type
;
197 wxGCPool
[i
].m_used
= false;
199 if ((!wxGCPool
[i
].m_used
) && (wxGCPool
[i
].m_type
== type
))
201 wxGCPool
[i
].m_used
= true;
202 return wxGCPool
[i
].m_gc
;
206 // We did not find an available GC.
207 // We need to grow the GC pool.
208 pptr
= (wxGC
*)realloc(wxGCPool
,
209 (wxGCPoolSize
+ GC_POOL_ALLOC_SIZE
)*sizeof(wxGC
));
212 // Initialize newly allocated pool.
214 memset(&wxGCPool
[wxGCPoolSize
], 0,
215 GC_POOL_ALLOC_SIZE
*sizeof(wxGC
));
217 // Initialize entry we will return.
218 wxGCPool
[wxGCPoolSize
].m_gc
= gdk_gc_new( window
);
219 gdk_gc_set_exposures( wxGCPool
[wxGCPoolSize
].m_gc
, FALSE
);
220 wxGCPool
[wxGCPoolSize
].m_type
= type
;
221 wxGCPool
[wxGCPoolSize
].m_used
= true;
223 // Set new value of pool size.
224 wxGCPoolSize
+= GC_POOL_ALLOC_SIZE
;
226 // Return newly allocated entry.
227 return wxGCPool
[wxGCPoolSize
-GC_POOL_ALLOC_SIZE
].m_gc
;
230 // The realloc failed. Fall through to error.
231 wxFAIL_MSG( wxT("No GC available") );
233 return (GdkGC
*) NULL
;
236 static void wxFreePoolGC( GdkGC
*gc
)
238 for (int i
= 0; i
< wxGCPoolSize
; i
++)
240 if (wxGCPool
[i
].m_gc
== gc
)
242 wxGCPool
[i
].m_used
= false;
247 wxFAIL_MSG( wxT("Wrong GC") );
250 //-----------------------------------------------------------------------------
252 //-----------------------------------------------------------------------------
255 IMPLEMENT_ABSTRACT_CLASS(wxGTKWindowImplDC
, wxGTKImplDC
)
257 IMPLEMENT_ABSTRACT_CLASS(wxWindowDC
, wxDC
)
261 wxGTKWindowImplDC::wxGTKWindowImplDC( wxDC
*owner
) :
264 wxWindowDC::wxWindowDC()
267 m_penGC
= (GdkGC
*) NULL
;
268 m_brushGC
= (GdkGC
*) NULL
;
269 m_textGC
= (GdkGC
*) NULL
;
270 m_bgGC
= (GdkGC
*) NULL
;
271 m_cmap
= (GdkColormap
*) NULL
;
272 m_isScreenDC
= false;
273 m_owningWindow
= (wxWindow
*)NULL
;
274 m_context
= (PangoContext
*)NULL
;
275 m_layout
= (PangoLayout
*)NULL
;
276 m_fontdesc
= (PangoFontDescription
*)NULL
;
280 wxGTKWindowImplDC::wxGTKWindowImplDC( wxDC
*owner
, wxWindow
*window
) :
283 wxWindowDC::wxWindowDC( wxWindow
*window
)
286 wxASSERT_MSG( window
, wxT("DC needs a window") );
288 m_penGC
= (GdkGC
*) NULL
;
289 m_brushGC
= (GdkGC
*) NULL
;
290 m_textGC
= (GdkGC
*) NULL
;
291 m_bgGC
= (GdkGC
*) NULL
;
292 m_cmap
= (GdkColormap
*) NULL
;
293 m_owningWindow
= (wxWindow
*)NULL
;
294 m_isScreenDC
= false;
295 m_font
= window
->GetFont();
297 GtkWidget
*widget
= window
->m_wxwindow
;
299 // Some controls don't have m_wxwindow - like wxStaticBox, but the user
300 // code should still be able to create wxClientDCs for them, so we will
301 // use the parent window here then.
304 window
= window
->GetParent();
305 widget
= window
->m_wxwindow
;
308 wxASSERT_MSG( widget
, wxT("DC needs a widget") );
310 m_context
= window
->GtkGetPangoDefaultContext();
311 m_layout
= pango_layout_new( m_context
);
312 m_fontdesc
= pango_font_description_copy( widget
->style
->font_desc
);
314 GtkPizza
*pizza
= GTK_PIZZA( widget
);
315 m_window
= pizza
->bin_window
;
317 // Window not realized ?
320 // Don't report problems as per MSW.
326 m_cmap
= gtk_widget_get_colormap( widget
? widget
: window
->m_widget
);
330 /* this must be done after SetUpDC, bacause SetUpDC calls the
331 repective SetBrush, SetPen, SetBackground etc functions
332 to set up the DC. SetBackground call m_owner->SetBackground
333 and this might not be desired as the standard dc background
334 is white whereas a window might assume gray to be the
335 standard (as e.g. wxStatusBar) */
337 m_owningWindow
= window
;
339 if (m_owningWindow
&& m_owningWindow
->m_wxwindow
&&
340 (m_owningWindow
->GetLayoutDirection() == wxLayout_RightToLeft
))
345 // origin in the upper right corner
346 m_deviceOriginX
= m_owningWindow
->GetClientSize().x
;
350 wxGTKWindowImplDC::~wxGTKWindowImplDC()
355 g_object_unref (m_layout
);
357 pango_font_description_free( m_fontdesc
);
360 void wxGTKWindowImplDC::SetUpDC( bool isMemDC
)
364 wxASSERT_MSG( !m_penGC
, wxT("GCs already created") );
370 wxGTKMemoryImplDC
*mem_dc
= (wxGTKMemoryImplDC
*) this;
371 if (mem_dc
->GetSelectedBitmap().GetDepth() == 1)
373 m_penGC
= wxGetPoolGC( m_window
, wxPEN_MONO
);
374 m_brushGC
= wxGetPoolGC( m_window
, wxBRUSH_MONO
);
375 m_textGC
= wxGetPoolGC( m_window
, wxTEXT_MONO
);
376 m_bgGC
= wxGetPoolGC( m_window
, wxBG_MONO
);
385 m_penGC
= wxGetPoolGC( m_window
, wxPEN_SCREEN
);
386 m_brushGC
= wxGetPoolGC( m_window
, wxBRUSH_SCREEN
);
387 m_textGC
= wxGetPoolGC( m_window
, wxTEXT_SCREEN
);
388 m_bgGC
= wxGetPoolGC( m_window
, wxBG_SCREEN
);
392 m_penGC
= wxGetPoolGC( m_window
, wxPEN_COLOUR
);
393 m_brushGC
= wxGetPoolGC( m_window
, wxBRUSH_COLOUR
);
394 m_textGC
= wxGetPoolGC( m_window
, wxTEXT_COLOUR
);
395 m_bgGC
= wxGetPoolGC( m_window
, wxBG_COLOUR
);
399 /* background colour */
400 m_backgroundBrush
= *wxWHITE_BRUSH
;
401 m_backgroundBrush
.GetColour().CalcPixel( m_cmap
);
402 const GdkColor
*bg_col
= m_backgroundBrush
.GetColour().GetColor();
405 m_textForegroundColour
.CalcPixel( m_cmap
);
406 gdk_gc_set_foreground( m_textGC
, m_textForegroundColour
.GetColor() );
408 m_textBackgroundColour
.CalcPixel( m_cmap
);
409 gdk_gc_set_background( m_textGC
, m_textBackgroundColour
.GetColor() );
411 gdk_gc_set_fill( m_textGC
, GDK_SOLID
);
413 gdk_gc_set_colormap( m_textGC
, m_cmap
);
416 m_pen
.GetColour().CalcPixel( m_cmap
);
417 gdk_gc_set_foreground( m_penGC
, m_pen
.GetColour().GetColor() );
418 gdk_gc_set_background( m_penGC
, bg_col
);
420 gdk_gc_set_line_attributes( m_penGC
, 0, GDK_LINE_SOLID
, GDK_CAP_NOT_LAST
, GDK_JOIN_ROUND
);
423 m_brush
.GetColour().CalcPixel( m_cmap
);
424 gdk_gc_set_foreground( m_brushGC
, m_brush
.GetColour().GetColor() );
425 gdk_gc_set_background( m_brushGC
, bg_col
);
427 gdk_gc_set_fill( m_brushGC
, GDK_SOLID
);
430 gdk_gc_set_background( m_bgGC
, bg_col
);
431 gdk_gc_set_foreground( m_bgGC
, bg_col
);
433 gdk_gc_set_fill( m_bgGC
, GDK_SOLID
);
436 gdk_gc_set_function( m_textGC
, GDK_COPY
);
437 gdk_gc_set_function( m_brushGC
, GDK_COPY
);
438 gdk_gc_set_function( m_penGC
, GDK_COPY
);
441 gdk_gc_set_clip_rectangle( m_penGC
, (GdkRectangle
*) NULL
);
442 gdk_gc_set_clip_rectangle( m_brushGC
, (GdkRectangle
*) NULL
);
443 gdk_gc_set_clip_rectangle( m_textGC
, (GdkRectangle
*) NULL
);
444 gdk_gc_set_clip_rectangle( m_bgGC
, (GdkRectangle
*) NULL
);
448 hatch_bitmap
= hatches
;
449 hatch_bitmap
[0] = gdk_bitmap_create_from_data( (GdkWindow
*) NULL
, bdiag_bits
, bdiag_width
, bdiag_height
);
450 hatch_bitmap
[1] = gdk_bitmap_create_from_data( (GdkWindow
*) NULL
, cdiag_bits
, cdiag_width
, cdiag_height
);
451 hatch_bitmap
[2] = gdk_bitmap_create_from_data( (GdkWindow
*) NULL
, fdiag_bits
, fdiag_width
, fdiag_height
);
452 hatch_bitmap
[3] = gdk_bitmap_create_from_data( (GdkWindow
*) NULL
, cross_bits
, cross_width
, cross_height
);
453 hatch_bitmap
[4] = gdk_bitmap_create_from_data( (GdkWindow
*) NULL
, horiz_bits
, horiz_width
, horiz_height
);
454 hatch_bitmap
[5] = gdk_bitmap_create_from_data( (GdkWindow
*) NULL
, verti_bits
, verti_width
, verti_height
);
458 void wxGTKWindowImplDC::DoGetSize( int* width
, int* height
) const
460 wxCHECK_RET( m_owningWindow
, _T("GetSize() doesn't work without window") );
462 m_owningWindow
->GetSize(width
, height
);
465 bool wxGTKWindowImplDC::DoFloodFill(wxCoord x
, wxCoord y
,
466 const wxColour
& col
, int style
)
469 extern bool wxDoFloodFill(wxDC
*dc
, wxCoord x
, wxCoord y
,
470 const wxColour
& col
, int style
);
472 return wxDoFloodFill( GetOwner(), x
, y
, col
, style
);
478 bool wxGTKWindowImplDC::DoGetPixel( wxCoord x1
, wxCoord y1
, wxColour
*col
) const
481 // Generic (and therefore rather inefficient) method.
482 // Could be improved.
484 wxBitmap
bitmap(1, 1);
485 memdc
.SelectObject(bitmap
);
486 memdc
.Blit(0, 0, 1, 1, (wxDC
*) this, x1
, y1
);
487 memdc
.SelectObject(wxNullBitmap
);
489 wxImage image
= bitmap
.ConvertToImage();
490 col
->Set(image
.GetRed(0, 0), image
.GetGreen(0, 0), image
.GetBlue(0, 0));
492 #else // !wxUSE_IMAGE
494 #endif // wxUSE_IMAGE/!wxUSE_IMAGE
497 void wxGTKWindowImplDC::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
499 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
501 if (m_pen
.GetStyle() != wxTRANSPARENT
)
504 gdk_draw_line( m_window
, m_penGC
, XLOG2DEV(x1
), YLOG2DEV(y1
), XLOG2DEV(x2
), YLOG2DEV(y2
) );
506 CalcBoundingBox(x1
, y1
);
507 CalcBoundingBox(x2
, y2
);
511 void wxGTKWindowImplDC::DoCrossHair( wxCoord x
, wxCoord y
)
513 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
515 if (m_pen
.GetStyle() != wxTRANSPARENT
)
519 GetOwner()->GetSize( &w
, &h
);
520 wxCoord xx
= XLOG2DEV(x
);
521 wxCoord yy
= YLOG2DEV(y
);
524 gdk_draw_line( m_window
, m_penGC
, 0, yy
, XLOG2DEVREL(w
), yy
);
525 gdk_draw_line( m_window
, m_penGC
, xx
, 0, xx
, YLOG2DEVREL(h
) );
530 void wxGTKWindowImplDC::DoDrawArc( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
531 wxCoord xc
, wxCoord yc
)
533 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
535 wxCoord xx1
= XLOG2DEV(x1
);
536 wxCoord yy1
= YLOG2DEV(y1
);
537 wxCoord xx2
= XLOG2DEV(x2
);
538 wxCoord yy2
= YLOG2DEV(y2
);
539 wxCoord xxc
= XLOG2DEV(xc
);
540 wxCoord yyc
= YLOG2DEV(yc
);
541 double dx
= xx1
- xxc
;
542 double dy
= yy1
- yyc
;
543 double radius
= sqrt((double)(dx
*dx
+dy
*dy
));
544 wxCoord r
= (wxCoord
)radius
;
545 double radius1
, radius2
;
547 if (xx1
== xx2
&& yy1
== yy2
)
552 else if ( wxIsNullDouble(radius
) )
559 radius1
= (xx1
- xxc
== 0) ?
560 (yy1
- yyc
< 0) ? 90.0 : -90.0 :
561 -atan2(double(yy1
-yyc
), double(xx1
-xxc
)) * RAD2DEG
;
562 radius2
= (xx2
- xxc
== 0) ?
563 (yy2
- yyc
< 0) ? 90.0 : -90.0 :
564 -atan2(double(yy2
-yyc
), double(xx2
-xxc
)) * RAD2DEG
;
566 wxCoord alpha1
= wxCoord(radius1
* 64.0);
567 wxCoord alpha2
= wxCoord((radius2
- radius1
) * 64.0);
568 while (alpha2
<= 0) alpha2
+= 360*64;
569 while (alpha1
> 360*64) alpha1
-= 360*64;
573 if (m_brush
.GetStyle() != wxTRANSPARENT
)
575 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
577 gdk_gc_set_ts_origin( m_textGC
,
578 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
579 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
580 gdk_draw_arc( m_window
, m_textGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
581 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
583 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
585 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
586 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
587 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
589 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
591 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
592 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
593 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
595 if (m_brush
.GetStyle() == wxSTIPPLE
)
597 gdk_gc_set_ts_origin( m_brushGC
,
598 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
599 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
600 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
601 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
605 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
609 if (m_pen
.GetStyle() != wxTRANSPARENT
)
611 gdk_draw_arc( m_window
, m_penGC
, FALSE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
613 if ((m_brush
.GetStyle() != wxTRANSPARENT
) && (alpha2
- alpha1
!= 360*64))
615 gdk_draw_line( m_window
, m_penGC
, xx1
, yy1
, xxc
, yyc
);
616 gdk_draw_line( m_window
, m_penGC
, xxc
, yyc
, xx2
, yy2
);
621 CalcBoundingBox (x1
, y1
);
622 CalcBoundingBox (x2
, y2
);
625 void wxGTKWindowImplDC::DoDrawEllipticArc( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double sa
, double ea
)
627 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
629 wxCoord xx
= XLOG2DEV(x
);
630 wxCoord yy
= YLOG2DEV(y
);
631 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
632 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
634 // CMB: handle -ve width and/or height
635 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
636 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
640 wxCoord start
= wxCoord(sa
* 64.0);
641 wxCoord end
= wxCoord((ea
-sa
) * 64.0);
643 if (m_brush
.GetStyle() != wxTRANSPARENT
)
645 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
647 gdk_gc_set_ts_origin( m_textGC
,
648 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
649 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
650 gdk_draw_arc( m_window
, m_textGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
651 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
653 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
655 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
656 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
657 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
659 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
661 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
662 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
663 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
665 if (m_brush
.GetStyle() == wxSTIPPLE
)
667 gdk_gc_set_ts_origin( m_brushGC
,
668 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
669 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
670 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
671 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
675 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
679 if (m_pen
.GetStyle() != wxTRANSPARENT
)
680 gdk_draw_arc( m_window
, m_penGC
, FALSE
, xx
, yy
, ww
, hh
, start
, end
);
683 CalcBoundingBox (x
, y
);
684 CalcBoundingBox (x
+ width
, y
+ height
);
687 void wxGTKWindowImplDC::DoDrawPoint( wxCoord x
, wxCoord y
)
689 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
691 if ((m_pen
.GetStyle() != wxTRANSPARENT
) && m_window
)
692 gdk_draw_point( m_window
, m_penGC
, XLOG2DEV(x
), YLOG2DEV(y
) );
694 CalcBoundingBox (x
, y
);
697 void wxGTKWindowImplDC::DoDrawLines( int n
, wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
)
699 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
701 if (m_pen
.GetStyle() == wxTRANSPARENT
) return;
704 //Check, if scaling is necessary
706 xoffset
!= 0 || yoffset
!= 0 || XLOG2DEV(10) != 10 || YLOG2DEV(10) != 10;
708 // GdkPoint and wxPoint have the same memory layout, so we can cast one to the other
709 GdkPoint
* gpts
= reinterpret_cast<GdkPoint
*>(points
);
712 gpts
= new GdkPoint
[n
];
714 for (int i
= 0; i
< n
; i
++)
718 gpts
[i
].x
= XLOG2DEV(points
[i
].x
+ xoffset
);
719 gpts
[i
].y
= YLOG2DEV(points
[i
].y
+ yoffset
);
721 CalcBoundingBox(points
[i
].x
+ xoffset
, points
[i
].y
+ yoffset
);
725 gdk_draw_lines( m_window
, m_penGC
, gpts
, n
);
731 void wxGTKWindowImplDC::DoDrawPolygon( int n
, wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
, int WXUNUSED(fillStyle
) )
733 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
737 //Check, if scaling is necessary
739 xoffset
!= 0 || yoffset
!= 0 || XLOG2DEV(10) != 10 || YLOG2DEV(10) != 10;
741 // GdkPoint and wxPoint have the same memory layout, so we can cast one to the other
742 GdkPoint
* gdkpoints
= reinterpret_cast<GdkPoint
*>(points
);
745 gdkpoints
= new GdkPoint
[n
];
748 for (i
= 0 ; i
< n
; i
++)
752 gdkpoints
[i
].x
= XLOG2DEV(points
[i
].x
+ xoffset
);
753 gdkpoints
[i
].y
= YLOG2DEV(points
[i
].y
+ yoffset
);
755 CalcBoundingBox(points
[i
].x
+ xoffset
, points
[i
].y
+ yoffset
);
760 if (m_brush
.GetStyle() != wxTRANSPARENT
)
762 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
764 gdk_gc_set_ts_origin( m_textGC
,
765 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
766 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
767 gdk_draw_polygon( m_window
, m_textGC
, TRUE
, gdkpoints
, n
);
768 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
770 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
772 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
773 gdk_draw_polygon( m_window
, m_brushGC
, TRUE
, gdkpoints
, n
);
774 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
776 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
778 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
779 gdk_draw_polygon( m_window
, m_brushGC
, TRUE
, gdkpoints
, n
);
780 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
782 if (m_brush
.GetStyle() == wxSTIPPLE
)
784 gdk_gc_set_ts_origin( m_brushGC
,
785 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
786 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
787 gdk_draw_polygon( m_window
, m_brushGC
, TRUE
, gdkpoints
, n
);
788 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
792 gdk_draw_polygon( m_window
, m_brushGC
, TRUE
, gdkpoints
, n
);
796 if (m_pen
.GetStyle() != wxTRANSPARENT
)
799 for (i = 0 ; i < n ; i++)
801 gdk_draw_line( m_window, m_penGC,
804 gdkpoints[(i+1)%n].x,
805 gdkpoints[(i+1)%n].y);
808 gdk_draw_polygon( m_window
, m_penGC
, FALSE
, gdkpoints
, n
);
817 void wxGTKWindowImplDC::DoDrawRectangle( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
819 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
821 wxCoord xx
= XLOG2DEV(x
);
822 wxCoord yy
= YLOG2DEV(y
);
823 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
824 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
826 // CMB: draw nothing if transformed w or h is 0
827 if (ww
== 0 || hh
== 0) return;
829 // CMB: handle -ve width and/or height
830 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
831 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
835 if (m_brush
.GetStyle() != wxTRANSPARENT
)
837 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
839 gdk_gc_set_ts_origin( m_textGC
,
840 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
841 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
842 gdk_draw_rectangle( m_window
, m_textGC
, TRUE
, xx
, yy
, ww
, hh
);
843 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
845 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
847 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
848 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
);
849 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
851 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
853 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
854 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
);
855 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
857 if (m_brush
.GetStyle() == wxSTIPPLE
)
859 gdk_gc_set_ts_origin( m_brushGC
,
860 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
861 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
862 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
);
863 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
867 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
);
871 if (m_pen
.GetStyle() != wxTRANSPARENT
)
874 if ((m_pen
.GetWidth() == 2) && (m_pen
.GetCap() == wxCAP_ROUND
) &&
875 (m_pen
.GetJoin() == wxJOIN_ROUND
) && (m_pen
.GetStyle() == wxSOLID
))
877 // Use 2 1-line rects instead
878 gdk_gc_set_line_attributes( m_penGC
, 1, GDK_LINE_SOLID
, GDK_CAP_ROUND
, GDK_JOIN_ROUND
);
883 gdk_draw_rectangle( m_window
, m_penGC
, FALSE
, xx
+1, yy
, ww
-2, hh
-2 );
884 gdk_draw_rectangle( m_window
, m_penGC
, FALSE
, xx
, yy
-1, ww
, hh
);
888 gdk_draw_rectangle( m_window
, m_penGC
, FALSE
, xx
, yy
, ww
-2, hh
-2 );
889 gdk_draw_rectangle( m_window
, m_penGC
, FALSE
, xx
-1, yy
-1, ww
, hh
);
893 gdk_gc_set_line_attributes( m_penGC
, 2, GDK_LINE_SOLID
, GDK_CAP_ROUND
, GDK_JOIN_ROUND
);
898 // Just use X11 for other cases
899 gdk_draw_rectangle( m_window
, m_penGC
, FALSE
, xx
, yy
, ww
-1, hh
-1 );
904 CalcBoundingBox( x
, y
);
905 CalcBoundingBox( x
+ width
, y
+ height
);
908 void wxGTKWindowImplDC::DoDrawRoundedRectangle( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double radius
)
910 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
912 if (radius
< 0.0) radius
= - radius
* ((width
< height
) ? width
: height
);
914 wxCoord xx
= XLOG2DEV(x
);
915 wxCoord yy
= YLOG2DEV(y
);
916 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
917 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
918 wxCoord rr
= XLOG2DEVREL((wxCoord
)radius
);
920 // CMB: handle -ve width and/or height
921 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
922 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
924 // CMB: if radius is zero use DrawRectangle() instead to avoid
925 // X drawing errors with small radii
928 DoDrawRectangle( x
, y
, width
, height
);
932 // CMB: draw nothing if transformed w or h is 0
933 if (ww
== 0 || hh
== 0) return;
935 // CMB: adjust size if outline is drawn otherwise the result is
936 // 1 pixel too wide and high
937 if (m_pen
.GetStyle() != wxTRANSPARENT
)
945 // CMB: ensure dd is not larger than rectangle otherwise we
946 // get an hour glass shape
948 if (dd
> ww
) dd
= ww
;
949 if (dd
> hh
) dd
= hh
;
952 if (m_brush
.GetStyle() != wxTRANSPARENT
)
954 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
956 gdk_gc_set_ts_origin( m_textGC
,
957 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
958 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
959 gdk_draw_rectangle( m_window
, m_textGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
960 gdk_draw_rectangle( m_window
, m_textGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
961 gdk_draw_arc( m_window
, m_textGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
962 gdk_draw_arc( m_window
, m_textGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
963 gdk_draw_arc( m_window
, m_textGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
964 gdk_draw_arc( m_window
, m_textGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
965 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
967 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
969 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
970 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
971 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
972 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
973 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
974 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
975 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
976 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
978 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
980 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
981 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
982 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
983 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
984 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
985 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
986 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
987 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
989 if (m_brush
.GetStyle() == wxSTIPPLE
)
991 gdk_gc_set_ts_origin( m_brushGC
,
992 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
993 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
994 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
995 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
996 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
997 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
998 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
999 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
1000 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
1004 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
1005 gdk_draw_rectangle( m_window
, m_brushGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
1006 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
1007 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
1008 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
1009 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
1013 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1015 gdk_draw_line( m_window
, m_penGC
, xx
+rr
+1, yy
, xx
+ww
-rr
, yy
);
1016 gdk_draw_line( m_window
, m_penGC
, xx
+rr
+1, yy
+hh
, xx
+ww
-rr
, yy
+hh
);
1017 gdk_draw_line( m_window
, m_penGC
, xx
, yy
+rr
+1, xx
, yy
+hh
-rr
);
1018 gdk_draw_line( m_window
, m_penGC
, xx
+ww
, yy
+rr
+1, xx
+ww
, yy
+hh
-rr
);
1019 gdk_draw_arc( m_window
, m_penGC
, FALSE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
1020 gdk_draw_arc( m_window
, m_penGC
, FALSE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
1021 gdk_draw_arc( m_window
, m_penGC
, FALSE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
1022 gdk_draw_arc( m_window
, m_penGC
, FALSE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
1026 // this ignores the radius
1027 CalcBoundingBox( x
, y
);
1028 CalcBoundingBox( x
+ width
, y
+ height
);
1031 void wxGTKWindowImplDC::DoDrawEllipse( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1033 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1035 wxCoord xx
= XLOG2DEV(x
);
1036 wxCoord yy
= YLOG2DEV(y
);
1037 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1038 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1040 // CMB: handle -ve width and/or height
1041 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
1042 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
1046 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1048 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
1050 gdk_gc_set_ts_origin( m_textGC
,
1051 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
1052 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
1053 gdk_draw_arc( m_window
, m_textGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1054 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
1056 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
1058 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
1059 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1060 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
1062 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
1064 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
1065 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1066 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
1068 if (m_brush
.GetStyle() == wxSTIPPLE
)
1070 gdk_gc_set_ts_origin( m_brushGC
,
1071 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
1072 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
1073 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1074 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
1078 gdk_draw_arc( m_window
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1082 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1083 gdk_draw_arc( m_window
, m_penGC
, FALSE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1086 CalcBoundingBox( x
, y
);
1087 CalcBoundingBox( x
+ width
, y
+ height
);
1090 void wxGTKWindowImplDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
1092 // VZ: egcs 1.0.3 refuses to compile this without cast, no idea why
1093 DoDrawBitmap( (const wxBitmap
&)icon
, x
, y
, true );
1096 void wxGTKWindowImplDC::DoDrawBitmap( const wxBitmap
&bitmap
,
1097 wxCoord x
, wxCoord y
,
1100 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1102 wxCHECK_RET( bitmap
.IsOk(), wxT("invalid bitmap") );
1104 bool is_mono
= bitmap
.GetDepth() == 1;
1106 // scale/translate size and position
1107 int xx
= XLOG2DEV(x
);
1108 int yy
= YLOG2DEV(y
);
1110 int w
= bitmap
.GetWidth();
1111 int h
= bitmap
.GetHeight();
1113 if (m_owningWindow
&& m_owningWindow
->GetLayoutDirection() == wxLayout_RightToLeft
)
1116 CalcBoundingBox( x
, y
);
1117 CalcBoundingBox( x
+ w
, y
+ h
);
1119 if (!m_window
) return;
1121 int ww
= XLOG2DEVREL(w
);
1122 int hh
= YLOG2DEVREL(h
);
1124 // compare to current clipping region
1125 if (!m_currentClippingRegion
.IsNull())
1127 wxRegion
tmp( xx
,yy
,ww
,hh
);
1128 tmp
.Intersect( m_currentClippingRegion
);
1133 // scale bitmap if required
1134 wxBitmap use_bitmap
= bitmap
;
1135 if ((w
!= ww
) || (h
!= hh
))
1136 use_bitmap
= use_bitmap
.Rescale( 0, 0, ww
, hh
, ww
, hh
);
1138 // apply mask if any
1139 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
1140 if (useMask
&& use_bitmap
.GetMask())
1141 mask
= use_bitmap
.GetMask()->GetBitmap();
1143 GdkGC
* use_gc
= is_mono
? m_textGC
: m_penGC
;
1145 GdkBitmap
*new_mask
= (GdkBitmap
*) NULL
;
1149 if (!m_currentClippingRegion
.IsNull())
1152 new_mask
= gdk_pixmap_new( wxGetRootWindow()->window
, ww
, hh
, 1 );
1153 GdkGC
*gc
= gdk_gc_new( new_mask
);
1155 gdk_gc_set_foreground( gc
, &col
);
1156 gdk_draw_rectangle( new_mask
, gc
, TRUE
, 0, 0, ww
, hh
);
1158 gdk_gc_set_background( gc
, &col
);
1160 gdk_gc_set_foreground( gc
, &col
);
1161 gdk_gc_set_clip_region( gc
, m_currentClippingRegion
.GetRegion() );
1162 gdk_gc_set_clip_origin( gc
, -xx
, -yy
);
1163 gdk_gc_set_fill( gc
, GDK_OPAQUE_STIPPLED
);
1164 gdk_gc_set_stipple( gc
, mask
);
1165 gdk_draw_rectangle( new_mask
, gc
, TRUE
, 0, 0, ww
, hh
);
1167 g_object_unref (gc
);
1170 gdk_gc_set_clip_mask(use_gc
, mask
);
1171 gdk_gc_set_clip_origin(use_gc
, xx
, yy
);
1174 // Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For
1175 // drawing a mono-bitmap (XBitmap) we use the current text GC
1178 GdkPixmap
*bitmap2
= gdk_pixmap_new( wxGetRootWindow()->window
, ww
, hh
, -1 );
1179 GdkGC
*gc
= gdk_gc_new( bitmap2
);
1180 gdk_gc_set_foreground( gc
, m_textForegroundColour
.GetColor() );
1181 gdk_gc_set_background( gc
, m_textBackgroundColour
.GetColor() );
1182 gdk_wx_draw_bitmap(bitmap2
, gc
, use_bitmap
.GetPixmap(), 0, 0);
1184 gdk_draw_drawable(m_window
, use_gc
, bitmap2
, 0, 0, xx
, yy
, -1, -1);
1186 g_object_unref (bitmap2
);
1187 g_object_unref (gc
);
1191 if (use_bitmap
.HasPixbuf())
1193 gdk_draw_pixbuf(m_window
, use_gc
,
1194 use_bitmap
.GetPixbuf(),
1195 0, 0, xx
, yy
, -1, -1,
1196 GDK_RGB_DITHER_NORMAL
, xx
, yy
);
1200 gdk_draw_drawable(m_window
, use_gc
,
1201 use_bitmap
.GetPixmap(),
1202 0, 0, xx
, yy
, -1, -1);
1206 // remove mask again if any
1209 gdk_gc_set_clip_mask(use_gc
, NULL
);
1210 gdk_gc_set_clip_origin(use_gc
, 0, 0);
1211 if (!m_currentClippingRegion
.IsNull())
1212 gdk_gc_set_clip_region(use_gc
, m_currentClippingRegion
.GetRegion());
1213 if (new_mask
!= NULL
)
1214 g_object_unref(new_mask
);
1218 bool wxGTKWindowImplDC::DoBlit( wxCoord xdest
, wxCoord ydest
,
1219 wxCoord width
, wxCoord height
,
1221 wxCoord xsrc
, wxCoord ysrc
,
1224 wxCoord xsrcMask
, wxCoord ysrcMask
)
1226 wxCHECK_MSG( IsOk(), false, wxT("invalid window dc") );
1228 wxCHECK_MSG( source
, false, wxT("invalid source dc") );
1230 if (!m_window
) return false;
1232 // transform the source DC coords to the device ones
1233 xsrc
= source
->LogicalToDeviceX(xsrc
);
1234 ysrc
= source
->LogicalToDeviceY(ysrc
);
1237 wxMemoryDC
*memDC
= wxDynamicCast(source
, wxMemoryDC
);
1240 selected
= memDC
->GetSelectedBitmap();
1241 if ( !selected
.IsOk() )
1245 bool use_bitmap_method
= false;
1246 bool is_mono
= false;
1248 if (xsrcMask
== -1 && ysrcMask
== -1)
1254 if (selected
.IsOk())
1256 is_mono
= (selected
.GetDepth() == 1);
1258 // we use the "XCopyArea" way to copy a memory dc into
1259 // a different window if the memory dc BOTH
1260 // a) doesn't have any mask or its mask isn't used
1264 if (useMask
&& (selected
.GetMask()))
1266 // we HAVE TO use the direct way for memory dcs
1267 // that have mask since the XCopyArea doesn't know
1269 use_bitmap_method
= true;
1273 // we HAVE TO use the direct way for memory dcs
1274 // that are bitmaps because XCopyArea doesn't cope
1275 // with different bit depths
1276 use_bitmap_method
= true;
1278 else if ((xsrc
== 0) && (ysrc
== 0) &&
1279 (width
== selected
.GetWidth()) &&
1280 (height
== selected
.GetHeight()))
1282 // we SHOULD use the direct way if all of the bitmap
1283 // in the memory dc is copied in which case XCopyArea
1284 // wouldn't be able able to boost performace by reducing
1285 // the area to be scaled
1286 use_bitmap_method
= true;
1290 CalcBoundingBox( xdest
, ydest
);
1291 CalcBoundingBox( xdest
+ width
, ydest
+ height
);
1293 // scale/translate size and position
1294 wxCoord xx
= XLOG2DEV(xdest
);
1295 wxCoord yy
= YLOG2DEV(ydest
);
1297 wxCoord ww
= XLOG2DEVREL(width
);
1298 wxCoord hh
= YLOG2DEVREL(height
);
1300 // compare to current clipping region
1301 if (!m_currentClippingRegion
.IsNull())
1303 wxRegion
tmp( xx
,yy
,ww
,hh
);
1304 tmp
.Intersect( m_currentClippingRegion
);
1309 int old_logical_func
= m_logicalFunction
;
1310 SetLogicalFunction( logical_func
);
1312 if (use_bitmap_method
)
1314 // scale/translate bitmap size
1315 wxCoord bm_width
= selected
.GetWidth();
1316 wxCoord bm_height
= selected
.GetHeight();
1318 // Get clip coords for the bitmap. If we don't
1319 // use wxBitmap::Rescale(), which can clip the
1320 // bitmap, these are the same as the original
1327 // interpret userscale of src too
1329 memDC
->GetUserScale(&xsc
,&ysc
);
1330 bm_width
= (int) (bm_width
/ xsc
);
1331 bm_height
= (int) (bm_height
/ ysc
);
1333 wxCoord bm_ww
= XLOG2DEVREL( bm_width
);
1334 wxCoord bm_hh
= YLOG2DEVREL( bm_height
);
1336 // Scale bitmap if required
1337 wxBitmap use_bitmap
= selected
;
1338 if ((selected
.GetWidth()!= bm_ww
) || ( selected
.GetHeight()!= bm_hh
))
1340 // This indicates that the blitting code below will get
1341 // a clipped bitmap and therefore needs to move the origin
1343 wxRegion
tmp( xx
,yy
,ww
,hh
);
1344 if (!m_currentClippingRegion
.IsNull())
1345 tmp
.Intersect( m_currentClippingRegion
);
1346 tmp
.GetBox(cx
,cy
,cw
,ch
);
1348 // Scale and clipped bitmap
1349 use_bitmap
= selected
.Rescale(cx
-xx
,cy
-yy
,cw
,ch
,bm_ww
,bm_hh
);
1352 // apply mask if any
1353 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
1354 if (useMask
&& use_bitmap
.GetMask())
1355 mask
= use_bitmap
.GetMask()->GetBitmap();
1357 GdkGC
* use_gc
= is_mono
? m_textGC
: m_penGC
;
1359 GdkBitmap
*new_mask
= (GdkBitmap
*) NULL
;
1363 if (!m_currentClippingRegion
.IsNull())
1366 new_mask
= gdk_pixmap_new( wxGetRootWindow()->window
, bm_ww
, bm_hh
, 1 );
1367 GdkGC
*gc
= gdk_gc_new( new_mask
);
1369 gdk_gc_set_foreground( gc
, &col
);
1370 gdk_gc_set_ts_origin( gc
, -xsrcMask
, -ysrcMask
);
1371 gdk_draw_rectangle( new_mask
, gc
, TRUE
, 0, 0, bm_ww
, bm_hh
);
1373 gdk_gc_set_background( gc
, &col
);
1375 gdk_gc_set_foreground( gc
, &col
);
1376 gdk_gc_set_clip_region( gc
, m_currentClippingRegion
.GetRegion() );
1377 // was: gdk_gc_set_clip_origin( gc, -xx, -yy );
1378 gdk_gc_set_clip_origin( gc
, -cx
, -cy
);
1379 gdk_gc_set_fill( gc
, GDK_OPAQUE_STIPPLED
);
1380 gdk_gc_set_stipple( gc
, mask
);
1381 gdk_draw_rectangle( new_mask
, gc
, TRUE
, 0, 0, bm_ww
, bm_hh
);
1383 g_object_unref (gc
);
1386 gdk_gc_set_clip_mask(use_gc
, mask
);
1387 if (new_mask
!= NULL
)
1388 gdk_gc_set_clip_origin(use_gc
, cx
, cy
);
1390 gdk_gc_set_clip_origin(use_gc
, cx
- xsrcMask
, cy
- ysrcMask
);
1393 // Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For
1394 // drawing a mono-bitmap (XBitmap) we use the current text GC
1398 GdkPixmap
*bitmap
= gdk_pixmap_new( wxGetRootWindow()->window
, bm_ww
, bm_hh
, -1 );
1399 GdkGC
*gc
= gdk_gc_new( bitmap
);
1400 gdk_gc_set_foreground( gc
, m_textForegroundColour
.GetColor() );
1401 gdk_gc_set_background( gc
, m_textBackgroundColour
.GetColor() );
1402 gdk_wx_draw_bitmap(bitmap
, gc
, use_bitmap
.GetPixmap(), 0, 0);
1404 gdk_draw_drawable(m_window
, use_gc
, bitmap
, xsrc
, ysrc
, cx
, cy
, cw
, ch
);
1406 g_object_unref (bitmap
);
1407 g_object_unref (gc
);
1411 // was: gdk_draw_drawable( m_window, m_penGC, use_bitmap.GetPixmap(), xsrc, ysrc, xx, yy, ww, hh );
1412 gdk_draw_drawable(m_window
, use_gc
, use_bitmap
.GetPixmap(), xsrc
, ysrc
, cx
, cy
, cw
, ch
);
1415 // remove mask again if any
1418 gdk_gc_set_clip_mask(use_gc
, NULL
);
1419 gdk_gc_set_clip_origin(use_gc
, 0, 0);
1420 if (!m_currentClippingRegion
.IsNull())
1421 gdk_gc_set_clip_region(use_gc
, m_currentClippingRegion
.GetRegion());
1425 g_object_unref (new_mask
);
1427 else // use_bitmap_method
1429 if (selected
.IsOk() && ((width
!= ww
) || (height
!= hh
)))
1432 wxRegion
tmp( xx
,yy
,ww
,hh
);
1433 tmp
.Intersect( m_currentClippingRegion
);
1434 wxCoord cx
,cy
,cw
,ch
;
1435 tmp
.GetBox(cx
,cy
,cw
,ch
);
1438 wxBitmap bitmap
= selected
.Rescale( cx
-xx
, cy
-yy
, cw
, ch
, ww
, hh
);
1440 // draw scaled bitmap
1441 // was: gdk_draw_drawable( m_window, m_penGC, bitmap.GetPixmap(), 0, 0, xx, yy, -1, -1 );
1442 gdk_draw_drawable( m_window
, m_penGC
, bitmap
.GetPixmap(), 0, 0, cx
, cy
, -1, -1 );
1446 // No scaling and not a memory dc with a mask either
1448 GdkWindow
* window
= NULL
;
1449 wxImplDC
*impl
= source
->GetImpl();
1450 wxGTKWindowImplDC
*gtk_impl
= wxDynamicCast(impl
, wxGTKWindowImplDC
);
1452 window
= gtk_impl
->GetGDKWindow();
1454 GdkWindow
* window
= source
->GetGDKWindow();
1459 // copy including child window contents
1460 gdk_gc_set_subwindow( m_penGC
, GDK_INCLUDE_INFERIORS
);
1461 gdk_draw_drawable( m_window
, m_penGC
,
1465 gdk_gc_set_subwindow( m_penGC
, GDK_CLIP_BY_CHILDREN
);
1469 SetLogicalFunction( old_logical_func
);
1474 void wxGTKWindowImplDC::DoDrawText( const wxString
&text
, wxCoord x
, wxCoord y
)
1476 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1478 if (!m_window
) return;
1480 if (text
.empty()) return;
1485 wxCHECK_RET( m_context
, wxT("no Pango context") );
1486 wxCHECK_RET( m_layout
, wxT("no Pango layout") );
1487 wxCHECK_RET( m_fontdesc
, wxT("no Pango font description") );
1489 gdk_pango_context_set_colormap( m_context
, m_cmap
);
1491 bool underlined
= m_font
.IsOk() && m_font
.GetUnderlined();
1493 const wxCharBuffer data
= wxGTK_CONV( text
);
1496 size_t datalen
= strlen(data
);
1498 // in Pango >= 1.16 the "underline of leading/trailing spaces" bug
1499 // has been fixed and thus the hack implemented below should never be used
1500 static bool pangoOk
= !wx_pango_version_check(1, 16, 0);
1502 bool needshack
= underlined
&& !pangoOk
;
1503 char *hackstring
= NULL
;
1507 // a PangoLayout which has leading/trailing spaces with underlined font
1508 // is not correctly drawn by this pango version: Pango won't underline the spaces.
1509 // This can be a problem; e.g. wxHTML rendering of underlined text relies on
1510 // this behaviour. To workaround this problem, we use a special hack here
1511 // suggested by pango maintainer Behdad Esfahbod: we prepend and append two
1512 // empty space characters and give them a dummy colour attribute.
1513 // This will force Pango to underline the leading/trailing spaces, too.
1515 // need to realloc the string to prepend & append our special characters
1516 hackstring
= (char*)malloc((datalen
+7)*sizeof(char));
1518 // copy the leading U+200C ZERO WIDTH NON-JOINER encoded in UTF8 format
1519 strcpy(hackstring
, "\342\200\214");
1521 // copy the user string
1522 memcpy(&hackstring
[3], data
, datalen
);
1524 // copy the trailing U+200C ZERO WIDTH NON-JOINER encoded in UTF8 format
1525 strcpy(&hackstring
[datalen
+3], "\342\200\214");
1527 // the special characters that we added require 6 additional bytes:
1530 pango_layout_set_text(m_layout
, hackstring
, datalen
);
1534 pango_layout_set_text(m_layout
, data
, datalen
);
1539 PangoAttrList
*attrs
= pango_attr_list_new();
1540 PangoAttribute
*a
= pango_attr_underline_new(PANGO_UNDERLINE_SINGLE
);
1542 a
->end_index
= datalen
;
1543 pango_attr_list_insert(attrs
, a
);
1547 // dummy colour for the leading space
1548 a
= pango_attr_foreground_new (0x0057, 0x52A9, 0xD614);
1551 pango_attr_list_insert(attrs
, a
);
1553 // dummy colour for the trailing space
1554 a
= pango_attr_foreground_new (0x0057, 0x52A9, 0xD614);
1555 a
->start_index
= datalen
- 1;
1556 a
->end_index
= datalen
;
1557 pango_attr_list_insert(attrs
, a
);
1560 pango_layout_set_attributes(m_layout
, attrs
);
1561 pango_attr_list_unref(attrs
);
1566 if (fabs(m_scaleY
- 1.0) > 0.00001)
1568 // If there is a user or actually any scale applied to
1569 // the device context, scale the font.
1571 // scale font description
1572 gint oldSize
= pango_font_description_get_size( m_fontdesc
);
1573 double size
= oldSize
;
1574 size
= size
* m_scaleY
;
1575 pango_font_description_set_size( m_fontdesc
, (gint
)size
);
1577 // actually apply scaled font
1578 pango_layout_set_font_description( m_layout
, m_fontdesc
);
1580 pango_layout_get_pixel_size( m_layout
, &w
, &h
);
1581 if ( m_backgroundMode
== wxSOLID
)
1583 gdk_gc_set_foreground(m_textGC
, m_textBackgroundColour
.GetColor());
1584 gdk_draw_rectangle(m_window
, m_textGC
, TRUE
, x
, y
, w
, h
);
1585 gdk_gc_set_foreground(m_textGC
, m_textForegroundColour
.GetColor());
1589 if (m_owningWindow
&& m_owningWindow
->GetLayoutDirection() == wxLayout_RightToLeft
)
1590 gdk_draw_layout( m_window
, m_textGC
, x
-w
, y
, m_layout
);
1592 gdk_draw_layout( m_window
, m_textGC
, x
, y
, m_layout
);
1594 // reset unscaled size
1595 pango_font_description_set_size( m_fontdesc
, oldSize
);
1597 // actually apply unscaled font
1598 pango_layout_set_font_description( m_layout
, m_fontdesc
);
1602 pango_layout_get_pixel_size( m_layout
, &w
, &h
);
1603 if ( m_backgroundMode
== wxSOLID
)
1605 gdk_gc_set_foreground(m_textGC
, m_textBackgroundColour
.GetColor());
1606 gdk_draw_rectangle(m_window
, m_textGC
, TRUE
, x
, y
, w
, h
);
1607 gdk_gc_set_foreground(m_textGC
, m_textForegroundColour
.GetColor());
1611 if (m_owningWindow
&& m_owningWindow
->GetLayoutDirection() == wxLayout_RightToLeft
)
1612 gdk_draw_layout( m_window
, m_textGC
, x
-w
, y
, m_layout
);
1614 gdk_draw_layout( m_window
, m_textGC
, x
, y
, m_layout
);
1619 // undo underline attributes setting:
1620 pango_layout_set_attributes(m_layout
, NULL
);
1626 width
= wxCoord(width
/ m_scaleX
);
1627 height
= wxCoord(height
/ m_scaleY
);
1628 CalcBoundingBox (x
+ width
, y
+ height
);
1629 CalcBoundingBox (x
, y
);
1636 // TODO: There is an example of rotating text with GTK2 that would probably be
1637 // a better approach here:
1638 // http://www.daa.com.au/pipermail/pygtk/2003-April/005052.html
1640 void wxGTKWindowImplDC::DoDrawRotatedText( const wxString
&text
, wxCoord x
, wxCoord y
, double angle
)
1643 if (!m_window
|| text
.empty())
1646 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1648 if ( wxIsNullDouble(angle
) )
1650 DoDrawText(text
, x
, y
);
1657 // TODO: implement later without GdkFont for GTK 2.0
1658 DoGetTextExtent(text
, &w
, &h
, NULL
,NULL
, &m_font
);
1660 // draw the string normally
1663 dc
.SelectObject(src
);
1664 dc
.SetFont(GetFont());
1665 dc
.SetBackground(*wxBLACK_BRUSH
);
1666 dc
.SetBrush(*wxBLACK_BRUSH
);
1668 dc
.SetTextForeground( *wxWHITE
);
1669 dc
.DrawText(text
, 0, 0);
1670 dc
.SelectObject(wxNullBitmap
);
1672 // Calculate the size of the rotated bounding box.
1673 double rad
= DegToRad(angle
);
1674 double dx
= cos(rad
),
1677 // the rectngle vertices are counted clockwise with the first one being at
1678 // (0, 0) (or, rather, at (x, y))
1680 y2
= -w
*dy
; // y axis points to the bottom, hence minus
1683 double x3
= x4
+ x2
,
1687 wxCoord maxX
= (wxCoord
)(dmax(x2
, dmax(x3
, x4
)) + 0.5),
1688 maxY
= (wxCoord
)(dmax(y2
, dmax(y3
, y4
)) + 0.5),
1689 minX
= (wxCoord
)(dmin(x2
, dmin(x3
, x4
)) - 0.5),
1690 minY
= (wxCoord
)(dmin(y2
, dmin(y3
, y4
)) - 0.5);
1693 wxImage image
= src
.ConvertToImage();
1695 image
.ConvertColourToAlpha( m_textForegroundColour
.Red(),
1696 m_textForegroundColour
.Green(),
1697 m_textForegroundColour
.Blue() );
1698 image
= image
.Rotate( rad
, wxPoint(0,0) );
1700 int i_angle
= (int) angle
;
1701 i_angle
= i_angle
% 360;
1705 if ((i_angle
>= 90.0) && (i_angle
< 270.0))
1706 xoffset
= image
.GetWidth();
1708 if ((i_angle
>= 0.0) && (i_angle
< 180.0))
1709 yoffset
= image
.GetHeight();
1711 if ((i_angle
>= 0) && (i_angle
< 90))
1712 yoffset
-= (int)( cos(rad
)*h
);
1713 if ((i_angle
>= 90) && (i_angle
< 180))
1714 xoffset
-= (int)( sin(rad
)*h
);
1715 if ((i_angle
>= 180) && (i_angle
< 270))
1716 yoffset
-= (int)( cos(rad
)*h
);
1717 if ((i_angle
>= 270) && (i_angle
< 360))
1718 xoffset
-= (int)( sin(rad
)*h
);
1720 int i_x
= x
- xoffset
;
1721 int i_y
= y
- yoffset
;
1724 DoDrawBitmap( src
, i_x
, i_y
, true );
1727 // it would be better to draw with non underlined font and draw the line
1728 // manually here (it would be more straight...)
1730 if ( m_font
.GetUnderlined() )
1732 gdk_draw_line( m_window
, m_textGC
,
1733 XLOG2DEV(x
+ x4
), YLOG2DEV(y
+ y4
+ font
->descent
),
1734 XLOG2DEV(x
+ x3
), YLOG2DEV(y
+ y3
+ font
->descent
));
1738 // update the bounding box
1739 CalcBoundingBox(x
+ minX
, y
+ minY
);
1740 CalcBoundingBox(x
+ maxX
, y
+ maxY
);
1741 #endif // wxUSE_IMAGE
1744 void wxGTKWindowImplDC::DoGetTextExtent(const wxString
&string
,
1745 wxCoord
*width
, wxCoord
*height
,
1746 wxCoord
*descent
, wxCoord
*externalLeading
,
1747 const wxFont
*theFont
) const
1755 if ( externalLeading
)
1756 *externalLeading
= 0;
1761 // ensure that theFont is always non-NULL
1762 if ( !theFont
|| !theFont
->IsOk() )
1763 theFont
= wx_const_cast(wxFont
*, &m_font
);
1765 // and use it if it's valid
1766 if ( theFont
->IsOk() )
1768 pango_layout_set_font_description
1771 theFont
->GetNativeFontInfo()->description
1775 // Set layout's text
1776 const wxCharBuffer dataUTF8
= wxGTK_CONV_FONT(string
, *theFont
);
1779 // hardly ideal, but what else can we do if conversion failed?
1783 pango_layout_set_text( m_layout
, dataUTF8
, strlen(dataUTF8
) );
1788 pango_layout_get_pixel_size( m_layout
, width
, &h
);
1789 PangoLayoutIter
*iter
= pango_layout_get_iter(m_layout
);
1790 int baseline
= pango_layout_iter_get_baseline(iter
);
1791 pango_layout_iter_free(iter
);
1792 *descent
= h
- PANGO_PIXELS(baseline
);
1795 *height
= (wxCoord
) h
;
1799 pango_layout_get_pixel_size( m_layout
, width
, height
);
1802 // Reset old font description
1803 if (theFont
->IsOk())
1804 pango_layout_set_font_description( m_layout
, m_fontdesc
);
1808 bool wxGTKWindowImplDC::DoGetPartialTextExtents(const wxString
& text
,
1809 wxArrayInt
& widths
) const
1811 const size_t len
= text
.length();
1818 // Set layout's text
1819 const wxCharBuffer dataUTF8
= wxGTK_CONV_FONT(text
, m_font
);
1822 // hardly ideal, but what else can we do if conversion failed?
1823 wxLogLastError(wxT("DoGetPartialTextExtents"));
1827 pango_layout_set_text( m_layout
, dataUTF8
, strlen(dataUTF8
) );
1829 // Calculate the position of each character based on the widths of
1830 // the previous characters
1832 // Code borrowed from Scintilla's PlatGTK
1833 PangoLayoutIter
*iter
= pango_layout_get_iter(m_layout
);
1835 pango_layout_iter_get_cluster_extents(iter
, NULL
, &pos
);
1837 while (pango_layout_iter_next_cluster(iter
))
1839 pango_layout_iter_get_cluster_extents(iter
, NULL
, &pos
);
1840 int position
= PANGO_PIXELS(pos
.x
);
1841 widths
[i
++] = position
;
1844 widths
[i
++] = PANGO_PIXELS(pos
.x
+ pos
.width
);
1845 pango_layout_iter_free(iter
);
1851 wxCoord
wxGTKWindowImplDC::GetCharWidth() const
1853 pango_layout_set_text( m_layout
, "H", 1 );
1855 pango_layout_get_pixel_size( m_layout
, &w
, NULL
);
1859 wxCoord
wxGTKWindowImplDC::GetCharHeight() const
1861 PangoFontMetrics
*metrics
= pango_context_get_metrics (m_context
, m_fontdesc
, pango_context_get_language(m_context
));
1862 wxCHECK_MSG( metrics
, -1, _T("failed to get pango font metrics") );
1864 wxCoord h
= PANGO_PIXELS (pango_font_metrics_get_descent (metrics
) +
1865 pango_font_metrics_get_ascent (metrics
));
1866 pango_font_metrics_unref (metrics
);
1870 void wxGTKWindowImplDC::Clear()
1872 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1874 if (!m_window
) return;
1877 DoGetSize( &width
, &height
);
1878 gdk_draw_rectangle( m_window
, m_bgGC
, TRUE
, 0, 0, width
, height
);
1881 void wxGTKWindowImplDC::SetFont( const wxFont
&font
)
1888 pango_font_description_free( m_fontdesc
);
1890 m_fontdesc
= pango_font_description_copy( m_font
.GetNativeFontInfo()->description
);
1895 PangoContext
*oldContext
= m_context
;
1897 m_context
= m_owningWindow
->GtkGetPangoDefaultContext();
1899 // If we switch back/forth between different contexts
1900 // we also have to create a new layout. I think so,
1901 // at least, and it doesn't hurt to do it.
1902 if (oldContext
!= m_context
)
1905 g_object_unref (m_layout
);
1907 m_layout
= pango_layout_new( m_context
);
1911 pango_layout_set_font_description( m_layout
, m_fontdesc
);
1915 void wxGTKWindowImplDC::SetPen( const wxPen
&pen
)
1917 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1919 if (m_pen
== pen
) return;
1923 if (!m_pen
.IsOk()) return;
1925 if (!m_window
) return;
1927 gint width
= m_pen
.GetWidth();
1930 // CMB: if width is non-zero scale it with the dc
1935 // X doesn't allow different width in x and y and so we take
1938 ( fabs((double) XLOG2DEVREL(width
)) +
1939 fabs((double) YLOG2DEVREL(width
)) ) / 2.0;
1943 // width can't be 0 or an internal GTK error occurs inside
1944 // gdk_gc_set_dashes() below
1949 static const wxGTKDash dotted
[] = {1, 1};
1950 static const wxGTKDash short_dashed
[] = {2, 2};
1951 static const wxGTKDash wxCoord_dashed
[] = {2, 4};
1952 static const wxGTKDash dotted_dashed
[] = {3, 3, 1, 3};
1954 // We express dash pattern in pen width unit, so we are
1955 // independent of zoom factor and so on...
1957 const wxGTKDash
*req_dash
;
1959 GdkLineStyle lineStyle
= GDK_LINE_SOLID
;
1960 switch (m_pen
.GetStyle())
1964 lineStyle
= GDK_LINE_ON_OFF_DASH
;
1965 req_nb_dash
= m_pen
.GetDashCount();
1966 req_dash
= (wxGTKDash
*)m_pen
.GetDash();
1971 lineStyle
= GDK_LINE_ON_OFF_DASH
;
1978 lineStyle
= GDK_LINE_ON_OFF_DASH
;
1980 req_dash
= wxCoord_dashed
;
1985 lineStyle
= GDK_LINE_ON_OFF_DASH
;
1987 req_dash
= short_dashed
;
1992 // lineStyle = GDK_LINE_DOUBLE_DASH;
1993 lineStyle
= GDK_LINE_ON_OFF_DASH
;
1995 req_dash
= dotted_dashed
;
2000 case wxSTIPPLE_MASK_OPAQUE
:
2005 lineStyle
= GDK_LINE_SOLID
;
2006 req_dash
= (wxGTKDash
*)NULL
;
2012 if (req_dash
&& req_nb_dash
)
2014 wxGTKDash
*real_req_dash
= new wxGTKDash
[req_nb_dash
];
2017 for (int i
= 0; i
< req_nb_dash
; i
++)
2018 real_req_dash
[i
] = req_dash
[i
] * width
;
2019 gdk_gc_set_dashes( m_penGC
, 0, real_req_dash
, req_nb_dash
);
2020 delete[] real_req_dash
;
2024 // No Memory. We use non-scaled dash pattern...
2025 gdk_gc_set_dashes( m_penGC
, 0, (wxGTKDash
*)req_dash
, req_nb_dash
);
2029 GdkCapStyle capStyle
= GDK_CAP_ROUND
;
2030 switch (m_pen
.GetCap())
2032 case wxCAP_PROJECTING
: { capStyle
= GDK_CAP_PROJECTING
; break; }
2033 case wxCAP_BUTT
: { capStyle
= GDK_CAP_BUTT
; break; }
2040 capStyle
= GDK_CAP_NOT_LAST
;
2044 capStyle
= GDK_CAP_ROUND
;
2050 GdkJoinStyle joinStyle
= GDK_JOIN_ROUND
;
2051 switch (m_pen
.GetJoin())
2053 case wxJOIN_BEVEL
: { joinStyle
= GDK_JOIN_BEVEL
; break; }
2054 case wxJOIN_MITER
: { joinStyle
= GDK_JOIN_MITER
; break; }
2056 default: { joinStyle
= GDK_JOIN_ROUND
; break; }
2059 gdk_gc_set_line_attributes( m_penGC
, width
, lineStyle
, capStyle
, joinStyle
);
2061 m_pen
.GetColour().CalcPixel( m_cmap
);
2062 gdk_gc_set_foreground( m_penGC
, m_pen
.GetColour().GetColor() );
2065 void wxGTKWindowImplDC::SetBrush( const wxBrush
&brush
)
2067 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2069 if (m_brush
== brush
) return;
2073 if (!m_brush
.IsOk()) return;
2075 if (!m_window
) return;
2077 m_brush
.GetColour().CalcPixel( m_cmap
);
2078 gdk_gc_set_foreground( m_brushGC
, m_brush
.GetColour().GetColor() );
2080 gdk_gc_set_fill( m_brushGC
, GDK_SOLID
);
2082 if ((m_brush
.GetStyle() == wxSTIPPLE
) && (m_brush
.GetStipple()->IsOk()))
2084 if (m_brush
.GetStipple()->GetDepth() != 1)
2086 gdk_gc_set_fill( m_brushGC
, GDK_TILED
);
2087 gdk_gc_set_tile( m_brushGC
, m_brush
.GetStipple()->GetPixmap() );
2091 gdk_gc_set_fill( m_brushGC
, GDK_STIPPLED
);
2092 gdk_gc_set_stipple( m_brushGC
, m_brush
.GetStipple()->GetPixmap() );
2096 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
2098 gdk_gc_set_fill( m_textGC
, GDK_OPAQUE_STIPPLED
);
2099 gdk_gc_set_stipple( m_textGC
, m_brush
.GetStipple()->GetMask()->GetBitmap() );
2102 if (m_brush
.IsHatch())
2104 gdk_gc_set_fill( m_brushGC
, GDK_STIPPLED
);
2105 int num
= m_brush
.GetStyle() - wxBDIAGONAL_HATCH
;
2106 gdk_gc_set_stipple( m_brushGC
, hatches
[num
] );
2110 void wxGTKWindowImplDC::SetBackground( const wxBrush
&brush
)
2112 /* CMB 21/7/98: Added SetBackground. Sets background brush
2113 * for Clear() and bg colour for shapes filled with cross-hatch brush */
2115 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2117 if (m_backgroundBrush
== brush
) return;
2119 m_backgroundBrush
= brush
;
2121 if (!m_backgroundBrush
.IsOk()) return;
2123 if (!m_window
) return;
2125 m_backgroundBrush
.GetColour().CalcPixel( m_cmap
);
2126 gdk_gc_set_background( m_brushGC
, m_backgroundBrush
.GetColour().GetColor() );
2127 gdk_gc_set_background( m_penGC
, m_backgroundBrush
.GetColour().GetColor() );
2128 gdk_gc_set_background( m_bgGC
, m_backgroundBrush
.GetColour().GetColor() );
2129 gdk_gc_set_foreground( m_bgGC
, m_backgroundBrush
.GetColour().GetColor() );
2131 gdk_gc_set_fill( m_bgGC
, GDK_SOLID
);
2133 if ((m_backgroundBrush
.GetStyle() == wxSTIPPLE
) && (m_backgroundBrush
.GetStipple()->IsOk()))
2135 if (m_backgroundBrush
.GetStipple()->GetDepth() != 1)
2137 gdk_gc_set_fill( m_bgGC
, GDK_TILED
);
2138 gdk_gc_set_tile( m_bgGC
, m_backgroundBrush
.GetStipple()->GetPixmap() );
2142 gdk_gc_set_fill( m_bgGC
, GDK_STIPPLED
);
2143 gdk_gc_set_stipple( m_bgGC
, m_backgroundBrush
.GetStipple()->GetPixmap() );
2147 if (m_backgroundBrush
.IsHatch())
2149 gdk_gc_set_fill( m_bgGC
, GDK_STIPPLED
);
2150 int num
= m_backgroundBrush
.GetStyle() - wxBDIAGONAL_HATCH
;
2151 gdk_gc_set_stipple( m_bgGC
, hatches
[num
] );
2155 void wxGTKWindowImplDC::SetLogicalFunction( int function
)
2157 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2159 if (m_logicalFunction
== function
)
2162 // VZ: shouldn't this be a CHECK?
2169 case wxXOR
: mode
= GDK_XOR
; break;
2170 case wxINVERT
: mode
= GDK_INVERT
; break;
2171 case wxOR_REVERSE
: mode
= GDK_OR_REVERSE
; break;
2172 case wxAND_REVERSE
: mode
= GDK_AND_REVERSE
; break;
2173 case wxCLEAR
: mode
= GDK_CLEAR
; break;
2174 case wxSET
: mode
= GDK_SET
; break;
2175 case wxOR_INVERT
: mode
= GDK_OR_INVERT
; break;
2176 case wxAND
: mode
= GDK_AND
; break;
2177 case wxOR
: mode
= GDK_OR
; break;
2178 case wxEQUIV
: mode
= GDK_EQUIV
; break;
2179 case wxNAND
: mode
= GDK_NAND
; break;
2180 case wxAND_INVERT
: mode
= GDK_AND_INVERT
; break;
2181 case wxCOPY
: mode
= GDK_COPY
; break;
2182 case wxNO_OP
: mode
= GDK_NOOP
; break;
2183 case wxSRC_INVERT
: mode
= GDK_COPY_INVERT
; break;
2185 // unsupported by GTK
2186 case wxNOR
: mode
= GDK_COPY
; break;
2188 wxFAIL_MSG( wxT("unsupported logical function") );
2192 m_logicalFunction
= function
;
2194 gdk_gc_set_function( m_penGC
, mode
);
2195 gdk_gc_set_function( m_brushGC
, mode
);
2197 // to stay compatible with wxMSW, we don't apply ROPs to the text
2198 // operations (i.e. DrawText/DrawRotatedText).
2199 // True, but mono-bitmaps use the m_textGC and they use ROPs as well.
2200 gdk_gc_set_function( m_textGC
, mode
);
2203 void wxGTKWindowImplDC::SetTextForeground( const wxColour
&col
)
2205 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2207 // don't set m_textForegroundColour to an invalid colour as we'd crash
2208 // later then (we use m_textForegroundColour.GetColor() without checking
2210 if ( !col
.IsOk() || (m_textForegroundColour
== col
) )
2213 m_textForegroundColour
= col
;
2217 m_textForegroundColour
.CalcPixel( m_cmap
);
2218 gdk_gc_set_foreground( m_textGC
, m_textForegroundColour
.GetColor() );
2222 void wxGTKWindowImplDC::SetTextBackground( const wxColour
&col
)
2224 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2227 if ( !col
.IsOk() || (m_textBackgroundColour
== col
) )
2230 m_textBackgroundColour
= col
;
2234 m_textBackgroundColour
.CalcPixel( m_cmap
);
2235 gdk_gc_set_background( m_textGC
, m_textBackgroundColour
.GetColor() );
2239 void wxGTKWindowImplDC::SetBackgroundMode( int mode
)
2241 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2243 m_backgroundMode
= mode
;
2245 if (!m_window
) return;
2247 // CMB 21/7/98: fill style of cross-hatch brushes is affected by
2248 // transparent/solid background mode
2250 if (m_brush
.GetStyle() != wxSOLID
&& m_brush
.GetStyle() != wxTRANSPARENT
)
2252 gdk_gc_set_fill( m_brushGC
,
2253 (m_backgroundMode
== wxTRANSPARENT
) ? GDK_STIPPLED
: GDK_OPAQUE_STIPPLED
);
2257 void wxGTKWindowImplDC::SetPalette( const wxPalette
& WXUNUSED(palette
) )
2259 wxFAIL_MSG( wxT("wxGTKWindowImplDC::SetPalette not implemented") );
2262 void wxGTKWindowImplDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
2264 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2266 if (!m_window
) return;
2269 rect
.x
= XLOG2DEV(x
);
2270 rect
.y
= YLOG2DEV(y
);
2271 rect
.width
= XLOG2DEVREL(width
);
2272 rect
.height
= YLOG2DEVREL(height
);
2274 if (m_owningWindow
&& m_owningWindow
->m_wxwindow
&&
2275 (m_owningWindow
->GetLayoutDirection() == wxLayout_RightToLeft
))
2277 rect
.x
-= rect
.width
;
2280 if (!m_currentClippingRegion
.IsNull())
2281 m_currentClippingRegion
.Intersect( rect
);
2283 m_currentClippingRegion
.Union( rect
);
2285 #if USE_PAINT_REGION
2286 if (!m_paintClippingRegion
.IsNull())
2287 m_currentClippingRegion
.Intersect( m_paintClippingRegion
);
2290 wxCoord xx
, yy
, ww
, hh
;
2291 m_currentClippingRegion
.GetBox( xx
, yy
, ww
, hh
);
2293 wxImplDC::DoSetClippingRegion( xx
, yy
, ww
, hh
);
2295 wxDC::DoSetClippingRegion( xx
, yy
, ww
, hh
);
2298 gdk_gc_set_clip_region( m_penGC
, m_currentClippingRegion
.GetRegion() );
2299 gdk_gc_set_clip_region( m_brushGC
, m_currentClippingRegion
.GetRegion() );
2300 gdk_gc_set_clip_region( m_textGC
, m_currentClippingRegion
.GetRegion() );
2301 gdk_gc_set_clip_region( m_bgGC
, m_currentClippingRegion
.GetRegion() );
2304 void wxGTKWindowImplDC::DoSetClippingRegionAsRegion( const wxRegion
®ion
)
2306 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2310 DestroyClippingRegion();
2314 if (!m_window
) return;
2316 if (!m_currentClippingRegion
.IsNull())
2317 m_currentClippingRegion
.Intersect( region
);
2319 m_currentClippingRegion
.Union( region
);
2321 #if USE_PAINT_REGION
2322 if (!m_paintClippingRegion
.IsNull())
2323 m_currentClippingRegion
.Intersect( m_paintClippingRegion
);
2326 wxCoord xx
, yy
, ww
, hh
;
2327 m_currentClippingRegion
.GetBox( xx
, yy
, ww
, hh
);
2329 wxImplDC::DoSetClippingRegion( xx
, yy
, ww
, hh
);
2331 wxDC::DoSetClippingRegion( xx
, yy
, ww
, hh
);
2334 gdk_gc_set_clip_region( m_penGC
, m_currentClippingRegion
.GetRegion() );
2335 gdk_gc_set_clip_region( m_brushGC
, m_currentClippingRegion
.GetRegion() );
2336 gdk_gc_set_clip_region( m_textGC
, m_currentClippingRegion
.GetRegion() );
2337 gdk_gc_set_clip_region( m_bgGC
, m_currentClippingRegion
.GetRegion() );
2340 void wxGTKWindowImplDC::DestroyClippingRegion()
2342 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2345 wxImplDC::DestroyClippingRegion();
2347 wxDC::DestroyClippingRegion();
2350 m_currentClippingRegion
.Clear();
2352 #if USE_PAINT_REGION
2353 if (!m_paintClippingRegion
.IsEmpty())
2354 m_currentClippingRegion
.Union( m_paintClippingRegion
);
2357 if (!m_window
) return;
2359 if (m_currentClippingRegion
.IsEmpty())
2361 gdk_gc_set_clip_rectangle( m_penGC
, (GdkRectangle
*) NULL
);
2362 gdk_gc_set_clip_rectangle( m_brushGC
, (GdkRectangle
*) NULL
);
2363 gdk_gc_set_clip_rectangle( m_textGC
, (GdkRectangle
*) NULL
);
2364 gdk_gc_set_clip_rectangle( m_bgGC
, (GdkRectangle
*) NULL
);
2368 gdk_gc_set_clip_region( m_penGC
, m_currentClippingRegion
.GetRegion() );
2369 gdk_gc_set_clip_region( m_brushGC
, m_currentClippingRegion
.GetRegion() );
2370 gdk_gc_set_clip_region( m_textGC
, m_currentClippingRegion
.GetRegion() );
2371 gdk_gc_set_clip_region( m_bgGC
, m_currentClippingRegion
.GetRegion() );
2375 void wxGTKWindowImplDC::Destroy()
2377 if (m_penGC
) wxFreePoolGC( m_penGC
);
2378 m_penGC
= (GdkGC
*) NULL
;
2379 if (m_brushGC
) wxFreePoolGC( m_brushGC
);
2380 m_brushGC
= (GdkGC
*) NULL
;
2381 if (m_textGC
) wxFreePoolGC( m_textGC
);
2382 m_textGC
= (GdkGC
*) NULL
;
2383 if (m_bgGC
) wxFreePoolGC( m_bgGC
);
2384 m_bgGC
= (GdkGC
*) NULL
;
2387 void wxGTKWindowImplDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
2389 m_deviceOriginX
= x
;
2390 m_deviceOriginY
= y
;
2392 ComputeScaleAndOrigin();
2395 void wxGTKWindowImplDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
2397 m_signX
= (xLeftRight
? 1 : -1);
2398 m_signY
= (yBottomUp
? -1 : 1);
2400 if (m_owningWindow
&& m_owningWindow
->m_wxwindow
&&
2401 (m_owningWindow
->GetLayoutDirection() == wxLayout_RightToLeft
))
2404 ComputeScaleAndOrigin();
2407 void wxGTKWindowImplDC::ComputeScaleAndOrigin()
2409 const wxRealPoint
origScale(m_scaleX
, m_scaleY
);
2412 wxImplDC::ComputeScaleAndOrigin();
2414 wxDC::ComputeScaleAndOrigin();
2417 // if scale has changed call SetPen to recalulate the line width
2418 if ( wxRealPoint(m_scaleX
, m_scaleY
) != origScale
&& m_pen
.IsOk() )
2420 // this is a bit artificial, but we need to force wxDC to think the pen
2428 // Resolution in pixels per logical inch
2429 wxSize
wxGTKWindowImplDC::GetPPI() const
2431 return wxSize( (int) (m_mm_to_pix_x
* 25.4 + 0.5), (int) (m_mm_to_pix_y
* 25.4 + 0.5));
2434 int wxGTKWindowImplDC::GetDepth() const
2436 return gdk_drawable_get_depth(m_window
);
2440 //-----------------------------------------------------------------------------
2442 //-----------------------------------------------------------------------------
2445 IMPLEMENT_ABSTRACT_CLASS(wxGTKClientImplDC
, wxGTKWindowImplDC
)
2447 IMPLEMENT_ABSTRACT_CLASS(wxClientDC
, wxWindowDC
)
2451 wxGTKClientImplDC::wxGTKClientImplDC( wxDC
*owner
)
2452 : wxGTKWindowImplDC( owner
)
2456 wxGTKClientImplDC::wxGTKClientImplDC( wxDC
*owner
, wxWindow
*win
)
2457 : wxGTKWindowImplDC( owner
, win
)
2459 wxClientDC::wxClientDC()
2463 wxClientDC::wxClientDC( wxWindow
*win
)
2468 wxCHECK_RET( win
, _T("NULL window in wxGTKClientImplDC::wxClientDC") );
2470 #ifdef __WXUNIVERSAL__
2471 wxPoint ptOrigin
= win
->GetClientAreaOrigin();
2472 SetDeviceOrigin(ptOrigin
.x
, ptOrigin
.y
);
2473 wxSize size
= win
->GetClientSize();
2474 SetClippingRegion(wxPoint(0, 0), size
);
2475 #endif // __WXUNIVERSAL__
2478 void wxGTKClientImplDC::DoGetSize(int *width
, int *height
) const
2480 wxCHECK_RET( m_owningWindow
, _T("GetSize() doesn't work without window") );
2482 m_owningWindow
->GetClientSize( width
, height
);
2485 //-----------------------------------------------------------------------------
2487 //-----------------------------------------------------------------------------
2490 IMPLEMENT_ABSTRACT_CLASS(wxGTKPaintImplDC
, wxGTKClientImplDC
)
2492 IMPLEMENT_ABSTRACT_CLASS(wxPaintDC
, wxClientDC
)
2495 // Limit the paint region to the window size. Sometimes
2496 // the paint region is too big, and this risks X11 errors
2497 static void wxLimitRegionToSize(wxRegion
& region
, const wxSize
& sz
)
2499 wxRect originalRect
= region
.GetBox();
2500 wxRect
rect(originalRect
);
2501 if (rect
.width
+ rect
.x
> sz
.x
)
2502 rect
.width
= sz
.x
- rect
.x
;
2503 if (rect
.height
+ rect
.y
> sz
.y
)
2504 rect
.height
= sz
.y
- rect
.y
;
2505 if (rect
!= originalRect
)
2507 region
= wxRegion(rect
);
2508 wxLogTrace(wxT("painting"), wxT("Limiting region from %d, %d, %d, %d to %d, %d, %d, %d\n"),
2509 originalRect
.x
, originalRect
.y
, originalRect
.width
, originalRect
.height
,
2510 rect
.x
, rect
.y
, rect
.width
, rect
.height
);
2515 wxGTKPaintImplDC::wxGTKPaintImplDC( wxDC
*owner
)
2516 : wxGTKClientImplDC( owner
)
2520 wxGTKPaintImplDC::wxGTKPaintImplDC( wxDC
*owner
, wxWindow
*win
)
2521 : wxGTKClientImplDC( owner
, win
)
2523 wxPaintDC::wxPaintDC()
2528 wxPaintDC::wxPaintDC( wxWindow
*win
)
2532 #if USE_PAINT_REGION
2533 if (!win
->m_clipPaintRegion
)
2536 wxSize sz
= win
->GetSize();
2537 m_paintClippingRegion
= win
->m_nativeUpdateRegion
;
2538 wxLimitRegionToSize(m_paintClippingRegion
, sz
);
2540 GdkRegion
*region
= m_paintClippingRegion
.GetRegion();
2543 m_currentClippingRegion
.Union( m_paintClippingRegion
);
2544 wxLimitRegionToSize(m_currentClippingRegion
, sz
);
2546 if (sz
.x
<= 0 || sz
.y
<= 0)
2549 gdk_gc_set_clip_region( m_penGC
, region
);
2550 gdk_gc_set_clip_region( m_brushGC
, region
);
2551 gdk_gc_set_clip_region( m_textGC
, region
);
2552 gdk_gc_set_clip_region( m_bgGC
, region
);
2554 #endif // USE_PAINT_REGION
2557 // ----------------------------------------------------------------------------
2559 // ----------------------------------------------------------------------------
2561 class wxDCModule
: public wxModule
2568 DECLARE_DYNAMIC_CLASS(wxDCModule
)
2571 IMPLEMENT_DYNAMIC_CLASS(wxDCModule
, wxModule
)
2573 bool wxDCModule::OnInit()
2579 void wxDCModule::OnExit()