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 #ifndef INC_GRID_H
00101 #define INC_GRID_H
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118 enum GridBlobType
00119 {
00120 NoGridBlob = -1,
00121 BottomLeft,
00122 TopLeft,
00123 TopRight,
00124 BottomRight,
00125
00126 LeftMiddle,
00127 TopMiddle,
00128 RightMiddle,
00129 BottomMiddle,
00130
00131 NumGridBlobTypes
00132 };
00133
00134 struct GridFlagsType
00135 {
00136 BOOL Selected : 1;
00137 BOOL RelativeOrigin : 1;
00138 BOOL DefaultGrid : 1;
00139 BOOL Disabled : 1;
00140 };
00141
00142 enum GridType { INVALID_GRID_TYPE,RECTANGULAR,ISOMETRIC};
00143
00144 #define NUM_GRID_TYPES 2
00145
00146 class ProcessGrid;
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164 class NodeGrid: public NodeRenderablePaper
00165 {
00166 CC_DECLARE_DYNAMIC( NodeGrid )
00167
00168 public:
00169 NodeGrid();
00170
00171 virtual SubtreeRenderState RenderSubtree(RenderRegion* pRender, Node** ppNextNode = NULL, BOOL bClip = TRUE);
00172
00173 virtual String Describe(BOOL Plural, BOOL Verbose);
00174
00175 virtual void Render( RenderRegion* pRender );
00176
00177 #ifdef _DEBUG
00178 virtual void ShowDebugTreeDetails() const;
00179 #endif
00180
00181 virtual void GetDebugDetails(StringBase* Str);
00182
00183 virtual BOOL Snap(DocCoord* pDocCoord);
00184 virtual BOOL Snap(DocRect* pDocRect,const DocCoord& PrevCoord,const DocCoord& CurCoord);
00185
00186
00187 BOOL IsGridSelected() const;
00188 void SetGridSelected(BOOL selected);
00189 BOOL IsDefault() const;
00190 void SetDefault(BOOL Default);
00191 BOOL IsDisabled() const;
00192 void SetDisabled(BOOL Disabled);
00193 virtual BOOL IsRenderedAsInk() const {return TRUE;}
00194
00195 DocRect GetBoundingRect();
00196 void SetBoundingRect(const DocRect& BRect);
00197 DocRect GetBlobBoundingRect();
00198
00199 DocCoord GetBlobCoord(GridBlobType GridBlob);
00200
00201 void SetOrigin(MILLIPOINT X,MILLIPOINT Y);
00202 void GetOrigin(MILLIPOINT* pX,MILLIPOINT* pY);
00203
00204 virtual BOOL SetGridParams(double,UINT32,UnitType,BOOL Scale=TRUE) { return FALSE; }
00205
00206 virtual double CalcDivisions(BOOL Scale);
00207
00208 virtual double GetDivisions(BOOL Scale=TRUE) { return 1.0;}
00209 virtual UnitType GetUnits( BOOL Scale=TRUE) { return INCHES; }
00210 virtual UINT32 GetSubdivisions() { return 1;}
00211 virtual GridType GetGridType() { return INVALID_GRID_TYPE; }
00212 virtual double GetMainStep() { return 72000.0; }
00213
00214 static void RecalcNumSelectedGrids(Spread* pSpread);
00215 static void ProcessAllGrids(ProcessGrid* pProcessGrid);
00216 static void ProcessGridsInSpread(ProcessGrid* pProcessGrid,Spread* pSpread);
00217 static void ForceRedrawAllGrids();
00218 static void MakeDefaultGrid(Spread* pSpread, BOOL Scale=TRUE);
00219
00220
00221 static void ResetDocRectSnap();
00222
00223
00224 static UINT32 GetNumSelectedGrids();
00225 static UINT32 GetNumNonDefaultSelectedGrids();
00226 static GridType GetTypeForDefaultGrid();
00227 static BOOL GetDefaultGridDisabled();
00228 static double GetDefaultDivisions();
00229 static UINT32 GetDefaultSubdivisions();
00230 static UnitType GetDefaultUnits();
00231 static GridType GetDefaultGridType();
00232
00233 static void SetTypeForDefaultGrid(GridType GType);
00234 static void SetDefaultGridDisabled(BOOL state);
00235 static void SetDefaultDivisions(double Div);
00236 static void SetDefaultSubdivisions(UINT32 Sub);
00237 static void SetDefaultUnits(UnitType UType);
00238 static void SetDefaultGridType(GridType GType);
00239
00240 virtual void PolyCopyNodeContents(NodeRenderable* pNodeCopy);
00241
00242
00243 virtual BOOL WritePreChildrenWeb(BaseCamelotFilter* pFilter);
00244 virtual BOOL WritePreChildrenNative(BaseCamelotFilter* pFilter);
00245
00246 protected:
00247
00248 virtual BOOL WriteGridAndRulerSettings(BaseCamelotFilter* pFilter);
00249 virtual BOOL WriteGirdAndRulerOrigin(BaseCamelotFilter* pFilter);
00250
00251 protected:
00252 virtual Node* SimpleCopy();
00253 virtual UINT32 GetNodeSize() const { return sizeof(*this); }
00254 void CopyNodeContents(NodeGrid* NodeCopy);
00255 void UpdateBlobsData();
00256
00257 void CalcGridRenderSteps(MILLIPOINT PixelWidth,double* pStep,double DomStep,UnitType Units);
00258
00259 MILLIPOINT SnapOrdinate(MILLIPOINT ord,double Step,MILLIPOINT origin);
00260
00261
00262
00263 MILLIPOINT XOrigin;
00264 MILLIPOINT YOrigin;
00265
00266 DocColour GridColour;
00267 DocRect GridBoundingRect;
00268
00269 static INT32 LastXDir;
00270 static INT32 LastYDir;
00271
00272 private:
00273 GridFlagsType GridFlags;
00274 DocCoord BlobCoords[NumGridBlobTypes];
00275
00276 static UINT32 NumSelected;
00277 static UINT32 NumNonDefaultSelected;
00278
00279 static GridType TypeForDefaultGrid;
00280 static BOOL DefaultGridDisabled;
00281 static double DefaultDivisions;
00282 static UINT32 DefaultSubdivisions;
00283 static UnitType DefaultUnits;
00284 static GridType DefaultGridType;
00285
00286 protected:
00287 void DumpRect(DocRect& R,TCHAR* S);
00288 };
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306 class NodeGridRect: public NodeGrid
00307 {
00308 CC_DECLARE_DYNAMIC( NodeGridRect )
00309
00310 public:
00311 NodeGridRect();
00312
00313 String Describe(BOOL Plural, BOOL Verbose);
00314
00315 void Render( RenderRegion* pRender );
00316
00317 #ifdef _DEBUG
00318 void ShowDebugTreeDetails() const;
00319 #endif
00320
00321 void GetDebugDetails(StringBase* Str);
00322
00323
00324 BOOL Snap(DocCoord* pDocCoord);
00325 BOOL Snap(DocCoord* pDocCoord,double XStep,double YStep);
00326 BOOL Snap(DocRect* pDocRect,const DocCoord& PrevCoord,const DocCoord& CurCoord);
00327
00328
00329 BOOL SetGridParams(double Div,UINT32 SubDiv,UnitType Units, BOOL Scale=TRUE);
00330
00331 double GetDivisions(BOOL Scale=TRUE);
00332 UINT32 GetSubdivisions();
00333 UnitType GetUnits(BOOL Scale=TRUE);
00334 GridType GetGridType() { return RECTANGULAR; }
00335
00336 double GetMainStep() { return MainXStep; }
00337
00338 Node* SimpleCopy();
00339 virtual UINT32 GetNodeSize() const { return sizeof(*this); }
00340
00341 virtual void PolyCopyNodeContents(NodeRenderable* pNodeCopy);
00342
00343 protected:
00344 void CopyNodeContents(NodeGridRect* NodeCopy);
00345
00346 private:
00347
00348 void RenderMainPoints(RenderRegion* pRender,DocRect RendRect,MILLIPOINT pixelWidth);
00349 void RenderSubPoints(RenderRegion* pRender,DocRect RendRect,MILLIPOINT pixelWidth);
00350
00351
00352
00353 double MainXStep;
00354 double MainYStep;
00355 double SubXStep;
00356 double SubYStep;
00357
00358 UnitType Units;
00359 double Divisions;
00360 UINT32 Subdivisions;
00361 };
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379 class NodeGridIso: public NodeGrid
00380 {
00381 CC_DECLARE_DYNAMIC( NodeGridIso )
00382
00383 public:
00384 NodeGridIso();
00385
00386 String Describe(BOOL Plural, BOOL Verbose);
00387
00388 void Render( RenderRegion* pRender );
00389
00390 #ifdef _DEBUG
00391 void ShowDebugTreeDetails() const;
00392 #endif
00393
00394 void GetDebugDetails(StringBase* Str);
00395
00396
00397 BOOL Snap(DocCoord* pDocCoord);
00398 BOOL Snap(DocCoord* pDocCoord,double Step);
00399 BOOL Snap(DocRect* pDocRect,const DocCoord& PrevCoord,const DocCoord& CurCoord);
00400
00401 BOOL SetGridParams(double Div, UINT32 SubDiv, UnitType Units, BOOL Scale=TRUE);
00402
00403 double GetDivisions(BOOL Scale=TRUE);
00404 UINT32 GetSubdivisions();
00405 UnitType GetUnits(BOOL Scale=TRUE);
00406 GridType GetGridType() { return ISOMETRIC; }
00407
00408 double GetMainStep() { return MainStep; }
00409
00410 Node* SimpleCopy();
00411 virtual UINT32 GetNodeSize() const { return sizeof(*this); }
00412
00413 virtual void PolyCopyNodeContents(NodeRenderable* pNodeCopy);
00414
00415 protected:
00416 void CopyNodeContents(NodeGridIso* NodeCopy);
00417
00418 private:
00419
00420 void RenderPoints(RenderRegion* pRender,DocRect RendRect,MILLIPOINT pixelWidth);
00421
00422 void RenderSubPoints( RenderRegion* pRender,
00423 const DocCoord& MainGridPoint,
00424 MILLIPOINT MainRenderStep,
00425 MILLIPOINT SubRenderStep,
00426 MILLIPOINT pixelWidth,
00427 DocRect& ScaledBB);
00428
00429 MILLIPOINT CalcYOrigin(MILLIPOINT x,double Step);
00430
00431
00432
00433 double MainStep;
00434 double SubStep;
00435
00436 UnitType Units;
00437 double Divisions;
00438 UINT32 Subdivisions;
00439 };
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452 class ProcessGrid : public SimpleCCObject
00453 {
00454 public:
00455 virtual ~ProcessGrid() { }
00456 virtual void Process(NodeGrid* pGrid) = 0;
00457
00458 Document* pDoc;
00459 Chapter* pChapter;
00460 Spread* pSpread;
00461 };
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473 class ProcessGridForceRedraw : public ProcessGrid
00474 {
00475 public:
00476 void Process(NodeGrid* pGrid);
00477 };
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490 class ProcessGridUnitMsg : public ProcessGrid
00491 {
00492 public:
00493 ProcessGridUnitMsg(UnitMsg* pThisUnitMsg);
00494
00495 void Process(NodeGrid* pGrid);
00496
00497 private:
00498 UnitMsg* pUnitMsg;
00499 };
00500
00501
00502 #endif // INC_GRID_H