X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2bda0e173844e8e0f8acf4e8ad8b5c26e5c6fe5d..da938cfd99020f38e9936aaae185214586d0fbca:/src/msw/dc.cpp?ds=sidebyside diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 9a63615fea..365714b327 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -108,6 +108,8 @@ wxDC::wxDC(void) m_logicalScaleY = 1.0; m_userScaleX = 1.0; m_userScaleY = 1.0; + m_signX = 1; + m_signY = 1; m_systemScaleX = 1.0; m_systemScaleY = 1.0; m_mappingMode = MM_TEXT; @@ -410,12 +412,6 @@ bool wxDC::GetPixel(long x, long y, wxColour *col) const // returns TRUE for pixels in the color of the current pen // and FALSE for all other pixels colors // if col is non-NULL return the color of the pixel -/* - int xx1 = (int)x; - int yy1 = (int)y; - if (m_canvas) - m_canvas->CalcScrolledPosition((int)x, (int)y, &xx1, &yy1); -*/ // get the color of the pixel COLORREF pixelcolor = ::GetPixel((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y)); @@ -445,21 +441,6 @@ void wxDC::CrossHair(long x, long y) long y1 = y-2000; long x2 = x+2000; long y2 = y+2000; -/* - long xx1 = x1 ; - long yy1 = y1 ; - long xx2 = x2 ; - long yy2 = y2 ; - long xx = x ; - long yy = y ; - - if (m_canvas) - { - m_canvas->CalcScrolledPosition(x1, y1, &xx1, &yy1); - m_canvas->CalcScrolledPosition(x2, y2, &xx2, &yy2); - m_canvas->CalcScrolledPosition(x, y, &xx, &yy); - } -*/ BeginDrawing(); @@ -480,17 +461,6 @@ void wxDC::DrawLine(long x1, long y1, long x2, long y2) // BUGBUG - is this necessary? YES YES YES YEs Yes yes ye.... if (m_pen.Ok() && m_autoSetting) SetPen(m_pen); -/* - int xx1 = (int)x1; - int yy1 = (int)y1; - int xx2 = (int)x2; - int yy2 = (int)y2; - if (m_canvas) - { - m_canvas->CalcScrolledPosition((int)x1, (int)y1, &xx1, &yy1); - m_canvas->CalcScrolledPosition((int)x2, (int)y2, &xx2, &yy2); - } -*/ BeginDrawing(); @@ -510,15 +480,6 @@ void wxDC::DrawLine(long x1, long y1, long x2, long y2) void wxDC::DrawArc(long x1,long y1,long x2,long y2,double xc,double yc) { -/* - int xx1 = (int)x1; - int yy1 = (int)y1; - int xx2 = (int)x2; - int yy2 = (int)y2; - int xxc = (int)xc ; - int yyc = (int)yc; -*/ - double dx = xc-x1 ; double dy = yc-y1 ; double radius = (double)sqrt(dx*dx+dy*dy) ;; @@ -532,15 +493,6 @@ void wxDC::DrawArc(long x1,long y1,long x2,long y2,double xc,double yc) if (m_pen.Ok() && m_autoSetting) SetPen(m_pen) ; -/* - if (m_canvas) - { - m_canvas->CalcScrolledPosition((int)x1, (int)y1, &xx1, &yy1); - m_canvas->CalcScrolledPosition((int)x2, (int)y2, &xx2, &yy2); - m_canvas->CalcScrolledPosition((int)xc, (int)yc, &xxc, &yyc); - } -*/ - BeginDrawing(); long xx1 = XLOG2DEV(x1) ; @@ -574,24 +526,12 @@ void wxDC::DrawArc(long x1,long y1,long x2,long y2,double xc,double yc) CalcBoundingBox((xc+radius), (yc+radius)); } -void wxDC::DrawEllipticArc(long WXUNUSED(x),long WXUNUSED(y),long WXUNUSED(w),long WXUNUSED(h),double WXUNUSED(sa),double WXUNUSED(ea)) -{ - // Not implemented -} - void wxDC::DrawPoint(long x, long y) { // BUGBUG - is this necessary? if (m_pen.Ok() && m_autoSetting) SetPen(m_pen) ; -/* - int xx1 = (int)x; - int yy1 = (int)y; - if (m_canvas) - m_canvas->CalcScrolledPosition((int)x, (int)y, &xx1, &yy1); -*/ - BeginDrawing(); COLORREF color = 0x00ffffff; @@ -601,12 +541,6 @@ void wxDC::DrawPoint(long x, long y) color = m_pen.GetColour().GetPixel() ; } -/* - color = RGB(m_pen->GetColour().Red(), - m_pen->GetColour().Green(), - m_pen->GetColour().Blue()); -*/ - SetPixel((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y), color); EndDrawing(); @@ -619,15 +553,6 @@ void wxDC::DrawPolygon(int n, wxPoint points[], long xoffset, long yoffset,int f // BUGBUG - is this necessary? if (m_pen.Ok() && m_autoSetting) SetPen(m_pen) ; -/* - int xoffset1 = 0; - int yoffset1 = 0; - - if (m_canvas) - m_canvas->CalcScrolledPosition(0, 0, &xoffset1, &yoffset1); - - xoffset1 += (int)xoffset; yoffset1 += (int)yoffset; -*/ BeginDrawing(); @@ -635,10 +560,10 @@ void wxDC::DrawPolygon(int n, wxPoint points[], long xoffset, long yoffset,int f int i; for (i = 0; i < n; i++) { - cpoints[i].x = (int)(XLOG2DEV(points[i].x)); - cpoints[i].y = (int)(YLOG2DEV(points[i].y)); + cpoints[i].x = (int)(XLOG2DEV(points[i].x + xoffset)); + cpoints[i].y = (int)(YLOG2DEV(points[i].y + yoffset)); - CalcBoundingBox(points[i].x, points[i].y); + CalcBoundingBox(points[i].x + xoffset, points[i].y + yoffset); } int prev = SetPolyFillMode((HDC) m_hDC,fillStyle==wxODDEVEN_RULE?ALTERNATE:WINDING) ; @@ -656,27 +581,16 @@ void wxDC::DrawLines(int n, wxPoint points[], long xoffset, long yoffset) if (m_pen.Ok() && m_autoSetting) SetPen(m_pen) ; -/* - int xoffset1 = 0; - int yoffset1 = 0; - - if (m_canvas) - { - m_canvas->CalcScrolledPosition(0, 0, &xoffset1, &yoffset1); - } - xoffset1 += (int)xoffset; yoffset1 += (int)yoffset; -*/ - BeginDrawing(); POINT *cpoints = new POINT[n]; int i; for (i = 0; i < n; i++) { - cpoints[i].x = (int)(XLOG2DEV(points[i].x)); - cpoints[i].y = (int)(YLOG2DEV(points[i].y)); + cpoints[i].x = (int)(XLOG2DEV(points[i].x + xoffset)); + cpoints[i].y = (int)(YLOG2DEV(points[i].y + yoffset)); - CalcBoundingBox(points[i].x, points[i].y); + CalcBoundingBox(points[i].x + xoffset, points[i].y + yoffset); } (void)Polyline((HDC) m_hDC, cpoints, n); @@ -692,18 +606,6 @@ void wxDC::DrawRectangle(long x, long y, long width, long height) if (m_pen.Ok() && m_autoSetting) SetPen(m_pen) ; -/* - int x1 = (int)x; - int y1 = (int)y; - int x2 = (int)(x+width); - int y2 = (int)(y+height); - - if (m_canvas) - { - m_canvas->CalcScrolledPosition((int)x, (int)y, &x1, &y1); - m_canvas->CalcScrolledPosition((int)(x+width), (int)(y+height), &x2, &y2); - } -*/ long x2 = x + width; long y2 = y + height; @@ -769,17 +671,6 @@ void wxDC::DrawRoundedRectangle(long x, long y, long width, long height, double radius = (- radius * smallest); } -/* - int x1 = (int)x; - int y1 = (int)y; - - if (m_canvas) - { - m_canvas->CalcScrolledPosition((int)x, (int)y, &x1, &y1); - m_canvas->CalcScrolledPosition((int)(x+width), (int)(y+height), &x2, &y2); - } -*/ - long x2 = (x+width); long y2 = (y+height); @@ -800,17 +691,6 @@ void wxDC::DrawEllipse(long x, long y, long width, long height) if (m_pen.Ok() && m_autoSetting) SetPen(m_pen) ; -/* - int x1 = (int)x; - int y1 = (int)y; - - if (m_canvas) - { - m_canvas->CalcScrolledPosition((int)x, (int)y, &x1, &y1); - m_canvas->CalcScrolledPosition((int)(x+width), (int)(y+height), &x2, &y2); - } -*/ - long x2 = (x+width); long y2 = (y+height); @@ -824,16 +704,53 @@ void wxDC::DrawEllipse(long x, long y, long width, long height) CalcBoundingBox(x2, y2); } -void wxDC::DrawIcon(const wxIcon& icon, long x, long y) +// Chris Breeze 20/5/98: first implementation of DrawEllipticArc on Windows +void wxDC::DrawEllipticArc(long x,long y,long w,long h,double sa,double ea) { -/* - int x1 = (int)x; - int y1 = (int)y; +// BUGBUG - is this necessary? + if (m_pen.Ok() && m_autoSetting) + SetPen(m_pen) ; - if (m_canvas) - m_canvas->CalcScrolledPosition(int)x, (int)y, &x1, &y1); -*/ + long x2 = (x+w); + long y2 = (y+h); + + BeginDrawing(); + + const double deg2rad = 3.14159265359 / 180.0; + int rx1 = XLOG2DEV(x+w/2); + int ry1 = YLOG2DEV(y+h/2); + int rx2 = rx1; + int ry2 = ry1; + rx1 += (int)(100.0 * abs(w) * cos(sa * deg2rad)); + ry1 -= (int)(100.0 * abs(h) * m_signY * sin(sa * deg2rad)); + rx2 += (int)(100.0 * abs(w) * cos(ea * deg2rad)); + ry2 -= (int)(100.0 * abs(h) * m_signY * sin(ea * deg2rad)); + + // draw pie with NULL_PEN first and then outline otherwise a line is + // drawn from the start and end points to the centre + HPEN orig_pen = ::SelectObject((HDC) m_hDC, ::GetStockObject(NULL_PEN)); + if (m_signY > 0) + { + (void)Pie((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2)+1, YLOG2DEV(y2)+1, + rx1, ry1, rx2, ry2); + } + else + { + (void)Pie((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y)-1, XLOG2DEV(x2)+1, YLOG2DEV(y2), + rx1, ry1-1, rx2, ry2-1); + } + ::SelectObject((HDC) m_hDC, orig_pen); + (void)Arc((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2), YLOG2DEV(y2), + rx1, ry1, rx2, ry2); + + EndDrawing(); + + CalcBoundingBox(x, y); + CalcBoundingBox(x2, y2); +} +void wxDC::DrawIcon(const wxIcon& icon, long x, long y) +{ BeginDrawing(); ::DrawIcon((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y), (HICON) icon.GetHICON()); @@ -937,14 +854,6 @@ void wxDC::SetBrush(const wxBrush& brush) void wxDC::DrawText(const wxString& text, long x, long y, bool use16bit) { -/* - int xx1 = (int)x; - int yy1 = (int)y; - - if (m_canvas) - m_canvas->CalcScrolledPosition((int)x, (int)y, &xx1, &yy1); -*/ - BeginDrawing(); if (m_font.Ok() && m_font.GetResourceHandle()) @@ -1260,6 +1169,14 @@ void wxDC::SetUserScale(double x, double y) SetMapMode(m_mappingMode); } +void wxDC::SetAxisOrientation(bool xLeftRight, bool yBottomUp) +{ + m_signX = xLeftRight ? 1 : -1; + m_signY = yBottomUp ? -1 : 1; + + SetMapMode(m_mappingMode); +} + void wxDC::SetSystemScale(double x, double y) { m_systemScaleX = x; @@ -1294,42 +1211,42 @@ void wxDC::SetDeviceOrigin(long x, long y) long wxDC::DeviceToLogicalX(long x) const { - return (long) (((x) - m_deviceOriginX)/(m_logicalScaleX*m_userScaleX*m_systemScaleX) - m_logicalOriginX) ; + return (long) (((x) - m_deviceOriginX)/(m_logicalScaleX*m_userScaleX*m_signX*m_systemScaleX) - m_logicalOriginX) ; } long wxDC::DeviceToLogicalXRel(long x) const { - return (long) ((x)/(m_logicalScaleX*m_userScaleX*m_systemScaleX)) ; + return (long) ((x)/(m_logicalScaleX*m_userScaleX*m_signX*m_systemScaleX)) ; } long wxDC::DeviceToLogicalY(long y) const { - return (long) (((y) - m_deviceOriginY)/(m_logicalScaleY*m_userScaleY*m_systemScaleY) - m_logicalOriginY) ; + return (long) (((y) - m_deviceOriginY)/(m_logicalScaleY*m_userScaleY*m_signY*m_systemScaleY) - m_logicalOriginY) ; } long wxDC::DeviceToLogicalYRel(long y) const { - return (long) ((y)/(m_logicalScaleY*m_userScaleY*m_systemScaleY)) ; + return (long) ((y)/(m_logicalScaleY*m_userScaleY*m_signY*m_systemScaleY)) ; } long wxDC::LogicalToDeviceX(long x) const { - return (long) (floor((x) - m_logicalOriginX)*m_logicalScaleX*m_userScaleX*m_systemScaleX + m_deviceOriginX) ; + return (long) (floor((x) - m_logicalOriginX)*m_logicalScaleX*m_userScaleX*m_signX*m_systemScaleX + m_deviceOriginX) ; } long wxDC::LogicalToDeviceXRel(long x) const { - return (long) (floor(x)*m_logicalScaleX*m_userScaleX*m_systemScaleX) ; + return (long) (floor(x)*m_logicalScaleX*m_userScaleX*m_signX*m_systemScaleX) ; } long wxDC::LogicalToDeviceY(long y) const { - return (long) (floor((y) - m_logicalOriginY)*m_logicalScaleY*m_userScaleY*m_systemScaleY + m_deviceOriginY); + return (long) (floor((y) - m_logicalOriginY)*m_logicalScaleY*m_userScaleY*m_signY*m_systemScaleY + m_deviceOriginY); } long wxDC::LogicalToDeviceYRel(long y) const { - return (long) (floor(y)*m_logicalScaleY*m_userScaleY*m_systemScaleY) ; + return (long) (floor(y)*m_logicalScaleY*m_userScaleY*m_signY*m_systemScaleY) ; } // This group of functions may not do any conversion @@ -1395,6 +1312,19 @@ bool wxDC::Blit(long xdest, long ydest, long width, long height, long xsrc1 = xsrc; long ysrc1 = ysrc; + // Chris Breeze 18/5/98: use text foreground/background colours + // when blitting from 1-bit bitmaps + COLORREF old_textground = ::GetTextColor((HDC)m_hDC); + COLORREF old_background = ::GetBkColor((HDC)m_hDC); + if (m_textForegroundColour.Ok()) + { + ::SetTextColor((HDC) m_hDC, m_textForegroundColour.GetPixel() ) ; + } + if (m_textBackgroundColour.Ok()) + { + ::SetBkColor((HDC) m_hDC, m_textBackgroundColour.GetPixel() ) ; + } + DWORD dwRop = rop == wxCOPY ? SRCCOPY : rop == wxCLEAR ? WHITENESS : rop == wxSET ? BLACKNESS : @@ -1483,6 +1413,8 @@ bool wxDC::Blit(long xdest, long ydest, long width, long height, success = (BitBlt((HDC) m_hDC, xdest1, ydest1, (int)width, (int)height, (HDC) source->m_hDC, xsrc1, ysrc1, dwRop) != 0); } + ::SetTextColor((HDC)m_hDC, old_textground); + ::SetBkColor((HDC)m_hDC, old_background); source->EndDrawing(); EndDrawing(); @@ -1505,6 +1437,7 @@ void wxDC::GetSizeMM(long *width, long *height) const *height = h; } +/* #if USE_SPLINES # if USE_XFIG_SPLINE_CODE # include "../common/xfspline.inc" @@ -1512,6 +1445,11 @@ void wxDC::GetSizeMM(long *width, long *height) const # include "../common/wxspline.inc" # endif #endif // USE_SPLINES +*/ + +#if USE_SPLINES +#include "xfspline.inc" +#endif // USE_SPLINES void wxDC::DrawPolygon(wxList *list, long xoffset, long yoffset,int fillStyle) {