00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 #include "camtypes.h"
00104 #include "shadtool.h"
00105 #include "nodecont.h"
00106
00107 #include "keypress.h"
00108 #include "vkextra.h"
00109
00110 #ifdef BUILDSHADOWS
00111
00112
00113
00114 #include "blobs.h"
00115 #include "csrstack.h"
00116
00117 #include "oilfiles.h"
00118 #include "opshadow.h"
00119 #include "shadinfo.h"
00120 #include "toollist.h"
00121 #include "layer.h"
00122 #include "layermsg.h"
00123 #include "nodeshad.h"
00124
00125
00126
00127
00128
00129
00130 #include "opbevel.h"
00131
00132 #include "objchge.h"
00133 #include "bubbleid.h"
00134
00135 #include "nodetxts.h"
00136 #include "nodeblnd.h"
00137 #include "nodebldr.h"
00138 #include "slicehelper.h"
00139 #include "opliveeffects.h"
00140 #include "liveeffectstool.h"
00141 #include "ophist.h"
00142 #include "shadinfo.h"
00143
00144 DECLARE_SOURCE( "$Revision: 1386 $" );
00145
00146 CC_IMPLEMENT_MEMDUMP(SoftShadowTool,Tool_v1)
00147 CC_IMPLEMENT_DYNCREATE(OpDragCreateShadow2, SelOperation)
00148 CC_IMPLEMENT_DYNCREATE(SaveShadowSettingsAction, Action)
00149
00150
00151 #define new CAM_DEBUG_NEW
00152
00153
00154 #define DEFAULT_SHADOW_COLOUR COLOUR_BLACK
00155
00156
00157 TCHAR* SoftShadowTool::FamilyName = _T("Shadow Tools");
00158 TCHAR* SoftShadowTool::ToolName = _T("Shadow Tool");
00159 TCHAR* SoftShadowTool::Purpose = _T("Shadow manipulation");
00160 TCHAR* SoftShadowTool::Author = _T("DavidMc");
00161
00162
00163 BOOL SoftShadowTool::CurrentTool = FALSE;
00164 SoftShadowInfoBarOp* SoftShadowTool::pSoftShadowInfoBarOp = NULL;
00165 UINT32 SoftShadowTool::StatusID = _R(IDS_SOFTSHADOWSTATUS_FINDSTART);
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180 SoftShadowTool::SoftShadowTool()
00181 {
00182 pcCurrentCursor = NULL;
00183 m_bBlobRendering = TRUE;
00184 pLastBlobSpread = NULL;
00185 m_iEditStackPos = STACKPOS_TOP;
00186 m_pEditRange = NULL;
00187 }
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200 SoftShadowTool::~SoftShadowTool()
00201 {
00202 if (m_pEditRange)
00203 {
00204 delete m_pEditRange;
00205 m_pEditRange = NULL;
00206 }
00207 }
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222 BOOL SoftShadowTool::Init()
00223 {
00224
00225 BOOL ok = TRUE;
00226 if (ok)
00227 ok = ( OpApplyShadow::Declare() &&
00228 OpChangeShadowType::Declare() &&
00229 OpRemoveShadow::Declare() &&
00230 OpShadowPosition::Declare() &&
00231 OpShadowPenumbra::Declare() &&
00232 OpShadowAngle::Declare() &&
00233 OpShadowHeight::Declare() &&
00234 OpShadowScale::Declare() &&
00235 OpShadowHeightAndAngle::Declare() &&
00236 OpSaveShadowData::Declare() &&
00237 OpGlowWidth::Declare() &&
00238 OpChangeShadowProfile::Declare() &&
00239 OpChangeShadowDarkness::Declare() &&
00240 OpDragCreateShadow2::Declare());
00241
00242
00243
00244
00245
00246 if (ok)
00247 {
00248 pSoftShadowInfoBarOp = new SoftShadowInfoBarOp;
00249 ERROR2IF(pSoftShadowInfoBarOp==NULL, FALSE, "Can't create Shadow tool Infobar");
00250 if (pSoftShadowInfoBarOp)
00251 pSoftShadowInfoBarOp->pSoftShadowTool = this;
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280 }
00281
00282 return (ok);
00283 }
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302 void SoftShadowTool::Describe(void *InfoPtr)
00303 {
00304
00305 ToolInfo_v1 *Info = (ToolInfo_v1 *) InfoPtr;
00306
00307 Info->InfoVersion = 1;
00308
00309 Info->InterfaceVersion = GetToolInterfaceVersion();
00310
00311
00312 Info->Version = 1;
00313 Info->ID = GetID();
00314 Info->TextID = _R(IDS_SOFTSHADOW_TOOL);
00315
00316 Info->Family = FamilyName;
00317 Info->Name = ToolName;
00318 Info->Purpose = Purpose;
00319 Info->Author = Author;
00320
00321 Info->BubbleID = _R(IDBBL_SOFTSHADOW_TOOLBOX);
00322 }
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341 void SoftShadowTool::SelectChange(BOOL isSelected)
00342 {
00343 if (isSelected)
00344 {
00345 if (!CreateCursors()) return;
00346 CurrentCursorID = CursorStack::GPush(pcNormalSoftShadowCursor, FALSE);
00347 pcCurrentCursor = pcNormalSoftShadowCursor;
00348
00349
00350 CurrentTool = TRUE;
00351 SetShadowEditRangeFromSelection();
00352
00353
00354 pSoftShadowInfoBarOp->Create();
00355
00356 if (pSoftShadowInfoBarOp->pSoftShadowInfoBar)
00357 {
00358
00359 pSoftShadowInfoBarOp->UpdateInfoBar();
00360 }
00361
00362
00363 BlobManager* BlobMgr = GetApplication()->GetBlobManager();
00364 if (BlobMgr != NULL)
00365 {
00366
00367 BlobStyle MyBlobs;
00368 MyBlobs.Tiny = TRUE;
00369 BlobMgr->ToolInterest(MyBlobs);
00370 }
00371
00372 RenderToolBlobs(Document::GetSelectedSpread(), NULL);
00373 }
00374 else
00375 {
00376
00377 if (pcCurrentCursor != NULL)
00378 {
00379 CursorStack::GPop(CurrentCursorID);
00380 pcCurrentCursor = NULL;
00381 CurrentCursorID = 0;
00382 }
00383 DestroyCursors();
00384
00385 pSoftShadowInfoBarOp->CloseProfileDialog (pSoftShadowInfoBarOp->BiasGainGadget_m);
00386
00387
00388 pSoftShadowInfoBarOp->Delete();
00389
00390
00391 BlobManager* BlobMgr = GetApplication()->GetBlobManager();
00392 if (BlobMgr != NULL)
00393 {
00394 BlobStyle bsRemoves;
00395 bsRemoves.ToolObject = TRUE;
00396 BlobMgr->RemoveInterest(bsRemoves);
00397 }
00398
00399
00400 CurrentTool = FALSE;
00401
00402 RenderToolBlobs(Document::GetSelectedSpread(), NULL);
00403 }
00404 }
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421 BOOL SoftShadowTool::CreateCursors()
00422 {
00423
00424 pcNormalSoftShadowCursor = new Cursor(this, _R(IDC_SOFTSHADOWTOOLCURSOR));
00425 pcBlobSoftShadowCursor = new Cursor(this, _R(IDC_SOFTSHADOWBLOBCURSOR));
00426
00427 if ( pcNormalSoftShadowCursor==NULL || !pcNormalSoftShadowCursor->IsValid() ||
00428 pcBlobSoftShadowCursor==NULL || !pcBlobSoftShadowCursor->IsValid())
00429 {
00430 DestroyCursors();
00431 return FALSE;
00432 }
00433 else
00434 return TRUE;
00435 }
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452 void SoftShadowTool::DestroyCursors()
00453 {
00454 if (pcNormalSoftShadowCursor != NULL) delete pcNormalSoftShadowCursor;
00455 if (pcBlobSoftShadowCursor != NULL) delete pcBlobSoftShadowCursor ;
00456 }
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476 void SoftShadowTool::OnClick( DocCoord PointerPos, ClickType cType,
00477 ClickModifiers cMods, Spread* pSpread )
00478 {
00479 if (cMods.Menu) return;
00480
00481 switch (cType)
00482 {
00483
00484 case CLICKTYPE_DRAG:
00485 {
00486 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_DRAGCREATESHADOW);
00487 DragCreateShadowParam DragParam(this, pSoftShadowInfoBarOp, PointerPos, cMods);
00488 if (pOpDesc != NULL)
00489 pOpDesc->Invoke(&DragParam);
00490 }
00491 break;
00492 default:
00493 {
00494
00495
00496 DragTool::OnClick (PointerPos, cType, cMods, pSpread);
00497 }
00498 break;
00499 }
00500 }
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523 void SoftShadowTool::OnMouseMove(DocCoord PointerPos, Spread* pSpread, ClickModifiers ClickMods)
00524 {
00525 String_256 strFeedback;
00526 BOOL bShadowingOn = FigureUserFeedback(&strFeedback, pSpread, PointerPos, ClickMods);
00527
00528
00529 if (bShadowingOn)
00530 {
00531 if (pcCurrentCursor != pcBlobSoftShadowCursor)
00532 {
00533 CursorStack::GSetTop(pcBlobSoftShadowCursor, CurrentCursorID);
00534 pcCurrentCursor = pcBlobSoftShadowCursor;
00535 }
00536 }
00537
00538
00539 else
00540 {
00541 if (pcCurrentCursor != pcNormalSoftShadowCursor)
00542 {
00543 CursorStack::GSetTop(pcNormalSoftShadowCursor, CurrentCursorID);
00544 pcCurrentCursor = pcNormalSoftShadowCursor;
00545 }
00546 }
00547
00548
00549 GetApplication()->UpdateStatusBarText(&strFeedback);
00550 }
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570 BOOL SoftShadowTool::GetStatusLineText(String_256* ptext, Spread* pSpread, DocCoord DocPos, ClickModifiers ClickMods)
00571 {
00572
00573 String_256 strFeedback;
00574 FigureUserFeedback(&strFeedback, pSpread, DocPos, ClickMods);
00575
00576 *ptext += strFeedback;
00577 return TRUE;
00578 }
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596 BOOL SoftShadowTool::FigureUserFeedback(String_256* pText, Spread* pSpread,
00597 const DocCoord& dcPos, ClickModifiers cMods)
00598 {
00599 NodeRenderableInk* pTargetInk = NodeRenderableInk::FindSimpleAtPoint(pSpread, dcPos);
00600
00601 if (pTargetInk == NULL)
00602 {
00603
00604
00605 pText->Empty();
00606 pText->Load(_R(IDS_SHADOWSTATUS_MOVEPOINTER));
00607 return FALSE;
00608 }
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619 if (pTargetInk->IsAShadow())
00620 {
00621 NodeShadowController* pControl = (NodeShadowController*)((NodeShadow*)pTargetInk)->GetParentController();
00622 if (pControl != NULL)
00623 {
00624 ShadowType sType = pControl->GetShadowType();
00625 UINT32 StatusID = 0;
00626 StatusID = (sType == SHADOWTYPE_WALL) ? _R(IDS_SHADOWSTATUS_DRAGWALLSHADOWS) :
00627 (sType == SHADOWTYPE_FLOOR) ? _R(IDS_SHADOWSTATUS_DRAGFLOORSHADOWS) :
00628 (sType == SHADOWTYPE_GLOW) ? _R(IDS_SHADOWSTATUS_DRAGGLOWSHADOWS) :
00629 0;
00630 pText->Empty();
00631 if (StatusID != 0)
00632 pText->Load(StatusID);
00633 else
00634 ERROR3("Unrecognised shadow type!");
00635 }
00636 else
00637 {
00638 ERROR3("NodeShadow found without a NodeShadowController!");
00639 }
00640
00641 return TRUE;
00642 }
00643
00644 pText->Empty();
00645 pText->Load(_R(IDS_SHADOWSTATUS_DRAGTOSHADOW));
00646
00647 return TRUE;
00648 }
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669 ListRange* SoftShadowTool::GetShadowEditRange(NodeShadowController** ppMasterShadow)
00670 {
00671
00672
00673 if (m_pEditRange==NULL)
00674 SetShadowEditRangeFromSelection();
00675
00676 if (m_pEditRange)
00677 {
00678 if (ppMasterShadow)
00679 {
00680 if (!m_pEditRange->IsEmpty())
00681 {
00682 ERROR3IF(!m_pEditRange->FindFirst()->IsAShadowController(), "Stored ShadowEditRange contains non-shadow");
00683 *ppMasterShadow = (NodeShadowController*)m_pEditRange->FindFirst();
00684 }
00685 else
00686 *ppMasterShadow = NULL;
00687 }
00688
00689 return m_pEditRange;
00690 }
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705 ERROR3("I don't think we should ever get here!");
00706
00707
00708 SelRange* pSelRange = GetApplication()->FindSelection();
00709 return pSelRange->GetTopClassRange(CC_RUNTIME_CLASS(NodeShadowController), TRUE, FALSE, (Node**)ppMasterShadow, NULL);
00710 }
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731 void SoftShadowTool::SetShadowEditRange(ListRange* pNewRange, INT32 iNewPos, BOOL bConsistent)
00732 {
00733 if (m_pEditRange && m_pEditRange != pNewRange)
00734 {
00735 delete m_pEditRange;
00736 m_pEditRange = NULL;
00737 }
00738
00739 m_iEditStackPos = iNewPos;
00740 if (pNewRange)
00741 m_pEditRange = new ListRange(pNewRange);
00742 else
00743 m_pEditRange = NULL;
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767 }
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787 void SoftShadowTool::SelectShadowRange(ListRange* pNewRange)
00788 {
00789 ERROR3IF(pNewRange==NULL, "SelectShadowRange not given range pointer");
00790
00791
00792
00793 ListRange myRange(pNewRange);
00794
00795 NodeRenderableInk::DeselectAll(TRUE, TRUE);
00796 Node* pNode = myRange.FindFirst();
00797 while (pNode)
00798 {
00799 if (pNode->IsAShadowController())
00800 {
00801 NodeShadowController* pController = (NodeShadowController*)pNode;
00802 if (pController->GetShadow())
00803 pController->GetShadow()->Select(TRUE);
00804 }
00805
00806 pNode = myRange.FindNext(pNode);
00807 }
00808
00809
00810 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::EFFECTSTACKCHANGED));
00811 }
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833 BOOL SoftShadowTool::SetShadowEditRangeFromSelection(BOOL bBroadcast)
00834 {
00835 SelRange mySelRange = *GetApplication()->FindSelection();
00836 mySelRange.SetPromoteToParent(FALSE);
00837
00838 LiveEffectsTool* pLETool = NULL;
00839 INT32 iPos = 0;
00840 EffectsStack* pStack = mySelRange.GetEffectsStack();
00841 Node* pNode = mySelRange.FindFirst();
00842
00843
00844
00845 ListRange* pShadowRange = new ListRange;
00846
00847 while (pNode)
00848 {
00849 if (pNode->IsAShadowController() && !pShadowRange->Contains(pNode))
00850 pShadowRange->AddNode(pNode);
00851
00852 else if (pNode->IsAShadow())
00853 {
00854 NodeShadow* pShadow = (NodeShadow*)pNode;
00855 ERROR3IF(pShadow->GetParentController()==NULL, "Shadow has no controller!");
00856 if (!pShadowRange->Contains(pShadow->GetParentController()))
00857 pShadowRange->AddNode(pShadow->GetParentController());
00858 }
00859
00860 else
00861 {
00862 Node* pParent = pNode->FindParent();
00863 NodeShadowController* pTopController = NULL;
00864 while (pParent && (pParent->IsEffect() || pParent->IsController()))
00865 {
00866 if (pParent->IsAShadowController())
00867 pTopController = (NodeShadowController*)pParent;
00868
00869 pParent = pParent->FindParent();
00870 }
00871 if (pTopController && !pShadowRange->Contains(pTopController))
00872 pShadowRange->AddNode(pTopController);
00873 }
00874
00875 pNode = mySelRange.FindNext(pNode);
00876 }
00877
00878
00879 if (m_pEditRange)
00880 {
00881 delete m_pEditRange;
00882 m_pEditRange = NULL;
00883 }
00884
00885
00886 while (iPos < (INT32)pStack->GetCount())
00887 {
00888 if (pShadowRange->MatchesSelectionEffectLevel(iPos))
00889 break;
00890
00891 iPos++;
00892 }
00893 if (iPos >= (INT32)pStack->GetCount())
00894 iPos = STACKPOS_INVALID;
00895
00896
00897 m_iEditStackPos = iPos;
00898 m_pEditRange = pShadowRange;
00899 pLETool = (LiveEffectsTool*)Tool::FindTool(TOOLID_LIVEEFFECT);
00900 if (pLETool)
00901 {
00902 pLETool->SetCurrentEffectID(POSTPRO_ID_SHADOW);
00903 pLETool->SetCurrentStackPos(iPos);
00904 }
00905
00906 if (bBroadcast)
00907 {
00908
00909 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::EFFECTSTACKCHANGED));
00910 }
00911 return TRUE;
00912
00913
00914
00915
00916
00917
00918 }
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939 NodeShadowController* SoftShadowTool::GetShadowEditField(ShadowMaskBits flags, String_256* pStrInfo)
00940 {
00941 BOOL bNone = TRUE;
00942 BOOL bConsistent = FALSE;
00943 BOOL bMany = FALSE;
00944 NodeShadowController* pMaster = NULL;
00945
00946 pMaster = GetShadowEditField(flags, &bNone, &bConsistent, &bMany);
00947
00948
00949 if (bNone && pStrInfo!=NULL)
00950 pStrInfo->Load(_R(IDS_SHADOWSTRING_NONE));
00951
00952
00953 if (bMany && pStrInfo!=NULL)
00954 pStrInfo->Load(_R(IDS_SHADOWSTRING_MANY));
00955
00956
00957 if (bConsistent && pStrInfo!=NULL)
00958 pStrInfo->Empty();
00959
00960 return pMaster;
00961 }
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982 NodeShadowController* SoftShadowTool::GetShadowEditField(ShadowMaskBits flags, BOOL* pbNone, BOOL* pbConsistent, BOOL* pbMany)
00983 {
00984 ERROR3IF(pbNone==NULL, "!1");
00985 ERROR3IF(pbConsistent==NULL, "!2");
00986 ERROR3IF(pbMany==NULL, "!3");
00987
00988 *pbNone = TRUE;
00989 *pbConsistent = FALSE;
00990 *pbMany = FALSE;
00991
00992 Range* pRange = GetShadowEditRange();
00993 if (pRange==NULL || pRange->IsEmpty())
00994 return NULL;
00995
00996 *pbNone = FALSE;
00997
00998 NodeShadowController* pMaster = NULL;
00999 Node* pNode = pRange->FindFirst();
01000 ShadowFieldMask mask(flags);
01001 while (pNode)
01002 {
01003 ENSURE(pNode->IsAShadowController(), "Expected a NodeShadowController in GetShadowField");
01004
01005 if (pMaster==NULL)
01006 pMaster = (NodeShadowController*)pNode;
01007 else
01008 {
01009 *pbMany = TRUE;
01010 if (!pMaster->CompareState((NodeShadowController*)pNode, mask))
01011 return NULL;
01012 }
01013
01014 pNode = pRange->FindNext(pNode);
01015 }
01016
01017 *pbConsistent = TRUE;
01018 return pMaster;
01019 }
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041 BOOL SoftShadowTool::OnKeyPress(KeyPress* pKey)
01042 {
01043
01044 ClickModifiers ClickMods = ClickModifiers::GetClickModifiers();
01045
01046 switch (pKey->GetVirtKey())
01047 {
01048 case CAMKEY(1):
01049 if (pKey->IsPress() && !pKey->IsModified())
01050 {
01051 pSoftShadowInfoBarOp->HandleShadowTypeChange(SHADOWTYPE_NONE);
01052 return TRUE;
01053 }
01054 break;
01055
01056 case CAMKEY(2):
01057 if (pKey->IsPress() && !pKey->IsModified())
01058 {
01059 pSoftShadowInfoBarOp->HandleShadowTypeChange(SHADOWTYPE_WALL);
01060 return TRUE;
01061 }
01062 break;
01063
01064 case CAMKEY(3):
01065 if (pKey->IsPress() && !pKey->IsModified())
01066 {
01067 pSoftShadowInfoBarOp->HandleShadowTypeChange(SHADOWTYPE_FLOOR);
01068 return TRUE;
01069 }
01070 break;
01071
01072 case CAMKEY(4):
01073 if (pKey->IsPress() && !pKey->IsModified())
01074 {
01075 pSoftShadowInfoBarOp->HandleShadowTypeChange(SHADOWTYPE_GLOW);
01076 return TRUE;
01077 }
01078 break;
01079
01080 case CAMKEY(5):
01081 if (pKey->IsPress() && !pKey->IsModified())
01082 {
01083 pSoftShadowInfoBarOp->HandleShadowTypeChange(SHADOWTYPE_FEATHER);
01084 return TRUE;
01085 }
01086 break;
01087
01088 case CAMKEY(A):
01089 if (pKey->IsPress() && !pKey->IsModified())
01090 {
01091 pSoftShadowInfoBarOp->SelectShadowsAlone();
01092 return TRUE;
01093 }
01094 break;
01095 }
01096
01097 return FALSE;
01098 }
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118 OpDragCreateShadow2::OpDragCreateShadow2()
01119 {
01120 m_pInfoBar = NULL;
01121 m_pTool = NULL;
01122 m_plInitialShadowSettings = NULL;
01123 m_pOwnedRange = NULL;
01124 }
01125
01126
01127
01128
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138 OpDragCreateShadow2::~OpDragCreateShadow2()
01139 {
01140 m_pInfoBar = NULL;
01141 m_pTool = NULL;
01142 if (m_plInitialShadowSettings != NULL)
01143 {
01144 m_plInitialShadowSettings->DeleteAll();
01145 delete m_plInitialShadowSettings;
01146 m_plInitialShadowSettings = NULL;
01147 }
01148
01149 if (m_pOwnedRange)
01150 {
01151 delete m_pOwnedRange;
01152 m_pOwnedRange = NULL;
01153 }
01154 }
01155
01156
01157
01158
01159
01160
01161
01162
01163
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173
01174
01175
01176
01177
01178
01179
01180
01181
01182
01183
01184
01185
01186
01187
01188 void OpDragCreateShadow2::DoWithParam(OpDescriptor* pOpDesc, OpParam* pOpParam)
01189 {
01190
01191
01192
01193 DoStartSelOp(FALSE, FALSE, FALSE, FALSE);
01194
01195
01196 DragCreateShadowParam* pParam = (DragCreateShadowParam*)pOpParam;
01197
01198 m_pInfoBar = pParam->m_pInfoBar;
01199 m_pTool = pParam->m_pTool;
01200 m_InitialPointerPos = pParam->m_PointerPos;
01201
01202 m_pMasterShadow = NULL;
01203 if (m_plInitialShadowSettings != NULL)
01204 {
01205 m_plInitialShadowSettings->DeleteAll();
01206 delete m_plInitialShadowSettings;
01207 m_plInitialShadowSettings = NULL;
01208 }
01209
01210
01211
01212
01213 NodeRenderableInk* pTargetInk = NodeRenderableInk::FindSimpleAtPoint(Document::GetSelectedSpread(),
01214 m_InitialPointerPos);
01215 if (pTargetInk == NULL)
01216 {
01217 NodeRenderableInk::DeselectAll(TRUE, TRUE);
01218 End();
01219 return;
01220 }
01221 NodeRenderableInk* pTargetCompound = NodeRenderableInk::FindCompoundFromSimple(pTargetInk);
01222 NodeCompound* pController = pTargetInk->GetParentController();
01223 BOOL bControllerOfSelected = FALSE;
01224 if (pController)
01225 bControllerOfSelected = pController->IsParentOfSelected();
01226
01227
01228
01229
01230
01231
01232
01233
01234
01235
01236 ListRange* pShadowRange = NULL;
01237
01238
01239
01240 m_pTool->GetShadowEditRange(&m_pMasterShadow);
01241
01242
01243 if (pTargetInk->IsAShadow())
01244 {
01245 Node* pShadowedInk = NULL;
01246 if (pController && pController->IsAShadowController())
01247 {
01248 pShadowedInk = ((NodeShadowController*)pController)->GetInkNodeFromController();
01249 }
01250
01251 if (pTargetInk->IsSelected() || pShadowedInk->IsSelected())
01252 {
01253
01254 }
01255 else
01256 {
01257
01258
01259 NodeRenderableInk::DeselectAll(TRUE, TRUE);
01260 pTargetInk->Select(TRUE);
01261 m_pTool->SetShadowEditRangeFromSelection();
01262 m_pTool->GetShadowEditRange(&m_pMasterShadow);
01263 }
01264 }
01265 else
01266 {
01267 if (pTargetCompound->IsSelected())
01268 {
01269
01270 }
01271 else
01272 {
01273
01274 NodeRenderableInk::DeselectAll(TRUE, TRUE);
01275 pTargetCompound->Select(TRUE);
01276 m_pTool->SetShadowEditRangeFromSelection();
01277 m_pTool->GetShadowEditRange(&m_pMasterShadow);
01278 }
01279 }
01280
01281
01282
01283
01284
01285 if (m_pMasterShadow == NULL || pParam->m_ClickMods.Adjust)
01286 {
01287
01288 NodeShadowParam NSParam(NodeShadowController::DefaultType);
01289 Range TempRange(*GetApplication()->FindSelection());
01290 TempRange.SetPromoteToParent(TRUE);
01291 pShadowRange = OpApplyShadow::DoApplyShadow(this, &TempRange, &NSParam);
01292 m_pOwnedRange = pShadowRange;
01293 m_pTool->SetShadowEditRange(pShadowRange, STACKPOS_TOP, TRUE);
01294
01295
01296
01297
01298 if (pShadowRange == NULL)
01299 {
01300 FailAndExecute();
01301 End();
01302 return;
01303 }
01304
01305 m_pMasterShadow = (NodeShadowController*)pShadowRange->FindFirst();
01306 if (m_pMasterShadow == NULL)
01307 {
01308 FailAndExecute();
01309 End();
01310 return;
01311 }
01312
01313 SliceHelper::AddNamesToController(this, m_pMasterShadow);
01314 }
01315 else
01316 {
01317
01318
01319 pShadowRange = m_pTool->GetShadowEditRange();
01320 Node* pNode = pShadowRange->FindFirst();
01321
01322 BOOL bOK;
01323 while (pNode)
01324 {
01325 if (pNode->IsAShadowController())
01326 {
01327 bOK = m_pMasterShadow->CompareState((NodeShadowController*)pNode) && SaveSettings((NodeShadowController*)pNode);
01328 if (!bOK)
01329 {
01330 FailAndExecute();
01331 End();
01332 return;
01333 }
01334 }
01335 else
01336 {
01337 FailAndExecute();
01338 End();
01339 return;
01340 }
01341
01342 pNode = pShadowRange->FindNext(pNode);
01343 }
01344 }
01345
01346
01347
01348 if (m_pMasterShadow == NULL)
01349 {
01350 ERROR3("OpDragCreateShadow2::DoWithParam; Selection problem");
01351 FailAndExecute();
01352 End();
01353 return;
01354 }
01355
01356
01357 pShadowRange = m_pTool->GetShadowEditRange();
01358 Node* pNode = pShadowRange->FindFirst();
01359
01360 BOOL bOK;
01361 bOK = DoInvalidateNodesRegions(*pShadowRange, TRUE, FALSE, FALSE, FALSE);
01362 if (!bOK)
01363 {
01364 FailAndExecute();
01365 End();
01366 return;
01367 }
01368
01369 while (pNode)
01370 {
01371 if (pNode->IsAShadowController())
01372 {
01373 NodeShadowController* pController = (NodeShadowController*)pNode;
01374
01375 pController->ReleaseCached(TRUE, FALSE, FALSE, FALSE);
01376 }
01377
01378 pNode = pShadowRange->FindNext(pNode);
01379 }
01380
01381
01382 m_InitialGlowWidth = m_pMasterShadow->GetGlowWidth();
01383 m_dcInitialWallOffset = m_pMasterShadow->GetWallShadowOffset();
01384 m_dcInitialFloorShadowVector = m_pMasterShadow->GetFloorShadowVector();
01385 m_InitialFeatherWidth = m_pMasterShadow->GetFeatherWidth();
01386
01387
01388 if (m_pInfoBar != NULL)
01389 m_pInfoBar->UpdateAllGadgets();
01390
01391
01392 Operation::SetQuickRender(TRUE);
01393
01394
01395 StartDrag(DRAGTYPE_AUTOSCROLL);
01396 }
01397
01398
01399
01400
01401
01402
01403
01404
01405
01406
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416 NodeRenderableInk* OpDragCreateShadow2::GetSelectedShadowFromNode(NodeRenderableInk* pClickedNode)
01417 {
01418 Node* pUpNode = pClickedNode->FindParent();
01419 while (pUpNode && (pUpNode->IsAShadowController() || pUpNode->IsNodeHidden()))
01420 {
01421 if (pUpNode->IsAShadowController())
01422 {
01423 NodeShadowController* pController = (NodeShadowController*)pUpNode;
01424 NodeShadow* pShadow = pController->GetShadow();
01425 if (pShadow && pShadow->IsSelected())
01426 {
01427 return pShadow;
01428 }
01429 }
01430
01431 pUpNode = pUpNode->FindParent();
01432 }
01433
01434 return NULL;
01435 }
01436
01437
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459 void OpDragCreateShadow2::DragPointerMove( DocCoord PointerPos,
01460 ClickModifiers ClickMods,
01461 Spread* pSpread, BOOL bSolidDrag)
01462 {
01463
01464
01465
01466
01467 DocRect drBaseRect = m_pMasterShadow->GetInsideBoundingRect();
01468
01469
01470 DocCoord dcTotalOffset = PointerPos - m_InitialPointerPos;
01471
01472
01473 switch (m_pMasterShadow->GetShadowType())
01474 {
01475
01476 case SHADOWTYPE_WALL:
01477 {
01478 DocCoord dcControlOffset = m_dcInitialWallOffset + dcTotalOffset;
01479
01480
01481 ChangeAllShadows(&dcControlOffset, NULL, 0, SHADOWTYPE_WALL);
01482
01483
01484
01485
01486 m_pInfoBar->UpdateGadgetPositionShadowX();
01487 m_pInfoBar->UpdateGadgetPositionShadowY();
01488 }
01489 break;
01490
01491
01492
01493
01494
01495
01496
01497
01498 case SHADOWTYPE_FLOOR:
01499 {
01500 DocCoord BaseCentre((drBaseRect.hi.x + drBaseRect.lo.x) / 2, drBaseRect.lo.y);
01501 DocCoord InitVector = m_InitialPointerPos - BaseCentre;
01502
01503
01504 if (InitVector.y > 0)
01505 {
01506 DocCoord NewVector = PointerPos - BaseCentre;
01507
01508 const double alpha = (double)m_dcInitialFloorShadowVector.y / (double)InitVector.y;
01509 const double offx = (double)m_dcInitialFloorShadowVector.x - ((double)InitVector.x * alpha);
01510
01511 DocCoord dcControlVector((MILLIPOINT)(0.5 + (double)NewVector.x * alpha + offx),
01512 (MILLIPOINT)(0.5 + (double)NewVector.y * alpha) );
01513
01514
01515 ChangeAllShadows(NULL, &dcControlVector, 0, SHADOWTYPE_FLOOR);
01516 }
01517 }
01518 break;
01519
01520
01521
01522
01523
01524
01525
01526 case SHADOWTYPE_GLOW:
01527 {
01528 if (m_InitialPointerPos.x < drBaseRect.Centre().x)
01529 dcTotalOffset.x = -dcTotalOffset.x;
01530
01531 if (m_InitialPointerPos.y < drBaseRect.Centre().y)
01532 dcTotalOffset.y = -dcTotalOffset.y;
01533
01534 MILLIPOINT GlowWidth = m_InitialGlowWidth + (dcTotalOffset.x + dcTotalOffset.y);
01535
01536 if (GlowWidth < 0)
01537 GlowWidth = 0;
01538
01539
01540 ChangeAllShadows(NULL, NULL, GlowWidth, SHADOWTYPE_GLOW);
01541 }
01542 break;
01543
01544 case SHADOWTYPE_FEATHER:
01545 {
01546 if (m_InitialPointerPos.x < drBaseRect.Centre().x)
01547 dcTotalOffset.x = -dcTotalOffset.x;
01548
01549 if (m_InitialPointerPos.y < drBaseRect.Centre().y)
01550 dcTotalOffset.y = -dcTotalOffset.y;
01551
01552 MILLIPOINT FeatherWidth = m_InitialFeatherWidth + (dcTotalOffset.x + dcTotalOffset.y);
01553
01554 if (FeatherWidth < 0)
01555 FeatherWidth = 0;
01556
01557
01558 ChangeAllShadows(NULL, NULL, FeatherWidth, SHADOWTYPE_FEATHER);
01559 }
01560 break;
01561
01562 default:
01563 ERROR3("OpDragCreateShadow2::DragPointerMove; found an unrecognised shadow type!");
01564 return;
01565 }
01566 }
01567
01568
01569
01570
01571
01572
01573
01574
01575
01576
01577
01578
01579
01580
01581
01582
01583
01584
01585
01586
01587
01588
01589
01590 void OpDragCreateShadow2::DragFinished( DocCoord PointerPos, ClickModifiers ClickMods,
01591 Spread* pSpread, BOOL bSuccess, BOOL bSolidDrag)
01592 {
01593
01594 EndDrag();
01595
01596
01597 Operation::SetQuickRender(FALSE);
01598
01599
01600
01601
01602
01603
01604
01605
01606 if (bSuccess)
01607 {
01608 if (m_plInitialShadowSettings != NULL && !m_plInitialShadowSettings->IsEmpty() )
01609 {
01610 ActionCode ac = SaveShadowSettingsAction::Init( this, GetUndoActionList(),
01611 m_plInitialShadowSettings );
01612 if (ac == AC_FAIL)
01613 bSuccess = FALSE;
01614 else
01615 m_plInitialShadowSettings = NULL;
01616 }
01617 }
01618
01619 if (m_pOwnedRange)
01620 {
01621 delete m_pOwnedRange;
01622 m_pOwnedRange = NULL;
01623 }
01624
01625
01626
01627 if (!bSuccess)
01628 {
01629
01630 ListRange* pShadowRange = m_pTool->GetShadowEditRange();
01631 Node* pNode = pShadowRange->FindFirst();
01632 DocRect drInvalidRegion;
01633 while (pNode)
01634 {
01635 ENSURE(pNode->IsAShadowController(), "Unexpected node type in ChangeAllShadows");
01636 NodeShadowController* pShadowController = (NodeShadowController*)pNode;
01637 NodeShadow* pNodeShadow = pShadowController->GetShadow();
01638 drInvalidRegion = drInvalidRegion.Union(pShadowController->GetEffectStackBounds());
01639 pShadowController->ReleaseCached(TRUE, FALSE, FALSE, TRUE);
01640
01641
01642 drInvalidRegion = drInvalidRegion.Union(pNodeShadow->GetBlobBoundingRect());
01643
01644 pNode = pShadowRange->FindNext(pNode);
01645 }
01646
01647
01648 Document* pDoc = Document::GetCurrent();
01649 Spread* pSpread = pDoc->GetSelectedSpread();
01650 if (pDoc != NULL && pSpread != NULL)
01651 {
01652 pDoc->ForceRedraw(pSpread, drInvalidRegion, FALSE, NULL, FALSE);
01653 }
01654
01655 RestoreSavedSettings();
01656 FailAndExecute();
01657 }
01658 else
01659 {
01660
01661 EffectsStack* pStack = GetApplication()->FindSelection()->GetEffectsStack();
01662 ENSURE(pStack, "Something's gone seriously wrong");
01663 if (!pStack->NodeInTopLevel(m_pMasterShadow))
01664 {
01665 ListRange* pShadowRange = m_pTool->GetShadowEditRange();
01666 DoInvalidateNodesRegions(*pShadowRange, TRUE);
01667 }
01668 }
01669
01670
01671 End();
01672 }
01673
01674
01675
01676
01677
01678
01679
01680
01681
01682
01683
01684
01685
01686
01687
01688
01689 BOOL OpDragCreateShadow2::Declare()
01690 {
01691 return (RegisterOpDescriptor(
01692 0,
01693 _R(IDS_DRAGCREATESHADOWOP),
01694 CC_RUNTIME_CLASS(OpDragCreateShadow2),
01695 OPTOKEN_DRAGCREATESHADOW,
01696 OpDragCreateShadow2::GetState));
01697 }
01698
01699
01700
01701
01702
01703
01704
01705
01706
01707
01708
01709
01710
01711
01712
01713
01714 OpState OpDragCreateShadow2::GetState(String_256* pstrDescription, OpDescriptor* pOpDesc)
01715 {
01716 OpState DefaultOpSt;
01717 return DefaultOpSt;
01718 }
01719
01720
01721
01722
01723
01724
01725
01726
01727
01728
01729
01730
01731
01732
01733
01734
01735
01736
01737
01738
01739
01740
01741
01742
01743
01744
01745
01746
01747
01748
01749
01750
01751
01752 void OpDragCreateShadow2::ChangeAllShadows( DocCoord* pdcWallOffset,
01753 DocCoord* pdcFloorVector,
01754 MILLIPOINT GlowWidth, ShadowType ChangeType )
01755 {
01756
01757
01758 MILLIPOINT FeatherWidth = GlowWidth;
01759 BOOL fInvalidParams = FALSE;
01760 double dFloorShadowAngle = 0;
01761 double dFloorShadowHeight = 0;
01762 switch (ChangeType)
01763 {
01764 case SHADOWTYPE_WALL:
01765
01766 fInvalidParams = (pdcWallOffset == NULL);
01767 break;
01768 case SHADOWTYPE_FLOOR:
01769
01770 fInvalidParams = (pdcFloorVector == NULL);
01771 if (pdcFloorVector)
01772 {
01773
01774 INT32 BaseHeight = m_pMasterShadow->GetInsideBoundingRect().Height();
01775 if (BaseHeight > 0)
01776 dFloorShadowHeight = (double)pdcFloorVector->y / (double)BaseHeight;
01777 else
01778 dFloorShadowHeight = 1.0;
01779
01780 if (dFloorShadowHeight > MAXSHADOWHEIGHT)
01781 dFloorShadowHeight = MAXSHADOWHEIGHT;
01782 else if (dFloorShadowHeight < 0.01)
01783 dFloorShadowHeight = 0.01;
01784
01785
01786
01787
01788 dFloorShadowAngle = pdcFloorVector->AngleFromVertical();
01789 if (dFloorShadowAngle < -MAXSHADOWANGLE)
01790 dFloorShadowAngle = -MAXSHADOWANGLE;
01791 else if (dFloorShadowAngle > MAXSHADOWANGLE)
01792 dFloorShadowAngle = MAXSHADOWANGLE;
01793 }
01794 break;
01795 case SHADOWTYPE_GLOW:
01796
01797 fInvalidParams = (GlowWidth < 0);
01798 break;
01799 case SHADOWTYPE_FEATHER:
01800
01801 fInvalidParams = (FeatherWidth < 0);
01802 break;
01803 default:
01804
01805 fInvalidParams = TRUE;
01806 break;
01807 }
01808 ERROR3IF(fInvalidParams, "OpDragCreateShadow2::ChangeAllShadows; Invalid input params!");
01809
01810
01811 DocRect drInvalidRegion;
01812
01813
01814 NodeShadowController* pShadowController = NULL;
01815 NodeShadow* pNodeShadow = NULL;
01816 ENSURE(!drInvalidRegion.IsValid() || drInvalidRegion.IsEmpty(), "bounding rect should be invalid before loop!");
01817
01818
01819 ListRange* pShadowRange = m_pTool->GetShadowEditRange();
01820 Node* pNode = pShadowRange->FindFirst();
01821 while (pNode)
01822 {
01823 ENSURE(pNode->IsAShadowController(), "Unexpected node type in ChangeAllShadows");
01824 pShadowController = (NodeShadowController*)pNode;
01825 pNodeShadow = pShadowController->GetShadow();
01826 drInvalidRegion = drInvalidRegion.Union(pShadowController->GetEffectStackBounds());
01827 pShadowController->ReleaseCached(TRUE, FALSE, FALSE, TRUE);
01828
01829 if (pShadowController->GetShadowType() == ChangeType)
01830 {
01831
01832 drInvalidRegion = drInvalidRegion.Union(pNodeShadow->GetBlobBoundingRect());
01833
01834
01835 switch (ChangeType)
01836 {
01837 case SHADOWTYPE_WALL:
01838 {
01839 pShadowController->SetWallShadowOffset(*pdcWallOffset, TRUE);
01840 }
01841 break;
01842
01843 case SHADOWTYPE_FLOOR:
01844 {
01845
01846 pShadowController->SetFloorShadowAngle(dFloorShadowAngle);
01847 pShadowController->SetFloorShadowHeight(dFloorShadowHeight);
01848 pShadowController->RegenerateNode(NULL);
01849 }
01850 break;
01851
01852 case SHADOWTYPE_GLOW:
01853 {
01854 pShadowController->SetGlowWidth(GlowWidth);
01855 pShadowController->RegenerateNode(NULL);
01856 }
01857 break;
01858
01859 case SHADOWTYPE_FEATHER:
01860 {
01861 pShadowController->SetFeatherWidth(FeatherWidth);
01862 pShadowController->RegenerateNode(NULL);
01863 }
01864 break;
01865
01866 default:
01867
01868 break;
01869 }
01870
01871
01872 drInvalidRegion = drInvalidRegion.Union(pNodeShadow->GetBlobBoundingRect());
01873 }
01874
01875
01876
01877
01878 {
01879 for (Node* pParent = pShadowController;
01880 pParent != NULL && pParent->IsAnObject();
01881 pParent = pParent->FindParent() )
01882 {
01883 for (NodeAttribute* pGLA = pParent->FindFirstGeometryLinkedAttr();
01884 pGLA != NULL;
01885 pGLA = pGLA->FindNextGeometryLinkedAttr() )
01886 {
01887 pGLA->LinkedNodeGeometryHasChanged(this);
01888 }
01889 }
01890 }
01891
01892 pNode = pShadowRange->FindNext(pNode);
01893 }
01894
01895
01896 Document* pDoc = Document::GetCurrent();
01897 Spread* pSpread = pDoc->GetSelectedSpread();
01898 if (pDoc != NULL && pSpread != NULL)
01899 {
01900 pDoc->ForceRedraw(pSpread, drInvalidRegion, FALSE, NULL, FALSE);
01901 GetApplication()->ServiceRendering();
01902 }
01903 }
01904
01905
01906
01907
01908
01909
01910
01911
01912
01913
01914
01915
01916
01917
01918
01919
01920
01921
01922
01923
01924
01925
01926
01927 BOOL OpDragCreateShadow2::SaveSettings(Range* pShadowRange)
01928 {
01929 ERROR3IF(pShadowRange == NULL, "OpDragCreateShadow2::SaveSettings; NULL input params!");
01930
01931 NodeShadowController* pController = (NodeShadowController*)pShadowRange->FindFirst();
01932 while (pController)
01933 {
01934 BOOL bOK = SaveSettings(pController);
01935 if (!bOK)
01936 return FALSE;
01937
01938 pController = (NodeShadowController*)pShadowRange->FindNext(pController);
01939 }
01940
01941 return TRUE;
01942 }
01943
01944
01945
01946
01947
01948
01949
01950
01951
01952
01953
01954
01955
01956
01957
01958
01959
01960
01961
01962
01963
01964
01965
01966 BOOL OpDragCreateShadow2::SaveSettings(NodeShadowController* pShadow)
01967 {
01968 ERROR3IF(pShadow == NULL, "OpDragCreateShadow2::SaveSettings; NULL input params!");
01969
01970 if (m_plInitialShadowSettings == NULL)
01971 {
01972 ALLOC_WITH_FAIL(m_plInitialShadowSettings, new List, this);
01973 if (m_plInitialShadowSettings == NULL)
01974 return FALSE;
01975 }
01976
01977 ShadowSettingsItem* pShadowSettings = NULL;
01978 ALLOC_WITH_FAIL(pShadowSettings, new ShadowSettingsItem(pShadow), this);
01979 if (pShadowSettings == NULL)
01980 return FALSE;
01981
01982 switch (pShadow->GetShadowType())
01983 {
01984 case SHADOWTYPE_WALL:
01985 pShadowSettings->dcWallOffset = pShadow->GetWallShadowOffset();
01986 break;
01987 case SHADOWTYPE_FLOOR:
01988 pShadowSettings->dcFloorVector = pShadow->GetFloorShadowVector();
01989 break;
01990 case SHADOWTYPE_GLOW:
01991 pShadowSettings->GlowWidth = pShadow->GetGlowWidth();
01992 break;
01993 case SHADOWTYPE_FEATHER:
01994 pShadowSettings->FeatherWidth = pShadow->GetFeatherWidth();
01995 break;
01996 default:
01997 ERROR3("OpDragCreateShadow2::SaveSettings; unrecognised shadow type!");
01998 break;
01999 }
02000
02001 m_plInitialShadowSettings->AddTail(pShadowSettings);
02002
02003 return TRUE;
02004 }
02005
02006
02007
02008
02009
02010
02011
02012
02013
02014
02015
02016
02017
02018
02019
02020
02021
02022
02023
02024
02025
02026 void OpDragCreateShadow2::RestoreSavedSettings()
02027 {
02028
02029 if (m_plInitialShadowSettings == NULL || m_plInitialShadowSettings->IsEmpty())
02030 return;
02031
02032
02033 DocRect drInvalidRegion;
02034
02035
02036 ShadowSettingsItem* pShadowSettings = (ShadowSettingsItem*)m_plInitialShadowSettings->GetHead();
02037 NodeShadowController* pShadowController = pShadowSettings->pShadow;
02038 NodeShadow* pNodeShadow = pShadowController->GetShadow();
02039 drInvalidRegion = pNodeShadow->GetBlobBoundingRect();
02040
02041
02042 while (pShadowSettings != NULL)
02043 {
02044 pShadowController = pShadowSettings->pShadow;
02045 pNodeShadow = pShadowController->GetShadow();
02046 drInvalidRegion = drInvalidRegion.Union(pShadowController->GetEffectStackBounds());
02047 pShadowController->ReleaseCached();
02048 pNodeShadow->ReleaseCached();
02049
02050
02051 drInvalidRegion = drInvalidRegion.Union(pNodeShadow->GetBlobBoundingRect());
02052
02053
02054 switch (pShadowController->GetShadowType())
02055 {
02056 case SHADOWTYPE_WALL:
02057 pShadowController->SetWallShadowOffset(pShadowSettings->dcWallOffset, TRUE);
02058 break;
02059 case SHADOWTYPE_FLOOR:
02060 pShadowController->SetFloorShadowVector(pShadowSettings->dcFloorVector);
02061 pShadowController->RegenerateNode(this);
02062 break;
02063 case SHADOWTYPE_GLOW:
02064 pShadowController->SetGlowWidth(pShadowSettings->GlowWidth);
02065 pShadowController->RegenerateNode(this);
02066 break;
02067 case SHADOWTYPE_FEATHER:
02068 pShadowController->SetFeatherWidth(pShadowSettings->FeatherWidth);
02069 pShadowController->RegenerateNode(this);
02070 break;
02071 default:
02072 ERROR3("OpDragCreateShadow2::RestoreSavedSettings; unrecognised shadow type!");
02073 break;
02074 }
02075
02076
02077 drInvalidRegion = drInvalidRegion.Union(pNodeShadow->GetBlobBoundingRect());
02078
02079 pShadowSettings = (ShadowSettingsItem*)m_plInitialShadowSettings->GetNext(pShadowSettings);
02080 }
02081
02082
02083 Document* pDoc = Document::GetCurrent();
02084 Spread* pSpread = pDoc->GetSelectedSpread();
02085 if (pDoc != NULL && pSpread != NULL)
02086 {
02087 pDoc->ForceRedraw(pSpread, drInvalidRegion);
02088 GetApplication()->ServiceRendering();
02089 }
02090 }
02091
02092
02093
02094
02095
02096
02097
02098
02099
02100
02101
02102
02103
02104
02105
02106
02107
02108
02109
02110 SaveShadowSettingsAction::SaveShadowSettingsAction()
02111 {
02112 m_plShadowSettings = NULL;
02113 }
02114
02115
02116
02117
02118
02119
02120
02121
02122
02123
02124
02125
02126 SaveShadowSettingsAction::~SaveShadowSettingsAction()
02127 {
02128 if (m_plShadowSettings != NULL)
02129 {
02130 m_plShadowSettings->DeleteAll();
02131 delete m_plShadowSettings;
02132 m_plShadowSettings = NULL;
02133 }
02134 }
02135
02136
02137
02138
02139
02140
02141
02142
02143
02144
02145
02146
02147
02148
02149
02150
02151
02152
02153
02154
02155
02156
02157
02158 ActionCode SaveShadowSettingsAction::Init( UndoableOperation* pUndoOp,
02159 ActionList* pActionList,
02160 List* plShadowSettings )
02161 {
02162
02163 ActionCode ac = AC_FAIL;
02164 UINT32 ActSize = sizeof(SaveShadowSettingsAction);
02165 SaveShadowSettingsAction* pNewAction = NULL;
02166 ac = Action::Init( pUndoOp,
02167 pActionList,
02168 ActSize,
02169 CC_RUNTIME_CLASS(SaveShadowSettingsAction),
02170 (Action**)&pNewAction );
02171
02172
02173
02174 if (ac != AC_FAIL && pNewAction != NULL)
02175 {
02176 pNewAction->SetShadowList(plShadowSettings);
02177 }
02178
02179 return ac;
02180 }
02181
02182
02183
02184
02185
02186
02187
02188
02189
02190
02191
02192
02193
02194
02195
02196
02197
02198 ActionCode SaveShadowSettingsAction::Execute()
02199 {
02200 List* plCurrentSettings = NULL;
02201 ALLOC_WITH_FAIL(plCurrentSettings, new List, pOperation);
02202 if (plCurrentSettings == NULL)
02203 return AC_FAIL;
02204
02205
02206
02207 ShadowSettingsItem* pOldSettings = NULL;
02208 ShadowSettingsItem* pNewSettings = (ShadowSettingsItem*)m_plShadowSettings->GetHead();
02209 while (pNewSettings != NULL)
02210 {
02211 NodeShadowController* pShadow = pNewSettings->pShadow;
02212
02213 pOldSettings = NULL;
02214 ALLOC_WITH_FAIL(pOldSettings, new ShadowSettingsItem(pShadow), pOperation);
02215 if (pOldSettings == NULL)
02216 {
02217 plCurrentSettings->DeleteAll();
02218 return AC_FAIL;
02219 }
02220
02221 switch (pShadow->GetShadowType())
02222 {
02223 case SHADOWTYPE_WALL:
02224 pOldSettings->dcWallOffset = pShadow->GetWallShadowOffset();
02225 break;
02226 case SHADOWTYPE_FLOOR:
02227 pOldSettings->dcFloorVector = pShadow->GetFloorShadowVector();
02228 break;
02229 case SHADOWTYPE_GLOW:
02230 pOldSettings->GlowWidth = pShadow->GetGlowWidth();
02231 break;
02232 case SHADOWTYPE_FEATHER:
02233 pOldSettings->FeatherWidth = pShadow->GetFeatherWidth();
02234 break;
02235 default:
02236 ERROR3("SaveShadowSettingsAction::Execute; unrecognised shadow type!");
02237 break;
02238 }
02239
02240 plCurrentSettings->AddTail(pOldSettings);
02241
02242 pNewSettings = (ShadowSettingsItem*)m_plShadowSettings->GetNext(pNewSettings);
02243 }
02244
02245
02246
02247 DocRect drInvalidRegion;
02248
02249 pNewSettings = (ShadowSettingsItem*)m_plShadowSettings->GetHead();
02250 NodeShadowController* pShadow = pNewSettings->pShadow;
02251 NodeShadow* pNodeShadow = pShadow->GetShadow();
02252 drInvalidRegion = pNodeShadow->GetBlobBoundingRect();
02253
02254 while (pNewSettings != NULL)
02255 {
02256 pShadow = pNewSettings->pShadow;
02257 pNodeShadow = pShadow->GetShadow();
02258 drInvalidRegion = drInvalidRegion.Union(pShadow->GetEffectStackBounds());
02259 pShadow->ReleaseCached();
02260 pNodeShadow->ReleaseCached();
02261
02262 drInvalidRegion = drInvalidRegion.Union(pNodeShadow->GetBlobBoundingRect());
02263
02264 switch (pShadow->GetShadowType())
02265 {
02266 case SHADOWTYPE_WALL:
02267 pShadow->SetWallShadowOffset(pNewSettings->dcWallOffset, TRUE);
02268 break;
02269 case SHADOWTYPE_FLOOR:
02270 pShadow->SetFloorShadowVector(pNewSettings->dcFloorVector);
02271 pShadow->RegenerateNode((UndoableOperation*)pOperation);
02272 break;
02273 case SHADOWTYPE_GLOW:
02274 pShadow->SetGlowWidth(pNewSettings->GlowWidth);
02275 pShadow->RegenerateNode((UndoableOperation*)pOperation);
02276 break;
02277 case SHADOWTYPE_FEATHER:
02278 pShadow->SetFeatherWidth(pNewSettings->FeatherWidth);
02279 pShadow->RegenerateNode((UndoableOperation*)pOperation);
02280 break;
02281 default:
02282 ERROR3("SaveShadowSettingsAction::Execute; unrecognised shadow type!");
02283 break;
02284 }
02285
02286 drInvalidRegion = drInvalidRegion.Union(pNodeShadow->GetBlobBoundingRect());
02287
02288
02289 pNewSettings = (ShadowSettingsItem*)m_plShadowSettings->GetNext(pNewSettings);
02290 }
02291
02292
02293 Document* pDoc = Document::GetCurrent();
02294 Spread* pSpread = pDoc->GetSelectedSpread();
02295 if (pDoc != NULL && pSpread != NULL)
02296 {
02297 pDoc->ForceRedraw(pSpread, drInvalidRegion);
02298 GetApplication()->ServiceRendering();
02299 }
02300
02301
02302 m_plShadowSettings->DeleteAll();
02303 delete m_plShadowSettings;
02304 m_plShadowSettings = NULL;
02305 return SaveShadowSettingsAction::Init( (UndoableOperation*)pOperation,
02306 pOppositeActLst,
02307 plCurrentSettings );
02308 }
02309
02310
02311
02312 #endif // BUILDSHADOWS