]>
git.saurik.com Git - wxWidgets.git/blob - src/dfb/dc.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/dfb/dc.cpp
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2006 REA Elektronik GmbH
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // ===========================================================================
13 // ===========================================================================
15 // ---------------------------------------------------------------------------
17 // ---------------------------------------------------------------------------
19 // For compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
31 #include "wx/dfb/private.h"
33 // these values are used to initialize newly created DC
34 #define DEFAULT_FONT (*wxNORMAL_FONT)
35 #define DEFAULT_PEN (*wxBLACK_PEN)
36 #define DEFAULT_BRUSH (*wxWHITE_BRUSH)
38 // ===========================================================================
40 // ===========================================================================
42 //-----------------------------------------------------------------------------
44 //-----------------------------------------------------------------------------
46 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxDCBase
)
48 // Default constructor
54 wxDC::wxDC(const wxIDirectFBSurfacePtr
& surface
)
59 void wxDC::Init(const wxIDirectFBSurfacePtr
& surface
)
61 m_ok
= (surface
!= NULL
);
62 wxCHECK_RET( surface
!= NULL
, _T("invalid surface") );
66 m_mm_to_pix_x
= (double)wxGetDisplaySize().GetWidth() /
67 (double)wxGetDisplaySizeMM().GetWidth();
68 m_mm_to_pix_y
= (double)wxGetDisplaySize().GetHeight() /
69 (double)wxGetDisplaySizeMM().GetHeight();
71 SetFont(DEFAULT_FONT
);
73 SetBrush(DEFAULT_BRUSH
);
77 // ---------------------------------------------------------------------------
79 // ---------------------------------------------------------------------------
82 #define DO_SET_CLIPPING_BOX(rg) \
84 wxRect rect = rg.GetBox(); \
85 m_clipX1 = (wxCoord) XDEV2LOG(rect.GetLeft()); \
86 m_clipY1 = (wxCoord) YDEV2LOG(rect.GetTop()); \
87 m_clipX2 = (wxCoord) XDEV2LOG(rect.GetRight()); \
88 m_clipY2 = (wxCoord) YDEV2LOG(rect.GetBottom()); \
91 void wxDC::DoSetClippingRegion(wxCoord cx
, wxCoord cy
, wxCoord cw
, wxCoord ch
)
93 wxCHECK_RET( Ok(), wxT("invalid dc") );
95 wxSize
size(GetSize());
97 // NB: We intersect the clipping rectangle with surface's area here because
98 // DirectFB will return an error if you try to set clipping rectangle
99 // that is partially outside of the surface.
101 r
.x1
= wxMax(0, XLOG2DEV(cx
));
102 r
.y1
= wxMax(0, YLOG2DEV(cy
));
103 r
.x2
= wxMin(r
.x1
+ XLOG2DEVREL(cw
), size
.x
) - 1;
104 r
.y2
= wxMin(r
.y1
+ YLOG2DEVREL(ch
), size
.y
) - 1;
106 if ( !m_surface
->SetClip(&r
) )
111 m_clipX2
= cx
+ cw
- 1;
112 m_clipY2
= cy
+ ch
-1;
116 void wxDC::DoSetClippingRegionAsRegion(const wxRegion
& region
)
118 // NB: this can be done because wxDFB only supports
119 // rectangular regions
120 SetClippingRegion(region
.AsRect());
123 void wxDC::DestroyClippingRegion()
125 wxCHECK_RET( Ok(), wxT("invalid dc") );
127 m_surface
->SetClip(NULL
);
132 // ---------------------------------------------------------------------------
133 // query capabilities
134 // ---------------------------------------------------------------------------
136 int wxDC::GetDepth() const
138 return m_surface
->GetDepth();
141 // ---------------------------------------------------------------------------
143 // ---------------------------------------------------------------------------
147 wxCHECK_RET( Ok(), wxT("invalid dc") );
149 if ( m_backgroundBrush
.GetStyle() == wxTRANSPARENT
)
152 wxColour clr
= m_backgroundBrush
.GetColour();
153 m_surface
->Clear(clr
.Red(), clr
.Green(), clr
.Blue(), clr
.Alpha());
156 extern bool wxDoFloodFill(wxDC
*dc
, wxCoord x
, wxCoord y
,
157 const wxColour
& col
, int style
);
159 bool wxDC::DoFloodFill(wxCoord x
, wxCoord y
,
160 const wxColour
& col
, int style
)
162 return wxDoFloodFill(this, x
, y
, col
, style
);
165 bool wxDC::DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
167 wxCHECK_MSG( col
, false, _T("NULL colour parameter in wxDC::GetPixel"));
169 wxFAIL_MSG( _T("GetPixel not implemented") );
173 void wxDC::DoCrossHair(wxCoord x
, wxCoord y
)
175 wxCHECK_RET( Ok(), wxT("invalid dc") );
177 wxFAIL_MSG( _T("CrossHair not implemented") );
180 void wxDC::DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
182 wxCHECK_RET( Ok(), wxT("invalid dc") );
184 if ( m_pen
.GetStyle() == wxTRANSPARENT
)
187 m_surface
->DrawLine(XLOG2DEV(x1
), YLOG2DEV(y1
),
188 XLOG2DEV(x2
), YLOG2DEV(y2
));
190 CalcBoundingBox(x1
, y1
);
191 CalcBoundingBox(x2
, y2
);
194 // Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1)
195 // and ending at (x2, y2)
196 void wxDC::DoDrawArc(wxCoord x1
, wxCoord y1
,
197 wxCoord x2
, wxCoord y2
,
198 wxCoord xc
, wxCoord yc
)
200 wxCHECK_RET( Ok(), wxT("invalid dc") );
202 wxFAIL_MSG( _T("DrawArc not implemented") );
205 void wxDC::DoDrawPoint(wxCoord x
, wxCoord y
)
207 wxCHECK_RET( Ok(), wxT("invalid dc") );
209 // NB: DirectFB API doesn't provide a function for drawing points, so
210 // implement it as 1px long line. This is inefficient, but then, so is
211 // using DrawPoint() for drawing more than a few points.
212 DoDrawLine(x
, y
, x
, y
);
214 // FIXME_DFB: implement special cases for common formats (RGB24,RGBA/RGB32)
217 void wxDC::DoDrawPolygon(int n
, wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
,int WXUNUSED(fillStyle
))
219 wxCHECK_RET( Ok(), wxT("invalid dc") );
221 wxFAIL_MSG( _T("DrawPolygon not implemented") );
224 void wxDC::DoDrawLines(int n
, wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
)
226 wxCHECK_RET( Ok(), wxT("invalid dc") );
228 // TODO: impl. using DirectDB's DrawLines
229 wxFAIL_MSG( _T("DrawLines not implemented") );
232 void wxDC::DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
234 wxCHECK_RET( Ok(), wxT("invalid dc") );
236 wxCoord xx
= XLOG2DEV(x
);
237 wxCoord yy
= YLOG2DEV(y
);
238 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
239 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
241 if ( ww
== 0 || hh
== 0 ) return;
254 if ( m_brush
.GetStyle() != wxTRANSPARENT
)
256 SelectColour(m_brush
.GetColour());
257 m_surface
->FillRectangle(xx
, yy
, ww
, hh
);
258 // restore pen's colour
259 SelectColour(m_pen
.GetColour());
262 if ( m_pen
.GetStyle() != wxTRANSPARENT
)
264 m_surface
->DrawRectangle(xx
, yy
, ww
, hh
);
267 CalcBoundingBox(x
, y
);
268 CalcBoundingBox(x
+ width
, y
+ height
);
271 void wxDC::DoDrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double radius
)
273 wxCHECK_RET( Ok(), wxT("invalid dc") );
275 wxFAIL_MSG( _T("DrawRoundedRectangle not implemented") );
278 void wxDC::DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
280 wxCHECK_RET( Ok(), wxT("invalid dc") );
282 wxFAIL_MSG( _T("DrawElipse not implemented") );
285 void wxDC::DoDrawEllipticArc(wxCoord x
,wxCoord y
,wxCoord w
,wxCoord h
,double sa
,double ea
)
287 wxCHECK_RET( Ok(), wxT("invalid dc") );
289 wxFAIL_MSG( _T("DrawElipticArc not implemented") );
292 void wxDC::DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
294 wxCHECK_RET( Ok(), wxT("invalid dc") );
296 wxCoord xx
= XLOG2DEV(x
);
297 wxCoord yy
= YLOG2DEV(y
);
299 // update the bounding box
301 CalcBoundingBox(x
, y
);
302 GetTextExtent(text
, &w
, &h
);
303 CalcBoundingBox(x
+ w
, y
+ h
);
305 // if background mode is solid, DrawText must paint text's background:
306 if ( m_backgroundMode
== wxSOLID
)
308 wxCHECK_RET( m_backgroundBrush
.Ok(), wxT("invalid background brush") );
310 SelectColour(m_backgroundBrush
.GetColour());
311 m_surface
->FillRectangle(xx
, yy
, XLOG2DEVREL(w
), YLOG2DEVREL(h
));
312 // restore pen's colour
313 SelectColour(m_pen
.GetColour());
316 // finally draw the text itself:
317 m_surface
->DrawString(wxSTR_TO_DFB(text
), -1, xx
, yy
, DSTF_LEFT
| DSTF_TOP
);
320 void wxDC::DoDrawRotatedText(const wxString
& text
,
321 wxCoord x
, wxCoord y
,
324 wxCHECK_RET( Ok(), wxT("invalid dc") );
326 wxFAIL_MSG( _T("DrawRotatedText not implemented") );
329 // ---------------------------------------------------------------------------
331 // ---------------------------------------------------------------------------
333 void wxDC::SetPen(const wxPen
& pen
)
335 m_pen
= pen
.Ok() ? pen
: DEFAULT_PEN
;
337 SelectColour(m_pen
.GetColour());
340 void wxDC::SetBrush(const wxBrush
& brush
)
342 m_brush
= brush
.Ok() ? brush
: DEFAULT_BRUSH
;
345 void wxDC::SelectColour(const wxColour
& clr
)
347 m_surface
->SetColor(clr
.Red(), clr
.Green(), clr
.Blue(), clr
.Alpha());
348 #warning "use SetColorIndex?"
352 void wxDC::SetPalette(const wxPalette
& WXUNUSED(palette
))
354 wxCHECK_RET( Ok(), wxT("invalid dc") );
356 wxFAIL_MSG( _T("SetPalette not implemented") );
358 #endif // wxUSE_PALETTE
360 void wxDC::SetFont(const wxFont
& font
)
362 wxCHECK_RET( Ok(), wxT("invalid dc") );
364 wxFont
f(font
.Ok() ? font
: DEFAULT_FONT
);
366 if ( !m_surface
->SetFont(f
.GetDirectFBFont()) )
372 void wxDC::SetBackground(const wxBrush
& brush
)
374 wxCHECK_RET( Ok(), wxT("invalid dc") );
376 if (!brush
.Ok()) return;
378 m_backgroundBrush
= brush
;
381 void wxDC::SetBackgroundMode(int mode
)
383 m_backgroundMode
= mode
;
386 void wxDC::SetLogicalFunction(int function
)
388 wxCHECK_RET( Ok(), wxT("invalid dc") );
390 wxFAIL_MSG( _T("SetLogicalFunction not implemented") );
392 m_logicalFunction
= function
;
395 bool wxDC::StartDoc(const wxString
& WXUNUSED(message
))
397 // We might be previewing, so return true to let it continue.
405 void wxDC::StartPage()
413 // ---------------------------------------------------------------------------
415 // ---------------------------------------------------------------------------
417 wxCoord
wxDC::GetCharHeight() const
419 wxCHECK_MSG( Ok(), -1, wxT("invalid dc") );
420 wxCHECK_MSG( m_font
.Ok(), -1, wxT("no font selected") );
423 m_font
.GetDirectFBFont()->GetHeight(&h
);
424 return YDEV2LOGREL(h
);
427 wxCoord
wxDC::GetCharWidth() const
429 wxCHECK_MSG( Ok(), -1, wxT("invalid dc") );
430 wxCHECK_MSG( m_font
.Ok(), -1, wxT("no font selected") );
433 m_font
.GetDirectFBFont()->GetStringWidth("H", 1, &w
);
434 // VS: YDEV is corrent, it should *not* be XDEV, because font's are only
435 // scaled according to m_scaleY
436 return YDEV2LOGREL(w
);
439 void wxDC::DoGetTextExtent(const wxString
& string
, wxCoord
*x
, wxCoord
*y
,
440 wxCoord
*descent
, wxCoord
*externalLeading
,
441 wxFont
*theFont
) const
443 wxCHECK_RET( Ok(), wxT("invalid dc") );
444 wxCHECK_RET( m_font
.Ok(), wxT("no font selected") );
445 wxCHECK_RET( !theFont
|| theFont
->Ok(), wxT("invalid font") );
448 if ( theFont
!= NULL
)
451 wxConstCast(this, wxDC
)->SetFont(*theFont
);
454 wxCoord xx
= 0, yy
= 0;
456 wxIDirectFBFontPtr f
= m_font
.GetDirectFBFont();
458 if ( f
->GetStringExtents(wxSTR_TO_DFB(string
), -1, &rect
, NULL
) )
460 // VS: YDEV is corrent, it should *not* be XDEV, because font's are
461 // only scaled according to m_scaleY
462 xx
= YDEV2LOGREL(rect
.w
);
463 yy
= YDEV2LOGREL(rect
.h
);
468 if ( f
->GetDescender(&d
) )
469 *descent
= YDEV2LOGREL(-d
);
477 if ( externalLeading
) *externalLeading
= 0;
479 if ( theFont
!= NULL
)
480 wxConstCast(this, wxDC
)->SetFont(oldFont
);
485 // ---------------------------------------------------------------------------
487 // ---------------------------------------------------------------------------
489 void wxDC::ComputeScaleAndOrigin()
491 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
492 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
494 // FIXME_DFB: scaling affects pixel size of font, pens, brushes, which
495 // is not currently implemented here; probably makes sense to
496 // switch to Cairo instead of implementing everything for DFB
497 wxASSERT_MSG( m_scaleX
== 1.0 && m_scaleY
== 1.0,
498 _T("scaling is not implemented in wxDFB") );
501 void wxDC::SetMapMode(int mode
)
503 #warning "move this to common code, it's shared by almost all ports!"
507 SetLogicalScale(twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
510 SetLogicalScale(pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
513 SetLogicalScale(m_mm_to_pix_x
, m_mm_to_pix_y
);
516 SetLogicalScale(m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0);
520 SetLogicalScale(1.0, 1.0);
523 m_mappingMode
= mode
;
526 void wxDC::SetUserScale(double x
, double y
)
528 #warning "move this to common code?"
529 // allow negative ? -> no
532 ComputeScaleAndOrigin();
535 void wxDC::SetLogicalScale(double x
, double y
)
537 #warning "move this to common code?"
541 ComputeScaleAndOrigin();
544 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
546 #warning "move this to common code?"
547 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
548 m_logicalOriginY
= y
* m_signY
;
549 ComputeScaleAndOrigin();
552 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
554 #warning "move this to common code?"
555 // only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there
558 ComputeScaleAndOrigin();
561 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
563 #warning "move this to common code?"
564 // only wxPostScripDC has m_signX = -1, we override SetAxisOrientation there
565 m_signX
= (xLeftRight
? 1 : -1);
566 m_signY
= (yBottomUp
? -1 : 1);
567 ComputeScaleAndOrigin();
570 // ---------------------------------------------------------------------------
571 // coordinates transformations
572 // ---------------------------------------------------------------------------
574 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
576 return ((wxDC
*)this)->XDEV2LOG(x
);
579 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
581 return ((wxDC
*)this)->YDEV2LOG(y
);
584 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
586 return ((wxDC
*)this)->XDEV2LOGREL(x
);
589 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
591 return ((wxDC
*)this)->YDEV2LOGREL(y
);
594 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
596 return ((wxDC
*)this)->XLOG2DEV(x
);
599 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
601 return ((wxDC
*)this)->YLOG2DEV(y
);
604 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
606 return ((wxDC
*)this)->XLOG2DEVREL(x
);
609 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
611 return ((wxDC
*)this)->YLOG2DEVREL(y
);
615 void wxDC::DoGetSize(int *w
, int *h
) const
617 wxCHECK_RET( Ok(), wxT("invalid dc") );
619 m_surface
->GetSize(w
, h
);
622 void wxDC::DoGetSizeMM(int *width
, int *height
) const
624 #warning "move this to common code?"
628 if ( width
) *width
= int(double(w
) / (m_userScaleX
*m_mm_to_pix_x
));
629 if ( height
) *height
= int(double(h
) / (m_userScaleY
*m_mm_to_pix_y
));
632 wxSize
wxDC::GetPPI() const
634 #warning "move this to common code?"
635 return wxSize(int(double(m_mm_to_pix_x
) * inches2mm
),
636 int(double(m_mm_to_pix_y
) * inches2mm
));
640 // ---------------------------------------------------------------------------
642 // ---------------------------------------------------------------------------
644 bool wxDC::DoBlit(wxCoord xdest
, wxCoord ydest
,
645 wxCoord width
, wxCoord height
,
646 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
647 int rop
, bool useMask
,
648 wxCoord xsrcMask
, wxCoord ysrcMask
)
653 wxCHECK_MSG( Ok(), false, wxT("invalid dc") );
654 wxCHECK_MSG( source
, false, wxT("invalid source dc") );
656 // transform the source DC coords to the device ones
657 xsrc
= source
->LogicalToDeviceX(xsrc
);
658 ysrc
= source
->LogicalToDeviceY(ysrc
);
660 /* FIXME_MGL: use the mask origin when drawing transparently */
661 if (xsrcMask
== -1 && ysrcMask
== -1)
663 xsrcMask
= xsrc
; ysrcMask
= ysrc
;
667 xsrcMask
= source
->LogicalToDeviceX(xsrcMask
);
668 ysrcMask
= source
->LogicalToDeviceY(ysrcMask
);
671 CalcBoundingBox(xdest
, ydest
);
672 CalcBoundingBox(xdest
+ width
, ydest
+ height
);
674 /* scale/translate size and position */
675 wxCoord xx
= XLOG2DEV(xdest
);
676 wxCoord yy
= YLOG2DEV(ydest
);
677 wxCoord ww
= XLOG2DEVREL(width
);
678 wxCoord hh
= YLOG2DEVREL(height
);
680 if ( source
->m_isMemDC
)
682 wxMemoryDC
*memDC
= (wxMemoryDC
*) source
;
683 DoDrawSubBitmap(memDC
->GetSelectedObject(), xsrc
, ysrc
, ww
, hh
,
684 xdest
, ydest
, rop
, useMask
);
688 m_MGLDC
->makeCurrent(); // will go away with MGL6.0
689 m_MGLDC
->bitBlt(*source
->GetMGLDC(),
690 xsrc
, ysrc
, xsrc
+ ww
, ysrc
+ hh
,
691 xx
, yy
, LogicalFunctionToMGLRop(rop
));
698 void wxDC::DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, bool useMask
)
700 wxCHECK_RET( Ok(), wxT("invalid dc") );
701 wxCHECK_RET( bmp
.Ok(), wxT("invalid bitmap") );
703 wxCoord w
= bmp
.GetWidth();
704 wxCoord h
= bmp
.GetHeight();
706 DoDrawSubBitmap(bmp
, 0, 0, w
, h
, x
, y
, m_logicalFunction
, useMask
);
709 void wxDC::DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
711 // VZ: egcs 1.0.3 refuses to compile this without cast, no idea why
712 DoDrawBitmap((const wxBitmap
&)icon
, x
, y
, true);
715 void wxDC::DoDrawSubBitmap(const wxBitmap
&bmp
,
716 wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
717 wxCoord destx
, wxCoord desty
, int rop
, bool useMask
)
720 wxCHECK_RET( Ok(), wxT("invalid dc") );
721 wxCHECK_RET( bmp
.Ok(), wxT("invalid bitmap") );
723 CalcBoundingBox(x
, y
);
724 CalcBoundingBox(x
+ w
, y
+ h
);
726 wxCoord dx
= XLOG2DEV(destx
);
727 wxCoord dy
= YLOG2DEV(desty
);
728 wxCoord dw
= XLOG2DEVREL(w
);
729 wxCoord dh
= YLOG2DEVREL(h
);
731 m_MGLDC
->makeCurrent(); // will go away with MGL6.0
733 bool useStretching
= ((w
!= dw
) || (h
!= dh
));
734 bool putSection
= (w
!= bmp
.GetWidth() || h
!= bmp
.GetHeight());
735 MGL_writeModeType mglRop
= (MGL_writeModeType
)LogicalFunctionToMGLRop(rop
);
737 if ( bmp
.GetDepth() == 1 )
739 // Mono bitmaps are handled in special way -- all 1s are drawn in
740 // foreground colours, all 0s in background colour.
742 ((wxBitmap
&)bmp
).SetMonoPalette(m_textForegroundColour
, m_textBackgroundColour
);
745 if ( useMask
&& bmp
.GetMask() )
747 // Since MGL does not support masks directly (in MGL, mask is handled
748 // in same way as in wxImage, i.e. there is one "key" color), we
749 // simulate masked bitblt in 6 steps (same as in MSW):
751 // 1. Create a temporary bitmap and copy the destination area into it.
752 // 2. Copy the source area into the temporary bitmap using the
753 // specified logical function.
754 // 3. Set the masked area in the temporary bitmap to BLACK by ANDing
755 // the mask bitmap with the temp bitmap with the foreground colour
756 // set to WHITE and the bg colour set to BLACK.
757 // 4. Set the unmasked area in the destination area to BLACK by
758 // ANDing the mask bitmap with the destination area with the
759 // foreground colour set to BLACK and the background colour set
761 // 5. OR the temporary bitmap with the destination area.
762 // 6. Delete the temporary bitmap.
764 // This sequence of operations ensures that the source's transparent
765 // area need not be black, and logical functions are supported.
767 wxBitmap
*mask
= bmp
.GetMask()->GetBitmap();
771 if ( GetDepth() <= 8 )
773 temp
= new MGLMemoryDC(dw
, dh
, GetDepth(), NULL
);
775 tempdc
.SetMGLDC(temp
, false);
776 tempdc
.SetPalette(m_palette
);
781 m_MGLDC
->getPixelFormat(pf
);
782 temp
= new MGLMemoryDC(dw
, dh
, GetDepth(), &pf
);
785 wxCHECK_RET( temp
->isValid(), wxT("cannot create temporary dc") );
787 temp
->bitBlt(*m_MGLDC
, dx
, dy
, dx
+ dw
, dy
+ dh
, 0, 0, MGL_REPLACE_MODE
);
789 DoBitBlt(bmp
, temp
, x
, y
, w
, h
, 0, 0, dw
, dh
, mglRop
,
790 useStretching
, putSection
);
792 mask
->SetMonoPalette(wxColour(0,0,0), wxColour(255,255,255));
793 DoBitBlt(*mask
, temp
, x
, y
, w
, h
, 0, 0, dw
, dh
, MGL_R2_MASKSRC
,
794 useStretching
, putSection
);
795 DoBitBlt(*mask
, m_MGLDC
, x
, y
, w
, h
, dx
, dy
, dw
, dh
, MGL_R2_MASKNOTSRC
,
796 useStretching
, putSection
);
798 m_MGLDC
->bitBlt(*temp
, 0, 0, dw
, dh
, dx
, dy
, MGL_OR_MODE
);
805 DoBitBlt(bmp
, m_MGLDC
, x
, y
, w
, h
, dx
, dy
, dw
, dh
, mglRop
,
806 useStretching
, putSection
);