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
18 #include "wx/dcclient.h"
21 #include "wx/window.h"
23 #include "wx/dcmemory.h"
24 #include "wx/math.h" // for floating-point functions
26 #include "wx/module.h"
29 #include "wx/fontutil.h"
30 #include "wx/scrolwin.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 //-----------------------------------------------------------------------------
254 IMPLEMENT_ABSTRACT_CLASS(wxWindowDCImpl
, wxGTKDCImpl
)
256 wxWindowDCImpl::wxWindowDCImpl( wxDC
*owner
) :
259 m_gdkwindow
= (GdkWindow
*) NULL
;
260 m_penGC
= (GdkGC
*) NULL
;
261 m_brushGC
= (GdkGC
*) NULL
;
262 m_textGC
= (GdkGC
*) NULL
;
263 m_bgGC
= (GdkGC
*) NULL
;
264 m_cmap
= (GdkColormap
*) NULL
;
265 m_isScreenDC
= false;
266 m_context
= (PangoContext
*)NULL
;
267 m_layout
= (PangoLayout
*)NULL
;
268 m_fontdesc
= (PangoFontDescription
*)NULL
;
271 wxWindowDCImpl::wxWindowDCImpl( wxDC
*owner
, wxWindow
*window
) :
274 wxASSERT_MSG( window
, wxT("DC needs a window") );
276 m_gdkwindow
= (GdkWindow
*) NULL
;
277 m_penGC
= (GdkGC
*) NULL
;
278 m_brushGC
= (GdkGC
*) NULL
;
279 m_textGC
= (GdkGC
*) NULL
;
280 m_bgGC
= (GdkGC
*) NULL
;
281 m_cmap
= (GdkColormap
*) NULL
;
282 m_isScreenDC
= false;
283 m_font
= window
->GetFont();
285 GtkWidget
*widget
= window
->m_wxwindow
;
287 // Some controls don't have m_wxwindow - like wxStaticBox, but the user
288 // code should still be able to create wxClientDCs for them, so we will
289 // use the parent window here then.
292 window
= window
->GetParent();
293 widget
= window
->m_wxwindow
;
296 wxASSERT_MSG( widget
, wxT("DC needs a widget") );
298 m_context
= window
->GtkGetPangoDefaultContext();
299 m_layout
= pango_layout_new( m_context
);
300 m_fontdesc
= pango_font_description_copy( widget
->style
->font_desc
);
302 m_gdkwindow
= widget
->window
;
304 // Window not realized ?
307 // Don't report problems as per MSW.
313 m_cmap
= gtk_widget_get_colormap( widget
? widget
: window
->m_widget
);
317 /* this must be done after SetUpDC, bacause SetUpDC calls the
318 repective SetBrush, SetPen, SetBackground etc functions
319 to set up the DC. SetBackground call m_owner->SetBackground
320 and this might not be desired as the standard dc background
321 is white whereas a window might assume gray to be the
322 standard (as e.g. wxStatusBar) */
326 if (m_window
&& m_window
->m_wxwindow
&&
327 (m_window
->GetLayoutDirection() == wxLayout_RightToLeft
))
332 // origin in the upper right corner
333 m_deviceOriginX
= m_window
->GetClientSize().x
;
337 wxWindowDCImpl::~wxWindowDCImpl()
342 g_object_unref (m_layout
);
344 pango_font_description_free( m_fontdesc
);
347 void wxWindowDCImpl::SetUpDC( bool isMemDC
)
351 wxASSERT_MSG( !m_penGC
, wxT("GCs already created") );
355 if ((isMemDC
) && (GetSelectedBitmap().IsOk()))
357 if (GetSelectedBitmap().GetDepth() == 1)
359 m_penGC
= wxGetPoolGC( m_gdkwindow
, wxPEN_MONO
);
360 m_brushGC
= wxGetPoolGC( m_gdkwindow
, wxBRUSH_MONO
);
361 m_textGC
= wxGetPoolGC( m_gdkwindow
, wxTEXT_MONO
);
362 m_bgGC
= wxGetPoolGC( m_gdkwindow
, wxBG_MONO
);
371 m_penGC
= wxGetPoolGC( m_gdkwindow
, wxPEN_SCREEN
);
372 m_brushGC
= wxGetPoolGC( m_gdkwindow
, wxBRUSH_SCREEN
);
373 m_textGC
= wxGetPoolGC( m_gdkwindow
, wxTEXT_SCREEN
);
374 m_bgGC
= wxGetPoolGC( m_gdkwindow
, wxBG_SCREEN
);
378 m_penGC
= wxGetPoolGC( m_gdkwindow
, wxPEN_COLOUR
);
379 m_brushGC
= wxGetPoolGC( m_gdkwindow
, wxBRUSH_COLOUR
);
380 m_textGC
= wxGetPoolGC( m_gdkwindow
, wxTEXT_COLOUR
);
381 m_bgGC
= wxGetPoolGC( m_gdkwindow
, wxBG_COLOUR
);
385 /* background colour */
386 m_backgroundBrush
= *wxWHITE_BRUSH
;
387 m_backgroundBrush
.GetColour().CalcPixel( m_cmap
);
388 const GdkColor
*bg_col
= m_backgroundBrush
.GetColour().GetColor();
391 m_textForegroundColour
.CalcPixel( m_cmap
);
392 gdk_gc_set_foreground( m_textGC
, m_textForegroundColour
.GetColor() );
394 m_textBackgroundColour
.CalcPixel( m_cmap
);
395 gdk_gc_set_background( m_textGC
, m_textBackgroundColour
.GetColor() );
397 gdk_gc_set_fill( m_textGC
, GDK_SOLID
);
399 gdk_gc_set_colormap( m_textGC
, m_cmap
);
402 m_pen
.GetColour().CalcPixel( m_cmap
);
403 gdk_gc_set_foreground( m_penGC
, m_pen
.GetColour().GetColor() );
404 gdk_gc_set_background( m_penGC
, bg_col
);
406 gdk_gc_set_line_attributes( m_penGC
, 0, GDK_LINE_SOLID
, GDK_CAP_NOT_LAST
, GDK_JOIN_ROUND
);
409 m_brush
.GetColour().CalcPixel( m_cmap
);
410 gdk_gc_set_foreground( m_brushGC
, m_brush
.GetColour().GetColor() );
411 gdk_gc_set_background( m_brushGC
, bg_col
);
413 gdk_gc_set_fill( m_brushGC
, GDK_SOLID
);
416 gdk_gc_set_background( m_bgGC
, bg_col
);
417 gdk_gc_set_foreground( m_bgGC
, bg_col
);
419 gdk_gc_set_fill( m_bgGC
, GDK_SOLID
);
422 gdk_gc_set_function( m_textGC
, GDK_COPY
);
423 gdk_gc_set_function( m_brushGC
, GDK_COPY
);
424 gdk_gc_set_function( m_penGC
, GDK_COPY
);
427 gdk_gc_set_clip_rectangle( m_penGC
, (GdkRectangle
*) NULL
);
428 gdk_gc_set_clip_rectangle( m_brushGC
, (GdkRectangle
*) NULL
);
429 gdk_gc_set_clip_rectangle( m_textGC
, (GdkRectangle
*) NULL
);
430 gdk_gc_set_clip_rectangle( m_bgGC
, (GdkRectangle
*) NULL
);
434 hatch_bitmap
= hatches
;
435 hatch_bitmap
[0] = gdk_bitmap_create_from_data( (GdkWindow
*) NULL
, bdiag_bits
, bdiag_width
, bdiag_height
);
436 hatch_bitmap
[1] = gdk_bitmap_create_from_data( (GdkWindow
*) NULL
, cdiag_bits
, cdiag_width
, cdiag_height
);
437 hatch_bitmap
[2] = gdk_bitmap_create_from_data( (GdkWindow
*) NULL
, fdiag_bits
, fdiag_width
, fdiag_height
);
438 hatch_bitmap
[3] = gdk_bitmap_create_from_data( (GdkWindow
*) NULL
, cross_bits
, cross_width
, cross_height
);
439 hatch_bitmap
[4] = gdk_bitmap_create_from_data( (GdkWindow
*) NULL
, horiz_bits
, horiz_width
, horiz_height
);
440 hatch_bitmap
[5] = gdk_bitmap_create_from_data( (GdkWindow
*) NULL
, verti_bits
, verti_width
, verti_height
);
444 void wxWindowDCImpl::DoGetSize( int* width
, int* height
) const
446 wxCHECK_RET( m_window
, _T("GetSize() doesn't work without window") );
448 m_window
->GetSize(width
, height
);
451 bool wxWindowDCImpl::DoFloodFill(wxCoord x
, wxCoord y
,
452 const wxColour
& col
, int style
)
455 extern bool wxDoFloodFill(wxDC
*dc
, wxCoord x
, wxCoord y
,
456 const wxColour
& col
, int style
);
458 return wxDoFloodFill( GetOwner(), x
, y
, col
, style
);
469 bool wxWindowDCImpl::DoGetPixel( wxCoord x1
, wxCoord y1
, wxColour
*col
) const
472 // Generic (and therefore rather inefficient) method.
473 // Could be improved.
475 wxBitmap
bitmap(1, 1);
476 memdc
.SelectObject(bitmap
);
477 memdc
.Blit(0, 0, 1, 1, GetOwner(), x1
, y1
);
478 memdc
.SelectObject(wxNullBitmap
);
480 wxImage image
= bitmap
.ConvertToImage();
481 col
->Set(image
.GetRed(0, 0), image
.GetGreen(0, 0), image
.GetBlue(0, 0));
483 #else // !wxUSE_IMAGE
489 #endif // wxUSE_IMAGE/!wxUSE_IMAGE
492 void wxWindowDCImpl::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
494 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
496 if (m_pen
.GetStyle() != wxTRANSPARENT
)
499 gdk_draw_line( m_gdkwindow
, m_penGC
, XLOG2DEV(x1
), YLOG2DEV(y1
), XLOG2DEV(x2
), YLOG2DEV(y2
) );
501 CalcBoundingBox(x1
, y1
);
502 CalcBoundingBox(x2
, y2
);
506 void wxWindowDCImpl::DoCrossHair( wxCoord x
, wxCoord y
)
508 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
510 if (m_pen
.GetStyle() != wxTRANSPARENT
)
514 GetOwner()->GetSize( &w
, &h
);
515 wxCoord xx
= XLOG2DEV(x
);
516 wxCoord yy
= YLOG2DEV(y
);
519 gdk_draw_line( m_gdkwindow
, m_penGC
, 0, yy
, XLOG2DEVREL(w
), yy
);
520 gdk_draw_line( m_gdkwindow
, m_penGC
, xx
, 0, xx
, YLOG2DEVREL(h
) );
525 void wxWindowDCImpl::DoDrawArc( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
526 wxCoord xc
, wxCoord yc
)
528 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
530 wxCoord xx1
= XLOG2DEV(x1
);
531 wxCoord yy1
= YLOG2DEV(y1
);
532 wxCoord xx2
= XLOG2DEV(x2
);
533 wxCoord yy2
= YLOG2DEV(y2
);
534 wxCoord xxc
= XLOG2DEV(xc
);
535 wxCoord yyc
= YLOG2DEV(yc
);
536 double dx
= xx1
- xxc
;
537 double dy
= yy1
- yyc
;
538 double radius
= sqrt((double)(dx
*dx
+dy
*dy
));
539 wxCoord r
= (wxCoord
)radius
;
540 double radius1
, radius2
;
542 if (xx1
== xx2
&& yy1
== yy2
)
547 else if ( wxIsNullDouble(radius
) )
554 radius1
= (xx1
- xxc
== 0) ?
555 (yy1
- yyc
< 0) ? 90.0 : -90.0 :
556 -atan2(double(yy1
-yyc
), double(xx1
-xxc
)) * RAD2DEG
;
557 radius2
= (xx2
- xxc
== 0) ?
558 (yy2
- yyc
< 0) ? 90.0 : -90.0 :
559 -atan2(double(yy2
-yyc
), double(xx2
-xxc
)) * RAD2DEG
;
561 wxCoord alpha1
= wxCoord(radius1
* 64.0);
562 wxCoord alpha2
= wxCoord((radius2
- radius1
) * 64.0);
563 while (alpha2
<= 0) alpha2
+= 360*64;
564 while (alpha1
> 360*64) alpha1
-= 360*64;
568 if (m_brush
.GetStyle() != wxTRANSPARENT
)
570 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
572 gdk_gc_set_ts_origin( m_textGC
,
573 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
574 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
575 gdk_draw_arc( m_gdkwindow
, m_textGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
576 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
578 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
580 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
581 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
582 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
584 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
586 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
587 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
588 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
590 if (m_brush
.GetStyle() == wxSTIPPLE
)
592 gdk_gc_set_ts_origin( m_brushGC
,
593 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
594 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
595 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
596 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
600 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
604 if (m_pen
.GetStyle() != wxTRANSPARENT
)
606 gdk_draw_arc( m_gdkwindow
, m_penGC
, FALSE
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
608 if ((m_brush
.GetStyle() != wxTRANSPARENT
) && (alpha2
- alpha1
!= 360*64))
610 gdk_draw_line( m_gdkwindow
, m_penGC
, xx1
, yy1
, xxc
, yyc
);
611 gdk_draw_line( m_gdkwindow
, m_penGC
, xxc
, yyc
, xx2
, yy2
);
616 CalcBoundingBox (x1
, y1
);
617 CalcBoundingBox (x2
, y2
);
620 void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double sa
, double ea
)
622 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
624 wxCoord xx
= XLOG2DEV(x
);
625 wxCoord yy
= YLOG2DEV(y
);
626 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
627 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
629 // CMB: handle -ve width and/or height
630 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
631 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
635 wxCoord start
= wxCoord(sa
* 64.0);
636 wxCoord end
= wxCoord((ea
-sa
) * 64.0);
638 if (m_brush
.GetStyle() != wxTRANSPARENT
)
640 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
642 gdk_gc_set_ts_origin( m_textGC
,
643 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
644 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
645 gdk_draw_arc( m_gdkwindow
, m_textGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
646 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
648 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
650 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
651 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
652 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
654 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
656 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
657 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
658 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
660 if (m_brush
.GetStyle() == wxSTIPPLE
)
662 gdk_gc_set_ts_origin( m_brushGC
,
663 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
664 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
665 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
666 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
670 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, start
, end
);
674 if (m_pen
.GetStyle() != wxTRANSPARENT
)
675 gdk_draw_arc( m_gdkwindow
, m_penGC
, FALSE
, xx
, yy
, ww
, hh
, start
, end
);
678 CalcBoundingBox (x
, y
);
679 CalcBoundingBox (x
+ width
, y
+ height
);
682 void wxWindowDCImpl::DoDrawPoint( wxCoord x
, wxCoord y
)
684 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
686 if ((m_pen
.GetStyle() != wxTRANSPARENT
) && m_gdkwindow
)
687 gdk_draw_point( m_gdkwindow
, m_penGC
, XLOG2DEV(x
), YLOG2DEV(y
) );
689 CalcBoundingBox (x
, y
);
692 void wxWindowDCImpl::DoDrawLines( int n
, wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
)
694 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
696 if (m_pen
.GetStyle() == wxTRANSPARENT
) return;
699 //Check, if scaling is necessary
701 xoffset
!= 0 || yoffset
!= 0 || XLOG2DEV(10) != 10 || YLOG2DEV(10) != 10;
703 // GdkPoint and wxPoint have the same memory layout, so we can cast one to the other
704 GdkPoint
* gpts
= reinterpret_cast<GdkPoint
*>(points
);
707 gpts
= new GdkPoint
[n
];
709 for (int i
= 0; i
< n
; i
++)
713 gpts
[i
].x
= XLOG2DEV(points
[i
].x
+ xoffset
);
714 gpts
[i
].y
= YLOG2DEV(points
[i
].y
+ yoffset
);
716 CalcBoundingBox(points
[i
].x
+ xoffset
, points
[i
].y
+ yoffset
);
720 gdk_draw_lines( m_gdkwindow
, m_penGC
, gpts
, n
);
726 void wxWindowDCImpl::DoDrawPolygon( int n
, wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
, int WXUNUSED(fillStyle
) )
728 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
732 //Check, if scaling is necessary
734 xoffset
!= 0 || yoffset
!= 0 || XLOG2DEV(10) != 10 || YLOG2DEV(10) != 10;
736 // GdkPoint and wxPoint have the same memory layout, so we can cast one to the other
737 GdkPoint
* gdkpoints
= reinterpret_cast<GdkPoint
*>(points
);
740 gdkpoints
= new GdkPoint
[n
];
743 for (i
= 0 ; i
< n
; i
++)
747 gdkpoints
[i
].x
= XLOG2DEV(points
[i
].x
+ xoffset
);
748 gdkpoints
[i
].y
= YLOG2DEV(points
[i
].y
+ yoffset
);
750 CalcBoundingBox(points
[i
].x
+ xoffset
, points
[i
].y
+ yoffset
);
755 if (m_brush
.GetStyle() != wxTRANSPARENT
)
757 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
759 gdk_gc_set_ts_origin( m_textGC
,
760 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
761 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
762 gdk_draw_polygon( m_gdkwindow
, m_textGC
, TRUE
, gdkpoints
, n
);
763 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
765 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
767 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
768 gdk_draw_polygon( m_gdkwindow
, m_brushGC
, TRUE
, gdkpoints
, n
);
769 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
771 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
773 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
774 gdk_draw_polygon( m_gdkwindow
, m_brushGC
, TRUE
, gdkpoints
, n
);
775 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
777 if (m_brush
.GetStyle() == wxSTIPPLE
)
779 gdk_gc_set_ts_origin( m_brushGC
,
780 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
781 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
782 gdk_draw_polygon( m_gdkwindow
, m_brushGC
, TRUE
, gdkpoints
, n
);
783 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
787 gdk_draw_polygon( m_gdkwindow
, m_brushGC
, TRUE
, gdkpoints
, n
);
791 if (m_pen
.GetStyle() != wxTRANSPARENT
)
794 for (i = 0 ; i < n ; i++)
796 gdk_draw_line( m_gdkwindow, m_penGC,
799 gdkpoints[(i+1)%n].x,
800 gdkpoints[(i+1)%n].y);
803 gdk_draw_polygon( m_gdkwindow
, m_penGC
, FALSE
, gdkpoints
, n
);
812 void wxWindowDCImpl::DoDrawRectangle( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
814 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
816 wxCoord xx
= XLOG2DEV(x
);
817 wxCoord yy
= YLOG2DEV(y
);
818 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
819 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
821 // CMB: draw nothing if transformed w or h is 0
822 if (ww
== 0 || hh
== 0) return;
824 // CMB: handle -ve width and/or height
825 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
826 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
830 if (m_brush
.GetStyle() != wxTRANSPARENT
)
832 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
834 gdk_gc_set_ts_origin( m_textGC
,
835 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
836 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
837 gdk_draw_rectangle( m_gdkwindow
, m_textGC
, TRUE
, xx
, yy
, ww
, hh
);
838 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
840 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
842 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
843 gdk_draw_rectangle( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
);
844 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
846 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
848 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
849 gdk_draw_rectangle( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
);
850 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
852 if (m_brush
.GetStyle() == wxSTIPPLE
)
854 gdk_gc_set_ts_origin( m_brushGC
,
855 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
856 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
857 gdk_draw_rectangle( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
);
858 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
862 gdk_draw_rectangle( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
);
866 if (m_pen
.GetStyle() != wxTRANSPARENT
)
869 if ((m_pen
.GetWidth() == 2) && (m_pen
.GetCap() == wxCAP_ROUND
) &&
870 (m_pen
.GetJoin() == wxJOIN_ROUND
) && (m_pen
.GetStyle() == wxSOLID
))
872 // Use 2 1-line rects instead
873 gdk_gc_set_line_attributes( m_penGC
, 1, GDK_LINE_SOLID
, GDK_CAP_ROUND
, GDK_JOIN_ROUND
);
878 gdk_draw_rectangle( m_gdkwindow
, m_penGC
, FALSE
, xx
+1, yy
, ww
-2, hh
-2 );
879 gdk_draw_rectangle( m_gdkwindow
, m_penGC
, FALSE
, xx
, yy
-1, ww
, hh
);
883 gdk_draw_rectangle( m_gdkwindow
, m_penGC
, FALSE
, xx
, yy
, ww
-2, hh
-2 );
884 gdk_draw_rectangle( m_gdkwindow
, m_penGC
, FALSE
, xx
-1, yy
-1, ww
, hh
);
888 gdk_gc_set_line_attributes( m_penGC
, 2, GDK_LINE_SOLID
, GDK_CAP_ROUND
, GDK_JOIN_ROUND
);
893 // Just use X11 for other cases
894 gdk_draw_rectangle( m_gdkwindow
, m_penGC
, FALSE
, xx
, yy
, ww
-1, hh
-1 );
899 CalcBoundingBox( x
, y
);
900 CalcBoundingBox( x
+ width
, y
+ height
);
903 void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double radius
)
905 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
907 if (radius
< 0.0) radius
= - radius
* ((width
< height
) ? width
: height
);
909 wxCoord xx
= XLOG2DEV(x
);
910 wxCoord yy
= YLOG2DEV(y
);
911 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
912 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
913 wxCoord rr
= XLOG2DEVREL((wxCoord
)radius
);
915 // CMB: handle -ve width and/or height
916 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
917 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
919 // CMB: if radius is zero use DrawRectangle() instead to avoid
920 // X drawing errors with small radii
923 DoDrawRectangle( x
, y
, width
, height
);
927 // CMB: draw nothing if transformed w or h is 0
928 if (ww
== 0 || hh
== 0) return;
930 // CMB: adjust size if outline is drawn otherwise the result is
931 // 1 pixel too wide and high
932 if (m_pen
.GetStyle() != wxTRANSPARENT
)
940 // CMB: ensure dd is not larger than rectangle otherwise we
941 // get an hour glass shape
943 if (dd
> ww
) dd
= ww
;
944 if (dd
> hh
) dd
= hh
;
947 if (m_brush
.GetStyle() != wxTRANSPARENT
)
949 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
951 gdk_gc_set_ts_origin( m_textGC
,
952 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
953 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
954 gdk_draw_rectangle( m_gdkwindow
, m_textGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
955 gdk_draw_rectangle( m_gdkwindow
, m_textGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
956 gdk_draw_arc( m_gdkwindow
, m_textGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
957 gdk_draw_arc( m_gdkwindow
, m_textGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
958 gdk_draw_arc( m_gdkwindow
, m_textGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
959 gdk_draw_arc( m_gdkwindow
, m_textGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
960 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
962 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
964 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
965 gdk_draw_rectangle( m_gdkwindow
, m_brushGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
966 gdk_draw_rectangle( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
967 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
968 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
969 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
970 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
971 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
973 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
975 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
976 gdk_draw_rectangle( m_gdkwindow
, m_brushGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
977 gdk_draw_rectangle( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
978 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
979 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
980 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
981 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
982 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
984 if (m_brush
.GetStyle() == wxSTIPPLE
)
986 gdk_gc_set_ts_origin( m_brushGC
,
987 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
988 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
989 gdk_draw_rectangle( m_gdkwindow
, m_brushGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
990 gdk_draw_rectangle( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
991 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
992 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
993 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
994 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
995 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
999 gdk_draw_rectangle( m_gdkwindow
, m_brushGC
, TRUE
, xx
+rr
, yy
, ww
-dd
+1, hh
);
1000 gdk_draw_rectangle( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
+rr
, ww
, hh
-dd
+1 );
1001 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
1002 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
1003 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
1004 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
1008 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1010 gdk_draw_line( m_gdkwindow
, m_penGC
, xx
+rr
+1, yy
, xx
+ww
-rr
, yy
);
1011 gdk_draw_line( m_gdkwindow
, m_penGC
, xx
+rr
+1, yy
+hh
, xx
+ww
-rr
, yy
+hh
);
1012 gdk_draw_line( m_gdkwindow
, m_penGC
, xx
, yy
+rr
+1, xx
, yy
+hh
-rr
);
1013 gdk_draw_line( m_gdkwindow
, m_penGC
, xx
+ww
, yy
+rr
+1, xx
+ww
, yy
+hh
-rr
);
1014 gdk_draw_arc( m_gdkwindow
, m_penGC
, FALSE
, xx
, yy
, dd
, dd
, 90*64, 90*64 );
1015 gdk_draw_arc( m_gdkwindow
, m_penGC
, FALSE
, xx
+ww
-dd
, yy
, dd
, dd
, 0, 90*64 );
1016 gdk_draw_arc( m_gdkwindow
, m_penGC
, FALSE
, xx
+ww
-dd
, yy
+hh
-dd
, dd
, dd
, 270*64, 90*64 );
1017 gdk_draw_arc( m_gdkwindow
, m_penGC
, FALSE
, xx
, yy
+hh
-dd
, dd
, dd
, 180*64, 90*64 );
1021 // this ignores the radius
1022 CalcBoundingBox( x
, y
);
1023 CalcBoundingBox( x
+ width
, y
+ height
);
1026 void wxWindowDCImpl::DoDrawEllipse( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1028 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1030 wxCoord xx
= XLOG2DEV(x
);
1031 wxCoord yy
= YLOG2DEV(y
);
1032 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1033 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1035 // CMB: handle -ve width and/or height
1036 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
1037 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
1041 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1043 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
1045 gdk_gc_set_ts_origin( m_textGC
,
1046 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
1047 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
1048 gdk_draw_arc( m_gdkwindow
, m_textGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1049 gdk_gc_set_ts_origin( m_textGC
, 0, 0 );
1051 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
1053 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
1054 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1055 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
1057 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
1059 gdk_gc_set_ts_origin( m_brushGC
, m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
1060 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1061 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
1063 if (m_brush
.GetStyle() == wxSTIPPLE
)
1065 gdk_gc_set_ts_origin( m_brushGC
,
1066 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
1067 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
1068 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1069 gdk_gc_set_ts_origin( m_brushGC
, 0, 0 );
1073 gdk_draw_arc( m_gdkwindow
, m_brushGC
, TRUE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1077 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1078 gdk_draw_arc( m_gdkwindow
, m_penGC
, FALSE
, xx
, yy
, ww
, hh
, 0, 360*64 );
1081 CalcBoundingBox( x
, y
);
1082 CalcBoundingBox( x
+ width
, y
+ height
);
1085 void wxWindowDCImpl::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
1087 // VZ: egcs 1.0.3 refuses to compile this without cast, no idea why
1088 DoDrawBitmap( (const wxBitmap
&)icon
, x
, y
, true );
1091 void wxWindowDCImpl::DoDrawBitmap( const wxBitmap
&bitmap
,
1092 wxCoord x
, wxCoord y
,
1095 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1097 wxCHECK_RET( bitmap
.IsOk(), wxT("invalid bitmap") );
1099 bool is_mono
= bitmap
.GetDepth() == 1;
1101 // scale/translate size and position
1102 int xx
= XLOG2DEV(x
);
1103 int yy
= YLOG2DEV(y
);
1105 int w
= bitmap
.GetWidth();
1106 int h
= bitmap
.GetHeight();
1108 if (m_window
&& m_window
->GetLayoutDirection() == wxLayout_RightToLeft
)
1111 CalcBoundingBox( x
, y
);
1112 CalcBoundingBox( x
+ w
, y
+ h
);
1114 if (!m_gdkwindow
) return;
1116 int ww
= XLOG2DEVREL(w
);
1117 int hh
= YLOG2DEVREL(h
);
1119 // compare to current clipping region
1120 if (!m_currentClippingRegion
.IsNull())
1122 wxRegion
tmp( xx
,yy
,ww
,hh
);
1123 tmp
.Intersect( m_currentClippingRegion
);
1128 // scale bitmap if required
1129 wxBitmap use_bitmap
= bitmap
;
1130 if ((w
!= ww
) || (h
!= hh
))
1131 use_bitmap
= use_bitmap
.Rescale( 0, 0, ww
, hh
, ww
, hh
);
1133 // apply mask if any
1134 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
1135 if (useMask
&& use_bitmap
.GetMask())
1136 mask
= use_bitmap
.GetMask()->GetBitmap();
1138 GdkGC
* use_gc
= is_mono
? m_textGC
: m_penGC
;
1140 GdkBitmap
*new_mask
= (GdkBitmap
*) NULL
;
1144 if (!m_currentClippingRegion
.IsNull())
1147 new_mask
= gdk_pixmap_new( wxGetRootWindow()->window
, ww
, hh
, 1 );
1148 GdkGC
*gc
= gdk_gc_new( new_mask
);
1150 gdk_gc_set_foreground( gc
, &col
);
1151 gdk_draw_rectangle( new_mask
, gc
, TRUE
, 0, 0, ww
, hh
);
1153 gdk_gc_set_background( gc
, &col
);
1155 gdk_gc_set_foreground( gc
, &col
);
1156 gdk_gc_set_clip_region( gc
, m_currentClippingRegion
.GetRegion() );
1157 gdk_gc_set_clip_origin( gc
, -xx
, -yy
);
1158 gdk_gc_set_fill( gc
, GDK_OPAQUE_STIPPLED
);
1159 gdk_gc_set_stipple( gc
, mask
);
1160 gdk_draw_rectangle( new_mask
, gc
, TRUE
, 0, 0, ww
, hh
);
1162 g_object_unref (gc
);
1165 gdk_gc_set_clip_mask(use_gc
, mask
);
1166 gdk_gc_set_clip_origin(use_gc
, xx
, yy
);
1169 // Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For
1170 // drawing a mono-bitmap (XBitmap) we use the current text GC
1173 GdkPixmap
*bitmap2
= gdk_pixmap_new( wxGetRootWindow()->window
, ww
, hh
, -1 );
1174 GdkGC
*gc
= gdk_gc_new( bitmap2
);
1175 gdk_gc_set_foreground( gc
, m_textForegroundColour
.GetColor() );
1176 gdk_gc_set_background( gc
, m_textBackgroundColour
.GetColor() );
1177 gdk_wx_draw_bitmap(bitmap2
, gc
, use_bitmap
.GetPixmap(), 0, 0);
1179 gdk_draw_drawable(m_gdkwindow
, use_gc
, bitmap2
, 0, 0, xx
, yy
, -1, -1);
1181 g_object_unref (bitmap2
);
1182 g_object_unref (gc
);
1186 if (use_bitmap
.HasPixbuf())
1188 gdk_draw_pixbuf(m_gdkwindow
, use_gc
,
1189 use_bitmap
.GetPixbuf(),
1190 0, 0, xx
, yy
, -1, -1,
1191 GDK_RGB_DITHER_NORMAL
, xx
, yy
);
1195 gdk_draw_drawable(m_gdkwindow
, use_gc
,
1196 use_bitmap
.GetPixmap(),
1197 0, 0, xx
, yy
, -1, -1);
1201 // remove mask again if any
1204 gdk_gc_set_clip_mask(use_gc
, NULL
);
1205 gdk_gc_set_clip_origin(use_gc
, 0, 0);
1206 if (!m_currentClippingRegion
.IsNull())
1207 gdk_gc_set_clip_region(use_gc
, m_currentClippingRegion
.GetRegion());
1208 if (new_mask
!= NULL
)
1209 g_object_unref(new_mask
);
1213 bool wxWindowDCImpl::DoBlit( wxCoord xdest
, wxCoord ydest
,
1214 wxCoord width
, wxCoord height
,
1216 wxCoord xsrc
, wxCoord ysrc
,
1219 wxCoord xsrcMask
, wxCoord ysrcMask
)
1221 wxCHECK_MSG( IsOk(), false, wxT("invalid window dc") );
1223 wxCHECK_MSG( source
, false, wxT("invalid source dc") );
1225 if (!m_gdkwindow
) return false;
1227 // transform the source DC coords to the device ones
1228 xsrc
= source
->LogicalToDeviceX(xsrc
);
1229 ysrc
= source
->LogicalToDeviceY(ysrc
);
1232 wxMemoryDC
*memDC
= wxDynamicCast(source
, wxMemoryDC
);
1235 selected
= memDC
->GetSelectedBitmap();
1236 if ( !selected
.IsOk() )
1240 bool use_bitmap_method
= false;
1241 bool is_mono
= false;
1243 if (xsrcMask
== -1 && ysrcMask
== -1)
1249 if (selected
.IsOk())
1251 is_mono
= (selected
.GetDepth() == 1);
1253 // we use the "XCopyArea" way to copy a memory dc into
1254 // a different window if the memory dc BOTH
1255 // a) doesn't have any mask or its mask isn't used
1259 if (useMask
&& (selected
.GetMask()))
1261 // we HAVE TO use the direct way for memory dcs
1262 // that have mask since the XCopyArea doesn't know
1264 use_bitmap_method
= true;
1268 // we HAVE TO use the direct way for memory dcs
1269 // that are bitmaps because XCopyArea doesn't cope
1270 // with different bit depths
1271 use_bitmap_method
= true;
1273 else if ((xsrc
== 0) && (ysrc
== 0) &&
1274 (width
== selected
.GetWidth()) &&
1275 (height
== selected
.GetHeight()))
1277 // we SHOULD use the direct way if all of the bitmap
1278 // in the memory dc is copied in which case XCopyArea
1279 // wouldn't be able able to boost performace by reducing
1280 // the area to be scaled
1281 use_bitmap_method
= true;
1285 CalcBoundingBox( xdest
, ydest
);
1286 CalcBoundingBox( xdest
+ width
, ydest
+ height
);
1288 // scale/translate size and position
1289 wxCoord xx
= XLOG2DEV(xdest
);
1290 wxCoord yy
= YLOG2DEV(ydest
);
1292 wxCoord ww
= XLOG2DEVREL(width
);
1293 wxCoord hh
= YLOG2DEVREL(height
);
1295 // compare to current clipping region
1296 if (!m_currentClippingRegion
.IsNull())
1298 wxRegion
tmp( xx
,yy
,ww
,hh
);
1299 tmp
.Intersect( m_currentClippingRegion
);
1304 int old_logical_func
= m_logicalFunction
;
1305 SetLogicalFunction( logical_func
);
1307 if (use_bitmap_method
)
1309 // scale/translate bitmap size
1310 wxCoord bm_width
= selected
.GetWidth();
1311 wxCoord bm_height
= selected
.GetHeight();
1313 // Get clip coords for the bitmap. If we don't
1314 // use wxBitmap::Rescale(), which can clip the
1315 // bitmap, these are the same as the original
1322 // interpret userscale of src too
1324 memDC
->GetUserScale(&xsc
,&ysc
);
1325 bm_width
= (int) (bm_width
/ xsc
);
1326 bm_height
= (int) (bm_height
/ ysc
);
1328 wxCoord bm_ww
= XLOG2DEVREL( bm_width
);
1329 wxCoord bm_hh
= YLOG2DEVREL( bm_height
);
1331 // Scale bitmap if required
1332 wxBitmap use_bitmap
= selected
;
1333 if ((selected
.GetWidth()!= bm_ww
) || ( selected
.GetHeight()!= bm_hh
))
1335 // This indicates that the blitting code below will get
1336 // a clipped bitmap and therefore needs to move the origin
1338 wxRegion
tmp( xx
,yy
,ww
,hh
);
1339 if (!m_currentClippingRegion
.IsNull())
1340 tmp
.Intersect( m_currentClippingRegion
);
1341 tmp
.GetBox(cx
,cy
,cw
,ch
);
1343 // Scale and clipped bitmap
1344 use_bitmap
= selected
.Rescale(cx
-xx
,cy
-yy
,cw
,ch
,bm_ww
,bm_hh
);
1347 // apply mask if any
1348 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
1349 if (useMask
&& use_bitmap
.GetMask())
1350 mask
= use_bitmap
.GetMask()->GetBitmap();
1352 GdkGC
* use_gc
= is_mono
? m_textGC
: m_penGC
;
1354 GdkBitmap
*new_mask
= (GdkBitmap
*) NULL
;
1358 if (!m_currentClippingRegion
.IsNull())
1361 new_mask
= gdk_pixmap_new( wxGetRootWindow()->window
, bm_ww
, bm_hh
, 1 );
1362 GdkGC
*gc
= gdk_gc_new( new_mask
);
1364 gdk_gc_set_foreground( gc
, &col
);
1365 gdk_gc_set_ts_origin( gc
, -xsrcMask
, -ysrcMask
);
1366 gdk_draw_rectangle( new_mask
, gc
, TRUE
, 0, 0, bm_ww
, bm_hh
);
1368 gdk_gc_set_background( gc
, &col
);
1370 gdk_gc_set_foreground( gc
, &col
);
1371 gdk_gc_set_clip_region( gc
, m_currentClippingRegion
.GetRegion() );
1372 // was: gdk_gc_set_clip_origin( gc, -xx, -yy );
1373 gdk_gc_set_clip_origin( gc
, -cx
, -cy
);
1374 gdk_gc_set_fill( gc
, GDK_OPAQUE_STIPPLED
);
1375 gdk_gc_set_stipple( gc
, mask
);
1376 gdk_draw_rectangle( new_mask
, gc
, TRUE
, 0, 0, bm_ww
, bm_hh
);
1378 g_object_unref (gc
);
1381 gdk_gc_set_clip_mask(use_gc
, mask
);
1382 if (new_mask
!= NULL
)
1383 gdk_gc_set_clip_origin(use_gc
, cx
, cy
);
1385 gdk_gc_set_clip_origin(use_gc
, cx
- xsrcMask
, cy
- ysrcMask
);
1388 // Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For
1389 // drawing a mono-bitmap (XBitmap) we use the current text GC
1393 GdkPixmap
*bitmap
= gdk_pixmap_new( wxGetRootWindow()->window
, bm_ww
, bm_hh
, -1 );
1394 GdkGC
*gc
= gdk_gc_new( bitmap
);
1395 gdk_gc_set_foreground( gc
, m_textForegroundColour
.GetColor() );
1396 gdk_gc_set_background( gc
, m_textBackgroundColour
.GetColor() );
1397 gdk_wx_draw_bitmap(bitmap
, gc
, use_bitmap
.GetPixmap(), 0, 0);
1399 gdk_draw_drawable(m_gdkwindow
, use_gc
, bitmap
, xsrc
, ysrc
, cx
, cy
, cw
, ch
);
1401 g_object_unref (bitmap
);
1402 g_object_unref (gc
);
1406 // was: gdk_draw_drawable( m_gdkwindow, m_penGC, use_bitmap.GetPixmap(), xsrc, ysrc, xx, yy, ww, hh );
1407 gdk_draw_drawable(m_gdkwindow
, use_gc
, use_bitmap
.GetPixmap(), xsrc
, ysrc
, cx
, cy
, cw
, ch
);
1410 // remove mask again if any
1413 gdk_gc_set_clip_mask(use_gc
, NULL
);
1414 gdk_gc_set_clip_origin(use_gc
, 0, 0);
1415 if (!m_currentClippingRegion
.IsNull())
1416 gdk_gc_set_clip_region(use_gc
, m_currentClippingRegion
.GetRegion());
1420 g_object_unref (new_mask
);
1422 else // use_bitmap_method
1424 if (selected
.IsOk() && ((width
!= ww
) || (height
!= hh
)))
1427 wxRegion
tmp( xx
,yy
,ww
,hh
);
1428 tmp
.Intersect( m_currentClippingRegion
);
1429 wxCoord cx
,cy
,cw
,ch
;
1430 tmp
.GetBox(cx
,cy
,cw
,ch
);
1433 wxBitmap bitmap
= selected
.Rescale( cx
-xx
, cy
-yy
, cw
, ch
, ww
, hh
);
1435 // draw scaled bitmap
1436 // was: gdk_draw_drawable( m_gdkwindow, m_penGC, bitmap.GetPixmap(), 0, 0, xx, yy, -1, -1 );
1437 gdk_draw_drawable( m_gdkwindow
, m_penGC
, bitmap
.GetPixmap(), 0, 0, cx
, cy
, -1, -1 );
1441 // No scaling and not a memory dc with a mask either
1443 GdkWindow
* window
= NULL
;
1444 wxDCImpl
*impl
= source
->GetImpl();
1445 wxWindowDCImpl
*gtk_impl
= wxDynamicCast(impl
, wxWindowDCImpl
);
1447 window
= gtk_impl
->GetGDKWindow();
1449 GdkWindow
* window
= source
->GetGDKWindow();
1454 // copy including child window contents
1455 gdk_gc_set_subwindow( m_penGC
, GDK_INCLUDE_INFERIORS
);
1456 gdk_draw_drawable( m_gdkwindow
, m_penGC
,
1460 gdk_gc_set_subwindow( m_penGC
, GDK_CLIP_BY_CHILDREN
);
1464 SetLogicalFunction( old_logical_func
);
1469 void wxWindowDCImpl::DoDrawText( const wxString
&text
, wxCoord x
, wxCoord y
)
1471 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1473 if (!m_gdkwindow
) return;
1475 if (text
.empty()) return;
1480 wxCHECK_RET( m_context
, wxT("no Pango context") );
1481 wxCHECK_RET( m_layout
, wxT("no Pango layout") );
1482 wxCHECK_RET( m_fontdesc
, wxT("no Pango font description") );
1484 gdk_pango_context_set_colormap( m_context
, m_cmap
);
1486 bool underlined
= m_font
.IsOk() && m_font
.GetUnderlined();
1488 const wxCharBuffer data
= wxGTK_CONV( text
);
1491 size_t datalen
= strlen(data
);
1493 // in Pango >= 1.16 the "underline of leading/trailing spaces" bug
1494 // has been fixed and thus the hack implemented below should never be used
1495 static bool pangoOk
= !wx_pango_version_check(1, 16, 0);
1497 bool needshack
= underlined
&& !pangoOk
;
1498 char *hackstring
= NULL
;
1502 // a PangoLayout which has leading/trailing spaces with underlined font
1503 // is not correctly drawn by this pango version: Pango won't underline the spaces.
1504 // This can be a problem; e.g. wxHTML rendering of underlined text relies on
1505 // this behaviour. To workaround this problem, we use a special hack here
1506 // suggested by pango maintainer Behdad Esfahbod: we prepend and append two
1507 // empty space characters and give them a dummy colour attribute.
1508 // This will force Pango to underline the leading/trailing spaces, too.
1510 // need to realloc the string to prepend & append our special characters
1511 hackstring
= (char*)malloc((datalen
+7)*sizeof(char));
1513 // copy the leading U+200C ZERO WIDTH NON-JOINER encoded in UTF8 format
1514 strcpy(hackstring
, "\342\200\214");
1516 // copy the user string
1517 memcpy(&hackstring
[3], data
, datalen
);
1519 // copy the trailing U+200C ZERO WIDTH NON-JOINER encoded in UTF8 format
1520 strcpy(&hackstring
[datalen
+3], "\342\200\214");
1522 // the special characters that we added require 6 additional bytes:
1525 pango_layout_set_text(m_layout
, hackstring
, datalen
);
1529 pango_layout_set_text(m_layout
, data
, datalen
);
1534 PangoAttrList
*attrs
= pango_attr_list_new();
1535 PangoAttribute
*a
= pango_attr_underline_new(PANGO_UNDERLINE_SINGLE
);
1537 a
->end_index
= datalen
;
1538 pango_attr_list_insert(attrs
, a
);
1542 // dummy colour for the leading space
1543 a
= pango_attr_foreground_new (0x0057, 0x52A9, 0xD614);
1546 pango_attr_list_insert(attrs
, a
);
1548 // dummy colour for the trailing space
1549 a
= pango_attr_foreground_new (0x0057, 0x52A9, 0xD614);
1550 a
->start_index
= datalen
- 1;
1551 a
->end_index
= datalen
;
1552 pango_attr_list_insert(attrs
, a
);
1555 pango_layout_set_attributes(m_layout
, attrs
);
1556 pango_attr_list_unref(attrs
);
1561 if (fabs(m_scaleY
- 1.0) > 0.00001)
1563 // If there is a user or actually any scale applied to
1564 // the device context, scale the font.
1566 // scale font description
1567 gint oldSize
= pango_font_description_get_size( m_fontdesc
);
1568 double size
= oldSize
;
1569 size
= size
* m_scaleY
;
1570 pango_font_description_set_size( m_fontdesc
, (gint
)size
);
1572 // actually apply scaled font
1573 pango_layout_set_font_description( m_layout
, m_fontdesc
);
1575 pango_layout_get_pixel_size( m_layout
, &w
, &h
);
1576 if ( m_backgroundMode
== wxSOLID
)
1578 gdk_gc_set_foreground(m_textGC
, m_textBackgroundColour
.GetColor());
1579 gdk_draw_rectangle(m_gdkwindow
, m_textGC
, TRUE
, x
, y
, w
, h
);
1580 gdk_gc_set_foreground(m_textGC
, m_textForegroundColour
.GetColor());
1584 if (m_window
&& m_window
->GetLayoutDirection() == wxLayout_RightToLeft
)
1585 gdk_draw_layout( m_gdkwindow
, m_textGC
, x
-w
, y
, m_layout
);
1587 gdk_draw_layout( m_gdkwindow
, m_textGC
, x
, y
, m_layout
);
1589 // reset unscaled size
1590 pango_font_description_set_size( m_fontdesc
, oldSize
);
1592 // actually apply unscaled font
1593 pango_layout_set_font_description( m_layout
, m_fontdesc
);
1597 pango_layout_get_pixel_size( m_layout
, &w
, &h
);
1598 if ( m_backgroundMode
== wxSOLID
)
1600 gdk_gc_set_foreground(m_textGC
, m_textBackgroundColour
.GetColor());
1601 gdk_draw_rectangle(m_gdkwindow
, m_textGC
, TRUE
, x
, y
, w
, h
);
1602 gdk_gc_set_foreground(m_textGC
, m_textForegroundColour
.GetColor());
1606 if (m_window
&& m_window
->GetLayoutDirection() == wxLayout_RightToLeft
)
1607 gdk_draw_layout( m_gdkwindow
, m_textGC
, x
-w
, y
, m_layout
);
1609 gdk_draw_layout( m_gdkwindow
, m_textGC
, x
, y
, m_layout
);
1614 // undo underline attributes setting:
1615 pango_layout_set_attributes(m_layout
, NULL
);
1621 width
= wxCoord(width
/ m_scaleX
);
1622 height
= wxCoord(height
/ m_scaleY
);
1623 CalcBoundingBox (x
+ width
, y
+ height
);
1624 CalcBoundingBox (x
, y
);
1631 // TODO: There is an example of rotating text with GTK2 that would probably be
1632 // a better approach here:
1633 // http://www.daa.com.au/pipermail/pygtk/2003-April/005052.html
1635 void wxWindowDCImpl::DoDrawRotatedText( const wxString
&text
, wxCoord x
, wxCoord y
, double angle
)
1638 if (!m_gdkwindow
|| text
.empty())
1641 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1643 if ( wxIsNullDouble(angle
) )
1645 DoDrawText(text
, x
, y
);
1652 // TODO: implement later without GdkFont for GTK 2.0
1653 DoGetTextExtent(text
, &w
, &h
, NULL
,NULL
, &m_font
);
1655 // draw the string normally
1658 dc
.SelectObject(src
);
1659 dc
.SetFont(GetFont());
1660 dc
.SetBackground(*wxBLACK_BRUSH
);
1661 dc
.SetBrush(*wxBLACK_BRUSH
);
1663 dc
.SetTextForeground( *wxWHITE
);
1664 dc
.DrawText(text
, 0, 0);
1665 dc
.SelectObject(wxNullBitmap
);
1667 // Calculate the size of the rotated bounding box.
1668 double rad
= DegToRad(angle
);
1669 double dx
= cos(rad
),
1672 // the rectngle vertices are counted clockwise with the first one being at
1673 // (0, 0) (or, rather, at (x, y))
1675 y2
= -w
*dy
; // y axis points to the bottom, hence minus
1678 double x3
= x4
+ x2
,
1682 wxCoord maxX
= (wxCoord
)(dmax(x2
, dmax(x3
, x4
)) + 0.5),
1683 maxY
= (wxCoord
)(dmax(y2
, dmax(y3
, y4
)) + 0.5),
1684 minX
= (wxCoord
)(dmin(x2
, dmin(x3
, x4
)) - 0.5),
1685 minY
= (wxCoord
)(dmin(y2
, dmin(y3
, y4
)) - 0.5);
1688 wxImage image
= src
.ConvertToImage();
1690 image
.ConvertColourToAlpha( m_textForegroundColour
.Red(),
1691 m_textForegroundColour
.Green(),
1692 m_textForegroundColour
.Blue() );
1693 image
= image
.Rotate( rad
, wxPoint(0,0) );
1695 int i_angle
= (int) angle
;
1696 i_angle
= i_angle
% 360;
1700 if ((i_angle
>= 90.0) && (i_angle
< 270.0))
1701 xoffset
= image
.GetWidth();
1703 if ((i_angle
>= 0.0) && (i_angle
< 180.0))
1704 yoffset
= image
.GetHeight();
1706 if ((i_angle
>= 0) && (i_angle
< 90))
1707 yoffset
-= (int)( cos(rad
)*h
);
1708 if ((i_angle
>= 90) && (i_angle
< 180))
1709 xoffset
-= (int)( sin(rad
)*h
);
1710 if ((i_angle
>= 180) && (i_angle
< 270))
1711 yoffset
-= (int)( cos(rad
)*h
);
1712 if ((i_angle
>= 270) && (i_angle
< 360))
1713 xoffset
-= (int)( sin(rad
)*h
);
1715 int i_x
= x
- xoffset
;
1716 int i_y
= y
- yoffset
;
1719 DoDrawBitmap( src
, i_x
, i_y
, true );
1722 // it would be better to draw with non underlined font and draw the line
1723 // manually here (it would be more straight...)
1725 if ( m_font
.GetUnderlined() )
1727 gdk_draw_line( m_gdkwindow
, m_textGC
,
1728 XLOG2DEV(x
+ x4
), YLOG2DEV(y
+ y4
+ font
->descent
),
1729 XLOG2DEV(x
+ x3
), YLOG2DEV(y
+ y3
+ font
->descent
));
1733 // update the bounding box
1734 CalcBoundingBox(x
+ minX
, y
+ minY
);
1735 CalcBoundingBox(x
+ maxX
, y
+ maxY
);
1736 #else // !wxUSE_IMAGE
1741 #endif // wxUSE_IMAGE/!wxUSE_IMAGE
1744 void wxWindowDCImpl::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 wxWindowDCImpl::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
wxWindowDCImpl::GetCharWidth() const
1853 pango_layout_set_text( m_layout
, "H", 1 );
1855 pango_layout_get_pixel_size( m_layout
, &w
, NULL
);
1859 wxCoord
wxWindowDCImpl::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 wxWindowDCImpl::Clear()
1872 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
1874 if (!m_gdkwindow
) return;
1877 DoGetSize( &width
, &height
);
1878 gdk_draw_rectangle( m_gdkwindow
, m_bgGC
, TRUE
, 0, 0, width
, height
);
1881 void wxWindowDCImpl::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_window
->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 wxWindowDCImpl::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_gdkwindow
) 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 wxWindowDCImpl::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_gdkwindow
) 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 wxWindowDCImpl::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_gdkwindow
) 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 wxWindowDCImpl::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 wxWindowDCImpl::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 wxWindowDCImpl::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 wxWindowDCImpl::SetBackgroundMode( int mode
)
2241 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2243 m_backgroundMode
= mode
;
2245 if (!m_gdkwindow
) 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 wxWindowDCImpl::SetPalette( const wxPalette
& WXUNUSED(palette
) )
2259 wxFAIL_MSG( wxT("wxWindowDCImpl::SetPalette not implemented") );
2262 void wxWindowDCImpl::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
2264 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2266 if (!m_gdkwindow
) return;
2269 rect
.x
= XLOG2DEV(x
);
2270 rect
.y
= YLOG2DEV(y
);
2271 rect
.width
= XLOG2DEVREL(width
);
2272 rect
.height
= YLOG2DEVREL(height
);
2274 if (m_window
&& m_window
->m_wxwindow
&&
2275 (m_window
->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 wxGTKDCImpl::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 wxWindowDCImpl::DoSetClippingRegionAsRegion( const wxRegion
®ion
)
2306 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2310 DestroyClippingRegion();
2314 if (!m_gdkwindow
) 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 wxGTKDCImpl::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 wxWindowDCImpl::DestroyClippingRegion()
2342 wxCHECK_RET( IsOk(), wxT("invalid window dc") );
2345 wxDCImpl::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_gdkwindow
) 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 wxWindowDCImpl::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 wxWindowDCImpl::SetDeviceOrigin( wxCoord x
, wxCoord y
)
2389 m_deviceOriginX
= x
;
2390 m_deviceOriginY
= y
;
2392 ComputeScaleAndOrigin();
2395 void wxWindowDCImpl::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
2397 m_signX
= (xLeftRight
? 1 : -1);
2398 m_signY
= (yBottomUp
? -1 : 1);
2400 if (m_window
&& m_window
->m_wxwindow
&&
2401 (m_window
->GetLayoutDirection() == wxLayout_RightToLeft
))
2404 ComputeScaleAndOrigin();
2407 void wxWindowDCImpl::ComputeScaleAndOrigin()
2409 const wxRealPoint
origScale(m_scaleX
, m_scaleY
);
2412 wxDCImpl::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
wxWindowDCImpl::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 wxWindowDCImpl::GetDepth() const
2436 return gdk_drawable_get_depth(m_gdkwindow
);
2440 //-----------------------------------------------------------------------------
2442 //-----------------------------------------------------------------------------
2444 IMPLEMENT_ABSTRACT_CLASS(wxClientDCImpl
, wxWindowDCImpl
)
2446 wxClientDCImpl::wxClientDCImpl( wxDC
*owner
)
2447 : wxWindowDCImpl( owner
)
2451 wxClientDCImpl::wxClientDCImpl( wxDC
*owner
, wxWindow
*win
)
2452 : wxWindowDCImpl( owner
, win
)
2454 wxCHECK_RET( win
, _T("NULL window in wxClientDCImpl::wxClientDC") );
2456 #ifdef __WXUNIVERSAL__
2457 wxPoint ptOrigin
= win
->GetClientAreaOrigin();
2458 SetDeviceOrigin(ptOrigin
.x
, ptOrigin
.y
);
2459 wxSize size
= win
->GetClientSize();
2460 DoSetClippingRegion(0, 0, size
.x
, size
.y
);
2465 void wxClientDCImpl::DoGetSize(int *width
, int *height
) const
2467 wxCHECK_RET( m_window
, _T("GetSize() doesn't work without window") );
2469 m_window
->GetClientSize( width
, height
);
2472 //-----------------------------------------------------------------------------
2474 //-----------------------------------------------------------------------------
2476 IMPLEMENT_ABSTRACT_CLASS(wxPaintDCImpl
, wxClientDCImpl
)
2478 // Limit the paint region to the window size. Sometimes
2479 // the paint region is too big, and this risks X11 errors
2480 static void wxLimitRegionToSize(wxRegion
& region
, const wxSize
& sz
)
2482 wxRect originalRect
= region
.GetBox();
2483 wxRect
rect(originalRect
);
2484 if (rect
.width
+ rect
.x
> sz
.x
)
2485 rect
.width
= sz
.x
- rect
.x
;
2486 if (rect
.height
+ rect
.y
> sz
.y
)
2487 rect
.height
= sz
.y
- rect
.y
;
2488 if (rect
!= originalRect
)
2490 region
= wxRegion(rect
);
2491 wxLogTrace(wxT("painting"), wxT("Limiting region from %d, %d, %d, %d to %d, %d, %d, %d\n"),
2492 originalRect
.x
, originalRect
.y
, originalRect
.width
, originalRect
.height
,
2493 rect
.x
, rect
.y
, rect
.width
, rect
.height
);
2497 wxPaintDCImpl::wxPaintDCImpl( wxDC
*owner
)
2498 : wxClientDCImpl( owner
)
2502 wxPaintDCImpl::wxPaintDCImpl( wxDC
*owner
, wxWindow
*win
)
2503 : wxClientDCImpl( owner
, win
)
2505 #if USE_PAINT_REGION
2506 if (!win
->m_clipPaintRegion
)
2509 wxSize sz
= win
->GetSize();
2510 m_paintClippingRegion
= win
->m_nativeUpdateRegion
;
2511 wxLimitRegionToSize(m_paintClippingRegion
, sz
);
2513 GdkRegion
*region
= m_paintClippingRegion
.GetRegion();
2516 m_currentClippingRegion
.Union( m_paintClippingRegion
);
2517 wxLimitRegionToSize(m_currentClippingRegion
, sz
);
2519 if (sz
.x
<= 0 || sz
.y
<= 0)
2522 gdk_gc_set_clip_region( m_penGC
, region
);
2523 gdk_gc_set_clip_region( m_brushGC
, region
);
2524 gdk_gc_set_clip_region( m_textGC
, region
);
2525 gdk_gc_set_clip_region( m_bgGC
, region
);
2530 // ----------------------------------------------------------------------------
2532 // ----------------------------------------------------------------------------
2534 class wxDCModule
: public wxModule
2541 DECLARE_DYNAMIC_CLASS(wxDCModule
)
2544 IMPLEMENT_DYNAMIC_CLASS(wxDCModule
, wxModule
)
2546 bool wxDCModule::OnInit()
2552 void wxDCModule::OnExit()