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 #include "camtypes.h"
00100
00101 #include <math.h>
00102
00103 #include "nodebev.h"
00104 #include "nbevcont.h"
00105 #include "noderect.h"
00106 #include "ppbevel.h"
00107
00108
00109
00110
00111
00112 #include "gclips.h"
00113
00114 #include "pathtrap.h"
00115
00116 #include "grndrgn.h"
00117 #include "grndbmp.h"
00118 #include "nodebmp.h"
00119
00120 #include "bmpcomp.h"
00121 #include "attrbev.h"
00122
00123
00124 #include "blobs.h"
00125
00126 #include "lineattr.h"
00127 #include "bevtool.h"
00128 #include "csrstack.h"
00129 #include "prntview.h"
00130 #include "moldtool.h"
00131 #include "opcntr.h"
00132 #include "nodecntr.h"
00133 #include "ndbldpth.h"
00134 #include "ncntrcnt.h"
00135 #include "nodetxts.h"
00136
00137 #include "extender.h"
00138 #include "swfrndr.h"
00139 #include "cmxrendr.h"
00140 #include "ai_epsrr.h"
00141 #include "rsmooth.h"
00142 #include "contmenu.h"
00143 #include "blndhelp.h"
00144 #include "offscrn.h"
00145 #include "scanrr.h"
00146 #include "opgrad.h"
00147
00148 #include "strkattr.h"
00149 #include "ngcore.h"
00150 #include "slicehelper.h"
00151 #include "brshattr.h"
00152 #include "fthrattr.h"
00153
00154 #include "pmaskrgn.h"
00155 #include "ophist.h"
00156 #include "objchge.h"
00157 #include "attrmap.h"
00158
00159 CC_IMPLEMENT_DYNCREATE(NodeBevel, NodeRenderableInk)
00160 CC_IMPLEMENT_DYNCREATE(BevelRecordHandler, CamelotRecordHandler)
00161 CC_IMPLEMENT_DYNCREATE(NodeBevelBegin, NodeRenderableBounded)
00162
00163
00164 #define new CAM_DEBUG_NEW
00165
00166
00167 #ifdef GENERATETIMINGS
00168 INT32 Timing1 = 0;
00169 #endif
00170
00171
00172
00173 const UINT32 BevelClipPathToPath_Tolerance = 30 ;
00174 const UINT32 BevelClipPathToPath_Flatness = 200 ;
00175 const UINT32 BevelStrokePathToPath_Flatness = 200 ;
00176
00177 const double BevelMaxBitmapWidth = 1600.0;
00178 const double BevelMaxBitmapHeight = 1200.0;
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222 NodeBevel::NodeBevel(Node* ContextNode,
00223 AttachNodeDirection Direction,
00224 BOOL Locked,
00225 BOOL Mangled,
00226 BOOL Marked,
00227 BOOL Selected
00228 ) : NodeRenderableInk(ContextNode, Direction, Locked, Mangled, Marked, Selected )
00229 {
00230 m_Indent = 0;
00231 m_pBevelBitmap = NULL;
00232 m_Contrast = 100;
00233 m_bLock = FALSE;
00234 m_bRenderBitmaps = TRUE;
00235 m_bZeroLineWidth = TRUE;
00236 m_LastPixelSize = 0;
00237 m_bOuter = FALSE;
00238 m_BitmapWidth = 0;
00239 m_BitmapHeight = 0;
00240 InkPath.Initialise(0,12);
00241 m_ShrunkPath.Initialise();
00242 m_bStopRender = FALSE;
00243 m_pBMPFill = NULL;
00244 m_BevelType = 0;
00245 m_LightAngle = 0;
00246 m_ViewScale = 0;
00247 m_OuterBevelPath.Initialise();
00248 m_Path.Initialise();
00249 m_pBeveler = NULL;
00250 m_Tilt = 32.0;
00251 m_bPathIsClosed = FALSE;
00252 m_bCached = FALSE;
00253 m_DoingRotation = FALSE;
00254 m_SubPixelOffset.x = 0;
00255 m_SubPixelOffset.y = 0;
00256 m_IsFlatFilledOnly = TRUE;
00257 m_HasTransparencyApplied = FALSE;
00258 m_pTranspFill = NULL;
00259 m_pCombiBitmap = NULL;
00260 m_LastZoomFactor = 1.0;
00261 m_LastCachedPrintBMPDPI = 0.0;
00262 m_IsABlendStepBevel = FALSE;
00263 m_DoRender = TRUE;
00264 m_IsAnAlphaBMP = FALSE;
00265 m_AmConvertingToShapes = FALSE;
00266 m_LastExportedDPI = 96.0;
00267 }
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280 NodeBevel::NodeBevel()
00281 {
00282 m_bStopRender = FALSE;
00283 m_Indent = 0;
00284 m_LightAngle = 300;
00285 m_bLock = FALSE;
00286 m_BevelType = 0;
00287 m_bZeroLineWidth = TRUE;
00288 m_pBevelBitmap = NULL;
00289 m_bOuter = FALSE;
00290 m_Contrast = 100;
00291 m_ShrunkPath.Initialise();
00292 m_ViewScale = 0;
00293 m_pBMPFill = NULL;
00294 m_bRenderBitmaps = TRUE;
00295 m_OuterBevelPath.Initialise();
00296 m_Path.Initialise();
00297 m_BevelType = 0;
00298 m_LightAngle = 0;
00299 m_JointType = MitreJoin;
00300 InkPath.Initialise(0,12);
00301 m_pBeveler = NULL;
00302 m_Tilt = 32.0;
00303 m_bPathIsClosed = FALSE;
00304 m_bCached = FALSE;
00305 m_DoingRotation = FALSE;
00306 m_SubPixelOffset.x = 0;
00307 m_SubPixelOffset.y = 0;
00308 m_IsFlatFilledOnly = TRUE;
00309 m_HasTransparencyApplied = FALSE;
00310 m_pTranspFill = NULL;
00311 m_pCombiBitmap = NULL;
00312 m_LastZoomFactor = 1.0;
00313 m_LastCachedPrintBMPDPI = 0.0;
00314 m_LastPixelSize = 0;
00315 m_IsABlendStepBevel = FALSE;
00316 m_DoRender = TRUE;
00317 m_IsAnAlphaBMP = FALSE;
00318 m_AmConvertingToShapes = FALSE;
00319 m_LastExportedDPI = 96.0;
00320 }
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334 NodeBevel::~NodeBevel()
00335 {
00336 if (m_pBMPFill)
00337 {
00338 delete m_pBMPFill;
00339 m_pBMPFill = NULL;
00340 }
00341
00342 if (m_pTranspFill)
00343 {
00344 delete m_pTranspFill;
00345 m_pTranspFill = NULL;
00346 }
00347
00348 if (m_pBevelBitmap)
00349 {
00350 delete m_pBevelBitmap;
00351 m_pBevelBitmap = NULL;
00352 }
00353
00354 if(m_pCombiBitmap)
00355 {
00356 delete m_pCombiBitmap;
00357 m_pCombiBitmap = NULL;
00358 }
00359
00360 DeleteCache();
00361 }
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375 String NodeBevel::Describe(BOOL Plural, BOOL Verbose)
00376 {
00377 String Name;
00378 Name.Load(_R(IDS_BEVEL_NODE_NAME));
00379
00380 return Name;
00381 };
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394 BOOL NodeBevel::GenerateBevel()
00395 {
00396 NodeBevelController* pControl = (NodeBevelController *)FindParent();
00397 if ( !pControl )
00398 return FALSE ;
00399
00400
00401 if ( pControl->GetInsideBoundingRect().IsEmpty() )
00402 return FALSE;
00403
00404 BOOL ok = TRUE;
00405
00406
00407 if (m_pBMPFill)
00408 {
00409 delete m_pBMPFill;
00410 m_pBMPFill = NULL;
00411 }
00412
00413 if (m_pTranspFill)
00414 {
00415 delete m_pTranspFill;
00416 m_pTranspFill = NULL;
00417 }
00418
00419 if (m_pCombiBitmap)
00420 {
00421 delete m_pCombiBitmap;
00422 m_pCombiBitmap = NULL;
00423 }
00424
00425
00426 m_pBMPFill = new BitmapFillAttribute;
00427 ERROR2IF(m_pBMPFill == NULL,FALSE,"Failed to create a new BMP Fill Attrib!");
00428
00429 m_pTranspFill = new BitmapTranspFillAttribute;
00430 ERROR2IF(m_pTranspFill == NULL,FALSE,"Failed to create a new TranspBMP Fill Attrib!");
00431
00432 UINT32 startTrans = 0x00;
00433 UINT32 endTrans = 0xff;
00434 m_pTranspFill->SetTranspType(TT_BEVEL);
00435 m_pTranspFill->SetStartTransp(&startTrans);
00436 m_pTranspFill->SetEndTransp(&endTrans);
00437 m_pTranspFill->SetTesselation(RT_RepeatInverted);
00438
00439 m_pBMPFill->SetTesselation(RT_RepeatInverted);
00440
00441
00442
00443
00444 if (!SetupVariables() || !CreateBevelPaths())
00445 ok = FALSE;
00446
00447 return ok;
00448 }
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463 BOOL NodeBevel::GenerateBevelForBlendStep(SumAllPathsElem* pElem, CCAttrMap * pAttrMap)
00464 {
00465
00466 if (!SetupVariables(pAttrMap))
00467 return FALSE;
00468
00469 m_ViewScale = 0;
00470
00471 BOOL bOuter = m_bOuter;
00472 INT32 Width = m_Indent;
00473
00474 m_OuterBevelPath.ClearPath();
00475 m_Path.ClearPath();
00476
00477 CProfileBiasGain Profile;
00478
00479
00480
00481
00482
00483 JointType generateJoinType=MitreJoin;
00484
00485 AttrJoinType * pJoinType = NULL;
00486 AttrJoinType * pBevelJoinType = NULL;
00487
00488 pElem->GetAttrMap ()->Lookup( CC_RUNTIME_CLASS(AttrJoinType), (void *&)pJoinType);
00489 pAttrMap->Lookup( CC_RUNTIME_CLASS(AttrJoinType), (void *&)pBevelJoinType);
00490
00491 if (pJoinType && pBevelJoinType)
00492 {
00493 if (*pJoinType == *pBevelJoinType)
00494 generateJoinType = pJoinType->Value.JoinType;
00495 else
00496 generateJoinType = pBevelJoinType->Value.JoinType;
00497 }
00498
00499
00500 ContourBecomeA MyBecomeA(BECOMEA_PASSBACK, CC_RUNTIME_CLASS(NodePath),
00501 NULL, FALSE, &m_OuterBevelPath, &m_Path, Width, 1, bOuter, Profile,generateJoinType,
00502 BevelClipPathToPath_Flatness,TRUE);
00503
00504 Path BlankPath;
00505 BlankPath.Initialise();
00506
00507 NodePath* pPathNode = new NodePath;
00508 ERRORIF(pPathNode == NULL, _R(IDE_NOMORE_MEMORY), FALSE);
00509
00510 pPathNode->InkPath.Initialise();
00511
00512 pElem->GetPath()->ClipPathToPath(BlankPath, &(pPathNode->InkPath), 6);
00513
00514 NodePath* pStrokedPathNode = pPathNode->MakeNodePathFromAttributes(30, pElem->GetAttrMap());
00515
00516 if (pStrokedPathNode)
00517 {
00518 pStrokedPathNode->DoBecomeA(&MyBecomeA);
00519 delete pStrokedPathNode;
00520 }
00521
00522 delete pPathNode;
00523 pPathNode = NULL;
00524
00525 if(m_Path.GetUsedSlots() <= 0)
00526 return TRUE;
00527 m_IsABlendStepBevel = TRUE;
00528
00529
00530 m_OuterBevelPath.IsFilled = TRUE;
00531 m_OuterBevelPath.IsStroked = FALSE;
00532
00533
00534 Path ReversedPath;
00535 ReversedPath.Initialise();
00536 ReversedPath.CloneFrom(m_Path);
00537
00538
00539 DocView* pDocView = Document::GetCurrent()->GetFirstDocView();
00540 double CurrentZoom = 1.0;
00541
00542 if(pDocView)
00543 CurrentZoom = pDocView->GetZoomFactor();
00544
00545 ReverseAndShrinkBevelPathIntoInkPath(&ReversedPath, CurrentZoom, bOuter);
00546
00547
00548 if (!CreateBevelBitmap())
00549 return FALSE;
00550
00551 m_bCached = TRUE;
00552
00553 return TRUE;
00554 }
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569 BOOL NodeBevel::CreateBevelBitmap()
00570 {
00571
00572 Node* pNode = FindParent();
00573 if (!pNode && !pNode->IsKindOf(CC_RUNTIME_CLASS(NodeBevelController)))
00574 {
00575 ERROR3("Bevel node has a parent which isn't a bevel controller node !");
00576 return FALSE;
00577 }
00578
00579 TRACEUSER( "MarkH", _T("Creating a new Bevel Bitmap!\n"));
00580
00581
00582 m_ShrunkPath.ClearPath();
00583
00584
00585 if (m_pBevelBitmap)
00586 {
00587 delete m_pBevelBitmap;
00588 m_pBevelBitmap = NULL;
00589 }
00590
00591 if (m_pBeveler)
00592 {
00593 delete m_pBeveler;
00594 m_pBeveler = NULL;
00595 }
00596
00597 if(m_pCombiBitmap)
00598 {
00599 delete m_pCombiBitmap;
00600 m_pCombiBitmap = NULL;
00601 }
00602
00603
00604 if (m_Path.GetNumCoords() == 0)
00605 return FALSE;
00606
00607
00608 m_pBeveler = new CBeveler(&m_Path);
00609 ERROR2IF(!m_pBeveler,FALSE,"Failed to create a CBeveler pointer!");
00610
00611
00612 MILLIPOINT Flatness = BEVEL_FLATNESS;
00613
00614
00615 NodeBevelController* pBevelController = (NodeBevelController *) pNode;
00616 if (pBevelController && pBevelController->IsPrinting())
00617 Flatness = (MILLIPOINT)(((double)BEVEL_FLATNESS) * (96.0 / pBevelController->GetDPI()));
00618
00619
00620 m_pBeveler->SetBevelType(m_BevelType);
00621 m_pBeveler->SetBevelAngle(m_LightAngle);
00622 m_pBeveler->SetBevelTilt(m_Tilt);
00623
00624
00625 AttrJoinType * pJoinType = NULL;
00626 FindAppliedAttribute(CC_RUNTIME_CLASS(AttrJoinType), (NodeAttribute **)(&pJoinType));
00627 JointType JT = RoundJoin;
00628 if (pJoinType)
00629 JT = pJoinType->Value.JoinType;
00630
00631
00632 double angle = 3.1415926536*m_LightAngle/180 ;
00633 NormCoord nc( cos(angle),sin(angle) );
00634
00635
00636 BOOL ok = m_pBeveler->SetUpBeveler(m_Indent, JT, &nc, m_bOuter, pBevelController->m_Contrast, NULL, BevelClipPathToPath_Flatness);
00637
00638
00639 if(!ok)
00640 return FALSE;
00641
00642
00643 CalculateBitmapSize(&m_BitmapWidth, &m_BitmapHeight);
00644
00645
00646 if (m_BitmapWidth <= 0 || m_BitmapHeight <= 0)
00647 return TRUE;
00648
00649
00650 m_pBeveler->SetBevelerSize(m_BitmapWidth,m_BitmapHeight);
00651
00652
00653 BoundingRectangle = m_PixelAllignedRect;
00654 IsBoundingRectValid = TRUE;
00655
00656 m_BMPCentre.x = m_PixelAllignedRect.lo.x;
00657 m_BMPCentre.y = m_PixelAllignedRect.lo.y;
00658 m_BMPPoint1.x = m_PixelAllignedRect.hi.x;
00659 m_BMPPoint1.y = m_PixelAllignedRect.lo.y;
00660 m_BMPPoint2.x = m_PixelAllignedRect.lo.x;
00661 m_BMPPoint2.y = m_PixelAllignedRect.hi.y;
00662
00663 NodeAttribute* pFillAttrib = NULL;
00664 DocColour FillColour = COLOUR_BLACK;
00665
00666
00667 if(FindAppliedAttribute(CC_RUNTIME_CLASS(AttrFillGeometry),&pFillAttrib))
00668 {
00669
00670 if(pFillAttrib != NULL && pFillAttrib->IsAFlatFill())
00671 {
00672 FillColour = *((AttrFlatColourFill*)pFillAttrib)->GetStartColour();
00673 m_IsFlatFilledOnly = TRUE;
00674 }
00675 else
00676 {
00677
00678 m_IsFlatFilledOnly = FALSE;
00679
00680
00681 if(pFillAttrib->IsABitmapFill())
00682 {
00683 BitmapFillAttribute* pFill = (BitmapFillAttribute*)pFillAttrib->GetAttributeValue();
00684 m_IsAnAlphaBMP = (pFill->GetBitmap()->GetBitmapInfoHeader()->biBitCount == 32);
00685 }
00686 else
00687 m_IsAnAlphaBMP = FALSE;
00688 }
00689 }
00690
00691
00692 SetUpBitmapPalette((RenderRegion *)NULL,FillColour);
00693
00694
00695 return TRUE;
00696 }
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714 BOOL NodeBevel::SetupVariables(CCAttrMap * pMap)
00715 {
00716
00717 AttrBevelIndent * pIndent = NULL;
00718 AttrBevelLightAngle * pLightAngle = NULL;
00719 AttrBevelContrast * pContrast = NULL;
00720 AttrBevelType * pType = NULL;
00721 AttrBevelLightTilt * pTilt = NULL;
00722
00723 if(pMap == NULL)
00724 {
00725 this->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrBevelIndent), (NodeAttribute **)(&pIndent));
00726 this->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrBevelLightAngle), (NodeAttribute **)(&pLightAngle));
00727 this->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrBevelContrast), (NodeAttribute **)(&pContrast));
00728 this->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrBevelType), (NodeAttribute **)(&pType));
00729 this->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrBevelLightTilt), (NodeAttribute **)(&pTilt));
00730 }
00731 else
00732 {
00733 pMap->Lookup( CC_RUNTIME_CLASS(AttrBevelIndent), (void *&)pIndent);
00734 pMap->Lookup( CC_RUNTIME_CLASS(AttrBevelLightAngle), (void *&)pLightAngle);
00735 pMap->Lookup( CC_RUNTIME_CLASS(AttrBevelContrast), (void *&)pContrast);
00736 pMap->Lookup( CC_RUNTIME_CLASS(AttrBevelType), (void *&)pType);
00737 pMap->Lookup( CC_RUNTIME_CLASS(AttrBevelLightTilt), (void *&)pTilt);
00738 }
00739
00740 NodeBevelController * pBevelController = (NodeBevelController *)FindParent();
00741 if ( !pBevelController )
00742 return FALSE ;
00743
00744
00745 if (pIndent && pLightAngle && pContrast && pType && pTilt)
00746 {
00747 if (pIndent->Value.m_Indent < 0)
00748 {
00749 pBevelController->m_Indent = -pIndent->Value.m_Indent;
00750 pBevelController->m_bOuter = TRUE;
00751 }
00752 else
00753 {
00754 pBevelController->m_Indent = pIndent->Value.m_Indent;
00755 pBevelController->m_bOuter = FALSE;
00756 }
00757
00758 m_Indent = pBevelController->m_Indent;
00759 m_bOuter = pBevelController->m_bOuter;
00760
00761 m_LightAngle = pBevelController->m_LightAngle = pLightAngle->Value.m_LightAngle;
00762 m_Contrast = pBevelController->m_Contrast = pContrast->Value.m_Contrast;
00763 m_BevelType = pBevelController->m_BevelType = pType->Value.m_Type;
00764 m_Tilt = pBevelController->m_Tilt = pTilt->Value.m_LightTilt;
00765
00766 return TRUE;
00767 }
00768
00769 return FALSE;
00770 }
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784 BOOL NodeBevel::CreateBevelPaths()
00785 {
00786
00787 DeleteCache();
00788
00789
00790 Node * pNode = FindParent();
00791 NodeBevelController * pControl = (NodeBevelController *)FindParent();
00792
00793 if (!pNode)
00794 return FALSE;
00795
00796 pNode = pNode->FindFirstChild();
00797
00798 if (!pNode || pNode == this)
00799 return FALSE;
00800
00801 double CurrentFlatness = 200.0;
00802
00803
00804
00805
00806
00807 Node* pNodeToBevel = pNode->FindNextInk();
00808
00809 while(pNodeToBevel == this && pNodeToBevel)
00810 pNodeToBevel = pNodeToBevel->FindNextInk();
00811
00812 if(pNodeToBevel)
00813 {
00814 DocRect DR = ((NodeRenderableInk*)pNodeToBevel)->GetBoundingRect();
00815
00816
00817 double Smallest = DR.Height() < DR.Width() ? (double)DR.Height() : (double)DR.Width();
00818
00819
00820 CurrentFlatness = Smallest / 375.0;
00821
00822
00823 if(1.0 > CurrentFlatness) CurrentFlatness = 1.0;
00824 if(375.0 < CurrentFlatness) CurrentFlatness = 375.0;
00825 }
00826
00827
00828 DocView* pDocView = Document::GetCurrent()->GetFirstDocView();
00829 double CurrentZoom = 1.0;
00830
00831 if(pDocView)
00832 CurrentZoom = pDocView->GetZoomFactor();
00833
00834 m_LastZoomFactor = CurrentZoom;
00835
00836 m_Path.ClearPath();
00837 InkPath.ClearPath();
00838 m_OuterBevelPath.ClearPath();
00839
00840 INT32 Width = pControl->m_Indent;
00841 BOOL bOuter = pControl->m_bOuter;
00842
00843
00844 CProfileBiasGain Profile;
00845 AttrJoinType * pJoinType = NULL;
00846 FindAppliedAttribute(CC_RUNTIME_CLASS(AttrJoinType), (NodeAttribute **)(&pJoinType));
00847
00848 JointType JT = RoundJoin;
00849 if (pJoinType)
00850 JT = pJoinType->Value.JoinType;
00851
00852
00853
00854
00855
00856
00857
00858 ContourBecomeA MyBecomeA(BECOMEA_PASSBACK, CC_RUNTIME_CLASS(NodePath),
00859 NULL, FALSE, &m_OuterBevelPath, &m_Path, Width, 1, bOuter, Profile, JT,
00860 CurrentFlatness,TRUE);
00861
00862
00863 m_bPathIsClosed = TRUE;
00864
00865 Path CopyPath; CopyPath.Initialise();
00866 Path TempPath; TempPath.Initialise();
00867
00868
00869
00870
00871
00872
00873 while (pNode)
00874 {
00875 if(pNode != this)
00876 {
00877
00878
00879 MyBecomeA.ResetCount();
00880
00881
00882 if (!pNode->IS_KIND_OF(NodeBlendPath))
00883 {
00884
00885 if (pNode->IsNodePath())
00886 {
00887
00888 if (((NodePath *)pNode)->InkPath.IsClosed())
00889 m_bPathIsClosed = FALSE;
00890
00891
00892
00893
00894
00895
00896
00897
00898 NodePath* pPathNode = ((NodePath *)pNode)->MakeNodePathFromAttributes(CurrentFlatness);
00899
00900 if (pPathNode)
00901 {
00902 pPathNode->DoBecomeA(&MyBecomeA);
00903 delete pPathNode;
00904 }
00905
00906 }
00907 else if (pNode->CanBecomeA(&MyBecomeA))
00908 {
00909
00910 if (MyBecomeA.GetCount() > 0)
00911 {
00912
00913 if (pNode->IS_KIND_OF(TextStory))
00914 {
00915
00916 ((TextStory *)pNode)->FormatAndChildren();
00917 }
00918 else
00919 {
00920
00921 Node* pLid = pNode;
00922 Node* pNext = pNode;
00923
00924 while(pNext)
00925 {
00926 pNext = SliceHelper::FindNextOfClass(pNext,pLid,CC_RUNTIME_CLASS(TextStory));
00927
00928 if(pNext)
00929 ((TextStory*)pNext)->FormatAndChildren();
00930 }
00931 }
00932
00933 if (!pNode->DoBecomeA(&MyBecomeA))
00934 break;
00935 }
00936
00937 if (MyBecomeA.GetCount() > 1)
00938 {
00939 TRACEUSER( "MarkH", _T("Clipping group to tidy things up!\n"));
00940
00941
00942 CopyPath.ClearPath();
00943 CopyPath.CloneFrom(m_Path);
00944 m_Path.ClearPath();
00945
00946 if(TempPath.ClipPathToPath(CopyPath,&m_Path,7|CLIPPING_SOURCE_WINDING,BevelClipPathToPath_Tolerance,CurrentFlatness,CurrentFlatness) < 0)
00947 {
00948 TRACEUSER( "MarkH", _T("ClipFailed!!! NodeBev.cpp\n"));
00949 }
00950 }
00951 }
00952 }
00953 }
00954
00955 pNode = pNode->FindNext();
00956 }
00957
00958
00959 m_OuterBevelPath.IsFilled = TRUE;
00960 m_OuterBevelPath.IsStroked = FALSE;
00961
00962
00963 Path ReversedPath;
00964 ReversedPath.Initialise();
00965 ReversedPath.CloneFrom(m_Path);
00966
00967 return ReverseAndShrinkBevelPathIntoInkPath(&ReversedPath, CurrentZoom, bOuter);
00968 }
00969
00970 BOOL NodeBevel::ReverseAndShrinkBevelPathIntoInkPath(Path* pBevelPath, double ZoomValue, BOOL IsAnOuter)
00971 {
00972
00973
00974
00975
00976 if(pBevelPath == NULL)
00977 return FALSE;
00978
00979 double CurrentFlatness = 200.0 * ZoomValue;
00980
00981 Path CopyPath;
00982 CopyPath.Initialise();
00983 CopyPath.CloneFrom(*pBevelPath);
00984 pBevelPath->ClearPath();
00985
00986 UINT32 Modifier = 750;
00987
00988 if(!m_bOuter)
00989 Modifier = 0;
00990
00991 if(ZoomValue < 1.0)
00992 Modifier = UINT32( double(Modifier) * ZoomValue );
00993
00994 CurrentFlatness = CopyPath.CalculateFlatnessValueFromPath(375.0);
00995 CopyPath.InitializeContourValues(Modifier,JOIN_ROUND,!IsAnOuter,CurrentFlatness);
00996
00997 if(CopyPath.GetContourForStep(pBevelPath) < 0)
00998 pBevelPath->CloneFrom(CopyPath);
00999
01000 if(pBevelPath->GetUsedSlots() > 2)
01001 pBevelPath->Reverse();
01002
01003 if (IsAnOuter)
01004 {
01005
01006
01007 InkPath.CloneFrom(m_OuterBevelPath);
01008 InkPath.MergeTwoPaths(*pBevelPath);
01009 }
01010 else
01011 {
01012
01013
01014
01015 if(m_OuterBevelPath.ClipPathToPath(
01016 *pBevelPath, &InkPath, 1 | CLIPPING_CLIP_WINDING,
01017 BevelClipPathToPath_Tolerance,
01018 CurrentFlatness,CurrentFlatness) < 0)
01019 {
01020 TRACEUSER( "MarkH", _T("ClipFailed so copying path! PATHS\n"));
01021 }
01022 }
01023
01024 InkPath.IsFilled = TRUE;
01025 InkPath.IsStroked = FALSE;
01026
01027 return TRUE;
01028 }
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040 void NodeBevel::Render(RenderRegion* pRender)
01041 {
01042
01043
01044
01045 NodeBevelController * pBevelController = (NodeBevelController *)GetParentController();
01046 DocView* pDocView = Document::GetCurrent()->GetFirstDocView();
01047
01048
01049 if(pBevelController == NULL || pRender == NULL || !m_DoRender || !pDocView)
01050 return;
01051
01052
01053 m_Indent = pBevelController->m_Indent;
01054 m_Contrast = pBevelController->m_Contrast;
01055 m_LightAngle = pBevelController->m_LightAngle;
01056 m_BevelType = pBevelController->m_BevelType;
01057 m_bOuter = pBevelController->m_bOuter;
01058
01059
01060 if (m_Indent==0)
01061 return;
01062
01063
01064
01065 if (pBevelController->IsPrinting())
01066 {
01067
01068 if (!(pRender->GetClipRect().IsIntersectedWith(BoundingRectangle)))
01069 {
01070 DeleteCachedBitmap();
01071 return ;
01072 }
01073 }
01074
01075
01076 if (m_bLock)
01077 return;
01078
01079 m_bStopRender = FALSE;
01080
01081
01082
01083 if (pBevelController->GetInsideBoundingRect().IsEmpty() || InkPath.GetNumCoords() == 0)
01084 {
01085 m_bStopRender = TRUE;
01086 return;
01087 }
01088
01089 BOOL DoReRender = FALSE;
01090
01091 double CurrentZoom = pDocView->GetZoomFactor();
01092
01093 if(m_LastZoomFactor != CurrentZoom)
01094 {
01095 if(m_pCombiBitmap != NULL)
01096 {
01097 delete m_pCombiBitmap;
01098 m_pCombiBitmap = NULL;
01099 }
01100
01101 Path ReversedPath;
01102 ReversedPath.Initialise();
01103 ReversedPath.CloneFrom(m_Path);
01104
01105 if(!ReverseAndShrinkBevelPathIntoInkPath(&ReversedPath, CurrentZoom, m_bOuter))
01106 {
01107 m_bStopRender = TRUE;
01108 return;
01109 }
01110
01111 m_LastZoomFactor = CurrentZoom;
01112 }
01113
01114 pRender->SaveContext();
01115
01116 NodeAttribute* pFillAttrib = NULL;
01117 DocColour FillColour = COLOUR_BLACK;
01118
01119
01120 BOOL LastFillWasFlat = m_IsFlatFilledOnly;
01121
01122
01123 if(FindAppliedAttribute(CC_RUNTIME_CLASS(AttrFillGeometry),&pFillAttrib))
01124 {
01125
01126 if(pFillAttrib != NULL && pFillAttrib->IsAFlatFill())
01127 {
01128 FillColour = *((AttrFlatColourFill*)pFillAttrib)->GetStartColour();
01129 m_IsFlatFilledOnly = (FillColour != COLOUR_NONE);
01130 }
01131 else
01132 {
01133
01134 m_IsFlatFilledOnly = FALSE;
01135 if(pFillAttrib && m_pBMPFill)
01136 m_pBMPFill->SetTesselation(((ColourFillAttribute*)pFillAttrib->GetAttributeValue())->GetTesselation());
01137 }
01138 }
01139
01140
01141 if(FindAppliedAttribute(CC_RUNTIME_CLASS(AttrTranspFillGeometry),&pFillAttrib))
01142 {
01143 if(pFillAttrib != NULL && pFillAttrib->IsATranspFill())
01144 {
01145
01146
01147 if(pFillAttrib->IsAFlatFill())
01148 {
01149
01150 m_HasTransparencyApplied = *((AttrFlatTranspFill*)pFillAttrib)->GetStartTransp() > 0;
01151 }
01152 else
01153 m_HasTransparencyApplied = TRUE;
01154
01155 if (m_HasTransparencyApplied && pFillAttrib!=NULL && m_pTranspFill!=NULL)
01156 m_pTranspFill->SetTesselation(((ColourFillAttribute*)pFillAttrib->GetAttributeValue())->GetTesselation());
01157 }
01158 else
01159 {
01160
01161 m_HasTransparencyApplied = FALSE;
01162 }
01163 }
01164
01165
01166
01167 if((!m_DoingRotation && !pRender->IsHitDetect() && pRender->RRQuality.GetQuality() > 10 && !pRender->IsKindOf(CC_RUNTIME_CLASS(ScanningRenderRegion)))
01168 || !m_pBevelBitmap)
01169 {
01170
01171
01172 DoReRender |= (m_IsFlatFilledOnly && !LastFillWasFlat && m_HasTransparencyApplied);
01173
01174 if(pRender->IsPrinting())
01175 {
01176
01177 if(!pRender->IsKindOf(CC_RUNTIME_CLASS(ScanningRenderRegion)) && pRender->RRQuality.GetQuality() > 100)
01178 {
01179 if(m_LastCachedPrintBMPDPI == 0.0)
01180 {
01181
01182 m_LastCachedPrintBMPDPI = pBevelController->GetDPI();
01183 DoReRender = TRUE;
01184 }
01185 }
01186 }
01187 else
01188 m_LastCachedPrintBMPDPI = 0.0;
01189
01190 if(m_pBevelBitmap == NULL)
01191 DoReRender = TRUE;
01192
01193
01194 if(((MILLIPOINT)m_LastPixelSize != pRender->GetScaledPixelWidth() && !pBevelController->IsPrinting()) || DoReRender)
01195 {
01196 if(pRender->GetScaledPixelWidth() > 2)
01197 {
01198 m_LastPixelSize = pRender->GetScaledPixelWidth();
01199 if (!RenderBitmapForDisplay(pRender))
01200 {
01201 m_bStopRender = TRUE;
01202 pRender->RestoreContext();
01203 return;
01204 }
01205 }
01206 else if(pRender->IsKindOf(CC_RUNTIME_CLASS(FlashRenderRegion)))
01207 {
01208 INT32 NewDPI = 96;
01209 Camelot.GetPrefValue(TEXT("Displays"),TEXT("CompCToEDPI"),&NewDPI);
01210 pBevelController->SetDPI(NewDPI);
01211
01212 BOOL OldFlag = m_AmConvertingToShapes;
01213 m_AmConvertingToShapes = TRUE;
01214 CreateBevelBitmap();
01215 RenderBitmapForDisplay(pRender);
01216 m_AmConvertingToShapes = OldFlag;
01217 }
01218 }
01219
01220
01221 SetUpBitmapPalette((RenderRegion *)NULL,FillColour);
01222 }
01223
01224
01225
01226 if (m_BitmapWidth > 0 && m_BitmapHeight > 0)
01227 {
01228
01229 if(!pRender->IsHitDetect() && pRender->RRQuality.GetQuality() > 30)
01230 {
01231 RenderBitmap(pRender);
01232 }
01233 else
01234 {
01235
01236
01237
01238
01239 pRender->EnableAllBrushPathProcessors(FALSE);
01240
01241 pRender->SetLineColour(COLOUR_BLACK);
01242 pRender->SetFillColour(FillColour);
01243 pRender->SetLineWidth(50);
01244
01245 InkPath.IsStroked = TRUE;
01246 pRender->DrawPath(&InkPath);
01247 InkPath.IsStroked = FALSE;
01248
01249
01250 pRender->EnableAllBrushPathProcessors(TRUE);
01251 }
01252 }
01253
01254 m_bStopRender = TRUE;
01255
01256
01257 m_bLock = FALSE;
01258
01259 pRender->RestoreContext();
01260
01261
01262 }
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275 BOOL NodeBevel::RenderBitmapForDisplay(RenderRegion * pRegion)
01276 {
01277 TRACEUSER( "Gerry", _T("NodeBevel::RenderBitmapForDisplay\n"));
01278
01279
01280 NodeBevelController * pControl = (NodeBevelController *)GetParentController();
01281
01282
01283 if (pControl == NULL)
01284 return FALSE;
01285
01286
01287
01288
01289 if (m_pBeveler != NULL)
01290 {
01291 if (m_BitmapHeight < 1 || m_BitmapWidth < 1)
01292 {
01293 delete m_pBeveler;
01294 m_pBeveler = NULL;
01295 }
01296 }
01297
01298 if (m_pBeveler == NULL)
01299 {
01300 if (!CreateBevelBitmap())
01301 return(FALSE);
01302 }
01303
01304 if (m_pBevelBitmap)
01305 {
01306 delete m_pBevelBitmap;
01307 m_pBevelBitmap = NULL;
01308 }
01309
01310
01311 if(pRegion)
01312 m_LastPixelSize = pRegion->GetScaledPixelWidth();
01313
01314 if (pRegion && pRegion->IS_KIND_OF(PrintingMaskedRenderRegion))
01315 CalculateBitmapSize(&m_BitmapWidth, &m_BitmapHeight, pRegion);
01316 else
01317 CalculateBitmapSize(&m_BitmapWidth, &m_BitmapHeight, NULL);
01318
01319
01320 INT32 Width = m_BitmapWidth;
01321 INT32 Height = m_BitmapHeight;
01322
01323 if (Width == 0 || Height == 0)
01324 return FALSE;
01325
01326
01327
01328
01329 m_pBevelBitmap = new KernelBitmap(Width, Height, 8, 96, TRUE);
01330 ERROR2IF(m_pBevelBitmap == NULL,FALSE,"Failed to create a new bevel bitmap!");
01331
01332
01333 m_pBeveler->RenderToBitmap(m_pBevelBitmap, TRUE, &m_SubPixelOffset);
01334
01335
01336
01337 if (m_pCombiBitmap)
01338 {
01339 delete m_pCombiBitmap;
01340 m_pCombiBitmap = NULL;
01341 }
01342
01343
01344 m_pBMPFill->BitmapRef.SetBitmap(m_pBevelBitmap);
01345 m_pTranspFill->BitmapRef.SetBitmap(m_pBevelBitmap);
01346
01347 return TRUE;
01348 }
01349
01350
01351
01352
01353
01354
01355
01356
01357
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367
01368
01369
01370
01371
01372
01373
01374
01375
01376
01377
01378
01379
01380
01381
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391
01392
01393
01394
01395
01396
01397
01398
01399
01400
01401
01402
01403
01404
01405
01406
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419
01420 void NodeBevel::RenderBitmap(RenderRegion* pRender)
01421 {
01422
01423
01424
01425 if(!pRender)
01426 return;
01427
01428
01429
01430
01431
01432 if(pRender->IsKindOf(CC_RUNTIME_CLASS(ScanningRenderRegion)))
01433 {
01434
01435
01436 ScanningRenderRegion* pScanner = (ScanningRenderRegion*)pRender;
01437
01438 pScanner->ComplexShapeFoundWrapper();
01439 return;
01440 }
01441
01442
01443 if(!m_pBevelBitmap)
01444 return;
01445
01446
01447 pRender->SaveContext();
01448
01449
01450 NodeBevelController* pControl = (NodeBevelController *)GetParentController();
01451
01452 FillMappingAttribute FillMapAttrib;
01453 TranspFillMappingAttribute TranspFillMapAttrib;
01454
01455
01456 if (pControl == NULL)
01457 {
01458 pRender->RestoreContext();
01459 return;
01460 }
01461
01462
01463
01464
01465 double PixelWidth = pRender->GetScaledPixelWidth();
01466
01467
01468 View* pView = View::GetCurrent();
01469
01470
01471 if (pView)
01472 {
01473
01474
01475 if (m_ViewScale != PixelWidth || m_ShrunkPath.GetNumCoords() == 0 || pControl->IsPrinting())
01476 {
01477
01478 if (m_bZeroLineWidth)
01479 pRender->SetLineWidth(50);
01480
01481
01482 m_ViewScale = (UINT32)PixelWidth;
01483 }
01484 }
01485
01486
01487 if (!m_bOuter)
01488 {
01489
01490
01491 }
01492
01493
01494
01495 if (m_bZeroLineWidth)
01496 {
01497 pRender->SetLineColour(COLOUR_NONE);
01498 pRender->SetLineWidth(50);
01499 }
01500
01501 if(m_IsFlatFilledOnly)
01502 {
01503
01504
01505
01506 FillMapAttrib.Repeat = 0;
01507 FillMapAttrib.Render(pRender);
01508
01509 if (m_pBMPFill)
01510 {
01511
01512 m_pBMPFill->SetStartPoint(&m_BMPCentre);
01513 m_pBMPFill->SetEndPoint (&m_BMPPoint1);
01514 m_pBMPFill->SetEndPoint2 (&m_BMPPoint2);
01515 m_pBMPFill->Render(pRender);
01516 }
01517 else
01518 {
01519 pRender->RestoreContext();
01520 ERROR1RAW(_R(IDE_NOMORE_MEMORY));
01521 }
01522 }
01523 else if(!m_IsFlatFilledOnly && !m_HasTransparencyApplied)
01524 {
01525
01526
01527 if (m_pTranspFill)
01528 {
01529 TranspFillMapAttrib.Repeat = 0;
01530 TranspFillMapAttrib.Render(pRender);
01531
01532
01533 m_pTranspFill->SetStartPoint(&m_BMPCentre);
01534 m_pTranspFill->SetEndPoint (&m_BMPPoint1);
01535 m_pTranspFill->SetEndPoint2 (&m_BMPPoint2);
01536 m_pTranspFill->Render(pRender);
01537 }
01538 else
01539 {
01540 pRender->RestoreContext();
01541 ERROR1RAW(_R(IDE_NOMORE_MEMORY));
01542 }
01543 }
01544 else if(!m_IsFlatFilledOnly && m_HasTransparencyApplied)
01545 {
01546
01547
01548
01549
01550
01551
01552
01553 if(m_pBMPFill)
01554 {
01555 if(!pRender->IsKindOf(CC_RUNTIME_CLASS(ScanningRenderRegion)))
01556 {
01557 if(!m_pCombiBitmap)
01558 {
01559
01560
01561
01562
01563
01564
01565 m_pCombiBitmap = CreateCombinedBMPAndTranspFill(pRender);
01566 }
01567
01568 if(m_pCombiBitmap == NULL)
01569 {
01570 ERROR3("Failed to create a new BitmapTransparency Bitmap!");
01571 pRender->RestoreContext();
01572 return;
01573 }
01574
01575
01576 m_pBMPFill->BitmapRef.SetBitmap(m_pCombiBitmap);
01577
01578 m_pBMPFill->SetStartPoint(&m_BMPCentre);
01579 m_pBMPFill->SetEndPoint (&m_BMPPoint1);
01580 m_pBMPFill->SetEndPoint2 (&m_BMPPoint2);
01581 m_pBMPFill->Render(pRender);
01582 }
01583 else
01584 {
01585
01586 }
01587
01588 FillMapAttrib.Repeat = 0;
01589 FillMapAttrib.Render(pRender);
01590 }
01591 else
01592 {
01593
01594 pRender->RestoreContext();
01595 ERROR1RAW(_R(IDE_NOMORE_MEMORY));
01596 }
01597 }
01598
01599
01600 if(InkPath.GetNumCoords() > 2)
01601 pRender->DrawPath(&InkPath);
01602
01603 pRender->RestoreContext();
01604
01605 }
01606
01607
01608
01609
01610
01611
01612
01613
01614
01615
01616
01617
01618 KernelBitmap* NodeBevel::CreateCombinedBMPAndTranspFill(RenderRegion* pRegion)
01619 {
01620
01621 View* pView = View::GetCurrent();
01622
01623
01624 if(pRegion == NULL || pView == NULL)
01625 return NULL;
01626
01627
01628
01629 KernelBitmap* pNewBMP = NULL;
01630
01631
01632 double GScale = 1.0;
01633 double SPW = pRegion->GetScaledPixelWidth();
01634
01635
01636
01637
01638
01639
01640
01641 if(SPW <= 0.0 || SPW > 3750.0)
01642 SPW = 3750.0;
01643
01644
01645
01646 DocRect RRect(m_BMPPoint2.x,m_BMPPoint1.y,m_BMPPoint1.x,m_BMPPoint2.y);
01647
01648
01649 double ScaledWidth = (double)RRect.Width() / SPW;
01650 double ScaledHeight = (double)RRect.Height() / SPW;
01651
01652
01653
01654
01655 if((ScaledWidth > BevelMaxBitmapWidth) || (ScaledHeight > BevelMaxBitmapHeight))
01656 {
01657
01658 if((BevelMaxBitmapWidth / ScaledWidth) >= (BevelMaxBitmapHeight / ScaledHeight))
01659 {
01660
01661 SPW = 750.0 / (BevelMaxBitmapWidth / ScaledWidth);
01662 GScale = BevelMaxBitmapWidth / ScaledWidth;
01663 }
01664 else
01665 {
01666
01667 SPW = 750.0 / (BevelMaxBitmapHeight / ScaledHeight);
01668 GScale = BevelMaxBitmapHeight / ScaledHeight;
01669 }
01670
01671
01672 }
01673
01674
01675
01676
01677 #if FALSE
01678
01679 NodeBevelController * pControl = (NodeBevelController *)FindParent();
01680 if(pControl && pRegion->IsPrinting())
01681 {
01682 GScale = 96;
01683
01684 Document* pDoc = pView->GetDoc();
01685
01686 PrintComponent *pPrintComponent = (PrintComponent *)pDoc->GetDocComponent(CC_RUNTIME_CLASS(PrintComponent));
01687 if(pPrintComponent)
01688 {
01689 PrintControl *pPrintControl = pPrintComponent->GetPrintControl();
01690 if(pPrintControl)
01691 GScale = 1.0 * pPrintControl->GetDotsPerInch() / 96.0;
01692 }
01693 }
01694 else
01695 {
01696 GScale = 750.0 / SPW;
01697
01698 if(GScale > 1.0)
01699 GScale = 1.0;
01700 }
01701 #endif
01702
01703
01704
01705
01706 Path InflatePath;
01707 InflatePath.Initialise();
01708 InflatePath.CreatePathFromDocRect(&RRect);
01709
01710
01711 NodeAttribute * pFillAttr = NULL;
01712 FindAppliedAttribute(CC_RUNTIME_CLASS(AttrFillGeometry),&pFillAttr);
01713
01714
01715 NodeAttribute * pFillMapAttr = NULL;
01716 FindAppliedAttribute(CC_RUNTIME_CLASS(AttrFillMapping),&pFillMapAttr);
01717
01718 BOOL bOldForce = pView->SetForceDefaultColourContexts();
01719
01720
01721 ConcurrentRenderer* pGOffScreen = new ConcurrentRenderer;
01722 if (pGOffScreen == NULL)
01723 {
01724 pView->SetForceDefaultColourContexts(bOldForce);
01725 ERROR2(NULL, "Failed to create a new Borrower Class!");
01726 }
01727
01728
01729
01730 if (pGOffScreen->Initialise((GRenderRegion*)pRegion, GScale, RRect, 32, TRUE))
01731 {
01732 GRenderRegion* pGBMP = pGOffScreen->GetRenderRegion();
01733
01734
01735 if(pGBMP)
01736 {
01737 pGBMP->GetDrawContext()->SetAntialiasFlag(0);
01738
01739
01740 if(pFillAttr)
01741 pFillAttr->Render(pGBMP);
01742
01743 if(pFillMapAttr)
01744 pFillMapAttr->Render(pGBMP);
01745
01746 pGBMP->SetLineColour(COLOUR_NONE);
01747 pGBMP->SetLineWidth(50);
01748
01749 if (m_pTranspFill)
01750 {
01751 TRACEUSER( "MarkH", _T("Rendering Transparent Fill!\n"));
01752 m_pTranspFill->SetStartPoint(&m_BMPCentre);
01753 m_pTranspFill->SetEndPoint (&m_BMPPoint1);
01754 m_pTranspFill->SetEndPoint2 (&m_BMPPoint2);
01755 m_pTranspFill->Render(pGBMP);
01756 }
01757
01758
01759 pGBMP->DrawPath(&InflatePath);
01760
01761
01762 pNewBMP = pGOffScreen->GetKernelBitmap();
01763
01764
01765 }
01766 else
01767 {
01768 ERROR3("Failed to create a new GRenderBitmap!");
01769 }
01770
01771
01772 pGOffScreen->RestorePreviousRendererState();
01773 }
01774 else
01775 {
01776
01777
01778 delete pGOffScreen;
01779 pNewBMP = NULL;
01780 }
01781
01782 pView->SetForceDefaultColourContexts(bOldForce);
01783
01784
01785 return pNewBMP;
01786 }
01787
01788
01789
01790
01791
01792
01793
01794
01795
01796
01797
01798 void NodeBevel::CalculateBitmapSize(INT32 * retnWid, INT32 * retnHei, RenderRegion * pRegion)
01799 {
01800
01801 NodeBevelController * pControl = (NodeBevelController *)FindParent();
01802
01803
01804 if(!retnWid || !retnHei || !pControl)
01805 return;
01806
01807
01808 DocRect dr(0,0,0,0);
01809
01810
01811 if(m_bOuter)
01812 {
01813 if(m_pBeveler)
01814 dr = m_pBeveler->GetSelectionRect();
01815 else
01816 {
01817 InkPath.GetTrueBoundingRect(&dr);
01818 dr.Inflate(m_Indent);
01819 }
01820 }
01821 else
01822 {
01823
01824 m_Path.GetTrueBoundingRect(&dr);
01825 }
01826
01827
01828 if (dr.IsEmpty())
01829 {
01830 *retnWid = 0;
01831 *retnHei = 0;
01832 return;
01833 }
01834
01835 MILLIPOINT PixSize = 750;
01836
01837 if(pRegion)
01838 PixSize = pRegion->GetScaledPixelWidth();
01839
01840 if(Document::GetCurrent() && Document::GetCurrent()->GetFirstDocView()
01841 && !(pRegion && pRegion->IS_KIND_OF(PrintingMaskedRenderRegion))
01842 )
01843 PixSize = (MILLIPOINT)((double)PixSize / (Document::GetCurrent()->GetFirstDocView())->GetViewScale().MakeDouble());
01844
01845 if(PixSize == 0)
01846 PixSize = 1;
01847
01848 m_PixelAllignedRect = dr;
01849 double lWidth = dr.Width() / PixSize;
01850 double lHeight = dr.Height() / PixSize;
01851
01852
01853 if ((!pControl->IsPrinting() && !m_AmConvertingToShapes) ||
01854 (pRegion && pRegion->IS_KIND_OF(PrintingMaskedRenderRegion)))
01855 {
01856
01857 if (pRegion && PixSize > 0 )
01858 {
01859 lWidth = (lWidth * 750) / PixSize;
01860 lHeight = (lHeight * 750) / PixSize;
01861 }
01862
01863
01864 while ( lWidth > BevelMaxBitmapWidth || lHeight > BevelMaxBitmapHeight )
01865 {
01866
01867 lWidth *= 0.5;
01868 lHeight *= 0.5;
01869 }
01870 }
01871 else
01872 {
01873 double DPI = pControl->GetDPI();
01874 lWidth = dr.Width () * DPI / 72000 ;
01875 lHeight = dr.Height() * DPI / 72000 ;
01876 }
01877
01878
01879 *retnWid = (INT32)ceil(lWidth);
01880 *retnHei = (INT32)ceil(lHeight);
01881 }
01882
01883
01884
01885
01886
01887
01888
01889
01890
01891
01892
01893 void NodeBevel::SetUpBitmapPalette(RenderRegion * pRegion, DocColour FlatColour)
01894 {
01895
01896 if (!m_pBevelBitmap)
01897 return;
01898
01899
01900 if (m_pBevelBitmap->GetBPP() != 8)
01901 return;
01902
01903
01904 LPRGBQUAD pPalette = m_pBevelBitmap->GetPaletteForBitmap();
01905 INT32 Red = 0;
01906 INT32 Green = 0;
01907 INT32 Blue = 0;
01908
01909
01910 NodeBevelController* pControl = (NodeBevelController *)FindParent();
01911 ERROR3IF(pControl == NULL, "No parent");
01912
01913
01914 double Contrast = pControl->m_Contrast;
01915
01916
01917 if ( pRegion )
01918 {
01919
01920 BevelAttributeValueContrast *pVal = (BevelAttributeValueContrast *)pRegion->GetCurrentAttribute(ATTR_BEVELCONTRAST);
01921 if (!pVal)
01922 return;
01923 Contrast = pVal->m_Contrast;
01924 }
01925
01926 GDrawContext* pGD = GRenderRegion::GetStaticDrawContext();
01927 pGD->SetBevelLightness(UINT32( Contrast*2.5599900)) ;
01928 pGD->SetBevelDarkness (UINT32(Contrast*Contrast*0.0255999)) ;
01929
01930
01931 FlatColour.GetRGBValue(&Red,&Green,&Blue);
01932
01933
01934
01935 for ( INT32 i=0 ; i<256 ; i++ )
01936 {
01937 if(!m_IsFlatFilledOnly)
01938 {
01939
01940 pPalette[i].rgbRed =
01941 pPalette[i].rgbBlue =
01942 pPalette[i].rgbGreen = i ;
01943 }
01944 else
01945 {
01946
01947 pPalette[i].rgbRed = pGD->TranslateBevelValue(i,Red ) ;
01948 pPalette[i].rgbGreen = pGD->TranslateBevelValue(i,Green) ;
01949 pPalette[i].rgbBlue = pGD->TranslateBevelValue(i,Blue ) ;
01950 }
01951 pPalette[i].rgbReserved = 0 ;
01952 }
01953 }
01954
01955
01956
01957
01958
01959
01960
01961
01962
01963
01964
01965
01966
01967
01968 KernelBitmap* NodeBevel::CreateBitmapCopy(double DPI, BOOL CheckFillFlags)
01969 {
01970 m_AmConvertingToShapes = TRUE;
01971
01972 NodeBevelController* pControl = (NodeBevelController *)FindParent();
01973
01974 INT32 NewDPI = 96;
01975 if(pControl && DPI == -1.0)
01976 {
01977 View* pView = View::GetCurrent();
01978 if (pView)
01979 NewDPI = (INT32)pView->GetConvertToEditableShapesDPI();
01980 }
01981 else
01982 NewDPI = (INT32)DPI;
01983
01984 if(pControl)
01985 pControl->SetDPI(NewDPI);
01986
01987
01988
01989 ERROR2IF(!RenderBitmapForDisplay(NULL),FALSE,"Failed to create the bevel bitmap!");
01990
01991 NodeAttribute* pFillAttrib = NULL;
01992 NodeAttribute* pFillMapAttr = NULL;
01993 NodeAttribute* pFillTranspMapAttr = NULL;
01994 NodeAttribute* pFillEffectAttr = NULL;
01995 DocColour FillColour = COLOUR_BLACK;
01996
01997
01998 FindAppliedAttribute(CC_RUNTIME_CLASS(AttrFillMapping),&pFillMapAttr);
01999 FindAppliedAttribute(CC_RUNTIME_CLASS(AttrTranspFillMapping),&pFillTranspMapAttr);
02000 FindAppliedAttribute(CC_RUNTIME_CLASS(AttrFillEffect),&pFillEffectAttr);
02001
02002
02003 if(FindAppliedAttribute(CC_RUNTIME_CLASS(AttrFillGeometry),&pFillAttrib))
02004 {
02005
02006 if(pFillAttrib != NULL && pFillAttrib->IsAFlatFill())
02007 FillColour = *((AttrFlatColourFill*)pFillAttrib)->GetStartColour();
02008 }
02009
02010
02011 SetUpBitmapPalette((RenderRegion *)NULL,FillColour);
02012
02013 KernelBitmap* pConvertedBMP = NULL;
02014
02015
02016
02017 if(!m_IsFlatFilledOnly && (m_HasTransparencyApplied || !CheckFillFlags))
02018 {
02019
02020 View* pView = View::GetCurrent();
02021 Matrix Mat(1,0,0,1,0,0);
02022 FIXED16 Scale = 1;
02023 DocRect RenderRect(m_BMPPoint2.x,m_BMPPoint1.y,m_BMPPoint1.x,m_BMPPoint2.y);
02024 Path InflatePath;
02025 InflatePath.Initialise();
02026 InflatePath.CreatePathFromDocRect(&RenderRect);
02027
02028
02029 ERROR2IF(RenderRect.IsEmpty(),NULL,"We`ve got an empty DocRect in the selection! (CBMPBits)");
02030
02031
02032 GRenderBitmap* pGBMP = new GRenderBitmap(RenderRect, Mat, Scale, 32, NewDPI, FALSE, 0, NULL, TRUE);
02033
02034 if(pGBMP)
02035 {
02036 pGBMP->m_DoCompression = TRUE;
02037
02038 if(!pGBMP->AttachDevice(pView, NULL, NULL))
02039 {
02040 delete pGBMP;
02041 pGBMP = NULL;
02042 }
02043 else
02044 {
02045
02046 NodeAttribute * pFillAttr = NULL;
02047 FindAppliedAttribute(CC_RUNTIME_CLASS(AttrFillGeometry),&pFillAttr);
02048
02049 pGBMP->InitDevice();
02050 pGBMP->InitAttributes();
02051 pGBMP->RRQuality.SetQuality(QUALITY_MAX);
02052 pGBMP->SetQualityLevel();
02053 pGBMP->SetLineAttributes();
02054 pGBMP->SetFillAttributes();
02055
02056 pGBMP->StartRender();
02057
02058 pGBMP->GetDrawContext()->SetAntialiasFlag(0);
02059
02060
02061 if(pFillAttr)
02062 pFillAttr->Render(pGBMP);
02063
02064 if(pFillMapAttr)
02065 pFillMapAttr->Render(pGBMP);
02066
02067 if(pFillEffectAttr)
02068 pFillEffectAttr->Render(pGBMP);
02069
02070 pGBMP->SetLineColour(COLOUR_NONE);
02071 pGBMP->SetLineWidth(50);
02072
02073 if (m_pTranspFill)
02074 {
02075 TRACEUSER( "MarkH", _T("Rendering Transparent Fill!\n"));
02076 m_pTranspFill->SetStartPoint(&m_BMPCentre);
02077 m_pTranspFill->SetEndPoint (&m_BMPPoint1);
02078 m_pTranspFill->SetEndPoint2 (&m_BMPPoint2);
02079 m_pTranspFill->Render(pGBMP);
02080 }
02081
02082
02083 pGBMP->DrawPath(&InflatePath);
02084
02085 pGBMP->StopRender();
02086
02087 pConvertedBMP = new KernelBitmap(pGBMP->ExtractBitmapCopy());
02088 delete pGBMP;
02089 pGBMP = NULL;
02090 }
02091 }
02092 }
02093 else
02094 {
02095
02096 pConvertedBMP = new KernelBitmap(m_pBevelBitmap->ActualBitmap->MakeCopy());
02097 }
02098
02099 return pConvertedBMP;
02100 }
02101
02102
02103
02104
02105
02106
02107
02108
02109
02110
02111
02112
02113 BOOL NodeBevel::DoBecomeA(BecomeA* pBecomeA)
02114 {
02115
02116 ERROR2IF_PF(pBecomeA == NULL,FALSE,("pBecomeA is NULL"));
02117
02118 if (!pBecomeA->BAPath())
02119 return FALSE;
02120
02121
02122
02123 BOOL ValidReason = (pBecomeA->GetReason() == BECOMEA_REPLACE || pBecomeA->GetReason() == BECOMEA_PASSBACK);
02124 ERROR2IF_PF(!ValidReason,FALSE,("Unkown BecomeA reason %d",pBecomeA->GetReason()));
02125
02126 NodePath * pNewNodePath = NULL;
02127 Node * pBevelStartNode = NULL;
02128 NodeRenderableInk * pParent = NULL;
02129 NodeHidden * pHiddenNode = NULL;
02130 NodeAttribute * pAttr = NULL;
02131
02132
02133
02134
02135 AttrStrokeColour * pStrokeColour = NULL;
02136 AttrLineWidth * pLineWidth = NULL;
02137
02138 NodeAttribute* pFillMapAttr = NULL;
02139 NodeAttribute* pFillTranspMapAttr = NULL;
02140 NodeAttribute* pFillEffectAttr = NULL;
02141
02142
02143
02144
02145 DocColour dcNone(COLOUR_NONE);
02146
02147 switch (pBecomeA->GetReason())
02148 {
02149 case BECOMEA_REPLACE:
02150 {
02151
02152
02153
02154
02155
02156
02157
02158
02159
02160
02161
02162
02163
02164
02165
02166
02167
02168
02169
02170
02171
02172
02173
02174
02175
02176
02177
02178
02179
02180
02181
02182
02183 UndoableOperation* pOp = pBecomeA->GetUndoOp();
02184 ALLOC_WITH_FAIL(pNewNodePath, new NodePath, pOp);
02185
02186
02187
02188
02189
02190
02191
02192
02193
02194
02195
02196
02197
02198
02199
02200
02201
02202
02203
02204
02205
02206
02207
02208
02209
02210
02211
02212
02213
02214
02215
02216
02217
02218
02219
02220
02221
02222
02223
02224
02225
02226
02227
02228
02229
02230
02231
02232
02233
02234
02235
02236
02237
02238
02239
02240
02241
02242
02243
02244
02245
02246
02247
02248
02249
02250
02251
02252
02253
02254
02255
02256
02257
02258
02259
02260
02261
02262
02263
02264
02265
02266
02267
02268
02269
02270
02271
02272
02273
02274
02275
02276
02277
02278
02279
02280
02281
02282
02283
02284
02285
02286
02287
02288
02289
02290
02291
02292 BOOL bCreateNew = (m_Path.GetNumCoords() != 0);
02293
02294 KernelBitmap* pConvertedBMP = NULL;
02295
02296 if (bCreateNew)
02297 {
02298 pConvertedBMP = CreateBitmapCopy();
02299
02300 if(!pConvertedBMP)
02301 {
02302 ERROR3("Failed To Create Bevel Bitmap Copy!");
02303 return FALSE;
02304 }
02305 else
02306 {
02307 NodeCompound* pControl = GetParentController();
02308 if (pControl != NULL)
02309 {
02310 LPBITMAPINFOHEADER pBevelHeader = pConvertedBMP->GetBitmapInfoHeader();
02311 const double PixPerMetre = pControl->GetDPI() * INCHES_PER_METRE;
02312 pBevelHeader->biXPelsPerMeter = pBevelHeader->biYPelsPerMeter = (INT32)(PixPerMetre + 0.5);
02313 }
02314
02315 pConvertedBMP->Attach(Document::GetCurrent()->GetBitmapList());
02316 }
02317
02318
02319 if(m_pBevelBitmap)
02320 {
02321 delete m_pBevelBitmap;
02322 m_pBevelBitmap = NULL;
02323 }
02324
02325
02326 m_pBMPFill->BitmapRef.SetBitmap(pConvertedBMP);
02327 m_pTranspFill->BitmapRef.SetBitmap(pConvertedBMP);
02328
02329 if (m_pCombiBitmap)
02330 {
02331 delete m_pCombiBitmap;
02332 m_pCombiBitmap = NULL;
02333 }
02334
02335 m_pBMPFill->SetStartPoint(&m_BMPCentre);
02336 m_pBMPFill->SetEndPoint(&m_BMPPoint1);
02337 m_pBMPFill->SetEndPoint2(&m_BMPPoint2);
02338
02339 m_pTranspFill->SetStartPoint(&m_BMPCentre);
02340 m_pTranspFill->SetEndPoint(&m_BMPPoint1);
02341 m_pTranspFill->SetEndPoint2(&m_BMPPoint2);
02342
02343
02344 pNewNodePath->InkPath.Initialise();
02345 pNewNodePath->InkPath.CloneFrom(InkPath);
02346 pNewNodePath->InkPath.IsFilled = TRUE;
02347 pNewNodePath->InkPath.TryToClose();
02348 pNewNodePath->InkPath.InitialiseFlags();
02349
02350
02351 if(FindAppliedAttribute(CC_RUNTIME_CLASS(AttrFeather),&pAttr))
02352 pAttr->CopyNode(pNewNodePath, FIRSTCHILD);
02353
02354
02355 if(m_IsFlatFilledOnly && !m_HasTransparencyApplied)
02356 {
02357
02358 if(m_pBMPFill)
02359 {
02360
02361 pAttr = m_pBMPFill->MakeNode();
02362 pAttr->AttachNode(pNewNodePath,FIRSTCHILD);
02363 }
02364 }
02365 else if((m_IsFlatFilledOnly && m_HasTransparencyApplied) || (!m_IsFlatFilledOnly && m_HasTransparencyApplied))
02366 {
02367
02368 if(FindAppliedAttribute(CC_RUNTIME_CLASS(AttrTranspFillGeometry),&pAttr))
02369 pAttr->CopyNode(pNewNodePath, FIRSTCHILD);
02370
02371 if(m_pBMPFill)
02372 {
02373
02374 pAttr = m_pBMPFill->MakeNode();
02375 pAttr->AttachNode(pNewNodePath,FIRSTCHILD);
02376 }
02377 }
02378 else
02379 {
02380
02381 if(FindAppliedAttribute(CC_RUNTIME_CLASS(AttrFillGeometry),&pAttr))
02382 pAttr->CopyNode(pNewNodePath, FIRSTCHILD);
02383
02384 if(m_pTranspFill)
02385 {
02386
02387 pAttr = m_pTranspFill->MakeNode();
02388 pAttr->AttachNode(pNewNodePath,FIRSTCHILD);
02389 }
02390 }
02391
02392
02393 ALLOC_WITH_FAIL(pLineWidth, new AttrLineWidth, pOp);
02394 pLineWidth->Value.LineWidth = 50;
02395 pLineWidth->AttachNode(pNewNodePath, FIRSTCHILD);
02396
02397
02398 ALLOC_WITH_FAIL(pStrokeColour, new AttrStrokeColour, pOp);
02399 pStrokeColour->SetStartColour(&dcNone);
02400 pStrokeColour->AttachNode(pNewNodePath, FIRSTCHILD);
02401
02402 if(pFillMapAttr)
02403 pFillMapAttr->CopyNode(pNewNodePath,FIRSTCHILD);
02404
02405 if(pFillTranspMapAttr)
02406 pFillTranspMapAttr->CopyNode(pNewNodePath,FIRSTCHILD);
02407
02408 if(pFillEffectAttr)
02409 pFillEffectAttr->CopyNode(pNewNodePath,FIRSTCHILD);
02410
02411 }
02412
02413 m_AmConvertingToShapes = FALSE;
02414
02415
02416
02417 pParent = (NodeRenderableInk *)FindParent();
02418
02419 if (pParent)
02420 {
02421
02422
02423
02424
02425
02426 pBevelStartNode = pParent->FindFirstChild(CC_RUNTIME_CLASS(NodeBevelBegin));
02427
02428 if (pOp)
02429 {
02430 pOp->DoRemoveAttrTypeFromSubtree(pParent, CC_RUNTIME_CLASS(AttrBevelLightAngle));
02431 pOp->DoRemoveAttrTypeFromSubtree(pParent, CC_RUNTIME_CLASS(AttrBevelType));
02432 pOp->DoRemoveAttrTypeFromSubtree(pParent, CC_RUNTIME_CLASS(AttrBevelContrast));
02433 pOp->DoRemoveAttrTypeFromSubtree(pParent, CC_RUNTIME_CLASS(AttrBevelIndent));
02434
02435 if (bCreateNew)
02436 {
02437
02438 if(!m_bOuter)
02439 pOp->DoInsertNewNode(pNewNodePath, pParent, LASTCHILD, TRUE, FALSE, FALSE, TRUE);
02440 else
02441 pOp->DoInsertNewNode(pNewNodePath, pBevelStartNode, NEXT, TRUE, FALSE, FALSE, TRUE);
02442 }
02443
02444 if (pBevelStartNode)
02445 pOp->DoHideNode(pBevelStartNode, TRUE, &pHiddenNode, FALSE);
02446 }
02447 else
02448 {
02449 pParent->RemoveAttrTypeFromSubtree(CC_RUNTIME_CLASS(AttrBevelLightAngle));
02450 pParent->RemoveAttrTypeFromSubtree(CC_RUNTIME_CLASS(AttrBevelType));
02451 pParent->RemoveAttrTypeFromSubtree(CC_RUNTIME_CLASS(AttrBevelContrast));
02452 pParent->RemoveAttrTypeFromSubtree(CC_RUNTIME_CLASS(AttrBevelIndent));
02453
02454 if (bCreateNew)
02455 {
02456
02457 if(!m_bOuter)
02458 pNewNodePath->AttachNode(pParent, LASTCHILD, FALSE, FALSE);
02459 else
02460 pNewNodePath->AttachNode(pBevelStartNode, NEXT, FALSE, FALSE);
02461 }
02462
02463 if (pBevelStartNode)
02464 {
02465 pBevelStartNode->CascadeDelete();
02466 delete pBevelStartNode;
02467 }
02468 }
02469 }
02470
02471 if (bCreateNew)
02472 {
02473 CCAttrMap ThisMap;
02474 if (!pNewNodePath->FindAppliedAttributes(&ThisMap))
02475 return FALSE;
02476
02477 CCAttrMap* pThisMap = ThisMap.Copy();
02478 if (pThisMap)
02479 {
02480 if (pThisMap->Lookup(CC_RUNTIME_CLASS(AttrStrokeColour), (void *&)(pStrokeColour)))
02481 {
02482 if (pStrokeColour && pStrokeColour->GetStartColour())
02483 pStrokeColour->SetStartColour(&dcNone);
02484 }
02485 }
02486 pBecomeA->PassBack(pNewNodePath, this, pThisMap);
02487 }
02488
02489
02490 if (pOp)
02491 pOp->DoHideNode(this, TRUE, &pHiddenNode, FALSE);
02492 else
02493 {
02494 CascadeDelete();
02495 delete this;
02496 }
02497 }
02498 break;
02499 case BECOMEA_PASSBACK:
02500 {
02501
02502 pNewNodePath = new NodePath;
02503 ERRORIF(pNewNodePath == NULL, _R(IDE_NOMORE_MEMORY), FALSE);
02504
02505
02506 pNewNodePath->InkPath.Initialise();
02507 pNewNodePath->InkPath.CloneFrom(InkPath);
02508 pNewNodePath->InkPath.IsFilled = TRUE;
02509 pNewNodePath->InkPath.TryToClose();
02510 pNewNodePath->InkPath.InitialiseFlags();
02511
02512
02513 CCAttrMap ThisMap;
02514 if (!FindAppliedAttributes(&ThisMap))
02515 return FALSE;
02516
02517
02518 CCAttrMap * pNewAttrMap = ThisMap.Copy();
02519
02520 if( pNewAttrMap->Lookup( CC_RUNTIME_CLASS(AttrStrokeColour), (void *&)(pStrokeColour)))
02521 {
02522 if (pStrokeColour && pStrokeColour->GetStartColour())
02523 pStrokeColour->SetStartColour(&dcNone);
02524 }
02525
02526 pBecomeA->PassBack(pNewNodePath, this, pNewAttrMap);
02527 }
02528 break;
02529 default:
02530 break;
02531 }
02532 return TRUE;
02533 }
02534
02535
02536
02537
02538
02539
02540
02541
02542
02543
02544
02545
02546
02547 BOOL NodeBevel::CanBecomeA(BecomeA* pBecomeA)
02548 {
02549 if (pBecomeA->BAPath())
02550 {
02551 pBecomeA->AddCount(2);
02552
02553 return TRUE;
02554 }
02555
02556 return FALSE;
02557 }
02558
02559
02560
02561
02562
02563
02564
02565
02566
02567
02568 void NodeBevel::RenderTinyBlobs(RenderRegion* pRender)
02569 {
02570 pRender->SaveContext();
02571 pRender->SetLineColour(COLOUR_NONE);
02572 pRender->SetFillColour(COLOUR_UNSELECTEDBLOB);
02573
02574
02575 BlobManager* BlobMgr = GetApplication()->GetBlobManager();
02576
02577 DocRect dr(0,0,0,0);
02578 InkPath.GetTrueBoundingRect(&dr);
02579
02580 DocCoord Coord(dr.lo.x + (BlobMgr->GetBlobSize() / 2),
02581 dr.hi.y - (BlobMgr->GetBlobSize() / 2));
02582 pRender->DrawBlob(Coord, BT_UNSELECTED);
02583 pRender->RestoreContext();
02584 }
02585
02586
02587
02588
02589
02590
02591
02592
02593
02594
02595
02596
02597 BitmapFillAttribute* NodeBevel::GetBitmapFillAttribute ( void )
02598 {
02599 return m_pBMPFill;
02600 }
02601
02602
02603
02604
02605
02606
02607
02608
02609
02610
02611
02612 DocRect NodeBevel::GetBoundingRect(BOOL DontUseAttrs, BOOL HitTest)
02613 {
02614 if ( IsBoundingRectValid && !DontUseAttrs )
02615 return BoundingRectangle;
02616
02617 DocRect dr(0,0,0,0);
02618
02619
02620 if (InkPath.GetNumCoords() == 0)
02621 {
02622 Node* pNode = NULL;
02623
02624 if(m_bOuter)
02625 pNode = FindNext(CC_RUNTIME_CLASS(NodeRenderableBounded));
02626 else
02627 pNode = FindPrevious(CC_RUNTIME_CLASS(NodeRenderableBounded));
02628
02629 if (!pNode)
02630 return DocRect(0,0,0,0);
02631
02632 while (pNode)
02633 {
02634 if (pNode->IsRenderable() && !pNode->IsAnAttribute() &&
02635 !pNode->IsKindOf(CC_RUNTIME_CLASS(NodeBevelBegin)) &&
02636 !pNode->IsNodeHidden())
02637 {
02638 if (pNode->IsNodePath())
02639 {
02640
02641 NodePath * pNodePath = ((NodePath *)pNode)->MakeNodePathFromAttributes(BevelClipPathToPath_Flatness);
02642
02643 DocRect dr2(0,0,0,0);
02644 pNodePath->InkPath.GetTrueBoundingRect(&dr2);
02645 dr = dr.Union(dr2);
02646
02647 delete pNodePath;
02648 }
02649 else
02650 dr = dr.Union(((NodeRenderableBounded *) pNode)->GetBoundingRect(DontUseAttrs, HitTest));
02651 }
02652
02653 if(m_bOuter)
02654 pNode = pNode->FindNext(CC_RUNTIME_CLASS(NodeRenderableBounded));
02655 else
02656 pNode = pNode->FindPrevious(CC_RUNTIME_CLASS(NodeRenderableBounded));
02657 }
02658
02659 BoundingRectangle = dr;
02660
02661 if (m_bOuter)
02662 BoundingRectangle.Inflate(m_Indent * 2);
02663 }
02664 else
02665 InkPath.GetTrueBoundingRect(&BoundingRectangle);
02666
02667 IsBoundingRectValid = TRUE;
02668
02669 return BoundingRectangle;
02670 }
02671
02672
02673 DocRect NodeBevel::GetBlobBoundingRect()
02674 {
02675
02676 BlobManager* BlobMgr = GetApplication()->GetBlobManager();
02677 BlobStyle BS = BlobMgr->GetCurrentInterest(TRUE);
02678
02679 INT32 BlobSize = BlobMgr->GetBlobSize();
02680 DocRect br = GetBoundingRect();
02681 br.lo.x -= BlobSize;
02682 br.lo.y -= BlobSize;
02683 br.hi.x += BlobSize;
02684 br.hi.y += BlobSize;
02685
02686 IncludeChildrensBoundingRects(&br);
02687
02688
02689 if (Tool::GetCurrentID() != TOOLID_BEVELTOOL || !BevelTool::AmActive())
02690 return br;
02691
02692 DocRect BlobRect;
02693
02694
02695 DocCoord blob( (br.hi.x+br.lo.x)>>1,
02696 (br.hi.y+br.lo.y)>>1 );
02697
02698 View * pView = View::GetCurrent();
02699 if (!pView)
02700 return br;
02701
02702 INT32 iLen = (INT32)(pView->GetScaledPixelWidth().MakeDouble()*40) ;
02703
02704
02705 if (pView)
02706 {
02707 iLen += (INT32)(pView->GetScaledPixelWidth().MakeDouble()*15);
02708 iLen += GetApplication()->GetBlobManager()->GetBlobSize();
02709 }
02710
02711 DocRect dr;
02712
02713 dr.lo.x = blob.x - iLen;
02714 dr.lo.y = blob.y - iLen;
02715 dr.hi.x = blob.x + iLen;
02716 dr.hi.y = blob.y + iLen;
02717
02718 BlobRect = br;
02719
02720
02721 BlobRect = BlobRect.Union(dr);
02722
02723 return BlobRect;
02724 }
02725
02726
02727
02728
02729
02730
02731
02732
02733
02734
02735
02736
02737 void NodeBevel::Transform( TransformBase& tb )
02738 {
02739 if(!m_MustRegenOnChildChange)
02740 return;
02741
02742
02743 FIXED16 ScaleFactor = tb.GetScalar();
02744
02745 TransformChildren(tb);
02746 Trans2DMatrix * pMat2D = NULL;
02747 if (tb.IsInvertable())
02748 pMat2D = (Trans2DMatrix*)(&tb);
02749
02750
02751 m_Indent= labs( INT32(ScaleFactor.MakeDouble() * ((double)m_Indent) ));
02752
02753 NodeBevelController * pControl = (NodeBevelController *)FindParent();
02754 if (pControl)
02755 pControl->m_Indent = m_Indent;
02756
02757 AttrBevelIndent * pApplied = NULL;
02758 AttrBevelIndent * pIndent = NULL;
02759
02760 if ( pMat2D &&
02761 !pMat2D->GetMatrix().IsTranslation() &&
02762 FindAppliedAttribute(CC_RUNTIME_CLASS(AttrBevelIndent),(NodeAttribute **)&pApplied) &&
02763 pApplied->IsADefaultAttr() )
02764 {
02765
02766 pIndent = new AttrBevelIndent(FindParent(), FIRSTCHILD);
02767 if (pIndent)
02768 {
02769 pIndent->Value.m_Indent = m_Indent;
02770 if (m_bOuter)
02771 pIndent->Value.m_Indent = -m_Indent;
02772 ((NodeRenderableInk *)FindParent())->NormaliseAttributes();
02773 }
02774 }
02775
02776
02777 if (m_Path.GetNumCoords() > 0)
02778 tb.Transform(m_Path.GetCoordArray(), m_Path.GetNumCoords());
02779
02780 if (m_OuterBevelPath.GetNumCoords() > 0)
02781 tb.Transform(m_OuterBevelPath.GetCoordArray(), m_OuterBevelPath.GetNumCoords());
02782
02783 if (InkPath.GetNumCoords() > 0)
02784 tb.Transform(InkPath.GetCoordArray(), InkPath.GetNumCoords());
02785
02786 if (m_ShrunkPath.GetNumCoords() > 0)
02787 tb.Transform(m_ShrunkPath.GetCoordArray(), m_ShrunkPath.GetNumCoords());
02788
02789
02790 if (pMat2D)
02791 {
02792 if (!pMat2D->GetMatrix().IsTranslation())
02793 {
02794 GenerateBevel();
02795 }
02796 else
02797 {
02798 DocCoord TransCoords(0,0);
02799 pMat2D->GetMatrix().GetTranslation(TransCoords);
02800
02801
02802
02803
02804 {
02805
02806 tb.Transform(&m_BMPCentre, 1);
02807 tb.Transform(&m_BMPPoint1, 1);
02808 tb.Transform(&m_BMPPoint2, 1);
02809 tb.Transform(&BoundingRectangle.lo, 1);
02810 tb.Transform(&BoundingRectangle.hi, 1);
02811 }
02812 }
02813 }
02814
02815 InvalidateBoundingRect();
02816 GetBoundingRect(TRUE, FALSE);
02817 }
02818
02819
02820
02821
02822
02823
02824
02825
02826
02827
02828 BOOL NodeBevel::NeedsTransparency() const
02829 {
02830 return TRUE;
02831 }
02832
02833
02834
02835
02836
02837
02838
02839
02840
02841
02842
02843
02844
02845
02846
02847
02848
02849
02850
02851
02852 BOOL NodeBevel::RequiresAttrib(CCRuntimeClass* pAttribClass, BOOL Search)
02853 {
02854 if (pAttribClass == NULL || pAttribClass == CC_RUNTIME_CLASS(AttrBrushType))
02855 return FALSE;
02856 else
02857 return NodeRenderableInk::RequiresAttrib(pAttribClass, Search);
02858 }
02859
02860
02861
02862
02863
02864
02865
02866
02867
02868
02869
02870
02871
02872
02873
02874
02875
02876
02877
02878
02879
02880 BOOL NodeBevel::RequiresAttrib(NodeAttribute* pAttr, BOOL Search)
02881 {
02882 if (pAttr == NULL || pAttr->IS_KIND_OF(AttrBrushType))
02883 return FALSE;
02884 else
02885 return NodeRenderableInk::RequiresAttrib(pAttr, Search);
02886 }
02887
02888
02889
02890
02891
02892
02893
02894
02895
02896
02897
02898
02899
02900
02901
02902
02903
02904
02905
02906 BOOL NodeBevel::CanAttrBeAppliedToMe(CCRuntimeClass* pAttribClass)
02907 {
02908 if (pAttribClass == NULL || pAttribClass == CC_RUNTIME_CLASS(AttrBrushType))
02909 return FALSE;
02910 else
02911 return TRUE;
02912 }
02913
02914
02915
02916
02917
02918
02919
02920
02921
02922
02923
02924
02925
02926 NodeCompound* NodeBevel::GetParentController() const
02927 {
02928 NodeBevelController* pBob = (NodeBevelController*)FindParent();
02929 if (pBob != NULL && !IS_A(pBob, NodeBevelController))
02930 {
02931 ERROR3("Parent of Bevel was not a NodeBevelController");
02932 pBob = NULL;
02933 }
02934
02935 return pBob;
02936 }
02937
02938
02939
02940
02941
02942
02943
02944
02945
02946
02947
02948 void NodeBevel::DeleteCachedBitmap()
02949 {
02950 if(m_pBevelBitmap)
02951 {
02952 m_pBevelBitmap->Detach();
02953 m_pBevelBitmap->DestroyGreyscaleVersion();
02954 delete m_pBevelBitmap;
02955 m_pBevelBitmap = NULL;
02956 }
02957
02958 if(m_pCombiBitmap)
02959 {
02960 delete m_pCombiBitmap;
02961 m_pCombiBitmap = NULL;
02962 }
02963 }
02964
02965
02966
02967
02968
02969
02970
02971
02972
02973
02974 void NodeBevel::DeleteCache()
02975 {
02976 m_bCached = FALSE;
02977
02978 if (m_pBevelBitmap)
02979 {
02980 m_pBevelBitmap->Detach();
02981 delete m_pBevelBitmap;
02982 m_pBevelBitmap = NULL;
02983 }
02984
02985 if (m_pBeveler)
02986 {
02987 delete m_pBeveler;
02988 m_pBeveler = NULL;
02989 }
02990
02991 InkPath.ClearPath();
02992 m_OuterBevelPath.ClearPath();
02993 m_ShrunkPath.ClearPath();
02994 m_Path.ClearPath();
02995 InvalidateMe();
02996 }
02997
02998
02999
03000
03001
03002
03003
03004
03005
03006
03007
03008 BOOL NodeBevel::ReRenderBevelBitmap(BOOL bAntialias)
03009 {
03010 BOOL ok = TRUE;
03011
03012 if (m_pBeveler && m_pBevelBitmap)
03013 {
03014
03015 m_pBeveler->SetBevelAngle(m_LightAngle);
03016 m_pBeveler->SetBevelType(m_BevelType);
03017 m_pBeveler->SetBevelTilt(m_Tilt);
03018
03019 if(m_pCombiBitmap)
03020 {
03021 delete m_pCombiBitmap;
03022 m_pCombiBitmap = NULL;
03023 }
03024
03025
03026 if (bAntialias)
03027 m_DoingRotation = FALSE;
03028 else
03029 m_DoingRotation = TRUE;
03030
03031 m_pBevelBitmap->DestroyGreyscaleVersion();
03032 ok = m_pBeveler->RenderToBitmap(m_pBevelBitmap, bAntialias, &m_SubPixelOffset);
03033 }
03034
03035 return ok;
03036 }
03037
03038
03039
03040
03041
03042
03043
03044
03045
03046
03047
03048 BOOL NodeBevel::IsNodePath() const
03049 {
03050 return FALSE;
03051 }
03052
03053
03054
03055
03056
03057
03058
03059
03060
03061
03062 BOOL NodeBevel::WritePreChildrenWeb(BaseCamelotFilter* pFilter)
03063 {
03064 UINT32 Tag = TAG_BEVELINK;
03065
03066 CamelotFileRecord Rec(pFilter,Tag,0);
03067
03068 pFilter->Write(&Rec);
03069
03070 return TRUE;
03071 }
03072
03073 BOOL NodeBevel::WritePreChildrenNative(BaseCamelotFilter* pFilter)
03074 {
03075 return WritePreChildrenWeb(pFilter);
03076 }
03077
03078
03079
03080
03081
03082
03083
03084
03085
03086
03087
03088
03089 Node* NodeBevel::SimpleCopy()
03090 {
03091 NodeBevel * pNewNode = new NodeBevel;
03092
03093 ERRORIF(pNewNode == NULL, _R(IDE_NOMORE_MEMORY), NULL);
03094
03095 CopyNodeContents(pNewNode);
03096
03097 return pNewNode;
03098 }
03099
03100
03101
03102
03103
03104
03105
03106
03107
03108
03109
03110
03111
03112
03113 void NodeBevel::CopyNodeContents(NodeBevel* pNewNode)
03114 {
03115 pNewNode->m_Indent = m_Indent;
03116 pNewNode->m_LightAngle = m_LightAngle;
03117 pNewNode->m_Contrast = m_Contrast;
03118 pNewNode->m_BevelType = m_BevelType;
03119 pNewNode->m_bOuter = m_bOuter;
03120
03121 pNewNode->InkPath.Initialise(InkPath.GetNumCoords());
03122 pNewNode->InkPath.CopyPathDataFrom(&InkPath);
03123
03124 pNewNode->m_MustRegenOnChildChange = m_MustRegenOnChildChange;
03125
03126 pNewNode->m_Tilt = m_Tilt;
03127
03128 pNewNode->m_IsABlendStepBevel = m_IsABlendStepBevel;
03129
03130
03131 pNewNode->m_BMPCentre = m_BMPCentre;
03132 pNewNode->m_BMPPoint1 = m_BMPPoint1;
03133 pNewNode->m_BMPPoint2 = m_BMPPoint2;
03134
03135
03136 pNewNode->m_SelectedRect = m_SelectedRect;
03137 pNewNode->m_JointType = m_JointType;
03138
03139 pNewNode->m_Path.Initialise(m_Path.GetNumCoords());
03140 pNewNode->m_Path.CopyPathDataFrom(&m_Path);
03141
03142 pNewNode->m_DoRender = TRUE;
03143
03144 pNewNode->DeleteCachedBitmap();
03145
03146 if (m_pBevelBitmap==NULL && m_pBMPFill!=NULL)
03147 m_pBMPFill->BitmapRef.SetBitmap(m_pBevelBitmap);
03148 if (m_pBevelBitmap==NULL && m_pTranspFill!=NULL)
03149 m_pTranspFill->BitmapRef.SetBitmap(m_pBevelBitmap);
03150
03151 if (pNewNode->m_pBMPFill)
03152 delete pNewNode->m_pBMPFill;
03153 pNewNode->m_pBMPFill = NULL;
03154 if (m_pBMPFill)
03155 {
03156 pNewNode->m_pBMPFill = new BitmapFillAttribute;
03157 pNewNode->m_pBMPFill->SimpleCopy(m_pBMPFill);
03158 }
03159
03160 if (pNewNode->m_pTranspFill)
03161 delete pNewNode->m_pTranspFill;
03162 pNewNode->m_pTranspFill = NULL;
03163 if (m_pTranspFill)
03164 {
03165 pNewNode->m_pTranspFill = new BitmapTranspFillAttribute;
03166 pNewNode->m_pTranspFill->SimpleCopy(m_pTranspFill);
03167 }
03168
03169 pNewNode->m_BitmapWidth = m_BitmapWidth;
03170 pNewNode->m_BitmapHeight = m_BitmapHeight;
03171
03172 pNewNode->m_SubPixelOffset = m_SubPixelOffset;
03173 pNewNode->m_PixelAllignedRect = m_PixelAllignedRect;
03174 pNewNode->m_IsFlatFilledOnly = m_IsFlatFilledOnly;
03175 pNewNode->m_IsAnAlphaBMP = m_IsAnAlphaBMP;
03176 pNewNode->m_HasTransparencyApplied = m_HasTransparencyApplied;
03177 pNewNode->m_AmConvertingToShapes = m_AmConvertingToShapes;
03178
03179 pNewNode->m_LastCachedPrintBMPDPI = m_LastCachedPrintBMPDPI;
03180 pNewNode->m_LastExportedDPI = m_LastExportedDPI;
03181
03182
03183 pNewNode->m_bStopRender = m_bStopRender;
03184 pNewNode->m_DoingRotation = m_DoingRotation;
03185
03186
03187
03188 pNewNode->m_OuterBevelPath.Initialise(m_OuterBevelPath.GetNumCoords());
03189 pNewNode->m_OuterBevelPath.CopyPathDataFrom(&m_OuterBevelPath);
03190
03191
03192 pNewNode->m_ViewScale = m_ViewScale;
03193
03194
03195 pNewNode->m_ShrunkPath.Initialise(m_ShrunkPath.GetNumCoords());
03196 pNewNode->m_ShrunkPath.CopyPathDataFrom(&m_ShrunkPath);
03197
03198 pNewNode->m_bLock = m_bLock;
03199 pNewNode->m_bRenderBitmaps = m_bRenderBitmaps;
03200
03201
03202 pNewNode->m_bZeroLineWidth = m_bZeroLineWidth;
03203
03204
03205 if (pNewNode->m_pBeveler)
03206 {
03207 delete pNewNode->m_pBeveler;
03208 pNewNode->m_pBeveler = NULL;
03209 }
03210
03211
03212
03213 pNewNode->m_bPathIsClosed = m_bPathIsClosed;
03214
03215
03216
03217 pNewNode->m_bCached = m_bCached;
03218
03219
03220
03221
03222 pNewNode->m_LastZoomFactor = m_LastZoomFactor;
03223
03224
03225 pNewNode->m_LastPixelSize = m_LastPixelSize;
03226
03227 NodeRenderableInk::CopyNodeContents(pNewNode);
03228 }
03229
03230
03231
03232
03233
03234
03235
03236
03237
03238
03239
03240
03241
03242
03243
03244
03245 void NodeBevel::PolyCopyNodeContents(NodeRenderable* pNodeCopy)
03246 {
03247 ENSURE(pNodeCopy, "Trying to copy a node's contents into a NULL node");
03248 ENSURE(IS_A(pNodeCopy, NodeBevel), "PolyCopyNodeContents given wrong dest node type");
03249
03250 if (IS_A(pNodeCopy, NodeBevel))
03251 CopyNodeContents((NodeBevel*)pNodeCopy);
03252 }
03253
03254
03255
03256
03257
03258
03259
03260
03261
03262
03263
03264
03265 BOOL NodeBevel::PostDuplicate(UndoableOperation* pOp)
03266 {
03267
03268 return TRUE;
03269 }
03270
03271
03273
03274
03275
03276
03277
03278
03279
03280
03281
03282
03283
03284
03285 BevelRecordHandler::BevelRecordHandler()
03286 {
03287 }
03288
03289
03290
03291
03292
03293
03294
03295
03296
03297
03298 BevelRecordHandler::~BevelRecordHandler()
03299 {
03300 }
03301
03302
03303
03304
03305
03306
03307
03308
03309
03310
03311 UINT32* BevelRecordHandler::GetTagList()
03312 {
03313 static const UINT32 TagList[] = {TAG_BEVEL,
03314 TAG_BEVATTR_INDENT,
03315 TAG_BEVATTR_LIGHTANGLE,
03316 TAG_BEVATTR_CONTRAST,
03317 TAG_BEVATTR_TYPE,
03318 TAG_BEVELINK,
03319 CXFRH_TAG_LIST_END};
03320 return (UINT32*)&TagList;
03321 }
03322
03323
03324
03325
03326
03327
03328
03329
03330
03331
03332
03333 BOOL BevelRecordHandler::HandleRecord(CXaraFileRecord* pCXaraFileRecord)
03334 {
03335
03336
03337
03338
03339
03340
03341
03342
03343 INT32 value = 0;
03344
03345 if (pCXaraFileRecord->GetTag() == TAG_BEVEL)
03346 {
03347 m_pBevelController = new NodeBevelController();
03348
03349 if (!m_pBevelController)
03350 {
03351 ERROR(_R(IDE_NOMORE_MEMORY), FALSE);
03352 }
03353
03354 BOOL ok = m_pBevelController->LoadBevelFromRecord(pCXaraFileRecord);
03355 if (!ok)
03356 {
03357 delete m_pBevelController ;
03358 m_pBevelController = NULL;
03359 return FALSE;
03360 }
03361
03362
03363 InsertNode(m_pBevelController);
03364 }
03365 else if (pCXaraFileRecord->GetTag() == TAG_BEVELINK)
03366 {
03367
03368 m_pBevelInk = new NodeBevel;
03369
03370 if (!m_pBevelInk)
03371 {
03372 ERROR(_R(IDE_NOMORE_MEMORY), FALSE);
03373 }
03374
03375 InsertNode(m_pBevelInk);
03376 m_pBevelInk->InvalidateMe();
03377 }
03378 else if (pCXaraFileRecord->GetTag() == TAG_BEVATTR_INDENT)
03379 {
03380
03381 if (!pCXaraFileRecord->ReadINT32(&value))
03382 return FALSE;
03383 }
03384 else if (pCXaraFileRecord->GetTag() == TAG_BEVATTR_LIGHTANGLE)
03385 {
03386
03387 if (!pCXaraFileRecord->ReadINT32(&value))
03388 return FALSE;
03389 }
03390 else if (pCXaraFileRecord->GetTag() == TAG_BEVATTR_CONTRAST)
03391 {
03392
03393 if (!pCXaraFileRecord->ReadINT32(&value))
03394 return FALSE;
03395 }
03396 else if (pCXaraFileRecord->GetTag() == TAG_BEVATTR_TYPE)
03397 {
03398
03399 if (!pCXaraFileRecord->ReadINT32(&value))
03400 return FALSE;
03401 }
03402
03403 return TRUE;
03404 }
03405
03406
03407
03408
03409
03410
03411
03412
03413
03414
03415
03416
03417
03418
03419 BOOL NodeBevel::NeedsParent(Node* pNode) const
03420 {
03421 if (!pNode)
03422 return TRUE;
03423
03424 if (pNode->IsKindOf(CC_RUNTIME_CLASS(NodeBevelController)))
03425 return TRUE;
03426
03427 return FALSE;
03428 }
03429
03430
03431
03432
03433
03434
03435
03436
03437
03438
03439
03440
03441
03442
03443 DocRect NodeBevel::GetInsideBoundingRect()
03444 {
03445 Node * pNode = FindPrevious();
03446
03447 DocRect dr(0,0,0,0);
03448
03449 while (pNode)
03450 {
03451 if (pNode->IsAnObject() && !pNode->IsNodeHidden() && pNode->IsBounded() &&
03452 !pNode->IsKindOf(CC_RUNTIME_CLASS(NodeBevelBegin)))
03453 {
03454 dr = dr.Union(((NodeRenderableBounded *)pNode)->GetBoundingRect());
03455 }
03456 pNode = pNode->FindPrevious();
03457 }
03458
03459 return dr;
03460 }
03461
03462
03463
03464
03465
03466
03467
03468
03469
03470
03471
03472
03473
03474
03475
03476
03477
03478
03479 void NodeBevel::RenderNodesForPrinting(RenderRegion * pRender)
03480 {
03481
03482 pRender->SaveContext();
03483
03484
03485 Node* pController = (Node*)GetParentController();
03486
03487 Node* pNode = pController->FindFirstChild();
03488
03489 while (pNode)
03490 {
03491 if (!pNode->IsKindOf(CC_RUNTIME_CLASS(NodeBevelBegin)) &&
03492 !pNode->IsKindOf(CC_RUNTIME_CLASS(NodeBevel)) &&
03493 !pNode->IsNodeHidden() &&
03494 pNode->IsNodeRenderableClass())
03495 {
03496 RenderNodeRecursively(pNode, pRender);
03497 }
03498 pNode = pNode->FindNext();
03499 }
03500
03501 pRender->RestoreContext();
03502 }
03503
03504
03505
03506
03507
03508
03509
03510
03511
03512
03513
03514
03515
03516
03517
03518 void NodeBevel::RenderNodeRecursively(Node * pNode, RenderRegion * pRender)
03519 {
03520 BOOL bHasChildren = FALSE;
03521
03522
03523 Node * pChildNode = pNode->FindFirstChild();
03524
03525 if (pChildNode)
03526 {
03527
03528 pRender->SaveContext();
03529 bHasChildren = TRUE;
03530 }
03531
03532 while (pChildNode)
03533 {
03534 if (!pChildNode->IsKindOf(CC_RUNTIME_CLASS(NodeBevelBegin)) &&
03535 !pChildNode->IsKindOf(CC_RUNTIME_CLASS(NodeBevel)) &&
03536 !pChildNode->IsNodeHidden() &&
03537 pChildNode->IsNodeRenderableClass())
03538 {
03539 RenderNodeRecursively(pChildNode, pRender);
03540 }
03541 pChildNode = pChildNode->FindNext();
03542 }
03543
03544
03545 pRender->SaveContext();
03546 pRender->SetLineColour(COLOUR_NONE);
03547 pNode->Render(pRender);
03548 pRender->RestoreContext();
03549
03550
03551 if (bHasChildren)
03552 pRender->RestoreContext();
03553 }
03554
03555
03556
03557
03558
03559
03560
03561
03562
03563
03564
03565
03566
03567
03568
03569
03570
03571
03572
03573
03574 BOOL NodeBevel::AllowOp(ObjChangeParam *pParam, BOOL SetOpPermissionState,
03575 BOOL DoPreTriggerEdit)
03576 {
03577 ERROR2IF(pParam==NULL, FALSE, "NodeBevel::AllowOp; NULL pParam");
03578
03579
03580 BOOL allowed = TRUE;
03581
03582 UndoableOperation* pOp = pParam->GetOpPointer();
03583
03584
03585 pParam->SetCallingChild(NULL);
03586
03587
03588 if (allowed && Parent != NULL && pParam->GetDirection()!= OBJCHANGE_CALLEDBYPARENT)
03589 {
03590 ObjChangeDirection OldDirection = pParam->GetDirection();
03591 pParam->SetCallingChild(this);
03592 pParam->SetDirection(OBJCHANGE_CALLEDBYCHILD);
03593 allowed = Parent->AllowOp(pParam, SetOpPermissionState, DoPreTriggerEdit);
03594 pParam->SetDirection(OldDirection);
03595 }
03596
03597
03598 if (allowed && pOp)
03599 {
03600
03601 if ( pOp->IsKindOf(CC_RUNTIME_CLASS(OpCreateNewMould)) ||
03602 pOp->IsKindOf(CC_RUNTIME_CLASS(OpPasteEnvelope)) ||
03603 pOp->IsKindOf(CC_RUNTIME_CLASS(OpPastePerspective)) ||
03604 pOp->IsKindOf(CC_RUNTIME_CLASS(OpCreateContour))
03605 )
03606 allowed = FALSE;
03607
03608 if( (pOp->IsKindOf(CC_RUNTIME_CLASS(OpEditFill)) ||
03609 pOp->IsKindOf(CC_RUNTIME_CLASS(OpApplyAttribToSelected))) &&
03610 !m_IsFlatFilledOnly && m_HasTransparencyApplied && m_pCombiBitmap )
03611 {
03612
03613 if (m_pBMPFill->GetBitmap() == m_pCombiBitmap)
03614 m_pBMPFill->BitmapRef.SetBitmap(NULL);
03615 if (m_pTranspFill->GetBitmap() == m_pCombiBitmap)
03616 m_pTranspFill->BitmapRef.SetBitmap(NULL);
03617
03618 delete m_pCombiBitmap;
03619 m_pCombiBitmap = NULL;
03620 }
03621 }
03622
03623
03624 if (SetOpPermissionState)
03625 SetOpPermission(allowed ? PERMISSION_ALLOWED : PERMISSION_DENIED, TRUE);
03626
03627 if (allowed)
03628 {
03629 UndoableOperation* pChangeOp = pParam->GetOpPointer();
03630
03631
03632 BOOL InformGeomLinkedAttrs = SetOpPermissionState && pChangeOp && pChangeOp->MayChangeNodeBounds();
03633 if (InformGeomLinkedAttrs)
03634 {
03635 NodeAttribute* pNA = FindFirstGeometryLinkedAttr();
03636 while(pNA)
03637 {
03638 pNA->LinkedNodeGeometryHasChanged(pChangeOp);
03639 pNA = pNA->FindNextGeometryLinkedAttr();
03640 }
03641 }
03642
03643
03644
03645
03646 if (DoPreTriggerEdit && pChangeOp && pChangeOp->MayChangeNodeBounds() && NameGallery::Instance())
03647 allowed = NameGallery::Instance()->PreTriggerEdit(pChangeOp, pParam, this);
03648 }
03649
03650
03651 return allowed;
03652 }
03653
03654
03655
03656
03657
03658
03659
03660
03661
03662
03663
03664
03665
03666
03667 void NodeBevel::RenderEorDrag(RenderRegion * pRegion)
03668 {
03669 pRegion->DrawPath(&InkPath);
03670 }
03671
03672
03673
03674
03675
03676
03677
03678
03679
03680
03681
03682
03683
03684
03685
03686
03687
03688
03689
03690
03691
03692 DocRect NodeBevel::ValidateExtend(const ExtendParams& ExtParams)
03693 {
03694 Node* pBob = GetParentController();
03695 if (pBob == NULL)
03696 {
03697 ERROR3("NodeBevel::ValidateExtend- no controller Node found!");
03698 return DocRect(INT32_MAX, INT32_MAX, INT32_MAX, INT32_MAX);
03699 }
03700 else
03701 {
03702 return pBob->ValidateExtend(ExtParams);
03703 }
03704 }
03705
03706
03707
03708
03709
03710
03711
03712
03713
03714
03715
03716
03717
03718
03719
03720
03721
03722
03723
03724
03725
03726
03727
03728 void NodeBevel::Extend(const ExtendParams& ExtParams)
03729 {
03730 Node* pBob = GetParentController();
03731 if (pBob == NULL)
03732 {
03733 ERROR3("NodeBevel::ValidateExtend- no controller Node found!");
03734 }
03735 else
03736 pBob->Extend(ExtParams);
03737
03738 return;
03739 }
03740
03741
03742
03743
03744
03745
03746
03747
03748
03749
03750
03751
03752
03753
03754
03755
03756
03757
03758
03759
03760
03761
03762
03763 INT32 NodeBevel::EstimateNodeComplexity (OpParam* details)
03764 {
03765 return (InkPath.GetUsedSlots ());
03766 }
03767
03768 void NodeBevel::PreExportRender ( RenderRegion *pRegion )
03769 {
03770 if( pRegion
03771 PORTNOTE("other","Removed ImagemapRenderRegion usage")
03772 #ifndef EXCLUDE_FROM_XARALX
03773 && !pRegion->IsKindOf( CC_RUNTIME_CLASS(ImagemapRenderRegion) )
03774 #endif
03775 )
03776 {
03777 NodeBevelController* pControl = (NodeBevelController *)FindParent();
03778 if(pControl)
03779 {
03780 INT32 NewDPI = 96;
03781 Camelot.GetPrefValue(TEXT("Displays"),TEXT("CompCToEDPI"),&NewDPI);
03782 pControl->SetDPI(NewDPI);
03783 DeleteCachedBitmap();
03784 m_AmConvertingToShapes = TRUE;
03785
03786
03787
03788
03789
03790
03791
03792
03793
03794
03795
03796
03797
03798
03799
03800
03801 }
03802 }
03803 else
03804 m_AmConvertingToShapes = FALSE;
03805 }
03806
03807
03808
03809
03810
03811
03812
03813
03814
03815
03816
03817
03818
03819
03820
03821
03822
03823
03824 BOOL NodeBevel::ExportRender( RenderRegion *pRegion )
03825 {
03826 BOOL bResult = FALSE;
03827
03828
03829
03830
03831 if ( pRegion->IsKindOf ( CC_RUNTIME_CLASS ( FlashRenderRegion ) ) )
03832 {
03833
03834
03835 FlashRenderRegion *pFlash = ( FlashRenderRegion* ) pRegion;
03836
03837
03838
03839 bResult = pFlash->ExportBevel ( this );
03840 }
03841 PORTNOTE("cmx", "Removed CMX Support")
03842 #ifndef EXCLUDE_FROM_XARALX
03843
03844 else if ( pRegion->IsKindOf ( CC_RUNTIME_CLASS ( CMXRenderRegion ) ) )
03845 {
03846
03847 CMXRenderRegion *pCMX = ( CMXRenderRegion* ) pRegion;
03848
03849
03850
03851 bResult = pCMX->ExportBevel ( this );
03852 }
03853 #endif
03854
03855 else if ( pRegion->IsKindOf ( CC_RUNTIME_CLASS ( AIEPSRenderRegion ) ) )
03856 {
03857
03858 AIEPSRenderRegion *pAIEPS = ( AIEPSRenderRegion* ) pRegion;
03859
03860
03861
03862 bResult = pAIEPS->ExportBevel ( this );
03863 }
03864
03865
03866
03867
03868 return bResult;
03869 }
03870
03871
03872
03873
03874
03875
03876
03877
03878
03879
03880
03881
03882
03883
03884
03885 BOOL NodeBevel::OnNodePopUp(Spread* pSpread, DocCoord PointerPos, ContextMenu* pMenu)
03886 {
03887 BOOL ok = TRUE;
03888
03889 PORTNOTETRACE("other","NodeBevel::ExportRender - do nothing");
03890 #ifndef NO_ADVANCED_TOOLS
03891 ok = ok && pMenu->BuildCommand(TOOL_OPTOKEN_BEVEL, TRUE);
03892 #endif
03893 return ok;
03894 }
03895
03896
03897
03898
03899
03900
03901
03902
03903
03904
03905
03906
03907
03908
03909 void NodeBevel::GetDebugDetails( StringBase* Str )
03910 {
03911 #if DEBUG_TREE
03912
03913 NodeRenderableInk::GetDebugDetails( Str );
03914
03915 String_256 TempStr;
03916 String_256 TempStr2;
03917
03918 (*Str) += TEXT( "\r\nNodeBevel Data Dump\r\n" );
03919
03920 DocRect BlobRect = GetBlobBoundingRect();
03921 TempStr._MakeMsg( TEXT("Blob Bounding Rect :\r\n\t#1%ld,\t#2%ld\r\n\t#3%ld,\t#4%ld\r\n"),
03922 BlobRect.lo.x, BlobRect.lo.y, BlobRect.hi.x, BlobRect.hi.y );
03923 (*Str) += TempStr;
03924
03925 TempStr._MakeMsg( TEXT("Type :\t#1%d\r\n"), m_BevelType);
03926 (*Str) += TempStr;
03927
03928 #endif
03929 }
03930
03931
03932
03934
03935
03936
03937
03938
03939
03940
03941
03942
03943
03944
03945
03946
03947
03948 NodeBevelBegin::NodeBevelBegin()
03949 {
03950 }
03951
03952
03953
03954
03955
03956
03957
03958
03959
03960
03961
03962
03963
03964
03965
03966
03967
03968
03969
03970 NodeBevelBegin::NodeBevelBegin(Node* ContextNode,
03971 AttachNodeDirection Direction,
03972 BOOL Locked,
03973 BOOL Mangled,
03974 BOOL Marked,
03975 BOOL Selected)
03976 : NodeRenderableBounded(ContextNode, Direction, Locked, Mangled, Marked, Selected)
03977 {
03978
03979 }
03980
03981
03982
03983
03984
03985
03986
03987
03988
03989
03990
03991
03992
03993 void NodeBevelBegin::Render(RenderRegion * rr)
03994 {
03995 return;
03996
03997
03998
03999
04000
04001
04002
04003
04004
04005
04006
04007
04008
04009
04010
04011
04012
04013
04014
04015
04016
04017
04018
04019 }
04020
04021
04022
04023
04024
04025
04026
04027
04028
04029
04030
04031 DocRect NodeBevelBegin::GetBoundingRect(BOOL DontUseAttrs, BOOL HitTest)
04032 {
04033
04034 NodeBevelController* pBevelController = (NodeBevelController*)FindParent();
04035
04036 if (pBevelController->GetInsideBoundingRect().IsEmpty())
04037 return DocRect(0,0,0,0);
04038
04039 if (pBevelController)
04040 {
04041 NodeBevel* pBevel = pBevelController->GetBevelNode();
04042
04043 if (pBevel)
04044 {
04045 BoundingRectangle = pBevel->GetBoundingRect(DontUseAttrs, HitTest);
04046 return BoundingRectangle;
04047 }
04048 }
04049
04050 Node * pNode = this->FindNext(CC_RUNTIME_CLASS(NodeRenderableBounded));
04051 if (!pNode || pNode->IsKindOf(CC_RUNTIME_CLASS(NodeBevel)))
04052 {
04053
04054 return BoundingRectangle;
04055 }
04056
04057 BoundingRectangle = ((NodeRenderableBounded *)pNode)->GetBoundingRect(DontUseAttrs, HitTest);
04058 return BoundingRectangle;
04059 }
04060
04061
04062 DocRect NodeBevelBegin::GetBlobBoundingRect()
04063 {
04064 return GetBoundingRect(TRUE, FALSE);
04065 }
04066
04067
04068
04069
04070
04071
04072
04073
04074
04075
04076
04077 Node* NodeBevelBegin::SimpleCopy()
04078 {
04079 NodeBevelBegin * pNewNode = new NodeBevelBegin;
04080
04081 ERRORIF(pNewNode == NULL, _R(IDE_NOMORE_MEMORY), NULL);
04082
04083 return pNewNode;
04084 }
04085
04086
04087
04088
04089
04090
04091
04092
04093
04094
04095
04096
04097
04098
04099 BOOL NodeBevelBegin::NeedsParent(Node* pNode) const
04100 {
04101 if (!pNode || pNode->IsKindOf(CC_RUNTIME_CLASS(NodeBevelController)))
04102 return TRUE;
04103
04104 return FALSE;
04105 }
04106
04107
04108
04109 void NodeBevelBegin::SetSelected(BOOL Status)
04110 {
04111 Node::SetSelected(FALSE);
04112 }
04113
04114
04115
04116
04117
04118
04119
04120
04121
04122
04123
04124
04125
04126
04127
04128
04129 SubtreeRenderState NodeBevelBegin::RenderSubtree(RenderRegion* pRender, Node** ppNextNode, BOOL bClip)
04130 {
04131 return SUBTREE_ROOTANDCHILDREN;
04132 }
04133
04134
04135
04136
04137
04138
04139
04140
04141
04142
04143
04144
04145
04146
04147
04148
04149
04150 BOOL NodeBevelBegin::ExportRender ( RenderRegion *pRegion )
04151 {
04152 BOOL bResult = FALSE;
04153
04154
04155
04156
04157
04158 if ( pRegion->IsKindOf ( CC_RUNTIME_CLASS ( FlashRenderRegion ) ) )
04159 {
04160
04161
04162 FlashRenderRegion *pFlash = ( FlashRenderRegion* ) pRegion;
04163
04164
04165
04166 bResult = pFlash->ExportBevelBegin ( this );
04167 }
04168
04169
04170 PORTNOTE("cmx", "Removed CMX Support")
04171 #ifndef EXCLUDE_FROM_XARALX
04172 else if ( pRegion->IsKindOf ( CC_RUNTIME_CLASS ( CMXRenderRegion ) ) )
04173 {
04174
04175
04176 CMXRenderRegion *pCMX = ( CMXRenderRegion* ) pRegion;
04177
04178
04179 bResult = pCMX->ExportBevelBegin ( this );
04180 }
04181 #endif
04182
04183 else
04184 {
04185
04186 Render(pRegion);
04187
04188 return TRUE;
04189 }
04190
04191
04192
04193
04194 return bResult;
04195 }
04196
04197