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/gtk/dcclient.h"
20 #include "wx/window.h"
22 #include "wx/dcmemory.h"
25 #include "wx/module.h"
28 #include "wx/fontutil.h"
30 #include "wx/gtk/private.h"
34 //-----------------------------------------------------------------------------
36 //-----------------------------------------------------------------------------
38 #define XLOG2DEV(x) LogicalToDeviceX(x)
39 #define XLOG2DEVREL(x) LogicalToDeviceXRel(x)
40 #define YLOG2DEV(y) LogicalToDeviceY(y)
41 #define YLOG2DEVREL(y) LogicalToDeviceYRel(y)
43 #define USE_PAINT_REGION 1
45 //-----------------------------------------------------------------------------
47 //-----------------------------------------------------------------------------
57 #define IS_15_PIX_HATCH(s) ((s)==wxCROSSDIAG_HATCH || (s)==wxHORIZONTAL_HATCH || (s)==wxVERTICAL_HATCH)
58 #define IS_16_PIX_HATCH(s) ((s)!=wxCROSSDIAG_HATCH && (s)!=wxHORIZONTAL_HATCH && (s)!=wxVERTICAL_HATCH)
61 static GdkPixmap
*hatches
[num_hatches
];
62 static GdkPixmap
**hatch_bitmap
= (GdkPixmap
**) NULL
;
64 extern GtkWidget
*wxGetRootWindow();
66 //-----------------------------------------------------------------------------
68 //-----------------------------------------------------------------------------
70 static const double RAD2DEG
= 180.0 / M_PI
;
72 // ----------------------------------------------------------------------------
74 // ----------------------------------------------------------------------------
76 static inline double dmax(double a
, double b
) { return a
> b ? a
: b
; }
77 static inline double dmin(double a
, double b
) { return a
< b ? a
: b
; }
79 static inline double DegToRad(double deg
) { return (deg
* M_PI
) / 180.0; }
81 //-----------------------------------------------------------------------------
82 // temporary implementation of the missing GDK function
83 //-----------------------------------------------------------------------------
86 void gdk_wx_draw_bitmap(GdkDrawable
*drawable
,
92 wxCHECK_RET( drawable
, _T("NULL drawable in gdk_wx_draw_bitmap") );
93 wxCHECK_RET( src
, _T("NULL src in gdk_wx_draw_bitmap") );
94 wxCHECK_RET( gc
, _T("NULL gc in gdk_wx_draw_bitmap") );
96 gint src_width
, src_height
;
97 gdk_drawable_get_size(src
, &src_width
, &src_height
);
99 XCopyPlane( GDK_WINDOW_XDISPLAY(drawable
),
101 GDK_WINDOW_XID(drawable
),
104 src_width
, src_height
,
109 //-----------------------------------------------------------------------------
110 // Implement Pool of Graphic contexts. Creating them takes too much time.
111 //-----------------------------------------------------------------------------
137 #define GC_POOL_ALLOC_SIZE 100
139 static int wxGCPoolSize
= 0;
141 static wxGC
*wxGCPool
= NULL
;
143 static void wxInitGCPool()
145 // This really could wait until the first call to
146 // wxGetPoolGC, but we will make the first allocation
147 // now when other initialization is being performed.
149 // Set initial pool size.
150 wxGCPoolSize
= GC_POOL_ALLOC_SIZE
;
152 // Allocate initial pool.
153 wxGCPool
= (wxGC
*)malloc(wxGCPoolSize
* sizeof(wxGC
));
154 if (wxGCPool
== NULL
)
156 // If we cannot malloc, then fail with error
157 // when debug is enabled. If debug is not enabled,
158 // the problem will eventually get caught
160 wxFAIL_MSG( wxT("Cannot allocate GC pool") );
164 // Zero initial pool.
165 memset(wxGCPool
, 0, wxGCPoolSize
* sizeof(wxGC
));
168 static void wxCleanUpGCPool()
170 for (int i
= 0; i
< wxGCPoolSize
; i
++)
172 if (wxGCPool
[i
].m_gc
)
173 g_object_unref (wxGCPool
[i
].m_gc
);
181 static GdkGC
* wxGetPoolGC( GdkWindow
*window
, wxPoolGCType type
)
185 // Look for an available GC.
186 for (int i
= 0; i
< wxGCPoolSize
; i
++)
188 if (!wxGCPool
[i
].m_gc
)
190 wxGCPool
[i
].m_gc
= gdk_gc_new( window
);
191 gdk_gc_set_exposures( wxGCPool
[i
].m_gc
, FALSE
);
192 wxGCPool
[i
].m_type
= type
;
193 wxGCPool
[i
].m_used
= false;
195 if ((!wxGCPool
[i
].m_used
) && (wxGCPool
[i
].m_type
== type
))
197 wxGCPool
[i
].m_used
= true;
198 return wxGCPool
[i
].m_gc
;
202 // We did not find an available GC.
203 // We need to grow the GC pool.
204 pptr
= (wxGC
*)realloc(wxGCPool
,
205 (wxGCPoolSize
+ GC_POOL_ALLOC_SIZE
)*sizeof(wxGC
));
208 // Initialize newly allocated pool.
210 memset(&wxGCPool
[wxGCPoolSize
], 0,
211 GC_POOL_ALLOC_SIZE
*sizeof(wxGC
));
213 // Initialize entry we will return.
214 wxGCPool
[wxGCPoolSize
].m_gc
= gdk_gc_new( window
);
215 gdk_gc_set_exposures( wxGCPool
[wxGCPoolSize
].m_gc
, FALSE
);
216 wxGCPool
[wxGCPoolSize
].m_type
= type
;
217 wxGCPool
[wxGCPoolSize
].m_used
= true;
219 // Set new value of pool size.
220 wxGCPoolSize
+= GC_POOL_ALLOC_SIZE
;
222 // Return newly allocated entry.
223 return wxGCPool
[wxGCPoolSize
-GC_POOL_ALLOC_SIZE
].m_gc
;
226 // The realloc failed. Fall through to error.
227 wxFAIL_MSG( wxT("No GC available") );
229 return (GdkGC
*) NULL
;
232 static void wxFreePoolGC( GdkGC
*gc
)
234 for (int i
= 0; i
< wxGCPoolSize
; i
++)
236 if (wxGCPool
[i
].m_gc
== gc
)
238 wxGCPool
[i
].m_used
= false;
243 wxFAIL_MSG( wxT("Wrong GC") );
246 //-----------------------------------------------------------------------------
248 //-----------------------------------------------------------------------------
250 IMPLEMENT_ABSTRACT_CLASS(wxWindowDCImpl
, wxGTKDCImpl
)
252 wxWindowDCImpl
::wxWindowDCImpl( wxDC
*owner
) :
255 m_gdkwindow
= (GdkWindow
*) NULL
;
256 m_penGC
= (GdkGC
*) NULL
;
257 m_brushGC
= (GdkGC
*) NULL
;
258 m_textGC
= (GdkGC
*) NULL
;
259 m_bgGC
= (GdkGC
*) NULL
;
260 m_cmap
= (GdkColormap
*) NULL
;
261 m_isScreenDC
= false;
262 m_context
= (PangoContext
*)NULL
;
263 m_layout
= (PangoLayout
*)NULL
;
264 m_fontdesc
= (PangoFontDescription
*)NULL
;
267 wxWindowDCImpl
::wxWindowDCImpl( wxDC
*owner
, wxWindow
*window
) :
270 wxASSERT_MSG( window
, wxT("DC needs a window") );
272 m_gdkwindow
= (GdkWindow
*) NULL
;
273 m_penGC
= (GdkGC
*) NULL
;
274 m_brushGC
= (GdkGC
*) NULL
;
275 m_textGC
= (GdkGC
*) NULL
;
276 m_bgGC
= (GdkGC
*) NULL
;
277 m_cmap
= (GdkColormap
*) NULL
;
278 m_isScreenDC
= false;
279 m_font
= window
->GetFont();
281 GtkWidget
*widget
= window
->m_wxwindow
;
283 // Some controls don't have m_wxwindow - like wxStaticBox, but the user
284 // code should still be able to create wxClientDCs for them, so we will
285 // use the parent window here then.
288 window
= window
->GetParent();
289 widget
= window
->m_wxwindow
;
292 wxASSERT_MSG( widget
, wxT("DC needs a widget") );
294 m_context
= window
->GtkGetPangoDefaultContext();
295 m_layout
= pango_layout_new( m_context
);
296 m_fontdesc
= pango_font_description_copy( widget
->style
->font_desc
);
298 m_gdkwindow
= widget
->window
;
300 // Window not realized ?
303 // Don't report problems as per MSW.
309 m_cmap
= gtk_widget_get_colormap( widget ? widget
: window
->m_widget
);
313 /* this must be done after SetUpDC, bacause SetUpDC calls the
314 repective SetBrush, SetPen, SetBackground etc functions
315 to set up the DC. SetBackground call m_owner->SetBackground
316 and this might not be desired as the standard dc background
317 is white whereas a window might assume gray to be the
318 standard (as e.g. wxStatusBar) */
322 if (m_window
&& m_window
->m_wxwindow
&&
323 (m_window
->GetLayoutDirection() == wxLayout_RightToLeft
))
328 // origin in the upper right corner
329 m_deviceOriginX
= m_window
->GetClientSize().x
;
333 wxWindowDCImpl
::~wxWindowDCImpl()
338 g_object_unref (m_layout
);
340 pango_font_description_free( m_fontdesc
);
343 void wxWindowDCImpl
::SetUpDC( bool isMemDC
)
347 wxASSERT_MSG( !m_penGC
, wxT("GCs already created") );
351 if ((isMemDC
) && (GetSelectedBitmap().IsOk()))
353 if (GetSelectedBitmap().GetDepth() == 1)
355 m_penGC
= wxGetPoolGC( m_gdkwindow
, wxPEN_MONO
);
356 m_brushGC
= wxGetPoolGC( m_gdkwindow
, wxBRUSH_MONO
);
357 m_textGC
= wxGetPoolGC( m_gdkwindow
, wxTEXT_MONO
);
358 m_bgGC
= wxGetPoolGC( m_gdkwindow
, wxBG_MONO
);
367 m_penGC
= wxGetPoolGC( m_gdkwindow
, wxPEN_SCREEN
);
368 m_brushGC
= wxGetPoolGC( m_gdkwindow
, wxBRUSH_SCREEN
);
369 m_textGC
= wxGetPoolGC( m_gdkwindow
, wxTEXT_SCREEN
);
370 m_bgGC
= wxGetPoolGC( m_gdkwindow
, wxBG_SCREEN
);
374 m_penGC
= wxGetPoolGC( m_gdkwindow
, wxPEN_COLOUR
);
375 m_brushGC
= wxGetPoolGC( m_gdkwindow
, wxBRUSH_COLOUR
);
376 m_textGC
= wxGetPoolGC( m_gdkwindow
, wxTEXT_COLOUR
);
377 m_bgGC
= wxGetPoolGC( m_gdkwindow
, wxBG_COLOUR
);
381 /* background colour */
382 m_backgroundBrush
= *wxWHITE_BRUSH
;
383 m_backgroundBrush
.GetColour().CalcPixel( m_cmap
);
384 const GdkColor
*bg_col
= m_backgroundBrush
.GetColour().GetColor();
387 m_textForegroundColour
.CalcPixel( m_cmap
);
388 gdk_gc_set_foreground( m_textGC
, m_textForegroundColour
.GetColor() );
390 m_textBackgroundColour
.CalcPixel( m_cmap
);
391 gdk_gc_set_background( m_textGC
, m_textBackgroundColour
.GetColor() );
393 gdk_gc_set_fill( m_textGC
, GDK_SOLID
);
395 gdk_gc_set_colormap( m_textGC
, m_cmap
);
398 m_pen
.GetColour().CalcPixel( m_cmap
);
399 gdk_gc_set_foreground( m_penGC
, m_pen
.GetColour().GetColor() );
400 gdk_gc_set_background( m_penGC
, bg_col
);
402 gdk_gc_set_line_attributes( m_penGC
, 0, GDK_LINE_SOLID
, GDK_CAP_NOT_LAST
, GDK_JOIN_ROUND
);
405 m_brush
.GetColour().CalcPixel( m_cmap
);
406 gdk_gc_set_foreground( m_brushGC
, m_brush
.GetColour().GetColor() );
407 gdk_gc_set_background( m_brushGC
, bg_col
);
409 gdk_gc_set_fill( m_brushGC
, GDK_SOLID
);
412 gdk_gc_set_background( m_bgGC
, bg_col
);
413 gdk_gc_set_foreground( m_bgGC
, bg_col
);
415 gdk_gc_set_fill( m_bgGC
, GDK_SOLID
);
418 gdk_gc_set_function( m_textGC
, GDK_COPY
);
419 gdk_gc_set_function( m_brushGC
, GDK_COPY
);
420 gdk_gc_set_function( m_penGC
, GDK_COPY
);
423 gdk_gc_set_clip_rectangle( m_penGC
, (GdkRectangle
*) NULL
);
424 gdk_gc_set_clip_rectangle( m_brushGC
, (GdkRectangle
*) NULL
);
425 gdk_gc_set_clip_rectangle( m_textGC
, (GdkRectangle
*) NULL
);
426 gdk_gc_set_clip_rectangle( m_bgGC
, (GdkRectangle
*) NULL
);
430 hatch_bitmap
= hatches
;
431 hatch_bitmap
[0] = gdk_bitmap_create_from_data( (GdkWindow
*) NULL
, bdiag_bits
, bdiag_width
, bdiag_height
);
432 hatch_bitmap
[1] = gdk_bitmap_create_from_data( (GdkWindow
*) NULL
, cdiag_bits
, cdiag_width
, cdiag_height
);
433 hatch_bitmap
[2] = gdk_bitmap_create_from_data( (GdkWindow
*) NULL
, fdiag_bits
, fdiag_width
, fdiag_height
);
434 hatch_bitmap
[3] = gdk_bitmap_create_from_data( (GdkWindow
*) NULL
, cross_bits
, cross_width
, cross_height
);
435 hatch_bitmap
[4] = gdk_bitmap_create_from_data( (GdkWindow
*) NULL
, horiz_bits
, horiz_width
, horiz_height
);
436 hatch_bitmap
[5] = gdk_bitmap_create_from_data( (GdkWindow
*) NULL
, verti_bits
, verti_width
, verti_height
);
440 void wxWindowDCImpl
::DoGetSize( int* width
, int* height
) const
442 wxCHECK_RET( m_window
, _T("GetSize() doesn't work without window") );
444 m_window
->GetSize(width
, height
);
447 bool wxWindowDCImpl
::DoFloodFill(wxCoord x
, wxCoord y
,
448 const wxColour
& col
, int style
)
451 extern bool wxDoFloodFill(wxDC
*dc
, wxCoord x
, wxCoord y
,
452 const wxColour
& col
, int style
);
454 return wxDoFloodFill( GetOwner(), x
, y
, col
, style
);
465 bool wxWindowDCImpl
::DoGetPixel( wxCoord x1
, wxCoord y1
, wxColour
*col
) const
468 // Generic (and therefore rather inefficient) method.
469 // Could be improved.
471 wxBitmap
bitmap(1, 1);
472 memdc
.SelectObject(bitmap
);
473 memdc
.Blit(0, 0, 1, 1, GetOwner(), x1
, y1
);
474 memdc
.SelectObject(wxNullBitmap
);
476 wxImage image
= bitmap
.ConvertToImage();
477 col
->Set(image
.GetRed(0, 0), image
.GetGreen(0, 0), image
.GetBlue(0, 0));
479 #else // !wxUSE_IMAGE
485 #endif // wxUSE_IMAGE/!wxUSE_IMAGE
488 void wxWindowDCImpl
::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
490 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
492 if (m_pen
.GetStyle() != wxTRANSPARENT
)
495 gdk_draw_line( m_gdkwindow
, m_penGC
, XLOG2DEV(x1
), YLOG2DEV(y1
), XLOG2DEV(x2
), YLOG2DEV(y2
) );
497 CalcBoundingBox(x1
, y1
);
498 CalcBoundingBox(x2
, y2
);
502 void wxWindowDCImpl
::DoCrossHair( wxCoord x
, wxCoord y
)
504 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
506 if (m_pen
.GetStyle() != wxTRANSPARENT
)
510 GetOwner()->GetSize( &w
, &h
);
511 wxCoord xx
= XLOG2DEV(x
);
512 wxCoord yy
= YLOG2DEV(y
);
515 gdk_draw_line( m_gdkwindow
, m_penGC
, 0, yy
, XLOG2DEVREL(w
), yy
);
516 gdk_draw_line( m_gdkwindow
, m_penGC
, xx
, 0, xx
, YLOG2DEVREL(h
) );
521 void wxWindowDCImpl
::DoDrawArc( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
522 wxCoord xc
, wxCoord yc
)
524 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
526 wxCoord xx1
= XLOG2DEV(x1
);
527 wxCoord yy1
= YLOG2DEV(y1
);
528 wxCoord xx2
= XLOG2DEV(x2
);
529 wxCoord yy2
= YLOG2DEV(y2
);
530 wxCoord xxc
= XLOG2DEV(xc
);
531 wxCoord yyc
= YLOG2DEV(yc
);
532 double dx
= xx1
- xxc
;
533 double dy
= yy1
- yyc
;
534 double radius
= sqrt((double)(dx
*dx
+dy
*dy
));
535 wxCoord r
= (wxCoord
)radius
;
536 double radius1
, radius2
;
538 if (xx1
== xx2
&& yy1
== yy2
)
543 else if ( wxIsNullDouble(radius
) )
550 radius1
= (xx1
- xxc
== 0) ?
551 (yy1
- yyc
< 0) ?
90.0 : -90.0 :
552 -atan2(double(yy1
-yyc
), double(xx1
-xxc
)) * RAD2DEG
;
553 radius2
= (xx2
- xxc
== 0) ?
554 (yy2
- yyc
< 0) ?
90.0 : -90.0 :
555 -atan2(double(yy2
-yyc
), double(xx2
-xxc
)) * RAD2DEG
;
557 wxCoord alpha1
= wxCoord(radius1
* 64.0);
558 wxCoord alpha2
= wxCoord((radius2
- radius1
) * 64.0);
559 while (alpha2
<= 0) alpha2
+= 360*64;
560 while (alpha1
> 360*64) alpha1
-= 360*64;
564 if (m_brush
.GetStyle() != wxTRANSPARENT
)
566 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
568 gdk_gc_set_ts_origin( m_textGC
,
569 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
570 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
571 gdk_draw_arc( m_gdkwindow
, m_textGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
572 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
574 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
576 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
577 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
578 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
580 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
582 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
583 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
584 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
586 if (m_brush
.GetStyle() == wxSTIPPLE
)
588 gdk_gc_set_ts_origin( m_brushGC
,
589 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
590 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
591 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
592 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
596 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
600 if (m_pen
.GetStyle() != wxTRANSPARENT
)
602 gdk_draw_arc( m_gdkwindow
, m_penGC
, FALSE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
604 if ((m_brush
.GetStyle() != wxTRANSPARENT
) && (alpha2
- alpha1
!= 360*64))
606 gdk_draw_line( m_gdkwindow
, m_penGC
, xx1
, yy1
, xxc
, yyc
);
607 gdk_draw_line( m_gdkwindow
, m_penGC
, xxc
, yyc
, xx2
, yy2
);
612 CalcBoundingBox (x1
, y1
);
613 CalcBoundingBox (x2
, y2
);
616 void wxWindowDCImpl
::DoDrawEllipticArc( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double sa
, double ea
)
618 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
620 wxCoord xx
= XLOG2DEV(x
);
621 wxCoord yy
= YLOG2DEV(y
);
622 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
623 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
625 // CMB: handle -ve width and/or height
626 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
627 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
631 wxCoord start
= wxCoord(sa
* 64.0);
632 wxCoord end
= wxCoord((ea
-sa
) * 64.0);
634 if (m_brush
.GetStyle() != wxTRANSPARENT
)
636 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
638 gdk_gc_set_ts_origin( m_textGC
,
639 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
640 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
641 gdk_draw_arc( m_gdkwindow
, m_textGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
642 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
644 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
646 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
647 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
648 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
650 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
652 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
653 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
654 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
656 if (m_brush
.GetStyle() == wxSTIPPLE
)
658 gdk_gc_set_ts_origin( m_brushGC
,
659 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
660 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
661 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
662 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
666 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
670 if (m_pen
.GetStyle() != wxTRANSPARENT
)
671 gdk_draw_arc( m_gdkwindow
, m_penGC
, FALSE
, xx
, yy
, ww
, hh
, start
, end
);
674 CalcBoundingBox (x
, y
);
675 CalcBoundingBox (x
+ width
, y
+ height
);
678 void wxWindowDCImpl
::DoDrawPoint( wxCoord x
, wxCoord y
)
680 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
682 if ((m_pen
.GetStyle() != wxTRANSPARENT
) && m_gdkwindow
)
683 gdk_draw_point( m_gdkwindow
, m_penGC
, XLOG2DEV(x
), YLOG2DEV(y
) );
685 CalcBoundingBox (x
, y
);
688 void wxWindowDCImpl
::DoDrawLines( int n
, wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
)
690 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
692 if (m_pen
.GetStyle() == wxTRANSPARENT
) return;
695 //Check, if scaling is necessary
697 xoffset
!= 0 || yoffset
!= 0 || XLOG2DEV(10) != 10 || YLOG2DEV(10) != 10;
699 // GdkPoint and wxPoint have the same memory layout, so we can cast one to the other
700 GdkPoint
* gpts
= reinterpret_cast<GdkPoint
*>(points
);
703 gpts
= new GdkPoint
[n
];
705 for (int i
= 0; i
< n
; i
++)
709 gpts
[i
].x
= XLOG2DEV(points
[i
].x
+ xoffset
);
710 gpts
[i
].y
= YLOG2DEV(points
[i
].y
+ yoffset
);
712 CalcBoundingBox(points
[i
].x
+ xoffset
, points
[i
].y
+ yoffset
);
716 gdk_draw_lines( m_gdkwindow
, m_penGC
, gpts
, n
);
722 void wxWindowDCImpl
::DoDrawPolygon( int n
, wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
, int WXUNUSED(fillStyle
) )
724 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
728 //Check, if scaling is necessary
730 xoffset
!= 0 || yoffset
!= 0 || XLOG2DEV(10) != 10 || YLOG2DEV(10) != 10;
732 // GdkPoint and wxPoint have the same memory layout, so we can cast one to the other
733 GdkPoint
* gdkpoints
= reinterpret_cast<GdkPoint
*>(points
);
736 gdkpoints
= new GdkPoint
[n
];
739 for (i
= 0 ; i
< n
; i
++)
743 gdkpoints
[i
].x
= XLOG2DEV(points
[i
].x
+ xoffset
);
744 gdkpoints
[i
].y
= YLOG2DEV(points
[i
].y
+ yoffset
);
746 CalcBoundingBox(points
[i
].x
+ xoffset
, points
[i
].y
+ yoffset
);
751 if (m_brush
.GetStyle() != wxTRANSPARENT
)
753 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
755 gdk_gc_set_ts_origin( m_textGC
,
756 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
757 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
758 gdk_draw_polygon( m_gdkwindow
, m_textGC
, TRUE
, gdkpoints
, n
);
759 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
761 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
763 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
764 gdk_draw_polygon( m_gdkwindow
, m_brushGC
, TRUE
, gdkpoints
, n
);
765 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
767 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
769 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
770 gdk_draw_polygon( m_gdkwindow
, m_brushGC
, TRUE
, gdkpoints
, n
);
771 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
773 if (m_brush
.GetStyle() == wxSTIPPLE
)
775 gdk_gc_set_ts_origin( m_brushGC
,
776 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
777 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
778 gdk_draw_polygon( m_gdkwindow
, m_brushGC
, TRUE
, gdkpoints
, n
);
779 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
783 gdk_draw_polygon( m_gdkwindow
, m_brushGC
, TRUE
, gdkpoints
, n
);
787 if (m_pen
.GetStyle() != wxTRANSPARENT
)
790 for (i = 0 ; i < n ; i++)
792 gdk_draw_line( m_gdkwindow, m_penGC,
795 gdkpoints[(i+1)%n].x,
796 gdkpoints[(i+1)%n].y);
799 gdk_draw_polygon( m_gdkwindow
, m_penGC
, FALSE
, gdkpoints
, n
);
808 void wxWindowDCImpl
::DoDrawRectangle( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
810 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
812 wxCoord xx
= XLOG2DEV(x
);
813 wxCoord yy
= YLOG2DEV(y
);
814 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
815 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
817 // CMB: draw nothing if transformed w or h is 0
818 if (ww
== 0 || hh
== 0) return;
820 // CMB: handle -ve width and/or height
821 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
822 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
826 if (m_brush
.GetStyle() != wxTRANSPARENT
)
828 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
830 gdk_gc_set_ts_origin( m_textGC
,
831 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
832 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
833 gdk_draw_rectangle( m_gdkwindow
, m_textGC
, TRUE
, xx
, yy
, ww
, hh
);
834 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
836 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
838 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
839 gdk_draw_rectangle( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
);
840 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
842 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
844 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
845 gdk_draw_rectangle( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
);
846 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
848 if (m_brush
.GetStyle() == wxSTIPPLE
)
850 gdk_gc_set_ts_origin( m_brushGC
,
851 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
852 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
853 gdk_draw_rectangle( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
);
854 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
858 gdk_draw_rectangle( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
);
862 if (m_pen
.GetStyle() != wxTRANSPARENT
)
865 if ((m_pen
.GetWidth() == 2) && (m_pen
.GetCap() == wxCAP_ROUND
) &&
866 (m_pen
.GetJoin() == wxJOIN_ROUND
) && (m_pen
.GetStyle() == wxSOLID
))
868 // Use 2 1-line rects instead
869 gdk_gc_set_line_attributes( m_penGC
, 1, GDK_LINE_SOLID
, GDK_CAP_ROUND
, GDK_JOIN_ROUND
);
874 gdk_draw_rectangle( m_gdkwindow
, m_penGC
, FALSE
, xx
+1, yy
, ww
-2, hh
-2 );
875 gdk_draw_rectangle( m_gdkwindow
, m_penGC
, FALSE
, xx
, yy
-1, ww
, hh
);
879 gdk_draw_rectangle( m_gdkwindow
, m_penGC
, FALSE
, xx
, yy
, ww
-2, hh
-2 );
880 gdk_draw_rectangle( m_gdkwindow
, m_penGC
, FALSE
, xx
-1, yy
-1, ww
, hh
);
884 gdk_gc_set_line_attributes( m_penGC
, 2, GDK_LINE_SOLID
, GDK_CAP_ROUND
, GDK_JOIN_ROUND
);
889 // Just use X11 for other cases
890 gdk_draw_rectangle( m_gdkwindow
, m_penGC
, FALSE
, xx
, yy
, ww
-1, hh
-1 );
895 CalcBoundingBox( x
, y
);
896 CalcBoundingBox( x
+ width
, y
+ height
);
899 void wxWindowDCImpl
::DoDrawRoundedRectangle( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double radius
)
901 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
903 if (radius
< 0.0) radius
= - radius
* ((width
< height
) ? width
: height
);
905 wxCoord xx
= XLOG2DEV(x
);
906 wxCoord yy
= YLOG2DEV(y
);
907 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
908 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
909 wxCoord rr
= XLOG2DEVREL((wxCoord
)radius
);
911 // CMB: handle -ve width and/or height
912 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
913 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
915 // CMB: if radius is zero use DrawRectangle() instead to avoid
916 // X drawing errors with small radii
919 DoDrawRectangle( x
, y
, width
, height
);
923 // CMB: draw nothing if transformed w or h is 0
924 if (ww
== 0 || hh
== 0) return;
926 // CMB: adjust size if outline is drawn otherwise the result is
927 // 1 pixel too wide and high
928 if (m_pen
.GetStyle() != wxTRANSPARENT
)
936 // CMB: ensure dd is not larger than rectangle otherwise we
937 // get an hour glass shape
939 if (dd
> ww
) dd
= ww
;
940 if (dd
> hh
) dd
= hh
;
943 if (m_brush
.GetStyle() != wxTRANSPARENT
)
945 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
947 gdk_gc_set_ts_origin( m_textGC
,
948 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
949 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
950 gdk_draw_rectangle( m_gdkwindow
, m_textGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
951 gdk_draw_rectangle( m_gdkwindow
, m_textGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
952 gdk_draw_arc( m_gdkwindow
, m_textGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
953 gdk_draw_arc( m_gdkwindow
, m_textGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
954 gdk_draw_arc( m_gdkwindow
, m_textGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
955 gdk_draw_arc( m_gdkwindow
, m_textGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
956 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
958 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
960 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
961 gdk_draw_rectangle( m_gdkwindow
, m_brushGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
962 gdk_draw_rectangle( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
963 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
964 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
965 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
966 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
967 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
969 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
971 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
972 gdk_draw_rectangle( m_gdkwindow
, m_brushGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
973 gdk_draw_rectangle( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
974 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
975 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
976 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
977 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
978 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
980 if (m_brush
.GetStyle() == wxSTIPPLE
)
982 gdk_gc_set_ts_origin( m_brushGC
,
983 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
984 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
985 gdk_draw_rectangle( m_gdkwindow
, m_brushGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
986 gdk_draw_rectangle( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
987 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
988 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
989 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
990 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
991 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
995 gdk_draw_rectangle( m_gdkwindow
, m_brushGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
996 gdk_draw_rectangle( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
997 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
998 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
999 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
1000 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
1004 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1006 gdk_draw_line( m_gdkwindow
, m_penGC
, xx
+rr
+1, yy
, xx
+ww
-rr
, yy
);
1007 gdk_draw_line( m_gdkwindow
, m_penGC
, xx
+rr
+1, yy
+hh
, xx
+ww
-rr
, yy
+hh
);
1008 gdk_draw_line( m_gdkwindow
, m_penGC
, xx
, yy
+rr
+1, xx
, yy
+hh
-rr
);
1009 gdk_draw_line( m_gdkwindow
, m_penGC
, xx
+ww
, yy
+rr
+1, xx
+ww
, yy
+hh
-rr
);
1010 gdk_draw_arc( m_gdkwindow
, m_penGC
, FALSE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
1011 gdk_draw_arc( m_gdkwindow
, m_penGC
, FALSE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
1012 gdk_draw_arc( m_gdkwindow
, m_penGC
, FALSE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
1013 gdk_draw_arc( m_gdkwindow
, m_penGC
, FALSE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
1017 // this ignores the radius
1018 CalcBoundingBox( x
, y
);
1019 CalcBoundingBox( x
+ width
, y
+ height
);
1022 void wxWindowDCImpl
::DoDrawEllipse( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1024 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1026 wxCoord xx
= XLOG2DEV(x
);
1027 wxCoord yy
= YLOG2DEV(y
);
1028 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1029 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1031 // CMB: handle -ve width and/or height
1032 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
1033 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
1037 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1039 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
1041 gdk_gc_set_ts_origin( m_textGC
,
1042 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
1043 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
1044 gdk_draw_arc( m_gdkwindow
, m_textGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1045 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
1047 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
1049 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
1050 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1051 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
1053 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
1055 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
1056 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1057 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
1059 if (m_brush
.GetStyle() == wxSTIPPLE
)
1061 gdk_gc_set_ts_origin( m_brushGC
,
1062 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
1063 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
1064 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1065 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
1069 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1073 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1074 gdk_draw_arc( m_gdkwindow
, m_penGC
, FALSE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1077 CalcBoundingBox( x
, y
);
1078 CalcBoundingBox( x
+ width
, y
+ height
);
1081 void wxWindowDCImpl
::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
1083 // VZ: egcs 1.0.3 refuses to compile this without cast, no idea why
1084 DoDrawBitmap( (const wxBitmap
&)icon
, x
, y
, true );
1087 void wxWindowDCImpl
::DoDrawBitmap( const wxBitmap
&bitmap
,
1088 wxCoord x
, wxCoord y
,
1091 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1093 wxCHECK_RET( bitmap
.IsOk(), wxT("invalid bitmap") );
1095 bool is_mono
= bitmap
.GetDepth() == 1;
1097 // scale/translate size and position
1098 int xx
= XLOG2DEV(x
);
1099 int yy
= YLOG2DEV(y
);
1101 int w
= bitmap
.GetWidth();
1102 int h
= bitmap
.GetHeight();
1104 if (m_window
&& m_window
->GetLayoutDirection() == wxLayout_RightToLeft
)
1107 CalcBoundingBox( x
, y
);
1108 CalcBoundingBox( x
+ w
, y
+ h
);
1110 if (!m_gdkwindow
) return;
1112 int ww
= XLOG2DEVREL(w
);
1113 int hh
= YLOG2DEVREL(h
);
1115 // compare to current clipping region
1116 if (!m_currentClippingRegion
.IsNull())
1118 wxRegion
tmp( xx
,yy
,ww
,hh
);
1119 tmp
.Intersect( m_currentClippingRegion
);
1124 // scale bitmap if required
1125 wxBitmap use_bitmap
= bitmap
;
1126 if ((w
!= ww
) || (h
!= hh
))
1127 use_bitmap
= use_bitmap
.Rescale( 0, 0, ww
, hh
, ww
, hh
);
1129 // apply mask if any
1130 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
1131 if (useMask
&& use_bitmap
.GetMask())
1132 mask
= use_bitmap
.GetMask()->GetBitmap();
1134 GdkGC
* use_gc
= is_mono ? m_textGC
: m_penGC
;
1136 GdkBitmap
*new_mask
= (GdkBitmap
*) NULL
;
1140 if (!m_currentClippingRegion
.IsNull())
1143 new_mask
= gdk_pixmap_new( wxGetRootWindow()->window
, ww
, hh
, 1 );
1144 GdkGC
*gc
= gdk_gc_new( new_mask
);
1146 gdk_gc_set_foreground( gc
, &col
);
1147 gdk_draw_rectangle( new_mask
, gc
, TRUE
, 0, 0, ww
, hh
);
1149 gdk_gc_set_background( gc
, &col
);
1151 gdk_gc_set_foreground( gc
, &col
);
1152 gdk_gc_set_clip_region( gc
, m_currentClippingRegion
.GetRegion() );
1153 gdk_gc_set_clip_origin( gc
, -xx
, -yy
);
1154 gdk_gc_set_fill( gc
, GDK_OPAQUE_STIPPLED
);
1155 gdk_gc_set_stipple( gc
, mask
);
1156 gdk_draw_rectangle( new_mask
, gc
, TRUE
, 0, 0, ww
, hh
);
1158 g_object_unref (gc
);
1161 gdk_gc_set_clip_mask(use_gc
, mask
);
1162 gdk_gc_set_clip_origin(use_gc
, xx
, yy
);
1165 // Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For
1166 // drawing a mono-bitmap (XBitmap) we use the current text GC
1169 GdkPixmap
*bitmap2
= gdk_pixmap_new( wxGetRootWindow()->window
, ww
, hh
, -1 );
1170 GdkGC
*gc
= gdk_gc_new( bitmap2
);
1171 gdk_gc_set_foreground( gc
, m_textForegroundColour
.GetColor() );
1172 gdk_gc_set_background( gc
, m_textBackgroundColour
.GetColor() );
1173 gdk_wx_draw_bitmap(bitmap2
, gc
, use_bitmap
.GetPixmap(), 0, 0);
1175 gdk_draw_drawable(m_gdkwindow
, use_gc
, bitmap2
, 0, 0, xx
, yy
, -1, -1);
1177 g_object_unref (bitmap2
);
1178 g_object_unref (gc
);
1182 if (use_bitmap
.HasPixbuf())
1184 gdk_draw_pixbuf(m_gdkwindow
, use_gc
,
1185 use_bitmap
.GetPixbuf(),
1186 0, 0, xx
, yy
, -1, -1,
1187 GDK_RGB_DITHER_NORMAL
, xx
, yy
);
1191 gdk_draw_drawable(m_gdkwindow
, use_gc
,
1192 use_bitmap
.GetPixmap(),
1193 0, 0, xx
, yy
, -1, -1);
1197 // remove mask again if any
1200 gdk_gc_set_clip_mask(use_gc
, NULL
);
1201 gdk_gc_set_clip_origin(use_gc
, 0, 0);
1202 if (!m_currentClippingRegion
.IsNull())
1203 gdk_gc_set_clip_region(use_gc
, m_currentClippingRegion
.GetRegion());
1204 if (new_mask
!= NULL
)
1205 g_object_unref(new_mask
);
1209 bool wxWindowDCImpl
::DoBlit( wxCoord xdest
, wxCoord ydest
,
1210 wxCoord width
, wxCoord height
,
1212 wxCoord xsrc
, wxCoord ysrc
,
1215 wxCoord xsrcMask
, wxCoord ysrcMask
)
1217 wxCHECK_MSG( IsOk(), false, wxT("invalid window dc") );
1219 wxCHECK_MSG( source
, false, wxT("invalid source dc") );
1221 if (!m_gdkwindow
) return false;
1223 // transform the source DC coords to the device ones
1224 xsrc
= source
->LogicalToDeviceX(xsrc
);
1225 ysrc
= source
->LogicalToDeviceY(ysrc
);
1228 wxMemoryDC
*memDC
= wxDynamicCast(source
, wxMemoryDC
);
1231 selected
= memDC
->GetSelectedBitmap();
1232 if ( !selected
.IsOk() )
1236 bool use_bitmap_method
= false;
1237 bool is_mono
= false;
1239 if (xsrcMask
== -1 && ysrcMask
== -1)
1245 if (selected
.IsOk())
1247 is_mono
= (selected
.GetDepth() == 1);
1249 // we use the "XCopyArea" way to copy a memory dc into
1250 // a different window if the memory dc BOTH
1251 // a) doesn't have any mask or its mask isn't used
1255 if (useMask
&& (selected
.GetMask()))
1257 // we HAVE TO use the direct way for memory dcs
1258 // that have mask since the XCopyArea doesn't know
1260 use_bitmap_method
= true;
1264 // we HAVE TO use the direct way for memory dcs
1265 // that are bitmaps because XCopyArea doesn't cope
1266 // with different bit depths
1267 use_bitmap_method
= true;
1269 else if ((xsrc
== 0) && (ysrc
== 0) &&
1270 (width
== selected
.GetWidth()) &&
1271 (height
== selected
.GetHeight()))
1273 // we SHOULD use the direct way if all of the bitmap
1274 // in the memory dc is copied in which case XCopyArea
1275 // wouldn't be able able to boost performace by reducing
1276 // the area to be scaled
1277 use_bitmap_method
= true;
1281 CalcBoundingBox( xdest
, ydest
);
1282 CalcBoundingBox( xdest
+ width
, ydest
+ height
);
1284 // scale/translate size and position
1285 wxCoord xx
= XLOG2DEV(xdest
);
1286 wxCoord yy
= YLOG2DEV(ydest
);
1288 wxCoord ww
= XLOG2DEVREL(width
);
1289 wxCoord hh
= YLOG2DEVREL(height
);
1291 // compare to current clipping region
1292 if (!m_currentClippingRegion
.IsNull())
1294 wxRegion
tmp( xx
,yy
,ww
,hh
);
1295 tmp
.Intersect( m_currentClippingRegion
);
1300 int old_logical_func
= m_logicalFunction
;
1301 SetLogicalFunction( logical_func
);
1303 if (use_bitmap_method
)
1305 // scale/translate bitmap size
1306 wxCoord bm_width
= selected
.GetWidth();
1307 wxCoord bm_height
= selected
.GetHeight();
1309 // Get clip coords for the bitmap. If we don't
1310 // use wxBitmap::Rescale(), which can clip the
1311 // bitmap, these are the same as the original
1318 // interpret userscale of src too
1320 memDC
->GetUserScale(&xsc
,&ysc
);
1321 bm_width
= (int) (bm_width
/ xsc
);
1322 bm_height
= (int) (bm_height
/ ysc
);
1324 wxCoord bm_ww
= XLOG2DEVREL( bm_width
);
1325 wxCoord bm_hh
= YLOG2DEVREL( bm_height
);
1327 // Scale bitmap if required
1328 wxBitmap use_bitmap
= selected
;
1329 if ((selected
.GetWidth()!= bm_ww
) || ( selected
.GetHeight()!= bm_hh
))
1331 // This indicates that the blitting code below will get
1332 // a clipped bitmap and therefore needs to move the origin
1334 wxRegion
tmp( xx
,yy
,ww
,hh
);
1335 if (!m_currentClippingRegion
.IsNull())
1336 tmp
.Intersect( m_currentClippingRegion
);
1337 tmp
.GetBox(cx
,cy
,cw
,ch
);
1339 // Scale and clipped bitmap
1340 use_bitmap
= selected
.Rescale(cx
-xx
,cy
-yy
,cw
,ch
,bm_ww
,bm_hh
);
1343 // apply mask if any
1344 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
1345 if (useMask
&& use_bitmap
.GetMask())
1346 mask
= use_bitmap
.GetMask()->GetBitmap();
1348 GdkGC
* use_gc
= is_mono ? m_textGC
: m_penGC
;
1350 GdkBitmap
*new_mask
= (GdkBitmap
*) NULL
;
1354 if (!m_currentClippingRegion
.IsNull())
1357 new_mask
= gdk_pixmap_new( wxGetRootWindow()->window
, bm_ww
, bm_hh
, 1 );
1358 GdkGC
*gc
= gdk_gc_new( new_mask
);
1360 gdk_gc_set_foreground( gc
, &col
);
1361 gdk_gc_set_ts_origin( gc
, -xsrcMask
, -ysrcMask
);
1362 gdk_draw_rectangle( new_mask
, gc
, TRUE
, 0, 0, bm_ww
, bm_hh
);
1364 gdk_gc_set_background( gc
, &col
);
1366 gdk_gc_set_foreground( gc
, &col
);
1367 gdk_gc_set_clip_region( gc
, m_currentClippingRegion
.GetRegion() );
1368 // was: gdk_gc_set_clip_origin( gc, -xx, -yy );
1369 gdk_gc_set_clip_origin( gc
, -cx
, -cy
);
1370 gdk_gc_set_fill( gc
, GDK_OPAQUE_STIPPLED
);
1371 gdk_gc_set_stipple( gc
, mask
);
1372 gdk_draw_rectangle( new_mask
, gc
, TRUE
, 0, 0, bm_ww
, bm_hh
);
1374 g_object_unref (gc
);
1377 gdk_gc_set_clip_mask(use_gc
, mask
);
1378 if (new_mask
!= NULL
)
1379 gdk_gc_set_clip_origin(use_gc
, cx
, cy
);
1381 gdk_gc_set_clip_origin(use_gc
, cx
- xsrcMask
, cy
- ysrcMask
);
1384 // Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For
1385 // drawing a mono-bitmap (XBitmap) we use the current text GC
1389 GdkPixmap
*bitmap
= gdk_pixmap_new( wxGetRootWindow()->window
, bm_ww
, bm_hh
, -1 );
1390 GdkGC
*gc
= gdk_gc_new( bitmap
);
1391 gdk_gc_set_foreground( gc
, m_textForegroundColour
.GetColor() );
1392 gdk_gc_set_background( gc
, m_textBackgroundColour
.GetColor() );
1393 gdk_wx_draw_bitmap(bitmap
, gc
, use_bitmap
.GetPixmap(), 0, 0);
1395 gdk_draw_drawable(m_gdkwindow
, use_gc
, bitmap
, xsrc
, ysrc
, cx
, cy
, cw
, ch
);
1397 g_object_unref (bitmap
);
1398 g_object_unref (gc
);
1402 // was: gdk_draw_drawable( m_gdkwindow, m_penGC, use_bitmap.GetPixmap(), xsrc, ysrc, xx, yy, ww, hh );
1403 gdk_draw_drawable(m_gdkwindow
, use_gc
, use_bitmap
.GetPixmap(), xsrc
, ysrc
, cx
, cy
, cw
, ch
);
1406 // remove mask again if any
1409 gdk_gc_set_clip_mask(use_gc
, NULL
);
1410 gdk_gc_set_clip_origin(use_gc
, 0, 0);
1411 if (!m_currentClippingRegion
.IsNull())
1412 gdk_gc_set_clip_region(use_gc
, m_currentClippingRegion
.GetRegion());
1416 g_object_unref (new_mask
);
1418 else // use_bitmap_method
1420 if (selected
.IsOk() && ((width
!= ww
) || (height
!= hh
)))
1423 wxRegion
tmp( xx
,yy
,ww
,hh
);
1424 tmp
.Intersect( m_currentClippingRegion
);
1425 wxCoord cx
,cy
,cw
,ch
;
1426 tmp
.GetBox(cx
,cy
,cw
,ch
);
1429 wxBitmap bitmap
= selected
.Rescale( cx
-xx
, cy
-yy
, cw
, ch
, ww
, hh
);
1431 // draw scaled bitmap
1432 // was: gdk_draw_drawable( m_gdkwindow, m_penGC, bitmap.GetPixmap(), 0, 0, xx, yy, -1, -1 );
1433 gdk_draw_drawable( m_gdkwindow
, m_penGC
, bitmap
.GetPixmap(), 0, 0, cx
, cy
, -1, -1 );
1437 // No scaling and not a memory dc with a mask either
1438 GdkWindow
* window
= NULL
;
1439 wxDCImpl
*impl
= source
->GetImpl();
1440 wxWindowDCImpl
*gtk_impl
= wxDynamicCast(impl
, wxWindowDCImpl
);
1442 window
= gtk_impl
->GetGDKWindow();
1445 SetLogicalFunction( old_logical_func
);
1449 // copy including child window contents
1450 gdk_gc_set_subwindow( m_penGC
, GDK_INCLUDE_INFERIORS
);
1451 gdk_draw_drawable( m_gdkwindow
, m_penGC
,
1455 gdk_gc_set_subwindow( m_penGC
, GDK_CLIP_BY_CHILDREN
);
1459 SetLogicalFunction( old_logical_func
);
1464 void wxWindowDCImpl
::DoDrawText( const wxString
&text
, wxCoord x
, wxCoord y
)
1466 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1468 if (!m_gdkwindow
) return;
1470 if (text
.empty()) return;
1475 wxCHECK_RET( m_context
, wxT("no Pango context") );
1476 wxCHECK_RET( m_layout
, wxT("no Pango layout") );
1477 wxCHECK_RET( m_fontdesc
, wxT("no Pango font description") );
1479 gdk_pango_context_set_colormap( m_context
, m_cmap
);
1481 bool underlined
= m_font
.IsOk() && m_font
.GetUnderlined();
1483 wxCharBuffer data
= wxGTK_CONV(text
);
1486 size_t datalen
= strlen(data
);
1488 // in Pango >= 1.16 the "underline of leading/trailing spaces" bug
1489 // has been fixed and thus the hack implemented below should never be used
1490 static bool pangoOk
= !wx_pango_version_check(1, 16, 0);
1492 bool needshack
= underlined
&& !pangoOk
;
1496 // a PangoLayout which has leading/trailing spaces with underlined font
1497 // is not correctly drawn by this pango version: Pango won't underline the spaces.
1498 // This can be a problem; e.g. wxHTML rendering of underlined text relies on
1499 // this behaviour. To workaround this problem, we use a special hack here
1500 // suggested by pango maintainer Behdad Esfahbod: we prepend and append two
1501 // empty space characters and give them a dummy colour attribute.
1502 // This will force Pango to underline the leading/trailing spaces, too.
1504 wxCharBuffer
data_tmp(datalen
+ 6);
1505 // copy the leading U+200C ZERO WIDTH NON-JOINER encoded in UTF8 format
1506 memcpy(data_tmp
.data(), "\342\200\214", 3);
1507 // copy the user string
1508 memcpy(data_tmp
.data() + 3, data
, datalen
);
1509 // copy the trailing U+200C ZERO WIDTH NON-JOINER encoded in UTF8 format
1510 memcpy(data_tmp
.data() + 3 + datalen
, "\342\200\214", 3);
1516 pango_layout_set_text(m_layout
, data
, datalen
);
1520 PangoAttrList
*attrs
= pango_attr_list_new();
1521 PangoAttribute
*a
= pango_attr_underline_new(PANGO_UNDERLINE_SINGLE
);
1523 a
->end_index
= datalen
;
1524 pango_attr_list_insert(attrs
, a
);
1528 // dummy colour for the leading space
1529 a
= pango_attr_foreground_new (0x0057, 0x52A9, 0xD614);
1532 pango_attr_list_insert(attrs
, a
);
1534 // dummy colour for the trailing space
1535 a
= pango_attr_foreground_new (0x0057, 0x52A9, 0xD614);
1536 a
->start_index
= datalen
- 1;
1537 a
->end_index
= datalen
;
1538 pango_attr_list_insert(attrs
, a
);
1541 pango_layout_set_attributes(m_layout
, attrs
);
1542 pango_attr_list_unref(attrs
);
1547 if (fabs(m_scaleY
- 1.0) > 0.00001)
1549 // If there is a user or actually any scale applied to
1550 // the device context, scale the font.
1552 // scale font description
1553 gint oldSize
= pango_font_description_get_size( m_fontdesc
);
1554 double size
= oldSize
;
1555 size
= size
* m_scaleY
;
1556 pango_font_description_set_size( m_fontdesc
, (gint
)size
);
1558 // actually apply scaled font
1559 pango_layout_set_font_description( m_layout
, m_fontdesc
);
1561 pango_layout_get_pixel_size( m_layout
, &w
, &h
);
1562 if ( m_backgroundMode
== wxSOLID
)
1564 gdk_gc_set_foreground(m_textGC
, m_textBackgroundColour
.GetColor());
1565 gdk_draw_rectangle(m_gdkwindow
, m_textGC
, TRUE
, x
, y
, w
, h
);
1566 gdk_gc_set_foreground(m_textGC
, m_textForegroundColour
.GetColor());
1570 if (m_window
&& m_window
->GetLayoutDirection() == wxLayout_RightToLeft
)
1571 gdk_draw_layout( m_gdkwindow
, m_textGC
, x
-w
, y
, m_layout
);
1573 gdk_draw_layout( m_gdkwindow
, m_textGC
, x
, y
, m_layout
);
1575 // reset unscaled size
1576 pango_font_description_set_size( m_fontdesc
, oldSize
);
1578 // actually apply unscaled font
1579 pango_layout_set_font_description( m_layout
, m_fontdesc
);
1583 pango_layout_get_pixel_size( m_layout
, &w
, &h
);
1584 if ( m_backgroundMode
== wxSOLID
)
1586 gdk_gc_set_foreground(m_textGC
, m_textBackgroundColour
.GetColor());
1587 gdk_draw_rectangle(m_gdkwindow
, m_textGC
, TRUE
, x
, y
, w
, h
);
1588 gdk_gc_set_foreground(m_textGC
, m_textForegroundColour
.GetColor());
1592 if (m_window
&& m_window
->GetLayoutDirection() == wxLayout_RightToLeft
)
1593 gdk_draw_layout( m_gdkwindow
, m_textGC
, x
-w
, y
, m_layout
);
1595 gdk_draw_layout( m_gdkwindow
, m_textGC
, x
, y
, m_layout
);
1600 // undo underline attributes setting:
1601 pango_layout_set_attributes(m_layout
, NULL
);
1607 width
= wxCoord(width
/ m_scaleX
);
1608 height
= wxCoord(height
/ m_scaleY
);
1609 CalcBoundingBox (x
+ width
, y
+ height
);
1610 CalcBoundingBox (x
, y
);
1614 // TODO: There is an example of rotating text with GTK2 that would probably be
1615 // a better approach here:
1616 // http://www.daa.com.au/pipermail/pygtk/2003-April/005052.html
1618 void wxWindowDCImpl
::DoDrawRotatedText( const wxString
&text
, wxCoord x
, wxCoord y
, double angle
)
1621 if (!m_gdkwindow
|| text
.empty())
1624 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1626 if ( wxIsNullDouble(angle
) )
1628 DoDrawText(text
, x
, y
);
1635 // TODO: implement later without GdkFont for GTK 2.0
1636 DoGetTextExtent(text
, &w
, &h
, NULL
,NULL
, &m_font
);
1638 // draw the string normally
1641 dc
.SelectObject(src
);
1642 dc
.SetFont(GetFont());
1643 dc
.SetBackground(*wxBLACK_BRUSH
);
1644 dc
.SetBrush(*wxBLACK_BRUSH
);
1646 dc
.SetTextForeground( *wxWHITE
);
1647 dc
.DrawText(text
, 0, 0);
1648 dc
.SelectObject(wxNullBitmap
);
1650 // Calculate the size of the rotated bounding box.
1651 double rad
= DegToRad(angle
);
1652 double dx
= cos(rad
),
1655 // the rectngle vertices are counted clockwise with the first one being at
1656 // (0, 0) (or, rather, at (x, y))
1658 y2
= -w
*dy
; // y axis points to the bottom, hence minus
1661 double x3
= x4
+ x2
,
1665 wxCoord maxX
= (wxCoord
)(dmax(x2
, dmax(x3
, x4
)) + 0.5),
1666 maxY
= (wxCoord
)(dmax(y2
, dmax(y3
, y4
)) + 0.5),
1667 minX
= (wxCoord
)(dmin(x2
, dmin(x3
, x4
)) - 0.5),
1668 minY
= (wxCoord
)(dmin(y2
, dmin(y3
, y4
)) - 0.5);
1671 wxImage image
= src
.ConvertToImage();
1673 image
.ConvertColourToAlpha( m_textForegroundColour
.Red(),
1674 m_textForegroundColour
.Green(),
1675 m_textForegroundColour
.Blue() );
1676 image
= image
.Rotate( rad
, wxPoint(0,0) );
1678 int i_angle
= (int) angle
;
1679 i_angle
= i_angle
% 360;
1683 if ((i_angle
>= 90.0) && (i_angle
< 270.0))
1684 xoffset
= image
.GetWidth();
1686 if ((i_angle
>= 0.0) && (i_angle
< 180.0))
1687 yoffset
= image
.GetHeight();
1689 if ((i_angle
>= 0) && (i_angle
< 90))
1690 yoffset
-= (int)( cos(rad
)*h
);
1691 if ((i_angle
>= 90) && (i_angle
< 180))
1692 xoffset
-= (int)( sin(rad
)*h
);
1693 if ((i_angle
>= 180) && (i_angle
< 270))
1694 yoffset
-= (int)( cos(rad
)*h
);
1695 if ((i_angle
>= 270) && (i_angle
< 360))
1696 xoffset
-= (int)( sin(rad
)*h
);
1698 int i_x
= x
- xoffset
;
1699 int i_y
= y
- yoffset
;
1702 DoDrawBitmap( src
, i_x
, i_y
, true );
1705 // it would be better to draw with non underlined font and draw the line
1706 // manually here (it would be more straight...)
1708 if ( m_font
.GetUnderlined() )
1710 gdk_draw_line( m_gdkwindow
, m_textGC
,
1711 XLOG2DEV(x
+ x4
), YLOG2DEV(y
+ y4
+ font
->descent
),
1712 XLOG2DEV(x
+ x3
), YLOG2DEV(y
+ y3
+ font
->descent
));
1716 // update the bounding box
1717 CalcBoundingBox(x
+ minX
, y
+ minY
);
1718 CalcBoundingBox(x
+ maxX
, y
+ maxY
);
1719 #else // !wxUSE_IMAGE
1724 #endif // wxUSE_IMAGE/!wxUSE_IMAGE
1727 void wxWindowDCImpl
::DoGetTextExtent(const wxString
&string
,
1728 wxCoord
*width
, wxCoord
*height
,
1729 wxCoord
*descent
, wxCoord
*externalLeading
,
1730 const wxFont
*theFont
) const
1738 if ( externalLeading
)
1739 *externalLeading
= 0;
1744 // ensure that theFont is always non-NULL
1745 if ( !theFont
|| !theFont
->IsOk() )
1746 theFont
= wx_const_cast(wxFont
*, &m_font
);
1748 // and use it if it's valid
1749 if ( theFont
->IsOk() )
1751 pango_layout_set_font_description
1754 theFont
->GetNativeFontInfo()->description
1758 // Set layout's text
1759 const wxCharBuffer dataUTF8
= wxGTK_CONV_FONT(string
, *theFont
);
1762 // hardly ideal, but what else can we do if conversion failed?
1766 pango_layout_set_text( m_layout
, dataUTF8
, strlen(dataUTF8
) );
1771 pango_layout_get_pixel_size( m_layout
, width
, &h
);
1772 PangoLayoutIter
*iter
= pango_layout_get_iter(m_layout
);
1773 int baseline
= pango_layout_iter_get_baseline(iter
);
1774 pango_layout_iter_free(iter
);
1775 *descent
= h
- PANGO_PIXELS(baseline
);
1778 *height
= (wxCoord
) h
;
1782 pango_layout_get_pixel_size( m_layout
, width
, height
);
1785 // Reset old font description
1786 if (theFont
->IsOk())
1787 pango_layout_set_font_description( m_layout
, m_fontdesc
);
1791 bool wxWindowDCImpl
::DoGetPartialTextExtents(const wxString
& text
,
1792 wxArrayInt
& widths
) const
1794 const size_t len
= text
.length();
1801 // Set layout's text
1802 const wxCharBuffer dataUTF8
= wxGTK_CONV_FONT(text
, m_font
);
1805 // hardly ideal, but what else can we do if conversion failed?
1806 wxLogLastError(wxT("DoGetPartialTextExtents"));
1810 pango_layout_set_text( m_layout
, dataUTF8
, strlen(dataUTF8
) );
1812 // Calculate the position of each character based on the widths of
1813 // the previous characters
1815 // Code borrowed from Scintilla's PlatGTK
1816 PangoLayoutIter
*iter
= pango_layout_get_iter(m_layout
);
1818 pango_layout_iter_get_cluster_extents(iter
, NULL
, &pos
);
1820 while (pango_layout_iter_next_cluster(iter
))
1822 pango_layout_iter_get_cluster_extents(iter
, NULL
, &pos
);
1823 int position
= PANGO_PIXELS(pos
.x
);
1824 widths
[i
++] = position
;
1827 widths
[i
++] = PANGO_PIXELS(pos
.x
+ pos
.width
);
1828 pango_layout_iter_free(iter
);
1834 wxCoord wxWindowDCImpl
::GetCharWidth() const
1836 pango_layout_set_text( m_layout
, "H", 1 );
1838 pango_layout_get_pixel_size( m_layout
, &w
, NULL
);
1842 wxCoord wxWindowDCImpl
::GetCharHeight() const
1844 PangoFontMetrics
*metrics
= pango_context_get_metrics (m_context
, m_fontdesc
, pango_context_get_language(m_context
));
1845 wxCHECK_MSG( metrics
, -1, _T("failed to get pango font metrics") );
1847 wxCoord h
= PANGO_PIXELS (pango_font_metrics_get_descent (metrics
) +
1848 pango_font_metrics_get_ascent (metrics
));
1849 pango_font_metrics_unref (metrics
);
1853 void wxWindowDCImpl
::Clear()
1855 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1857 if (!m_gdkwindow
) return;
1860 DoGetSize( &width
, &height
);
1861 gdk_draw_rectangle( m_gdkwindow
, m_bgGC
, TRUE
, 0, 0, width
, height
);
1864 void wxWindowDCImpl
::SetFont( const wxFont
&font
)
1871 pango_font_description_free( m_fontdesc
);
1873 m_fontdesc
= pango_font_description_copy( m_font
.GetNativeFontInfo()->description
);
1878 PangoContext
*oldContext
= m_context
;
1880 m_context
= m_window
->GtkGetPangoDefaultContext();
1882 // If we switch back/forth between different contexts
1883 // we also have to create a new layout. I think so,
1884 // at least, and it doesn't hurt to do it.
1885 if (oldContext
!= m_context
)
1888 g_object_unref (m_layout
);
1890 m_layout
= pango_layout_new( m_context
);
1894 pango_layout_set_font_description( m_layout
, m_fontdesc
);
1898 void wxWindowDCImpl
::SetPen( const wxPen
&pen
)
1900 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1902 if (m_pen
== pen
) return;
1906 if (!m_pen
.IsOk()) return;
1908 if (!m_gdkwindow
) return;
1910 gint width
= m_pen
.GetWidth();
1913 // CMB: if width is non-zero scale it with the dc
1918 // X doesn't allow different width in x and y and so we take
1921 ( fabs((double) XLOG2DEVREL(width
)) +
1922 fabs((double) YLOG2DEVREL(width
)) ) / 2.0;
1926 // width can't be 0 or an internal GTK error occurs inside
1927 // gdk_gc_set_dashes() below
1932 static const wxGTKDash dotted
[] = {1, 1};
1933 static const wxGTKDash short_dashed
[] = {2, 2};
1934 static const wxGTKDash wxCoord_dashed
[] = {2, 4};
1935 static const wxGTKDash dotted_dashed
[] = {3, 3, 1, 3};
1937 // We express dash pattern in pen width unit, so we are
1938 // independent of zoom factor and so on...
1940 const wxGTKDash
*req_dash
;
1942 GdkLineStyle lineStyle
= GDK_LINE_SOLID
;
1943 switch (m_pen
.GetStyle())
1947 lineStyle
= GDK_LINE_ON_OFF_DASH
;
1948 req_nb_dash
= m_pen
.GetDashCount();
1949 req_dash
= (wxGTKDash
*)m_pen
.GetDash();
1954 lineStyle
= GDK_LINE_ON_OFF_DASH
;
1961 lineStyle
= GDK_LINE_ON_OFF_DASH
;
1963 req_dash
= wxCoord_dashed
;
1968 lineStyle
= GDK_LINE_ON_OFF_DASH
;
1970 req_dash
= short_dashed
;
1975 // lineStyle = GDK_LINE_DOUBLE_DASH;
1976 lineStyle
= GDK_LINE_ON_OFF_DASH
;
1978 req_dash
= dotted_dashed
;
1983 case wxSTIPPLE_MASK_OPAQUE
:
1988 lineStyle
= GDK_LINE_SOLID
;
1989 req_dash
= (wxGTKDash
*)NULL
;
1995 if (req_dash
&& req_nb_dash
)
1997 wxGTKDash
*real_req_dash
= new wxGTKDash
[req_nb_dash
];
2000 for (int i
= 0; i
< req_nb_dash
; i
++)
2001 real_req_dash
[i
] = req_dash
[i
] * width
;
2002 gdk_gc_set_dashes( m_penGC
, 0, real_req_dash
, req_nb_dash
);
2003 delete[] real_req_dash
;
2007 // No Memory. We use non-scaled dash pattern...
2008 gdk_gc_set_dashes( m_penGC
, 0, (wxGTKDash
*)req_dash
, req_nb_dash
);
2012 GdkCapStyle capStyle
= GDK_CAP_ROUND
;
2013 switch (m_pen
.GetCap())
2015 case wxCAP_PROJECTING
: { capStyle
= GDK_CAP_PROJECTING
; break; }
2016 case wxCAP_BUTT
: { capStyle
= GDK_CAP_BUTT
; break; }
2023 capStyle
= GDK_CAP_NOT_LAST
;
2027 capStyle
= GDK_CAP_ROUND
;
2033 GdkJoinStyle joinStyle
= GDK_JOIN_ROUND
;
2034 switch (m_pen
.GetJoin())
2036 case wxJOIN_BEVEL
: { joinStyle
= GDK_JOIN_BEVEL
; break; }
2037 case wxJOIN_MITER
: { joinStyle
= GDK_JOIN_MITER
; break; }
2039 default: { joinStyle
= GDK_JOIN_ROUND
; break; }
2042 gdk_gc_set_line_attributes( m_penGC
, width
, lineStyle
, capStyle
, joinStyle
);
2044 m_pen
.GetColour().CalcPixel( m_cmap
);
2045 gdk_gc_set_foreground( m_penGC
, m_pen
.GetColour().GetColor() );
2048 void wxWindowDCImpl
::SetBrush( const wxBrush
&brush
)
2050 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2052 if (m_brush
== brush
) return;
2056 if (!m_brush
.IsOk()) return;
2058 if (!m_gdkwindow
) return;
2060 m_brush
.GetColour().CalcPixel( m_cmap
);
2061 gdk_gc_set_foreground( m_brushGC
, m_brush
.GetColour().GetColor() );
2063 gdk_gc_set_fill( m_brushGC
, GDK_SOLID
);
2065 if ((m_brush
.GetStyle() == wxSTIPPLE
) && (m_brush
.GetStipple()->IsOk()))
2067 if (m_brush
.GetStipple()->GetDepth() != 1)
2069 gdk_gc_set_fill( m_brushGC
, GDK_TILED
);
2070 gdk_gc_set_tile( m_brushGC
, m_brush
.GetStipple()->GetPixmap() );
2074 gdk_gc_set_fill( m_brushGC
, GDK_STIPPLED
);
2075 gdk_gc_set_stipple( m_brushGC
, m_brush
.GetStipple()->GetPixmap() );
2079 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
2081 gdk_gc_set_fill( m_textGC
, GDK_OPAQUE_STIPPLED
);
2082 gdk_gc_set_stipple( m_textGC
, m_brush
.GetStipple()->GetMask()->GetBitmap() );
2085 if (m_brush
.IsHatch())
2087 gdk_gc_set_fill( m_brushGC
, GDK_STIPPLED
);
2088 int num
= m_brush
.GetStyle() - wxBDIAGONAL_HATCH
;
2089 gdk_gc_set_stipple( m_brushGC
, hatches
[num
] );
2093 void wxWindowDCImpl
::SetBackground( const wxBrush
&brush
)
2095 /* CMB 21/7/98: Added SetBackground. Sets background brush
2096 * for Clear() and bg colour for shapes filled with cross-hatch brush */
2098 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2100 if (m_backgroundBrush
== brush
) return;
2102 m_backgroundBrush
= brush
;
2104 if (!m_backgroundBrush
.IsOk()) return;
2106 if (!m_gdkwindow
) return;
2108 m_backgroundBrush
.GetColour().CalcPixel( m_cmap
);
2109 gdk_gc_set_background( m_brushGC
, m_backgroundBrush
.GetColour().GetColor() );
2110 gdk_gc_set_background( m_penGC
, m_backgroundBrush
.GetColour().GetColor() );
2111 gdk_gc_set_background( m_bgGC
, m_backgroundBrush
.GetColour().GetColor() );
2112 gdk_gc_set_foreground( m_bgGC
, m_backgroundBrush
.GetColour().GetColor() );
2114 gdk_gc_set_fill( m_bgGC
, GDK_SOLID
);
2116 if ((m_backgroundBrush
.GetStyle() == wxSTIPPLE
) && (m_backgroundBrush
.GetStipple()->IsOk()))
2118 if (m_backgroundBrush
.GetStipple()->GetDepth() != 1)
2120 gdk_gc_set_fill( m_bgGC
, GDK_TILED
);
2121 gdk_gc_set_tile( m_bgGC
, m_backgroundBrush
.GetStipple()->GetPixmap() );
2125 gdk_gc_set_fill( m_bgGC
, GDK_STIPPLED
);
2126 gdk_gc_set_stipple( m_bgGC
, m_backgroundBrush
.GetStipple()->GetPixmap() );
2130 if (m_backgroundBrush
.IsHatch())
2132 gdk_gc_set_fill( m_bgGC
, GDK_STIPPLED
);
2133 int num
= m_backgroundBrush
.GetStyle() - wxBDIAGONAL_HATCH
;
2134 gdk_gc_set_stipple( m_bgGC
, hatches
[num
] );
2138 void wxWindowDCImpl
::SetLogicalFunction( int function
)
2140 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2142 if (m_logicalFunction
== function
)
2145 // VZ: shouldn't this be a CHECK?
2152 case wxXOR
: mode
= GDK_XOR
; break;
2153 case wxINVERT
: mode
= GDK_INVERT
; break;
2154 case wxOR_REVERSE
: mode
= GDK_OR_REVERSE
; break;
2155 case wxAND_REVERSE
: mode
= GDK_AND_REVERSE
; break;
2156 case wxCLEAR
: mode
= GDK_CLEAR
; break;
2157 case wxSET
: mode
= GDK_SET
; break;
2158 case wxOR_INVERT
: mode
= GDK_OR_INVERT
; break;
2159 case wxAND
: mode
= GDK_AND
; break;
2160 case wxOR
: mode
= GDK_OR
; break;
2161 case wxEQUIV
: mode
= GDK_EQUIV
; break;
2162 case wxNAND
: mode
= GDK_NAND
; break;
2163 case wxAND_INVERT
: mode
= GDK_AND_INVERT
; break;
2164 case wxCOPY
: mode
= GDK_COPY
; break;
2165 case wxNO_OP
: mode
= GDK_NOOP
; break;
2166 case wxSRC_INVERT
: mode
= GDK_COPY_INVERT
; break;
2168 // unsupported by GTK
2169 case wxNOR
: mode
= GDK_COPY
; break;
2171 wxFAIL_MSG( wxT("unsupported logical function") );
2175 m_logicalFunction
= function
;
2177 gdk_gc_set_function( m_penGC
, mode
);
2178 gdk_gc_set_function( m_brushGC
, mode
);
2180 // to stay compatible with wxMSW, we don't apply ROPs to the text
2181 // operations (i.e. DrawText/DrawRotatedText).
2182 // True, but mono-bitmaps use the m_textGC and they use ROPs as well.
2183 gdk_gc_set_function( m_textGC
, mode
);
2186 void wxWindowDCImpl
::SetTextForeground( const wxColour
&col
)
2188 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2190 // don't set m_textForegroundColour to an invalid colour as we'd crash
2191 // later then (we use m_textForegroundColour.GetColor() without checking
2193 if ( !col
.IsOk() || (m_textForegroundColour
== col
) )
2196 m_textForegroundColour
= col
;
2200 m_textForegroundColour
.CalcPixel( m_cmap
);
2201 gdk_gc_set_foreground( m_textGC
, m_textForegroundColour
.GetColor() );
2205 void wxWindowDCImpl
::SetTextBackground( const wxColour
&col
)
2207 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2210 if ( !col
.IsOk() || (m_textBackgroundColour
== col
) )
2213 m_textBackgroundColour
= col
;
2217 m_textBackgroundColour
.CalcPixel( m_cmap
);
2218 gdk_gc_set_background( m_textGC
, m_textBackgroundColour
.GetColor() );
2222 void wxWindowDCImpl
::SetBackgroundMode( int mode
)
2224 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2226 m_backgroundMode
= mode
;
2228 if (!m_gdkwindow
) return;
2230 // CMB 21/7/98: fill style of cross-hatch brushes is affected by
2231 // transparent/solid background mode
2233 if (m_brush
.GetStyle() != wxSOLID
&& m_brush
.GetStyle() != wxTRANSPARENT
)
2235 gdk_gc_set_fill( m_brushGC
,
2236 (m_backgroundMode
== wxTRANSPARENT
) ? GDK_STIPPLED
: GDK_OPAQUE_STIPPLED
);
2240 void wxWindowDCImpl
::SetPalette( const wxPalette
& WXUNUSED(palette
) )
2242 wxFAIL_MSG( wxT("wxWindowDCImpl::SetPalette not implemented") );
2245 void wxWindowDCImpl
::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
2247 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2249 if (!m_gdkwindow
) return;
2252 rect
.x
= XLOG2DEV(x
);
2253 rect
.y
= YLOG2DEV(y
);
2254 rect
.width
= XLOG2DEVREL(width
);
2255 rect
.height
= YLOG2DEVREL(height
);
2257 if (m_window
&& m_window
->m_wxwindow
&&
2258 (m_window
->GetLayoutDirection() == wxLayout_RightToLeft
))
2260 rect
.x
-= rect
.width
;
2263 if (!m_currentClippingRegion
.IsNull())
2264 m_currentClippingRegion
.Intersect( rect
);
2266 m_currentClippingRegion
.Union( rect
);
2268 #if USE_PAINT_REGION
2269 if (!m_paintClippingRegion
.IsNull())
2270 m_currentClippingRegion
.Intersect( m_paintClippingRegion
);
2273 wxCoord xx
, yy
, ww
, hh
;
2274 m_currentClippingRegion
.GetBox( xx
, yy
, ww
, hh
);
2276 wxGTKDCImpl
::DoSetClippingRegion( xx
, yy
, ww
, hh
);
2278 wxDC
::DoSetClippingRegion( xx
, yy
, ww
, hh
);
2281 gdk_gc_set_clip_region( m_penGC
, m_currentClippingRegion
.GetRegion() );
2282 gdk_gc_set_clip_region( m_brushGC
, m_currentClippingRegion
.GetRegion() );
2283 gdk_gc_set_clip_region( m_textGC
, m_currentClippingRegion
.GetRegion() );
2284 gdk_gc_set_clip_region( m_bgGC
, m_currentClippingRegion
.GetRegion() );
2287 void wxWindowDCImpl
::DoSetClippingRegionAsRegion( const wxRegion
®ion
)
2289 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2293 DestroyClippingRegion();
2297 if (!m_gdkwindow
) return;
2299 if (!m_currentClippingRegion
.IsNull())
2300 m_currentClippingRegion
.Intersect( region
);
2302 m_currentClippingRegion
.Union( region
);
2304 #if USE_PAINT_REGION
2305 if (!m_paintClippingRegion
.IsNull())
2306 m_currentClippingRegion
.Intersect( m_paintClippingRegion
);
2309 wxCoord xx
, yy
, ww
, hh
;
2310 m_currentClippingRegion
.GetBox( xx
, yy
, ww
, hh
);
2312 wxGTKDCImpl
::DoSetClippingRegion( xx
, yy
, ww
, hh
);
2314 wxDC
::DoSetClippingRegion( xx
, yy
, ww
, hh
);
2317 gdk_gc_set_clip_region( m_penGC
, m_currentClippingRegion
.GetRegion() );
2318 gdk_gc_set_clip_region( m_brushGC
, m_currentClippingRegion
.GetRegion() );
2319 gdk_gc_set_clip_region( m_textGC
, m_currentClippingRegion
.GetRegion() );
2320 gdk_gc_set_clip_region( m_bgGC
, m_currentClippingRegion
.GetRegion() );
2323 void wxWindowDCImpl
::DestroyClippingRegion()
2325 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2328 wxDCImpl
::DestroyClippingRegion();
2330 wxDC
::DestroyClippingRegion();
2333 m_currentClippingRegion
.Clear();
2335 #if USE_PAINT_REGION
2336 if (!m_paintClippingRegion
.IsEmpty())
2337 m_currentClippingRegion
.Union( m_paintClippingRegion
);
2340 if (!m_gdkwindow
) return;
2342 if (m_currentClippingRegion
.IsEmpty())
2344 gdk_gc_set_clip_rectangle( m_penGC
, (GdkRectangle
*) NULL
);
2345 gdk_gc_set_clip_rectangle( m_brushGC
, (GdkRectangle
*) NULL
);
2346 gdk_gc_set_clip_rectangle( m_textGC
, (GdkRectangle
*) NULL
);
2347 gdk_gc_set_clip_rectangle( m_bgGC
, (GdkRectangle
*) NULL
);
2351 gdk_gc_set_clip_region( m_penGC
, m_currentClippingRegion
.GetRegion() );
2352 gdk_gc_set_clip_region( m_brushGC
, m_currentClippingRegion
.GetRegion() );
2353 gdk_gc_set_clip_region( m_textGC
, m_currentClippingRegion
.GetRegion() );
2354 gdk_gc_set_clip_region( m_bgGC
, m_currentClippingRegion
.GetRegion() );
2358 void wxWindowDCImpl
::Destroy()
2360 if (m_penGC
) wxFreePoolGC( m_penGC
);
2361 m_penGC
= (GdkGC
*) NULL
;
2362 if (m_brushGC
) wxFreePoolGC( m_brushGC
);
2363 m_brushGC
= (GdkGC
*) NULL
;
2364 if (m_textGC
) wxFreePoolGC( m_textGC
);
2365 m_textGC
= (GdkGC
*) NULL
;
2366 if (m_bgGC
) wxFreePoolGC( m_bgGC
);
2367 m_bgGC
= (GdkGC
*) NULL
;
2370 void wxWindowDCImpl
::SetDeviceOrigin( wxCoord x
, wxCoord y
)
2372 m_deviceOriginX
= x
;
2373 m_deviceOriginY
= y
;
2375 ComputeScaleAndOrigin();
2378 void wxWindowDCImpl
::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
2380 m_signX
= (xLeftRight ?
1 : -1);
2381 m_signY
= (yBottomUp ?
-1 : 1);
2383 if (m_window
&& m_window
->m_wxwindow
&&
2384 (m_window
->GetLayoutDirection() == wxLayout_RightToLeft
))
2387 ComputeScaleAndOrigin();
2390 void wxWindowDCImpl
::ComputeScaleAndOrigin()
2392 const wxRealPoint
origScale(m_scaleX
, m_scaleY
);
2395 wxDCImpl
::ComputeScaleAndOrigin();
2397 wxDC
::ComputeScaleAndOrigin();
2400 // if scale has changed call SetPen to recalulate the line width
2401 if ( wxRealPoint(m_scaleX
, m_scaleY
) != origScale
&& m_pen
.IsOk() )
2403 // this is a bit artificial, but we need to force wxDC to think the pen
2411 // Resolution in pixels per logical inch
2412 wxSize wxWindowDCImpl
::GetPPI() const
2414 return wxSize( (int) (m_mm_to_pix_x
* 25.4 + 0.5), (int) (m_mm_to_pix_y
* 25.4 + 0.5));
2417 int wxWindowDCImpl
::GetDepth() const
2419 return gdk_drawable_get_depth(m_gdkwindow
);
2423 //-----------------------------------------------------------------------------
2425 //-----------------------------------------------------------------------------
2427 IMPLEMENT_ABSTRACT_CLASS(wxClientDCImpl
, wxWindowDCImpl
)
2429 wxClientDCImpl
::wxClientDCImpl( wxDC
*owner
)
2430 : wxWindowDCImpl( owner
)
2434 wxClientDCImpl
::wxClientDCImpl( wxDC
*owner
, wxWindow
*win
)
2435 : wxWindowDCImpl( owner
, win
)
2437 wxCHECK_RET( win
, _T("NULL window in wxClientDCImpl::wxClientDC") );
2439 #ifdef __WXUNIVERSAL__
2440 wxPoint ptOrigin
= win
->GetClientAreaOrigin();
2441 SetDeviceOrigin(ptOrigin
.x
, ptOrigin
.y
);
2442 wxSize size
= win
->GetClientSize();
2443 DoSetClippingRegion(0, 0, size
.x
, size
.y
);
2448 void wxClientDCImpl
::DoGetSize(int *width
, int *height
) const
2450 wxCHECK_RET( m_window
, _T("GetSize() doesn't work without window") );
2452 m_window
->GetClientSize( width
, height
);
2455 //-----------------------------------------------------------------------------
2457 //-----------------------------------------------------------------------------
2459 IMPLEMENT_ABSTRACT_CLASS(wxPaintDCImpl
, wxClientDCImpl
)
2461 // Limit the paint region to the window size. Sometimes
2462 // the paint region is too big, and this risks X11 errors
2463 static void wxLimitRegionToSize(wxRegion
& region
, const wxSize
& sz
)
2465 wxRect originalRect
= region
.GetBox();
2466 wxRect
rect(originalRect
);
2467 if (rect
.width
+ rect
.x
> sz
.x
)
2468 rect
.width
= sz
.x
- rect
.x
;
2469 if (rect
.height
+ rect
.y
> sz
.y
)
2470 rect
.height
= sz
.y
- rect
.y
;
2471 if (rect
!= originalRect
)
2473 region
= wxRegion(rect
);
2474 wxLogTrace(wxT("painting"), wxT("Limiting region from %d, %d, %d, %d to %d, %d, %d, %d\n"),
2475 originalRect
.x
, originalRect
.y
, originalRect
.width
, originalRect
.height
,
2476 rect
.x
, rect
.y
, rect
.width
, rect
.height
);
2480 wxPaintDCImpl
::wxPaintDCImpl( wxDC
*owner
)
2481 : wxClientDCImpl( owner
)
2485 wxPaintDCImpl
::wxPaintDCImpl( wxDC
*owner
, wxWindow
*win
)
2486 : wxClientDCImpl( owner
, win
)
2488 #if USE_PAINT_REGION
2489 if (!win
->m_clipPaintRegion
)
2492 wxSize sz
= win
->GetSize();
2493 m_paintClippingRegion
= win
->m_nativeUpdateRegion
;
2494 wxLimitRegionToSize(m_paintClippingRegion
, sz
);
2496 GdkRegion
*region
= m_paintClippingRegion
.GetRegion();
2499 m_currentClippingRegion
.Union( m_paintClippingRegion
);
2500 wxLimitRegionToSize(m_currentClippingRegion
, sz
);
2502 if (sz
.x
<= 0 || sz
.y
<= 0)
2505 gdk_gc_set_clip_region( m_penGC
, region
);
2506 gdk_gc_set_clip_region( m_brushGC
, region
);
2507 gdk_gc_set_clip_region( m_textGC
, region
);
2508 gdk_gc_set_clip_region( m_bgGC
, region
);
2513 // ----------------------------------------------------------------------------
2515 // ----------------------------------------------------------------------------
2517 class wxDCModule
: public wxModule
2524 DECLARE_DYNAMIC_CLASS(wxDCModule
)
2527 IMPLEMENT_DYNAMIC_CLASS(wxDCModule
, wxModule
)
2529 bool wxDCModule
::OnInit()
2535 void wxDCModule
::OnExit()