X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9effb77dbc83d7def19da6b61fe46f75b08420ef..a56a99abe859f37615251c865bc807bf13e8b180:/src/msw/dc.cpp?ds=sidebyside diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 5dbd1f291f..f99f3963bf 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -43,7 +43,7 @@ #include "wx/sysopt.h" #include "wx/dynlib.h" -#ifdef wxHAVE_RAW_BITMAP +#ifdef wxHAS_RAW_BITMAP #include "wx/rawbmp.h" #endif @@ -133,7 +133,7 @@ static bool AlphaBlt(HDC hdcDst, HDC hdcSrc, const wxBitmap& bmp); -#ifdef wxHAVE_RAW_BITMAP +#ifdef wxHAS_RAW_BITMAP // our (limited) AlphaBlend() replacement for Windows versions not providing it static void @@ -143,7 +143,7 @@ wxAlphaBlend(HDC hdcDst, int xDst, int yDst, int srcWidth, int srcHeight, const wxBitmap& bmpSrc); -#endif // wxHAVE_RAW_BITMAP +#endif // wxHAS_RAW_BITMAP // ---------------------------------------------------------------------------- // private classes @@ -399,6 +399,16 @@ wxBrushAttrsSetter::wxBrushAttrsSetter(wxMSWDCImpl& dc) } } +// ---------------------------------------------------------------------------- +// wxDC MSW-specific methods +// ---------------------------------------------------------------------------- + +WXHDC wxDC::GetHDC() const +{ + wxMSWDCImpl * const impl = wxDynamicCast(GetImpl(), wxMSWDCImpl); + return impl ? impl->GetHDC() : 0; +} + // --------------------------------------------------------------------------- // wxMSWDCImpl // --------------------------------------------------------------------------- @@ -525,7 +535,7 @@ wxMSWDCImpl::DoGetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) co wxDCImpl::DoGetClippingBox(x, y, w, h); } -// common part of DoSetClippingRegion() and DoSetClippingRegionAsRegion() +// common part of DoSetClippingRegion() and DoSetDeviceClippingRegion() void wxMSWDCImpl::SetClippingHrgn(WXHRGN hrgn) { wxCHECK_RET( hrgn, wxT("invalid clipping region") ); @@ -593,7 +603,7 @@ void wxMSWDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h } } -void wxMSWDCImpl::DoSetClippingRegionAsRegion(const wxRegion& region) +void wxMSWDCImpl::DoSetDeviceClippingRegion(const wxRegion& region) { SetClippingHrgn(region.GetHRGN()); } @@ -695,7 +705,7 @@ void wxMSWDCImpl::Clear() bool wxMSWDCImpl::DoFloodFill(wxCoord WXUNUSED_IN_WINCE(x), wxCoord WXUNUSED_IN_WINCE(y), const wxColour& WXUNUSED_IN_WINCE(col), - int WXUNUSED_IN_WINCE(style)) + wxFloodFillStyle WXUNUSED_IN_WINCE(style)) { #ifdef __WXWINCE__ return false; @@ -878,7 +888,7 @@ void wxMSWDCImpl::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, - int WXUNUSED_IN_WINCE(fillStyle)) + wxPolygonFillMode WXUNUSED_IN_WINCE(fillStyle)) { WXMICROWIN_CHECK_HDC @@ -927,7 +937,7 @@ wxMSWDCImpl::DoDrawPolyPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, - int fillStyle) + wxPolygonFillMode fillStyle) { #ifdef __WXWINCE__ wxDCImpl::DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); @@ -1074,22 +1084,23 @@ void wxMSWDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord hei wxBrushAttrsSetter cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling - wxCoord x2 = (x+width); - wxCoord y2 = (y+height); + // +1 below makes the ellipse more similar to other platforms. + // In particular, DoDrawEllipse(x,y,1,1) should draw one point. + wxCoord x2 = x + width + 1; + wxCoord y2 = y + height + 1; + + // Problem: Windows GDI Ellipse() with x2-x == y2-y == 3 and transparent + // pen doesn't draw anything. Should we provide a workaround? - (void)Ellipse(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2), YLOG2DEV(y2)); + ::Ellipse(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2), YLOG2DEV(y2)); CalcBoundingBox(x, y); CalcBoundingBox(x2, y2); } -#if wxUSE_SPLINES +#if wxUSE_SPLINES && !defined(__WXWINCE__) void wxMSWDCImpl::DoDrawSpline(const wxPointList *points) { -#ifdef __WXWINCE__ - // WinCE does not support ::PolyBezier so use generic version - wxDCImpl::DoDrawSpline(points); -#else // quadratic b-spline to cubic bezier spline conversion // // quadratic spline with control points P0,P1,P2 @@ -1178,9 +1189,8 @@ void wxMSWDCImpl::DoDrawSpline(const wxPointList *points) ::PolyBezier( GetHdc(), lppt, bezier_pos ); free(lppt); -#endif } -#endif +#endif // wxUSE_SPLINES // Chris Breeze 20/5/98: first implementation of DrawEllipticArc on Windows void wxMSWDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) @@ -1698,7 +1708,7 @@ void wxMSWDCImpl::SetBackgroundMode(int mode) // and m_backgroundMode is used there } -void wxMSWDCImpl::SetLogicalFunction(int function) +void wxMSWDCImpl::SetLogicalFunction(wxRasterOperationMode function) { WXMICROWIN_CHECK_HDC @@ -1712,7 +1722,7 @@ void wxMSWDCImpl::SetRop(WXHDC dc) if ( !dc || m_logicalFunction < 0 ) return; - int rop; + int rop wxDUMMY_INITIALIZE(0); switch (m_logicalFunction) { @@ -1732,10 +1742,6 @@ void wxMSWDCImpl::SetRop(WXHDC dc) case wxNAND: rop = R2_NOTMASKPEN; break; case wxOR: rop = R2_MERGEPEN; break; case wxSET: rop = R2_WHITE; break; - - default: - wxFAIL_MSG( wxT("unsupported logical function") ); - return; } SetROP2(GetHdc(), rop); @@ -1926,7 +1932,7 @@ void wxMSWDCImpl::RealizeScaleAndOrigin() #endif } -void wxMSWDCImpl::SetMapMode(int mode) +void wxMSWDCImpl::SetMapMode(wxMappingMode mode) { WXMICROWIN_CHECK_HDC @@ -2022,9 +2028,15 @@ void wxMSWDCImpl::SetLogicalOrigin(wxCoord x, wxCoord y) wxDCImpl::SetLogicalOrigin( x, y ); -#ifndef __WXWINCE__ - ::SetWindowOrgEx(GetHdc(), (int)m_logicalOriginX, (int)m_logicalOriginY, NULL); -#endif + RealizeScaleAndOrigin(); +} + +// For use by wxWidgets only, unless custom units are required. +void wxMSWDCImpl::SetLogicalScale(double x, double y) +{ + WXMICROWIN_CHECK_HDC + + wxDCImpl::SetLogicalScale(x,y); } void wxMSWDCImpl::SetDeviceOrigin(wxCoord x, wxCoord y) @@ -2047,7 +2059,7 @@ bool wxMSWDCImpl::DoBlit(wxCoord dstX, wxCoord dstY, wxCoord dstWidth, wxCoord dstHeight, wxDC *source, wxCoord srcX, wxCoord srcY, - int rop, bool useMask, + wxRasterOperationMode rop, bool useMask, wxCoord srcMaskX, wxCoord srcMaskY) { return DoStretchBlit(dstX, dstY, dstWidth, dstHeight, source, srcX, srcY, dstWidth, dstHeight, rop, useMask, srcMaskX, srcMaskY); @@ -2058,7 +2070,7 @@ bool wxMSWDCImpl::DoStretchBlit(wxCoord xdest, wxCoord ydest, wxDC *source, wxCoord xsrc, wxCoord ysrc, wxCoord srcWidth, wxCoord srcHeight, - int rop, bool useMask, + wxRasterOperationMode rop, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask) { wxCHECK_MSG( source, false, _T("wxMSWDCImpl::Blit(): NULL wxDC pointer") ); @@ -2394,14 +2406,6 @@ wxSize wxMSWDCImpl::GetPPI() const return wxSize(x, y); } -// For use by wxWidgets only, unless custom units are required. -void wxMSWDCImpl::SetLogicalScale(double x, double y) -{ - WXMICROWIN_CHECK_HDC - - wxDCImpl::SetLogicalScale(x,y); -} - // ---------------------------------------------------------------------------- // DC caching // ---------------------------------------------------------------------------- @@ -2586,21 +2590,21 @@ static bool AlphaBlt(HDC hdcDst, // AlphaBlend() unavailable of failed: use our own (probably much slower) // implementation -#ifdef wxHAVE_RAW_BITMAP +#ifdef wxHAS_RAW_BITMAP wxAlphaBlend(hdcDst, x, y, dstWidth, dstHeight, srcX, srcY, srcWidth, srcHeight, bmp); return true; -#else // !wxHAVE_RAW_BITMAP +#else // !wxHAS_RAW_BITMAP // no wxAlphaBlend() neither, fall back to using simple BitBlt() (we lose // alpha but at least something will be shown like this) wxUnusedVar(bmp); return false; -#endif // wxHAVE_RAW_BITMAP +#endif // wxHAS_RAW_BITMAP/!wxHAS_RAW_BITMAP } // wxAlphaBlend: our fallback if ::AlphaBlend() is unavailable -#ifdef wxHAVE_RAW_BITMAP +#ifdef wxHAS_RAW_BITMAP static void wxAlphaBlend(HDC hdcDst, int xDst, int yDst, @@ -2662,7 +2666,7 @@ wxAlphaBlend(HDC hdcDst, int xDst, int yDst, } } -#endif // #ifdef wxHAVE_RAW_BITMAP +#endif // wxHAS_RAW_BITMAP void wxMSWDCImpl::DoGradientFillLinear (const wxRect& rect, const wxColour& initialColour,