1 /////////////////////////////////////////////////////////////////////////////
2 // Name: x11/dcclient.cpp
3 // Purpose: wxClientDC class
4 // Author: Julian Smart, Robert Roebling
8 // Copyright: (c) Julian Smart, Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "dcclient.h"
16 #include "wx/dcclient.h"
17 #include "wx/dcmemory.h"
18 #include "wx/window.h"
22 #include "wx/x11/private.h"
26 //-----------------------------------------------------------------------------
28 //-----------------------------------------------------------------------------
30 #define USE_PAINT_REGION 1
32 //-----------------------------------------------------------------------------
34 //-----------------------------------------------------------------------------
44 #define IS_15_PIX_HATCH(s) ((s)==wxCROSSDIAG_HATCH || (s)==wxHORIZONTAL_HATCH || (s)==wxVERTICAL_HATCH)
45 #define IS_16_PIX_HATCH(s) ((s)!=wxCROSSDIAG_HATCH && (s)!=wxHORIZONTAL_HATCH && (s)!=wxVERTICAL_HATCH)
47 static Pixmap hatches
[num_hatches
];
48 static Pixmap
*hatch_bitmap
= (Pixmap
*) NULL
;
50 //-----------------------------------------------------------------------------
52 //-----------------------------------------------------------------------------
54 const double RAD2DEG
= 180.0 / M_PI
;
56 // ----------------------------------------------------------------------------
58 // ----------------------------------------------------------------------------
60 static inline double dmax(double a
, double b
) { return a
> b
? a
: b
; }
61 static inline double dmin(double a
, double b
) { return a
< b
? a
: b
; }
63 static inline double DegToRad(double deg
) { return (deg
* M_PI
) / 180.0; }
65 //-----------------------------------------------------------------------------
66 // Implement Pool of Graphic contexts. Creating them takes too much time.
67 //-----------------------------------------------------------------------------
69 #define GC_POOL_SIZE 200
95 static wxGC wxGCPool
[GC_POOL_SIZE
];
97 static void wxInitGCPool()
99 memset( wxGCPool
, 0, GC_POOL_SIZE
*sizeof(wxGC
) );
102 static void wxCleanUpGCPool()
104 for (int i
= 0; i
< GC_POOL_SIZE
; i
++)
106 if (wxGCPool
[i
].m_gc
)
107 XFreeGC( wxGlobalDisplay(), wxGCPool
[i
].m_gc
);
111 static GC
wxGetPoolGC( Window window
, wxPoolGCType type
)
113 for (int i
= 0; i
< GC_POOL_SIZE
; i
++)
115 if (!wxGCPool
[i
].m_gc
)
117 wxGCPool
[i
].m_gc
= XCreateGC( wxGlobalDisplay(), window
, 0, NULL
);
118 XSetGraphicsExposures( wxGlobalDisplay(), wxGCPool
[i
].m_gc
, FALSE
);
119 wxGCPool
[i
].m_type
= type
;
120 wxGCPool
[i
].m_used
= FALSE
;
122 if ((!wxGCPool
[i
].m_used
) && (wxGCPool
[i
].m_type
== type
))
124 wxGCPool
[i
].m_used
= TRUE
;
125 return wxGCPool
[i
].m_gc
;
129 wxFAIL_MSG( wxT("No GC available") );
134 static void wxFreePoolGC( GC gc
)
136 for (int i
= 0; i
< GC_POOL_SIZE
; i
++)
138 if (wxGCPool
[i
].m_gc
== gc
)
140 wxGCPool
[i
].m_used
= FALSE
;
145 wxFAIL_MSG( wxT("Wrong GC") );
148 // ----------------------------------------------------------------------------
150 // ----------------------------------------------------------------------------
152 IMPLEMENT_DYNAMIC_CLASS(wxWindowDC
, wxDC
)
154 wxWindowDC::wxWindowDC()
156 m_display
= (WXDisplay
*) NULL
;
157 m_penGC
= (WXGC
*) NULL
;
158 m_brushGC
= (WXGC
*) NULL
;
159 m_textGC
= (WXGC
*) NULL
;
160 m_bgGC
= (WXGC
*) NULL
;
161 m_cmap
= (WXColormap
*) NULL
;
163 m_isScreenDC
= FALSE
;
164 m_owner
= (wxWindow
*)NULL
;
167 wxWindowDC::wxWindowDC( wxWindow
*window
)
169 wxASSERT_MSG( window
, wxT("DC needs a window") );
171 m_display
= (WXDisplay
*) NULL
;
172 m_penGC
= (WXGC
*) NULL
;
173 m_brushGC
= (WXGC
*) NULL
;
174 m_textGC
= (WXGC
*) NULL
;
175 m_bgGC
= (WXGC
*) NULL
;
176 m_cmap
= (WXColormap
*) NULL
;
177 m_owner
= (wxWindow
*)NULL
;
179 m_isScreenDC
= FALSE
;
180 m_font
= window
->GetFont();
182 m_window
= (WXWindow
*) window
->GetMainWindow();
187 // don't report problems
193 m_display
= (WXDisplay
*) wxGlobalDisplay();
195 int screen
= DefaultScreen( (Display
*) m_display
);
196 m_cmap
= (WXColormap
) DefaultColormap( (Display
*) m_display
, screen
);
200 /* this must be done after SetUpDC, bacause SetUpDC calls the
201 repective SetBrush, SetPen, SetBackground etc functions
202 to set up the DC. SetBackground call m_owner->SetBackground
203 and this might not be desired as the standard dc background
204 is white whereas a window might assume gray to be the
205 standard (as e.g. wxStatusBar) */
210 wxWindowDC::~wxWindowDC()
215 void wxWindowDC::SetUpDC()
219 wxASSERT_MSG( !m_penGC
, wxT("GCs already created") );
223 m_penGC
= (WXGC
*) wxGetPoolGC( (Window
) m_window
, wxPEN_SCREEN
);
224 m_brushGC
= (WXGC
*) wxGetPoolGC( (Window
) m_window
, wxBRUSH_SCREEN
);
225 m_textGC
= (WXGC
*) wxGetPoolGC( (Window
) m_window
, wxTEXT_SCREEN
);
226 m_bgGC
= (WXGC
*) wxGetPoolGC( (Window
) m_window
, wxBG_SCREEN
);
229 if (m_isMemDC
&& (((wxMemoryDC
*)this)->m_selected
.GetDepth() == 1))
231 m_penGC
= (WXGC
*) wxGetPoolGC( (Window
) m_window
, wxPEN_MONO
);
232 m_brushGC
= (WXGC
*) wxGetPoolGC( (Window
) m_window
, wxBRUSH_MONO
);
233 m_textGC
= (WXGC
*) wxGetPoolGC( (Window
) m_window
, wxTEXT_MONO
);
234 m_bgGC
= (WXGC
*) wxGetPoolGC( (Window
) m_window
, wxBG_MONO
);
238 m_penGC
= (WXGC
*) wxGetPoolGC( (Window
) m_window
, wxPEN_COLOUR
);
239 m_brushGC
= (WXGC
*) wxGetPoolGC( (Window
) m_window
, wxBRUSH_COLOUR
);
240 m_textGC
= (WXGC
*) wxGetPoolGC( (Window
) m_window
, wxTEXT_COLOUR
);
241 m_bgGC
= (WXGC
*) wxGetPoolGC( (Window
) m_window
, wxBG_COLOUR
);
244 /* background colour */
245 m_backgroundBrush
= *wxWHITE_BRUSH
;
246 m_backgroundBrush
.GetColour().CalcPixel( m_cmap
);
247 unsigned long bg_col
= m_backgroundBrush
.GetColour().GetPixel();
250 m_textForegroundColour
.CalcPixel( m_cmap
);
251 XSetForeground( (Display
*) m_display
, (GC
) m_textGC
, m_textForegroundColour
.GetPixel() );
253 m_textBackgroundColour
.CalcPixel( m_cmap
);
254 XSetBackground( (Display
*) m_display
, (GC
) m_textGC
, m_textBackgroundColour
.GetPixel() );
256 XSetFillStyle( (Display
*) m_display
, (GC
) m_textGC
, FillSolid
);
259 // By default, draw transparently
260 GrSetGCUseBackground((GC
) m_textGC
, FALSE
);
264 m_pen
.GetColour().CalcPixel( m_cmap
);
265 XSetForeground( (Display
*) m_display
, (GC
) m_penGC
, m_pen
.GetColour().GetPixel() );
266 XSetBackground( (Display
*) m_display
, (GC
) m_penGC
, bg_col
);
268 XSetLineAttributes( (Display
*) m_display
, (GC
) m_penGC
, 0, LineSolid
, CapNotLast
, JoinRound
);
271 m_brush
.GetColour().CalcPixel( m_cmap
);
272 XSetForeground( (Display
*) m_display
, (GC
) m_brushGC
, m_brush
.GetColour().GetPixel() );
273 XSetBackground( (Display
*) m_display
, (GC
) m_brushGC
, bg_col
);
275 XSetFillStyle( (Display
*) m_display
, (GC
) m_brushGC
, FillSolid
);
278 XSetForeground( (Display
*) m_display
, (GC
) m_bgGC
, bg_col
);
279 XSetBackground( (Display
*) m_display
, (GC
) m_bgGC
, bg_col
);
281 XSetFillStyle( (Display
*) m_display
, (GC
) m_bgGC
, FillSolid
);
284 XSetFunction( (Display
*) m_display
, (GC
) m_textGC
, GXcopy
);
285 XSetFunction( (Display
*) m_display
, (GC
) m_brushGC
, GXcopy
);
286 XSetFunction( (Display
*) m_display
, (GC
)m_penGC
, GXcopy
);
289 XSetClipMask( (Display
*) m_display
, (GC
) m_penGC
, None
);
290 XSetClipMask( (Display
*) m_display
, (GC
) m_brushGC
, None
);
291 XSetClipMask( (Display
*) m_display
, (GC
) m_textGC
, None
);
292 XSetClipMask( (Display
*) m_display
, (GC
) m_bgGC
, None
);
296 int xscreen
= DefaultScreen( (Display
*) m_display
);
297 Window xroot
= RootWindow( (Display
*) m_display
, xscreen
);
299 hatch_bitmap
= hatches
;
300 hatch_bitmap
[0] = XCreateBitmapFromData( (Display
*) m_display
, xroot
, bdiag_bits
, bdiag_width
, bdiag_height
);
301 hatch_bitmap
[1] = XCreateBitmapFromData( (Display
*) m_display
, xroot
, cdiag_bits
, cdiag_width
, cdiag_height
);
302 hatch_bitmap
[2] = XCreateBitmapFromData( (Display
*) m_display
, xroot
, fdiag_bits
, fdiag_width
, fdiag_height
);
303 hatch_bitmap
[3] = XCreateBitmapFromData( (Display
*) m_display
, xroot
, cross_bits
, cross_width
, cross_height
);
304 hatch_bitmap
[4] = XCreateBitmapFromData( (Display
*) m_display
, xroot
, horiz_bits
, horiz_width
, horiz_height
);
305 hatch_bitmap
[5] = XCreateBitmapFromData( (Display
*) m_display
, xroot
, verti_bits
, verti_width
, verti_height
);
309 void wxWindowDC::DoGetSize( int* width
, int* height
) const
311 wxCHECK_RET( m_owner
, _T("GetSize() doesn't work without window") );
313 m_owner
->GetSize(width
, height
);
316 void wxWindowDC::DoFloodFill( wxCoord
WXUNUSED(x1
), wxCoord
WXUNUSED(y1
),
317 const wxColour
& WXUNUSED(col
), int WXUNUSED(style
) )
319 wxFAIL_MSG("not implemented");
322 bool wxWindowDC::DoGetPixel( wxCoord x1
, wxCoord y1
, wxColour
*col
) const
324 // Generic (and therefore rather inefficient) method.
325 // Could be improved.
327 wxBitmap
bitmap(1, 1);
328 memdc
.SelectObject(bitmap
);
329 memdc
.Blit(0, 0, 1, 1, (wxDC
*) this, x1
, y1
);
330 memdc
.SelectObject(wxNullBitmap
);
331 wxImage
image(bitmap
);
332 col
->Set(image
.GetRed(0, 0), image
.GetGreen(0, 0), image
.GetBlue(0, 0));
336 void wxWindowDC::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
338 wxCHECK_RET( Ok(), wxT("invalid window dc") );
340 if (m_pen
.GetStyle() != wxTRANSPARENT
)
343 XDrawLine( (Display
*) m_display
, (Window
) m_window
,
344 (GC
) m_penGC
, XLOG2DEV(x1
), YLOG2DEV(y1
), XLOG2DEV(x2
), YLOG2DEV(y2
) );
346 CalcBoundingBox(x1
, y1
);
347 CalcBoundingBox(x2
, y2
);
351 void wxWindowDC::DoCrossHair( wxCoord x
, wxCoord y
)
353 wxCHECK_RET( Ok(), wxT("invalid window dc") );
355 if (m_pen
.GetStyle() != wxTRANSPARENT
)
360 wxCoord xx
= XLOG2DEV(x
);
361 wxCoord yy
= YLOG2DEV(y
);
364 XDrawLine( (Display
*) m_display
, (Window
) m_window
,
365 (GC
) m_penGC
, 0, yy
, XLOG2DEVREL(w
), yy
);
366 XDrawLine( (Display
*) m_display
, (Window
) m_window
,
367 (GC
) m_penGC
, xx
, 0, xx
, YLOG2DEVREL(h
) );
372 void wxWindowDC::DoDrawArc( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
, wxCoord xc
, wxCoord yc
)
374 wxCHECK_RET( Ok(), wxT("invalid window dc") );
376 wxCoord xx1
= XLOG2DEV(x1
);
377 wxCoord yy1
= YLOG2DEV(y1
);
378 wxCoord xx2
= XLOG2DEV(x2
);
379 wxCoord yy2
= YLOG2DEV(y2
);
380 wxCoord xxc
= XLOG2DEV(xc
);
381 wxCoord yyc
= YLOG2DEV(yc
);
382 double dx
= xx1
- xxc
;
383 double dy
= yy1
- yyc
;
384 double radius
= sqrt((double)(dx
*dx
+dy
*dy
));
385 wxCoord r
= (wxCoord
)radius
;
386 double radius1
, radius2
;
388 if (xx1
== xx2
&& yy1
== yy2
)
396 radius1
= radius2
= 0.0;
400 radius1
= (xx1
- xxc
== 0) ?
401 (yy1
- yyc
< 0) ? 90.0 : -90.0 :
402 -atan2(double(yy1
-yyc
), double(xx1
-xxc
)) * RAD2DEG
;
403 radius2
= (xx2
- xxc
== 0) ?
404 (yy2
- yyc
< 0) ? 90.0 : -90.0 :
405 -atan2(double(yy2
-yyc
), double(xx2
-xxc
)) * RAD2DEG
;
407 wxCoord alpha1
= wxCoord(radius1
* 64.0);
408 wxCoord alpha2
= wxCoord((radius2
- radius1
) * 64.0);
409 while (alpha2
<= 0) alpha2
+= 360*64;
410 while (alpha1
> 360*64) alpha1
-= 360*64;
414 if (m_brush
.GetStyle() != wxTRANSPARENT
)
416 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
418 XSetTSOrigin( (Display
*) m_display
, (GC
) m_textGC
,
419 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
420 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
422 XFillArc( (Display
*) m_display
, (Window
) m_window
,
423 (GC
) m_brushGC
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
425 XSetTSOrigin( (Display
*) m_display
, (GC
) m_textGC
, 0, 0 );
427 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
429 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
,
430 m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
432 XFillArc( (Display
*) m_display
, (Window
) m_window
,
433 (GC
) m_brushGC
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
435 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
, 0, 0 );
437 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
439 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
,
440 m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
442 XFillArc( (Display
*) m_display
, (Window
) m_window
,
443 (GC
) m_brushGC
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
445 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
, 0, 0 );
447 if (m_brush
.GetStyle() == wxSTIPPLE
)
449 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
,
450 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
451 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
453 XFillArc( (Display
*) m_display
, (Window
) m_window
,
454 (GC
) m_brushGC
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
456 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
, 0, 0 );
460 XFillArc( (Display
*) m_display
, (Window
) m_window
,
461 (GC
) m_brushGC
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
465 if (m_pen
.GetStyle() != wxTRANSPARENT
)
467 XDrawArc( (Display
*) m_display
, (Window
) m_window
,
468 (GC
) m_penGC
, xxc
-r
, yyc
-r
, 2*r
,2*r
, alpha1
, alpha2
);
470 XDrawLine( (Display
*) m_display
, (Window
) m_window
,
471 (GC
) m_penGC
, xx1
, yy1
, xxc
, yyc
);
473 XDrawLine( (Display
*) m_display
, (Window
) m_window
,
474 (GC
) m_penGC
, xxc
, yyc
, xx2
, yy2
);
478 CalcBoundingBox (x1
, y1
);
479 CalcBoundingBox (x2
, y2
);
482 void wxWindowDC::DoDrawEllipticArc( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double sa
, double ea
)
484 wxCHECK_RET( Ok(), wxT("invalid window dc") );
486 wxCoord xx
= XLOG2DEV(x
);
487 wxCoord yy
= YLOG2DEV(y
);
488 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
489 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
491 // CMB: handle -ve width and/or height
492 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
493 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
497 wxCoord start
= wxCoord(sa
* 64.0);
498 wxCoord end
= wxCoord((ea
-sa
) * 64.0);
500 if (m_brush
.GetStyle() != wxTRANSPARENT
)
502 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
504 XSetTSOrigin( (Display
*) m_display
, (GC
) m_textGC
,
505 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
506 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
508 XFillArc( (Display
*) m_display
, (Window
) m_window
,
509 (GC
) m_textGC
, xx
, yy
, ww
, hh
, start
, end
);
511 XSetTSOrigin( (Display
*) m_display
, (GC
) m_textGC
, 0, 0 );
513 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
515 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
,
516 m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
518 XFillArc( (Display
*) m_display
, (Window
) m_window
,
519 (GC
) m_brushGC
, xx
, yy
, ww
, hh
, start
, end
);
521 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
, 0, 0 );
523 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
525 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
,
526 m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
528 XFillArc( (Display
*) m_display
, (Window
) m_window
,
529 (GC
) m_brushGC
, xx
, yy
, ww
, hh
, start
, end
);
531 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
, 0, 0 );
533 if (m_brush
.GetStyle() == wxSTIPPLE
)
535 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
,
536 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
537 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
539 XFillArc( (Display
*) m_display
, (Window
) m_window
,
540 (GC
) m_brushGC
, xx
, yy
, ww
, hh
, start
, end
);
542 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
, 0, 0 );
546 XFillArc( (Display
*) m_display
, (Window
) m_window
,
547 (GC
) m_brushGC
, xx
, yy
, ww
, hh
, start
, end
);
551 if (m_pen
.GetStyle() != wxTRANSPARENT
)
553 XDrawArc( (Display
*) m_display
, (Window
) m_window
,
554 (GC
) m_penGC
, xx
, yy
, ww
, hh
, start
, end
);
558 CalcBoundingBox (x
, y
);
559 CalcBoundingBox (x
+ width
, y
+ height
);
562 void wxWindowDC::DoDrawPoint( wxCoord x
, wxCoord y
)
564 wxCHECK_RET( Ok(), wxT("invalid window dc") );
566 if ((m_pen
.GetStyle() != wxTRANSPARENT
) && m_window
)
567 XDrawPoint( (Display
*) m_display
, (Window
) m_window
,
568 (GC
) m_penGC
, XLOG2DEV(x
), YLOG2DEV(y
) );
570 CalcBoundingBox (x
, y
);
573 void wxWindowDC::DoDrawLines( int n
, wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
)
575 wxCHECK_RET( Ok(), wxT("invalid window dc") );
577 if (m_pen
.GetStyle() == wxTRANSPARENT
) return;
580 XPoint
*xpoints
= new XPoint
[n
];
581 for (int i
= 0; i
< n
; i
++)
583 xpoints
[i
].x
= XLOG2DEV (points
[i
].x
+ xoffset
);
584 xpoints
[i
].y
= YLOG2DEV (points
[i
].y
+ yoffset
);
586 CalcBoundingBox( points
[i
].x
+ xoffset
, points
[i
].y
+ yoffset
);
588 XDrawLines( (Display
*) m_display
, (Window
) m_window
, (GC
) m_penGC
, xpoints
, n
, 0 );
593 void wxWindowDC::DoDrawPolygon( int n
, wxPoint points
[],
594 wxCoord xoffset
, wxCoord yoffset
, int fillStyle
)
596 wxCHECK_RET( Ok(), wxT("invalid window dc") );
600 XPoint
*xpoints
= new XPoint
[n
+ 1];
602 for (i
= 0; i
< n
; i
++)
604 xpoints
[i
].x
= XLOG2DEV (points
[i
].x
+ xoffset
);
605 xpoints
[i
].y
= YLOG2DEV (points
[i
].y
+ yoffset
);
607 CalcBoundingBox (points
[i
].x
+ xoffset
, points
[i
].y
+ yoffset
);
612 if (m_brush
.GetStyle() != wxTRANSPARENT
)
615 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
617 XSetTSOrigin( (Display
*) m_display
, (GC
) m_textGC
,
618 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
619 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
621 XFillPolygon( (Display
*) m_display
, (Window
) m_window
,
622 (GC
) m_textGC
, xpoints
, n
, Complex
, 0);
624 XSetTSOrigin( (Display
*) m_display
, (GC
) m_textGC
, 0, 0 );
626 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
628 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
,
629 m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
631 XFillPolygon( (Display
*) m_display
, (Window
) m_window
,
632 (GC
) m_brushGC
, xpoints
, n
, Complex
, 0);
634 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
, 0, 0 );
636 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
638 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
,
639 m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
641 XFillPolygon( (Display
*) m_display
, (Window
) m_window
,
642 (GC
) m_brushGC
, xpoints
, n
, Complex
, 0);
644 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
, 0, 0 );
646 if (m_brush
.GetStyle() == wxSTIPPLE
)
648 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
,
649 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
650 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
652 XFillPolygon( (Display
*) m_display
, (Window
) m_window
,
653 (GC
) m_brushGC
, xpoints
, n
, Complex
, 0);
655 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
, 0, 0 );
659 XFillPolygon( (Display
*) m_display
, (Window
) m_window
,
660 (GC
) m_brushGC
, xpoints
, n
, Complex
, 0);
664 if (m_pen
.GetStyle () != wxTRANSPARENT
)
666 // Close figure for XDrawLines
667 xpoints
[i
].x
= xpoints
[0].x
;
668 xpoints
[i
].y
= xpoints
[0].y
;
670 XDrawLines( (Display
*) m_display
, (Window
) m_window
, (GC
) m_penGC
, xpoints
, n
+ 1, 0);
677 void wxWindowDC::DoDrawRectangle( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
679 wxCHECK_RET( Ok(), wxT("invalid window dc") );
681 wxCoord xx
= XLOG2DEV(x
);
682 wxCoord yy
= YLOG2DEV(y
);
683 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
684 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
686 // CMB: draw nothing if transformed w or h is 0
687 if (ww
== 0 || hh
== 0) return;
689 // CMB: handle -ve width and/or height
690 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
691 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
695 if (m_brush
.GetStyle() != wxTRANSPARENT
)
697 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
699 XSetTSOrigin( (Display
*) m_display
, (GC
) m_textGC
,
700 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
701 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
703 XFillRectangle( (Display
*) m_display
, (Window
) m_window
,
704 (GC
) m_textGC
, xx
, yy
, ww
, hh
);
706 XSetTSOrigin( (Display
*) m_display
, (GC
) m_textGC
, 0, 0 );
708 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
710 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
,
711 m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
713 XFillRectangle( (Display
*) m_display
, (Window
) m_window
,
714 (GC
) m_brushGC
, xx
, yy
, ww
, hh
);
716 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
, 0, 0 );
718 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
720 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
,
721 m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
723 XFillRectangle( (Display
*) m_display
, (Window
) m_window
,
724 (GC
) m_brushGC
, xx
, yy
, ww
, hh
);
726 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
, 0, 0 );
728 if (m_brush
.GetStyle() == wxSTIPPLE
)
730 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
,
731 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
732 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
734 XFillRectangle( (Display
*) m_display
, (Window
) m_window
,
735 (GC
) m_brushGC
, xx
, yy
, ww
, hh
);
737 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
, 0, 0 );
741 XFillRectangle( (Display
*) m_display
, (Window
) m_window
,
742 (GC
) m_brushGC
, xx
, yy
, ww
, hh
);
746 if (m_pen
.GetStyle () != wxTRANSPARENT
)
748 XDrawRectangle( (Display
*) m_display
, (Window
) m_window
,
749 (GC
) m_penGC
, xx
, yy
, ww
-1, hh
-1 );
753 CalcBoundingBox( x
, y
);
754 CalcBoundingBox( x
+ width
, y
+ height
);
757 void wxWindowDC::DoDrawRoundedRectangle( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double radius
)
762 void wxWindowDC::DoDrawEllipse( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
764 wxCHECK_RET( Ok(), wxT("invalid window dc") );
766 wxCoord xx
= XLOG2DEV(x
);
767 wxCoord yy
= YLOG2DEV(y
);
768 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
769 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
771 // CMB: handle -ve width and/or height
772 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
773 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
777 if (m_brush
.GetStyle() != wxTRANSPARENT
)
779 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
781 XSetTSOrigin( (Display
*) m_display
, (GC
) m_textGC
,
782 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
783 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
785 XFillArc( (Display
*) m_display
, (Window
) m_window
,
786 (GC
) m_textGC
, xx
, yy
, ww
, hh
, 0, 360*64 );
788 XSetTSOrigin( (Display
*) m_display
, (GC
) m_textGC
, 0, 0 );
790 if (IS_15_PIX_HATCH(m_brush
.GetStyle()))
792 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
,
793 m_deviceOriginX
% 15, m_deviceOriginY
% 15 );
795 XFillArc( (Display
*) m_display
, (Window
) m_window
,
796 (GC
) m_brushGC
, xx
, yy
, ww
, hh
, 0, 360*64 );
798 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
, 0, 0 );
800 if (IS_16_PIX_HATCH(m_brush
.GetStyle()))
802 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
,
803 m_deviceOriginX
% 16, m_deviceOriginY
% 16 );
805 XFillArc( (Display
*) m_display
, (Window
) m_window
,
806 (GC
) m_brushGC
, xx
, yy
, ww
, hh
, 0, 360*64 );
808 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
, 0, 0 );
810 if (m_brush
.GetStyle() == wxSTIPPLE
)
812 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
,
813 m_deviceOriginX
% m_brush
.GetStipple()->GetWidth(),
814 m_deviceOriginY
% m_brush
.GetStipple()->GetHeight() );
816 XFillArc( (Display
*) m_display
, (Window
) m_window
,
817 (GC
) m_brushGC
, xx
, yy
, ww
, hh
, 0, 360*64 );
819 XSetTSOrigin( (Display
*) m_display
, (GC
) m_brushGC
, 0, 0 );
823 XFillArc( (Display
*) m_display
, (Window
) m_window
,
824 (GC
) m_brushGC
, xx
, yy
, ww
, hh
, 0, 360*64 );
828 if (m_pen
.GetStyle () != wxTRANSPARENT
)
830 XDrawArc( (Display
*) m_display
, (Window
) m_window
,
831 (GC
) m_penGC
, xx
, yy
, ww
, hh
, 0, 360*64 );
835 CalcBoundingBox( x
, y
);
836 CalcBoundingBox( x
+ width
, y
+ height
);
839 void wxWindowDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
841 DoDrawBitmap(icon
, x
, y
, TRUE
);
845 void wxWindowDC::DoDrawBitmap( const wxBitmap
&bitmap
,
846 wxCoord x
, wxCoord y
,
849 wxCHECK_RET( Ok(), wxT("invalid window dc") );
851 wxCHECK_RET( bitmap
.Ok(), wxT("invalid bitmap") );
853 bool is_mono
= (bitmap
.GetBitmap() != NULL
);
855 /* scale/translate size and position */
856 int xx
= XLOG2DEV(x
);
857 int yy
= YLOG2DEV(y
);
859 int w
= bitmap
.GetWidth();
860 int h
= bitmap
.GetHeight();
862 CalcBoundingBox( x
, y
);
863 CalcBoundingBox( x
+ w
, y
+ h
);
865 if (!m_window
) return;
867 int ww
= XLOG2DEVREL(w
);
868 int hh
= YLOG2DEVREL(h
);
870 /* compare to current clipping region */
871 if (!m_currentClippingRegion
.IsNull())
873 wxRegion
tmp( xx
,yy
,ww
,hh
);
874 tmp
.Intersect( m_currentClippingRegion
);
879 /* scale bitmap if required */
881 if ((w
!= ww
) || (h
!= hh
))
883 wxImage
image( bitmap
);
884 image
.Rescale( ww
, hh
);
887 use_bitmap
= image
.ConvertToMonoBitmap(255,255,255);
890 use_bitmap
= image
.ConvertToBitmap();
897 /* apply mask if any */
898 WXPixmap mask
= NULL
;
899 if (use_bitmap
.GetMask())
900 mask
= use_bitmap
.GetMask()->GetBitmap();
904 Pixmap pixmap
= (Pixmap
) use_bitmap
.GetPixmap() ;
905 Pixmap maskPixmap
= (Pixmap
) use_bitmap
.GetMask()->GetBitmap() ;
906 Pixmap bufPixmap
= GrNewPixmap(w
, h
, 0);
908 GrSetGCUseBackground(gc
, FALSE
);
909 GrSetGCMode(gc
, GR_MODE_COPY
);
911 // This code assumes that background and foreground
912 // colours are used in ROPs, like in MSW.
913 // Not sure if this is true.
915 // Copy destination to buffer.
916 // In DoBlit, we need this step because Blit has
917 // a ROP argument. Here, we don't need it.
918 // In DoBlit, we may be able to eliminate this step
919 // if we check if the rop = copy
921 GrCopyArea(bufPixmap
, gc
, 0, 0, w
, h
, (Window
) m_window
,
925 // Copy src to buffer using selected raster op (none selected
926 // in DrawBitmap, so just use Gxcopy)
927 GrCopyArea(bufPixmap
, gc
, 0, 0, w
, h
, pixmap
,
930 // Set masked area in buffer to BLACK (pixel value 0)
931 GrSetGCBackground(gc
, WHITE
);
932 GrSetGCForeground(gc
, BLACK
);
933 GrCopyArea(bufPixmap
, gc
, 0, 0, w
, h
, maskPixmap
,
936 // set unmasked area in dest to BLACK
937 GrSetGCBackground(gc
, BLACK
);
938 GrSetGCForeground(gc
, WHITE
);
939 GrCopyArea((Window
) m_window
, gc
, xx
, yy
, w
, h
, maskPixmap
,
943 GrCopyArea((Window
) m_window
, gc
, xx
, yy
, w
, h
, bufPixmap
,
947 GrDestroyWindow(bufPixmap
);
950 XCopyArea( (Display
*) m_display
, (Pixmap
) use_bitmap
.GetPixmap(), (Window
) m_window
,
951 (GC
) m_penGC
, 0, 0, w
, h
, xx
, yy
);
953 /* remove mask again if any */
956 if (!m_currentClippingRegion
.IsNull())
957 XSetRegion( (Display
*) m_display
, (GC
) m_penGC
, (Region
) m_currentClippingRegion
.GetX11Region() );
964 void wxWindowDC::DoDrawBitmap( const wxBitmap
&bitmap
,
965 wxCoord x
, wxCoord y
,
968 wxCHECK_RET( Ok(), wxT("invalid window dc") );
970 wxCHECK_RET( bitmap
.Ok(), wxT("invalid bitmap") );
972 bool is_mono
= (bitmap
.GetBitmap() != NULL
);
974 // scale/translate size and position
975 int xx
= XLOG2DEV(x
);
976 int yy
= YLOG2DEV(y
);
978 int w
= bitmap
.GetWidth();
979 int h
= bitmap
.GetHeight();
981 CalcBoundingBox( x
, y
);
982 CalcBoundingBox( x
+ w
, y
+ h
);
984 if (!m_window
) return;
986 int ww
= XLOG2DEVREL(w
);
987 int hh
= YLOG2DEVREL(h
);
989 // compare to current clipping region
990 if (!m_currentClippingRegion
.IsNull())
992 wxRegion
tmp( xx
,yy
,ww
,hh
);
993 tmp
.Intersect( m_currentClippingRegion
);
998 // scale bitmap if required
1000 if ((w
!= ww
) || (h
!= hh
))
1002 wxImage
image( bitmap
);
1003 image
.Rescale( ww
, hh
);
1006 use_bitmap
= image
.ConvertToMonoBitmap(255,255,255);
1009 use_bitmap
= image
.ConvertToBitmap();
1013 use_bitmap
= bitmap
;
1016 // apply mask if any
1017 WXPixmap mask
= NULL
;
1018 if (use_bitmap
.GetMask()) mask
= use_bitmap
.GetMask()->GetBitmap();
1020 if (useMask
&& mask
)
1022 WXPixmap new_mask
= NULL
;
1024 if (!m_currentClippingRegion
.IsNull())
1027 new_mask
= gdk_pixmap_new( wxGetRootWindow()->window
, ww
, hh
, 1 );
1028 GdkGC
*gc
= gdk_gc_new( new_mask
);
1030 gdk_gc_set_foreground( gc
, &col
);
1031 gdk_draw_rectangle( new_mask
, gc
, TRUE
, 0, 0, ww
, hh
);
1033 gdk_gc_set_background( gc
, &col
);
1035 gdk_gc_set_foreground( gc
, &col
);
1036 gdk_gc_set_clip_region( gc
, m_currentClippingRegion
.GetRegion() );
1037 gdk_gc_set_clip_origin( gc
, -xx
, -yy
);
1038 gdk_gc_set_fill( gc
, GDK_OPAQUE_STIPPLED
);
1039 gdk_gc_set_stipple( gc
, mask
);
1040 gdk_draw_rectangle( new_mask
, gc
, TRUE
, 0, 0, ww
, hh
);
1047 XSetClipMask( (Display
*) m_display
, (GC
) m_textGC
, (Pixmap
) new_mask
);
1049 XSetClipMask( (Display
*) m_display
, (GC
) m_textGC
, (Pixmap
) mask
);
1050 XSetClipOrigin( (Display
*) m_display
, (GC
) m_textGC
, xx
, yy
);
1055 XSetClipMask( (Display
*) m_display
, (GC
) m_penGC
, (Pixmap
) new_mask
);
1057 XSetClipMask( (Display
*) m_display
, (GC
) m_penGC
, (Pixmap
) mask
);
1058 XSetClipOrigin( (Display
*) m_display
, (GC
) m_penGC
, xx
, yy
);
1062 XFreePixmap( (Display
*) m_display
, (Pixmap
) new_mask
);
1065 // Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For
1066 // drawing a mono-bitmap (XBitmap) we use the current text GC
1068 XCopyPlane( (Display
*) m_display
, (Pixmap
) use_bitmap
.GetBitmap(), (Window
) m_window
,
1069 (GC
) m_textGC
, 0, 0, w
, h
, xx
, yy
, 1 );
1071 XCopyArea( (Display
*) m_display
, (Pixmap
) use_bitmap
.GetPixmap(), (Window
) m_window
,
1072 (GC
) m_penGC
, 0, 0, w
, h
, xx
, yy
);
1074 // remove mask again if any
1075 if (useMask
&& mask
)
1079 XSetClipMask( (Display
*) m_display
, (GC
) m_textGC
, None
);
1080 XSetClipOrigin( (Display
*) m_display
, (GC
) m_textGC
, 0, 0 );
1081 if (!m_currentClippingRegion
.IsNull())
1082 XSetRegion( (Display
*) m_display
, (GC
) m_textGC
, (Region
) m_currentClippingRegion
.GetX11Region() );
1086 XSetClipMask( (Display
*) m_display
, (GC
) m_penGC
, None
);
1087 XSetClipOrigin( (Display
*) m_display
, (GC
) m_penGC
, 0, 0 );
1088 if (!m_currentClippingRegion
.IsNull())
1089 XSetRegion( (Display
*) m_display
, (GC
) m_penGC
, (Region
) m_currentClippingRegion
.GetX11Region() );
1094 // wxUSE_NANOX/!wxUSE_NANOX
1096 bool wxWindowDC::DoBlit( wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1097 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int logical_func
, bool useMask
,
1098 wxCoord xsrcMask
, wxCoord ysrcMask
)
1100 /* this is the nth try to get this utterly useless function to
1101 work. it now completely ignores the scaling or translation
1102 of the source dc, but scales correctly on the target dc and
1103 knows about possible mask information in a memory dc. */
1105 wxCHECK_MSG( Ok(), FALSE
, wxT("invalid window dc") );
1107 wxCHECK_MSG( source
, FALSE
, wxT("invalid source dc") );
1109 if (!m_window
) return FALSE
;
1111 // transform the source DC coords to the device ones
1112 xsrc
= source
->XLOG2DEV(xsrc
);
1113 ysrc
= source
->YLOG2DEV(ysrc
);
1115 wxClientDC
*srcDC
= (wxClientDC
*)source
;
1116 wxMemoryDC
*memDC
= (wxMemoryDC
*)source
;
1118 bool use_bitmap_method
= FALSE
;
1119 bool is_mono
= FALSE
;
1121 // TODO: use the mask origin when drawing transparently
1122 if (xsrcMask
== -1 && ysrcMask
== -1)
1128 if (srcDC
->m_isMemDC
)
1130 if (!memDC
->m_selected
.Ok()) return FALSE
;
1132 /* we use the "XCopyArea" way to copy a memory dc into
1133 y different window if the memory dc BOTH
1134 a) doesn't have any mask or its mask isn't used
1138 if (useMask
&& (memDC
->m_selected
.GetMask()))
1140 /* we HAVE TO use the direct way for memory dcs
1141 that have mask since the XCopyArea doesn't know
1143 use_bitmap_method
= TRUE
;
1145 else if (memDC
->m_selected
.GetDepth() == 1)
1147 /* we HAVE TO use the direct way for memory dcs
1148 that are bitmaps because XCopyArea doesn't cope
1149 with different bit depths */
1151 use_bitmap_method
= TRUE
;
1153 else if ((xsrc
== 0) && (ysrc
== 0) &&
1154 (width
== memDC
->m_selected
.GetWidth()) &&
1155 (height
== memDC
->m_selected
.GetHeight()))
1157 /* we SHOULD use the direct way if all of the bitmap
1158 in the memory dc is copied in which case XCopyArea
1159 wouldn't be able able to boost performace by reducing
1160 the area to be scaled */
1161 use_bitmap_method
= TRUE
;
1165 use_bitmap_method
= FALSE
;
1169 CalcBoundingBox( xdest
, ydest
);
1170 CalcBoundingBox( xdest
+ width
, ydest
+ height
);
1172 // scale/translate size and position
1173 wxCoord xx
= XLOG2DEV(xdest
);
1174 wxCoord yy
= YLOG2DEV(ydest
);
1176 wxCoord ww
= XLOG2DEVREL(width
);
1177 wxCoord hh
= YLOG2DEVREL(height
);
1179 // compare to current clipping region
1180 if (!m_currentClippingRegion
.IsNull())
1182 wxRegion
tmp( xx
,yy
,ww
,hh
);
1183 tmp
.Intersect( m_currentClippingRegion
);
1188 int old_logical_func
= m_logicalFunction
;
1189 SetLogicalFunction( logical_func
);
1191 if (use_bitmap_method
)
1193 // scale/translate bitmap size
1194 wxCoord bm_width
= memDC
->m_selected
.GetWidth();
1195 wxCoord bm_height
= memDC
->m_selected
.GetHeight();
1197 wxCoord bm_ww
= XLOG2DEVREL( bm_width
);
1198 wxCoord bm_hh
= YLOG2DEVREL( bm_height
);
1200 // scale bitmap if required
1201 wxBitmap use_bitmap
;
1203 if ((bm_width
!= bm_ww
) || (bm_height
!= bm_hh
))
1205 wxImage
image( memDC
->m_selected
);
1206 image
= image
.Scale( bm_ww
, bm_hh
);
1210 use_bitmap
= image
.ConvertToMonoBitmap(255,255,255);
1213 use_bitmap
= image
.ConvertToBitmap();
1217 use_bitmap
= memDC
->m_selected
;
1220 // apply mask if any
1221 WXPixmap mask
= NULL
;
1222 if (use_bitmap
.GetMask()) mask
= use_bitmap
.GetMask()->GetBitmap();
1224 if (useMask
&& mask
)
1226 WXPixmap new_mask
= NULL
;
1228 if (!m_currentClippingRegion
.IsNull())
1231 new_mask
= gdk_pixmap_new( wxGetRootWindow()->window
, bm_ww
, bm_hh
, 1 );
1232 GdkGC
*gc
= gdk_gc_new( new_mask
);
1234 gdk_gc_set_foreground( gc
, &col
);
1235 gdk_draw_rectangle( new_mask
, gc
, TRUE
, 0, 0, bm_ww
, bm_hh
);
1237 gdk_gc_set_background( gc
, &col
);
1239 gdk_gc_set_foreground( gc
, &col
);
1240 gdk_gc_set_clip_region( gc
, m_currentClippingRegion
.GetRegion() );
1241 gdk_gc_set_clip_origin( gc
, -xx
, -yy
);
1242 gdk_gc_set_fill( gc
, GDK_OPAQUE_STIPPLED
);
1243 gdk_gc_set_stipple( gc
, mask
);
1244 gdk_draw_rectangle( new_mask
, gc
, TRUE
, 0, 0, bm_ww
, bm_hh
);
1251 XSetClipMask( (Display
*) m_display
, (GC
) m_textGC
, (Pixmap
) new_mask
);
1253 XSetClipMask( (Display
*) m_display
, (GC
) m_textGC
, (Pixmap
) mask
);
1254 XSetClipOrigin( (Display
*) m_display
, (GC
) m_textGC
, xx
, yy
);
1259 XSetClipMask( (Display
*) m_display
, (GC
) m_penGC
, (Pixmap
) new_mask
);
1261 XSetClipMask( (Display
*) m_display
, (GC
) m_penGC
, (Pixmap
) mask
);
1262 XSetClipOrigin( (Display
*) m_display
, (GC
) m_penGC
, xx
, yy
);
1266 XFreePixmap( (Display
*) m_display
, (Pixmap
) new_mask
);
1269 // Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For
1270 // drawing a mono-bitmap (XBitmap) we use the current text GC
1273 XCopyPlane( (Display
*) m_display
, (Pixmap
) use_bitmap
.GetBitmap(), (Window
) m_window
,
1274 (GC
) m_textGC
, xsrc
, ysrc
, width
, height
, xx
, yy
, 1 );
1276 XCopyArea( (Display
*) m_display
, (Pixmap
) use_bitmap
.GetPixmap(), (Window
) m_window
,
1277 (GC
) m_penGC
, xsrc
, ysrc
, width
, height
, xx
, yy
);
1279 // remove mask again if any
1280 if (useMask
&& mask
)
1284 XSetClipMask( (Display
*) m_display
, (GC
) m_textGC
, None
);
1285 XSetClipOrigin( (Display
*) m_display
, (GC
) m_textGC
, 0, 0 );
1286 if (!m_currentClippingRegion
.IsNull())
1287 XSetRegion( (Display
*) m_display
, (GC
) m_textGC
, (Region
) m_currentClippingRegion
.GetX11Region() );
1291 XSetClipMask( (Display
*) m_display
, (GC
) m_penGC
, None
);
1292 XSetClipOrigin( (Display
*) m_display
, (GC
) m_penGC
, 0, 0 );
1293 if (!m_currentClippingRegion
.IsNull())
1294 XSetRegion( (Display
*) m_display
, (GC
) m_penGC
, (Region
) m_currentClippingRegion
.GetX11Region() );
1298 else // use_bitmap_method
1300 if ((width
!= ww
) || (height
!= hh
))
1302 /* Draw source window into a bitmap as we cannot scale
1303 a window in contrast to a bitmap. this would actually
1304 work with memory dcs as well, but we'd lose the mask
1305 information and waste one step in this process since
1306 a memory already has a bitmap. all this is slightly
1307 inefficient as we could take an XImage directly from
1308 an X window, but we'd then also have to care that
1309 the window is not outside the screen (in which case
1310 we'd get a BadMatch or what not).
1311 Is a double XGetImage and combined XGetPixel and
1312 XPutPixel really faster? I'm not sure. look at wxXt
1313 for a different implementation of the same problem. */
1315 wxBitmap
bitmap( width
, height
);
1317 // copy including child window contents
1318 XSetSubwindowMode( (Display
*) m_display
, (GC
) m_penGC
, IncludeInferiors
);
1319 XCopyArea( (Display
*) m_display
, (Window
) srcDC
->GetWindow(), (Window
) bitmap
.GetPixmap(),
1320 (GC
) m_penGC
, xsrc
, ysrc
, width
, height
, 0, 0 );
1321 XSetSubwindowMode( (Display
*) m_display
, (GC
) m_penGC
, ClipByChildren
);
1324 wxImage
image( bitmap
);
1325 image
= image
.Scale( ww
, hh
);
1327 // convert to bitmap
1328 bitmap
= image
.ConvertToBitmap();
1330 // draw scaled bitmap
1331 XCopyArea( (Display
*) m_display
, (Window
) bitmap
.GetPixmap(), (Window
) m_window
,
1332 (GC
) m_penGC
, 0, 0, width
, height
, xx
, yy
);
1336 // No scaling and not a memory dc with a mask either
1338 // copy including child window contents
1339 XSetSubwindowMode( (Display
*) m_display
, (GC
) m_penGC
, IncludeInferiors
);
1340 XCopyArea( (Display
*) m_display
, (Window
) srcDC
->GetWindow(), (Window
) m_window
,
1341 (GC
) m_penGC
, xsrc
, ysrc
, width
, height
, xx
, yy
);
1342 XSetSubwindowMode( (Display
*) m_display
, (GC
) m_penGC
, ClipByChildren
);
1346 SetLogicalFunction( old_logical_func
);
1351 void wxWindowDC::DoDrawText( const wxString
&text
, wxCoord x
, wxCoord y
)
1353 wxCHECK_RET( Ok(), wxT("invalid window dc") );
1355 if (!m_window
) return;
1357 XFontStruct
*xfont
= (XFontStruct
*) m_font
.GetFontStruct( m_scaleY
, m_display
);
1359 wxCHECK_RET( xfont
, wxT("invalid font") );
1364 // First draw a rectangle representing the text background, if a text
1365 // background is specified
1366 if (m_textBackgroundColour
.Ok () && (m_backgroundMode
!= wxTRANSPARENT
))
1368 // Since X draws from the baseline of the text, must add the text height
1373 int direction
, descent
;
1375 slen
= strlen(text
);
1376 XCharStruct overall_return
;
1378 (void)XTextExtents(xfont
, (char*) text
.c_str(), slen
, &direction
,
1379 &ascent
, &descent
, &overall_return
);
1381 cx
= overall_return
.width
;
1382 cy
= ascent
+ descent
;
1383 m_textBackgroundColour
.CalcPixel(m_cmap
);
1384 XSetForeground ((Display
*) m_display
, (GC
) m_textGC
, m_textBackgroundColour
.GetPixel());
1385 XFillRectangle( (Display
*) m_display
, (Window
) m_window
,
1386 (GC
) m_textGC
, x
, y
, cx
, cy
);
1387 XSetForeground ((Display
*) m_display
, (GC
) m_textGC
, m_textForegroundColour
.GetPixel());
1391 XSetFont( (Display
*) m_display
, (GC
) m_textGC
, xfont
->fid
);
1393 if ((xfont
->min_byte1
== 0) && (xfont
->max_byte1
== 0))
1396 XDrawString( (Display
*) m_display
, (Window
) m_window
,
1397 (GC
) m_textGC
, x
, y
+ XFontStructGetAscent(xfont
), text
.c_str(), text
.Len() );
1401 if (m_font
.GetUnderlined())
1403 wxCoord ul_y
= y
+ XFontStructGetAscent(font
);
1404 if (font
->descent
> 0) ul_y
++;
1405 gdk_draw_line( m_window
, m_textGC
, x
, ul_y
, x
+ width
, ul_y
);
1408 width
= wxCoord(width
/ m_scaleX
);
1409 height
= wxCoord(height
/ m_scaleY
);
1411 CalcBoundingBox (x
+ width
, y
+ height
);
1412 CalcBoundingBox (x
, y
);
1416 void wxWindowDC::DoDrawRotatedText( const wxString
&text
, wxCoord x
, wxCoord y
, double angle
)
1421 void wxWindowDC::DoGetTextExtent( const wxString
&string
, wxCoord
*width
, wxCoord
*height
,
1422 wxCoord
*descent
, wxCoord
*externalLeading
,
1423 wxFont
*font
) const
1425 wxCHECK_RET( Ok(), "invalid dc" );
1427 wxFont fontToUse
= m_font
;
1428 if (font
) fontToUse
= *font
;
1430 wxCHECK_RET( fontToUse
.Ok(), "invalid font" );
1432 XFontStruct
*xfont
= (XFontStruct
*) fontToUse
.GetFontStruct( m_scaleY
, m_display
);
1434 wxCHECK_RET( xfont
, wxT("invalid font") );
1436 int direction
, ascent
, descent2
;
1437 XCharStruct overall
;
1439 XTextExtents( xfont
, (char*) string
.c_str(), string
.Len(), &direction
,
1440 &ascent
, &descent2
, &overall
);
1443 *width
= (wxCoord
)( overall
.width
/ m_scaleX
);
1445 *height
= (wxCoord
)((ascent
+ descent2
) / m_scaleY
);
1447 *descent
= (wxCoord
)(descent2
/ m_scaleY
);
1448 if (externalLeading
)
1449 *externalLeading
= 0; // ??
1452 wxCoord
wxWindowDC::GetCharWidth() const
1454 wxCHECK_MSG( Ok(), 0, "invalid dc" );
1456 wxCHECK_MSG( m_font
.Ok(), 0, "invalid font" );
1458 XFontStruct
*xfont
= (XFontStruct
*) m_font
.GetFontStruct( m_scaleY
, m_display
);
1460 wxCHECK_MSG( xfont
, 0, wxT("invalid font") );
1462 int direction
, ascent
, descent
;
1463 XCharStruct overall
;
1465 XTextExtents( xfont
, "H", 1, &direction
, &ascent
, &descent
, &overall
);
1467 return (wxCoord
)(overall
.width
/ m_scaleX
);
1470 wxCoord
wxWindowDC::GetCharHeight() const
1472 wxCHECK_MSG( Ok(), 0, "invalid dc" );
1474 wxCHECK_MSG( m_font
.Ok(), 0, "invalid font" );
1476 XFontStruct
*xfont
= (XFontStruct
*) m_font
.GetFontStruct( m_scaleY
, m_display
);
1478 wxCHECK_MSG( xfont
, 0, wxT("invalid font") );
1480 int direction
, ascent
, descent
;
1481 XCharStruct overall
;
1483 XTextExtents( xfont
, "H", 1, &direction
, &ascent
, &descent
, &overall
);
1485 return (wxCoord
)((ascent
+descent
) / m_scaleY
);
1488 void wxWindowDC::Clear()
1490 wxCHECK_RET( Ok(), wxT("invalid window dc") );
1492 if (!m_window
) return;
1494 /* - we either are a memory dc or have a window as the
1495 owner. anything else shouldn't happen.
1496 - we don't use gdk_window_clear() as we don't set
1497 the window's background colour anymore. it is too
1498 much pain to keep the DC's and the window's back-
1499 ground colour in synch. */
1504 m_owner
->GetSize( &width
, &height
);
1505 XFillRectangle( (Display
*) m_display
, (Window
) m_window
, (GC
) m_bgGC
, 0, 0, width
, height
);
1512 GetSize( &width
, &height
);
1513 XFillRectangle( (Display
*) m_display
, (Window
) m_window
, (GC
) m_bgGC
, 0, 0, width
, height
);
1518 void wxWindowDC::SetFont( const wxFont
&font
)
1520 wxCHECK_RET( Ok(), "invalid dc" );
1525 void wxWindowDC::SetPen( const wxPen
&pen
)
1527 wxCHECK_RET( Ok(), wxT("invalid window dc") );
1529 if (m_pen
== pen
) return;
1533 if (!m_pen
.Ok()) return;
1535 if (!m_window
) return;
1537 int width
= m_pen
.GetWidth();
1540 // CMB: if width is non-zero scale it with the dc
1545 // X doesn't allow different width in x and y and so we take
1548 ( fabs((double) XLOG2DEVREL(width
)) +
1549 fabs((double) YLOG2DEVREL(width
)) ) / 2.0;
1553 static const wxX11Dash dotted
[] = {1, 1};
1554 static const wxX11Dash short_dashed
[] = {2, 2};
1555 static const wxX11Dash long_dashed
[] = {2, 4};
1556 static const wxX11Dash dotted_dashed
[] = {3, 3, 1, 3};
1558 // We express dash pattern in pen width unit, so we are
1559 // independent of zoom factor and so on...
1561 const wxX11Dash
*req_dash
;
1563 int lineStyle
= LineSolid
;
1564 switch (m_pen
.GetStyle())
1568 lineStyle
= LineOnOffDash
;
1569 req_nb_dash
= m_pen
.GetDashCount();
1570 req_dash
= (wxX11Dash
*)m_pen
.GetDash();
1575 lineStyle
= LineOnOffDash
;
1582 lineStyle
= LineOnOffDash
;
1584 req_dash
= long_dashed
;
1589 lineStyle
= LineOnOffDash
;
1591 req_dash
= short_dashed
;
1596 // lineStyle = LineDoubleDash;
1597 lineStyle
= LineOnOffDash
;
1599 req_dash
= dotted_dashed
;
1604 case wxSTIPPLE_MASK_OPAQUE
:
1609 lineStyle
= LineSolid
;
1610 req_dash
= (wxX11Dash
*)NULL
;
1616 int capStyle
= CapRound
;
1617 switch (m_pen
.GetCap())
1619 case wxCAP_PROJECTING
: { capStyle
= CapProjecting
; break; }
1620 case wxCAP_BUTT
: { capStyle
= CapButt
; break; }
1627 capStyle
= CapNotLast
;
1631 capStyle
= CapRound
;
1637 int joinStyle
= JoinRound
;
1638 switch (m_pen
.GetJoin())
1640 case wxJOIN_BEVEL
: { joinStyle
= JoinBevel
; break; }
1641 case wxJOIN_MITER
: { joinStyle
= JoinMiter
; break; }
1643 default: { joinStyle
= JoinRound
; break; }
1646 XSetLineAttributes( (Display
*) m_display
, (GC
) m_penGC
, width
, lineStyle
, capStyle
, joinStyle
);
1648 m_pen
.GetColour().CalcPixel( m_cmap
);
1649 XSetForeground( (Display
*) m_display
, (GC
) m_penGC
, m_pen
.GetColour().GetPixel() );
1652 void wxWindowDC::SetBrush( const wxBrush
&brush
)
1654 wxCHECK_RET( Ok(), wxT("invalid window dc") );
1656 if (m_brush
== brush
) return;
1660 if (!m_brush
.Ok()) return;
1662 if (!m_window
) return;
1664 m_brush
.GetColour().CalcPixel( m_cmap
);
1665 XSetForeground( (Display
*) m_display
, (GC
) m_brushGC
, m_brush
.GetColour().GetPixel() );
1667 XSetFillStyle( (Display
*) m_display
, (GC
) m_brushGC
, FillSolid
);
1669 if ((m_brush
.GetStyle() == wxSTIPPLE
) && (m_brush
.GetStipple()->Ok()))
1671 if (m_brush
.GetStipple()->GetPixmap())
1673 XSetFillStyle( (Display
*) m_display
, (GC
) m_brushGC
, FillTiled
);
1674 XSetTile( (Display
*) m_display
, (GC
) m_brushGC
, (Pixmap
) m_brush
.GetStipple()->GetPixmap() );
1678 XSetFillStyle( (Display
*) m_display
, (GC
) m_brushGC
, FillStippled
);
1679 XSetStipple( (Display
*) m_display
, (GC
) m_brushGC
, (Pixmap
) m_brush
.GetStipple()->GetBitmap() );
1683 if ((m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
) && (m_brush
.GetStipple()->GetMask()))
1685 XSetFillStyle( (Display
*) m_display
, (GC
) m_textGC
, FillOpaqueStippled
);
1686 XSetStipple( (Display
*) m_display
, (GC
) m_textGC
, (Pixmap
) m_brush
.GetStipple()->GetMask()->GetBitmap() );
1689 if (IS_HATCH(m_brush
.GetStyle()))
1691 XSetFillStyle( (Display
*) m_display
, (GC
) m_brushGC
, FillStippled
);
1692 int num
= m_brush
.GetStyle() - wxBDIAGONAL_HATCH
;
1693 XSetStipple( (Display
*) m_display
, (GC
) m_brushGC
, hatches
[num
] );
1697 void wxWindowDC::SetBackground( const wxBrush
&brush
)
1699 /* CMB 21/7/98: Added SetBackground. Sets background brush
1700 * for Clear() and bg colour for shapes filled with cross-hatch brush */
1702 wxCHECK_RET( Ok(), wxT("invalid window dc") );
1704 if (m_backgroundBrush
== brush
) return;
1706 m_backgroundBrush
= brush
;
1708 if (!m_backgroundBrush
.Ok()) return;
1710 if (!m_window
) return;
1712 m_backgroundBrush
.GetColour().CalcPixel( m_cmap
);
1713 XSetBackground( (Display
*) m_display
, (GC
) m_brushGC
, m_backgroundBrush
.GetColour().GetPixel() );
1714 XSetBackground( (Display
*) m_display
, (GC
) m_penGC
, m_backgroundBrush
.GetColour().GetPixel() );
1715 XSetBackground( (Display
*) m_display
, (GC
) m_bgGC
, m_backgroundBrush
.GetColour().GetPixel() );
1716 XSetForeground( (Display
*) m_display
, (GC
) m_bgGC
, m_backgroundBrush
.GetColour().GetPixel() );
1718 XSetFillStyle( (Display
*) m_display
, (GC
) m_bgGC
, FillSolid
);
1720 if ((m_backgroundBrush
.GetStyle() == wxSTIPPLE
) && (m_backgroundBrush
.GetStipple()->Ok()))
1722 if (m_backgroundBrush
.GetStipple()->GetPixmap())
1724 XSetFillStyle( (Display
*) m_display
, (GC
) m_bgGC
, FillTiled
);
1725 XSetTile( (Display
*) m_display
, (GC
) m_bgGC
, (Pixmap
) m_backgroundBrush
.GetStipple()->GetPixmap() );
1729 XSetFillStyle( (Display
*) m_display
, (GC
) m_bgGC
, FillStippled
);
1730 XSetStipple( (Display
*) m_display
, (GC
) m_bgGC
, (Pixmap
) m_backgroundBrush
.GetStipple()->GetBitmap() );
1734 if (IS_HATCH(m_backgroundBrush
.GetStyle()))
1736 XSetFillStyle( (Display
*) m_display
, (GC
) m_bgGC
, FillStippled
);
1737 int num
= m_backgroundBrush
.GetStyle() - wxBDIAGONAL_HATCH
;
1738 XSetStipple( (Display
*) m_display
, (GC
) m_bgGC
, hatches
[num
] );
1742 void wxWindowDC::SetLogicalFunction( int function
)
1744 wxCHECK_RET( Ok(), "invalid dc" );
1748 if (m_logicalFunction
== function
)
1751 // VZ: shouldn't this be a CHECK?
1758 x_function
= GXclear
;
1764 x_function
= GXinvert
;
1767 x_function
= GXorReverse
;
1770 x_function
= GXandReverse
;
1779 x_function
= GXandInverted
;
1782 x_function
= GXnoop
;
1788 x_function
= GXequiv
;
1791 x_function
= GXcopyInverted
;
1794 x_function
= GXorInverted
;
1797 x_function
= GXnand
;
1804 x_function
= GXcopy
;
1808 XSetFunction( (Display
*) m_display
, (GC
) m_penGC
, x_function
);
1809 XSetFunction( (Display
*) m_display
, (GC
) m_brushGC
, x_function
);
1811 // to stay compatible with wxMSW, we don't apply ROPs to the text
1812 // operations (i.e. DrawText/DrawRotatedText).
1813 // True, but mono-bitmaps use the m_textGC and they use ROPs as well.
1814 XSetFunction( (Display
*) m_display
, (GC
) m_textGC
, x_function
);
1816 m_logicalFunction
= function
;
1819 void wxWindowDC::SetTextForeground( const wxColour
&col
)
1821 wxCHECK_RET( Ok(), wxT("invalid window dc") );
1823 // don't set m_textForegroundColour to an invalid colour as we'd crash
1824 // later then (we use m_textForegroundColour.GetColor() without checking
1826 if ( !col
.Ok() || (m_textForegroundColour
== col
) )
1829 m_textForegroundColour
= col
;
1833 m_textForegroundColour
.CalcPixel( m_cmap
);
1834 XSetForeground( (Display
*) m_display
, (GC
) m_textGC
, m_textForegroundColour
.GetPixel() );
1838 void wxWindowDC::SetTextBackground( const wxColour
&col
)
1840 wxCHECK_RET( Ok(), wxT("invalid window dc") );
1843 if ( !col
.Ok() || (m_textBackgroundColour
== col
) )
1846 m_textBackgroundColour
= col
;
1850 m_textBackgroundColour
.CalcPixel( m_cmap
);
1851 XSetBackground( (Display
*) m_display
, (GC
) m_textGC
, m_textBackgroundColour
.GetPixel() );
1855 void wxWindowDC::SetBackgroundMode( int mode
)
1857 wxCHECK_RET( Ok(), wxT("invalid window dc") );
1859 m_backgroundMode
= mode
;
1862 GrSetGCUseBackground((GC
) m_textGC
, mode
== wxTRANSPARENT
? FALSE
: TRUE
);
1865 if (!m_window
) return;
1867 // CMB 21/7/98: fill style of cross-hatch brushes is affected by
1868 // transparent/solid background mode
1870 if (m_brush
.GetStyle() != wxSOLID
&& m_brush
.GetStyle() != wxTRANSPARENT
)
1872 XSetFillStyle( (Display
*) m_display
, (GC
) m_brushGC
,
1873 (m_backgroundMode
== wxTRANSPARENT
) ? FillStippled
: FillOpaqueStippled
);
1877 void wxWindowDC::SetPalette( const wxPalette
& palette
)
1883 /* Use GetXColormap */
1884 XSetWindowColormap ((Display
*) m_display
, (Window
) m_window
->GetXWindow(),
1885 (Colormap
) palette
.GetXColormap());
1887 /* Use wxGetMainColormap */
1888 XSetWindowColormap ((Display
*) m_display
, (Window
) m_window
->GetXWindow(),
1889 (Colormap
) wxTheApp
->GetMainColormap(m_display
));
1894 void wxWindowDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1896 wxCHECK_RET( Ok(), wxT("invalid window dc") );
1898 if (!m_window
) return;
1901 rect
.x
= XLOG2DEV(x
);
1902 rect
.y
= YLOG2DEV(y
);
1903 rect
.width
= XLOG2DEVREL(width
);
1904 rect
.height
= YLOG2DEVREL(height
);
1906 if (!m_currentClippingRegion
.IsNull())
1907 m_currentClippingRegion
.Intersect( rect
);
1909 m_currentClippingRegion
.Union( rect
);
1911 #if USE_PAINT_REGION
1912 if (!m_paintClippingRegion
.IsNull())
1913 m_currentClippingRegion
.Intersect( m_paintClippingRegion
);
1916 wxCoord xx
, yy
, ww
, hh
;
1917 m_currentClippingRegion
.GetBox( xx
, yy
, ww
, hh
);
1918 wxDC::DoSetClippingRegion( xx
, yy
, ww
, hh
);
1920 XSetRegion( (Display
*) m_display
, (GC
) m_penGC
, (Region
) m_currentClippingRegion
.GetX11Region() );
1921 XSetRegion( (Display
*) m_display
, (GC
) m_brushGC
, (Region
) m_currentClippingRegion
.GetX11Region() );
1922 XSetRegion( (Display
*) m_display
, (GC
) m_textGC
, (Region
) m_currentClippingRegion
.GetX11Region() );
1923 XSetRegion( (Display
*) m_display
, (GC
) m_bgGC
, (Region
) m_currentClippingRegion
.GetX11Region() );
1926 void wxWindowDC::DoSetClippingRegionAsRegion( const wxRegion
& region
)
1928 wxCHECK_RET( Ok(), wxT("invalid window dc") );
1932 DestroyClippingRegion();
1936 if (!m_window
) return;
1938 if (!m_currentClippingRegion
.IsNull())
1939 m_currentClippingRegion
.Intersect( region
);
1941 m_currentClippingRegion
.Union( region
);
1943 #if USE_PAINT_REGION
1944 if (!m_paintClippingRegion
.IsNull())
1945 m_currentClippingRegion
.Intersect( m_paintClippingRegion
);
1948 wxCoord xx
, yy
, ww
, hh
;
1949 m_currentClippingRegion
.GetBox( xx
, yy
, ww
, hh
);
1950 wxDC::DoSetClippingRegion( xx
, yy
, ww
, hh
);
1952 XSetRegion( (Display
*) m_display
, (GC
) m_penGC
, (Region
) m_currentClippingRegion
.GetX11Region() );
1953 XSetRegion( (Display
*) m_display
, (GC
) m_brushGC
, (Region
) m_currentClippingRegion
.GetX11Region() );
1954 XSetRegion( (Display
*) m_display
, (GC
) m_textGC
, (Region
) m_currentClippingRegion
.GetX11Region() );
1955 XSetRegion( (Display
*) m_display
, (GC
) m_bgGC
, (Region
) m_currentClippingRegion
.GetX11Region() );
1958 void wxWindowDC::DestroyClippingRegion()
1960 wxCHECK_RET( Ok(), wxT("invalid window dc") );
1962 wxDC::DestroyClippingRegion();
1964 m_currentClippingRegion
.Clear();
1966 #if USE_PAINT_REGION
1967 if (!m_paintClippingRegion
.IsEmpty())
1968 m_currentClippingRegion
.Union( m_paintClippingRegion
);
1971 if (!m_window
) return;
1973 if (m_currentClippingRegion
.IsEmpty())
1975 XSetClipMask( (Display
*) m_display
, (GC
) m_penGC
, None
);
1976 XSetClipMask( (Display
*) m_display
, (GC
) m_brushGC
, None
);
1977 XSetClipMask( (Display
*) m_display
, (GC
) m_textGC
, None
);
1978 XSetClipMask( (Display
*) m_display
, (GC
) m_bgGC
, None
);
1982 XSetRegion( (Display
*) m_display
, (GC
) m_penGC
, (Region
) m_currentClippingRegion
.GetX11Region() );
1983 XSetRegion( (Display
*) m_display
, (GC
) m_brushGC
, (Region
) m_currentClippingRegion
.GetX11Region() );
1984 XSetRegion( (Display
*) m_display
, (GC
) m_textGC
, (Region
) m_currentClippingRegion
.GetX11Region() );
1985 XSetRegion( (Display
*) m_display
, (GC
) m_bgGC
, (Region
) m_currentClippingRegion
.GetX11Region() );
1989 void wxWindowDC::Destroy()
1991 if (m_penGC
) wxFreePoolGC( (GC
) m_penGC
);
1993 if (m_brushGC
) wxFreePoolGC( (GC
) m_brushGC
);
1995 if (m_textGC
) wxFreePoolGC( (GC
) m_textGC
);
1997 if (m_bgGC
) wxFreePoolGC( (GC
) m_bgGC
);
2001 void wxWindowDC::ComputeScaleAndOrigin()
2003 /* CMB: copy scale to see if it changes */
2004 double origScaleX
= m_scaleX
;
2005 double origScaleY
= m_scaleY
;
2007 wxDC::ComputeScaleAndOrigin();
2009 /* CMB: if scale has changed call SetPen to recalulate the line width */
2010 if ((m_scaleX
!= origScaleX
|| m_scaleY
!= origScaleY
) &&
2013 /* this is a bit artificial, but we need to force wxDC to think
2014 the pen has changed */
2021 wxSize
wxWindowDC::GetPPI() const
2023 return wxSize(100, 100);
2026 int wxWindowDC::GetDepth() const
2028 wxFAIL_MSG(wxT("not implemented"));
2033 //-----------------------------------------------------------------------------
2035 //-----------------------------------------------------------------------------
2037 IMPLEMENT_DYNAMIC_CLASS(wxClientDC
, wxWindowDC
)
2039 wxClientDC::wxClientDC( wxWindow
*window
)
2040 : wxWindowDC( window
)
2042 wxCHECK_RET( window
, _T("NULL window in wxClientDC::wxClientDC") );
2044 m_window
= (WXWindow
*) window
->GetClientWindow();
2046 #if wxUSE_TWO_WINDOWS
2048 wxPoint ptOrigin
= window
->GetClientAreaOrigin();
2049 SetDeviceOrigin(ptOrigin
.x
, ptOrigin
.y
);
2050 wxSize size
= window
->GetClientSize();
2051 SetClippingRegion(wxPoint(0, 0), size
);
2055 void wxClientDC::DoGetSize(int *width
, int *height
) const
2057 wxCHECK_RET( m_owner
, _T("GetSize() doesn't work without window") );
2059 m_owner
->GetClientSize( width
, height
);
2062 // ----------------------------------------------------------------------------
2064 // ----------------------------------------------------------------------------
2066 IMPLEMENT_DYNAMIC_CLASS(wxPaintDC
, wxClientDC
)
2068 wxPaintDC::wxPaintDC(wxWindow
* window
)
2069 : wxClientDC(window
)
2071 #if USE_PAINT_REGION
2072 if (!window
->GetClipPaintRegion())
2075 m_paintClippingRegion
= window
->GetUpdateRegion();
2076 Region region
= (Region
) m_paintClippingRegion
.GetX11Region();
2079 m_currentClippingRegion
.Union( m_paintClippingRegion
);
2081 XSetRegion( (Display
*) m_display
, (GC
) m_penGC
, region
);
2082 XSetRegion( (Display
*) m_display
, (GC
) m_brushGC
, region
);
2083 XSetRegion( (Display
*) m_display
, (GC
) m_textGC
, region
);
2084 XSetRegion( (Display
*) m_display
, (GC
) m_bgGC
, region
);
2086 #endif // USE_PAINT_REGION
2089 // ----------------------------------------------------------------------------
2091 // ----------------------------------------------------------------------------
2093 class wxDCModule
: public wxModule
2100 DECLARE_DYNAMIC_CLASS(wxDCModule
)
2103 IMPLEMENT_DYNAMIC_CLASS(wxDCModule
, wxModule
)
2105 bool wxDCModule::OnInit()
2111 void wxDCModule::OnExit()