📄 scemfdcrenderer.h
字号:
/*
* This file is part of the EMFexplorer projet.
* Copyright (C) 2004 Smith Charles.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*
* Extension: for commercial use, apply the Equity Public License, which
* adds to the normal terms of the GLPL a condition of donation to the author.
* If you are interested in support for this source code,
* contact Smith Charles <smith.charles@free.fr> for more information.
*/
#ifndef _SCEMFDCRENDERER_H_
#define _SCEMFDCRENDERER_H_
#include "kSCEMFLibError.h"
#include "I_EMFRenderer.h"
#include "SCGdiplusUtils.h"
#include "SCGdiplusTypes.h"
#include "SCGenInclude.h"
#include SC_INC_GENLIB(SCGenMath.h)
#include SC_INC_GENLIB(SCRefdObjHolder_T.h)
#include SC_INC_WINLIB(SCRectPoly.h)
#include SC_INC_WINLIB(SCGDIRops.h)
#include <float.h>
#include <afxtempl.h>
////////////////////////////////////////////////////////////////////////////////////
///
#define SC_FLOAT_EQ(x,v) (((v - FLT_EPSILON) < x) && (x <( v + FLT_EPSILON)))
#define SC_RGBCOLOR(color) (color & 0x00FFFFFF)
#define SC_FINAL_COLOR(color) m_DrawingAttributes.bReverseVideo ? SC_RGBCOLOR(~color) : SC_RGBCOLOR(color)
#define SC_FONT_SIMUL_UNDERLINE 0x01
#define SC_FONT_SIMUL_OVERSTRIKE 0x02
// Let this undefined if GDI has to do the ROPs in the parser
// #define SC_RENDERER_CAN_DOROP
////////////////////////////////////////////////////////////////////////////////////
///
typedef SCRefdObjHolder<GDPPen> SCPenHolder;
typedef SCRefdObjContainer<GDPBrush, SCBrush> SCBrushHolder;
typedef SCRefdObjHolder<SCFont> SCFontHolder;
typedef SCRefdObjHolder<SCPath> SCPathHolder;
typedef SCRefdObjHolder<SCFontCollection> SCFontCollectionHolder;
class SCRectPolygon;
class CSCGDIState;
typedef CTypedPtrArray<CPtrArray, CSCGDIState*> SCStatesArray;
class CSCEMFmetaDCRenderer;
////////////////////////////////////////////////////////////////////////////////////
/// Class to render on DC
class CSCEMFdcRenderer : public I_EMFRenderer,
public I_SCDCGraphics
{
// Construction/Destruction
public:
CSCEMFdcRenderer();
virtual ~CSCEMFdcRenderer();
// Attributes
// getters
// setters
void SCSetDrawingAttributes(SCGDIpDrawingAttributes& rDrawingAttributes) { m_DrawingAttributes = rDrawingAttributes;}
void SCSetFontCollection(SCFontCollection* pColl) { m_pFontCollection = pColl; }
static void SCCleanFontCopies();
// Operation
// Implementation
// I_EMFRenderer
// Rendering device
virtual BOOL SCBeginRendering(HDC hDestDC, HDC hSrcDC);
virtual void SCEndRendering() {}
// Curves and surfaces
virtual void SCDrawLines(POINT* pPoints, DWORD dwCount);
virtual void SCDrawLinesS(POINTS* pPoints, DWORD dwCount);
virtual void SCDrawLinesTo(POINT* pPoints, DWORD dwCount);
virtual void SCDrawLinesToS(POINTS* pPoints, DWORD dwCount);
virtual void SCDrawBezier(POINT* pPoints, DWORD dwCount);
virtual void SCDrawBezierTo(POINT* pPoints, DWORD dwCount);
virtual void SCDrawBezierS(POINTS* pPoints, DWORD dwCount);
virtual void SCDrawBezierToS(POINTS* pPoints, DWORD dwCount);
virtual void SCDrawPolygon(POINT* pPoints, DWORD dwCount);
virtual void SCDrawPolygonS(POINTS* pPoints, DWORD dwCount);
virtual void SCDrawPolyPolygon(POINT* pPoints, DWORD dwCount, DWORD *pPolyVertices, DWORD dwNbPolys);
virtual void SCDrawPolyPolygonS(POINTS* pPoints, DWORD dwCount, DWORD *pPolyVertices, DWORD dwNbPolys);
virtual void SCDrawPolyPolyline(POINT* pPoints, DWORD dwCount, DWORD *pPolyVertices, DWORD dwNbPolys);
virtual void SCDrawPolyPolylineS(POINTS* pPoints, DWORD dwCount, DWORD *pPolyVertices, DWORD dwNbPolys);
virtual void SCDrawPolyDraw(POINT* pPoints, DWORD dwCount, BYTE *pTypes);
virtual void SCDrawPolyDrawS(POINTS* pPoints, DWORD dwCount, BYTE *pTypes);
virtual void SCDrawRectangle(LPCRECT pBox);
virtual void SCDrawRoundRectangle(LPCRECT pBox, SIZE szlCorner);
virtual void SCDrawEllipse(LPCRECT pBox);
virtual void SCDrawAngleArc(POINT* pPtCenter, DWORD dwRadius, FLOAT fStartAngle, FLOAT fSweepAngle);
virtual void SCDrawArc(LPCRECTL pBox, LPCPOINTL pPtStart, LPCPOINTL pPtEnd);
virtual void SCDrawChord(LPCRECTL pBox, LPCPOINTL pPtStart, LPCPOINTL pPtEnd);
virtual void SCDrawPie(LPCRECTL pBox, LPCPOINTL pPtStart, LPCPOINTL pPtEnd);
virtual void SCDrawArcTo(LPCRECTL pBox, LPCPOINTL pPtStart, LPCPOINTL pPtEnd);
// Texts
virtual void SCDrawText(INT x, INT y, UINT uiOptions, LPCRECT pRect,
LPCWSTR pwString, UINT uiCount, LPCINT pDxWidths, FLOAT fScaleX, FLOAT fScaleY);
// Images
virtual void SCDrawImage(LPCRECT pDest, LPCRECT pSrc, LPCBYTE pBits, LPCBITMAPINFO pBmi, DWORD dwUsage, DWORD dwRop3, XFORM* pXForm=NULL);
virtual void SCDrawImagePlg(LPCPOINTL p3PtDest, LPCRECT pSrc, LPCBYTE pBits, LPCBITMAPINFO pBmi, DWORD dwUsage, XFORM* pXForm, COLORREF crBkColorSrc,
LONG lxMask, LONG lyMask, LPCBYTE pBitsMask, LPCBITMAPINFO pBmiMask, DWORD dwUsageMask);
virtual void SCDrawImageMsk(LPCRECT pDest, LPCRECT pSrc, LPCBYTE pBits, LPCBITMAPINFO pBmi, DWORD dwUsage, DWORD dwRop4, XFORM* pXForm, COLORREF crBkColorSrc,
LONG lxMask, LONG lyMask, LPCBYTE pBitsMask, LPCBITMAPINFO pBmiMask, DWORD dwUsageMask);
virtual void SCDrawImageTransparent(LPCRECT pDest, LPCRECT pSrc, LPCBYTE pBits,
LPCBITMAPINFO pBmi, DWORD dwUsage, DWORD dwRop3,
XFORM* pXForm, COLORREF crBkColorSrc);
virtual void SCDrawImageAlpha(LPCRECT pDest, LPCRECT pSrc, LPCBYTE pBits,
LPCBITMAPINFO pBmi, DWORD dwUsage, DWORD dwRop3,
XFORM* pXForm, COLORREF crBkColorSrc);
virtual void SCDrawPixel(POINTL ptlPixel, COLORREF crColor);
virtual void SCPatBlt(LPCRECT pDest, DWORD dwRop3, XFORM* pXForm=NULL);
virtual void SCGradientFill(TRIVERTEX* pVer, DWORD dwCountVer, LPCBYTE pMesh, DWORD dwCountMesh, DWORD dwMode);
virtual void SCFloodFill(POINTL& rPtStart, COLORREF crColor, DWORD iMode);
// Paths
virtual void SCDrawPath(LPCPOINT pPoints, LPCBYTE pTypes, DWORD dwCount, DWORD dwDrawType=SC_PATH_STROKEANDFILL);
virtual void SCSetClipPath(LPCPOINT pPoints, LPCBYTE pTypes, DWORD dwCount, INT iClipMode);
virtual void SCBeginPath();
virtual void SCCloseFigure();
virtual void SCEndPath();
virtual void SCApplyPath(DWORD dwDrawType=SC_PATH_STROKEANDFILL, INT iClipMode=RGN_COPY);
virtual void SCFlattenPath();
virtual void SCWidenPath();
virtual void SCAbortPath();
// Drawing objects
virtual void SCOnChangePen(HPEN hPen);
virtual void SCOnChangeExtPen(HPEN hPen);
virtual void SCOnChangeBrush(HBRUSH hBrush);
virtual void SCOnChangeFont(HFONT hFont);
virtual void SCOnChangePalette(HPALETTE hPal);
// Clipping
virtual void SCIntersectClipRect(RECTL& rRect);
virtual void SCExcludeClipRect(RECTL& rRect);
virtual void SCOffsetClipRect(POINTL& rPtOffset);
virtual void SCSelectClipRgn(LPCBYTE pData, DWORD dwSize, DWORD dwMode);
// Region
virtual void SCOnSetMetaRgn();
virtual void SCFillRgn(HBRUSH hBrush, LPCBYTE pData, DWORD dwSize);
virtual void SCFrameRgn(HBRUSH hBrush, SIZEL szlStroke, LPCBYTE pData, DWORD dwSize);
virtual void SCInvertRgn(LPCBYTE pData, DWORD dwSize);
virtual void SCPaintRgn(LPCBYTE pData, DWORD dwSize);
// States and drawing modes
virtual void SCOnDCSaved();
virtual void SCOnDCRestored(INT iRelative);
virtual void SCMoveToEx(POINTL& PtDest);
virtual void SCSetMapMode(DWORD dwMode);
virtual void SCSetBkMode(DWORD dwMode);
virtual void SCSetPolyFillMode(DWORD dwMode) { m_dwFillMode = dwMode; }
virtual void SCSetStretchBltMode(DWORD dwMode) { m_dwStretchBltMode = dwMode; }
virtual void SCSetTextAlign(DWORD dwMode) { m_dwTextAlign = dwMode; }
virtual void SCSetROP2(DWORD dwMode) { m_dwROP2 = dwMode; }
//virtual void SCEnableICM(DWORD dwMode);
virtual void SCSetBkColor(COLORREF BkColor);
virtual void SCSetTextColor(COLORREF TxtColor);
virtual void SCSetColorAsjustment(CONST COLORADJUSTMENT *lpca) { ASSERT(0);} // TODO;
virtual void SCSetArcDirection(DWORD dwMode) { m_dwArcDirection = dwMode; }
virtual void SCSetMiterLimit(FLOAT fMiterLimit) { m_fMiterLimit = fMiterLimit; }
virtual void SCSetBrushOrg(POINTL& PtOrg);
// Transform
virtual void SCApplyTransform(XFORM& xform);
virtual void SCSetWorldTransform(XFORM& xform);
virtual void SCModifyWorldTransform(XFORM& xform, DWORD dwMode);
virtual void SCSetWindowOrg(INT iX, INT iY);
virtual void SCSetViewportOrg(INT iX, INT iY);
virtual void SCSetWindowExtent(INT iCx, INT iCy);
virtual void SCSetViewportExtent(INT iCx, INT iCy);
virtual void SCScaleWindow(LONG lxNum, LONG lxDenom, LONG lyNum, LONG lyDenom);
virtual void SCScaleViewport(LONG lxNum, LONG lxDenom, LONG lyNum, LONG lyDenom);
// I_RendererAttribs I_SCDCGraphics
virtual GDPGraphics* SCGetGraphics() { return m_pGraphics; }
virtual HDC SCGetDC() { return m_pGraphics->GetHDC(); }
virtual void SCReleaseDC(HDC hdc) { m_pGraphics->ReleaseHDC(hdc); }
virtual BOOL SCUsingMonochromeDC() { return m_bMonochrome; }
virtual COLORREF SCGetTextColor() { return m_TextColor; }
virtual COLORREF SCGetBkColor() { return m_BkColor; }
virtual DWORD SCGetBkMode() { return m_dwBkMode; }
virtual DWORD SCGetROP2() { return m_dwROP2; }
virtual Brush* SCGetBrush() { return m_pBrush; }
virtual COLORREF SCGetFinalColor(COLORREF crColor);
virtual void SCDrawBitmap(Bitmap* pBmp, Rect& rRcDest);
// Data
protected:
virtual BOOL SCCreateSurface(HDC hDestDC)
{
return ((m_pGraphics = new Graphics(hDestDC))!=NULL);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -