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 "freehand.h"
00105 #include "freeinfo.h"
00106 #include "dlgmgr.h"
00107
00108
00109
00110
00111
00112
00113 #include "pen.h"
00114
00115 #include "opbevel.h"
00116
00117 #include "opdrbrsh.h"
00118 #include "brshcomp.h"
00119 #include "brushmsg.h"
00120 #include "brushdlg.h"
00121
00122 #include "brshdata.h"
00123 #include "sgstroke.h"
00124 #include "strkattr.h"
00125 #include "valfunc.h"
00126 #include "ndoptmz.h"
00127 #include "ppstroke.h"
00128 #include "brpress.h"
00129 #include "valfunc.h"
00130
00131
00132
00133 #include "colmsg.h"
00134 #include "brshattr.h"
00135
00136 DECLARE_SOURCE( "$Revision: 1771 $" );
00137
00138
00139 CC_IMPLEMENT_DYNCREATE( FreeHandInfoBarOp, InformationBarOp )
00140 #define new CAM_DEBUG_NEW
00141
00142 PORTNOTE("other", "Disabled Brush editing")
00143 #ifndef EXCLUDE_FROM_XARALX
00144 CBrushGadget FreeHandInfoBarOp::BrushGadget;
00145 #endif
00146
00147
00148
00149
00150
00151 enum {
00152 CONSTANT,
00153 SS_Fallout,
00154 SS_Iron,
00155 ELLIPSE,
00156 SS_SlimBlip,
00157 BLIP,
00158 SS_Cigar,
00159 SS_Cigar2,
00160 SS_Cigar3,
00161 SS_Convex,
00162 RAMPS2,
00163 RAMPS,
00164 SS_Concave,
00165 RAMPL2,
00166 RAMPL,
00167 TEARDROPCURVEDEND,
00168 TEARDROP,
00169 SS_Comet,
00170 SS_Petal,
00171 SS_Reed,
00172 SS_Meteor,
00173 SS_Torpedo,
00174 SS_Missile,
00175 SS_Goldfish,
00176 SS_Yacht,
00177 SS_Barb,
00178 SS_OceanLiner,
00179 PROPELLER,
00180 DOUBLERAMPS,
00181 BEVELENDS,
00182 SAWTOOTH,
00183 INTESTINE,
00184 DECAY
00185 };
00186
00187
00188 const BrushHandle BrushHandle_Many = BrushHandle_NoBrush - 1;
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200 FreeHandInfoBarOp::FreeHandInfoBarOp()
00201 {
00202 DlgResID = _R(IDD_FREEHANDTOOL);
00203
00204
00205 pTool = NULL;
00206 CanRetroFit = FALSE;
00207
00208
00209 ControlsExist = FALSE;
00210
00211 m_pBrushList = NULL;
00212
00213 m_DisplayBrush = BrushHandle_NoBrush;
00214
00215
00216
00217
00218
00219
00220 m_SelectedStroke = CONSTANT;
00221 }
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234 FreeHandInfoBarOp::~FreeHandInfoBarOp()
00235 {
00236 if (m_pBrushList != NULL)
00237 {
00238 m_pBrushList->clear();
00239 delete m_pBrushList;
00240 m_pBrushList = NULL;
00241 }
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251 }
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269 MsgResult FreeHandInfoBarOp::Message(Msg* Message)
00270 {
00271 if (IS_OUR_DIALOG_MSG(Message))
00272 {
00273 DialogMsg* Msg = (DialogMsg*)Message;
00274
00275
00276 if (Msg->DlgMsg == DIM_CANCEL)
00277 {
00278
00279 ControlsExist = FALSE;
00280
00281
00282 Close();
00283 }
00284
00285 else if (Msg->DlgMsg == DIM_CREATE)
00286 {
00287 #if 0
00288
00289 #ifdef EXCLUDE_FROM_XARALX
00290 EnableGadget(_R(IDC_CREATEBRUSH), FALSE);
00291 EnableGadget(_R(IDC_EDITBRUSH), FALSE);
00292 #endif
00293 #endif
00294 HandleCreate();
00295 }
00296 else
00297 {
00298 if (FALSE) {}
00299
00300
00301
00302 #ifdef VECTOR_STROKING
00303 else if (Msg->GadgetID == _R(IDC_FREEHANDPRESSURE))
00304 {
00305 if (Msg->DlgMsg == DIM_LFT_BN_CLICKED)
00306 {
00307 OpDescriptor *pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_TOGGLEPRESSURE);
00308 if (pOpDesc != NULL)
00309 {
00310 pOpDesc->Invoke();
00311 UpdateState();
00312 }
00313 }
00314 }
00315 #endif // VECTOR_STROKING
00316 else if (Msg->GadgetID == _R(IDC_FREEHANDSLIDER))
00317 {
00318 switch (Msg->DlgMsg)
00319 {
00320 case DIM_SLIDER_POS_CHANGING:
00321 {
00322 HandleSliderPosChanging();
00323 break;
00324 }
00325
00326 case DIM_SLIDER_POS_SET:
00327 {
00328
00329 pTool->RetroFitFinished();
00330 break;
00331 }
00332 default:
00333 break;
00334 }
00335 }
00336 else if (Msg->GadgetID == _R(IDC_CREATEBRUSH))
00337 {
00338 pTool->CreateBrush();
00339 UpdateState();
00340 }
00341 else if (Msg->GadgetID == _R(IDC_EDITBRUSH))
00342 {
00343 switch (Msg->DlgMsg)
00344 {
00345 case DIM_LFT_BN_CLICKED:
00346 {
00347 LaunchBrushEditDialog();
00348 break;
00349 }
00350 default:
00351 break;
00352 }
00353 }
00354 else if (Msg->GadgetID == _R(IDC_BRUSHTYPE))
00355 {
00356 switch (Msg->DlgMsg)
00357 {
00358 case DIM_SELECTION_CHANGED:
00359 {
00360 HandleBrushSelectChange();
00361 UpdateState();
00362 break;
00363 }
00364 default:
00365 break;
00366 }
00367 }
00368 else if (Msg->GadgetID == _R(IDC_STROKETYPE))
00369 {
00370 switch (Msg->DlgMsg)
00371 {
00372 case DIM_SELECTION_CHANGED:
00373 {
00374 HandleStrokeSelectChange();
00375
00376 break;
00377 }
00378 default:
00379 break;
00380 }
00381 }
00382 }
00383 }
00384 else
00385 {
00386
00387 if (ControlsExist && Message->IsKindOf(CC_RUNTIME_CLASS(SelChangingMsg)))
00388 {
00389
00390 if (pTool!=NULL)
00391 {
00392
00393 CanRetroFit = pTool->IsRetroPathStillValid();
00394
00395
00396 SetRetroString();
00397 }
00398 }
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410 if (ControlsExist)
00411 {
00412 if (IsVisible ())
00413 {
00414 if (Message->IsKindOf(CC_RUNTIME_CLASS(DocChangingMsg)))
00415 {
00416 Document* pDoc = Document::GetCurrent();
00417 BOOL EnableCombos = pDoc != NULL;
00418 if (!EnableCombos)
00419 {
00420 EnableGadget(_R(IDC_BRUSHTYPE), EnableCombos);
00421 EnableGadget(_R(IDC_STROKETYPE), EnableCombos);
00422 EnableGadget(_R(IDC_FREEHANDSLIDER), EnableCombos);
00423 }
00424 DocChangingMsg* pDocMsg = (DocChangingMsg*)Message;
00425 if (pDocMsg->State == DocChangingMsg::BORNANDSTABLE)
00426 {
00427 EnableGadget(_R(IDC_BRUSHTYPE), TRUE);
00428 EnableGadget(_R(IDC_STROKETYPE), TRUE);
00429 EnableGadget(_R(IDC_FREEHANDSLIDER), TRUE);
00430 if (m_pBrushList == NULL || m_pBrushList->size() == 0)
00431 InitBrushList();
00432 else
00433 ReInitBrushList();
00434
00435 SetBrushListToControl ();
00436
00437 }
00438
00439 }
00440 else if (Message->IsKindOf(CC_RUNTIME_CLASS(BrushDefMsg)))
00441 {
00442 SetBrushListToControl();
00443 SetHeadOfListSelected();
00444
00445 }
00446 }
00447 }
00448
00449
00450 if (Message->IsKindOf(CC_RUNTIME_CLASS(BrushMsg)))
00451
00452
00453 {
00454 BrushHandle SelHandle = ((BrushMsg*)Message)->m_BrushSelected;
00455
00456 if (pTool != NULL)
00457 {
00458 pTool->SetBrushUpdateState(UPDATE_ONIDLE);
00459 pTool->BrushSelected(SelHandle, FALSE);
00460 }
00461
00462
00463 if (SelHandle != BrushHandle_NoBrush)
00464 SetHeadOfList(SelHandle);
00465
00466 m_DisplayBrush = SelHandle;
00467
00468
00469 if (ControlsExist)
00470 {
00471 SetBrushListToControl();
00472 SetHeadOfListSelected();
00473 }
00474 }
00475
00476
00477 if (Message->IsKindOf(CC_RUNTIME_CLASS(StrokeMsg)) && ControlsExist && IsVisible())
00478 SetStrokeComboFromSelection();
00479
00480
00481 if (Message->IsKindOf(CC_RUNTIME_CLASS(ScreenChangeMsg)) || Message->IsKindOf(CC_RUNTIME_CLASS(CurrentAttrChangedMsg))
00482 || Message->IsKindOf(CC_RUNTIME_CLASS(BrushDefMsg)))
00483 {
00484 if (pTool != NULL && HasWindow()
00485 && (Document::GetCurrent() != NULL))
00486 {
00487 pTool->ScreenChanged(TRUE);
00488 UpdateState();
00489 }
00490 }
00491
00492
00493 if (Message->IsKindOf(CC_RUNTIME_CLASS(DocViewMsg)))
00494 {
00495 DocViewMsg* pDVM = (DocViewMsg*)Message;
00496 if (pDVM->State == DocViewMsg::SELCHANGED)
00497 pTool->ScreenChanged(TRUE);
00498 }
00499
00500
00501 if (Message->IsKindOf(CC_RUNTIME_CLASS(NewBrushMsg)))
00502 {
00503 AddBrush();
00504 if (pTool)
00505 {
00506 UINT32 BrushNum = BrushComponent::GetNumberOfBrushes() - 1;
00507 pTool->BrushSelected(BrushNum, FALSE);
00508 }
00509 }
00510 }
00511
00512
00513 if (MESSAGE_IS_A(Message, SelChangingMsg))
00514 {
00515 Document* pDoc = Document::GetCurrent();
00516 if (pDoc != NULL)
00517 {
00518 if (ControlsExist && IsVisible())
00519 {
00520
00521
00522 BrushData Data = GetBrushDataFromSelection();
00523 if (Data.m_BrushHandle != BrushHandle_NoBrush)
00524 {
00525 PORTNOTE("other", "Disabled Brush editing")
00526 #ifndef EXCLUDE_FROM_XARALX
00527 if (BrushGadget.IsDialogOpen())
00528 BrushGadget.ReInitialiseDialog(&Data);
00529 #endif
00530 }
00531
00532 SetBrushComboFromSelection();
00533 SetStrokeComboFromSelection();
00534 }
00535 }
00536
00537 if (pTool != NULL && HasWindow())
00538 pTool->ScreenChanged(TRUE);
00539 }
00540
00541 if (MESSAGE_IS_A(Message, ColourChangingMsg))
00542 {
00543 ColourChangingMsg *TheMsg = (ColourChangingMsg *) Message;
00544
00545
00546
00547 if(TheMsg->State == ColourChangingMsg::SELVIEWCONTEXTCHANGE)
00548 {
00549
00550
00551
00552
00553 if (pTool != NULL && HasWindow())
00554 pTool->ScreenChanged(TRUE);
00555 }
00556 }
00557
00558
00559 return (InformationBarOp::Message(Message));
00560 }
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578 void FreeHandInfoBarOp::AddBrush ()
00579 {
00580 UINT32 BrushNum = BrushComponent::GetNumberOfBrushes() - 1;
00581
00582
00583 if (m_pBrushList == NULL)
00584 {
00585 ERROR3("Brush list is null in FreeHandInfoBarOp::AddBrush");
00586 }
00587 SetHeadOfList((BrushHandle)BrushNum);
00588 m_DisplayBrush = 2;
00589
00590 if (ControlsExist)
00591 {
00592 SetBrushListToControl();
00593 SetHeadOfListSelected();
00594 }
00595
00596 }
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612 void FreeHandInfoBarOp::AddBrush(BrushHandle Handle)
00613 {
00614
00615 if (m_pBrushList == NULL)
00616 {
00617
00618 return;
00619 }
00620 m_pBrushList->push_back(Handle);
00621
00622 if (ControlsExist)
00623 {
00624 SetBrushListToControl();
00625 SetDisplayBrush();
00626 }
00627 }
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641 void FreeHandInfoBarOp::RemoveBrush(BrushHandle Handle)
00642 {
00643
00644 if (m_pBrushList != NULL)
00645 {
00646 m_pBrushList->remove(Handle);
00647 }
00648
00649
00650 m_DisplayBrush = BrushHandle_NoBrush;
00651
00652 if (ControlsExist)
00653 {
00654 SetBrushListToControl();
00655 SetDisplayBrush();
00656 }
00657
00658
00659 if (pTool != NULL)
00660 {
00661 pTool->SetBrushUpdateState(UPDATE_NOW);
00662 pTool->BrushSelected(BrushHandle_NoBrush, FALSE);
00663 }
00664 }
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677 void FreeHandInfoBarOp::HandleCreate()
00678 {
00679 if (WindowID!=NULL)
00680 {
00681
00682
00683 UpdateState();
00684
00685
00686 SetGadgetRange(_R(IDC_FREEHANDSLIDER), 0, 100, 5);
00687 SetGadgetBitmaps(_R(IDC_FREEHANDSLIDER), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
00688
00689
00690 INT32 Smoothness = 50;
00691 if (pTool!=NULL)
00692 Smoothness = pTool->GetSmoothness();
00693 SetLongGadgetValue(_R(IDC_FREEHANDSLIDER), Smoothness);
00694
00695
00696 TCHAR Str[32];
00697 String_32 jcf(_R(IDS_PERCENT_FORMAT));
00698 camSnprintf(Str, 32, jcf, (INT32) Smoothness);
00699 String_32 PercentStr(Str);
00700 SetStringGadgetValue(_R(IDC_FREEHANDPERCENT), PercentStr);
00701
00702
00703 if (pTool!=NULL)
00704 CanRetroFit = pTool->IsRetroPathStillValid();
00705 SetRetroString();
00706
00707
00708 if (m_pBrushList == NULL || m_pBrushList->size() == 0)
00709 InitBrushList();
00710
00711
00712 m_bgddBrushType.Init(WindowID, _R(IDC_BRUSHTYPE));
00713 m_bgddBrushType.SetColumns(3);
00714 m_bgddBrushType.SetItemSize(wxSize(75, 40));
00715
00716
00717 m_bgddStrokes.Init(WindowID, _R(IDC_STROKETYPE));
00718 m_bgddStrokes.SetColumns(3);
00719 m_bgddStrokes.SetItemSize(wxSize(50, 50));
00720
00721
00722 SetBrushListToControl();
00723
00724
00725 SetBrushComboFromSelection();
00726
00727
00728 PORTNOTE("other", "Disabled BrushGadget")
00729 #ifndef EXCLUDE_FROM_XARALX
00730 BrushGadget.LinkControlButton (this, _R(IDC_EDITBRUSH), _R(IDBBL_BRUSHEDIT), _R(IDS_BRUSHEDITDLG));
00731 BrushGadget.DisableTimeStamping ();
00732 #endif
00733
00734
00735 }
00736
00737 ControlsExist = TRUE;
00738 }
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755 void FreeHandInfoBarOp::HandleBrushSelectChange()
00756 {
00757
00758
00759
00760 Document* pDoc = Document::GetCurrent();
00761 if (!pDoc)
00762 return;
00763
00764
00765 INT32 iIndex = m_bgddBrushType.GetSelected();
00766
00767 BrushHandle SelHandle;
00768
00769
00770
00771
00772
00773 SelHandle = GetBrushHandleFromControlIndex(iIndex);
00774
00775
00776
00777 if (pTool != NULL)
00778 {
00779 pTool->SetBrushUpdateState(UPDATE_ONIDLE);
00780 pTool->BrushSelected(SelHandle);
00781 }
00782
00783 if (SelHandle != BrushHandle_NoBrush)
00784 {
00785 SetHeadOfList(SelHandle);
00786 SetBrushListToControl();
00787 m_DisplayBrush = SelHandle;
00788
00789 SetHeadOfListSelected();
00790 }
00791 else
00792 {
00793 m_DisplayBrush = SelHandle;
00794
00795 }
00796
00797
00798
00799
00800 }
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814 void FreeHandInfoBarOp::HandleStrokeSelectChange()
00815 {
00816
00817 Document* pDoc = Document::GetCurrent();
00818 if (!pDoc)
00819 return;
00820
00821
00822 INT32 Index = m_bgddStrokes.GetSelected();
00823
00824
00825
00826
00827
00828 List AttribsList;
00829
00830
00831 NodeAttributePtrItem* pStrokeItem = new NodeAttributePtrItem;
00832 if (pStrokeItem == NULL)
00833 {
00834 ERROR3("Unable to create new stroke item in FreeHandInfoBarOp::HandleStrokeSelectChange");
00835 return;
00836 }
00837
00838
00839 NodeAttributePtrItem* pVarWidthItem = new NodeAttributePtrItem;
00840 if (pVarWidthItem == NULL)
00841 {
00842 ERROR3("Unable to create new variable width item in FreeHandInfoBarOp::HandleStrokeSelectChange");
00843 delete pStrokeItem;
00844 return;
00845 }
00846
00847 NodeAttribute* pVarWidth = NULL;
00848 NodeAttribute* pStrokeType = NULL;
00849
00850
00851 PathProcessorStroke* PPS = NULL;
00852 if (Index != CONSTANT)
00853 {
00854 PPS = new PathProcessorStroke;
00855 if (PPS == NULL)
00856 {
00857 ERROR3("Unable to create new path processor in FreeHandInfoBarOp::HandleStrokeSelectChange");
00858 delete pStrokeItem;
00859 delete pVarWidthItem;
00860 return;
00861 }
00862 }
00863
00864 StrokeTypeAttrValue NewStroke(PPS);
00865 pStrokeType = NewStroke.MakeNode();
00866
00867 if (pStrokeType == NULL)
00868 {
00869 ERROR3("Unable to create new stroke attribute in FreeHandInfoBarOp::HandleStrokeSelectChange");
00870 delete pStrokeItem;
00871 delete pVarWidthItem;
00872 delete PPS;
00873 return;
00874 }
00875
00876 pStrokeItem->NodeAttribPtr = pStrokeType;
00877
00878
00879 switch (Index)
00880 {
00881 case CONSTANT:
00882 {
00883
00884 VariableWidthAttrValue VarWidth;
00885
00886 pVarWidth = VarWidth.MakeNode();
00887
00888 if (pVarWidth)
00889 {
00890 pVarWidthItem->NodeAttribPtr = pVarWidth;
00891 }
00892 else
00893 {
00894 delete pVarWidthItem;
00895 return;
00896 }
00897 }
00898 break;
00899
00900 case RAMPL:
00901 {
00902
00903 VariableWidthAttrValue VarWidth(new ValueFunctionRampL);
00904
00905 pVarWidth = VarWidth.MakeNode();
00906
00907 if (pVarWidth)
00908 {
00909 pVarWidthItem->NodeAttribPtr = pVarWidth;
00910 }
00911 else
00912 {
00913 delete pStrokeItem;
00914 delete pVarWidthItem;
00915 delete pStrokeType;
00916 return;
00917 }
00918 }
00919 break;
00920
00921 case RAMPL2:
00922 {
00923
00924 VariableWidthAttrValue VarWidth(new ValueFunctionRampL2);
00925
00926 pVarWidth = VarWidth.MakeNode();
00927
00928 if (pVarWidth)
00929 {
00930 pVarWidthItem->NodeAttribPtr = pVarWidth;
00931 }
00932 else
00933 {
00934 delete pStrokeItem;
00935 delete pVarWidthItem;
00936 delete pStrokeType;
00937 return;
00938 }
00939 }
00940 break;
00941
00942 case RAMPS:
00943 {
00944
00945 VariableWidthAttrValue VarWidth(new ValueFunctionRampS);
00946
00947 pVarWidth = VarWidth.MakeNode();
00948
00949 if (pVarWidth)
00950 {
00951 pVarWidthItem->NodeAttribPtr = pVarWidth;
00952 }
00953 else
00954 {
00955 delete pStrokeItem;
00956 delete pVarWidthItem;
00957 delete pStrokeType;
00958 return;
00959 }
00960 }
00961 break;
00962
00963 case RAMPS2:
00964 {
00965
00966 VariableWidthAttrValue VarWidth(new ValueFunctionRampS2);
00967
00968 pVarWidth = VarWidth.MakeNode();
00969
00970 if (pVarWidth)
00971 {
00972 pVarWidthItem->NodeAttribPtr = pVarWidth;
00973 }
00974 else
00975 {
00976 delete pStrokeItem;
00977 delete pVarWidthItem;
00978 delete pStrokeType;
00979 return;
00980 }
00981 }
00982 break;
00983
00984 case BLIP:
00985 {
00986
00987 VariableWidthAttrValue VarWidth(new ValueFunctionBlip);
00988
00989 pVarWidth = VarWidth.MakeNode();
00990
00991 if (pVarWidth)
00992 {
00993 pVarWidthItem->NodeAttribPtr = pVarWidth;
00994 }
00995 else
00996 {
00997 delete pStrokeItem;
00998 delete pVarWidthItem;
00999 delete pStrokeType;
01000 return;
01001 }
01002 }
01003 break;
01004
01005 case ELLIPSE:
01006 {
01007
01008 VariableWidthAttrValue VarWidth(new ValueFunctionEllipse);
01009
01010 pVarWidth = VarWidth.MakeNode();
01011
01012 if (pVarWidth)
01013 {
01014 pVarWidthItem->NodeAttribPtr = pVarWidth;
01015 }
01016 else
01017 {
01018 delete pStrokeItem;
01019 delete pVarWidthItem;
01020 delete pStrokeType;
01021 return;
01022 }
01023
01024 }
01025 break;
01026
01027 case TEARDROP:
01028 {
01029
01030 VariableWidthAttrValue VarWidth(new ValueFunctionTeardrop);
01031
01032 pVarWidth = VarWidth.MakeNode();
01033
01034 if (pVarWidth)
01035 {
01036 pVarWidthItem->NodeAttribPtr = pVarWidth;
01037 }
01038 else
01039 {
01040 delete pStrokeItem;
01041 delete pVarWidthItem;
01042 delete pStrokeType;
01043 return;
01044 }
01045 }
01046 break;
01047
01048 case TEARDROPCURVEDEND:
01049 {
01050
01051 VariableWidthAttrValue VarWidth(new ValueFunctionTeardropCurvedEnd);
01052
01053 pVarWidth = VarWidth.MakeNode();
01054
01055 if (pVarWidth)
01056 {
01057 pVarWidthItem->NodeAttribPtr = pVarWidth;
01058 }
01059 else
01060 {
01061 delete pStrokeItem;
01062 delete pVarWidthItem;
01063 delete pStrokeType;
01064 return;
01065 }
01066 }
01067 break;
01068
01069 case DOUBLERAMPS:
01070 {
01071
01072 VariableWidthAttrValue VarWidth(new ValueFunctionDoubleRampS);
01073
01074 pVarWidth = VarWidth.MakeNode();
01075
01076 if (pVarWidth)
01077 {
01078 pVarWidthItem->NodeAttribPtr = pVarWidth;
01079 }
01080 else
01081 {
01082 delete pStrokeItem;
01083 delete pVarWidthItem;
01084 delete pStrokeType;
01085 return;
01086 }
01087 }
01088 break;
01089
01090 case SAWTOOTH:
01091 {
01092
01093 VariableWidthAttrValue VarWidth(new ValueFunctionSawTooth);
01094
01095 pVarWidth = VarWidth.MakeNode();
01096
01097 if (pVarWidth)
01098 {
01099 pVarWidthItem->NodeAttribPtr = pVarWidth;
01100 }
01101 else
01102 {
01103 delete pStrokeItem;
01104 delete pVarWidthItem;
01105 delete pStrokeType;
01106 return;
01107 }
01108 }
01109 break;
01110
01111 case PROPELLER:
01112 {
01113
01114 VariableWidthAttrValue VarWidth(new ValueFunctionPropeller);
01115
01116 pVarWidth = VarWidth.MakeNode();
01117
01118 if (pVarWidth)
01119 {
01120 pVarWidthItem->NodeAttribPtr = pVarWidth;
01121 }
01122 else
01123 {
01124 delete pStrokeItem;
01125 delete pVarWidthItem;
01126 delete pStrokeType;
01127 return;
01128 }
01129 }
01130 break;
01131
01132 case INTESTINE:
01133 {
01134
01135 VariableWidthAttrValue VarWidth(new ValueFunctionIntestine);
01136
01137 pVarWidth = VarWidth.MakeNode();
01138
01139 if (pVarWidth)
01140 {
01141 pVarWidthItem->NodeAttribPtr = pVarWidth;
01142 }
01143 else
01144 {
01145 delete pStrokeItem;
01146 delete pVarWidthItem;
01147 delete pStrokeType;
01148 return;
01149 }
01150 }
01151 break;
01152
01153 case DECAY:
01154 {
01155
01156 VariableWidthAttrValue VarWidth(new ValueFunctionDecay);
01157
01158 pVarWidth = VarWidth.MakeNode();
01159
01160 if (pVarWidth)
01161 {
01162 pVarWidthItem->NodeAttribPtr = pVarWidth;
01163 }
01164 else
01165 {
01166 delete pStrokeItem;
01167 delete pVarWidthItem;
01168 delete pStrokeType;
01169 return;
01170 }
01171 }
01172 break;
01173
01174 case BEVELENDS:
01175 {
01176
01177 VariableWidthAttrValue VarWidth(new ValueFunctionBevelEnds);
01178
01179 pVarWidth = VarWidth.MakeNode();
01180
01181 if (pVarWidth)
01182 {
01183 pVarWidthItem->NodeAttribPtr = pVarWidth;
01184 }
01185 else
01186 {
01187 delete pStrokeItem;
01188 delete pVarWidthItem;
01189 delete pStrokeType;
01190 return;
01191 }
01192 }
01193 break;
01194
01195 case SS_Yacht:
01196 {
01197
01198 VariableWidthAttrValue VarWidth(new ValueFunctionSS_Yacht);
01199
01200 pVarWidth = VarWidth.MakeNode();
01201
01202 if (pVarWidth) { pVarWidthItem->NodeAttribPtr = pVarWidth; }
01203 else
01204 {
01205 delete pStrokeItem;
01206 delete pVarWidthItem;
01207 delete pStrokeType;
01208 return;
01209 }
01210 }
01211 break;
01212
01213 case SS_Iron:
01214 {
01215
01216 VariableWidthAttrValue VarWidth(new ValueFunctionSS_Iron);
01217
01218 pVarWidth = VarWidth.MakeNode();
01219
01220 if (pVarWidth) { pVarWidthItem->NodeAttribPtr = pVarWidth; }
01221 else
01222 {
01223 delete pStrokeItem;
01224 delete pVarWidthItem;
01225 delete pStrokeType;
01226 return;
01227 }
01228 }
01229 break;
01230
01231 case SS_Reed:
01232 {
01233
01234 VariableWidthAttrValue VarWidth(new ValueFunctionSS_Reed);
01235
01236 pVarWidth = VarWidth.MakeNode();
01237
01238 if (pVarWidth) { pVarWidthItem->NodeAttribPtr = pVarWidth; }
01239 else
01240 {
01241 delete pStrokeItem;
01242 delete pVarWidthItem;
01243 delete pStrokeType;
01244 return;
01245 }
01246 }
01247 break;
01248
01249 case SS_Meteor:
01250 {
01251
01252 VariableWidthAttrValue VarWidth(new ValueFunctionSS_Meteor);
01253
01254 pVarWidth = VarWidth.MakeNode();
01255
01256 if (pVarWidth) { pVarWidthItem->NodeAttribPtr = pVarWidth; }
01257 else
01258 {
01259 delete pStrokeItem;
01260 delete pVarWidthItem;
01261 delete pStrokeType;
01262 return;
01263 }
01264 }
01265 break;
01266
01267 case SS_Petal:
01268 {
01269
01270 VariableWidthAttrValue VarWidth(new ValueFunctionSS_Petal);
01271
01272 pVarWidth = VarWidth.MakeNode();
01273
01274 if (pVarWidth) { pVarWidthItem->NodeAttribPtr = pVarWidth; }
01275 else
01276 {
01277 delete pStrokeItem;
01278 delete pVarWidthItem;
01279 delete pStrokeType;
01280 return;
01281 }
01282 }
01283 break;
01284
01285 case SS_Comet:
01286 {
01287
01288 VariableWidthAttrValue VarWidth(new ValueFunctionSS_Comet);
01289
01290 pVarWidth = VarWidth.MakeNode();
01291
01292 if (pVarWidth) { pVarWidthItem->NodeAttribPtr = pVarWidth; }
01293 else
01294 {
01295 delete pStrokeItem;
01296 delete pVarWidthItem;
01297 delete pStrokeType;
01298 return;
01299 }
01300 }
01301 break;
01302
01303 case SS_Fallout:
01304 {
01305
01306 VariableWidthAttrValue VarWidth(new ValueFunctionSS_Fallout);
01307
01308 pVarWidth = VarWidth.MakeNode();
01309
01310 if (pVarWidth) { pVarWidthItem->NodeAttribPtr = pVarWidth; }
01311 else
01312 {
01313 delete pStrokeItem;
01314 delete pVarWidthItem;
01315 delete pStrokeType;
01316 return;
01317 }
01318 }
01319 break;
01320
01321 case SS_Torpedo:
01322 {
01323
01324 VariableWidthAttrValue VarWidth(new ValueFunctionSS_Torpedo);
01325
01326 pVarWidth = VarWidth.MakeNode();
01327
01328 if (pVarWidth) { pVarWidthItem->NodeAttribPtr = pVarWidth; }
01329 else
01330 {
01331 delete pStrokeItem;
01332 delete pVarWidthItem;
01333 delete pStrokeType;
01334 return;
01335 }
01336 }
01337 break;
01338
01339 case SS_Missile:
01340 {
01341
01342 VariableWidthAttrValue VarWidth(new ValueFunctionSS_Missile);
01343
01344 pVarWidth = VarWidth.MakeNode();
01345
01346 if (pVarWidth) { pVarWidthItem->NodeAttribPtr = pVarWidth; }
01347 else
01348 {
01349 delete pStrokeItem;
01350 delete pVarWidthItem;
01351 delete pStrokeType;
01352 return;
01353 }
01354 }
01355 break;
01356
01357 case SS_Convex:
01358 {
01359
01360 VariableWidthAttrValue VarWidth(new ValueFunctionSS_Convex);
01361
01362 pVarWidth = VarWidth.MakeNode();
01363
01364 if (pVarWidth) { pVarWidthItem->NodeAttribPtr = pVarWidth; }
01365 else
01366 {
01367 delete pStrokeItem;
01368 delete pVarWidthItem;
01369 delete pStrokeType;
01370 return;
01371 }
01372 }
01373 break;
01374
01375 case SS_Concave:
01376 {
01377
01378 VariableWidthAttrValue VarWidth(new ValueFunctionSS_Concave);
01379
01380 pVarWidth = VarWidth.MakeNode();
01381
01382 if (pVarWidth) { pVarWidthItem->NodeAttribPtr = pVarWidth; }
01383 else
01384 {
01385 delete pStrokeItem;
01386 delete pVarWidthItem;
01387 delete pStrokeType;
01388 return;
01389 }
01390 }
01391 break;
01392
01393 case SS_SlimBlip:
01394 {
01395
01396 VariableWidthAttrValue VarWidth(new ValueFunctionSS_SlimBlip);
01397
01398 pVarWidth = VarWidth.MakeNode();
01399
01400 if (pVarWidth) { pVarWidthItem->NodeAttribPtr = pVarWidth; }
01401 else
01402 {
01403 delete pStrokeItem;
01404 delete pVarWidthItem;
01405 delete pStrokeType;
01406 return;
01407 }
01408 }
01409 break;
01410
01411 case SS_Cigar:
01412 {
01413
01414 VariableWidthAttrValue VarWidth(new ValueFunctionSS_Cigar);
01415
01416 pVarWidth = VarWidth.MakeNode();
01417
01418 if (pVarWidth) { pVarWidthItem->NodeAttribPtr = pVarWidth; }
01419 else
01420 {
01421 delete pStrokeItem;
01422 delete pVarWidthItem;
01423 delete pStrokeType;
01424 return;
01425 }
01426 }
01427 break;
01428 case SS_Cigar2:
01429 {
01430
01431 VariableWidthAttrValue VarWidth(new ValueFunctionSS_Cigar2);
01432
01433 pVarWidth = VarWidth.MakeNode();
01434
01435 if (pVarWidth) { pVarWidthItem->NodeAttribPtr = pVarWidth; }
01436 else
01437 {
01438 delete pStrokeItem;
01439 delete pVarWidthItem;
01440 delete pStrokeType;
01441 return;
01442 }
01443 }
01444 break;
01445
01446 case SS_Cigar3:
01447 {
01448
01449 VariableWidthAttrValue VarWidth(new ValueFunctionSS_Cigar3);
01450
01451 pVarWidth = VarWidth.MakeNode();
01452
01453 if (pVarWidth) { pVarWidthItem->NodeAttribPtr = pVarWidth; }
01454 else
01455 {
01456 delete pStrokeItem;
01457 delete pVarWidthItem;
01458 delete pStrokeType;
01459 return;
01460 }
01461 }
01462 break;
01463
01464 case SS_OceanLiner:
01465 {
01466
01467 VariableWidthAttrValue VarWidth(new ValueFunctionSS_OceanLiner);
01468
01469 pVarWidth = VarWidth.MakeNode();
01470
01471 if (pVarWidth) { pVarWidthItem->NodeAttribPtr = pVarWidth; }
01472 else
01473 {
01474 delete pStrokeItem;
01475 delete pVarWidthItem;
01476 delete pStrokeType;
01477 return;
01478 }
01479 }
01480 break;
01481
01482 case SS_Goldfish:
01483 {
01484
01485 VariableWidthAttrValue VarWidth(new ValueFunctionSS_Goldfish);
01486
01487 pVarWidth = VarWidth.MakeNode();
01488
01489 if (pVarWidth) { pVarWidthItem->NodeAttribPtr = pVarWidth; }
01490 else
01491 {
01492 delete pStrokeItem;
01493 delete pVarWidthItem;
01494 delete pStrokeType;
01495 return;
01496 }
01497 }
01498 break;
01499
01500 case SS_Barb:
01501 {
01502
01503 VariableWidthAttrValue VarWidth(new ValueFunctionSS_Barb);
01504
01505 pVarWidth = VarWidth.MakeNode();
01506
01507 if (pVarWidth) { pVarWidthItem->NodeAttribPtr = pVarWidth; }
01508 else
01509 {
01510 delete pStrokeItem;
01511 delete pVarWidthItem;
01512 delete pStrokeType;
01513 return;
01514 }
01515 }
01516 break;
01517
01518 default:
01519 {
01520 ERROR3("Unrecognised stroke type in HandleStrokeSelectChange");
01521 delete pStrokeItem;
01522 delete pVarWidthItem;
01523 delete pStrokeType;
01524 m_SelectedStroke = CONSTANT;
01525 return;
01526 }
01527 }
01528
01529
01530
01531 SelRange* pSel = GetApplication()->FindSelection();
01532 if (pSel)
01533 {
01534
01535 if (pSel->IsEmpty())
01536 m_SelectedStroke = Index;
01537
01538
01539 pSel->UpdateParentBoundsOfSelection();
01540 }
01541
01542
01543
01544
01545
01546 if (pStrokeItem != NULL)
01547 AttribsList.AddTail(pStrokeItem);
01548
01549 if (pVarWidthItem != NULL)
01550 AttribsList.AddTail(pVarWidthItem);
01551
01552
01553 AttributeManager::AttributesSelected(AttribsList, _R(IDS_STROKEAPPLY_UNDO));
01554
01555
01556
01557 NodeAttributePtrItem* pAttrItem = (NodeAttributePtrItem*)AttribsList.GetHead();
01558 while (pAttrItem)
01559 {
01560 delete (pAttrItem->NodeAttribPtr);
01561 pAttrItem->NodeAttribPtr = NULL;
01562 pAttrItem = (NodeAttributePtrItem*)AttribsList.GetNext(pAttrItem);
01563 }
01564 AttribsList.DeleteAll();
01565
01566 }
01567
01568
01569
01570
01571
01572
01573
01574
01575
01576
01577
01578
01579
01580
01581 void FreeHandInfoBarOp::HandleSliderPosChanging()
01582 {
01583
01584 TCHAR Str[32];
01585 BOOL Valid;
01586 INT32 Result = GetLongGadgetValue(_R(IDC_FREEHANDSLIDER), 0, 100, 0, &Valid);
01587
01588
01589 String_32 jcf(_R(IDS_PERCENT_FORMAT));
01590 camSnprintf(Str, 32, jcf, (INT32) Result);
01591 String_8 PercentStr(Str);
01592 SetStringGadgetValue(_R(IDC_FREEHANDPERCENT), PercentStr);
01593
01594
01595 if (Valid)
01596 {
01597
01598 pTool->SetSmoothness(Result);
01599 pTool->RetroFitChanging();
01600 }
01601
01602 }
01603
01604
01605
01606
01607
01608
01609
01610
01611
01612
01613
01614
01615
01616 void FreeHandInfoBarOp::LaunchBrushEditDialog()
01617 {
01618
01619
01620 OpDescriptor* pDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_BRUSHEDIT_DLG);
01621 if (pDesc != NULL)
01622 {
01623 pDesc->Invoke();
01624 }
01625
01626 }
01627
01628
01629
01630
01631
01632
01633
01634
01635
01636
01637
01638
01639
01640
01641
01642
01643
01644 BrushData FreeHandInfoBarOp::GetBrushDataFromSelection(BOOL* pSelEmpty)
01645 {
01646
01647 List NodeList;
01648 BevelTools::BuildListOfSelectedNodes(&NodeList, CC_RUNTIME_CLASS(AttrBrushType));
01649 BrushData Data;
01650 INT32 NumItems = NodeList.GetCount();
01651
01652
01653
01654 switch (NumItems)
01655 {
01656 case 0:
01657 if (pSelEmpty != NULL)
01658 *pSelEmpty = TRUE;
01659 NodeList.DeleteAll();
01660 return Data;
01661 case 1:
01662 if (pSelEmpty != NULL)
01663 *pSelEmpty = FALSE;
01664 break;
01665 default:
01666 if (pSelEmpty != NULL)
01667 *pSelEmpty = FALSE;
01668 NodeList.DeleteAll();
01669 return Data;
01670 }
01671
01672
01673 NodeListItem * pItem = (NodeListItem *)NodeList.GetHead();
01674
01675 if (pItem)
01676 {
01677 Node* pBrush = pItem->pNode;
01678 if (pBrush)
01679 {
01680 AttrBrushType* pAttrBrush = (AttrBrushType*)pBrush;
01681 if (pAttrBrush->GetBrushHandle() != BrushHandle_NoBrush)
01682 {
01683 Data = pAttrBrush->GetBrushData();
01684
01685 }
01686 }
01687 }
01688 NodeList.DeleteAll();
01689 return Data;
01690 }
01691
01692
01693
01694
01695
01696
01697
01698
01699
01700
01701
01702
01703
01704
01705
01706
01707 BrushHandle FreeHandInfoBarOp::GetBrushHandleFromSelection(BOOL* pSelEmpty)
01708 {
01709
01710 List NodeList;
01711 BevelTools::BuildListOfSelectedNodes(&NodeList, CC_RUNTIME_CLASS(AttrBrushType), TRUE);
01712 BrushData Data;
01713 INT32 NumItems = NodeList.GetCount();
01714
01715 BrushHandle SelHandle = BrushHandle_NoBrush;
01716
01717 if (NumItems != 0)
01718 {
01719 if (pSelEmpty !=NULL)
01720 *pSelEmpty = FALSE;
01721
01722 NodeListItem * pItem = (NodeListItem *)NodeList.GetHead();
01723
01724 BOOL bFirst = TRUE;
01725
01726 AttrBrushType* pAttrBrush = NULL;
01727 Node* pBrush = NULL;
01728 while (pItem)
01729 {
01730 pBrush = pItem->pNode;
01731 if (pBrush)
01732 {
01733 pAttrBrush = (AttrBrushType*)pBrush;
01734 if (bFirst)
01735 {
01736 SelHandle = pAttrBrush->GetBrushHandle();
01737 bFirst = FALSE;
01738 }
01739 else
01740 {
01741
01742 if (pAttrBrush->GetBrushHandle() != SelHandle)
01743 {
01744 SelHandle = BrushHandle_Many;
01745 break;
01746 }
01747 }
01748 }
01749 pItem = (NodeListItem *)NodeList.GetNext(pItem);
01750 }
01751 }
01752 else
01753 {
01754
01755 SelRange* pSel = GetApplication()->FindSelection();
01756 if (pSel && pSel->IsEmpty())
01757 {
01758 if (pSelEmpty != NULL)
01759 *pSelEmpty = TRUE;
01760 }
01761 }
01762 NodeList.DeleteAll();
01763 return SelHandle;
01764 }
01765
01766
01767
01768
01769
01770
01771
01772
01773
01774
01775
01776
01777
01778 BOOL FreeHandInfoBarOp::InitBrushList()
01779 {
01780 if (m_pBrushList == NULL)
01781 m_pBrushList = new BrushList;
01782
01783 if (m_pBrushList == NULL)
01784 return FALSE;
01785
01786 m_pBrushList->clear();
01787
01788 UINT32 NumBrushes = BrushComponent::GetNumberOfBrushes();
01789
01790 for (UINT32 Index = 0; Index < NumBrushes; Index++)
01791 {
01792 BrushHandle Handle = Index;
01793 m_pBrushList->push_back(Handle);
01794 }
01795
01796 return TRUE;
01797 }
01798
01799
01800
01801
01802
01803
01804
01805
01806
01807
01808
01809
01810
01811
01812
01813
01814
01815
01816 BOOL FreeHandInfoBarOp::ReInitBrushList()
01817 {
01818 if (m_pBrushList == NULL)
01819 return InitBrushList();
01820
01821 UINT32 NumBrushes = BrushComponent::GetNumberOfBrushes();
01822 UINT32 NumListBrushes = m_pBrushList->size();
01823
01824 while (NumListBrushes < NumBrushes)
01825 {
01826 m_pBrushList->push_back(NumListBrushes);
01827 NumListBrushes++;
01828 }
01829 return TRUE;
01830
01831 }
01832
01833
01834
01835
01836
01837
01838
01839
01840
01841
01842
01843
01844
01845 BOOL FreeHandInfoBarOp::SetBrushListToControl()
01846 {
01847
01848 if (m_pBrushList == NULL)
01849 return TRUE;
01850
01851
01852 Document* pDoc = Document::GetCurrent();
01853 if (pDoc == NULL)
01854 return TRUE;
01855
01856
01857
01858 m_bgddBrushType.Clear();
01859
01860
01861
01862
01863
01864
01865
01866 BrushHandle Handle = BrushHandle_NoBrush;
01867
01868 BrushList::const_iterator iter;
01869 for (iter = m_pBrushList->begin(); iter !=m_pBrushList->end(); iter++)
01870 {
01871
01872 Handle = *iter;
01873
01874
01875 if (Handle != BrushHandle_NoBrush)
01876 {
01877 AttrBrushType* pNewAttr = BrushComponent::CreateNode (Handle);
01878
01879 if (pNewAttr != NULL)
01880 m_bgddBrushType.AddItem(pNewAttr);
01881 }
01882 else
01883 {
01884 ERROR3("Default brush handle found in list in FreeHandInfoBarOp::SetBrushListToControl");
01885 }
01886 }
01887
01888 return SetStrokesToControl() ;
01889 }
01890
01891
01892
01893
01894
01895
01896
01897
01898
01899
01900
01901
01902 BOOL FreeHandInfoBarOp::SetStrokesToControl()
01903 {
01904
01905 m_bgddStrokes.Clear();
01906
01907
01908
01909
01910
01911
01912 VariableWidthAttrValue *pAttr;
01913 pAttr = new VariableWidthAttrValue(NULL);
01914 VarWidthItem* pItem = new VarWidthItem(pAttr, String_64(TEXT("Constant")));
01915 m_bgddStrokes.AddItem(pItem);
01916
01917
01918 pAttr = new VariableWidthAttrValue(new ValueFunctionSS_Fallout);
01919 pItem = new VarWidthItem(pAttr, String_64(TEXT("Fallout")));
01920 m_bgddStrokes.AddItem(pItem);
01921
01922
01923 pAttr = new VariableWidthAttrValue(new ValueFunctionSS_Iron);
01924 pItem = new VarWidthItem(pAttr, String_64(TEXT("Iron")));
01925 m_bgddStrokes.AddItem(pItem);
01926
01927
01928 pAttr = new VariableWidthAttrValue(new ValueFunctionEllipse);
01929 pItem = new VarWidthItem(pAttr, String_64(TEXT("Ellipse")));
01930 m_bgddStrokes.AddItem(pItem);
01931
01932
01933 pAttr = new VariableWidthAttrValue(new ValueFunctionSS_SlimBlip);
01934 pItem = new VarWidthItem(pAttr, String_64(TEXT("Slim Blip")));
01935 m_bgddStrokes.AddItem(pItem);
01936
01937
01938 pAttr = new VariableWidthAttrValue(new ValueFunctionBlip);
01939 pItem = new VarWidthItem(pAttr, String_64(TEXT("Blip")));
01940 m_bgddStrokes.AddItem(pItem);
01941
01942
01943 pAttr = new VariableWidthAttrValue(new ValueFunctionSS_Cigar);
01944 pItem = new VarWidthItem(pAttr, String_64(TEXT("Cigar")));
01945 m_bgddStrokes.AddItem(pItem);
01946
01947
01948 pAttr = new VariableWidthAttrValue(new ValueFunctionSS_Cigar2);
01949 pItem = new VarWidthItem(pAttr, String_64(TEXT("Cigar 2")));
01950 m_bgddStrokes.AddItem(pItem);
01951
01952
01953 pAttr = new VariableWidthAttrValue(new ValueFunctionSS_Cigar3);
01954 pItem = new VarWidthItem(pAttr, String_64(TEXT("Cigar 3")));
01955 m_bgddStrokes.AddItem(pItem);
01956
01957
01958 pAttr = new VariableWidthAttrValue(new ValueFunctionSS_Convex);
01959 pItem = new VarWidthItem(pAttr, String_64(TEXT("Convex")));
01960 m_bgddStrokes.AddItem(pItem);
01961
01962
01963 pAttr = new VariableWidthAttrValue(new ValueFunctionRampS2);
01964 pItem = new VarWidthItem(pAttr, String_64(TEXT("Convex 2")));
01965 m_bgddStrokes.AddItem(pItem);
01966
01967
01968 pAttr = new VariableWidthAttrValue(new ValueFunctionRampS);
01969 pItem = new VarWidthItem(pAttr, String_64(TEXT("Convex 3")));
01970 m_bgddStrokes.AddItem(pItem);
01971
01972
01973 pAttr = new VariableWidthAttrValue(new ValueFunctionSS_Concave);
01974 pItem = new VarWidthItem(pAttr, String_64(TEXT("Concave")));
01975 m_bgddStrokes.AddItem(pItem);
01976
01977
01978 pAttr = new VariableWidthAttrValue(new ValueFunctionRampL2);
01979 pItem = new VarWidthItem(pAttr, String_64(TEXT("Concave 2")));
01980 m_bgddStrokes.AddItem(pItem);
01981
01982
01983 pAttr = new VariableWidthAttrValue(new ValueFunctionRampL);
01984 pItem = new VarWidthItem(pAttr, String_64(TEXT("Concave 3")));
01985 m_bgddStrokes.AddItem(pItem);
01986
01987
01988 pAttr = new VariableWidthAttrValue(new ValueFunctionTeardropCurvedEnd);
01989 pItem = new VarWidthItem(pAttr, String_64(TEXT("Dab")));
01990 m_bgddStrokes.AddItem(pItem);
01991
01992
01993 pAttr = new VariableWidthAttrValue(new ValueFunctionTeardrop);
01994 pItem = new VarWidthItem(pAttr, String_64(TEXT("Raindrop")));
01995 m_bgddStrokes.AddItem(pItem);
01996
01997
01998 pAttr = new VariableWidthAttrValue(new ValueFunctionSS_Comet);
01999 pItem = new VarWidthItem(pAttr, String_64(TEXT("Comet")));
02000 m_bgddStrokes.AddItem(pItem);
02001
02002
02003 pAttr = new VariableWidthAttrValue(new ValueFunctionSS_Petal);
02004 pItem = new VarWidthItem(pAttr, String_64(TEXT("Petal")));
02005 m_bgddStrokes.AddItem(pItem);
02006
02007
02008 pAttr = new VariableWidthAttrValue(new ValueFunctionSS_Reed);
02009 pItem = new VarWidthItem(pAttr, String_64(TEXT("Reed")));
02010 m_bgddStrokes.AddItem(pItem);
02011
02012
02013 pAttr = new VariableWidthAttrValue(new ValueFunctionSS_Meteor);
02014 pItem = new VarWidthItem(pAttr, String_64(TEXT("Meteor")));
02015 m_bgddStrokes.AddItem(pItem);
02016
02017
02018 pAttr = new VariableWidthAttrValue(new ValueFunctionSS_Torpedo);
02019 pItem = new VarWidthItem(pAttr, String_64(TEXT("Torpedo")));
02020 m_bgddStrokes.AddItem(pItem);
02021
02022
02023 pAttr = new VariableWidthAttrValue(new ValueFunctionSS_Missile);
02024 pItem = new VarWidthItem(pAttr, String_64(TEXT("Missile")));
02025 m_bgddStrokes.AddItem(pItem);
02026
02027
02028 pAttr = new VariableWidthAttrValue(new ValueFunctionSS_Goldfish);
02029 pItem = new VarWidthItem(pAttr, String_64(TEXT("Goldfish")));
02030 m_bgddStrokes.AddItem(pItem);
02031
02032
02033 pAttr = new VariableWidthAttrValue(new ValueFunctionSS_Yacht);
02034 pItem = new VarWidthItem(pAttr, String_64(TEXT("Yacht")));
02035 m_bgddStrokes.AddItem(pItem);
02036
02037
02038 pAttr = new VariableWidthAttrValue(new ValueFunctionSS_Barb);
02039 pItem = new VarWidthItem(pAttr, String_64(TEXT("Barb")));
02040 m_bgddStrokes.AddItem(pItem);
02041
02042
02043 pAttr = new VariableWidthAttrValue(new ValueFunctionSS_OceanLiner);
02044 pItem = new VarWidthItem(pAttr, String_64(TEXT("Ocean Liner")));
02045 m_bgddStrokes.AddItem(pItem);
02046
02047
02048 pAttr = new VariableWidthAttrValue(new ValueFunctionPropeller);
02049 pItem = new VarWidthItem(pAttr, String_64(TEXT("Propeller")));
02050 m_bgddStrokes.AddItem(pItem);
02051
02052
02053 pAttr = new VariableWidthAttrValue(new ValueFunctionDoubleRampS);
02054 pItem = new VarWidthItem(pAttr, String_64(TEXT("Bow Tie")));
02055
02056 m_bgddStrokes.AddItem(pItem);
02057
02058
02059 pAttr = new VariableWidthAttrValue(new ValueFunctionBevelEnds);
02060 pItem = new VarWidthItem(pAttr, String_64(TEXT("Bevel Ends")));
02061 m_bgddStrokes.AddItem(pItem);
02062
02063
02064 pAttr = new VariableWidthAttrValue(new ValueFunctionSawTooth);
02065 pItem = new VarWidthItem(pAttr, String_64(TEXT("Saw Tooth")));
02066
02067 m_bgddStrokes.AddItem(pItem);
02068
02069
02070 pAttr = new VariableWidthAttrValue(new ValueFunctionIntestine);
02071 pItem = new VarWidthItem(pAttr, String_64(TEXT("Intestine")));
02072 m_bgddStrokes.AddItem(pItem);
02073
02074
02075 pAttr = new VariableWidthAttrValue(new ValueFunctionDecay);
02076 pItem = new VarWidthItem(pAttr, String_64(TEXT("Decay")));
02077 m_bgddStrokes.AddItem(pItem);
02078
02079
02080 SetStrokeComboFromSelection();
02081
02082 return TRUE;
02083 }
02084
02085
02086
02087
02088
02089
02090
02091
02092
02093
02094
02095
02096
02097 void FreeHandInfoBarOp::SetHeadOfListSelected()
02098 {
02099
02100
02101 Document* pDoc = Document::GetCurrent();
02102 if (pDoc == NULL)
02103 return;
02104 if (m_pBrushList == NULL)
02105 {
02106 ERROR3("Brush list is NULL in FreeHandInfoBarOp::SetHeadOfListSelected");
02107 return;
02108 }
02109
02110
02111
02112 if (!m_pBrushList->empty())
02113 {
02114 BrushHandle Handle = m_pBrushList->front();
02115
02116
02117 m_bgddBrushType.SetSelected(0);
02118
02119 m_DisplayBrush = Handle;
02120
02121 }
02122
02123 }
02124
02125
02126
02127
02128
02129
02130
02131
02132
02133
02134
02135
02136
02137 void FreeHandInfoBarOp::SetDisplayBrush()
02138 {
02139
02140
02141 INT32 iIndex = GetControlIndexFromBrushHandle(m_DisplayBrush);
02142
02143 m_bgddBrushType.SetSelected(iIndex);
02144
02145
02146
02147
02148
02149
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 void FreeHandInfoBarOp::SetBrushComboFromSelection()
02177 {
02178
02179
02180
02181
02182
02183
02184
02185
02186
02187 BOOL bSelectionEmpty = FALSE;
02188 BrushHandle SelHandle = GetBrushHandleFromSelection(&bSelectionEmpty);
02189
02190 switch (SelHandle)
02191 {
02192 case BrushHandle_NoBrush:
02193 {
02194
02195
02196 if (bSelectionEmpty)
02197 {
02198 SetDisplayBrush();
02199 }
02200 else
02201 {
02202
02203 BrushHandle Temp = m_DisplayBrush;
02204 m_DisplayBrush = SelHandle;
02205 SetDisplayBrush();
02206
02207 m_DisplayBrush = Temp;
02208 }
02209 }
02210 break;
02211 case BrushHandle_Many:
02212 {
02213
02214 String_256 Many;
02215 Many.Load(_R(IDS_FILLTOOL_MANY));
02216
02217
02218
02219 m_bgddBrushType.SetSelected(-1);
02220
02221 }
02222 break;
02223
02224 default:
02225 {
02226
02227 BrushHandle Temp = m_DisplayBrush;
02228 m_DisplayBrush = SelHandle;
02229 SetDisplayBrush();
02230
02231 m_DisplayBrush = Temp;
02232 }
02233 break;
02234 }
02235
02236 }
02237
02238
02239
02240
02241
02242
02243
02244
02245
02246
02247
02248
02249
02250
02251
02252 void FreeHandInfoBarOp::SetStrokeComboFromSelection()
02253 {
02254 Document* pDoc = Document::GetCurrent();
02255
02256
02257 if (pDoc == NULL)
02258 return;
02259
02260
02261 SelRange* pSel = GetApplication()->FindSelection();
02262
02263 INT32 SelectedStroke = m_SelectedStroke;
02264
02265 if (pSel)
02266 {
02267 Node* pNode = pSel->FindFirst();
02268
02269
02270 AttrVariableWidth* pVarWidth = NULL;
02271 VariableWidthAttrValue* pVal = NULL;
02272 ValueFunction* pFunk = NULL;
02273 ValueFunctionID ID = ValueFunctionID_None;
02274
02275 BOOL bFirst = TRUE;
02276 BOOL bDifferent = FALSE;
02277 INT32 NumItems = 0;
02278
02279
02280
02281
02282
02283 while (pNode)
02284 {
02285 NumItems++;
02286
02287
02288 if (pNode->IsAnObject())
02289 {
02290
02291 ((NodeRenderableInk*)pNode)->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrVariableWidth),
02292 (NodeAttribute**)&pVarWidth);
02293
02294 if (pVarWidth)
02295 {
02296
02297 pVal = (VariableWidthAttrValue*)pVarWidth->GetAttributeValue();
02298 pFunk = pVal->GetWidthFunction();
02299
02300
02301 if (bFirst)
02302 {
02303 if (pFunk)
02304 ID = pFunk->GetUniqueID();
02305
02306
02307 SelectedStroke = GetStrokeIndexFromValueFunctionID(ID);
02308
02309 bFirst = FALSE;
02310 }
02311 else
02312 {
02313
02314 if (pFunk && (pFunk->GetUniqueID() != ID))
02315 {
02316 bDifferent = TRUE;
02317 break;
02318 }
02319 }
02320 }
02321
02322 }
02323 pNode = pSel->FindNext(pNode);
02324 }
02325
02326
02327 if (NumItems == 0)
02328 {
02329
02330 AttributeManager* pAttrMgr = &(pDoc->GetAttributeMgr());
02331 if (pAttrMgr == NULL)
02332 {
02333 ERROR3("Unable to get attribute manager!");
02334 return;
02335 }
02336
02337
02338 pVarWidth = NULL;
02339 pVarWidth = (AttrVariableWidth*)pAttrMgr->GetCurrentAttribute(CC_RUNTIME_CLASS(NodeRenderableInk),
02340 CC_RUNTIME_CLASS(AttrVariableWidth));
02341 if (pVarWidth)
02342 {
02343 VariableWidthAttrValue* pVal = (VariableWidthAttrValue*)pVarWidth->GetAttributeValue();
02344 ValueFunction* pFunk = pVal->GetWidthFunction();
02345 if (pFunk)
02346 {
02347 SelectedStroke = GetStrokeIndexFromValueFunctionID(pFunk->GetUniqueID());
02348 }
02349 else
02350 {
02351 SelectedStroke = CONSTANT;
02352 }
02353 }
02354 }
02355
02356 if (bDifferent)
02357 {
02358
02359
02360
02361
02362
02363
02364
02365
02366
02367 m_bgddStrokes.SetSelected(-1);
02368 return;
02369 }
02370
02371 }
02372
02373
02374 m_bgddStrokes.SetSelected(SelectedStroke);
02375 }
02376
02377
02378
02379
02380
02381
02382
02383
02384
02385
02386
02387
02388
02389
02390
02391
02392
02393
02394
02395 INT32 FreeHandInfoBarOp::GetStrokeIndexFromValueFunctionID(ValueFunctionID ID)
02396 {
02397 INT32 ReturnVal = CONSTANT;
02398 switch (ID)
02399 {
02400 case ValueFunctionID_None:
02401 break;
02402 case ValueFunctionID_Constant:
02403 break;
02404 case ValueFunctionID_RampS:
02405 ReturnVal = RAMPS;
02406 break;
02407 case ValueFunctionID_RampS2:
02408 ReturnVal = RAMPS2;
02409 break;
02410 case ValueFunctionID_Teardrop:
02411 ReturnVal = TEARDROP;
02412 break;
02413 case ValueFunctionID_Ellipse:
02414 ReturnVal = ELLIPSE;
02415 break;
02416 case ValueFunctionID_Blip:
02417 ReturnVal = BLIP;
02418 break;
02419 case ValueFunctionID_RampL:
02420 ReturnVal = RAMPL;
02421 break;
02422 case ValueFunctionID_RampL2:
02423 ReturnVal = RAMPL2;
02424 break;
02425 case ValueFunctionID_DoubleRampS:
02426 ReturnVal = DOUBLERAMPS;
02427 break;
02428 case ValueFunctionID_TeardropCurvedEnd:
02429 ReturnVal = TEARDROPCURVEDEND;
02430 break;
02431 case ValueFunctionID_SawTooth:
02432 ReturnVal = SAWTOOTH;
02433 break;
02434 case ValueFunctionID_Propeller:
02435 ReturnVal = PROPELLER;
02436 break;
02437 case ValueFunctionID_Intestine:
02438 ReturnVal = INTESTINE;
02439 break;
02440 case ValueFunctionID_Decay:
02441 ReturnVal = DECAY;
02442 break;
02443 case ValueFunctionID_BevelEnds:
02444 ReturnVal = BEVELENDS;
02445 break;
02446 case ValueFunctionID_SS_Yacht:
02447 ReturnVal = SS_Yacht;
02448 break;
02449 case ValueFunctionID_SS_Iron:
02450 ReturnVal = SS_Iron;
02451 break;
02452 case ValueFunctionID_SS_Reed:
02453 ReturnVal = SS_Reed;
02454 break;
02455 case ValueFunctionID_SS_Meteor:
02456 ReturnVal = SS_Meteor;
02457 break;
02458 case ValueFunctionID_SS_Petal:
02459 ReturnVal = SS_Petal;
02460 break;
02461 case ValueFunctionID_SS_Comet:
02462 ReturnVal = SS_Comet;
02463 break;
02464 case ValueFunctionID_SS_Fallout:
02465 ReturnVal = SS_Fallout;
02466 break;
02467 case ValueFunctionID_SS_Torpedo:
02468 ReturnVal = SS_Torpedo;
02469 break;
02470 case ValueFunctionID_SS_Missile:
02471 ReturnVal = SS_Missile;
02472 break;
02473 case ValueFunctionID_SS_Convex:
02474 ReturnVal = SS_Convex;
02475 break;
02476 case ValueFunctionID_SS_Concave:
02477 ReturnVal = SS_Concave;
02478 break;
02479 case ValueFunctionID_SS_SlimBlip:
02480 ReturnVal = SS_SlimBlip;
02481 break;
02482 case ValueFunctionID_SS_Cigar:
02483 ReturnVal = SS_Cigar;
02484 break;
02485 case ValueFunctionID_SS_Cigar2:
02486 ReturnVal = SS_Cigar2;
02487 break;
02488 case ValueFunctionID_SS_Cigar3:
02489 ReturnVal = SS_Cigar3;
02490 break;
02491 case ValueFunctionID_SS_OceanLiner:
02492 ReturnVal = SS_OceanLiner;
02493 break;
02494 case ValueFunctionID_SS_Goldfish:
02495 ReturnVal = SS_Goldfish;
02496 break;
02497 case ValueFunctionID_SS_Barb:
02498 ReturnVal = SS_Barb;
02499 break;
02500
02501 default:
02502 ERROR3("Illegal ValueFunction ID");
02503 break;
02504 }
02505
02506 return ReturnVal;
02507 }
02508
02509
02510
02511
02512
02513
02514
02515
02516
02517
02518
02519
02520
02521 BrushHandle FreeHandInfoBarOp::GetBrushHandleFromControlIndex(BrushHandle Index)
02522 {
02523 BrushHandle RetVal = BrushHandle_NoBrush;
02524 if (m_pBrushList != NULL)
02525 {
02526 size_t i = (size_t)Index;
02527 if (i<m_pBrushList->size())
02528 {
02529 BrushList::const_iterator iter = m_pBrushList->begin();
02530 for (size_t n=0; n<i; n++) iter++;
02531 return *iter;
02532 }
02533 }
02534 return RetVal;
02535 }
02536
02537
02538
02539
02540
02541
02542
02543
02544
02545
02546
02547
02548
02549 INT32 FreeHandInfoBarOp::GetControlIndexFromBrushHandle(BrushHandle Handle)
02550 {
02551 INT32 Retval = -1;
02552 if (m_pBrushList != NULL)
02553 {
02554 INT32 Counter = 0;
02555 BrushList::const_iterator iter;
02556 for (iter = m_pBrushList->begin(); iter != m_pBrushList->end(); iter++)
02557 {
02558 if (*iter == Handle)
02559 {
02560 Retval = Counter;
02561 break;
02562 }
02563 Counter++;
02564 }
02565 }
02566 return Retval;
02567 }
02568
02569
02570
02571
02572
02573
02574
02575
02576
02577
02578
02579
02580
02581
02582 void FreeHandInfoBarOp::SetHeadOfList(BrushHandle Handle)
02583 {
02584 if (Handle == BrushHandle_NoBrush)
02585 {
02586 ERROR3("Attempting to set BrushHandle_NoBrush to head of list in FreeHandInfoBarOp::SetHeadOfList");
02587 return;
02588 }
02589
02590 if (m_pBrushList == NULL)
02591 {
02592 ERROR3("Brush list is NULL in FreeHandInfoBarOp::SetHeadOfList");
02593 return;
02594 }
02595
02596
02597 m_pBrushList->remove(Handle);
02598
02599 m_pBrushList->push_front(Handle);
02600
02601 }
02602
02603
02604
02605
02606
02607
02608
02609
02610
02611
02612
02613
02614
02615
02616
02617 void FreeHandInfoBarOp::SetDefaultStrokeInCombo()
02618 {
02619
02620
02621 m_bgddBrushType.SetSelected(0);
02622
02623 }
02624
02625
02626
02627
02628
02629
02630
02631
02632
02633
02634
02635
02636 void FreeHandInfoBarOp::SetToolActiveState(BOOL IsToolActive)
02637 {
02638
02639 ControlsExist = IsToolActive;
02640 }
02641
02642
02643
02644
02645
02646
02647
02648
02649
02650
02651
02652
02653
02654
02655
02656 void FreeHandInfoBarOp::SetRetroState(BOOL CanFit)
02657 {
02658
02659 CanRetroFit = CanFit;
02660
02661
02662 SetRetroString();
02663 }
02664
02665
02666
02667
02668
02669
02670
02671
02672
02673
02674
02675
02676
02677
02678 void FreeHandInfoBarOp::SetRetroString()
02679 {
02680
02681 if (WindowID!=NULL)
02682 {
02683 if (CanRetroFit)
02684 {
02685
02686 String_64 RetroWord;
02687 if (RetroWord.Load(_R(IDS_FHANDRETROTEXT)))
02688 {
02689
02690 SetStringGadgetValue(_R(IDC_FREEHANDRETRO), RetroWord);
02691 }
02692 }
02693 else
02694 {
02695
02696 String_8 RetroWord(_T(""));
02697 SetStringGadgetValue(_R(IDC_FREEHANDRETRO), RetroWord);
02698 }
02699 }
02700 }
02701
02702
02703
02704
02705
02706
02707
02708
02709
02710
02711
02712
02713
02714
02715 void FreeHandInfoBarOp::UpdateState()
02716 {
02717
02718 if (!ControlsExist)
02719 return;
02720
02721
02722 OpState State = CBrushEditDlg::GetState(NULL, NULL);
02723
02724 if (State.Greyed == FALSE)
02725 EnableGadget(_R(IDC_EDITBRUSH), TRUE);
02726 else
02727 EnableGadget(_R(IDC_EDITBRUSH), FALSE);
02728
02729 SelRange* pSel = GetApplication()->FindSelection();
02730 if (pSel != NULL)
02731 {
02732
02733 if (pSel->FindFirst() == NULL)
02734 EnableGadget(_R(IDC_CREATEBRUSH), FALSE);
02735 else
02736 EnableGadget(_R(IDC_CREATEBRUSH), TRUE);
02737
02738 }
02739
02740
02741
02742
02743 #ifdef VECTOR_STROKING
02744
02745
02746 OpDescriptor *pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_TOGGLEPRESSURE);
02747 if (pOpDesc != NULL)
02748 {
02749 String_256 Why;
02750 OpState State = pOpDesc->GetOpsState(&Why);
02751
02752
02753
02754 CWindowID hGadget = DialogManager::GetGadget(GetReadWriteWindowID (), _R(IDC_FREEHANDPRESSURE));
02755
02756 if (hGadget)
02757 {
02758 SetBoolGadgetSelected(_R(IDC_FREEHANDPRESSURE), (State.Ticked) ? 1 : 0);
02759 EnableGadget(_R(IDC_FREEHANDPRESSURE), (State.Greyed) ? 0 : 1);
02760 }
02761 }
02762 #endif // VECTOR_STROKING
02763
02764
02765
02766 }
02767
02768