home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 38.6 KB | 1,500 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWPriRas.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #if defined(FW_PROFILER_CALLS) && defined(__MWERKS__)
- #pragma profile on
- #endif
-
- #ifndef FWPRIRAS_H
- #include "FWPriRas.h"
- #endif
-
- #ifndef FWPICTUR_H
- #include "FWPictur.h"
- #endif
-
- #ifndef FWBITMAP_H
- #include "FWBitmap.h"
- #endif
-
- #ifndef FWTXTBUF_H
- #include "FWTxtBuf.h"
- #endif
-
- #ifndef FWGRUTIL_H
- #include "FWGrUtil.h"
- #endif
-
- #ifndef FWTXTSHP_H
- #include "FWTxtShp.h"
- #endif
-
- #ifndef FWTXTBOX_H
- #include "FWTxtBox.h"
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWREGION_H
- #include "FWRegion.h"
- #endif
-
- #ifndef FWPOLY_H
- #include "FWPoly.h"
- #endif
-
- #ifndef FWICON_H
- #include "FWIcon.h"
- #endif
-
- #ifndef FWGDEV_H
- #include "FWGDev.h"
- #endif
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWMDASH_H
- #include "FWMDash.h"
- #endif
-
- #ifndef FWMDASH_H
- #include "FWMDash.h"
- #endif
-
- #ifndef FWMEMMGR_H
- #include "FWMemMgr.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODShape_xh
- #include <Shape.xh>
- #endif
-
- // ----- Standard C Includes -----
-
- #include <math.h>
-
- // ----- Platform Includes -----
-
- #if defined(FW_BUILD_MAC) && !defined(__LOWMEM__)
- #include <LowMem.h>
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__ICONS__)
- #include <Icons.h>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #pragma segment FWGraphx_Rasterizer
-
- //========================================================================================
- // Local macros to make rasterizer code more staightforward
- //========================================================================================
-
- #ifdef FW_BUILD_WIN
-
- #define FW_CHECK_RASTERIZER \
- FW_ASSERT(&gc == FW_gLastGC);
-
- #endif
-
- #ifdef FW_BUILD_MAC
-
- #define FW_CHECK_RASTERIZER \
- FW_ASSERT(&gc == FW_gLastGC); \
- FW_ASSERT(gc.GetGraphicDevice()->GetPlatformCanvas() == FW_QDGlobals.thePort);
-
- #endif
-
- #define FW_CHECK_RENDER_VERB \
- if (renderVerb == FW_kNoRendering) \
- return;
-
- #define FW_RASTERIZER_PROLOG \
- FW_CHECK_RASTERIZER \
- FW_CGraphicDevice* device = gc.GetGraphicDevice();
-
- #define FW_CHECK_INK \
- FW_ASSERT((const void*)ink != NULL);
-
- #define FW_CHECK_STYLE \
- FW_ASSERT((const void*)style != NULL);
-
- #define FW_CHECK_FONT \
- FW_ASSERT((const void*)font != NULL);
-
-
- //========================================================================================
- // class FW_CPrivRasterizer
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivRasterizer::FW_CPrivRasterizer
- //----------------------------------------------------------------------------------------
-
- FW_CPrivRasterizer::FW_CPrivRasterizer()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivRasterizer::~FW_CPrivRasterizer
- //----------------------------------------------------------------------------------------
-
- FW_CPrivRasterizer::~FW_CPrivRasterizer()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivRasterizer::RenderRect
- //----------------------------------------------------------------------------------------
-
- void FW_CPrivRasterizer::RenderRect(FW_CGraphicContext& gc,
- const FW_CRect& rect,
- FW_ERenderVerbs renderVerb,
- const FW_PInk& ink,
- const FW_PStyle& style)
- {
- FW_RASTERIZER_PROLOG
- FW_CHECK_RENDER_VERB
- FW_CHECK_INK
- FW_CHECK_STYLE
-
- FW_SPlatformRect plfmRect = gc.LogicalToDevice(rect);
-
- #ifdef FW_BUILD_WIN
- FW_Boolean frameBrush = device->SelectInkAndStyle(ink, style,
- FW_kGeometricShapeWithInvert,
- renderVerb);
-
- HDC hDC = *device;
- if (frameBrush)
- {
- int penSizeX = device->fPenSize.x;
- int penSizeY = device->fPenSize.y;
-
- device->fGDIBrush.SelectObject(hDC);
- ::PatBlt(hDC, plfmRect.left, plfmRect.top, plfmRect.right - plfmRect.left, penSizeY, PATCOPY);
- ::PatBlt(hDC, plfmRect.right - penSizeX, plfmRect.top, penSizeX, plfmRect.bottom - plfmRect.top, PATCOPY);
- ::PatBlt(hDC, plfmRect.left, plfmRect.top, penSizeX, plfmRect.bottom - plfmRect.top, PATCOPY);
- ::PatBlt(hDC, plfmRect.left, plfmRect.bottom - penSizeY, plfmRect.right - plfmRect.left, penSizeY, PATCOPY);
- }
- else
- {
- if (ink->GetTransferMode() == FW_kInvert || ink->GetTransferMode() == FW_kHilite)
- {
- ::InvertRect(hDC, &plfmRect);
- }
- else
- {
- if (renderVerb == FW_kFill)
- {
- plfmRect.right++;
- plfmRect.bottom++;
- }
-
- ::Rectangle(hDC, plfmRect.left, plfmRect.top, plfmRect.right, plfmRect.bottom);
- }
- }
- #endif
- #ifdef FW_BUILD_MAC
- FW_Boolean styleIsDash = MacSelectInkAndStyle(device, FW_kGeometricShape, renderVerb, ink, style);
-
- if (renderVerb == FW_kFrame)
- {
- if (styleIsDash)
- {
- FW_CMacDashDraw draw(style->GetDashStyle());
-
- ::MoveTo(plfmRect.left, plfmRect.top);
- draw.LineTo(plfmRect.right - 1, plfmRect.top);
- draw.LineTo(plfmRect.right - 1, plfmRect.bottom - 1);
- draw.LineTo(plfmRect.left, plfmRect.bottom - 1);
- draw.LineTo(plfmRect.left, plfmRect.top);
- }
- else
- {
- ::FrameRect(&plfmRect);
- }
- }
- else
- {
- switch (ink->GetTransferMode())
- {
- case FW_kErase:
- ::EraseRect(&plfmRect);
- break;
-
- case FW_kHilite:
- FW_CGraphicDevice::SetHiliteMode();
- // fall-through
-
- case FW_kInvert:
- ::InvertRect(&plfmRect);
- break;
-
- default:
- ::PaintRect(&plfmRect);
- }
- }
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivRasterizer::RenderOval
- //----------------------------------------------------------------------------------------
-
- void FW_CPrivRasterizer::RenderOval(FW_CGraphicContext& gc,
- const FW_CRect& rect,
- FW_ERenderVerbs renderVerb,
- const FW_PInk& ink,
- const FW_PStyle& style)
- {
- FW_RASTERIZER_PROLOG
- FW_CHECK_RENDER_VERB
- FW_CHECK_INK
- FW_CHECK_STYLE
-
- FW_SPlatformRect plfmRect = gc.LogicalToDevice(rect);
-
- #ifdef FW_BUILD_WIN
- FW_Boolean frameBrush = device->SelectInkAndStyle(ink, style, FW_kGeometricShape, renderVerb);
-
- if (frameBrush)
- {
- HRGN hrgn = ::CreateEllipticRgn(plfmRect.left, plfmRect.top, plfmRect.right + 1, plfmRect.bottom + 1);
- ::FrameRgn(*device, hrgn, device->fGDIBrush.GetBrush(*device), device->fPenSize.x, device->fPenSize.y);
- ::DeleteObject(hrgn);
- }
- else
- {
- if (renderVerb == FW_kFill)
- {
- plfmRect.right++;
- plfmRect.bottom++;
- }
-
- ::Ellipse(*device, plfmRect.left, plfmRect.top, plfmRect.right, plfmRect.bottom);
- }
- #endif
- #ifdef FW_BUILD_MAC
- MacSelectInkAndStyle(device, FW_kGeometricShape, renderVerb, ink, style);
-
- if (renderVerb == FW_kFrame)
- {
- ::FrameOval(&plfmRect);
- }
- else
- {
- switch (ink->GetTransferMode())
- {
- case FW_kErase:
- ::EraseOval(&plfmRect);
- break;
- case FW_kHilite:
- FW_CGraphicDevice::SetHiliteMode();
- // fall-through
- case FW_kInvert:
- ::InvertOval(&plfmRect);
- break;
- default:
- ::PaintOval(&plfmRect);
- }
- }
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivRasterizer::RenderRoundRect
- //----------------------------------------------------------------------------------------
-
- void FW_CPrivRasterizer::RenderRoundRect(FW_CGraphicContext& gc,
- const FW_CRect& rect,
- const FW_CPoint& ovalSize,
- FW_ERenderVerbs renderVerb,
- const FW_PInk& ink,
- const FW_PStyle& style)
- {
- FW_RASTERIZER_PROLOG
- FW_CHECK_RENDER_VERB
- FW_CHECK_INK
- FW_CHECK_STYLE
-
- FW_SPlatformRect plfmRect = gc.LogicalToDevice(rect);
- FW_SPlatformPoint plfmOvalSize = gc.LogicalToDevice(ovalSize.x, ovalSize.y);
-
- #ifdef FW_BUILD_WIN
- FW_Boolean frameBrush = device->SelectInkAndStyle(ink, style, FW_kGeometricShape, renderVerb);
-
- if (frameBrush)
- {
- HRGN hrgn = NULL;
- // There is a bug in Windows. If the size of the round rect is smaller than 1, we are dead.
- if ((plfmRect.right - plfmRect.left <= 1) || (plfmRect.bottom - plfmRect.top <= 1))
- hrgn = ::CreateEllipticRgn(plfmRect.left, plfmRect.top,
- plfmRect.right + 1, plfmRect.bottom + 1);
- else
- hrgn = ::CreateRoundRectRgn(plfmRect.left, plfmRect.top,
- plfmRect.right + 1, plfmRect.bottom + 1,
- plfmOvalSize.x, plfmOvalSize.y);
-
- ::FrameRgn(*device, hrgn, device->fGDIBrush.GetBrush(*device), device->fPenSize.x, device->fPenSize.y);
- ::DeleteObject(hrgn);
- }
- else
- {
- if (renderVerb == FW_kFill)
- {
- plfmRect.right++;
- plfmRect.bottom++;
- }
-
- ::RoundRect(*device,
- plfmRect.left, plfmRect.top,
- plfmRect.right, plfmRect.bottom,
- plfmOvalSize.x, plfmOvalSize.y);
- }
- #endif
- #ifdef FW_BUILD_MAC
- GrafPtr curGrafPtr; // [KVV] Debugging
- GetPort(&curGrafPtr);
-
- MacSelectInkAndStyle(device, FW_kGeometricShape, renderVerb, ink, style);
-
- if (renderVerb == FW_kFrame)
- {
- ::FrameRoundRect(&plfmRect, plfmOvalSize.h, plfmOvalSize.v);
- }
- else
- {
- switch (ink->GetTransferMode())
- {
- case FW_kErase:
- ::EraseRoundRect(&plfmRect, plfmOvalSize.h, plfmOvalSize.v);
- break;
- case FW_kHilite:
- FW_CGraphicDevice::SetHiliteMode();
- case FW_kInvert:
- ::InvertRoundRect(&plfmRect, plfmOvalSize.h, plfmOvalSize.v);
- break;
- default:
- ::PaintRoundRect(&plfmRect, plfmOvalSize.h, plfmOvalSize.v);
- }
- }
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivRasterizer::RenderArc
- //----------------------------------------------------------------------------------------
-
- void FW_CPrivRasterizer::RenderArc(FW_CGraphicContext& gc,
- const FW_CRect& rect,
- short startAngle, short arcAngle,
- FW_ERenderVerbs renderVerb,
- const FW_PInk& ink,
- const FW_PStyle& style)
- {
- FW_RASTERIZER_PROLOG
- FW_CHECK_RENDER_VERB
- FW_CHECK_INK
- FW_CHECK_STYLE
-
- FW_SPlatformRect arcRect = gc.LogicalToDevice(rect);
-
- #ifdef FW_BUILD_WIN
- short angle1 = startAngle;
-
- // Normalize the start angle
- angle1 = angle1 % 360;
- if (angle1 < 0)
- angle1 += 360;
-
- // Compute and normalize the end angle
- short angle2 = angle1 + arcAngle;
- if (arcAngle < 0)
- {
- short temp = angle1;
- angle1 = angle2;
- angle2 = temp;
- }
-
- FW_SPlatformPoint endPoint, startPoint;
- FW_PrivCalcArcPoints(arcRect, angle1, endPoint); // on Windows, arc and pie are drawn counterclockwise
- FW_PrivCalcArcPoints(arcRect, angle2, startPoint);
-
- FW_Boolean frameBrush = device->SelectInkAndStyle(ink, style, FW_kGeometricShape, renderVerb);
-
- if (renderVerb == FW_kFrame)
- {
- if(frameBrush)
- {
- ODRgnHandle rgnHandle = ::FW_CreateArcRegion(arcRect, startAngle, arcAngle);
- ::FrameRgn(*device, rgnHandle, device->fGDIBrush.GetBrush(*device), device->fPenSize.x, device->fPenSize.y);
- ::FW_DisposeRegion(rgnHandle);
- }
- else
- {
- ::Arc(*device, arcRect.left, arcRect.top, arcRect.right, arcRect.bottom,
- startPoint.x, startPoint.y, endPoint.x, endPoint.y);
- }
- }
- else
- {
- arcRect.right++;
- arcRect.bottom++;
- ::Pie(*device, arcRect.left, arcRect.top, arcRect.right, arcRect.bottom,
- startPoint.x, startPoint.y, endPoint.x, endPoint.y);
- }
- #endif
- #ifdef FW_BUILD_MAC
- MacSelectInkAndStyle(device, FW_kGeometricShape, renderVerb, ink, style);
-
- if (renderVerb == FW_kFrame)
- {
- ::FrameArc(&arcRect, startAngle, arcAngle);
- }
- else
- {
- switch (ink->GetTransferMode())
- {
- case FW_kErase:
- ::EraseArc(&arcRect, startAngle, arcAngle);
- break;
- case FW_kHilite:
- FW_CGraphicDevice::SetHiliteMode();
- case FW_kInvert:
- ::InvertArc(&arcRect, startAngle, arcAngle);
- break;
- default:
- ::PaintArc(&arcRect, startAngle, arcAngle);
- }
- }
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivRasterizer::RenderLine
- //----------------------------------------------------------------------------------------
-
- void FW_CPrivRasterizer::RenderLine(FW_CGraphicContext& gc,
- const FW_CPoint& start,
- const FW_CPoint& end,
- FW_ERenderVerbs renderVerb,
- const FW_PInk& ink,
- const FW_PStyle& style)
- {
- FW_RASTERIZER_PROLOG
- FW_CHECK_RENDER_VERB
- FW_CHECK_INK
- FW_CHECK_STYLE
-
- FW_SPlatformPoint plfmStart = gc.LogicalToDevice(start);
- FW_SPlatformPoint plfmEnd = gc.LogicalToDevice(end);
-
- #ifdef FW_BUILD_WIN
- HDC hDC = device->GetPlatformCanvas();
- FW_Boolean frameBrush = device->SelectInkAndStyle(ink, style, FW_kGeometricShape, FW_kFrame);
-
- if (frameBrush)
- {
- int penSizeX = device->fPenSize.x;
- int penHalfX = penSizeX / 2;
- int penSizeY = device->fPenSize.y;
- int penHalfY = penSizeY / 2;
- if (plfmStart.x == plfmEnd.x)
- {
- device->fGDIBrush.SelectObject(hDC);
- ::PatBlt(hDC, plfmStart.x - penHalfX, plfmStart.y - penHalfY, penSizeX, plfmEnd.y - plfmStart.y, PATCOPY);
- }
- else if (plfmStart.y == plfmEnd.y)
- {
- device->fGDIBrush.SelectObject(hDC);
- ::PatBlt(hDC, plfmStart.x - penHalfX, plfmStart.y - penHalfY, plfmEnd.x - plfmStart.x, penSizeY, PATCOPY);
- }
- else
- {
- HRGN hRgn = ::FW_CreateLineRegion(FW_CPoint(plfmStart), FW_CPoint(plfmEnd), FW_CPoint(device->fPenSize));
- ::FillRgn(hDC, hRgn, device->fGDIBrush.GetBrush(hDC));
- ::DeleteObject(hRgn);
- }
- }
- else
- {
- ::MoveToEx(hDC, plfmStart.x, plfmStart.y, NULL);
- ::LineTo(hDC, plfmEnd.x, plfmEnd.y);
- }
- #endif
- #ifdef FW_BUILD_MAC
- FW_Boolean styleIsDash = MacSelectInkAndStyle(device,
- FW_kLineShape,
- FW_kFrame, // We never use FW_kFill for lines
- ink,
- style);
-
- short halfPenh = FW_QDGlobals.thePort->pnSize.h / 2;
- short halfPenv = FW_QDGlobals.thePort->pnSize.v / 2;
-
- ::MoveTo(plfmStart.h - halfPenh, plfmStart.v - halfPenv);
-
- if (styleIsDash && halfPenh == 0 && halfPenv == 0)
- {
- FW_CMacDashDraw draw(style->GetDashStyle());
- draw.LineTo(plfmEnd.h - halfPenh, plfmEnd.v - halfPenv);
- }
- else
- {
- ::LineTo(plfmEnd.h - halfPenh, plfmEnd.v - halfPenv);
- }
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivRasterizer::RenderRegion
- //----------------------------------------------------------------------------------------
-
- void FW_CPrivRasterizer::RenderRegion(FW_CGraphicContext& gc,
- ODShape* odShape,
- FW_ERenderVerbs renderVerb,
- const FW_PInk& ink,
- const FW_PStyle& style)
- {
- FW_RASTERIZER_PROLOG
- FW_CHECK_RENDER_VERB
- FW_CHECK_INK
- FW_CHECK_STYLE
-
- Environment* ev = gc.GetEnvironment();
-
- ODShape* deviceShape = gc.LogicalToDevice(odShape);
- ODRgnHandle rgnHandle = ::FW_GetShapeRegion(ev, deviceShape);
- FW_ASSERT(rgnHandle != NULL);
-
- #ifdef FW_BUILD_WIN
- FW_ERenderVerbs localVerb = renderVerb == FW_kFrame ? FW_kFill : renderVerb;
- device->SelectInkAndStyle(ink, style, FW_kGeometricShapeWithInvert, localVerb);
-
- switch (renderVerb)
- {
- case FW_kFrame:
- ::FrameRgn(*device, rgnHandle, device->fGDIBrush.GetBrush(*device), device->fPenSize.x, device->fPenSize.y);
- break;
-
- case FW_kFill:
- if (ink->GetTransferMode() == FW_kInvert || ink->GetTransferMode() == FW_kHilite)
- ::InvertRgn(*device, rgnHandle);
- else
- ::FillRgn(*device, rgnHandle, device->fGDIBrush.GetBrush(*device));
- break;
- }
- #endif
- #ifdef FW_BUILD_MAC
- MacSelectInkAndStyle(device, FW_kGeometricShape, renderVerb, ink, style);
-
- if (renderVerb == FW_kFrame)
- {
- ::FrameRgn(rgnHandle);
- }
- else
- {
- switch (ink->GetTransferMode())
- {
- case FW_kErase:
- ::EraseRgn(rgnHandle);
- break;
- case FW_kXOr:
- ::InvertRgn(rgnHandle);
- break;
- default:
- ::PaintRgn(rgnHandle);
- }
- }
-
- #endif
- deviceShape->Release(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivRasterizer::RenderPolygon
- //----------------------------------------------------------------------------------------
-
- void FW_CPrivRasterizer::RenderPolygon(FW_CGraphicContext& gc,
- const FW_PPolygon& polygon,
- FW_ERenderVerbs renderVerb,
- FW_Boolean autoCloseFrame,
- const FW_PInk& ink,
- const FW_PStyle& style)
- {
- FW_RASTERIZER_PROLOG
- FW_CHECK_RENDER_VERB
- FW_CHECK_INK
- FW_CHECK_STYLE
-
- #ifdef FW_BUILD_WIN
- // Convert points to platform points
- unsigned long count = polygon->GetCount();
- const FW_CPoint* points = polygon->GetPoints();
-
- unsigned long plfmCount = count;
- FW_Boolean needClose = FALSE;
- if(renderVerb == FW_kFrame && autoCloseFrame && points[0] != points[count - 1])
- {
- ++ plfmCount;
- needClose = TRUE;
- }
-
- FW_SPlatformPoint* plfmPoints = new FW_SPlatformPoint[plfmCount];
- for(unsigned long i = 0; i < count; i ++)
- plfmPoints[i] = gc.LogicalToDevice(points[i]);
-
- if(needClose)
- plfmPoints[plfmCount - 1] = plfmPoints[0];
-
- // Prepare the graphics device
- FW_Boolean frameBrush = device->SelectInkAndStyle(ink, style, FW_kGeometricShape, renderVerb);
-
- int penSizeX = device->fPenSize.x;
- int penHalfX = penSizeX / 2;
- int penSizeY = device->fPenSize.y;
- int penHalfY = penSizeY / 2;
-
- HDC hDC = *device;
-
- // Render the polygon
- switch (renderVerb)
- {
- case FW_kFrame:
- if(frameBrush)
- {
- // Doing it like this is way, way faster than creating a polygon
- // region for the whole thing and framing it
- FW_SPlatformPoint pt0, pt1;
- BOOL bBrushSelected = FALSE;
-
- for(unsigned long p = 0; p < plfmCount - 1; p ++)
- {
- pt0 = plfmPoints[p];
- pt1 = plfmPoints[p + 1];
-
- if (pt0.x == pt1.x)
- {
- if (!bBrushSelected)
- {
- device->fGDIBrush.SelectObject(hDC);
- bBrushSelected = TRUE;
- }
-
- ::PatBlt(hDC, pt0.x - penHalfX, pt0.y - penHalfY, penSizeX, pt1.y - pt0.y, PATCOPY);
- }
- else if (pt0.y == pt1.y)
- {
- if (!bBrushSelected)
- {
- device->fGDIBrush.SelectObject(hDC);
- bBrushSelected = TRUE;
- }
-
- ::PatBlt(hDC, pt0.x - penHalfX, pt0.y - penHalfY, pt1.x - pt0.x, penSizeY, PATCOPY);
- }
- else
- {
- HRGN hRgn = ::FW_CreateLineRegion(FW_CPoint(pt0), FW_CPoint(pt1), FW_CPoint(device->fPenSize));
- ::FillRgn(hDC, hRgn, device->fGDIBrush.GetBrush(hDC));
- ::DeleteObject(hRgn);
- }
- }
- }
- else
- {
- ::Polyline(hDC, plfmPoints, plfmCount);
- }
- break;
-
- case FW_kFill:
- ::Polygon(hDC, plfmPoints, plfmCount);
- break;
- }
-
- delete[] plfmPoints;
- #endif
- #ifdef FW_BUILD_MAC
- // Create a polygon
- GrafPtr savePort;
- ::GetPort(&savePort);
- ::SetPort(FW_gScratchWindow);
- PolyHandle polyHandle = ::OpenPoly();
-
- if(polyHandle == NULL)
- {
- ::SetPort(savePort);
- FW_Failure(FW_xMemoryExhausted);
- }
-
- unsigned long count = polygon->GetCount();
- const FW_CPoint* points = polygon->GetPoints();
-
- FW_SPlatformPoint plfmPoint;
- plfmPoint = gc.LogicalToDevice(points[0]);
- ::MoveTo(plfmPoint.h, plfmPoint.v);
-
- for(unsigned long i = 1; i < count; i ++)
- {
- plfmPoint = gc.LogicalToDevice(points[i]);
- ::LineTo(plfmPoint.h, plfmPoint.v);
- }
-
- // Close the polygon if needed
- if(renderVerb == FW_kFrame && autoCloseFrame && points[0] != points[count - 1])
- {
- plfmPoint = gc.LogicalToDevice(points[0]);
- ::LineTo(plfmPoint.h, plfmPoint.v);
- }
-
- ::ClosePoly();
- ::SetPort(savePort);
-
- // Prepare the grafport
- FW_Boolean styleIsDash = MacSelectInkAndStyle(device, FW_kGeometricShape, renderVerb, ink, style);
-
- // Render the polygon
- if (renderVerb == FW_kFrame)
- {
- if (styleIsDash)
- {
- FW_CMacDashDraw draw(style->GetDashStyle());
- short nPolyCount = ((*polyHandle)->polySize - 10) / sizeof(Point);
- ::MoveTo((*polyHandle)->polyPoints[0].h, (*polyHandle)->polyPoints[0].v);
- for (short n = 1; n < nPolyCount; ++ n)
- draw.LineTo((*polyHandle)->polyPoints[n].h, (*polyHandle)->polyPoints[n].v);
- }
- else
- {
- ::FramePoly(polyHandle);
- }
- }
- else
- {
- switch (ink->GetTransferMode())
- {
- case FW_kErase:
- ::ErasePoly(polyHandle);
- break;
- case FW_kXOr:
- ::InvertPoly(polyHandle);
- break;
- default:
- ::PaintPoly(polyHandle);
- }
- }
-
- ::KillPoly(polyHandle);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivRasterizer::TextExtent
- //----------------------------------------------------------------------------------------
-
- void FW_CPrivRasterizer::TextExtent(FW_CGraphicContext& gc,
- FW_CPrivTextBuffer *textBuffer,
- const FW_PFont& font,
- FW_CPoint& textExtent)
- {
- FW_RASTERIZER_PROLOG
- FW_CHECK_FONT
-
- if (textBuffer->IsDone())
- {
- textExtent = FW_kZeroPoint;
- return;
- }
-
- device->SelectFont(font, TRUE);
-
- // ----- TextExtent only cares about the first line -----
- FW_CharacterCount charCount = textBuffer->GetCurrentLineLength();
- const FW_Char* text = (const FW_Char*) textBuffer->GetCurrentLine();
-
- #ifdef FW_BUILD_WIN
- SIZE size;
- ::GetTextExtentPoint32(*device, text, charCount, &size);
- FW_SPlatformPoint plfmExtent(size.cx, size.cy);
- #endif
- #ifdef FW_BUILD_MAC
- FontInfo fi;
- ::GetFontInfo(&fi);
-
- FW_SPlatformPoint plfmExtent(
- ::TextWidth(text, 0, charCount),
- fi.ascent + fi.descent);
- #endif
-
- textExtent = gc.DeviceToLogical(plfmExtent.X(), plfmExtent.Y());
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivRasterizer::TextBoxSize
- //----------------------------------------------------------------------------------------
-
- void FW_CPrivRasterizer::TextBoxSize(FW_CGraphicContext& gc,
- FW_CPrivTextBuffer *textBuffer,
- const FW_PFont& font,
- FW_TextBoxOptions options,
- FW_CRect& textBox)
- {
- FW_RASTERIZER_PROLOG
- FW_CHECK_FONT
-
- FW_ASSERT((const void*)font != NULL);
- FW_ASSERT(textBuffer != NULL);
-
- FW_SPlatformRect plfmBox = gc.LogicalToDevice(textBox);
-
- if (textBuffer->IsDone())
- {
- plfmBox.bottom = plfmBox.top;
- }
- else
- {
- device->SelectFont(font, TRUE); // TRUE: scale
- plfmBox.bottom = PrivTextBox(device, textBuffer, plfmBox, options, FALSE, font); // FALSE: don't draw
- }
-
- FW_CPoint textBoxSize = gc.DeviceToLogical(plfmBox.right, plfmBox.bottom);
- textBox.right = textBox.left + textBoxSize.x;
- textBox.bottom = textBox.top + textBoxSize.y;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivRasterizer::RenderText
- //----------------------------------------------------------------------------------------
-
- void FW_CPrivRasterizer::RenderText(FW_CGraphicContext& gc,
- FW_CPrivTextBuffer *textBuffer,
- const FW_CPoint& position,
- FW_TextAlignment textAlignment,
- FW_ERenderVerbs renderVerb,
- const FW_PInk& ink,
- const FW_PFont& font)
- {
- FW_RASTERIZER_PROLOG
- FW_CHECK_RENDER_VERB
- FW_CHECK_FONT
- FW_CHECK_INK
-
- FW_ASSERT(textBuffer != NULL);
- if (textBuffer->IsDone()) // No text to draw
- return;
-
- FW_SPlatformPoint plfmPos = gc.LogicalToDevice(position);
-
- // ----- RenderText only cares about the first line -----
- FW_CharacterCount charCount = textBuffer->GetCurrentLineLength();
- const FW_Char* text = (const FW_Char*) textBuffer->GetCurrentLine();
-
- #ifdef FW_BUILD_WIN
- device->SelectInkAndFont(ink, font);
-
- // ----- Set the text alignment - always use TA_UPDATECP (see below)
- TEXTMETRIC tm;
- UINT newAlign = TA_UPDATECP;
-
- switch (textAlignment & FW_kTextAlignPrivVertAlignMask)
- {
- case FW_kTextAlignTop:
- newAlign |= TA_TOP;
- break;
-
- case FW_kTextAlignBottom:
- newAlign |= TA_BOTTOM;
- break;
-
- case FW_kTextAlignVCenter:
- ::GetTextMetrics(*device, &tm);
- plfmPos.y -= (tm.tmHeight - tm.tmInternalLeading) / 2;
- break;
-
- case FW_kTextAlignBaseLine:
- newAlign |= TA_BASELINE;
- break;
- }
-
- switch (textAlignment & FW_kTextAlignPrivHorzAlignMask)
- {
- case FW_kTextAlignLeft:
- newAlign |= TA_LEFT;
- break;
-
- case FW_kTextAlignRight:
- newAlign |= TA_RIGHT;
- break;
-
- case FW_kTextAlignHCenter:
- newAlign |= TA_CENTER;
- break;
- }
-
- // It is necessary to use TA_UPDATECP because the next call may want to use
- // FW_kTextAlignUseCurrentPos. However, TA_UPDATECP also means "use CP", so
- // if this is not what the user wants, we should move to the right pos first
-
- if((textAlignment & FW_kTextAlignPrivUsePosMask) == FW_kTextAlignUseSpecifiedPos)
- ::MoveToEx(*device, plfmPos.x, plfmPos.y, NULL);
-
- ::SetTextAlign(*device, newAlign);
- ::TextOut(*device,
- 0, 0, // we use TA_UPDATECP, remember?
- text,
- charCount);
-
- ::SetTextAlign(*device, TA_LEFT | TA_TOP | TA_NOUPDATECP); // restore the flags
- #endif
- #ifdef FW_BUILD_MAC
- device->SelectInk(ink, FW_kTypographicShape, FW_kFill);
- device->SelectFont(font, TRUE); // SetInGrafPort called by SelectFont
-
- // ----- The Mac only knows to draw text from the baseline, so we need to do some adjustment
- FW_SPlatformPoint plfmTextPos = MacCalcTextPosition(device, charCount, (const char*) text, textAlignment, plfmPos);
-
- // ----- Draw the text
- ::MoveTo(plfmTextPos.h, plfmTextPos.v);
- ::DrawText(text, 0, charCount);
-
- // ----- StrikeOut if necessary
- if (font->GetFontStyle() & FW_kStrikeOut)
- MacStrikeOut(device, plfmTextPos.h, plfmTextPos.v);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CTextBoxShape::PrivTextBox
- //----------------------------------------------------------------------------------------
-
- FW_PlatformCoordinate FW_CPrivRasterizer::PrivTextBox(FW_CGraphicDevice* device,
- FW_CPrivTextBuffer *textBuffer,
- const FW_SPlatformRect& box,
- FW_TextBoxOptions options,
- FW_Boolean draw,
- const FW_PFont& font)
- {
- // ----- Check options for consistency
- FW_TextBoxOptions opt = options;
-
- if (!draw)
- opt &= ~FW_kTextBoxClipToBox;
-
- if ((opt & FW_kTextBoxSingleLine) != 0)
- {
- opt &= ~FW_kTextBoxWordWrap;
- opt &= ~FW_kTextBoxWordBreak;
- }
-
- if ((opt & FW_kTextBoxWordWrap) != 0)
- {
- opt &= ~FW_kTextBoxJustifyBottom;
- opt &= ~FW_kTextBoxJustifyVCenter;
- }
-
- FW_CharacterPosition segStart; // start of the current string segment
- FW_CharacterCount segLen; // its length (charcter count)
- FW_PlatformCoordinate actualWidth; // its actual width (pixels)
- FW_PlatformCoordinate maxWidth = box.right - box.left;
-
- FW_Boolean bClip = (opt & FW_kTextBoxClipToBox) != 0;
-
- #ifdef FW_BUILD_WIN
- // ----- Set the clipping region if we need to
- HDC hDC = device->GetPlatformCanvas();
- int savedDC = 0;
- if (bClip)
- {
- savedDC = ::SaveDC(hDC);
- ::IntersectClipRect(hDC,
- box.left, box.top,
- box.right, box.bottom);
- }
-
- // ----- Get the font height
- TEXTMETRIC textMetric;
- ::GetTextMetrics(hDC, &textMetric);
- short fontHeight = textMetric.tmHeight + textMetric.tmExternalLeading;
-
- short drawPosY = box.top;
- short drawPosX = box.left;
- #endif
- #ifdef FW_BUILD_MAC
- // ----- Set the clipping region if we need to
- RgnHandle oldClipRgn = 0;
- if (bClip)
- {
- oldClipRgn = device->GetClip();
- device->IntersectClipRect(box);
- }
-
- // ----- Get the font height -----
- FontInfo fi;
- ::GetFontInfo(&fi);
- short fontHeight = fi.ascent + fi.descent + fi.leading;
-
- short drawPosY = box.top + fi.ascent;
- short drawPosX = box.left;
-
- FW_Boolean bIsStrikeOut = font->GetFontStyle() & FW_kStrikeOut;
- #endif
-
- // ----- Check vertical jusitficaiton
- switch (opt & FW_kTextBoxPrivVertJusificationMask)
- {
- case FW_kTextBoxJustifyVCenter:
- #ifdef FW_BUILD_WIN
- drawPosY = (box.top + box.bottom - fontHeight) / 2;
- #endif
- #ifdef FW_BUILD_MAC
- drawPosY = (box.top + box.bottom + fi.ascent - fi.descent) / 2;
- #endif
- break;
-
- case FW_kTextBoxJustifyBottom:
- drawPosY = box.bottom - fontHeight;
- break;
- }
-
- // ----- Draw string segments one by one
- FW_Boolean wordWrap = (opt & FW_kTextBoxWordWrap) != 0;
- FW_Boolean wordBreak = (opt & FW_kTextBoxWordBreak) != 0;
- FW_Boolean reachedBottom = FALSE;
- while (!reachedBottom && !textBuffer->IsDone())
- {
- const FW_Char* line = (const FW_Char*) textBuffer->GetCurrentLine();
- FW_CharacterCount lineLength = textBuffer->GetCurrentLineLength();
-
- // ----- Draw the current segment
- while (!reachedBottom && PrivGetStringSegment(*device, line, lineLength,
- segStart, segLen, maxWidth, actualWidth, wordWrap, wordBreak))
- {
- // ----- Check horizontal jusitficaiton
- switch (opt & FW_kTextBoxPrivHorzJusificationMask)
- {
- case FW_kTextAlignHCenter:
- drawPosX = (box.left + box.right - actualWidth) / 2;
- break;
-
- case FW_kTextAlignRight:
- drawPosX = box.right - actualWidth;
- break;
- }
-
- if (draw)
- {
- // ----- Draw the next line -----
- #ifdef FW_BUILD_WIN
- ::TextOut(hDC, drawPosX, drawPosY, line + segStart, segLen);
- #endif
- #ifdef FW_BUILD_MAC
- ::MoveTo(drawPosX, drawPosY);
- ::DrawText((Ptr)line, segStart, segLen);
-
- // ----- StrikeOut if necessary -----
- if (bIsStrikeOut)
- MacStrikeOut(device, drawPosX, drawPosY);
- #endif
- }
-
- drawPosY += fontHeight; // Move one line down
- line += segLen + segStart; // move on to the next segment
- lineLength -= segLen + segStart;
-
- // see if we've gotten to the bottom of the rectangle and need not to continue
- reachedBottom = bClip && (drawPosY > box.bottom);
- }
-
- if (!reachedBottom)
- textBuffer->GetNextLine();
- }
-
- // ----- Restore clipping region
- #ifdef FW_BUILD_WIN
- if (savedDC != 0)
- ::RestoreDC(*device, savedDC);
- #endif
- #ifdef FW_BUILD_MAC
- if (oldClipRgn != NULL)
- {
- ::SetClip(oldClipRgn);
- ::DisposeRgn(oldClipRgn);
- }
-
- #endif
-
- // ----- Return the result ----
- #ifdef FW_BUILD_WIN
- return drawPosY;
- #endif
- #ifdef FW_BUILD_MAC
- return drawPosY - fi.ascent;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CTextBoxShape::RenderTextBox
- //----------------------------------------------------------------------------------------
-
- FW_CFixed FW_CPrivRasterizer::RenderTextBox(FW_CGraphicContext& gc,
- FW_CPrivTextBuffer *textBuffer,
- const FW_CRect& box,
- FW_TextBoxOptions options,
- FW_ERenderVerbs renderVerb,
- const FW_PInk& ink,
- const FW_PFont& font)
- {
- FW_RASTERIZER_PROLOG
- FW_CHECK_FONT
- FW_CHECK_INK
-
- FW_ASSERT(textBuffer != NULL);
- if (renderVerb == FW_kNoRendering || textBuffer->IsDone())
- return box.top;
-
- FW_SPlatformRect plfmBox = gc.LogicalToDevice(box);
-
- #ifdef FW_BUILD_WIN
- device->SelectInkAndFont(ink, font);
- #endif
- #ifdef FW_BUILD_MAC
- device->SelectInk(ink, FW_kTypographicShape, FW_kFill);
- device->SelectFont(font, TRUE); // SetInGrafPort called by SelectFont
- #endif
-
- FW_PlatformCoordinate bottom = PrivTextBox(device, textBuffer, plfmBox, options, TRUE, font);
-
- if (bottom != plfmBox.bottom)
- {
- FW_SPlatformPoint pt(0, bottom);
- FW_CPoint cPt = gc.DeviceToLogical(pt);
- return cPt.y;
- }
-
- return box.bottom;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivRasterizer::RenderPicture
- //----------------------------------------------------------------------------------------
-
- void FW_CPrivRasterizer::RenderPicture(FW_CGraphicContext& gc,
- FW_PPicture picture,
- const FW_CRect& dstRect,
- FW_ERenderVerbs renderVerb)
- {
- FW_RASTERIZER_PROLOG
- FW_CHECK_RENDER_VERB
-
- FW_ASSERT((const void*)picture != NULL);
- FW_PlatformPict pict = picture->GetPlatformPict();
- FW_SPlatformRect plfmRect = gc.LogicalToDevice(dstRect);
-
- #ifdef FW_BUILD_WIN
- ::PlayEnhMetaFile(*device, pict, &plfmRect);
- #endif
- #ifdef FW_BUILD_MAC
- ::DrawPicture(picture->GetPlatformPict(), &plfmRect);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivRasterizer::RenderBitmap
- //----------------------------------------------------------------------------------------
-
- void FW_CPrivRasterizer::RenderBitmap(FW_CGraphicContext& gc,
- FW_PBitmap bitmap,
- const FW_CRect& srcRect,
- const FW_CRect& dstRect,
- FW_ERenderVerbs renderVerb,
- const FW_PInk& ink)
- {
- FW_RASTERIZER_PROLOG
- FW_CHECK_RENDER_VERB
-
- FW_ASSERT((const void*)bitmap != NULL);
-
- // Convert source and destination rectangles
- FW_SPlatformRect plfmDstRect = gc.LogicalToDevice(dstRect);
- FW_SPlatformRect plfmSrcRect = srcRect;
-
- #ifdef FW_BUILD_WIN
- ::SetTextColor(*device, *ink->GetForeColor());
- ::SetBkColor(*device, *ink->GetBackColor());
-
- HDC hDC = *device;
-
- HBITMAP plfmBitmap = bitmap->GetPlatformBitmap();
-
- HDC memoryDC = ::CreateCompatibleDC(*device);
- HBITMAP oldBitmap = (HBITMAP) ::SelectObject(memoryDC, plfmBitmap);
-
- HPALETTE hPal = bitmap->GetPalette();
- HPALETTE hPalOld = NULL;
- if (hPal != NULL)
- {
- hPalOld = ::SelectPalette(hDC, hPal, FALSE);
- ::RealizePalette(hDC);
- }
-
- ::StretchBlt(hDC,
- plfmDstRect.left,
- plfmDstRect.top,
- plfmDstRect.right - plfmDstRect.left,
- plfmDstRect.bottom - plfmDstRect.top,
- memoryDC,
- plfmSrcRect.left,
- plfmSrcRect.top,
- plfmSrcRect.right - plfmSrcRect.left,
- plfmSrcRect.bottom - plfmSrcRect.top,
- WinConvertRasterOp(ink->GetTransferMode()));
-
- if (hPalOld)
- ::SelectPalette(hDC, hPalOld, TRUE);
-
- ::SelectObject(memoryDC, oldBitmap);
- ::DeleteDC(memoryDC);
- #endif
- #ifdef FW_BUILD_MAC
- device->SelectInk(ink, FW_kImageShape, FW_kFill); // Never use FW_kFrame for bitmap
- device->SetInGrafPort();
-
- PixMapHandle pmh = bitmap->MacLockPixels();
- ::CopyBits((BitMap*)*pmh, &FW_QDGlobals.thePort->portBits,
- &plfmSrcRect, &plfmDstRect,
- ink->GetTransferMode(), NULL);
- bitmap->MacUnlockPixels();
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivRasterizer::RenderIcon
- //----------------------------------------------------------------------------------------
-
- void FW_CPrivRasterizer::RenderIcon(FW_CGraphicContext& gc,
- const FW_PIcon& icon,
- const FW_CRect& rect,
- FW_RenderIconOptions options,
- FW_ERenderVerbs renderVerb)
- {
- FW_RASTERIZER_PROLOG
- FW_CHECK_RENDER_VERB
-
- FW_ASSERT((const void*)icon != NULL);
-
- FW_CPoint iconSize;
- icon->GetIconSize(iconSize);
-
- short xSize = iconSize.IntX(), ySize = iconSize.IntY();
-
- FW_SPlatformRect plfmDstRect = gc.LogicalToDevice(rect);
-
- if(options != FW_kIconScaleToFit)
- {
- // Horizontal alignment
- switch((options & FW_kIconPrivHorzMask))
- {
- case FW_kIconAlignCenter:
- plfmDstRect.left = (plfmDstRect.right + plfmDstRect.left - xSize) / 2;
- // fall-through
-
- case FW_kIconAlignLeft:
- plfmDstRect.right = plfmDstRect.left + xSize;
- break;
-
- case FW_kIconAlignRight:
- plfmDstRect.left = plfmDstRect.right - xSize;
- break;
- }
-
- // Vertical alignment
- switch((options & FW_kIconPrivVertMask))
- {
- case FW_kIconAlignVCenter:
- plfmDstRect.top = (plfmDstRect.top + plfmDstRect.bottom - ySize) / 2;
- // fall-through
-
- case FW_kIconAlignTop:
- plfmDstRect.bottom = plfmDstRect.top + ySize;
- break;
-
- case FW_kIconAlignBottom:
- plfmDstRect.top = plfmDstRect.bottom - ySize;
- break;
- }
- }
-
- FW_PlatformIcon hIcon = icon->GetPlatformIcon();
-
- #ifdef FW_BUILD_WIN
- ::DrawIconEx(*device, plfmDstRect.left, plfmDstRect.top, hIcon,
- plfmDstRect.right - plfmDstRect.left,
- plfmDstRect.bottom - plfmDstRect.top,
- 0, NULL, DI_NORMAL);
- #endif
- #ifdef FW_BUILD_MAC
- ::RGBForeColor(&FW_kRGBBlack);
- ::RGBBackColor(&FW_kRGBWhite);
- ::PlotIconSuite(&plfmDstRect, atNone, ttNone, hIcon);
- #endif
- }
-
-
-
- #ifdef FW_BUILD_MAC
-
- //========================================================================================
- // Macintosh-specific implementation
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivRasterizer::MacSelectInkAndStyle
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CPrivRasterizer::MacSelectInkAndStyle(FW_CGraphicDevice* device,
- FW_EShapeCategories shapeCategory,
- FW_ERenderVerbs renderVerb,
- const FW_PInk& ink,
- const FW_PStyle& style)
- {
-
- device->SelectInk(ink, shapeCategory, renderVerb);
- FW_Boolean styleIsDash = device->SelectStyle(style, ink->GetTransferMode());
- device->SetInGrafPort();
- return styleIsDash;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivRasterizer::MacCalcTextPosition
- //----------------------------------------------------------------------------------------
-
- FW_SPlatformPoint FW_CPrivRasterizer::MacCalcTextPosition(FW_CGraphicDevice* device,
- short byteCount, const char* text,
- FW_TextAlignment textAlignment,
- const FW_SPlatformPoint& position) const
- {
- FW_ASSERT(device->GetPlatformCanvas() == FW_QDGlobals.thePort);
-
- FW_ASSERT(text != NULL);
-
- FW_SPlatformPoint plfmPos(position);
-
- if((textAlignment & FW_kTextAlignPrivUsePosMask) == FW_kTextAlignUseCurrentPos)
- {
- ::GetPen(&plfmPos);
- }
- else
- {
- // ----- Adjust Horizontal position
- FW_TextAlignment hAlign = textAlignment & FW_kTextAlignPrivHorzAlignMask;
- if (hAlign != FW_kTextAlignLeft)
- {
- short textWidth = ::TextWidth(text, 0, byteCount);
- if (hAlign == FW_kTextAlignRight)
- plfmPos.h -= textWidth;
- else
- plfmPos.h -= (textWidth / 2);
- }
- }
-
- // ----- In both cases we need to adjust the vertical position
- FW_TextAlignment vAlign = textAlignment & FW_kTextAlignPrivVertAlignMask;
- if (vAlign != FW_kTextAlignBaseLine)
- {
- FontInfo fi;
- ::GetFontInfo(&fi);
- switch (vAlign)
- {
- case FW_kTextAlignTop:
- plfmPos.v += fi.ascent;
- break;
-
- case FW_kTextAlignBottom:
- plfmPos.v -= fi.descent;
- break;
-
- case FW_kTextAlignVCenter:
- plfmPos.v += fi.ascent - ((fi.descent + fi.ascent) / 2);
- break;
- }
- }
-
- return plfmPos;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivRasterizer::MacStrikeOut
- //----------------------------------------------------------------------------------------
-
- void FW_CPrivRasterizer::MacStrikeOut(FW_CGraphicDevice* device,
- short beforePosX, short beforePosY)
- {
- // ----- Get the pen position before drawing -----
- FW_SPlatformPoint afterPoint;
- ::GetPen(&afterPoint);
-
- FontInfo fi;
- ::GetFontInfo(&fi);
- short ySize = (fi.ascent + fi.descent) / 2;
-
- device->SetPenSize(1,1);
- device->SetInGrafPort();
-
- ::MoveTo(beforePosX, beforePosY - ySize);
- ::LineTo(afterPoint.h - 1, afterPoint.v - ySize);
-
- // ----- Restore the pen position -----
- ::MoveTo(afterPoint.h, afterPoint.v);
- }
-
- #endif
-
- #ifdef FW_BUILD_WIN
-
- //========================================================================================
- // Windows-specific implementation
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivRasterizer::WinConvertRasterOp
- //----------------------------------------------------------------------------------------
-
- DWORD FW_CPrivRasterizer::WinConvertRasterOp(FW_TransferModes transferMode)
- {
- if ((transferMode & 0xFFFF0000L) == 0)
- return (DWORD)transferMode; // Native Raster ops
- else
- {
- FW_ASSERT(transferMode <= FW_LastTransferMode);
- return FW_gWinRasterOps[transferMode & 0x0000FFFFL];
- }
- }
-
- #endif
-