00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 #ifndef INC_OSRNDRGN
00105 #define INC_OSRNDRGN
00106
00107
00108
00109
00110
00111
00112 #include "gbrush.h"
00113
00114
00115
00116 class GradFillAttribute;
00117 class BitmapFillAttribute;
00118 class LinearFillAttribute;
00119 class RadialFillAttribute;
00120 class ConicalFillAttribute;
00121 class SquareFillAttribute;
00122 class ThreeColFillAttribute;
00123 class FourColFillAttribute;
00124 class KernelBitmap;
00125 class DocView;
00126 class CRgn;
00127 class CPalette;
00128
00129
00130
00131 class OSRRFontInfo
00132 {
00133 public:
00134 OSRRFontInfo();
00135
00136 public:
00137 WORD Typeface;
00138 BOOL Bold;
00139 BOOL Italic;
00140 MILLIPOINT Width;
00141 MILLIPOINT Height;
00142 ANGLE Rotation;
00143 wxFont *pRenderFont;
00144 wxFont *pOldFont;
00145 };
00146
00147
00148 class EORCacheClass
00149 {
00150 public:
00151 EORCacheClass() : Valid(FALSE) {}
00152
00153 BOOL Valid;
00154 DocColour SourceColour;
00155 COLORREF EORColour;
00156 };
00157
00158
00159
00160
00161
00162 #define SIZEOF_POLYLINE_BUFFER 8192
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177 class CCAPI OSRenderRegion : public RenderRegion
00178 {
00179 CC_DECLARE_DYNAMIC(OSRenderRegion)
00180
00181 public:
00182
00183
00184 static RenderRegion* Create(DocRect ClipRegion,
00185 Matrix ConvertMatrix,
00186 FIXED16 ViewScale,
00187 RenderType rType,
00188 View* pView = NULL,
00189 BOOL UseOSRendering = FALSE,
00190 BOOL bForce32BPP = FALSE);
00191
00192 ~OSRenderRegion();
00193 OSRenderRegion(const OSRenderRegion &other);
00194
00195 static BOOL Init();
00196 static void FlushEORCache(void);
00197
00198 virtual BOOL AttachDevice(View*, wxDC*, Spread* SpreadToAttach = NULL, bool fOwned = false );
00199 virtual BOOL InitDevice();
00200
00201
00202 BOOL StartRender();
00203 BOOL StopRender();
00204
00205
00206 virtual void SetSolidColours(BOOL SetSolid);
00207
00208
00209 void DrawPathToOutputDevice(Path* PathToDraw, PathShape shapePath=PATHSHAPE_PATH);
00210 void DrawRect(DocRect* PathToDraw);
00211 void DrawDragRect(DocRect* PathToDraw);
00212 virtual void DrawDragBounds(DocRect *RectToRender);
00213 virtual void DrawDashLine(const DocCoord &StartPoint, const DocCoord &EndPoint);
00214 void DrawLine(const DocCoord &StartPoint, const DocCoord &EndPoint);
00215 void DrawPixel(const DocCoord &Point);
00216 void DrawCross(const DocCoord &Point, const UINT32 Size);
00217 void DrawBlob(DocCoord p, BlobType type);
00218
00219 void DrawBitmap(const DocCoord &Point, KernelBitmap* pBitmap);
00220 void DrawBitmap(const DocCoord &Point, UINT32 BitmapID, UINT32 ToolID = NULL);
00221 BOOL DrawTransformedBitmap(NodeBitmap *pNodeBitmap);
00222
00223 void DrawBitmapBlob(const DocCoord &Point, KernelBitmap* BlobShape);
00224 void DrawBitmapBlob(const DocCoord &Point, ResourceID resID );
00225
00226 static wxSize GetFixedDCPPI (wxDC &dc);
00227
00228
00229
00230
00231 virtual SlowJobResult DrawMaskedBitmap(const DocRect &Rect, KernelBitmap* pBitmap,
00232 MaskedRenderRegion* pMask, ProgressDisplay *Progress);
00233 protected:
00234 virtual SlowJobResult DrawSeparatedMaskedBitmap(const DocRect &Rect, KernelBitmap* pBitmap,
00235 MaskedRenderRegion* pMask, ProgressDisplay *Progress);
00236
00237 public:
00238 void DrawFixedSystemText(StringBase *TheText, DocRect &BoundsRect, UINT32 uFormat = DEFAULT_TEXT_FORMATTING);
00239 void SetFixedSystemTextColours(DocColour *TextCol, DocColour *Background);
00240 void GetFixedSystemTextSize(StringBase *TheText, DocRect *BoundsRect, double* atDpi = NULL);
00241
00242 static void GetBlobRect( FIXED16, const DocCoord& BlobPoint, BlobType bType, DocRect *pResult );
00243
00244 BOOL RenderGradFillPath(Path *, GradFillAttribute* );
00245 BOOL RenderBitmapFill (Path *, BitmapFillAttribute* );
00246
00247 virtual BOOL RenderChar(WCHAR ch, Matrix* pMatrix);
00248
00249
00250 static WinRect DocRectToWin( View *pView, const Matrix& RenderMatrix,
00251 const DocRect& docrect,
00252 INT32 leftshift, INT32 topshift, INT32 rightshift, INT32 bottomshift,
00253 BOOL MightClip = FALSE);
00254
00255
00256
00257 static WinRect DocRectToWin( const Matrix& RenderMatrix, const DocRect& docrect,
00258 const double dpi);
00259
00260 static WinRect BitmapDocRectToWin( Matrix& RenderMatrix, const DocRect& docrect,
00261 const double dpi);
00262 static BOOL CalculateGavinOffsetsWinRect( const Matrix& RenderMatrix,
00263 const DocRect& DRect,
00264 const double dpi,
00265 GMATRIX* GMat,
00266 BOOL bCentralise,
00267 double* pdXCentralAdjust,
00268 double* pdYCentralAdjust);
00269
00270 static DocRect WinRectToDoc( const Matrix &RenderMatrix,
00271 const WinRect& WRect,
00272 const double dpi);
00273
00274 static BOOL DoBetterLines;
00275
00276 static MILLIPOINT GetHitTestRadius(DocView *pDocView);
00277
00278 BOOL StrokeProperly( Path *const );
00279
00280
00281 virtual void GetRenderRegionCaps(RRCaps* pCaps);
00282
00283 protected:
00284
00285 static INT32 HitTestRadius;
00286
00287
00288 OSRenderRegion(DocRect ClipRegion, Matrix ConvertMatrix, FIXED16 ViewScale = 1);
00289
00290
00291
00292 void InitClipping();
00293 void DeInitClipping();
00294
00295 void InitAttributes();
00296 void DeInitAttributes();
00297
00298
00299 void SetLineAttributes(ChangeLineAttrType Type = CHANGELINEATTR_ALL);
00300 void SetFillAttributes(ChangeAttrType Type = CHANGEATTR_ALL);
00301 void SetOSDrawingMode();
00302 void SetQualityLevel();
00303
00304
00305 Coord DocCoordToOS256(const DocCoord& DocPoint);
00306 WinCoord DocCoordToWin(const DocCoord& DocPoint);
00307 WinRect DocRectToWin( const DocRect& docrect, INT32 leftshift, INT32 topshift,
00308 INT32 rightshift, INT32 bottomshift, BOOL MightClip = FALSE)
00309 { return DocRectToWin(RenderView, RenderMatrix, docrect,
00310 leftshift, topshift,
00311 rightshift, bottomshift, MightClip ); }
00312
00313
00314 BOOL RenderRadialFill ( Path *PathToDraw, RadialFillAttribute *Fill );
00315 BOOL RenderLinearFill ( Path *PathToDraw, LinearFillAttribute *Fill );
00316 BOOL RenderConicalFill ( Path *PathToDraw, ConicalFillAttribute *Fill );
00317 BOOL RenderSquareFill ( Path *PathToDraw, SquareFillAttribute *Fill );
00318 BOOL RenderThreeColFill ( Path *PathToDraw, ThreeColFillAttribute *Fill );
00319 BOOL RenderFourColFill ( Path *PathToDraw, FourColFillAttribute *Fill );
00320
00321 static MILLIPOINT CalcDistance(DocCoord a, DocCoord b);
00322 static void MakeEllipticalPath(Path *pPath, DocCoord Parallel[4]);
00323
00324 #if 0
00325
00326 void DrawLineArrow(ArrowRec &ArrowToDraw, const Coord &Centre, const Coord &Direction);
00327 #endif
00328
00329
00330 void CreateNewPen();
00331 void SelectNewPen();
00332 void CreateNewBrush();
00333 void SelectNewBrush();
00334
00335 BOOL SelectNewFont(WORD Typeface, BOOL Bold, BOOL Italic,
00336 MILLIPOINT Width, MILLIPOINT Height, ANGLE Rotation);
00337
00338 void MakeDashType(DashRec&, DashType*);
00339
00340
00341 void RenderPath32( Path *DrawPath);
00342 void RenderPath( Path *DrawPath );
00343
00344
00345 BOOL RawRenderPath32( Path *const );
00346 BOOL RawRenderPath( DocCoord *const, PathVerb *const, INT32 NumCoords, INT32 *PolyCount, INT32 *Count,
00347 INT32 Flatness = 0, INT32 *pActualFlatness = NULL );
00348 BOOL SetClipToPathTemporary( Path *const);
00349
00350
00351 #define NORMALPATH(pp) pp->GetCoordArray(), pp->GetVerbArray(), pp->GetNumCoords()
00352
00353
00354 BOOL Bezier(INT32 Px0,INT32 Py0, INT32 Px1,INT32 Py1, INT32 Px2,INT32 Py2, INT32 Px3,INT32 Py3, INT32 Flatness);
00355 BOOL Split(INT32 Px0,INT32 Py0, INT32 Px1,INT32 Py1, INT32 Px2,INT32 Py2, INT32 Px3,INT32 Py3, INT32 Flatness);
00356 INT32 CalcPathFlattening();
00357
00358
00359 INT32 MPtoLP(MILLIPOINT MPtoConvert);
00360 wxColour CalcEORColour( DocColour &Wanted, COLORREF = RGB(255,255,255) );
00361 void CalcLogBrush(wxBrush*, DocColour &);
00362
00363
00364 wxPoint FindBitmapOrigin(DocCoord Centre, INT32 Width, INT32 Height);
00365
00366
00367 protected:
00368
00369 MILLIPOINT CalcScaledPixelWidth();
00370 MILLIPOINT CalcPixelWidth();
00371
00372
00373 struct
00374 {
00375 BOOL Metafile : 1;
00376
00377 BOOL ValidPen : 1;
00378 BOOL ValidBrush : 1;
00379 BOOL UsePalette : 1;
00380 } RFlags;
00381
00382
00383 wxRegion* OSClipRegion;
00384 wxPalette* OldPalette;
00385
00386 GBrush GDrawBrush;
00387
00388 protected:
00389 void GetValidPen();
00390 void GetValidBrush();
00391
00392
00393 static wxPoint PointArray[SIZEOF_POLYLINE_BUFFER];
00394
00395
00396 static EORCacheClass EORCache;
00397
00398 INT32 InsertPos;
00399
00400
00401 FIXED16 PixelScale;
00402
00403 INT32 nFillStyle ;
00404
00405
00406 INT32 CurrentPen;
00407 INT32 CurrentBrush;
00408 wxPen RenderPen[2];
00409 wxBrush RenderBrush[2];
00410
00411
00412 wxFont *OldFont;
00413
00414 OSRRFontInfo FontInfo;
00415
00416
00417 wxPoint NewBrushOrg;
00418
00419
00420 RRCaps Caps;
00421
00422 protected:
00423 BYTE *SepTables;
00424 };
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439 class PaperRenderRegion : public OSRenderRegion
00440 {
00441 CC_DECLARE_DYNAMIC(PaperRenderRegion)
00442
00443 public:
00444
00445 PaperRenderRegion(DocRect ClipRect, Matrix ConvertMatrix, FIXED16 ViewScale);
00446 ~PaperRenderRegion();
00447
00448
00449 BOOL AttachDevice(View *pView, Spread *pSpread, wxDC *pDC, Matrix& ViewMatrix,
00450 FIXED16 ViewScale, DocRect& ClipRect, bool fOwned = false );
00451 void DetachDevice();
00452
00453 virtual BOOL InitDevice();
00454 };
00455
00456 #endif