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 "layergal.h"
00105
00106 DECLARE_SOURCE("$Revision: 1282 $");
00107
00108
00109 #include "sprdmsg.h"
00110
00111
00112
00113
00114 #include "layermgr.h"
00115
00116 #include "insertnd.h"
00117
00118
00119
00120
00121 #include "guides.h"
00122 #include "nodetxts.h"
00123 #include "textops.h"
00124 #include "bubbleid.h"
00125 #include "ophist.h"
00126 #include "sglayer.h"
00127 #include "sginit.h"
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137 #include "nodetxts.h"
00138
00139 #include "layermsg.h"
00140
00141
00142 #define Swap(a,b) { (a)^=(b), (b)^=(a), (a)^=(b); }
00143
00144
00145
00146
00147 CC_IMPLEMENT_DYNCREATE(OpDeletePageBackground,OpLayerGalChange);
00148 CC_IMPLEMENT_DYNCREATE(OpLayerGalChange,UndoableOperation);
00149 CC_IMPLEMENT_DYNCREATE(OpDisplayLayerGallery,Operation);
00150 PORTNOTE("galleries", "disabled frame gallery")
00151 #ifndef EXCLUDE_FROM_XARALX
00152 CC_IMPLEMENT_DYNCREATE(OpDisplayFrameGallery,Operation);
00153 #endif
00154 CC_IMPLEMENT_DYNCREATE(LayerNameDlg, DialogOp)
00155 CC_IMPLEMENT_DYNCREATE(LayerStateAction,Action)
00156
00157 const CDlgMode LayerNameDlg::Mode = MODAL;
00158 const INT32 LayerNameDlg::IDD = _R(IDD_LAYER_NAME);
00159 BOOL LayerNameDlg::IsOpen = FALSE;
00160 LayerNameDlg* LayerNameDlg::pLayerNameDlg = NULL;
00161
00162
00163
00164 #define new CAM_DEBUG_NEW
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182 OpDeletePageBackground::OpDeletePageBackground()
00183 {
00184
00185 }
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202 OpState OpDeletePageBackground::GetState(String_256* pUIDescription, OpDescriptor* pOpDesc)
00203 {
00204 OpState OpSt;
00205
00206
00207 Spread * pSpread = Document::GetSelectedSpread();
00208 if (pSpread)
00209 {
00210
00211 Layer* pLayer = pSpread->FindFirstPageBackgroundLayer();
00212 if (pLayer)
00213 {
00214
00215 OpSt.Greyed = FALSE;
00216 }
00217 else
00218 {
00219
00220 OpSt.Greyed = TRUE;
00221 }
00222 }
00223 else
00224 {
00225
00226 OpSt.Greyed = TRUE;
00227 }
00228
00229 return OpSt;
00230 }
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247 void OpDeletePageBackground::Do(OpDescriptor* pOpDesc)
00248 {
00249
00250
00251 Spread * pSpread = Document::GetSelectedSpread();
00252 if (pSpread)
00253 {
00254
00255 Layer* pLayer = pSpread->FindFirstPageBackgroundLayer();
00256 if (pLayer)
00257 {
00258 OpLayerGalParam Param(PAGEBACKGROUND_DEFAULT, pSpread);
00259 Param.pLayer = pLayer;
00260 DoWithParam(pOpDesc, (OpParam*)&Param);
00261 }
00262 }
00263
00264 return;
00265 }
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286 OpLayerGalChange::OpLayerGalChange(): UndoableOperation()
00287 {
00288 pSpread = NULL;
00289 UndoIDS = _R(IDS_NOTYPE);
00290 BroadcastLayerChanges = TRUE;
00291 pOpUndoLayer = NULL;
00292 pOpRedoLayer = NULL;
00293 }
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313 BOOL OpLayerGalChange::Init()
00314 {
00315 return (
00316 RegisterOpDescriptor(
00317 0,
00318 _R(IDS_LAYERCHANGEOP),
00319 CC_RUNTIME_CLASS(OpLayerGalChange),
00320 OPTOKEN_LAYERGALCHANGE,
00321 OpLayerGalChange::GetState,
00322 0,
00323 _R(IDBBL_LAYERCHANGEOP),
00324 0
00325 ) &&
00326 RegisterOpDescriptor(
00327 0,
00328 _R(IDS_DELETEPAGEBACKGROUND),
00329 CC_RUNTIME_CLASS(OpDeletePageBackground),
00330 OPTOKEN_DELETEPAGEBACKGROUND,
00331 OpDeletePageBackground::GetState,
00332 0,
00333 0,
00334 0
00335 )
00336
00337 &&
00338 PORTNOTE("galleries", "Disabled frame stuff")
00339 #ifndef EXCLUDE_FROM_XARALX
00340 RegisterOpDescriptor(
00341 0,
00342 _R(IDS_SELECTSTARTFRAME),
00343 CC_RUNTIME_CLASS(OpSelectStartFrame),
00344 OPTOKEN_FRAME_STARTFRAME,
00345 OpSelectStartFrame::GetState,
00346 0,
00347 _R(IDBBL_SELECTSTARTFRAME),
00348 _R(IDD_ANIMATIONBAR),
00349 _R(IDC_PREVIEW_STARTFRAME),
00350 SYSTEMBAR_ANIMATION,
00351 TRUE,
00352 FALSE,
00353 TRUE,
00354 NULL,
00355 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC)
00356 )
00357 &&
00358 RegisterOpDescriptor(
00359 0,
00360 _R(IDS_SELECTENDFRAME),
00361 CC_RUNTIME_CLASS(OpSelectEndFrame),
00362 OPTOKEN_FRAME_ENDFRAME,
00363 OpSelectEndFrame::GetState,
00364 0,
00365 _R(IDBBL_SELECTENDFRAME),
00366 _R(IDD_ANIMATIONBAR),
00367 _R(IDC_PREVIEW_ENDFRAME),
00368 SYSTEMBAR_ANIMATION,
00369 TRUE,
00370 FALSE,
00371 TRUE,
00372 NULL,
00373 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC)
00374 )
00375 &&
00376 RegisterOpDescriptor(
00377 0,
00378 _R(IDS_SELECTPREVFRAME),
00379 CC_RUNTIME_CLASS(OpSelectPrevFrame),
00380 OPTOKEN_FRAME_PREVFRAME,
00381 OpSelectPrevFrame::GetState,
00382 0,
00383 _R(IDBBL_SELECTPREVFRAME),
00384 _R(IDD_ANIMATIONBAR),
00385 _R(IDC_PREVIEW_PREVFRAME),
00386 SYSTEMBAR_ANIMATION,
00387 TRUE,
00388 FALSE,
00389 TRUE,
00390 NULL,
00391 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC)
00392 )
00393 &&
00394 RegisterOpDescriptor(
00395 0,
00396 _R(IDS_SELECTNEXTFRAME),
00397 CC_RUNTIME_CLASS(OpSelectNextFrame),
00398 OPTOKEN_FRAME_NEXTFRAME,
00399 OpSelectNextFrame::GetState,
00400 0,
00401 _R(IDBBL_SELECTNEXTFRAME),
00402 _R(IDD_ANIMATIONBAR),
00403 _R(IDC_PREVIEW_NEXTFRAME),
00404 SYSTEMBAR_ANIMATION,
00405 TRUE,
00406 FALSE,
00407 TRUE,
00408 NULL,
00409 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC)
00410 )
00411 &&
00412 RegisterOpDescriptor(
00413 0,
00414 _R(IDS_NEWFRAME),
00415 CC_RUNTIME_CLASS(OpCreateNewFrame),
00416 OPTOKEN_FRAME_NEWFRAME,
00417 OpCreateNewFrame::GetState,
00418 0,
00419 _R(IDBBL_NEWFRAME),
00420 _R(IDD_ANIMATIONBAR),
00421 _R(IDC_FRAME_NEWFRAME),
00422 SYSTEMBAR_ANIMATION,
00423 TRUE,
00424 FALSE,
00425 TRUE,
00426 NULL,
00427 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC)
00428 )
00429 &&
00430 RegisterOpDescriptor(
00431 0,
00432 _R(IDS_COPYFRAME),
00433 CC_RUNTIME_CLASS(OpCopyFrame),
00434 OPTOKEN_FRAME_COPYFRAME,
00435 OpCopyFrame::GetState,
00436 0,
00437 _R(IDBBL_COPYFRAME),
00438 _R(IDD_ANIMATIONBAR),
00439 _R(IDC_FRAME_COPYFRAME),
00440 SYSTEMBAR_ANIMATION,
00441 TRUE,
00442 FALSE,
00443 TRUE,
00444 NULL,
00445 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC)
00446 )
00447 &&
00448 RegisterOpDescriptor(
00449 0,
00450 _R(IDS_DELETEFRAME),
00451 CC_RUNTIME_CLASS(OpDeleteFrame),
00452 OPTOKEN_FRAME_DELETEFRAME,
00453 OpDeleteFrame::GetState,
00454 0,
00455 _R(IDBBL_DELETEFRAME),
00456 _R(IDD_ANIMATIONBAR),
00457 _R(IDC_FRAME_DELETEFRAME),
00458 SYSTEMBAR_ANIMATION,
00459 TRUE,
00460 FALSE,
00461 TRUE,
00462 NULL,
00463 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC)
00464 )
00465 &&
00466 #endif
00467 TRUE
00468 );
00469 }
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486 OpState OpLayerGalChange::GetState(String_256* UIDescription, OpDescriptor*)
00487 {
00488 OpState OpSt;
00489 return(OpSt);
00490 }
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517 void OpLayerGalChange::DoWithParam(OpDescriptor*, OpParam* pOpParam)
00518 {
00519 OpLayerGalParam* pOpLayerGalParam = (OpLayerGalParam*)pOpParam;
00520
00521 pSpread = pOpLayerGalParam->GetParentSpread();
00522 Reason = pOpLayerGalParam->GetReason();
00523
00524 Layer* pLayer = pOpLayerGalParam->pLayer;
00525 Node* pContextNode= pOpLayerGalParam->pContextNode;
00526 AttachNodeDirection AttDir = pOpLayerGalParam->AttDir;
00527 LayerStatus NewStatus = pOpLayerGalParam->Status;
00528
00529 BOOL FrameLayer = FALSE;
00530
00531 switch (Reason)
00532 {
00533
00534
00535 case (FRAME_SELECT):
00536
00537 if (pLayer == NULL || pLayer->IsActive())
00538 goto EndOperation;
00539
00540 PORTNOTE("galleries", "disabled frame gallery")
00541 #ifndef EXCLUDE_FROM_XARALX
00542
00543 FrameSGallery::MakeActiveLayer(pLayer);
00544 #endif
00545 UndoIDS = _R(IDS_FRAME_UNDO_SELECTNEW);
00546 break;
00547
00548
00549 case (FRAME_NEW):
00550 FrameLayer = TRUE;
00551 case (LAYER_NEW):
00552 {
00553
00554 ALLOC_WITH_FAIL(pLayer, (new Layer()), this);
00555 if (pLayer == NULL)
00556 goto EndOperation;
00557
00558
00559
00560 pLayer->SetLayerStatus(NewStatus);
00561
00562
00563 if (FrameLayer)
00564 {
00565 pLayer->SetFrame(TRUE);
00566 pLayer->SetEdited(TRUE);
00567 }
00568
00569
00570
00571
00572 Layer* pLastLayer = pSpread->FindLastLayer();
00573 if(pLastLayer && pLastLayer->IsGuide())
00574 {
00575
00576 pLastLayer = pLastLayer->FindPrevLayer();
00577 }
00578 Node* pNodeToInsert;
00579 if(pLastLayer)
00580 {
00581 pNodeToInsert = pLastLayer;
00582 }
00583 else
00584 {
00585
00586 pNodeToInsert = pContextNode;
00587 }
00588
00589 if (DoInsertNewNode(pLayer, pLastLayer, NEXT, FALSE))
00590 {
00591 PORTNOTE("galleries", "Disabled frame gallery")
00592 #ifndef EXCLUDE_FROM_XARALX
00593 if (FrameLayer)
00594 FrameSGallery::MakeActiveLayer(pLayer);
00595 else
00596 #endif
00597 LayerSGallery::MakeActiveLayer(pLayer);
00598
00599
00600 pOpUndoLayer = pLayer;
00601 pLayer->EnsureUniqueLayerID();
00602 }
00603 }
00604
00605 if (FrameLayer)
00606 UndoIDS = _R(IDS_FRAME_UNDO_NEW);
00607 else
00608 UndoIDS = _R(IDS_LAYER_UNDO_NEW);
00609 break;
00610
00611
00612
00613 case (FRAME_DELETE):
00614 FrameLayer = TRUE;
00615 case (LAYER_DELETE):
00616 case (PAGEBACKGROUND_DEFAULT):
00617 {
00618
00619
00620
00621
00622
00623
00624 Layer* pPrevLayer = pLayer->FindPrevLayer();
00625 Layer* pNextLayer = pLayer->FindNextLayer();
00626
00627 if (pLayer->IsVisible())
00628 {
00629 if (!DoInvalidateLayerRegion(pLayer))
00630 goto EndOperation;
00631 }
00632
00633 NodeRenderableInk::DeselectAllOnLayer(pLayer);
00634
00635 if (!DoHideNode(pLayer,TRUE))
00636 goto EndOperation;
00637
00638
00639
00640 pOpRedoLayer = pLayer;
00641
00642
00643 if (pSpread->FindFirstLayer() == NULL)
00644 {
00645 Layer* pFirstLayer;
00646
00647 ALLOC_WITH_FAIL(pFirstLayer, (new Layer()), this);
00648 if (pFirstLayer == NULL)
00649 goto EndOperation;
00650
00651
00652
00653 pFirstLayer->SetActive(TRUE);
00654 pFirstLayer->GetLayerStatus().StringLayerID = LayerSGallery::CreateUniqueLayerID(pSpread);
00655
00656
00657 if (DoInsertNewNode(pFirstLayer,pSpread,LASTCHILD,FALSE,TRUE,TRUE,TRUE))
00658 {
00659
00660
00661 pOpUndoLayer = pLayer;
00662 }
00663 }
00664 else
00665 {
00666
00667 if (pLayer->IsActive())
00668 {
00669 Layer* pNewActiveLayer = pNextLayer;
00670
00671 if (pNewActiveLayer == NULL)
00672 pNewActiveLayer = pPrevLayer;
00673
00674 if (pNewActiveLayer != NULL)
00675 {
00676 PORTNOTE("galleries", "disabled frame gallery")
00677 #ifndef EXCLUDE_FROM_XARALX
00678 if (FrameLayer)
00679 FrameSGallery::MakeActiveLayer(pNewActiveLayer);
00680 else
00681 #endif
00682 LayerSGallery::MakeActiveLayer(pNewActiveLayer);
00683 }
00684
00685 ERROR3IF(pNewActiveLayer == NULL,"Can't find another layer to make active");
00686
00687
00688 pLayer->SetActive(FALSE);
00689 }
00690 }
00691 }
00692
00693 if (FrameLayer)
00694 UndoIDS = _R(IDS_FRAME_UNDO_DELETE);
00695 else
00696 {
00697 if (Reason == LAYER_DELETE)
00698 UndoIDS = _R(IDS_LAYER_UNDO_DELETE);
00699 else
00700 UndoIDS = _R(IDS_UNDO_DEFAULTBACKGROUND);
00701 }
00702 break;
00703
00704
00705
00706 case (LAYER_CHANGE_NAME):
00707 UndoIDS = _R(IDS_LAYER_UNDO_CHANGENAME);
00708
00709
00710 {
00711
00712
00713 if (UndoIDS == _R(IDS_NOTYPE)) UndoIDS = _R(IDS_LAYER_UNDO_CHANGE);
00714
00715
00716
00717 ChangeLyrAttribAction* UndoAttribChngAction;
00718
00719 if ( ChangeLyrAttribAction::Init(this,
00720 &UndoActions,
00721 sizeof(InvalidateRegionAction),
00722 pLayer->GetLayerStatus(),
00723 pLayer,
00724 ( Action**)(&UndoAttribChngAction))
00725 != AC_FAIL)
00726 {
00727 LayerStatus OldStatus = pLayer->GetLayerStatus();
00728
00729
00730 BOOL PrevVisible = pLayer->IsVisible();
00731 BOOL PrevLocked = pLayer->IsLocked();
00732 BOOL PrevOutline = pLayer->IsOutline();
00733
00734
00735 BOOL PrevVisibleReal = pLayer->GetVisibleFlagState();
00736
00737
00738 pLayer->SetLayerStatus(NewStatus);
00739
00740
00741 BOOL PostVisible = pLayer->IsVisible();
00742 BOOL PostLocked = pLayer->IsLocked();
00743 BOOL PostOutline = pLayer->IsOutline();
00744
00745
00746 BOOL PostVisibleReal = pLayer->GetVisibleFlagState();
00747
00748
00749
00750 if ((PrevVisibleReal != PostVisibleReal) || (PostVisible && (PrevOutline != PostOutline)))
00751 {
00752 if (!DoInvalidateLayerRegion(pLayer))
00753 goto EndOperation;
00754 }
00755
00756
00757 if ( ((PrevVisible != PostVisible) && !PostVisible) ||
00758 ((PrevLocked != PostLocked) && PostLocked) )
00759 {
00760 NodeRenderableInk::DeselectAllOnLayer(pLayer);
00761 }
00762 pLayer->EnsureUniqueLayerID();
00763 }
00764 else
00765 goto EndOperation;
00766
00767 }
00768 break;
00769
00770
00771
00772 case (FRAME_MOVE):
00773 FrameLayer = TRUE;
00774 case (LAYER_MOVE):
00775
00776 if(!DoMoveNode(pLayer, pContextNode, AttDir))
00777 goto EndOperation;
00778
00779 GetApplication()->UpdateSelection();
00780
00781
00782
00783
00784
00785
00786
00787
00788 if (FrameLayer)
00789 {
00790
00791 pLayer->SetFrame(TRUE);
00792 pLayer->SetEdited(TRUE);
00793 PORTNOTE("galleries", "Disabled frame gallery")
00794 #ifndef EXCLUDE_FROM_XARALX
00795 FrameSGallery::MakeActiveLayer(pLayer);
00796 #endif
00797 }
00798 else
00799 LayerSGallery::MakeActiveLayer(pLayer);
00800
00801 pOpUndoLayer = pLayer;
00802 pOpRedoLayer = pLayer;
00803
00804
00805 if (pOpLayerGalParam->MoveRedraw)
00806 {
00807 if (!DoInvalidateLayerRegion(pLayer))
00808 goto EndOperation;
00809 }
00810
00811 if (pOpLayerGalParam->ToggleBackground)
00812 LayerStateAction::Init(this,&UndoActions,*pOpLayerGalParam);
00813
00814 if (FrameLayer)
00815 UndoIDS = _R(IDS_FRAME_UNDO_MOVE);
00816 else
00817 UndoIDS = _R(IDS_LAYER_UNDO_MOVE);
00818 break;
00819
00820
00821
00822 case (FRAME_COPY):
00823 FrameLayer = TRUE;
00824 case (LAYER_COPY):
00825 {
00826 BOOL ok = TRUE;
00827 Layer* pCopyOfLayer = NULL;
00828
00829 if (pLayer == NULL)
00830 goto EndOperation;
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859 CALL_WITH_FAIL(pLayer->NodeCopy((Node**)&pCopyOfLayer), this, ok);
00860 if (!ok) goto EndOperation;
00861
00862
00863
00864 TextStory::SetFocusStory(NULL);
00865
00866
00867 pCopyOfLayer->SetLayerStatus(NewStatus);
00868
00869
00870 if (FrameLayer)
00871 {
00872 pCopyOfLayer->SetFrame(TRUE);
00873 pCopyOfLayer->SetEdited(TRUE);
00874 }
00875
00876
00877
00878
00879 Layer* pLastLayer = pSpread->FindLastLayer();
00880 if(pLastLayer && pLastLayer->IsGuide())
00881 {
00882
00883
00884 pLastLayer = pLastLayer->FindPrevLayer();
00885 }
00886 Node* pNodeToInsert;
00887 if(pLastLayer)
00888 {
00889 pNodeToInsert = pLastLayer;
00890 }
00891 else
00892 {
00893
00894 pNodeToInsert = pContextNode;
00895 }
00896
00897 if (!DoInsertNewNode(pCopyOfLayer, pNodeToInsert, NEXT, FALSE))
00898 {
00899
00900 pCopyOfLayer->CascadeDelete();
00901 delete pCopyOfLayer;
00902 goto EndOperation;
00903 }
00904
00905
00906 Node* pCurrent = pCopyOfLayer->FindFirstDepthFirst();
00907 while (pCurrent!=NULL && ok)
00908 {
00909 ok = pCurrent->PostDuplicate(this);
00910 pCurrent = pCurrent->FindNextDepthFirst(pCopyOfLayer);
00911 }
00912 if (!ok) goto EndOperation;
00913
00914 if (!DoInvalidateLayerRegion(pCopyOfLayer))
00915 goto EndOperation;
00916
00917
00918
00919 pOpUndoLayer = pCopyOfLayer;
00920
00921
00922 PORTNOTE("galleries", "Disabled frame gallery")
00923 #ifndef EXCLUDE_FROM_XARALX
00924 if (FrameLayer)
00925 FrameSGallery::MakeActiveLayer(pCopyOfLayer);
00926 else
00927 #endif
00928 LayerSGallery::MakeActiveLayer(pCopyOfLayer);
00929
00930 NodeRenderableInk::DeselectAllOnLayer(pLayer);
00931 pCopyOfLayer->EnsureUniqueLayerID();
00932 }
00933
00934 if (FrameLayer)
00935 UndoIDS = _R(IDS_FRAME_UNDO_COPY);
00936 else
00937 UndoIDS = _R(IDS_LAYER_UNDO_COPY);
00938 break;
00939
00940
00941
00942 case (LAYER_TOGGLEBACKGROUND):
00943 LayerStateAction::Init(this, &UndoActions, *pOpLayerGalParam);
00944 BroadcastLayerChanges = FALSE;
00945 UndoIDS = _R(IDS_LAYER_UNDO_MOVE);
00946 break;
00947
00948
00949
00950 case (LAYER_VISIBLE):
00951 LayerStateAction::Init(this, &UndoActions, *pOpLayerGalParam);
00952 BroadcastLayerChanges = FALSE;
00953 UndoIDS = _R(IDS_LAYER_UNDO_VISIBLE);
00954 break;
00955
00956
00957
00958 case (LAYER_LOCKED):
00959 LayerStateAction::Init(this, &UndoActions, *pOpLayerGalParam);
00960 BroadcastLayerChanges = FALSE;
00961 UndoIDS = _R(IDS_LAYER_UNDO_LOCKED);
00962 break;
00963
00964
00965
00966 case (FRAME_ALLVISIBLE):
00967 FrameLayer = TRUE;
00968 case (LAYER_ALLVISIBLE):
00969 LayerStateAction::Init(this, &UndoActions, *pOpLayerGalParam);
00970 BroadcastLayerChanges = FALSE;
00971 if (FrameLayer)
00972 UndoIDS = _R(IDS_FRAME_UNDO_ALLVISIBLE);
00973 else
00974 UndoIDS = _R(IDS_LAYER_UNDO_ALLVISIBLE);
00975 break;
00976
00977
00978
00979 case (FRAME_MULTILAYER):
00980 FrameLayer = TRUE;
00981 case (LAYER_MULTILAYER):
00982 LayerStateAction::Init(this, &UndoActions, *pOpLayerGalParam);
00983 BroadcastLayerChanges = FALSE;
00984 if (FrameLayer)
00985 UndoIDS = _R(IDS_FRAME_UNDO_MULTILAYER);
00986 else
00987 UndoIDS = _R(IDS_LAYER_UNDO_MULTILAYER);
00988 break;
00989
00990
00991
00992 case (LAYER_CHANGE):
00993 LayerStateAction::Init(this, &UndoActions, *pOpLayerGalParam);
00994
00995 UndoIDS = _R(IDS_OPCHANGELAYERPROPERTIES);
00996 break;
00997
00998
00999
01000 case (LAYER_SOLID):
01001
01002
01003
01004
01005
01006 LayerStateAction::Init(this, &UndoActions, *pOpLayerGalParam);
01007 BroadcastLayerChanges = FALSE;
01008 UndoIDS = _R(IDS_LAYER_UNDO_SOLID);
01009 break;
01010
01011
01012 case (LAYER_OVERLAY):
01013
01014
01015
01016 LayerStateAction::Init(this, &UndoActions, *pOpLayerGalParam);
01017 BroadcastLayerChanges = FALSE;
01018 UndoIDS = _R(IDS_LAYER_UNDO_OVERLAY);
01019 break;
01020
01021
01022
01023 case (LAYER_ACTIVE):
01024
01025 LayerStateAction::Init(this, &UndoActions, *pOpLayerGalParam);
01026 BroadcastLayerChanges = FALSE;
01027 UndoIDS = _R(IDS_LAYER_UNDO_ACTIVE);
01028 break;
01029
01030
01031 default:
01032 ERROR3("Unknown OpLayerGalChange reason code");
01033 break;
01034 }
01035
01036 if (BroadcastLayerChanges)
01037 {
01038 BROADCAST_TO_ALL(SpreadMsg(pSpread,SpreadMsg::LAYERCHANGES));
01039 }
01040
01041 EndOperation:
01042
01043 ERROR3IF(UndoIDS == 0,"The undo ID string is zero. No too useful!");
01044 End();
01045 }
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066 BOOL OpLayerGalChange::DoInvalidateLayerRegion(Layer* pLayer)
01067 {
01068 ERROR2IF(pLayer == NULL,FALSE, "pLayer is NULL");
01069 ERROR2IF(pSpread == NULL,FALSE,"pSpread is NULL");
01070
01071 BOOL ok = TRUE;
01072
01073 if (pLayer->IsGuide())
01074 {
01075 Node* pNode = pLayer->FindFirstChild(CC_RUNTIME_CLASS(NodeGuideline));
01076 while (pNode != NULL && ok)
01077 {
01078 DocRect Rect = ((NodeGuideline*)pNode)->GetRenderRect();
01079 ok = DoInvalidateRegion(pSpread,Rect);
01080
01081 pNode = pNode->FindNext(CC_RUNTIME_CLASS(NodeGuideline));
01082 }
01083 }
01084
01085 if (ok) ok = DoInvalidateNodeRegion(pLayer, TRUE);
01086
01087 return ok;
01088 }
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107 void OpLayerGalChange::GetOpName(String_256* OpName)
01108 {
01109 *OpName = String_256(UndoIDS);
01110 }
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125
01126
01127
01128
01129 BOOL OpLayerGalChange::Undo()
01130 {
01131
01132 switch (Reason)
01133 {
01134
01135
01136
01137
01138 case FRAME_NEW:
01139 case FRAME_COPY:
01140 case LAYER_NEW:
01141 case LAYER_COPY:
01142
01143 ERROR3IF(pOpUndoLayer == NULL,"The op's undo layer ptr is NULL");
01144
01145
01146
01147 case FRAME_DELETE:
01148 case LAYER_DELETE:
01149 case PAGEBACKGROUND_DEFAULT:
01150
01151
01152
01153 if (pOpUndoLayer != NULL && pOpUndoLayer->FindParent() != NULL)
01154 NodeRenderableInk::DeselectAllOnLayer(pOpUndoLayer);
01155
01156
01157
01158 case FRAME_MOVE:
01159 case LAYER_MOVE:
01160
01161
01162
01163 BroadcastLayerChanges = FALSE;
01164 break;
01165
01166 default:
01167 break;
01168 }
01169
01170 BOOL Result = Operation::Undo();
01171 if (Result)
01172 {
01173
01174 switch (Reason)
01175 {
01176
01177 case FRAME_MOVE:
01178 case LAYER_MOVE:
01179 GetApplication()->UpdateSelection();
01180 if (pOpUndoLayer != NULL)
01181 {
01182 PORTNOTE("galleries", "Disabled frame gallery")
01183 #ifndef EXCLUDE_FROM_XARALX
01184 if (Reason == FRAME_MOVE)
01185 FrameSGallery::MakeActiveLayer(pOpUndoLayer);
01186 else
01187 #endif
01188 LayerSGallery::MakeActiveLayer(pOpUndoLayer);
01189 BroadcastLayerChanges = TRUE;
01190 }
01191 break;
01192 default:
01193 break;
01194 }
01195
01196 if (BroadcastLayerChanges)
01197 {
01198 BROADCAST_TO_ALL(SpreadMsg(pSpread,SpreadMsg::LAYERCHANGES));
01199 }
01200 }
01201 return (Result);
01202 }
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220 BOOL OpLayerGalChange::Redo()
01221 {
01222
01223 switch (Reason)
01224 {
01225 case FRAME_DELETE:
01226 case LAYER_DELETE:
01227 case PAGEBACKGROUND_DEFAULT:
01228
01229 ERROR3IF(pOpRedoLayer == NULL,"The op's redo layer ptr is NULL");
01230
01231
01232
01233 if (pOpRedoLayer != NULL && pOpRedoLayer->FindParent() != NULL)
01234 NodeRenderableInk::DeselectAllOnLayer(pOpRedoLayer);
01235
01236
01237
01238 case FRAME_NEW:
01239 case FRAME_COPY:
01240 case FRAME_MOVE:
01241 case LAYER_NEW:
01242 case LAYER_COPY:
01243 case LAYER_MOVE:
01244
01245
01246
01247 BroadcastLayerChanges = FALSE;
01248 break;
01249
01250 default:
01251 break;
01252 }
01253
01254 BOOL Result = Operation::Redo();
01255 if (Result)
01256 {
01257
01258 switch (Reason)
01259 {
01260
01261 case FRAME_MOVE:
01262 case LAYER_MOVE:
01263 GetApplication()->UpdateSelection();
01264 if (pOpRedoLayer != NULL)
01265 {
01266 PORTNOTE("galleries", "Disabled frame gallery")
01267 #ifndef EXCLUDE_FROM_XARALX
01268 if (Reason == FRAME_MOVE)
01269 FrameSGallery::MakeActiveLayer(pOpRedoLayer);
01270 else
01271 #endif
01272 LayerSGallery::MakeActiveLayer(pOpRedoLayer);
01273 BroadcastLayerChanges = TRUE;
01274 }
01275 break;
01276
01277 default:
01278 break;
01279 }
01280
01281 if (BroadcastLayerChanges)
01282 {
01283 BROADCAST_TO_ALL(SpreadMsg(pSpread,SpreadMsg::LAYERCHANGES));
01284 }
01285 }
01286 return (Result);
01287 }
01288
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300
01301
01302 BOOL OpLayerGalChange::IsFrameMode()
01303 {
01304
01305 BOOL FramedDoc = FALSE;
01306
01307
01308 Spread* pSpread = Document::GetSelectedSpread();
01309
01310
01311 if(pSpread)
01312 {
01313
01314 Layer* pFrameLayer = pSpread->FindFirstFrameLayer();
01315
01316
01317 if (pFrameLayer)
01318 FramedDoc = TRUE;
01319 }
01320
01321 return FramedDoc;
01322 }
01323
01324
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334
01335
01336
01337
01338
01339
01340
01341
01342
01343
01344
01345
01346 LayerNameDlg::LayerNameDlg(): DialogOp(LayerNameDlg::IDD, LayerNameDlg::Mode)
01347 {
01348 pLayer = NULL;
01349 pSpread = NULL;
01350 }
01351
01352
01353
01354
01355
01356
01357
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367 MsgResult LayerNameDlg::Message(Msg* Message)
01368 {
01369 if (IS_OUR_DIALOG_MSG(Message))
01370 {
01371 DialogMsg* Msg = (DialogMsg*)Message;
01372 BOOL EndDialog = FALSE;
01373
01374 switch (Msg->DlgMsg)
01375 {
01376 case DIM_CREATE:
01377 ShowLayerDetails();
01378 LayerNameDlg::IsOpen = TRUE;
01379 LayerNameDlg::pLayerNameDlg = this;
01380 SetKeyboardFocus(_R(IDC_LAYER_NAME));
01381 HighlightText (_R(IDC_LAYER_NAME));
01382 break;
01383
01384 case DIM_COMMIT:
01385 EndDialog = TRUE;
01386 CommitDialogValues();
01387 break;
01388
01389 case DIM_SOFT_COMMIT:
01390
01391 break;
01392
01393 case DIM_CANCEL:
01394 EndDialog = TRUE;
01395 break;
01396
01397 case DIM_LFT_BN_CLICKED:
01398 break;
01399
01400 case DIM_TEXT_CHANGED:
01401 break;
01402
01403 default:
01404 break;
01405 }
01406
01407 if (EndDialog)
01408 {
01409 Close();
01410 End();
01411
01412 LayerNameDlg::IsOpen = FALSE;
01413 LayerNameDlg::pLayerNameDlg = NULL;
01414 return (DLG_EAT_IF_HUNGRY(Msg));
01415 }
01416 }
01417
01418
01419
01420 return DialogOp::Message(Message);
01421 }
01422
01423
01424
01425
01426
01427
01428
01429
01430
01431
01432
01433
01434
01435
01436
01437
01438
01439 OpState LayerNameDlg::GetState(String_256*, OpDescriptor*)
01440 {
01441 OpState OpSt;
01442 return(OpSt);
01443 }
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461
01462 BOOL LayerNameDlg::Init()
01463 {
01464 return (RegisterOpDescriptor(
01465 0,
01466 _R(IDS_LAYERNAMEDLG),
01467 CC_RUNTIME_CLASS(LayerNameDlg),
01468 OPTOKEN_LAYERNAMEDLG,
01469 LayerNameDlg::GetState,
01470 0,
01471 0
01472 )
01473 );
01474 }
01475
01476
01477
01478
01479
01480
01481
01482
01483
01484
01485
01486
01487
01488
01489
01490
01491 void LayerNameDlg::StartUp(LayerDlgParam* pParam)
01492 {
01493 if (!LayerNameDlg::IsOpen)
01494 {
01495 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_LAYERNAMEDLG);
01496 if (pOpDesc != NULL)
01497 pOpDesc->Invoke((OpParam*)pParam);
01498 else
01499 {
01500 ERROR3("Couldn't find OPTOKEN_LAYERNAMEDLG op descriptor");
01501 }
01502 }
01503 else if (LayerNameDlg::pLayerNameDlg != NULL)
01504 LayerNameDlg::pLayerNameDlg->BringToTop();
01505
01506 }
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518
01519
01520
01521
01522
01523
01524
01525 BOOL LayerNameDlg::Create()
01526 {
01527 if (DialogOp::Create())
01528 {
01529
01530 return TRUE;
01531 }
01532 else
01533 return FALSE;
01534
01535 }
01536
01537
01538
01539
01540
01541
01542
01543
01544
01545
01546
01547
01548
01549
01550
01551
01552
01553 void LayerNameDlg::DoWithParam(OpDescriptor*,OpParam* pOpParam)
01554 {
01555
01556 if (LayerNameDlg::IsOpen)
01557 return;
01558
01559 LayerDlgParam* pParam = (LayerDlgParam*)pOpParam;
01560
01561
01562 Reason = pParam->GetReason();
01563
01564
01565 pSpread = pParam->GetSpread();
01566 pLayer = pParam->GetLayer();
01567
01568
01569 if (pLayer != NULL && pSpread == NULL)
01570 pSpread = pLayer->FindParentSpread();
01571
01572 BOOL ok=FALSE;
01573
01574 switch (Reason)
01575 {
01576
01577 case LAYER_CHANGE_NAME:
01578 case LAYER_COPY:
01579 ERROR3IF(pLayer == NULL, "I don't have a layer");
01580 ERROR3IF(pSpread == NULL, "I dont' have a spread");
01581 ok = ((pLayer != NULL) && (pSpread != NULL));
01582 break;
01583
01584 case LAYER_NEW:
01585 ERROR3IF(pSpread == NULL, "I dont' have a spread");
01586 ok = (pSpread != NULL);
01587 break;
01588
01589 default:
01590 ERROR3("The layer name dialog can't process the given reason");
01591 ok = FALSE;
01592 break;
01593 }
01594
01595 if (ok) ok = Create();
01596
01597
01598 if (!ok)
01599 {
01600 InformError(0,_R(IDS_OK));
01601 End();
01602 }
01603
01604
01605
01606
01607
01608 }
01609
01610
01611
01612
01613
01614
01615
01616
01617
01618
01619
01620
01621
01622
01623
01624
01625
01626 void LayerNameDlg::ShowLayerDetails()
01627 {
01628 String_256 Name;
01629
01630 switch (Reason)
01631 {
01632 case LAYER_CHANGE_NAME:
01633 Name = pLayer->GetLayerID();
01634 break;
01635
01636 case LAYER_COPY:
01637 CreateUniqueLayerCopyName(pLayer->GetLayerID(), &Name);
01638 break;
01639 break;
01640
01641 case LAYER_NEW:
01642 Name = LayerSGallery::CreateUniqueLayerID(pSpread);
01643 break;
01644
01645 default:
01646 ERROR3("Unknown OpLayerGalReason reason");
01647 break;
01648 }
01649
01650 SetStringGadgetValue(_R(IDC_LAYER_NAME),Name);
01651 }
01652
01653
01654
01655
01656
01657
01658
01659
01660
01661
01662
01663
01664
01665
01666 void LayerNameDlg::CreateUniqueLayerCopyName(const String_256& strName, String_256* pCopyName)
01667 {
01668
01669 ERROR3IF(pCopyName == NULL,
01670 "Null output String_256* in LayerNameDlg::CreateUniqueLayerCopyName");
01671
01672
01673
01674
01675
01676 pCopyName->Load(_R(IDS_LAYERGAL_COPYOF));
01677 String_256 strNewName;
01678 if ((strName.Length() + pCopyName->Length()) >= pCopyName->MaxLength())
01679 {
01680
01681 strName.Left(&strNewName, pCopyName->MaxLength() - pCopyName->Length());
01682 }
01683 else
01684 {
01685
01686 strNewName = strName;
01687 }
01688
01689
01690 *pCopyName += strNewName;
01691 }
01692
01693
01694
01695
01696
01697
01698
01699
01700
01701
01702
01703
01704
01705
01706
01707
01708
01709
01710
01711
01712 void LayerNameDlg::CommitDialogValues()
01713 {
01714 String_256 NewName;
01715
01716 BOOL Valid;
01717
01718
01719 NewName = GetStringGadgetValue(_R(IDC_LAYER_NAME),&Valid);
01720
01721
01722
01723 if (Reason == LAYER_CHANGE_NAME)
01724 {
01725 if (pLayer->GetLayerID() == NewName)
01726 return;
01727 }
01728
01729
01730 OpLayerGalParam Param(Reason, pSpread);
01731 Param.pLayer = pLayer;
01732
01733
01734 Param.Status.StringLayerID = NewName;
01735
01736
01737
01738 if (Reason == LAYER_COPY || Reason == LAYER_NEW)
01739 {
01740 Param.pContextNode = pSpread;
01741 Param.AttDir = LASTCHILD;
01742 }
01743
01744
01745 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_LAYERGALCHANGE);
01746 if (pOpDesc != NULL)
01747 pOpDesc->Invoke((OpParam*)&Param);
01748 else
01749 {
01750 ERROR3("Couldn't find OPTOKEN_LAYERGALCHANGE op descriptor");
01751 }
01752 }
01753
01754
01755
01756
01757
01758
01759
01760
01761
01762
01763
01764
01765
01766
01767
01768
01769
01770
01771
01772
01773
01774
01775
01776
01777
01778
01779 BOOL OpDisplayLayerGallery::Init()
01780 {
01781 return (RegisterOpDescriptor(
01782 0,
01783 _R(IDS_DISPLAY_LAYER_GALLERY),
01784 CC_RUNTIME_CLASS(OpDisplayLayerGallery),
01785 OPTOKEN_DISPLAYLAYERGALLERY,
01786 OpDisplayLayerGallery::GetState,
01787 0,
01788 _R(IDBBL_DISPLAY_LAYER_GALLERY),
01789 _R(IDC_BTN_SGLAYER),
01790 _R(IDC_BTN_SGLAYER),
01791 SYSTEMBAR_ILLEGAL,
01792 TRUE,
01793 FALSE,
01794 TRUE,
01795 NULL,
01796 0,
01797 0,
01798 TRUE
01799 )
01800 );
01801 }
01802
01803
01804
01805
01806
01807
01808
01809
01810
01811
01812
01813
01814
01815
01816
01817
01818 OpState OpDisplayLayerGallery::GetState(String_256* UIDescription, OpDescriptor*)
01819 {
01820
01821
01822
01823 OpState OpSt;
01824
01825
01826 BOOL LayerDoc = TRUE;
01827
01828
01829 Spread* pSpread = Document::GetSelectedSpread();
01830
01831
01832 if(pSpread)
01833 {
01834
01835 Layer* pFrameLayer = pSpread->FindFirstFrameLayer();
01836
01837
01838 if (pFrameLayer)
01839 LayerDoc = FALSE;
01840 }
01841
01842 if(LayerDoc)
01843 {
01844
01845 SuperGallery* pSuperGallery = SuperGallery::FindSuperGallery(_R(IDD_LAYERSGALLERY));
01846
01847 if (pSuperGallery != NULL)
01848 {
01849 if (pSuperGallery->GetRuntimeClass() == CC_RUNTIME_CLASS(LayerSGallery))
01850 OpSt.Ticked = pSuperGallery->IsVisible();
01851 }
01852
01853
01854 OpSt.Greyed = (Document::GetSelected() == NULL);
01855 }
01856 else
01857 {
01858
01859 OpSt.Ticked = FALSE;
01860 OpSt.Greyed = TRUE;
01861 *UIDescription = String_256 (_R(IDS_NO_LAYERS));
01862 }
01863
01864 return(OpSt);
01865 }
01866
01867
01868
01869
01870
01871
01872
01873
01874
01875
01876
01877
01878
01879
01880
01881
01882 void OpDisplayLayerGallery::Do(OpDescriptor*)
01883 {
01884 SuperGallery* pSuperGallery = SuperGallery::FindSuperGallery(_R(IDD_LAYERSGALLERY));
01885
01886 if (!pSuperGallery) pSuperGallery = new LayerSGallery;
01887
01888 if (pSuperGallery != NULL)
01889 {
01890 if (pSuperGallery->GetRuntimeClass() == CC_RUNTIME_CLASS(LayerSGallery))
01891 {
01892
01893 pSuperGallery->SetVisibility( !pSuperGallery->IsVisible() );
01894 }
01895 else
01896 {
01897 ERROR3("Got the layer gallery but it's not of the LayerSGallery class");
01898 }
01899
01900 SGInit::UpdateGalleryButton(_R(OPTOKEN_DISPLAYLAYERGALLERY), pSuperGallery->IsVisible());
01901 }
01902
01903 ERROR3IF(pSuperGallery == NULL,"Couldn't find the layer gallery bar");
01904
01905 End();
01906 }
01907
01908 PORTNOTE("galleries", "disable frame gallery")
01909 #ifndef EXCLUDE_FROM_XARALX
01910
01911
01912
01913
01914
01915
01916
01917
01918
01919
01920
01921
01922
01923
01924
01925
01926
01927
01928
01929
01930
01931
01932
01933
01934
01935 BOOL OpDisplayFrameGallery::Init()
01936 {
01937 return (RegisterOpDescriptor(
01938 0,
01939 _R(IDS_DISPLAY_FRAME_GALLERY),
01940 CC_RUNTIME_CLASS(OpDisplayFrameGallery),
01941 OPTOKEN_DISPLAYFRAMEGALLERY,
01942 OpDisplayFrameGallery::GetState,
01943 _R(IDH_Gallery_Frame),
01944 _R(IDBBL_DISPLAY_FRAME_GALLERY),
01945 0 ));
01946 }
01947
01948
01949
01950
01951
01952
01953
01954
01955
01956
01957
01958
01959
01960
01961
01962
01963 OpState OpDisplayFrameGallery::GetState(String_256* UIDescription, OpDescriptor*)
01964 {
01965
01966
01967
01968 OpState OpSt;
01969
01970 #ifdef WEBSTER
01971
01972
01973 SuperGallery* pSuperGallery = SuperGallery::FindSuperGallery(_R(IDD_LAYERSGALLERY));
01974
01975 if (pSuperGallery != NULL)
01976 {
01977 if (pSuperGallery->GetRuntimeClass() == CC_RUNTIME_CLASS(FrameSGallery))
01978 OpSt.Ticked = pSuperGallery->IsVisible();
01979 }
01980
01981
01982 OpSt.Greyed = (Document::GetSelected() == NULL);
01983
01984 #else
01985
01986
01987 BOOL FramedDoc = FALSE;
01988
01989
01990 Spread* pSpread = Document::GetSelectedSpread();
01991
01992
01993 if(pSpread)
01994 {
01995
01996 Layer* pFrameLayer = pSpread->FindFirstFrameLayer();
01997
01998
01999 if (pFrameLayer)
02000 FramedDoc = TRUE;
02001 }
02002
02003
02004 if(FramedDoc)
02005 {
02006
02007 String_32 Name(_R(IDS_FRAMEGAL_GALLNAME));
02008 SuperGallery* pSuperGallery = SuperGallery::FindSuperGallery(Name);
02009
02010 if (pSuperGallery != NULL)
02011 {
02012 if (pSuperGallery->GetRuntimeClass() == CC_RUNTIME_CLASS(FrameSGallery))
02013 OpSt.Ticked = pSuperGallery->IsVisible();
02014 }
02015
02016
02017 OpSt.Greyed = (Document::GetSelected() == NULL);
02018 }
02019 else
02020 {
02021
02022
02023 OpSt.Ticked = FALSE;
02024 OpSt.Greyed = TRUE;
02025 *UIDescription = String_256 (_R(IDS_NO_FRAMES));
02026 }
02027
02028 #endif
02029
02030
02031 return(OpSt);
02032 }
02033
02034
02035
02036
02037
02038
02039
02040
02041
02042
02043
02044
02045
02046
02047
02048
02049 void OpDisplayFrameGallery::Do(OpDescriptor*)
02050 {
02051 String_32 Name(_R(IDS_FRAMEGAL_GALLNAME));
02052 SuperGallery* pSuperGallery = SuperGallery::FindSuperGallery(Name);
02053
02054 if (pSuperGallery != NULL)
02055 {
02056 if (pSuperGallery->GetRuntimeClass() == CC_RUNTIME_CLASS(FrameSGallery))
02057 {
02058 GIFAnimationPropertyTabs::SetFrameGalleryOpen(FALSE);
02059
02060
02061 pSuperGallery->SetVisibility( !pSuperGallery->IsVisible() );
02062 }
02063 else
02064 {
02065 ERROR3("Got the frame gallery but it's not of the LayerSGallery class");
02066 }
02067
02068 SGInit::UpdateGalleryButton(_R(OPTOKEN_DISPLAYFRAMEGALLERY), pSuperGallery->IsVisible());
02069
02070 GIFAnimationPropertyTabs::SetFrameGalleryOpen(TRUE);
02071 }
02072
02073 ERROR3IF(pSuperGallery == NULL,"Couldn't find the frame gallery bar");
02074
02075 End();
02076 }
02077 #endif
02078
02079
02080
02081
02082
02083
02084
02085
02086
02087
02088
02089
02090
02091
02092
02093
02094
02095
02096
02097
02098
02099 LayerStateAction::LayerStateAction()
02100 {
02101 }
02102
02103
02104
02105
02106
02107
02108
02109
02110
02111
02112
02113
02114
02115
02116
02117
02118
02119
02120
02121
02122
02123
02124
02125
02126
02127
02128
02129
02130
02131
02132
02133
02134 ActionCode LayerStateAction::Init( UndoableOperation* pOp,
02135 ActionList* pActionList,
02136 OpLayerGalParam EntryParam)
02137 {
02138 UINT32 ActSize = sizeof(LayerStateAction);
02139
02140 LayerStateAction* pNewAction;
02141 ActionCode Ac = Action::Init(pOp,pActionList,ActSize,CC_RUNTIME_CLASS(LayerStateAction),(Action**)&pNewAction);
02142
02143 if (Ac != AC_FAIL && pNewAction != NULL)
02144 {
02145 pNewAction->Param = EntryParam;
02146 OpLayerGalParam& Param = pNewAction->Param;
02147
02148 switch (Param.GetReason())
02149 {
02150 case LAYER_VISIBLE:
02151 ERROR3IF(Param.pLayer == NULL,"Param.pLayer == NULL");
02152
02153 if (Param.pLayer != NULL)
02154 LayerSGallery::DoChangeVisible(Param.pLayer,Param.NewState);
02155 break;
02156
02157 case LAYER_LOCKED:
02158 ERROR3IF(Param.pLayer == NULL,"Param.pLayer == NULL");
02159
02160 if (Param.pLayer != NULL)
02161 LayerSGallery::DoChangeLocked(Param.pLayer,Param.NewState);
02162 break;
02163
02164 case LAYER_ALLVISIBLE:
02165 case FRAME_ALLVISIBLE:
02166 if (Param.pLayerSGal != NULL)
02167 {
02168 Param.pLayerSGal->DoChangeAllVisible(Param.NewState);
02169 Param.pLayerSGal->ForceRedrawOfList();
02170 }
02171 break;
02172
02173 case LAYER_MULTILAYER:
02174 case FRAME_MULTILAYER:
02175 if (Param.pLayerSGal != NULL)
02176 {
02177 Param.pLayerSGal->DoChangeMultilayer(Param.NewState);
02178 Param.pLayerSGal->ForceRedrawOfList();
02179 }
02180 break;
02181
02182 case FRAME_MOVE:
02183 case LAYER_MOVE:
02184 case LAYER_TOGGLEBACKGROUND:
02185 ERROR3IF(Param.pLayer == NULL,"Param.pLayer == NULL");
02186 ERROR3IF(Param.pLayerSGal == NULL,"Param.pLayerSGal == NULL");
02187
02188 if (Param.pLayer != NULL)
02189 {
02190 if (Param.GetReason() == FRAME_MOVE)
02191 {
02192 Param.pLayer->SetBackground(FALSE);
02193 Param.pLayer->SetPrintable(!Param.pLayer->IsPrintable());
02194 }
02195 else
02196 {
02197 Param.pLayer->SetBackground(!Param.pLayer->IsBackground());
02198 Param.pLayer->SetPrintable(!Param.pLayer->IsPrintable());
02199 }
02200
02201 Param.pLayerSGal->CreateNewSubtree(Param.pLayer->FindDocument());
02202 }
02203 break;
02204
02205 case LAYER_CHANGE:
02206 ERROR3IF(Param.pLayer == NULL,"Param.pLayer == NULL");
02207
02208 if (Param.pLayer != NULL)
02209 {
02210 Param.OldVisibleState = Param.pLayer->IsVisible();
02211 Param.OldLockedState = Param.pLayer->IsLocked();
02212 Param.OldName = Param.pLayer->GetLayerID();
02213
02214 LayerSGallery::DoChangeVisible(Param.pLayer,Param.VisibleState);
02215 LayerSGallery::DoChangeLocked(Param.pLayer,Param.LockedState);
02216 Param.pLayer->SetLayerID(Param.NewName);
02217 }
02218 break;
02219
02220 case LAYER_SOLID:
02221 ERROR3IF(Param.pLayer == NULL,"Param.pLayer == NULL");
02222
02223 if (Param.pLayer != NULL)
02224 {
02225 PORTNOTE("galleries", "Disabled frame gallery")
02226 #ifndef EXCLUDE_FROM_XARALX
02227 FrameSGallery::DoChangeSolid(Param.pLayer,Param.NewState);
02228 #endif
02229 Param.pLayer->SetEdited(TRUE);
02230 Param.pLayer->SetFrame(TRUE);
02231 #ifdef _DEBUG
02232
02233 BROADCAST_TO_ALL(LayerMsg(Param.pLayer, LayerMsg::REDRAW_LAYER));
02234 #endif
02235 }
02236 break;
02237
02238 case LAYER_OVERLAY:
02239 ERROR3IF(Param.pLayer == NULL,"Param.pLayer == NULL");
02240
02241 if (Param.pLayer != NULL)
02242 {
02243 PORTNOTE("galleries", "Disabled frame gallery")
02244 #ifndef EXCLUDE_FROM_XARALX
02245 FrameSGallery::DoChangeOverlay(Param.pLayer,Param.NewState);
02246 #endif
02247 Param.pLayer->SetEdited(TRUE);
02248 Param.pLayer->SetFrame(TRUE);
02249 #ifdef _DEBUG
02250
02251 BROADCAST_TO_ALL(LayerMsg(Param.pLayer, LayerMsg::REDRAW_LAYER));
02252 #endif
02253 }
02254 break;
02255
02256 case LAYER_MAKEFRAME:
02257 ERROR3IF(Param.pLayer == NULL,"Param.pLayer == NULL");
02258 if (Param.pLayer != NULL)
02259 {
02260 Param.pLayer->SetFrame(Param.NewState);
02261 }
02262 break;
02263
02264 case LAYER_ACTIVE:
02265 ERROR3IF(Param.pLayer == NULL,"Param.pLayer == NULL");
02266 if (Param.pLayer != NULL)
02267 {
02268 Param.pLayer->SetActive(Param.NewState);
02269
02270
02271 BROADCAST_TO_ALL(LayerMsg(Param.pLayer, LayerMsg::UPDATE_ACTIVE_LAYER));
02272 }
02273 break;
02274
02275 default:
02276 ERROR3("Unknown Reason code");
02277 break;
02278 }
02279 }
02280
02281 return Ac;
02282 }
02283
02284
02285
02286
02287
02288
02289
02290
02291
02292
02293
02294
02295
02296
02297
02298
02299
02300 ActionCode LayerStateAction::Execute()
02301 {
02302 ActionCode Ac = AC_FAIL;
02303
02304 if (pOperation->IS_KIND_OF(UndoableOperation))
02305 {
02306 Param.NewState = !Param.NewState;
02307
02308
02309 Swap(Param.VisibleState,Param.OldVisibleState);
02310 Swap(Param.LockedState, Param.OldLockedState);
02311 String_256 Str = Param.OldName;
02312 Param.OldName = Param.NewName;
02313 Param.NewName = Str;
02314
02315 Ac = LayerStateAction::Init((UndoableOperation*)pOperation,pOppositeActLst,Param);
02316
02317 if (Ac != AC_FAIL)
02318 {
02319 LayerSGallery* pGal = Param.pLayerSGal;
02320
02321 if (pGal != NULL)
02322 {
02323 pGal->ForceRedrawOfList();
02324
02325 Document* pDoc = GetWorkingDoc();
02326
02327 if (pDoc != NULL && pGal->IsVisible())
02328 {
02329 pGal->SetBoolGadgetSelected(_R(IDC_BTN_MULTILAYER),!(pDoc->IsMultilayer() == 0));
02330 pGal->SetBoolGadgetSelected(_R(IDC_BTN_ALLVISIBLE),!(pDoc->IsAllVisible() == 0));
02331 }
02332 }
02333 }
02334 }
02335 else
02336 {
02337 ERROR3("LayerStateAction::Execute() called with op that's not an undoable op");
02338 }
02339
02340 return Ac;
02341 }
02342
02343 LayerStateAction::~LayerStateAction()
02344 {
02345 }