]>
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());
155 wxSize
size(GetSize());
156 CalcBoundingBox(XDEV2LOG(0), YDEV2LOG(0));
157 CalcBoundingBox(XDEV2LOG(size
.x
), YDEV2LOG(size
.y
));
160 extern bool wxDoFloodFill(wxDC
*dc
, wxCoord x
, wxCoord y
,
161 const wxColour
& col
, int style
);
163 bool wxDC::DoFloodFill(wxCoord x
, wxCoord y
,
164 const wxColour
& col
, int style
)
166 return wxDoFloodFill(this, x
, y
, col
, style
);
169 bool wxDC::DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
171 wxCHECK_MSG( col
, false, _T("NULL colour parameter in wxDC::GetPixel"));
173 wxFAIL_MSG( _T("GetPixel not implemented") );
177 void wxDC::DoCrossHair(wxCoord x
, wxCoord y
)
179 wxCHECK_RET( Ok(), wxT("invalid dc") );
181 wxFAIL_MSG( _T("CrossHair not implemented") );
184 void wxDC::DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
186 wxCHECK_RET( Ok(), wxT("invalid dc") );
188 if ( m_pen
.GetStyle() == wxTRANSPARENT
)
191 m_surface
->DrawLine(XLOG2DEV(x1
), YLOG2DEV(y1
),
192 XLOG2DEV(x2
), YLOG2DEV(y2
));
194 CalcBoundingBox(x1
, y1
);
195 CalcBoundingBox(x2
, y2
);
198 // Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1)
199 // and ending at (x2, y2)
200 void wxDC::DoDrawArc(wxCoord x1
, wxCoord y1
,
201 wxCoord x2
, wxCoord y2
,
202 wxCoord xc
, wxCoord yc
)
204 wxCHECK_RET( Ok(), wxT("invalid dc") );
206 wxFAIL_MSG( _T("DrawArc not implemented") );
209 void wxDC::DoDrawPoint(wxCoord x
, wxCoord y
)
211 wxCHECK_RET( Ok(), wxT("invalid dc") );
213 // NB: DirectFB API doesn't provide a function for drawing points, so
214 // implement it as 1px long line. This is inefficient, but then, so is
215 // using DrawPoint() for drawing more than a few points.
216 DoDrawLine(x
, y
, x
, y
);
218 // FIXME_DFB: implement special cases for common formats (RGB24,RGBA/RGB32)
221 void wxDC::DoDrawPolygon(int n
, wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
,int WXUNUSED(fillStyle
))
223 wxCHECK_RET( Ok(), wxT("invalid dc") );
225 wxFAIL_MSG( _T("DrawPolygon not implemented") );
228 void wxDC::DoDrawLines(int n
, wxPoint points
[], wxCoord xoffset
, wxCoord yoffset
)
230 wxCHECK_RET( Ok(), wxT("invalid dc") );
232 // TODO: impl. using DirectDB's DrawLines
233 wxFAIL_MSG( _T("DrawLines not implemented") );
236 void wxDC::DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
238 wxCHECK_RET( Ok(), wxT("invalid dc") );
240 wxCoord xx
= XLOG2DEV(x
);
241 wxCoord yy
= YLOG2DEV(y
);
242 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
243 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
245 if ( ww
== 0 || hh
== 0 ) return;
258 if ( m_brush
.GetStyle() != wxTRANSPARENT
)
260 SelectColour(m_brush
.GetColour());
261 m_surface
->FillRectangle(xx
, yy
, ww
, hh
);
262 // restore pen's colour
263 SelectColour(m_pen
.GetColour());
266 if ( m_pen
.GetStyle() != wxTRANSPARENT
)
268 m_surface
->DrawRectangle(xx
, yy
, ww
, hh
);
271 CalcBoundingBox(x
, y
);
272 CalcBoundingBox(x
+ width
, y
+ height
);
275 void wxDC::DoDrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double radius
)
277 wxCHECK_RET( Ok(), wxT("invalid dc") );
279 wxFAIL_MSG( _T("DrawRoundedRectangle not implemented") );
282 void wxDC::DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
284 wxCHECK_RET( Ok(), wxT("invalid dc") );
286 wxFAIL_MSG( _T("DrawElipse not implemented") );
289 void wxDC::DoDrawEllipticArc(wxCoord x
,wxCoord y
,wxCoord w
,wxCoord h
,double sa
,double ea
)
291 wxCHECK_RET( Ok(), wxT("invalid dc") );
293 wxFAIL_MSG( _T("DrawElipticArc not implemented") );
296 void wxDC::DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
298 wxCHECK_RET( Ok(), wxT("invalid dc") );
300 wxCoord xx
= XLOG2DEV(x
);
301 wxCoord yy
= YLOG2DEV(y
);
303 // update the bounding box
305 CalcBoundingBox(x
, y
);
306 GetTextExtent(text
, &w
, &h
);
307 CalcBoundingBox(x
+ w
, y
+ h
);
309 // if background mode is solid, DrawText must paint text's background:
310 if ( m_backgroundMode
== wxSOLID
)
312 wxCHECK_RET( m_backgroundBrush
.Ok(), wxT("invalid background brush") );
314 SelectColour(m_backgroundBrush
.GetColour());
315 m_surface
->FillRectangle(xx
, yy
, XLOG2DEVREL(w
), YLOG2DEVREL(h
));
316 // restore pen's colour
317 SelectColour(m_pen
.GetColour());
320 // finally draw the text itself:
321 m_surface
->DrawString(wxSTR_TO_DFB(text
), -1, xx
, yy
, DSTF_LEFT
| DSTF_TOP
);
324 void wxDC::DoDrawRotatedText(const wxString
& text
,
325 wxCoord x
, wxCoord y
,
328 wxCHECK_RET( Ok(), wxT("invalid dc") );
330 wxFAIL_MSG( _T("DrawRotatedText not implemented") );
333 // ---------------------------------------------------------------------------
335 // ---------------------------------------------------------------------------
337 void wxDC::SetPen(const wxPen
& pen
)
339 m_pen
= pen
.Ok() ? pen
: DEFAULT_PEN
;
341 SelectColour(m_pen
.GetColour());
344 void wxDC::SetBrush(const wxBrush
& brush
)
346 m_brush
= brush
.Ok() ? brush
: DEFAULT_BRUSH
;
349 void wxDC::SelectColour(const wxColour
& clr
)
351 m_surface
->SetColor(clr
.Red(), clr
.Green(), clr
.Blue(), clr
.Alpha());
352 #warning "use SetColorIndex?"
356 void wxDC::SetPalette(const wxPalette
& WXUNUSED(palette
))
358 wxCHECK_RET( Ok(), wxT("invalid dc") );
360 wxFAIL_MSG( _T("SetPalette not implemented") );
362 #endif // wxUSE_PALETTE
364 void wxDC::SetFont(const wxFont
& font
)
366 wxCHECK_RET( Ok(), wxT("invalid dc") );
368 wxFont
f(font
.Ok() ? font
: DEFAULT_FONT
);
370 if ( !m_surface
->SetFont(f
.GetDirectFBFont()) )
376 void wxDC::SetBackground(const wxBrush
& brush
)
378 wxCHECK_RET( Ok(), wxT("invalid dc") );
380 if (!brush
.Ok()) return;
382 m_backgroundBrush
= brush
;
385 void wxDC::SetBackgroundMode(int mode
)
387 m_backgroundMode
= mode
;
390 void wxDC::SetLogicalFunction(int function
)
392 wxCHECK_RET( Ok(), wxT("invalid dc") );
394 wxFAIL_MSG( _T("SetLogicalFunction not implemented") );
396 m_logicalFunction
= function
;
399 bool wxDC::StartDoc(const wxString
& WXUNUSED(message
))
401 // We might be previewing, so return true to let it continue.
409 void wxDC::StartPage()
417 // ---------------------------------------------------------------------------
419 // ---------------------------------------------------------------------------
421 wxCoord
wxDC::GetCharHeight() const
423 wxCHECK_MSG( Ok(), -1, wxT("invalid dc") );
424 wxCHECK_MSG( m_font
.Ok(), -1, wxT("no font selected") );
427 m_font
.GetDirectFBFont()->GetHeight(&h
);
428 return YDEV2LOGREL(h
);
431 wxCoord
wxDC::GetCharWidth() const
433 wxCHECK_MSG( Ok(), -1, wxT("invalid dc") );
434 wxCHECK_MSG( m_font
.Ok(), -1, wxT("no font selected") );
437 m_font
.GetDirectFBFont()->GetStringWidth("H", 1, &w
);
438 // VS: YDEV is corrent, it should *not* be XDEV, because font's are only
439 // scaled according to m_scaleY
440 return YDEV2LOGREL(w
);
443 void wxDC::DoGetTextExtent(const wxString
& string
, wxCoord
*x
, wxCoord
*y
,
444 wxCoord
*descent
, wxCoord
*externalLeading
,
445 wxFont
*theFont
) const
447 wxCHECK_RET( Ok(), wxT("invalid dc") );
448 wxCHECK_RET( m_font
.Ok(), wxT("no font selected") );
449 wxCHECK_RET( !theFont
|| theFont
->Ok(), wxT("invalid font") );
452 if ( theFont
!= NULL
)
455 wxConstCast(this, wxDC
)->SetFont(*theFont
);
458 wxCoord xx
= 0, yy
= 0;
460 wxIDirectFBFontPtr f
= m_font
.GetDirectFBFont();
462 if ( f
->GetStringExtents(wxSTR_TO_DFB(string
), -1, &rect
, NULL
) )
464 // VS: YDEV is corrent, it should *not* be XDEV, because font's are
465 // only scaled according to m_scaleY
466 xx
= YDEV2LOGREL(rect
.w
);
467 yy
= YDEV2LOGREL(rect
.h
);
472 if ( f
->GetDescender(&d
) )
473 *descent
= YDEV2LOGREL(-d
);
481 if ( externalLeading
) *externalLeading
= 0;
483 if ( theFont
!= NULL
)
484 wxConstCast(this, wxDC
)->SetFont(oldFont
);
489 // ---------------------------------------------------------------------------
491 // ---------------------------------------------------------------------------
493 void wxDC::ComputeScaleAndOrigin()
495 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
496 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
498 // FIXME_DFB: scaling affects pixel size of font, pens, brushes, which
499 // is not currently implemented here; probably makes sense to
500 // switch to Cairo instead of implementing everything for DFB
501 wxASSERT_MSG( m_scaleX
== 1.0 && m_scaleY
== 1.0,
502 _T("scaling is not implemented in wxDFB") );
505 void wxDC::SetMapMode(int mode
)
507 #warning "move this to common code, it's shared by almost all ports!"
511 SetLogicalScale(twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
514 SetLogicalScale(pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
517 SetLogicalScale(m_mm_to_pix_x
, m_mm_to_pix_y
);
520 SetLogicalScale(m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0);
524 SetLogicalScale(1.0, 1.0);
527 m_mappingMode
= mode
;
530 void wxDC::SetUserScale(double x
, double y
)
532 #warning "move this to common code?"
533 // allow negative ? -> no
536 ComputeScaleAndOrigin();
539 void wxDC::SetLogicalScale(double x
, double y
)
541 #warning "move this to common code?"
545 ComputeScaleAndOrigin();
548 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
550 #warning "move this to common code?"
551 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
552 m_logicalOriginY
= y
* m_signY
;
553 ComputeScaleAndOrigin();
556 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
558 #warning "move this to common code?"
559 // only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there
562 ComputeScaleAndOrigin();
565 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
567 #warning "move this to common code?"
568 // only wxPostScripDC has m_signX = -1, we override SetAxisOrientation there
569 m_signX
= (xLeftRight
? 1 : -1);
570 m_signY
= (yBottomUp
? -1 : 1);
571 ComputeScaleAndOrigin();
574 // ---------------------------------------------------------------------------
575 // coordinates transformations
576 // ---------------------------------------------------------------------------
578 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
580 return ((wxDC
*)this)->XDEV2LOG(x
);
583 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
585 return ((wxDC
*)this)->YDEV2LOG(y
);
588 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
590 return ((wxDC
*)this)->XDEV2LOGREL(x
);
593 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
595 return ((wxDC
*)this)->YDEV2LOGREL(y
);
598 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
600 return ((wxDC
*)this)->XLOG2DEV(x
);
603 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
605 return ((wxDC
*)this)->YLOG2DEV(y
);
608 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
610 return ((wxDC
*)this)->XLOG2DEVREL(x
);
613 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
615 return ((wxDC
*)this)->YLOG2DEVREL(y
);
619 void wxDC::DoGetSize(int *w
, int *h
) const
621 wxCHECK_RET( Ok(), wxT("invalid dc") );
623 m_surface
->GetSize(w
, h
);
626 void wxDC::DoGetSizeMM(int *width
, int *height
) const
628 #warning "move this to common code?"
632 if ( width
) *width
= int(double(w
) / (m_userScaleX
*m_mm_to_pix_x
));
633 if ( height
) *height
= int(double(h
) / (m_userScaleY
*m_mm_to_pix_y
));
636 wxSize
wxDC::GetPPI() const
638 #warning "move this to common code?"
639 return wxSize(int(double(m_mm_to_pix_x
) * inches2mm
),
640 int(double(m_mm_to_pix_y
) * inches2mm
));
644 // ---------------------------------------------------------------------------
646 // ---------------------------------------------------------------------------
648 bool wxDC::DoBlit(wxCoord xdest
, wxCoord ydest
,
649 wxCoord width
, wxCoord height
,
650 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
651 int rop
, bool useMask
,
652 wxCoord xsrcMask
, wxCoord ysrcMask
)
657 wxCHECK_MSG( Ok(), false, wxT("invalid dc") );
658 wxCHECK_MSG( source
, false, wxT("invalid source dc") );
660 // transform the source DC coords to the device ones
661 xsrc
= source
->LogicalToDeviceX(xsrc
);
662 ysrc
= source
->LogicalToDeviceY(ysrc
);
664 /* FIXME_MGL: use the mask origin when drawing transparently */
665 if (xsrcMask
== -1 && ysrcMask
== -1)
667 xsrcMask
= xsrc
; ysrcMask
= ysrc
;
671 xsrcMask
= source
->LogicalToDeviceX(xsrcMask
);
672 ysrcMask
= source
->LogicalToDeviceY(ysrcMask
);
675 CalcBoundingBox(xdest
, ydest
);
676 CalcBoundingBox(xdest
+ width
, ydest
+ height
);
678 /* scale/translate size and position */
679 wxCoord xx
= XLOG2DEV(xdest
);
680 wxCoord yy
= YLOG2DEV(ydest
);
681 wxCoord ww
= XLOG2DEVREL(width
);
682 wxCoord hh
= YLOG2DEVREL(height
);
684 if ( source
->m_isMemDC
)
686 wxMemoryDC
*memDC
= (wxMemoryDC
*) source
;
687 DoDrawSubBitmap(memDC
->GetSelectedObject(), xsrc
, ysrc
, ww
, hh
,
688 xdest
, ydest
, rop
, useMask
);
692 m_MGLDC
->makeCurrent(); // will go away with MGL6.0
693 m_MGLDC
->bitBlt(*source
->GetMGLDC(),
694 xsrc
, ysrc
, xsrc
+ ww
, ysrc
+ hh
,
695 xx
, yy
, LogicalFunctionToMGLRop(rop
));
702 void wxDC::DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, bool useMask
)
704 wxCHECK_RET( Ok(), wxT("invalid dc") );
705 wxCHECK_RET( bmp
.Ok(), wxT("invalid bitmap") );
707 wxCoord w
= bmp
.GetWidth();
708 wxCoord h
= bmp
.GetHeight();
710 DoDrawSubBitmap(bmp
, 0, 0, w
, h
, x
, y
, m_logicalFunction
, useMask
);
713 void wxDC::DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
715 // VZ: egcs 1.0.3 refuses to compile this without cast, no idea why
716 DoDrawBitmap((const wxBitmap
&)icon
, x
, y
, true);
719 void wxDC::DoDrawSubBitmap(const wxBitmap
&bmp
,
720 wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
721 wxCoord destx
, wxCoord desty
, int rop
, bool useMask
)
724 wxCHECK_RET( Ok(), wxT("invalid dc") );
725 wxCHECK_RET( bmp
.Ok(), wxT("invalid bitmap") );
727 CalcBoundingBox(x
, y
);
728 CalcBoundingBox(x
+ w
, y
+ h
);
730 wxCoord dx
= XLOG2DEV(destx
);
731 wxCoord dy
= YLOG2DEV(desty
);
732 wxCoord dw
= XLOG2DEVREL(w
);
733 wxCoord dh
= YLOG2DEVREL(h
);
735 m_MGLDC
->makeCurrent(); // will go away with MGL6.0
737 bool useStretching
= ((w
!= dw
) || (h
!= dh
));
738 bool putSection
= (w
!= bmp
.GetWidth() || h
!= bmp
.GetHeight());
739 MGL_writeModeType mglRop
= (MGL_writeModeType
)LogicalFunctionToMGLRop(rop
);
741 if ( bmp
.GetDepth() == 1 )
743 // Mono bitmaps are handled in special way -- all 1s are drawn in
744 // foreground colours, all 0s in background colour.
746 ((wxBitmap
&)bmp
).SetMonoPalette(m_textForegroundColour
, m_textBackgroundColour
);
749 if ( useMask
&& bmp
.GetMask() )
751 // Since MGL does not support masks directly (in MGL, mask is handled
752 // in same way as in wxImage, i.e. there is one "key" color), we
753 // simulate masked bitblt in 6 steps (same as in MSW):
755 // 1. Create a temporary bitmap and copy the destination area into it.
756 // 2. Copy the source area into the temporary bitmap using the
757 // specified logical function.
758 // 3. Set the masked area in the temporary bitmap to BLACK by ANDing
759 // the mask bitmap with the temp bitmap with the foreground colour
760 // set to WHITE and the bg colour set to BLACK.
761 // 4. Set the unmasked area in the destination area to BLACK by
762 // ANDing the mask bitmap with the destination area with the
763 // foreground colour set to BLACK and the background colour set
765 // 5. OR the temporary bitmap with the destination area.
766 // 6. Delete the temporary bitmap.
768 // This sequence of operations ensures that the source's transparent
769 // area need not be black, and logical functions are supported.
771 wxBitmap
*mask
= bmp
.GetMask()->GetBitmap();
775 if ( GetDepth() <= 8 )
777 temp
= new MGLMemoryDC(dw
, dh
, GetDepth(), NULL
);
779 tempdc
.SetMGLDC(temp
, false);
780 tempdc
.SetPalette(m_palette
);
785 m_MGLDC
->getPixelFormat(pf
);
786 temp
= new MGLMemoryDC(dw
, dh
, GetDepth(), &pf
);
789 wxCHECK_RET( temp
->isValid(), wxT("cannot create temporary dc") );
791 temp
->bitBlt(*m_MGLDC
, dx
, dy
, dx
+ dw
, dy
+ dh
, 0, 0, MGL_REPLACE_MODE
);
793 DoBitBlt(bmp
, temp
, x
, y
, w
, h
, 0, 0, dw
, dh
, mglRop
,
794 useStretching
, putSection
);
796 mask
->SetMonoPalette(wxColour(0,0,0), wxColour(255,255,255));
797 DoBitBlt(*mask
, temp
, x
, y
, w
, h
, 0, 0, dw
, dh
, MGL_R2_MASKSRC
,
798 useStretching
, putSection
);
799 DoBitBlt(*mask
, m_MGLDC
, x
, y
, w
, h
, dx
, dy
, dw
, dh
, MGL_R2_MASKNOTSRC
,
800 useStretching
, putSection
);
802 m_MGLDC
->bitBlt(*temp
, 0, 0, dw
, dh
, dx
, dy
, MGL_OR_MODE
);
809 DoBitBlt(bmp
, m_MGLDC
, x
, y
, w
, h
, dx
, dy
, dw
, dh
, mglRop
,
810 useStretching
, putSection
);