00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 #include "camtypes.h"
00100
00101 DECLARE_SOURCE("$Revision: 1732 $");
00102
00103 #include "brushdlg.h"
00104 #include "dlgmgr.h"
00105
00106
00107
00108 #include "brshattr.h"
00109 #include "brshdata.h"
00110 #include "ppbrush.h"
00111
00112
00113 #include "optsmsgs.h"
00114
00115 #include "qualattr.h"
00116 #include "ccdc.h"
00117
00118 #include "brushop.h"
00119 #include "brushmsg.h"
00120
00121 #include "opbevel.h"
00122 #include "freeinfo.h"
00123 #include "sgline.h"
00124
00125
00126 #include "freehand.h"
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155 CC_IMPLEMENT_DYNCREATE( CBrushEditDlg, DialogTabOp )
00156
00157 const INT32 MinSpacingSlider = 0;
00158 const INT32 MaxSpacingSlider = 99;
00159 const INT32 MinOffsetSlider = 0;
00160 const INT32 MaxOffsetSlider = 100;
00161 const INT32 MinScalingSlider = 0;
00162 const INT32 MaxScalingSlider = 99;
00163 const INT32 MinMultiSlider = 90;
00164 const INT32 MaxMultiSlider = 110;
00165 const INT32 MinScalingIncrSlider = -50;
00166 const INT32 MaxScalingIncrSlider = 50;
00167 const double DefaultRotationAngle = 0;
00168
00169 const INT32 MIN_ROTATION_SLIDER = 0;
00170 const INT32 MAX_ROTATION_SLIDER = 360;
00171 const INT32 MIN_ROTATION_INCR_SLIDER = -180;
00172 const INT32 MAX_ROTATION_INCR_SLIDER = 180;
00173 const INT32 MAX_ROTATION_RANDOM_SLIDER = 360;
00174 const INT32 MIN_RANDOM_SLIDER = 0;
00175 const INT32 MAX_RANDOM_SLIDER = 100;
00176 const INT32 MAX_RANDOM_SAT_SLIDER = 100;
00177 const INT32 MAX_RANDOM_HUE_SLIDER = 360;
00178 const INT32 MIN_SPACING_INCR = -10;
00179 const INT32 MAX_SPACING_INCR = 10;
00180 const INT32 MIN_PRESSURE_SLIDER = 0;
00181 const INT32 MAX_PRESSURE_SLIDER = 100;
00182 const INT32 MAXSPACINGMULTIPLIER = 5;
00183 const INT32 MAXOFFSETMULTIPLIER = 3;
00184 const INT32 MIN_TRANSP_SLIDER = 0;
00185 const INT32 MAX_TRANSP_SLIDER = 200;
00186 const double ExpFactor = 1.6;
00187 const double InvFactor = 1/ExpFactor;
00188
00189
00190
00191 const double MinSliderSpacing = 75;
00192
00193
00194 const double MinOffset = 0;
00195 const double MaxOffset = 300;
00196
00197
00198 #define new CAM_DEBUG_NEW
00199
00200 const UINT32 CBrushEditDlg::IDD = _R(IDD_BRUSHEDIT);
00201 const CDlgMode CBrushEditDlg::Mode = MODELESS;
00202 BOOL CBrushEditDlg::m_bIsOpen = FALSE;
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220 CBrushEditDlg::CBrushEditDlg ()
00221 : DialogTabOp( CBrushEditDlg::IDD, CBrushEditDlg::Mode )
00222 {
00223 FirstTime = TRUE;
00224
00225 EditingBrushDef = FALSE;
00226
00227 m_Handle = BrushHandle_NoBrush;
00228
00229 RenderType = RT_LINE;
00230
00231 pDocUnitList = NULL;
00232 CurrentUserUnitType = NOTYPE;
00233
00234 UsingRandomSpacing = FALSE;
00235 UsingRandomOffset = FALSE;
00236 UsingRandomScaling = FALSE;
00237
00238 EditGadgetLostFocus = 0;
00239
00240 pAttrBrush_m = NULL;
00241 }
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260 CBrushEditDlg::~CBrushEditDlg ()
00261 {
00262 if (OriginalData != NULL)
00263 delete (OriginalData);
00264 if (EditData != NULL)
00265 delete (EditData);
00266 }
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285 BOOL CBrushEditDlg::Init ()
00286 {
00287 return (
00288
00289 RegisterOpDescriptor
00290 (
00291 0,
00292 _R(IDS_BRUSHEDITDLG),
00293 CC_RUNTIME_CLASS (CBrushEditDlg),
00294 OPTOKEN_BRUSHEDIT_DLG,
00295 CBrushEditDlg::GetState,
00296 0,
00297 _R(IDBBL_BRUSHEDIT),
00298 _R(IDD_BARCONTROLSTORE),
00299 _R(IDC_BRUSHEDIT),
00300 SYSTEMBAR_EDIT,
00301 TRUE,
00302 FALSE,
00303 TRUE,
00304 0,
00305 0,
00306 ( DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC )
00307 )
00308 );
00309 }
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332 OpState CBrushEditDlg::GetState (String_256* pHelpString, OpDescriptor*)
00333 {
00334 static OpState DialogState;
00335
00336 DialogState.Greyed = TRUE;
00337
00338
00339 AttrBrushType* pAttrBrush = GetSingleSelectedBrushAttribute();
00340
00341 if (pAttrBrush != NULL && pAttrBrush->GetBrushHandle() != BrushHandle_NoBrush)
00342 DialogState.Greyed = FALSE;
00343
00344
00345 if (Tool::GetCurrentID() == TOOLID_FREEHAND)
00346 {
00347 FreeHandTool* pTool = (FreeHandTool*)Tool::GetCurrent();
00348 if (pTool->GetBrushHandle() != BrushHandle_NoBrush)
00349 DialogState.Greyed = FALSE;
00350 }
00351
00352
00353 if (m_bIsOpen)
00354 DialogState.Greyed = TRUE;
00355
00356 return (DialogState);
00357 }
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376 void CBrushEditDlg::Do (OpDescriptor*)
00377 {
00378 Document * pDocument = Document::GetSelected();
00379 ERROR3IF(pDocument == NULL,"UnitPropertiesDlg::DoWithParam No selected document");
00380
00381 if (pDocument)
00382 pDocUnitList = pDocument->GetDocUnitList();
00383 ERROR3IF(pDocUnitList == NULL,"UnitPropertiesDlg::DoWithParam No doc unit list attached to this doc yet");
00384
00385 CurrentUserUnitType = pDocUnitList->GetPageUnits ();
00386
00387 PORTNOTE("other", "Disabled CBrushGadget")
00388 #ifndef EXCLUDE_FROM_XARALX
00389
00390
00391 m_pOwningGadget = FreeHandInfoBarOp::GetBrushGadget();
00392 if (m_pOwningGadget != NULL)
00393 m_pOwningGadget->SetBrushDialog(this);
00394 #endif
00395
00396 EditData = new BrushData;
00397 if (EditData == NULL)
00398 return;
00399
00400 OriginalData = new BrushData;
00401 m_bDisableGadgets = TRUE;
00402
00403
00404 AttrBrushType* pAttrBrush = GetSingleSelectedBrushAttribute();
00405 if (pAttrBrush != NULL)
00406 {
00407 *EditData = pAttrBrush->GetBrushData();
00408 *OriginalData = *EditData;
00409 m_bDisableGadgets = FALSE;
00410
00411 ChangeParam_m.SetValues(*EditData);
00412 String_256 Name = EditData->m_Name;
00413 SetName(&Name);
00414 }
00415 else
00416 {
00417
00418 if (Tool::GetCurrentID() == TOOLID_FREEHAND)
00419 {
00420 FreeHandTool* pTool = (FreeHandTool*)Tool::GetCurrent();
00421 BrushHandle Handle = pTool->GetBrushHandle();
00422 if (Handle != BrushHandle_NoBrush)
00423 {
00424 BrushDefinition* pDef = BrushComponent::FindBrushDefinition(Handle);
00425 if (pDef != NULL)
00426 {
00427
00428 delete EditData;
00429 EditData = pDef->GetBrushData();
00430 EditData->m_BrushHandle = Handle;
00431 *OriginalData = *EditData;
00432 m_bDisableGadgets = FALSE;
00433
00434 ChangeParam_m.SetValues(*EditData);
00435 EditingBrushDef = TRUE;
00436 String_256 Name = EditData->m_Name;
00437 SetName(&Name);
00438 }
00439 }
00440 }
00441 }
00442
00443 Create ();
00444 Open ();
00445 m_bIsOpen = TRUE;
00446 m_bPreventUpdateSet = FALSE;
00447 m_SliderStarted = FALSE;
00448 }
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468 void CBrushEditDlg::DoWithParam (OpDescriptor*, OpParam* OwningGadgetParams)
00469 {
00470 PORTNOTE("other", "Disabled CBrushGadget")
00471 #ifndef EXCLUDE_FROM_XARALX
00472 m_pOwningGadget = reinterpret_cast<CBrushGadget*> (OwningGadgetParams->Param1);
00473 m_pOwningGadget->SetCBrushEditDlg (this);
00474 #endif
00475
00476
00477 if (WindowID != NULL && IsOpen() && IsWindowVisible())
00478 return;
00479
00480 EditData = new BrushData (*(reinterpret_cast<BrushData*> ((void*)(OwningGadgetParams->Param2))));
00481
00482
00483 if (EditingBrushDef)
00484 {
00485 BrushData* DeleteData = ((reinterpret_cast<BrushData*> ((void *)(OwningGadgetParams->Param2))));
00486 delete DeleteData;
00487 }
00488
00489 OriginalData = new BrushData (*EditData);
00490
00491
00492 ChangeParam_m.SetValues(*EditData);
00493
00494 m_bDisableGadgets = FALSE;
00495
00496 PORTNOTE("other", "Disabled CBrushGadget")
00497 #ifndef EXCLUDE_FROM_XARALX
00498
00499 if (m_pOwningGadget != 0)
00500 {
00501 Id_m = m_pOwningGadget->GetGadgetID ();
00502 }
00503
00504 if (m_pOwningGadget->GetEditingBrushDefinition ())
00505 {
00506 EditingBrushDef = TRUE;
00507 GetAttributeNodeFromDefinition();
00508 }
00509 #endif
00510
00511 Document * pDocument = Document::GetSelected();
00512 ERROR3IF(pDocument == NULL,"UnitPropertiesDlg::DoWithParam No selected document");
00513
00514 if (pDocument)
00515 pDocUnitList = pDocument->GetDocUnitList();
00516 ERROR3IF(pDocUnitList == NULL,"UnitPropertiesDlg::DoWithParam No doc unit list attached to this doc yet");
00517
00518 CurrentUserUnitType = pDocUnitList->GetPageUnits ();
00519
00520 String_256 Title (_R(IDS_BRUSHEDITDLGTITLE));
00521 SetName (&Title);
00522
00523 Create ();
00524 Open ();
00525
00526 PORTNOTE("other", "Disabled CBrushGadget")
00527 #ifndef EXCLUDE_FROM_XARALX
00528
00529 if (m_pOwningGadget != 0)
00530 {
00531 m_pOwningGadget->DialogHasOpened ();
00532 }
00533 #endif
00534
00535 m_bIsOpen = TRUE;
00536 m_bPreventUpdateSet = FALSE;
00537 m_SliderStarted = FALSE;
00538 }
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557 BOOL CBrushEditDlg::AddControlsToHelper()
00558 {
00559
00560 BOOL ok = AddDialogControlToHelper(_R(IDC_EDITBRUSHSPACING), _R(IDD_BRUSHEDITSPACING));
00561
00562 if (ok) ok = AddDialogControlToHelper(_R(IDC_EDITPATHOFFSETVALUE), _R(IDD_BRUSHEDITOFFSET));
00563
00564
00565 if (ok) ok = AddDialogControlToHelper(_R(IDC_EDITROTATEANGLE), _R(IDD_BRUSHEDITEFFECTS));
00566 if (ok) ok = AddDialogControlToHelper(_R(IDC_EDITROTATEANGLEINCR), _R(IDD_BRUSHEDITEFFECTS));
00567 if (ok) ok = AddDialogControlToHelper(_R(IDC_EDITBRUSHTRANSP), _R(IDD_BRUSHEDITSEQUENCE));
00568
00569 return ok;
00570 }
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589 void CBrushEditDlg::RemoveControlsFromHelper()
00590 {
00591 BOOL ok = RemoveDialogControlFromHelper(_R(IDC_EDITBRUSHSPACING), _R(IDD_BRUSHEDITSPACING));
00592
00593 if (ok) ok = RemoveDialogControlFromHelper(_R(IDC_EDITPATHOFFSETVALUE), _R(IDD_BRUSHEDITOFFSET));
00594
00595
00596 if (ok) ok = RemoveDialogControlFromHelper(_R(IDC_EDITROTATEANGLE), _R(IDD_BRUSHEDITEFFECTS));
00597 if (ok) ok = RemoveDialogControlFromHelper(_R(IDC_EDITROTATEANGLEINCR), _R(IDD_BRUSHEDITEFFECTS));
00598 if (ok) ok = RemoveDialogControlFromHelper(_R(IDC_EDITBRUSHTRANSP), _R(IDD_BRUSHEDITSEQUENCE));
00599
00600
00601 return;
00602 }
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622 MsgResult CBrushEditDlg::Message (Msg* Message)
00623 {
00624 BOOL bClose = FALSE;
00625 if (IS_OUR_DIALOG_MSG (Message))
00626 {
00627 DialogMsg* Msg = static_cast<DialogMsg*>( Message );
00628
00629 CDlgResID ThePage = Msg->PageID;
00630
00631 BOOL MessageAlreadyHandled = FALSE;
00632 INT32 Test = -1;
00633 switch (Msg->DlgMsg)
00634 {
00635
00636 case DIM_TITLEFOCUSWARN:
00637 {
00638
00639
00640
00641
00642 BROADCAST_TO_ALL(ScreenChangeMsg());
00643 }
00644 break;
00645
00646
00647 case DIM_CREATE:
00648 {
00649
00650 if (EditingBrushDef)
00651 {
00652
00653 if (FirstTime)
00654 {
00655 HideShuffleIrrelevantButtons ();
00656
00657
00658
00659 FirstTime = FALSE;
00660 }
00661 }
00662 else
00663 {
00664 if (FirstTime)
00665 {
00666 HideShuffleIrrelevantButtons ();
00667
00668 FirstTime = FALSE;
00669 }
00670 }
00671 DialogManager::DefaultKeyboardFocus();
00672 }
00673 break;
00674
00675 case DIM_SET_ACTIVE:
00676 {
00677 ReInitPage(ThePage);
00678 }
00679 break;
00680 case DIM_COMMIT:
00681
00682
00683 CreateNewBrush();
00684
00685 break;
00686
00687
00688 case DIM_SOFT_COMMIT:
00689 {
00690
00691
00692 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_CHANGEBRUSHDEF);
00693 if (pOpDesc != NULL)
00694 {
00695
00696 ChangeBrushDefOpParam DefParam;
00697 DefParam = ChangeParam_m;
00698 DefParam.ChangeType = CHANGEBRUSH_ALL;
00699 DefParam.m_Handle = EditData->m_BrushHandle;
00700 DefParam.m_NewScaling = 1.0;
00701 pOpDesc->Invoke(&DefParam);
00702
00703 }
00704 EnableGadget(_R(ID_APPLY_NOW), TRUE);
00705 }
00706 break;
00707
00708 case DIM_CANCEL:
00709 {
00710 TRACEUSER( "Diccon", _T("Closing dialog, EditingBD = %d\n"), EditingBrushDef);
00711
00712 if (EditingBrushDef)
00713 {
00714
00715 if (pAttrBrush_m != NULL)
00716 delete pAttrBrush_m;
00717 }
00718 m_bIsOpen = FALSE;
00719
00720
00721 Close ();
00722 bClose = TRUE;
00723 MessageAlreadyHandled = TRUE;
00724
00725 }
00726 break;
00727
00728
00729
00730 case DIM_SLIDER_POS_CHANGING :
00731 {
00732 if (!m_bPreventUpdateSet)
00733 {
00734 if (Tool::GetCurrentID() == TOOLID_FREEHAND)
00735 {
00736 FreeHandTool* pTool = (FreeHandTool*)Tool::GetCurrent();
00737 pTool->SetBrushUpdateState(UPDATE_NEVER);
00738 }
00739 m_bPreventUpdateSet = TRUE;
00740 }
00741
00742 HandleSliderPosChanging (Msg);
00743 }
00744 break;
00745
00746
00747 case DIM_SLIDER_POS_SET:
00748 {
00749
00750 if (m_bPreventUpdateSet)
00751 {
00752 if (Tool::GetCurrentID() == TOOLID_FREEHAND)
00753 {
00754
00755 FreeHandTool* pTool = (FreeHandTool*)Tool::GetCurrent();
00756 pTool->SetBrushUpdateState(UPDATE_ONIDLE);
00757
00758 }
00759 m_bPreventUpdateSet = FALSE;
00760 }
00761
00762 HandleSliderPosSet (Msg);
00763
00764
00765 }
00766 break;
00767
00768
00769 case DIM_LFT_BN_CLICKED:
00770 {
00771
00772 HandleButtonDown(Msg);
00773
00774 }
00775 break;
00776
00777
00778 case DIM_SELECTION_CHANGED:
00779 {
00780 switch (Msg->DlgMsgParam)
00781 {
00782 case ENTER_COMMIT:
00783 Test = 3;
00784 break;
00785 case TAB_COMMIT:
00786 Test = 4;
00787 break;
00788 default:
00789
00790 break;
00791 }
00792 HandleSelectionChange (Msg);
00793 }
00794 break;
00795
00796 default:
00797 break;
00798
00799 }
00800
00801
00802 if ( ThePage && !MessageAlreadyHandled)
00803 {
00804 if (FALSE) {}
00805 else if (ThePage == _R(IDD_BRUSHEDITSPACING))
00806 HandleBrushEditSpacingMsg (Msg);
00807 else if (ThePage == _R(IDD_BRUSHEDITOFFSET))
00808 HandleBrushEditOffsetMsg (Msg);
00809 else if (ThePage == _R(IDD_BRUSHEDITSCALING))
00810 HandleBrushEditScalingMsg (Msg);
00811 else if (ThePage == _R(IDD_BRUSHEDITEFFECTS))
00812 HandleBrushEditEffectMsg (Msg);
00813 else if (ThePage == _R(IDD_BRUSHEDITSEQUENCE))
00814 HandleBrushEditSequenceMsg (Msg);
00815 else if (ThePage == _R(IDD_BRUSHEDITFILL))
00816 HandleBrushFillMsg(Msg);
00817 else
00818 {
00819 ERROR3("Message from unknown tab dialog page");
00820 }
00821 }
00822
00823 }
00824 else
00825 {
00826
00827
00828 if (Message->IsKindOf(CC_RUNTIME_CLASS(BrushDefMsg)))
00829 {
00830
00831
00832 if (EditingBrushDef)
00833 {
00834
00835 GetAttributeNodeFromDefinition();
00836
00837 }
00838 }
00839 if (MESSAGE_IS_A(Message, SelChangingMsg))
00840 {
00841 HandleDocSelectionChange();
00842 }
00843 }
00844
00845
00846 MsgResult Result = DialogOp::Message (Message);
00847
00848 if (bClose)
00849 {
00850 PORTNOTE("other", "Disabled CBrushGadget")
00851 #ifndef EXCLUDE_FROM_XARALX
00852
00853 if (m_pOwningGadget != 0)
00854 {
00855 m_pOwningGadget->DialogHasClosed();
00856 }
00857 #endif
00858 }
00859
00860 return Result;
00861 }
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884 void CBrushEditDlg::HandleBrushEditSpacingMsg (DialogMsg* Msg)
00885 {
00886 TalkToPage (_R(IDD_BRUSHEDITSPACING));
00887
00888 switch(Msg->DlgMsg)
00889 {
00890 case DIM_CREATE:
00891 InitBrushSpacing ();
00892 break;
00894 case DIM_COMMIT :
00895 {
00896 HandleCommit (Msg);
00897 DialogManager::DefaultKeyboardFocus ();
00898 }
00899 break;
00900 default:
00901 break;
00902 }
00903 }
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924 void CBrushEditDlg::HandleBrushEditOffsetMsg (DialogMsg* Msg)
00925 {
00926 TalkToPage (_R(IDD_BRUSHEDITOFFSET));
00927
00928 switch(Msg->DlgMsg)
00929 {
00930 case DIM_CREATE:
00931 InitBrushOffset ();
00932 break;
00933 case DIM_COMMIT :
00934 {
00935 HandleCommit (Msg);
00936 DialogManager::DefaultKeyboardFocus ();
00937 }
00938 break;
00939 default:
00940 break;
00941 }
00942 }
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963 void CBrushEditDlg::HandleBrushEditScalingMsg (DialogMsg* Msg)
00964 {
00965 TalkToPage (_R(IDD_BRUSHEDITSCALING));
00966
00967 switch(Msg->DlgMsg)
00968 {
00969 case DIM_CREATE:
00970 InitBrushScaling ();
00971 break;
00972 case DIM_COMMIT :
00973 {
00974 HandleCommit (Msg);
00975 DialogManager::DefaultKeyboardFocus ();
00976 }
00977 break;
00978 default:
00979 break;
00980 }
00981 }
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003 void CBrushEditDlg::HandleBrushEditEffectMsg (DialogMsg* Msg)
01004 {
01005 TalkToPage (_R(IDD_BRUSHEDITEFFECTS));
01006
01007 switch(Msg->DlgMsg)
01008 {
01009 case DIM_CREATE:
01010 InitBrushEffects ();
01011 break;
01012 case DIM_COMMIT :
01013 {
01014 HandleCommit (Msg);
01015 DialogManager::DefaultKeyboardFocus ();
01016 }
01017 break;
01018 default:
01019 break;
01020 }
01021 }
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043 void CBrushEditDlg::HandleBrushEditSequenceMsg (DialogMsg* Msg)
01044 {
01045 TalkToPage (_R(IDD_BRUSHEDITSEQUENCE));
01046
01047 switch(Msg->DlgMsg)
01048 {
01049 case DIM_CREATE:
01050 InitBrushSequence ();
01051 break;
01052 case DIM_COMMIT :
01053 {
01054 HandleCommit (Msg);
01055 DialogManager::DefaultKeyboardFocus ();
01056 }
01057 break;
01058 default:
01059 break;
01060 }
01061 }
01062
01063
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083 void CBrushEditDlg::HandleBrushFillMsg (DialogMsg* Msg)
01084 {
01085 TalkToPage (_R(IDD_BRUSHEDITFILL));
01086
01087 switch(Msg->DlgMsg)
01088 {
01089 case DIM_CREATE:
01090 InitBrushFill ();
01091 break;
01092 case DIM_COMMIT :
01093 {
01094 HandleCommit (Msg);
01095 DialogManager::DefaultKeyboardFocus ();
01096 }
01097 break;
01098 default:
01099 break;
01100 }
01101 }
01102
01103 PORTNOTE("other", "Disabled CBrushGadget")
01104 #ifndef EXCLUDE_FROM_XARALX
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125 void CBrushEditDlg::InvokeVia (CBrushGadget& pInvokeWith, BrushData* pInvokeOn, AttrBrushType* pBrush, BOOL& bMany)
01126 {
01127 if (pInvokeOn == NULL)
01128 {
01129 ERROR3("Invalid inputs");
01130 return;
01131 }
01132
01133
01134 m_bDisableOps = TRUE;
01135 OpDescriptor* pOpDescriptor = OpDescriptor::FindOpDescriptor (OPTOKEN_BRUSHEDIT_DLG);
01136 if( pOpDescriptor != 0 )
01137 {
01138 OpParam Param( reinterpret_cast<INT32>( &pInvokeWith ), reinterpret_cast<INT32>( pInvokeOn ) );
01139 DoWithParam( pOpDescriptor, &Param );
01140 }
01141 }
01142
01143
01144 void CBrushEditDlg::InvokeVia (CBrushGadget& pInvokeWith, BrushHandle Handle)
01145 {
01146
01147 Document* pDoc = Document::GetCurrent();
01148 if (pDoc == NULL)
01149 return;
01150 BrushComponent* pBrushComp = (BrushComponent*)pDoc->GetDocComponent(CC_RUNTIME_CLASS(BrushComponent));
01151 if (pBrushComp == NULL)
01152 {
01153 ERROR3("No brush component in our document");
01154 return;
01155 }
01156 BrushDefinition* pBrushDef = pBrushComp->FindBrushDefinition(Handle);
01157 if (pBrushDef == NULL)
01158 return;
01159
01160
01161 EditingBrushDef = TRUE;
01162
01163
01164 BrushData* pInvokeOn = pBrushDef->GetBrushData();
01165 if (pInvokeOn == NULL)
01166 return;
01167
01168 m_bDisableOps = TRUE;
01169 m_Handle = Handle;
01170
01171 OpDescriptor* pOpDescriptor = OpDescriptor::FindOpDescriptor (OPTOKEN_BRUSHEDIT_DLG);
01172 if( pOpDescriptor != 0 )
01173 {
01174 OpParam Param( reinterpret_cast<INT32>( &pInvokeWith ), reinterpret_cast<INT32>( pInvokeOn ) );
01175 DoWithParam( pOpDescriptor, &Param );
01176 }
01177 }
01178
01179
01180
01181 void CBrushEditDlg::InvokeVia (CBrushGadget& pInvokeWith, BrushData* pInvokeOn, AttrBrushType* pBrush, AttrBrushType* pOrigBrush, BOOL& bMany)
01182 {
01183 if (pInvokeOn == NULL || pBrush == NULL)
01184 {
01185 ERROR3("Invalid inputs");
01186 return;
01187 }
01188
01189 OpDescriptor* pOpDescriptor = OpDescriptor::FindOpDescriptor (OPTOKEN_BRUSHEDIT_DLG);
01190 if( pOpDescriptor != 0 )
01191 {
01192 pAttrBrush_m = pBrush;
01193 pOrigAttrBrush_m = pOrigBrush;
01194 OpParam Param( reinterpret_cast<INT32>( &pInvokeWith ), reinterpret_cast<INT32>( pInvokeOn ) );
01195 DoWithParam( pOpDescriptor, &Param );
01196 }
01197 }
01198 #endif
01199
01200 BOOL CBrushEditDlg::RegisterYourPagesInOrderPlease ()
01201 {
01202 BOOL ok = ( AddAPage (_R(IDD_BRUSHEDITSPACING)) &&
01203 AddAPage (_R(IDD_BRUSHEDITOFFSET)) &&
01204 AddAPage (_R(IDD_BRUSHEDITSCALING)) &&
01205 AddAPage (_R(IDD_BRUSHEDITEFFECTS)) &&
01206 AddAPage (_R(IDD_BRUSHEDITSEQUENCE)) &&
01207 AddAPage (_R(IDD_BRUSHEDITFILL))
01208 );
01209
01210 return (ok);
01211 }
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225
01226
01227
01228
01229
01230
01231
01232
01233 void CBrushEditDlg::HideShuffleIrrelevantButtons ()
01234 {
01235 TalkToPage (0);
01236
01237
01238
01239
01240
01241
01242 TalkToPage (0);
01243 RECT rectApply;
01244 GetGadgetPosition (_R(ID_APPLY_NOW), &rectApply);
01245 RECT rectCancel;
01246 GetGadgetPosition (_R(IDCANCEL), &rectCancel);
01247
01248 SetGadgetPosition (_R(IDCANCEL), rectApply);
01249 SetGadgetPosition (_R(ID_APPLY_NOW), rectCancel);
01250
01251
01252 ChangeButtonText();
01253
01254 }
01255
01256
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276 void CBrushEditDlg::ChangeButtonText()
01277 {
01278 SetStringGadgetValue(_R(ID_CANCEL), _R(IDS_BRUSH_CLOSEDLG));
01279 SetStringGadgetValue(_R(ID_APPLY_NOW), _R(IDS_BRUSH_SAVE));
01280 SetStringGadgetValue(_R(IDOK), _R(IDS_BRUSH_SAVE_AS));
01281 }
01282
01283
01284
01285 static CGadgetID BrushSpacingGadgetIDs [] = {
01286
01287 _R(IDC_EDITBRUSHSPACING),
01288
01289 _R(IDC_EDITBRUSHSPACINGINCRCONST),
01290 _R(IDC_SLIDERBRUSHSPACINGMAXRAND),
01291 _R(IDC_BUTTONBRUSHSPACINGRANDSEED),
01292 _R(IDC_STATICBRUSHSPACING),
01293
01294 _R(IDC_STATICBRUSHSPACINGINCRCONST),
01295 _R(IDC_STATICBRUSHSPACINGMAXRAND),
01296 _R(IDC_SLIDERBRUSHSPACINGMULT),
01297 _R(IDC_SLIDERBRUSHSPACING1),
01298 _R(IDC_SLIDERBRUSHSPACINGINCR),
01299 _R(IDC_STATICBRUSHSPACINGRAND1),
01300 _R(IDC_COMBOSEQUENCETYPE),
01301 };
01302
01303 static INT32 NumberOfBrushSpacingGadgets = sizeof (BrushSpacingGadgetIDs) / sizeof (CGadgetID);
01304
01305 void CBrushEditDlg::InitBrushSpacing (BOOL OnlyForUnitChange )
01306 {
01307 SetSpacingSlider();
01308
01309
01310
01311
01312
01313 UpdateEditBox (_R(IDC_EDITBRUSHSPACING));
01314
01315 SetGadgetRange (_R(IDC_SLIDERBRUSHSPACINGMAXRAND), MIN_RANDOM_SLIDER, MAX_RANDOM_SLIDER);
01316 SetGadgetBitmaps (_R(IDC_SLIDERBRUSHSPACINGMAXRAND), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
01317 SetLongGadgetValue (_R(IDC_SLIDERBRUSHSPACINGMAXRAND), MAX_RANDOM_SLIDER - (EditData->m_BrushSpacingMaxRand) + MIN_RANDOM_SLIDER);
01318 SetRandomRangeText(_R(IDC_SLIDERBRUSHSPACINGMAXRAND));
01319
01320 if (m_bDisableGadgets)
01321 {
01322 ReInitBrushSpacing();
01323 return;
01324 }
01325
01326
01327
01328 if (EditData->m_BrushSpacingMaxRand == 0 && EditData->m_SequenceType != SEQ_RANDOM )
01329 {
01330
01331 UsingRandomSpacing = FALSE;
01332 EnableGadget (_R(IDC_BUTTONBRUSHSPACINGRANDSEED), FALSE);
01333
01334 }
01335 else
01336 {
01337 UsingRandomSpacing = TRUE;
01338 EnableGadget (_R(IDC_BUTTONBRUSHSPACINGRANDSEED), TRUE);
01339 }
01340 InitSequenceType ();
01341 }
01342
01343 static CGadgetID BrushOffsetGadgetIDs [] = {
01344
01345 _R(IDC_EDITPATHOFFSETVALUE),
01346 _R(IDC_EDITPATHOFFSETINCRCONST),
01347 _R(IDC_SLIDEROFFSETVALUEMAXRAND),
01348 _R(IDC_BUTTONOFFSETVALUERANDSEED),
01349 _R(IDC_COMBOPATHOFFSETTYPE),
01350 _R(IDC_STATICPATHOFFSETVALUE),
01351
01352 _R(IDC_STATICPATHOFFSETINCRCONST),
01353 _R(IDC_STATICPATHOFFSETTYPE),
01354 _R(IDC_STATICOFFSETVALUEMAXRAND),
01355 _R(IDC_SLIDERPATHOFFSETVAL),
01356 _R(IDC_SLIDEROFFSETINCRCONST)
01357
01358
01359 };
01360
01361 static INT32 NumberOfBrushOffsetGadgets = sizeof (BrushOffsetGadgetIDs) / sizeof (CGadgetID);
01362
01363 void CBrushEditDlg::InitBrushOffset (BOOL OnlyForUnitChange )
01364 {
01365 SetOffsetValSlider();
01366
01367
01368
01369
01370
01371
01372
01373
01374 SetGadgetRange (_R(IDC_SLIDEROFFSETVALUEMAXRAND), MinOffsetSlider, MaxOffsetSlider);
01375 SetGadgetBitmaps (_R(IDC_SLIDEROFFSETVALUEMAXRAND), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
01376 SetRandomRangeText(_R(IDC_SLIDEROFFSETVALUEMAXRAND));
01377
01378
01379 if (m_bDisableGadgets)
01380 {
01381 ReInitBrushOffset();
01382 return;
01383 }
01384 EnableGadget (_R(IDC_BUTTONOFFSETVALUERANDSEED), FALSE);
01385 switch (EditData->m_PathOffsetType)
01386 {
01387 case OFFSET_NONE:
01388 UsingRandomOffset = FALSE;
01389 EnableGadget (_R(IDC_STATICPATHOFFSETVALUE), FALSE);
01390 EnableGadget (_R(IDC_SPINPATHOFFSETVALUE), FALSE);
01391 EnableGadget (_R(IDC_EDITPATHOFFSETVALUE), FALSE);
01392 EnableGadget (_R(IDC_STATICPATHOFFSETINCRCONST), FALSE);
01393 EnableGadget (_R(IDC_SPINPATHOFFSETINCRCONST), FALSE);
01394 EnableGadget (_R(IDC_EDITPATHOFFSETINCRCONST), FALSE);
01395
01396 EnableGadget (_R(IDC_SLIDERPATHOFFSETVAL), FALSE);
01397 EnableGadget (_R(IDC_SLIDEROFFSETINCRCONST), FALSE);
01398
01399
01400 break;
01401
01402 case OFFSET_RANDOM:
01403 EnableGadget (_R(IDC_EDITPATHOFFSETVALUE), FALSE);
01404 EnableGadget (_R(IDC_SLIDERPATHOFFSETVAL), FALSE);
01405 EnableGadget (_R(IDC_STATICPATHOFFSETVALUE), FALSE);
01406 break;
01407
01408 default:
01409
01410 break;
01411 }
01412 if (EditData->m_OffsetValueMaxRand > 0)
01413 EnableGadget (_R(IDC_BUTTONOFFSETVALUERANDSEED), TRUE);
01414
01415 InitComboPathOffsetType ();
01416
01417 SetLongGadgetValue (_R(IDC_SLIDEROFFSETVALUEMAXRAND), MaxOffsetSlider - (EditData->m_OffsetValueMaxRand));
01418 }
01419
01420 static CGadgetID BrushScalingGadgetIDs [] = {
01421 _R(IDC_EDITBRUSHSCALINGINCR),
01422 _R(IDC_SLIDERBRUSHSCALINGMAXRAND),
01423 _R(IDC_BUTTONBRUSHSCALINGRANDSEED),
01424
01425 _R(IDC_STATICBRUSHSCALINGINCR),
01426 _R(IDC_STATICBRUSHSCALINGMAXRAND),
01427 _R(IDC_SLIDERBRUSHSCALINGINCR),
01428 _R(IDC_SLIDERSCALINGINCRCONST),
01429 _R(IDC_EDITSCALINGINCRCONST),
01430 _R(IDC_STATICPERCENT),
01431 _R(IDC_STATICPERCENT2),
01432 _R(IDC_SLIDERSCALINGPRESSURE)
01433
01434 };
01435
01436 static INT32 NumberOfBrushScalingGadgets = sizeof (BrushScalingGadgetIDs) / sizeof (CGadgetID);
01437
01438 void CBrushEditDlg::InitBrushScaling (BOOL OnlyForUnitChange )
01439 {
01440
01441 SetGadgetRange (_R(IDC_SLIDERBRUSHSCALINGMAXRAND), MinScalingSlider, MaxScalingSlider);
01442 SetGadgetBitmaps (_R(IDC_SLIDERBRUSHSCALINGMAXRAND), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
01443 SetLongGadgetValue (_R(IDC_SLIDERBRUSHSCALINGMAXRAND), MaxScalingSlider - (EditData->m_BrushScalingMaxRand));
01444 SetRandomRangeText(_R(IDC_SLIDERBRUSHSCALINGMAXRAND));
01445
01446
01448
01449
01450
01451
01452
01453 SetGadgetRange (_R(IDC_SLIDERSCALINGPRESSURE), MIN_PRESSURE_SLIDER, MAX_PRESSURE_SLIDER);
01454 SetGadgetBitmaps (_R(IDC_SLIDERSCALINGPRESSURE), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
01455 SetLongGadgetValue (_R(IDC_SLIDERSCALINGPRESSURE), (MAX_PRESSURE_SLIDER - EditData->m_ScalingMaxPressure) + MIN_PRESSURE_SLIDER);
01456 SetRandomRangeText(_R(IDC_SLIDERSCALINGPRESSURE));
01457
01458 SetStringGadgetValue(_R(IDC_STATICBRUSHSCALEINFO), _R(IDS_BRUSHSCALE));
01459
01460 if (m_bDisableGadgets)
01461 {
01462 ReInitBrushScaling();
01463 return;
01464 }
01465
01466 if (EditData->m_BrushScalingMaxRand == 0)
01467 {
01468 UsingRandomScaling = FALSE;
01469
01470
01471 EnableGadget (_R(IDC_BUTTONBRUSHSCALINGRANDSEED), FALSE);
01472 }
01473 else
01474 {
01475 UsingRandomScaling = TRUE;
01476
01477
01478
01479 }
01480
01481
01482 }
01483
01484 static CGadgetID BrushEffectsGadgetIDs [] = {
01485
01486 _R(IDC_CHECKROTATE),
01487 _R(IDC_EDITROTATEANGLE),
01488 _R(IDC_EDITROTATEANGLEINCR),
01489
01490 _R(IDC_BUTTONROTATEANGLERANDSEED),
01491 _R(IDC_SLIDERROTATEANGLEMAXRAND),
01492 _R(IDC_SLIDERROTATEANGLEINCR),
01493 _R(IDC_SLIDERROTATEANGLE),
01494 _R(IDC_SLIDERROTATEPRESSURE)
01495
01496
01497 };
01498
01499 static INT32 NumberOfBrushEffectsGadgets = sizeof (BrushEffectsGadgetIDs) / sizeof (CGadgetID);
01500
01501 void CBrushEditDlg::InitBrushEffects (BOOL OnlyForUnitChange )
01502 {
01503
01504 SetGadgetRange (_R(IDC_SLIDERROTATEANGLEMAXRAND), MIN_RANDOM_SLIDER, MAX_ROTATION_RANDOM_SLIDER);
01505 SetGadgetBitmaps (_R(IDC_SLIDERROTATEANGLEMAXRAND), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
01506 SetLongGadgetValue (_R(IDC_SLIDERROTATEANGLEMAXRAND), MAX_ROTATION_RANDOM_SLIDER - (EditData->m_RotationMaxRand) + MIN_RANDOM_SLIDER);
01507 SetRandomRangeText(_R(IDC_SLIDERROTATEANGLEMAXRAND));
01508
01509
01510 SetDoubleGadgetValue (_R(IDC_EDITROTATEANGLE), EditData->m_RotateAngle);
01511 SetGadgetBitmaps (_R(IDC_SLIDERROTATEANGLE), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
01512 SetGadgetRange (_R(IDC_SLIDERROTATEANGLE), MIN_ROTATION_SLIDER, MAX_ROTATION_SLIDER);
01513 SetDoubleGadgetValue (_R(IDC_SLIDERROTATEANGLE), (MAX_ROTATION_SLIDER - EditData->m_RotateAngle) + MIN_ROTATION_SLIDER);
01514
01515
01516 SetDoubleGadgetValue (_R(IDC_EDITROTATEANGLEINCR), EditData->m_RotAngleIncrConst);
01517 SetGadgetBitmaps (_R(IDC_SLIDERROTATEANGLEINCR), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
01518 SetGadgetRange (_R(IDC_SLIDERROTATEANGLEINCR), MIN_ROTATION_INCR_SLIDER, MAX_ROTATION_INCR_SLIDER);
01519 SetDoubleGadgetValue (_R(IDC_SLIDERROTATEANGLEINCR), (MAX_ROTATION_INCR_SLIDER - EditData->m_RotAngleIncrConst) + MIN_ROTATION_INCR_SLIDER);
01520
01521
01522 if (m_bDisableGadgets)
01523 {
01524 ReInitBrushEffects();
01525 return;
01526 }
01527
01528
01529 if (EditData->m_RotationMaxRand == 0)
01530 {
01531 EnableGadget (_R(IDC_BUTTONROTATEANGLERANDSEED), FALSE);
01532 }
01533
01534
01535 if (EditData->m_bRotate)
01536 {
01537 SetLongGadgetValue (_R(IDC_CHECKROTATE), 1);
01538 }
01539
01540
01541
01542
01543 }
01544
01545
01546
01547
01548
01549 static CGadgetID BrushSequenceGadgetIDs [] = {
01550 _R(IDC_SLIDERTRANSP),
01551 _R(IDC_SLIDERTRANSPPRESSURE),
01552 _R(IDC_EDITBRUSHTRANSP),
01553 _R(IDC_STATICTRANSPPRESSURE)
01554 };
01555
01556
01557 static INT32 NumberOfBrushSequenceGadgets = sizeof (BrushSequenceGadgetIDs) / sizeof (CGadgetID);
01558
01559
01560 void CBrushEditDlg::InitBrushSequence (BOOL OnlyForUnitChange )
01561 {
01562 if (m_bDisableGadgets)
01563 {
01564 ReInitBrushSequence();
01565 return;
01566 }
01567
01568
01569
01570 SetGadgetBitmaps(_R(IDC_SLIDERTRANSP), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
01571 SetGadgetRange(_R(IDC_SLIDERTRANSP), MIN_TRANSP_SLIDER, MAX_TRANSP_SLIDER);
01572 SetLongGadgetValue(_R(IDC_SLIDERTRANSP), (MAX_TRANSP_SLIDER - EditData->m_BrushTransparency) + MIN_TRANSP_SLIDER);
01573
01574 SetGadgetBitmaps(_R(IDC_SLIDERTRANSPPRESSURE), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
01575 SetGadgetRange(_R(IDC_SLIDERTRANSPPRESSURE), MIN_PRESSURE_SLIDER, MAX_PRESSURE_SLIDER);
01576 SetLongGadgetValue(_R(IDC_SLIDERTRANSPPRESSURE), (MAX_PRESSURE_SLIDER - EditData->m_TranspMaxPressure) + MIN_PRESSURE_SLIDER);
01577
01578 UpdateEditBox(_R(IDC_EDITBRUSHTRANSP));
01579 SetRandomRangeText(_R(IDC_SLIDERTRANSPPRESSURE));
01580 }
01581
01582 static CGadgetID BrushFillGadgetIDs [] = {
01583 _R(IDC_CHECKTILEING),
01584 _R(IDC_RADIOLOCALFILLALL),
01585 _R(IDC_RADIOLOCALFILLNAMED),
01586 _R(IDC_RADIOLOCALFILLNONE),
01587 _R(IDC_SLIDERHUERANDOM),
01588 _R(IDC_SLIDERSATURATIONRANDOM),
01589 _R(IDC_BUTTONBRUSHFILLRANDOM),
01590
01591 };
01592
01593 static CGadgetID LocalFillRadioGadgets [] = {
01594 _R(IDC_RADIOLOCALFILLALL),
01595 _R(IDC_RADIOLOCALFILLNAMED),
01596 _R(IDC_RADIOLOCALFILLNONE),
01597 0
01598 };
01599
01600 static INT32 NumberOfBrushFillGadgets = sizeof (BrushFillGadgetIDs) / sizeof (CGadgetID);
01601 static INT32 NumberOfLocalFillRadios = sizeof (LocalFillRadioGadgets) / sizeof (CGadgetID);
01602
01603 void CBrushEditDlg::InitBrushFill (BOOL OnlyForUnitChange )
01604 {
01605
01606 if (m_bDisableGadgets)
01607 {
01608 ReInitBrushFill();
01609 return;
01610 }
01611
01612
01613 SetGadgetBitmaps(_R(IDC_SLIDERSATURATIONRANDOM), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
01614 SetGadgetRange(_R(IDC_SLIDERSATURATIONRANDOM), MIN_RANDOM_SLIDER, MAX_RANDOM_SAT_SLIDER);
01615 SetLongGadgetValue(_R(IDC_SLIDERSATURATIONRANDOM), (MAX_RANDOM_SAT_SLIDER - EditData->m_BrushSatMaxRand) + MIN_RANDOM_SLIDER);
01616 SetRandomRangeText(_R(IDC_SLIDERSATURATIONRANDOM));
01617
01618 SetGadgetBitmaps(_R(IDC_SLIDERHUERANDOM), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
01619 SetGadgetRange(_R(IDC_SLIDERHUERANDOM), MIN_RANDOM_SLIDER, MAX_RANDOM_HUE_SLIDER);
01620 SetLongGadgetValue(_R(IDC_SLIDERHUERANDOM), (MAX_RANDOM_HUE_SLIDER - EditData->m_BrushHueMaxRand) + MIN_RANDOM_SLIDER);
01621 SetRandomRangeText(_R(IDC_SLIDERHUERANDOM));
01622
01623 if (EditData->m_BrushHueMaxRand > 0 || EditData->m_BrushSatMaxRand > 0)
01624 EnableGadget(_R(IDC_BUTTONBRUSHFILLRANDOM), TRUE);
01625 else
01626 EnableGadget(_R(IDC_BUTTONBRUSHFILLRANDOM), FALSE);
01627
01628 if (EditData->m_bTile)
01629 {
01630 SetLongGadgetValue (_R(IDC_CHECKTILEING), 1);
01631 }
01632 else
01633 {
01634 SetLongGadgetValue (_R(IDC_CHECKTILEING), 0);
01635 }
01636
01637
01638 if (!EditingBrushDef)
01639 {
01640 SetRadioGroupSelected(LocalFillRadioGadgets, _R(IDC_RADIOLOCALFILLNONE));
01641 if (EditData->m_bUseLocalFillColour)
01642 {
01643 SetRadioGroupSelected(LocalFillRadioGadgets, _R(IDC_RADIOLOCALFILLALL));
01644 }
01645 if (EditData->m_bUseNamedColour == FALSE)
01646 {
01647 SetRadioGroupSelected(LocalFillRadioGadgets, _R(IDC_RADIOLOCALFILLNAMED));
01648 }
01649
01650 }
01651 else
01652 {
01653
01654 for (INT32 i = 0; i < NumberOfLocalFillRadios - 1; i++)
01655 EnableGadget(LocalFillRadioGadgets[i], FALSE);
01656
01657 }
01658
01659 }
01660
01661
01662 void CBrushEditDlg::ReInitBrushFill()
01663 {
01664 BOOL Enable = !m_bDisableGadgets;
01665
01666 for (INT32 i = 0; i < NumberOfBrushFillGadgets; i++)
01667 {
01668 EnableGadget (BrushSequenceGadgetIDs [i], Enable);
01669 }
01670
01671 if (Enable)
01672 InitBrushFill ();
01673
01674 }
01675
01676
01677 void CBrushEditDlg::InitComboPathOffsetType ()
01678 {
01679 DeleteAllValues (_R(IDC_COMBOPATHOFFSETTYPE));
01680
01681 SetStringGadgetValue (_R(IDC_COMBOPATHOFFSETTYPE), _R(IDS_OFFSET_NONE), TRUE, 0);
01682 SetStringGadgetValue (_R(IDC_COMBOPATHOFFSETTYPE), _R(IDS_OFFSET_ALTERNATE), TRUE, 1);
01683 SetStringGadgetValue (_R(IDC_COMBOPATHOFFSETTYPE), _R(IDS_OFFSET_LEFT), TRUE, 2);
01684 SetStringGadgetValue (_R(IDC_COMBOPATHOFFSETTYPE), _R(IDS_OFFSET_RIGHT), TRUE, 3);
01685
01686
01687 switch (EditData->m_PathOffsetType)
01688 {
01689 case OFFSET_NONE:
01690 SetStringGadgetValue (_R(IDC_COMBOPATHOFFSETTYPE), _R(IDS_OFFSET_NONE), FALSE, -1);
01691 break;
01692 case OFFSET_ALTERNATE:
01693 SetStringGadgetValue (_R(IDC_COMBOPATHOFFSETTYPE), _R(IDS_OFFSET_ALTERNATE), FALSE, -1);
01694 break;
01695 case OFFSET_LEFT:
01696 SetStringGadgetValue (_R(IDC_COMBOPATHOFFSETTYPE), _R(IDS_OFFSET_LEFT), FALSE, -1);
01697 break;
01698 case OFFSET_RIGHT:
01699 SetStringGadgetValue (_R(IDC_COMBOPATHOFFSETTYPE), _R(IDS_OFFSET_RIGHT), FALSE, -1);
01700 break;
01701
01702
01703 default:
01704 SetStringGadgetValue (_R(IDC_COMBOPATHOFFSETTYPE), _R(IDS_OFFSET_NONE), FALSE, -1);
01705 break;
01706 }
01707 }
01708
01709 void CBrushEditDlg::InitSequenceType ()
01710 {
01711 DeleteAllValues (_R(IDC_COMBOSEQUENCETYPE));
01712
01713 SetStringGadgetValue (_R(IDC_COMBOSEQUENCETYPE), _R(IDS_SEQ_FORWARD), TRUE, 0);
01714 SetStringGadgetValue (_R(IDC_COMBOSEQUENCETYPE), _R(IDS_SEQ_BACKWARD), TRUE, 1);
01715 SetStringGadgetValue (_R(IDC_COMBOSEQUENCETYPE), _R(IDS_SEQ_MIRROR), TRUE, 2);
01716 SetStringGadgetValue (_R(IDC_COMBOSEQUENCETYPE), _R(IDS_SEQ_RANDOM), TRUE, 3);
01717
01718 switch (EditData->m_SequenceType)
01719 {
01720 case SEQ_FORWARD:
01721 SetStringGadgetValue (_R(IDC_COMBOSEQUENCETYPE), _R(IDS_SEQ_FORWARD), FALSE, -1);
01722 break;
01723 case SEQ_BACKWARD:
01724 SetStringGadgetValue (_R(IDC_COMBOSEQUENCETYPE), _R(IDS_SEQ_BACKWARD), FALSE, -1);
01725 break;
01726 case SEQ_MIRROR:
01727 SetStringGadgetValue (_R(IDC_COMBOSEQUENCETYPE), _R(IDS_SEQ_MIRROR), FALSE, -1);
01728 break;
01729 case SEQ_RANDOM:
01730 SetStringGadgetValue (_R(IDC_COMBOSEQUENCETYPE), _R(IDS_SEQ_RANDOM), FALSE, -1);
01731 break;
01732 }
01733
01734 BrushDefinition* pDef = BrushComponent::FindBrushDefinition(EditData->m_BrushHandle);
01735 if (pDef)
01736 {
01737 UINT32 Num = pDef->GetNumBrushObjects();
01738 if (Num == 1)
01739 EnableGadget(_R(IDC_COMBOSEQUENCETYPE), FALSE);
01740
01741 }
01742 }
01743
01744 void CBrushEditDlg::ReInitBrushSpacing ()
01745 {
01746 BOOL Enable = !m_bDisableGadgets;
01747 for (INT32 i = 0; i < NumberOfBrushSpacingGadgets; i++)
01748 {
01749 EnableGadget (BrushSpacingGadgetIDs [i], Enable);
01750 }
01751 if (Enable)
01752 InitBrushSpacing ();
01753 }
01754
01755 void CBrushEditDlg::ReInitBrushOffset ()
01756 {
01757 BOOL Enable = !m_bDisableGadgets;
01758 for (INT32 i = 0; i < NumberOfBrushOffsetGadgets; i++)
01759 {
01760 EnableGadget (BrushOffsetGadgetIDs [i], Enable);
01761 }
01762
01763 if (Enable)
01764 InitBrushOffset ();
01765 }
01766
01767 void CBrushEditDlg::ReInitBrushScaling ()
01768 {
01769 BOOL Enable = !m_bDisableGadgets;
01770 for (INT32 i = 0; i < NumberOfBrushScalingGadgets; i++)
01771 {
01772 EnableGadget (BrushScalingGadgetIDs [i], Enable);
01773 }
01774
01775 if (Enable)
01776 InitBrushScaling ();
01777 }
01778
01779 void CBrushEditDlg::ReInitBrushEffects ()
01780 {
01781 BOOL Enable = !m_bDisableGadgets;
01782 for (INT32 i = 0; i < NumberOfBrushEffectsGadgets; i++)
01783 {
01784 EnableGadget (BrushEffectsGadgetIDs [i], Enable);
01785 }
01786
01787 if (Enable)
01788 InitBrushEffects ();
01789 }
01790
01791 void CBrushEditDlg::ReInitBrushSequence ()
01792 {
01793 BOOL Enable = !m_bDisableGadgets;
01794
01795 for (INT32 i = 0; i < NumberOfBrushSequenceGadgets; i++)
01796 {
01797 EnableGadget (BrushSequenceGadgetIDs [i], Enable);
01798 }
01799
01800 if (Enable)
01801 InitBrushSequence ();
01802 }
01803
01804 void CBrushEditDlg::ReInitUnitDependantFields (CDlgResID ThePage)
01805 {
01806 if (ThePage == _R(IDD_BRUSHEDITSPACING))
01807 InitBrushSpacing (TRUE);
01808 else if (ThePage == _R(IDD_BRUSHEDITOFFSET))
01809 InitBrushOffset (TRUE);
01810 else if (ThePage == _R(IDD_BRUSHEDITSCALING))
01811 InitBrushScaling (TRUE);
01812 else if (ThePage == _R(IDD_BRUSHEDITEFFECTS))
01813 InitBrushEffects (TRUE);
01814 else if (ThePage == _R(IDD_BRUSHEDITSEQUENCE))
01815 InitBrushSequence (TRUE);
01816 else if (ThePage == _R(IDD_BRUSHEDITFILL))
01817 InitBrushFill (TRUE);
01818 else
01819 {
01820 ERROR3("Unknown tab dialog page");
01821 }
01822 }
01823
01824 void CBrushEditDlg::HandleCommit (DialogMsg* Msg)
01825 {
01826
01827 ReadEditBox (Msg);
01828
01829 WriteSliders (Msg);
01830
01831 BROADCAST_TO_CLASS (DialogMsg (0, Msg->DlgMsg, Id_m, (UINT_PTR) (EditData)), DialogBarOp);
01832
01833 LaunchOp();
01834 }
01835
01836 void CBrushEditDlg::HandleSelectionChange (DialogMsg* Msg)
01837 {
01838 ReadComboBox (Msg);
01839
01840
01841
01842 if (ChangeType_m == CHANGEBRUSH_NONE)
01843 ReadEditBox(Msg);
01844
01845 BROADCAST_TO_CLASS (DialogMsg (0, Msg->DlgMsg, Id_m, (UINT_PTR) (EditData)), DialogBarOp);
01846
01847 LaunchOp();
01848 }
01849
01850 void CBrushEditDlg::HandleButtonDown (DialogMsg* Msg)
01851 {
01852
01853 ReadCheckBox (Msg);
01854
01855
01856 if (ChangeType_m == CHANGEBRUSH_NONE)
01857 ReadButtons(Msg);
01858
01859
01860 if (ChangeType_m == CHANGEBRUSH_NONE)
01861 ReadRadios(Msg);
01862
01863 BROADCAST_TO_CLASS (DialogMsg (0, DIM_COMMIT, Id_m, (UINT_PTR) (EditData)), DialogBarOp);
01864 LaunchOp();
01865 }
01866
01867 void CBrushEditDlg::HandleSliderPosChanging (DialogMsg* Msg)
01868 {
01869 ReadSlider (Msg);
01870
01871 BROADCAST_TO_CLASS (DialogMsg (0, Msg->DlgMsg, Id_m, (UINT_PTR) (EditData)), DialogBarOp);
01872
01873
01874
01875
01876 if (!m_SliderStarted)
01877 {
01878 TRACEUSER( "Diccon", _T("Launching Op\n"));
01879 LaunchOp();
01880 m_SliderStarted = TRUE;
01881 }
01882 else if (ChangeType_m != CHANGEBRUSH_NONE && EditingBrushDef == FALSE)
01883 {
01884 ChangeParam_m.ChangeType = ChangeType_m;
01885 ChangeBrushAction Action;
01886
01887 Action.ChangeSelectionNoUndo(&ChangeParam_m);
01888 }
01889 }
01890
01891 void CBrushEditDlg::HandleSliderPosSet (DialogMsg* Msg)
01892 {
01893 ReadSlider (Msg);
01894
01895 BROADCAST_TO_CLASS (DialogMsg (0, Msg->DlgMsg, Id_m, (UINT_PTR) (EditData)), DialogBarOp);
01896
01897 if (ChangeType_m != CHANGEBRUSH_NONE && EditingBrushDef == FALSE)
01898 {
01899 ChangeParam_m.ChangeType = ChangeType_m;
01900 ChangeBrushAction Action;
01901
01902 Action.ChangeSelectionNoUndo(&ChangeParam_m);
01903 }
01904 m_SliderStarted = FALSE;
01905 }
01906
01907
01908 void CBrushEditDlg::LaunchOp()
01909 {
01910
01911
01912
01913 if (ChangeType_m != CHANGEBRUSH_NONE)
01914 {
01915 if (EditingBrushDef == FALSE)
01916 {
01917
01918 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_CHANGEBRUSH);
01919 if (pOpDesc != NULL )
01920 {
01921 ChangeParam_m.ChangeType = ChangeType_m;
01922 pOpDesc->Invoke(&ChangeParam_m);
01923 m_LastData = *EditData;
01924 }
01925
01926 }
01927
01928 }
01929 else
01930 TRACEUSER( "Diccon", _T("NOT LAUNCHING OP!!\n"));
01931
01932
01933 ChangeType_m = CHANGEBRUSH_NONE;
01934
01935
01936 SetPropertyPageModified(TRUE);
01937 }
01938
01939 BOOL CBrushEditDlg::GetAttributeNodeFromDefinition()
01940 {
01941
01942 if (!EditingBrushDef)
01943 return FALSE;
01944
01945
01946 Document* pDoc = Document::GetCurrent();
01947 if (pDoc == NULL)
01948 return FALSE;
01949
01950 BrushComponent* pBrushComp = (BrushComponent*)pDoc->GetDocComponent(CC_RUNTIME_CLASS(BrushComponent));
01951 if (pBrushComp == NULL)
01952 {
01953 ERROR3("No brush component in our document");
01954 return FALSE;
01955 }
01956
01957
01958 if (pAttrBrush_m != NULL)
01959 {
01960 delete pAttrBrush_m;
01961 pAttrBrush_m = NULL;
01962 }
01963
01964
01965 pAttrBrush_m = pBrushComp->CreateAttributeNode(m_Handle);
01966
01967
01968 if (pAttrBrush_m == NULL)
01969 return FALSE;
01970
01971 return TRUE;
01972 }
01973
01974
01975 UINT32 CBrushEditDlg::GetNewRandomNumber(UINT32 OldNumber)
01976 {
01977
01978 srand( (unsigned)time( NULL ) );
01979
01980 UINT32 Rand = (UINT32)rand();
01981
01982 while (Rand == OldNumber)
01983 Rand = (UINT32)rand();
01984
01985 return Rand;
01986 }
01987
01988
01989
01990
01991
01992
01993
01994
01995
01996
01997
01998
01999
02000
02001
02002
02003
02004
02005 void CBrushEditDlg::ReadEditBox (DialogMsg* Msg)
02006 {
02007 MILLIPOINT MilliPointNewVal;
02008 double DoubleNewVal;
02009 INT32 LongNewVal;
02010 BOOL Valid = FALSE;
02011 ChangeType_m = CHANGEBRUSH_NONE;
02012
02013
02014 if (FALSE) {}
02015 else if (Msg->GadgetID == _R(IDC_EDITBRUSHSPACING))
02016 {
02017 double MinSpacingSlider = 0;
02018 double MaxSpacingSlider = 0;
02019 GetSpacingRange(&MinSpacingSlider, &MaxSpacingSlider);
02020 DoubleNewVal = GetDoubleGadgetValue (_R(IDC_EDITBRUSHSPACING), MinSpacingSlider , MaxSpacingSlider);
02021 MILLIPOINT NewVal = GetPercentageAsDistance(DoubleNewVal, WIDTH);
02022 DoubleNewVal = pow((double)NewVal, InvFactor);
02023
02024 if (DoubleNewVal >= MinSpacingSlider && DoubleNewVal <= MaxSpacingSlider)
02025 {
02026 if (EditData->m_BrushSpacing != NewVal)
02027 {
02028
02029 EditData->m_BrushSpacing = NewVal;
02030 ChangeType_m = CHANGEBRUSH_SPACING;
02031 ChangeParam_m.m_NewSpacing = NewVal;
02032 ReInitBrushSpacing();
02033 }
02034 }
02035 else
02036 {
02037
02038 UpdateEditBox(_R(IDC_EDITBRUSHSPACING));
02039 }
02040 }
02041 else if (Msg->GadgetID == _R(IDC_EDITBRUSHSPACINGINCRCONST))
02042 {
02043 DoubleNewVal = GetDoubleGadgetValue(_R(IDC_EDITBRUSHSPACINGINCRCONST), MIN_SPACING_INCR, MAX_SPACING_INCR, _R(IDS_BRUSHINCRINVALID), &Valid);
02044
02045 if (DoubleNewVal > MIN_SPACING_INCR && DoubleNewVal < MAX_SPACING_INCR && Valid)
02046 {
02047
02048 MILLIPOINT Distance = GetPercentageAsDistance(DoubleNewVal, WIDTH);
02049 if (abs(Distance - EditData->m_BrushSpacingIncrConst) > 5)
02050 {
02051 EditData->m_BrushSpacingIncrConst = Distance;
02052 ChangeType_m = CHANGEBRUSH_SPACING_INCRCONST;
02053 ChangeParam_m.m_NewSpacingIncrConst = Distance;
02054 SetSpacingIncrSlider();
02055 }
02056 }
02057 else
02058 {
02059
02060 UpdateEditBox(_R(IDC_EDITBRUSHSPACINGINCRCONST));
02061 }
02062 }
02063 else if (Msg->GadgetID == _R(IDC_EDITPATHOFFSETVALUE))
02064 {
02065 DoubleNewVal = GetDoubleGadgetValue(_R(IDC_EDITPATHOFFSETVALUE), MinOffset, MaxOffset,0, &Valid );
02066
02067 if (DoubleNewVal <= MaxOffset && DoubleNewVal >= MinOffset && Valid)
02068 {
02069
02070 MILLIPOINT Offset = GetPercentageAsDistance(DoubleNewVal, HEIGHT);
02071 if (abs(Offset - EditData->m_PathOffsetValue) > 5)
02072 {
02073 EditData->m_PathOffsetValue = Offset;
02074 ChangeType_m = CHANGEBRUSH_OFFSET_VAL;
02075 ChangeParam_m.m_NewPathOffsetVal = Offset;
02076 ReInitBrushOffset();
02077 }
02078 }
02079 else
02080 {
02081 UpdateEditBox(_R(IDC_EDITPATHOFFSETVALUE));
02082 }
02083 }
02084 else if (Msg->GadgetID == _R(IDC_EDITPATHOFFSETINCRCONST))
02085 {
02086 DoubleNewVal = GetDoubleGadgetValue(_R(IDC_EDITPATHOFFSETINCRCONST), MIN_SPACING_INCR, MAX_SPACING_INCR, _R(IDS_BRUSHINCRINVALID), &Valid);
02087 if (Valid && DoubleNewVal <= MAX_SPACING_INCR && DoubleNewVal >= MIN_SPACING_INCR)
02088 {
02089 MilliPointNewVal = GetPercentageAsDistance(DoubleNewVal, HEIGHT);
02090 if (EditData->m_PathOffsetIncrConst != MilliPointNewVal)
02091 {
02092 EditData->m_PathOffsetIncrConst = MilliPointNewVal;
02093 ChangeParam_m.m_NewOffsetIncrConst = MilliPointNewVal;
02094 ChangeType_m = CHANGEBRUSH_OFFSET_INCRCONST;
02095 ReInitBrushOffset();
02096 }
02097 }
02098 else
02099 {
02100
02101 UpdateEditBox(_R(IDC_EDITPATHOFFSETINCRCONST));
02102 }
02103 }
02104 else if (Msg->GadgetID == _R(IDC_EDITSCALINGINCRCONST))
02105 {
02106 DoubleNewVal = GetDoubleGadgetValue (_R(IDC_EDITSCALINGINCRCONST), MinScalingIncrSlider, MaxScalingIncrSlider, _R(IDS_BRUSHSCALINGINCRINVALID), &Valid);
02107
02108 if (DoubleNewVal <= MaxScalingIncrSlider && DoubleNewVal >= MinScalingIncrSlider && Valid)
02109 {
02110
02111 if (EditData->m_BrushScalingIncrConst != DoubleNewVal)
02112 {
02113 EditData->m_BrushScalingIncrConst = DoubleNewVal;
02114 ReInitBrushScaling();
02115 ChangeType_m = CHANGEBRUSH_SCALING_INCRCONST;
02116 ChangeParam_m.m_NewScalingIncrConst = EditData->m_BrushScalingIncrConst;
02117 }
02118 }
02119 else
02120 {
02121
02122 UpdateEditBox(_R(IDC_EDITSCALINGINCRCONST));
02123 }
02124 }
02125 else if (Msg->GadgetID == _R(IDC_EDITBRUSHSCALINGINCR))
02126 {
02127 DoubleNewVal = GetDoubleGadgetValue (_R(IDC_EDITBRUSHSCALINGINCR), MinMultiSlider, MaxMultiSlider, _R(IDS_INCRPROP_INVALID), &Valid);
02128 if (! Valid || DoubleNewVal < MinMultiSlider || DoubleNewVal > MaxMultiSlider)
02129 {
02130
02131 UpdateEditBox(_R(IDC_EDITBRUSHSCALINGINCR));
02132 }
02133 else
02134 {
02135 if (EditData->m_BrushScalingIncr != DoubleNewVal / 100)
02136 {
02137 EditData->m_BrushScalingIncr = DoubleNewVal / 100;
02138 ChangeType_m = CHANGEBRUSH_SCALING_INCR;
02139 ChangeParam_m.m_NewScalingIncr = DoubleNewVal / 100;
02140 ReInitBrushScaling();
02141 }
02142 }
02143 }
02144 else if (Msg->GadgetID == _R(IDC_EDITROTATEANGLE))
02145 {
02146 DoubleNewVal = GetDoubleGadgetValue(_R(IDC_EDITROTATEANGLE), 0, MAX_ANGLE_DEG, _R(IDS_BRUSHANGLE_INVALID), &Valid );
02147 if (! Valid || DoubleNewVal < 0 || DoubleNewVal > MAX_ANGLE_DEG)
02148 {
02149
02150 UpdateEditBox(_R(IDC_EDITROTATEANGLE));
02151 }
02152 else
02153 {
02154 if (EditData->m_RotateAngle != DoubleNewVal)
02155 {
02156 EditData->m_RotateAngle = DoubleNewVal;
02157 ChangeType_m = CHANGEBRUSH_ROTATE_ANGLE;
02158 ChangeParam_m.m_NewRotateAngle = DoubleNewVal;
02159 ReInitBrushEffects();
02160 }
02161 }
02162 }
02163 else if (Msg->GadgetID == _R(IDC_EDITROTATEANGLEINCR))
02164 {
02165 DoubleNewVal = GetDoubleGadgetValue(_R(IDC_EDITROTATEANGLEINCR), MIN_ANGLE_DEG , MAX_ANGLE_DEG, _R(IDS_BRUSHANGLE_INVALID), &Valid);
02166 if (!Valid || DoubleNewVal < MIN_ANGLE_DEG || DoubleNewVal > MAX_ANGLE_DEG)
02167 {
02168
02169 UpdateEditBox(_R(IDC_EDITROTATEANGLEINCR));
02170 }
02171 else
02172 {
02173 if (EditData->m_RotAngleIncrConst != DoubleNewVal)
02174 {
02175 EditData->m_RotAngleIncrConst = DoubleNewVal ;
02176 ChangeType_m = CHANGEBRUSH_ROTATE_INCRCONST;
02177 ChangeParam_m.m_NewRotationIncrConst = DoubleNewVal ;
02178 ReInitBrushEffects();
02179 }
02180 }
02181 }
02182 else if (Msg->GadgetID == _R(IDC_EDITBRUSHTRANSP))
02183 {
02184 LongNewVal = GetLongGadgetValue(_R(IDC_EDITBRUSHTRANSP), MIN_TRANSP_SLIDER-100 , MAX_TRANSP_SLIDER-100, _R(IDS_BRUSHTRANSP_INVALID), &Valid);
02185 if (Valid)
02186 {
02187 if (EditData->m_BrushTransparency != LongNewVal + 100)
02188 {
02189 EditData->m_BrushTransparency = LongNewVal + 100;
02190 ChangeType_m = CHANGEBRUSH_TRANSP;
02191 ChangeParam_m.m_NewTransp = EditData->m_BrushTransparency;
02192 ReInitBrushSequence();
02193 }
02194
02195
02196 }
02197 UpdateEditBox(_R(IDC_EDITBRUSHTRANSP));
02198 }
02199 }
02200
02201 void CBrushEditDlg::ReadComboBox (DialogMsg* Msg)
02202 {
02203
02204
02205 WORD Index = (WORD)(-1);
02206
02207 if (Msg->GadgetID == _R(IDC_COMBOPATHOFFSETTYPE))
02208 {
02209 GetValueIndex(_R(IDC_COMBOPATHOFFSETTYPE), &Index);
02210 UsingRandomOffset = FALSE;
02211
02212 switch (Index)
02213 {
02214 case -1:
02215 ERROR3("Invalid index");
02216 break;
02217
02218 case OFFSET_NONE:
02219 EditData->m_PathOffsetType = OFFSET_NONE;
02220 if (EditData->m_OffsetValueMaxRand == 0)
02221 ChangeParam_m.m_NewPathOffsetType = OFFSET_NONE;
02222 else
02223 ChangeParam_m.m_NewPathOffsetType = OFFSET_RANDOM;
02224
02225 ChangeType_m = CHANGEBRUSH_OFFSET_TYPE;
02226 ReInitBrushOffset ();
02227 break;
02228
02229 case OFFSET_ALTERNATE:
02230 EditData->m_PathOffsetType = OFFSET_ALTERNATE;
02231 ChangeType_m = CHANGEBRUSH_OFFSET_TYPE;
02232 ChangeParam_m.m_NewPathOffsetType = OFFSET_ALTERNATE;
02233 ReInitBrushOffset ();
02234 break;
02235
02236 case OFFSET_LEFT:
02237 EditData->m_PathOffsetType = OFFSET_LEFT;
02238 ChangeType_m = CHANGEBRUSH_OFFSET_TYPE;
02239 ChangeParam_m.m_NewPathOffsetType = OFFSET_LEFT;
02240 ReInitBrushOffset ();
02241 break;
02242
02243 case OFFSET_RIGHT:
02244 EditData->m_PathOffsetType = OFFSET_RIGHT;
02245 ChangeType_m = CHANGEBRUSH_OFFSET_TYPE;
02246 ChangeParam_m.m_NewPathOffsetType = OFFSET_RIGHT;
02247 ReInitBrushOffset ();
02248 break;
02249
02250 case OFFSET_RANDOM:
02251 UsingRandomOffset = TRUE;
02252 EditData->m_PathOffsetType = OFFSET_RANDOM;
02253 ChangeType_m = CHANGEBRUSH_OFFSET_TYPE;
02254 ChangeParam_m.m_NewPathOffsetType = OFFSET_RANDOM;
02255 ReInitBrushOffset ();
02256 break;
02257
02258 default:
02259 ERROR3("Unrecognised offset type");
02260 ChangeType_m = CHANGEBRUSH_NONE;
02261 break;
02262 }
02263 }
02264 else if (Msg->GadgetID == _R(IDC_COMBOSEQUENCETYPE))
02265 {
02266 GetValueIndex(_R(IDC_COMBOSEQUENCETYPE), &Index);
02267 switch(Index)
02268 {
02269 case SEQ_FORWARD:
02270 EditData->m_SequenceType = SEQ_FORWARD;
02271 ChangeType_m = CHANGEBRUSH_SEQUENCE;
02272 ChangeParam_m.m_NewSequenceType = SEQ_FORWARD;
02273 break;
02274
02275 case SEQ_BACKWARD:
02276 EditData->m_SequenceType = SEQ_BACKWARD;
02277 ChangeType_m = CHANGEBRUSH_SEQUENCE;
02278 ChangeParam_m.m_NewSequenceType = SEQ_BACKWARD;
02279 break;
02280
02281 case SEQ_MIRROR:
02282 EditData->m_SequenceType = SEQ_MIRROR;
02283 ChangeType_m = CHANGEBRUSH_SEQUENCE;
02284 ChangeParam_m.m_NewSequenceType = SEQ_MIRROR;
02285 break;
02286
02287 case SEQ_RANDOM:
02288 EditData->m_SequenceType = SEQ_RANDOM;
02289 ChangeType_m = CHANGEBRUSH_SEQUENCE;
02290 ChangeParam_m.m_NewSequenceType = SEQ_RANDOM;
02291 break;
02292
02293 default:
02294 ERROR3("Unrecognised sequence type");
02295 ChangeType_m = CHANGEBRUSH_NONE;
02296 break;
02297 }
02298 ReInitBrushSpacing();
02299 }
02300 else
02301 ChangeType_m = CHANGEBRUSH_NONE;
02302 }
02303
02304 void CBrushEditDlg::ReadCheckBox (DialogMsg* Msg)
02305 {
02306
02307
02308 if (Msg->GadgetID == _R(IDC_CHECKTILEING))
02309 {
02310 EditData->m_bTile = !(EditData->m_bTile);
02311
02312
02313 ChangeType_m = CHANGEBRUSH_TILED;
02314 ChangeParam_m.m_bNewTiled = EditData->m_bTile;
02315 ReInitBrushFill();
02316 }
02317 else if (Msg->GadgetID == _R(IDC_CHECKLOCALFILLCOLOUR))
02318 {
02319
02320 EditData->m_bUseLocalFillColour = !(EditData->m_bUseLocalFillColour);
02321 ChangeType_m = CHANGEBRUSH_USELOCALFILLCOL;
02322 ChangeParam_m.m_bNewUseLocalFillColour = EditData->m_bUseLocalFillColour;
02323 ReInitBrushFill();
02324 }
02325 else if (Msg->GadgetID == _R(IDC_CHECKOVERRIDENAMED))
02326 {
02327 EditData->m_bUseNamedColour = !(EditData->m_bUseNamedColour);
02328 ChangeType_m = CHANGEBRUSH_USENAMEDCOL;
02329 ChangeParam_m.m_bNewUseNamed = EditData->m_bUseNamedColour;
02330 ReInitBrushFill();
02331 }
02332 else if (Msg->GadgetID == _R(IDC_CHECKROTATE))
02333 {
02334
02335 EditData->m_bRotate = !(EditData->m_bRotate);
02336 ChangeType_m = CHANGEBRUSH_TANGENTIAL;
02337 ChangeParam_m.m_bNewRotated = EditData->m_bRotate;
02338
02339
02340
02341
02342
02343
02344 }
02345 else
02346 {
02347
02348 ChangeType_m = CHANGEBRUSH_NONE;
02349 }
02350 }
02351
02352 void CBrushEditDlg::ReadRadios(DialogMsg* Msg)
02353 {
02354 if (Msg == NULL)
02355 return;
02356
02357 if (Msg->GadgetID == _R(IDC_RADIOLOCALFILLALL))
02358 {
02359 if (EditData->m_bUseLocalFillColour == FALSE)
02360 {
02361 EditData->m_bUseLocalFillColour = TRUE;
02362
02363
02364 EditData->m_bUseNamedColour = TRUE;
02365 ChangeParam_m.m_bNewUseLocalFillColour = TRUE;
02366 ChangeType_m = CHANGEBRUSH_USELOCALFILLCOL;
02367 }
02368 }
02369 else if (Msg->GadgetID == _R(IDC_RADIOLOCALFILLNAMED))
02370 {
02371
02372
02373 if (EditData->m_bUseNamedColour == TRUE)
02374 {
02375 EditData->m_bUseNamedColour = FALSE;
02376 EditData->m_bUseLocalFillColour = FALSE;
02377 ChangeParam_m.m_bNewUseNamed = FALSE;
02378 ChangeType_m = CHANGEBRUSH_USENAMEDCOL;
02379 }
02380 }
02381 else if (Msg->GadgetID == _R(IDC_RADIOLOCALFILLNONE))
02382 {
02383
02384 if (EditData->m_bUseLocalFillColour)
02385 {
02386 EditData->m_bUseLocalFillColour = FALSE;
02387 ChangeParam_m.m_bNewUseLocalFillColour = FALSE;
02388 ChangeType_m = CHANGEBRUSH_USELOCALFILLCOL;
02389 }
02390
02391 if (EditData->m_bUseNamedColour == FALSE)
02392 {
02393 EditData->m_bUseNamedColour = TRUE;
02394 ChangeParam_m.m_bNewUseNamed = TRUE;
02395 ChangeType_m = CHANGEBRUSH_USENAMEDCOL;
02396 }
02397
02398 }
02399 }
02400
02401 void CBrushEditDlg::ReadSlider (DialogMsg* Msg)
02402 {
02403 BOOL Valid;
02404 INT32 Result;
02405
02406 ChangeType_m = CHANGEBRUSH_NONE;
02407
02408 if (Msg->GadgetID == _R(IDC_SLIDERBRUSHSPACING1))
02409 {
02410 double MinSpacingSlider = 0;
02411 double MaxSpacingSlider = 0;
02412
02413 GetSpacingRange(&MinSpacingSlider, &MaxSpacingSlider);
02414
02415 INT32 IntMin = (INT32)(MinSpacingSlider);
02416 INT32 IntMax = (INT32)(MaxSpacingSlider);
02417
02418 Result = GetLongGadgetValue (_R(IDC_SLIDERBRUSHSPACING1), IntMin, IntMax, 0, &Valid);
02419 Result = (IntMax - Result) + IntMin;
02420
02421 if (Valid)
02422 {
02423 double ExpVal = pow(Result, ExpFactor);
02424 MILLIPOINT NewSpacing = (MILLIPOINT)ExpVal;
02425
02426 EditData->m_BrushSpacing = NewSpacing;
02427 ChangeParam_m.m_NewSpacing = NewSpacing;
02428 ChangeType_m = CHANGEBRUSH_SPACING;
02429 SetSpacingSlider();
02430
02431
02432 }
02433 }
02434 else if (Msg->GadgetID == _R(IDC_SLIDERBRUSHSPACINGINCR))
02435 {
02436 double dblResult = GetDoubleGadgetValue(_R(IDC_SLIDERBRUSHSPACINGINCR), MIN_SPACING_INCR, MAX_SPACING_INCR, 0, &Valid);
02437 dblResult = (MAX_SPACING_INCR - dblResult) + MIN_SPACING_INCR;
02438 if (Valid)
02439 {
02440
02441 MILLIPOINT Distance = GetPercentageAsDistance(dblResult, WIDTH);
02442
02443 EditData->m_BrushSpacingIncrConst = Distance;
02444 ChangeParam_m.m_NewSpacingIncrConst = Distance;
02445 ChangeType_m = CHANGEBRUSH_SPACING_INCRCONST;
02446 UpdateEditBox(_R(IDC_EDITBRUSHSPACINGINCRCONST));
02447
02448 }
02449 }
02450 else if (Msg->GadgetID == _R(IDC_SLIDERBRUSHSPACINGMAXRAND))
02451 {
02452 Result = GetLongGadgetValue (_R(IDC_SLIDERBRUSHSPACINGMAXRAND), MIN_RANDOM_SLIDER, MAX_RANDOM_SLIDER, 0, &Valid);
02453 Result = MAX_RANDOM_SLIDER - Result;
02454
02455 if (Valid)
02456 {
02457 EditData->m_BrushSpacingMaxRand = Result;
02458
02459 if (!UsingRandomSpacing)
02460 {
02461 if (Result != MIN_RANDOM_SLIDER)
02462 {
02463 ReInitBrushSpacing ();
02464 }
02465 }
02466 else if (Result == MIN_RANDOM_SLIDER)
02467 {
02468 ReInitBrushSpacing ();
02469 }
02470 ChangeType_m = CHANGEBRUSH_SPACING_MAXRAND;
02471 ChangeParam_m.m_NewSpacingMaxRand = Result;
02472 SetRandomRangeText(_R(IDC_SLIDERBRUSHSPACINGMAXRAND));
02473 }
02474 }
02475 else if (Msg->GadgetID == _R(IDC_SLIDERPATHOFFSETVAL))
02476 {
02477 double MinOffset = 0;
02478 double MaxOffset = 0;
02479
02480 GetOffsetRange(&MinOffset, &MaxOffset);
02481
02482 INT32 lMinOffset = (INT32)MinOffset;
02483 INT32 lMaxOffset = (INT32)MaxOffset;
02484
02485 Result = GetLongGadgetValue(_R(IDC_SLIDERPATHOFFSETVAL), lMinOffset, lMaxOffset, 0, &Valid);
02486 Result = (lMaxOffset - Result) + lMinOffset;
02487
02488 if (Valid)
02489 {
02490 double ExpVal = pow(Result, ExpFactor);
02491 MILLIPOINT NewOffset = (MILLIPOINT)ExpVal;
02492
02493 EditData->m_PathOffsetValue = NewOffset;
02494 ChangeParam_m.m_NewPathOffsetVal = NewOffset;
02495 ChangeType_m = CHANGEBRUSH_OFFSET_VAL;
02496 ReInitBrushOffset();
02497
02498 }
02499
02500 }
02501 else if (Msg->GadgetID == _R(IDC_SLIDEROFFSETINCRCONST))
02502 {
02503 double NewIncr = GetDoubleGadgetValue(_R(IDC_SLIDEROFFSETINCRCONST), MIN_SPACING_INCR, MAX_SPACING_INCR, 0, &Valid);
02504
02505 if (Valid)
02506 {
02507 NewIncr = (MAX_SPACING_INCR - NewIncr) + MIN_SPACING_INCR;
02508 MILLIPOINT Incr = GetPercentageAsDistance(NewIncr, HEIGHT);
02509 if (abs(EditData->m_PathOffsetIncrConst - Incr) > 20)
02510 {
02511 EditData->m_PathOffsetIncrConst = Incr;
02512 ChangeParam_m.m_NewOffsetIncrConst = Incr;
02513 ChangeType_m = CHANGEBRUSH_OFFSET_INCRCONST;
02514 UpdateEditBox(_R(IDC_EDITPATHOFFSETINCRCONST));
02515 }
02516 }
02517 }
02518 else if (Msg->GadgetID == _R(IDC_SLIDEROFFSETVALUEMAXRAND))
02519 {
02520 Result = GetLongGadgetValue (_R(IDC_SLIDEROFFSETVALUEMAXRAND), MinOffsetSlider, MaxOffsetSlider, 0, &Valid);
02521 Result = MaxOffsetSlider - Result;
02522
02523 if (Valid)
02524 {
02525 EditData->m_OffsetValueMaxRand = Result;
02526
02527
02528
02529 if (EditData->m_PathOffsetType == OFFSET_NONE)
02530 {
02531 EditData->m_PathOffsetType = OFFSET_RANDOM;
02532 ChangeParam_m.m_NewPathOffsetType = OFFSET_RANDOM;
02533 ChangeType_m = CHANGEBRUSH_ALL;
02534 }
02535 else
02536 ChangeType_m = CHANGEBRUSH_OFFSET_MAXRAND;
02537
02538 ChangeParam_m.m_NewOffsetValMaxRand = Result;
02539 }
02540 ReInitBrushOffset();
02541 }
02542 else if (Msg->GadgetID == _R(IDC_SLIDERBRUSHSCALINGMAXRAND))
02543 {
02544 Result = GetLongGadgetValue (_R(IDC_SLIDERBRUSHSCALINGMAXRAND), MinScalingSlider, MaxScalingSlider, 0, &Valid);
02545 Result = MaxScalingSlider - Result;
02546
02547 if (Valid)
02548 {
02549 EditData->m_BrushScalingMaxRand = Result;
02550
02551 if (!UsingRandomScaling)
02552 {
02553 if (Result != MinScalingSlider)
02554 {
02555 ReInitBrushScaling ();
02556 }
02557 }
02558 else if (Result == MinScalingSlider)
02559 {
02560 ReInitBrushScaling ();
02561 }
02562 SetRandomRangeText(_R(IDC_SLIDERBRUSHSCALINGMAXRAND));
02563 ChangeType_m = CHANGEBRUSH_SCALING_MAXRAND;
02564 ChangeParam_m.m_NewScalingMaxRand = Result;
02565 }
02566 }
02567 else if (Msg->GadgetID == _R(IDC_SLIDERROTATEANGLE))
02568 {
02569 double NewAngle = GetDoubleGadgetValue(_R(IDC_SLIDERROTATEANGLE), MIN_ROTATION_SLIDER, MAX_ROTATION_SLIDER, 0, &Valid);
02570 if (Valid)
02571 {
02572 NewAngle = (MAX_ROTATION_SLIDER - NewAngle) + MIN_ROTATION_SLIDER;
02573
02574
02575 INT32 AngleRounded = (INT32)NewAngle;
02576 ChangeParam_m.m_NewRotateAngle = (double)AngleRounded;
02577 ChangeType_m = CHANGEBRUSH_ROTATE_ANGLE;
02578 EditData->m_RotateAngle = ChangeParam_m.m_NewRotateAngle;
02579 ReInitBrushEffects();
02580
02581
02582 }
02583 }
02584 else if (Msg->GadgetID == _R(IDC_SLIDERROTATEANGLEINCR))
02585 {
02586 double NewIncr = GetDoubleGadgetValue(_R(IDC_SLIDERROTATEANGLEINCR), MIN_ROTATION_INCR_SLIDER, MAX_ROTATION_INCR_SLIDER,
02587 0, &Valid);
02588 if (Valid)
02589 {
02590 NewIncr = (MAX_ROTATION_INCR_SLIDER - NewIncr) + MIN_ROTATION_INCR_SLIDER;
02591
02592 INT32 IncrRounded = (INT32)NewIncr;
02593 EditData->m_RotAngleIncrConst =(double)IncrRounded;
02594 ChangeParam_m.m_NewRotationIncrConst = EditData->m_RotAngleIncrConst;
02595 ChangeType_m = CHANGEBRUSH_ROTATE_INCRCONST;
02596 ReInitBrushEffects();
02597
02598 }
02599 }
02600 else if (Msg->GadgetID == _R(IDC_SLIDERROTATEANGLEMAXRAND))
02601 {
02602 Result = GetLongGadgetValue (_R(IDC_SLIDERROTATEANGLEMAXRAND), MIN_RANDOM_SLIDER, MAX_ROTATION_RANDOM_SLIDER, 0, &Valid);
02603 Result = (MAX_ROTATION_RANDOM_SLIDER - Result) + MIN_RANDOM_SLIDER;
02604
02605 if (Valid)
02606 {
02607 EditData->m_RotationMaxRand = Result;
02608 ReInitBrushEffects ();
02609
02610 ChangeType_m = CHANGEBRUSH_ROTATE_MAXRAND;
02611 ChangeParam_m.m_NewRotateMaxRand = Result;
02612 SetRandomRangeText(_R(IDC_SLIDERROTATEANGLEMAXRAND));
02613 }
02614 }
02615 else if (Msg->GadgetID == _R(IDC_SLIDERROTATEINCR))
02616 {
02617 Result = GetLongGadgetValue(_R(IDC_SLIDERROTATEINCR), MinMultiSlider, MaxMultiSlider, 0, &Valid);
02618 Result = (MaxMultiSlider - Result) + MinMultiSlider;
02619 if (Valid)
02620 {
02621
02622 EditData->m_RotAngleIncrProp = (double)((double)Result / 100);
02623 ReInitBrushEffects();
02624 ChangeType_m = CHANGEBRUSH_ROTATE_INCRPROP;
02625 ChangeParam_m.m_NewRotationIncrProp = EditData->m_RotAngleIncrProp;
02626
02627 }
02628 }
02629 else if (Msg->GadgetID == _R(IDC_SLIDERBRUSHSCALINGINCR))
02630 {
02631 Result = GetLongGadgetValue (_R(IDC_SLIDERBRUSHSCALINGINCR), MinMultiSlider, MaxMultiSlider, 0, &Valid);
02632 Result = (MaxMultiSlider - Result) + MinMultiSlider;
02633 if (Valid)
02634 {
02635
02636 EditData->m_BrushScalingIncr = (double)Result / 100;
02637 ReInitBrushScaling();
02638 ChangeType_m = CHANGEBRUSH_SCALING_INCR;
02639 ChangeParam_m.m_NewScalingIncr = EditData->m_BrushScalingIncr;
02640
02641 }
02642 }
02643 else if (Msg->GadgetID == _R(IDC_SLIDERSCALINGINCRCONST))
02644 {
02645 Result = GetLongGadgetValue(_R(IDC_SLIDERSCALINGINCRCONST), MinScalingIncrSlider, MaxScalingIncrSlider, 0, &Valid);
02646 Result = (MaxScalingIncrSlider - Result) + MinScalingIncrSlider;
02647 if (Valid)
02648 {
02649 if (EditData->m_BrushScalingIncrConst != Result)
02650 {
02651 EditData->m_BrushScalingIncrConst = (double)Result;
02652 ReInitBrushScaling();
02653 ChangeType_m = CHANGEBRUSH_SCALING_INCRCONST;
02654 ChangeParam_m.m_NewScalingIncrConst = (double)Result;
02655 }
02656 }
02657 }
02658 else if (Msg->GadgetID == _R(IDC_SLIDERSCALINGPRESSURE))
02659 {
02660 Result = GetLongGadgetValue(_R(IDC_SLIDERSCALINGPRESSURE), MIN_PRESSURE_SLIDER, MAX_PRESSURE_SLIDER, 0, &Valid);
02661 if (Valid)
02662 {
02663 Result = (MAX_PRESSURE_SLIDER - Result) + MIN_PRESSURE_SLIDER;
02664
02665 EditData->m_ScalingMaxPressure = Result;
02666 ReInitBrushScaling();
02667 ChangeType_m = CHANGEBRUSH_SCALING_PRESSURE;
02668 ChangeParam_m.m_NewScalingMaxPressure = Result;
02669 SetRandomRangeText(_R(IDC_SLIDERSCALINGPRESSURE));
02670
02671 }
02672 }
02673 else if (Msg->GadgetID == _R(IDC_SLIDERSATURATIONRANDOM))
02674 {
02675 Result = GetLongGadgetValue(_R(IDC_SLIDERSATURATIONRANDOM), MIN_RANDOM_SLIDER, MAX_RANDOM_SAT_SLIDER, 0, &Valid);
02676 if (Valid)
02677 {
02678 Result = (MAX_RANDOM_SAT_SLIDER - Result) + MIN_RANDOM_SLIDER;
02679
02680 EditData->m_BrushSatMaxRand = Result;
02681 ChangeType_m = CHANGEBRUSH_SAT_MAXRAND;
02682 ChangeParam_m.m_NewSatMaxRand = Result;
02683 SetRandomRangeText(_R(IDC_SLIDERSATURATIONRANDOM));
02684
02685 ReInitBrushFill();
02686 }
02687 }
02688 else if (Msg->GadgetID == _R(IDC_SLIDERHUERANDOM))
02689 {
02690 Result = GetLongGadgetValue(_R(IDC_SLIDERHUERANDOM), MIN_RANDOM_SLIDER, MAX_RANDOM_HUE_SLIDER, 0, &Valid);
02691 if (Valid)
02692 {
02693 Result = (MAX_RANDOM_HUE_SLIDER - Result) + MIN_RANDOM_SLIDER;
02694
02695 EditData->m_BrushHueMaxRand = Result;
02696 ChangeType_m = CHANGEBRUSH_HUE_MAXRAND;
02697 ChangeParam_m.m_NewHueMaxRand = Result;
02698 SetRandomRangeText(_R(IDC_SLIDERHUERANDOM));
02699
02700 ReInitBrushFill();
02701 }
02702 }
02703 else if (Msg->GadgetID == _R(IDC_SLIDERTRANSP))
02704 {
02705 Result = GetLongGadgetValue(_R(IDC_SLIDERTRANSP), MIN_TRANSP_SLIDER, MAX_TRANSP_SLIDER, 0, &Valid);
02706 if (Valid)
02707 {
02708 Result = (MAX_TRANSP_SLIDER - Result) + MIN_TRANSP_SLIDER;
02709
02710 EditData->m_BrushTransparency = Result;
02711 ChangeType_m = CHANGEBRUSH_TRANSP;
02712 ChangeParam_m.m_NewTransp = Result;
02713 UpdateEditBox(_R(IDC_EDITBRUSHTRANSP));
02714
02715 }
02716 }
02717 else if (Msg->GadgetID == _R(IDC_SLIDERTRANSPPRESSURE))
02718 {
02719 Result = GetLongGadgetValue(_R(IDC_SLIDERTRANSPPRESSURE), MIN_PRESSURE_SLIDER, MAX_PRESSURE_SLIDER, 0, &Valid);
02720 if (Valid)
02721 {
02722 Result = (MAX_PRESSURE_SLIDER - Result) + MIN_PRESSURE_SLIDER;
02723
02724 EditData->m_TranspMaxPressure = Result;
02725 ChangeType_m = CHANGEBRUSH_TRANSP_PRESSURE;
02726 ChangeParam_m.m_NewTranspPressure = Result;
02727 ReInitBrushSequence();
02728
02729 }
02730 }
02731 }
02732
02733
02734 void CBrushEditDlg::ReadButtons(DialogMsg* Msg)
02735 {
02736 if (Msg->GadgetID == _R(IDC_BUTTONBRUSHSCALINGRANDSEED))
02737 {
02738 ChangeType_m = CHANGEBRUSH_SCALING_RANDSEED;
02739 ChangeParam_m.m_NewScalingRandSeed = GetNewRandomNumber(0);
02740 EditData->m_BrushScalingRandSeed = ChangeParam_m.m_NewScalingRandSeed;
02741 }
02742 else if (Msg->GadgetID == _R(IDC_BUTTONBRUSHSPACINGRANDSEED))
02743 {
02744 ChangeType_m = CHANGEBRUSH_SPACING_RANDSEED;
02745 ChangeParam_m.m_NewSpacingRandSeed = GetNewRandomNumber(0);
02746 EditData->m_BrushSpacingRandSeed = ChangeParam_m.m_NewSpacingRandSeed;
02747
02748
02749 ChangeParam_m.m_NewSequenceRandSeed = EditData->m_BrushSpacingRandSeed;
02750 EditData->m_SequenceRandSeed = ChangeParam_m.m_NewSequenceRandSeed;
02751 }
02752 else if (Msg->GadgetID == _R(IDC_BUTTONOFFSETVALUERANDSEED))
02753 {
02754
02755
02756
02757 ChangeType_m = CHANGEBRUSH_OFFSET_SEEDS;
02758 ChangeParam_m.m_NewOffsetValRandSeed = GetNewRandomNumber(0);
02759 ChangeParam_m.m_NewOffsetTypeRandSeed = GetNewRandomNumber(0);
02760 EditData->m_OffsetValueRandSeed = ChangeParam_m.m_NewOffsetValRandSeed;
02761 EditData->m_OffsetTypeRandSeed = ChangeParam_m.m_NewOffsetTypeRandSeed;
02762 }
02763 else if (Msg->GadgetID == _R(IDC_BUTTONBRUSHSEQUENCERANDSEED))
02764 {
02765 ChangeType_m = CHANGEBRUSH_SEQUENCE_RANDSEED;
02766 ChangeParam_m.m_NewSequenceRandSeed = GetNewRandomNumber(0);
02767 EditData->m_SequenceRandSeed = ChangeParam_m.m_NewSequenceRandSeed;
02768 }
02769 else if (Msg->GadgetID == _R(IDC_BUTTONROTATEANGLERANDSEED))
02770 {
02771 ChangeType_m = CHANGEBRUSH_ROTATE_RANDSEED;
02772 ChangeParam_m.m_NewRotateRandSeed = GetNewRandomNumber(0);
02773 EditData->m_RotationRandSeed = ChangeParam_m.m_NewRotateRandSeed;
02774 }
02775 else if (Msg->GadgetID == _R(IDC_BUTTONBRUSHFILLRANDOM))
02776 {
02777 ChangeType_m = CHANGEBRUSH_FILL_SEEDS;
02778 ChangeParam_m.m_NewHueRandSeed = GetNewRandomNumber(0);
02779 ChangeParam_m.m_NewSatRandSeed = GetNewRandomNumber(0);
02780 EditData->m_BrushHueRandSeed = ChangeParam_m.m_NewHueRandSeed;
02781 EditData->m_BrushSatRandSeed = ChangeParam_m.m_NewSatRandSeed;
02782 }
02783 }
02784
02785 void CBrushEditDlg::WriteSliders (DialogMsg* Msg)
02786 {
02787
02788 }
02789
02790 void CBrushEditDlg::UpdateEditBox (CGadgetID GadgetToUpdate)
02791 {
02792 if (GadgetToUpdate == _R(IDC_EDITBRUSHSPACING))
02793 {
02794
02795 double dSpacingValue = (double)EditData->m_BrushSpacing;
02796 MILLIPOINT lSpacingValue = (MILLIPOINT)dSpacingValue;
02797 dSpacingValue = pow(dSpacingValue, 1/ExpFactor);
02798
02799
02800
02801 double SpacingAsPercent = GetDistanceAsPercentageOfBBox(lSpacingValue, WIDTH);
02802 SetDoubleGadgetValue (_R(IDC_EDITBRUSHSPACING), SpacingAsPercent);
02803
02804 }
02805
02806
02807
02808
02809
02810
02811
02812
02813 else if (GadgetToUpdate == _R(IDC_EDITPATHOFFSETVALUE))
02814 {
02815 double PercentVal = GetDistanceAsPercentageOfBBox(EditData->m_PathOffsetValue, HEIGHT);
02816 SetDoubleGadgetValue(_R(IDC_EDITPATHOFFSETVALUE), PercentVal);
02817 }
02818
02819
02820
02821
02822
02823
02824
02825 else if (GadgetToUpdate == _R(IDC_EDITBRUSHSCALING))
02826 {
02827 SetDoubleGadgetValue (_R(IDC_EDITBRUSHSCALING), EditData->m_BrushScaling);
02828 }
02829 else if (GadgetToUpdate == _R(IDC_EDITBRUSHSCALINGINCR))
02830 {
02831 SetDoubleGadgetValue (_R(IDC_EDITBRUSHSCALINGINCR), EditData->m_BrushScalingIncr*100);
02832 }
02833
02834
02835
02836
02837
02838
02839 else if (GadgetToUpdate == _R(IDC_EDITROTATEANGLEINCR))
02840 {
02841 SetDoubleGadgetValue (_R(IDC_EDITROTATEANGLEINCR), EditData->m_RotAngleIncrConst);
02842 }
02843 else if (GadgetToUpdate == _R(IDC_EDITROTATEANGLE))
02844 {
02845 SetDoubleGadgetValue (_R(IDC_EDITROTATEANGLE), EditData->m_RotAngleIncrConst);
02846 }
02847 else if (GadgetToUpdate == _R(IDC_EDITBRUSHTRANSP))
02848 {
02849 SetLongGadgetValue(_R(IDC_EDITBRUSHTRANSP), EditData->m_BrushTransparency - 100);
02850 }
02851 }
02852
02853 void CBrushEditDlg::ReInitialiseDialog (BrushData* pData)
02854 {
02855 if (pData != NULL)
02856 {
02857 if (EditData != NULL)
02858 delete EditData;
02859 EditData = new BrushData(*pData);
02860 if (EditData == NULL)
02861 {
02862 ERROR3("Argh we failed to allocate new brush data");
02863 return;
02864 }
02865
02866
02867 ReInitPage(_R(IDD_BRUSHEDITSPACING));
02868 ReInitPage(_R(IDD_BRUSHEDITOFFSET));
02869 ReInitPage(_R(IDD_BRUSHEDITSCALING));
02870 ReInitPage(_R(IDD_BRUSHEDITEFFECTS));
02871 ReInitPage(_R(IDD_BRUSHEDITSEQUENCE));
02872
02873 }
02874 }
02875
02876 void CBrushEditDlg::ReInitPage(CDlgResID PageID)
02877 {
02878
02879 TalkToPage(PageID);
02880
02881 if (PageID == _R(IDD_BRUSHEDITSPACING))
02882 ReInitBrushSpacing();
02883 else if (PageID == _R(IDD_BRUSHEDITOFFSET))
02884 ReInitBrushOffset();
02885 else if (PageID == _R(IDD_BRUSHEDITSCALING))
02886 ReInitBrushScaling();
02887 else if (PageID == _R(IDD_BRUSHEDITEFFECTS))
02888 ReInitBrushEffects();
02889 else if (PageID == _R(IDD_BRUSHEDITSEQUENCE))
02890 ReInitBrushSequence();
02891 else if (PageID == _R(IDD_BRUSHEDITFILL))
02892 {
02893 }
02894 else
02895 {
02896 ERROR3("Message from unknown tab dialog page");
02897 }
02898
02899 }
02900
02901
02902
02903 AttrBrushType* CBrushEditDlg::GetSingleSelectedBrushAttribute()
02904 {
02905 AttrBrushType* pAttrBrush = NULL;
02906 List NodeList;
02907 BevelTools::BuildListOfSelectedNodes(&NodeList, CC_RUNTIME_CLASS(AttrBrushType));
02908 BrushData Data;
02909 INT32 NumItems = NodeList.GetCount();
02910 if (NumItems == 1)
02911 {
02912 NodeListItem* pItem = (NodeListItem*)NodeList.GetHead();
02913 if (pItem != NULL)
02914 pAttrBrush = (AttrBrushType*)pItem->pNode;
02915 }
02916 NodeList.DeleteAll();
02917 return pAttrBrush;
02918 }
02919
02920
02921
02922 void CBrushEditDlg::HandleDocSelectionChange()
02923 {
02924 AttrBrushType* pAttrBrush = GetSingleSelectedBrushAttribute();
02925 if (pAttrBrush == NULL)
02926 {
02927 m_bDisableGadgets = TRUE;
02928 String_32 Title = TEXT("");
02929 SetDialogTitle(Title);
02930
02931 RefreshActivePage();
02932 return;
02933 }
02934
02935
02936 if (EditData == NULL)
02937 EditData = new BrushData;
02938
02939 if (EditData == NULL)
02940 ERROR3("Unable to allocate brush data in CBrushEditDlg::HandleDocSelectionChange");
02941
02942 *EditData = pAttrBrush->GetBrushData();
02943
02944 if (OriginalData == NULL)
02945 OriginalData = new BrushData;
02946
02947 if (OriginalData == NULL)
02948 ERROR3("Unable to allocate brush data in CBrushEditDlg::HandleDocSelectionChange");
02949
02950 *OriginalData = *EditData;
02951 m_LastData = *EditData;
02952 m_bDisableGadgets = FALSE;
02953
02954
02955 SetDialogTitle(EditData->m_Name);
02956
02957
02958 ChangeParam_m.SetValues(*EditData);
02959
02960 EditingBrushDef = FALSE;
02961
02962 RefreshActivePage();
02963
02964 }
02965
02966
02967 void CBrushEditDlg::RefreshActivePage()
02968 {
02969 CDlgResID ActivePageID = GetCurrentPageID();
02970
02971 if (ActivePageID == _R(IDD_BRUSHEDITSPACING))
02972 {
02973 ReInitBrushSpacing();
02974 }
02975 else if (ActivePageID == _R(IDD_BRUSHEDITOFFSET))
02976 {
02977 ReInitBrushOffset();
02978 }
02979 else if (ActivePageID == _R(IDD_BRUSHEDITSCALING))
02980 {
02981 ReInitBrushScaling();
02982 }
02983 else if (ActivePageID == _R(IDD_BRUSHEDITEFFECTS))
02984 {
02985 ReInitBrushEffects();
02986 }
02987 else if (ActivePageID == _R(IDD_BRUSHEDITSEQUENCE))
02988 {
02989 ReInitBrushSequence();
02990 }
02991 else if (ActivePageID == _R(IDD_BRUSHEDITFILL))
02992 {
02993 ReInitBrushFill();
02994 }
02995
02996 }
02997
02998
02999
03000 void CBrushEditDlg::SetDialogTitle(String_256 Title)
03001 {
03002 SetTitlebarName(&Title);
03003 }
03004
03005
03006 void CBrushEditDlg::SetSpacingSlider()
03007 {
03008
03009 double MinSpacingSlider = 0; double MaxSpacingSlider = 0;
03010
03011 GetSpacingRange(&MinSpacingSlider, &MaxSpacingSlider);
03012
03013 INT32 IntMin = (INT32)(MinSpacingSlider);
03014 INT32 IntMax = (INT32)(MaxSpacingSlider);
03015
03016
03017 SetGadgetRange (_R(IDC_SLIDERBRUSHSPACING1), IntMin, IntMax);
03018 SetGadgetBitmaps( _R(IDC_SLIDERBRUSHSPACING1), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
03019
03020
03021 double dSpacingValue = (double)EditData->m_BrushSpacing;
03022 dSpacingValue = pow(dSpacingValue, 1/ExpFactor);
03023 INT32 iSpacingValue = (INT32)dSpacingValue;
03024 SetLongGadgetValue (_R(IDC_SLIDERBRUSHSPACING1), (IntMax - iSpacingValue) + IntMin);
03025
03026 UpdateEditBox(_R(IDC_EDITBRUSHSPACING));
03027 }
03028
03029 void CBrushEditDlg::SetSpacingIncrSlider()
03030 {
03031 SetGadgetRange(_R(IDC_SLIDERBRUSHSPACINGINCR), MIN_SPACING_INCR, MAX_SPACING_INCR);
03032 SetGadgetBitmaps (_R(IDC_SLIDERBRUSHSPACINGINCR), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
03033
03034 double PercentVal = GetDistanceAsPercentageOfBBox(EditData->m_BrushSpacingIncrConst, WIDTH);
03035 SetDoubleGadgetValue(_R(IDC_SLIDERBRUSHSPACINGINCR), (MAX_SPACING_INCR - PercentVal) + MIN_SPACING_INCR);
03036 }
03037
03038
03039 void CBrushEditDlg::SetOffsetValSlider()
03040 {
03041 double MinSlider = 0; double MaxSlider = 0;
03042
03043 GetOffsetRange(&MinSlider, &MaxSlider);
03044
03045 INT32 IntMin = (INT32)MinSlider;
03046 INT32 IntMax = (INT32)MaxSlider;
03047
03048 SetGadgetRange(_R(IDC_SLIDERPATHOFFSETVAL), IntMin, IntMax);
03049 SetGadgetBitmaps (_R(IDC_SLIDERPATHOFFSETVAL), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
03050
03051 double dOffsetVal = pow((double)EditData->m_PathOffsetValue, InvFactor);
03052 INT32 iOffsetVal = (INT32)dOffsetVal;
03053
03054 SetLongGadgetValue(_R(IDC_SLIDERPATHOFFSETVAL), (IntMax - iOffsetVal) + IntMin);
03055
03056 UpdateEditBox(_R(IDC_EDITPATHOFFSETVALUE));
03057 }
03058
03059
03060
03061
03062
03063
03064 void CBrushEditDlg::GetSpacingRange(double* pMinimum, double* pMaximum)
03065 {
03066 if (pMinimum == NULL || pMaximum == NULL)
03067 {
03068 ERROR3("Null pointers in CBrushEditDlg::GetSpacingRange");
03069 return;
03070 }
03071
03072 *pMinimum = MinSliderSpacing;
03073
03074 MILLIPOINT Width = GetSideOfBoundingBox(WIDTH);
03075 if (Width == 0)
03076 {
03077 ERROR3("Bounding rect is empty in CBrushEditDlg::GetSpacingRange");
03078 return;
03079 }
03080
03081 Width = Width * MAXSPACINGMULTIPLIER;
03082
03083 if (Width> MAX_BRUSH_SPACING)
03084 Width = MAX_BRUSH_SPACING;
03085
03086 double ExpRootWidth = pow((double)Width, 1/ExpFactor);
03087
03088 *pMaximum = ExpRootWidth;
03089 }
03090
03091
03092 void CBrushEditDlg::GetOffsetRange(double* pMin, double* pMax)
03093 {
03094 if (pMin == NULL || pMax == NULL)
03095 {
03096 ERROR3("Null pointers in CBrushEditDlg::GetOffsetRange");
03097 return;
03098 }
03099
03100 *pMin = MinOffset;
03101
03102 MILLIPOINT Height = GetSideOfBoundingBox(HEIGHT);
03103 if (Height == 0)
03104 {
03105
03106 return;
03107 }
03108
03109 Height = Height * MAXOFFSETMULTIPLIER;
03110
03111 if (Height > MAX_BRUSH_OFFSET)
03112 Height = MAX_BRUSH_OFFSET;
03113
03114 double ExpRootHeight = pow((double)Height, 1/ExpFactor);
03115
03116 *pMax = ExpRootHeight;
03117 }
03118
03119
03120 double CBrushEditDlg::GetDistanceAsPercentageOfBBox(MILLIPOINT Distance, RectSideInfo Side)
03121 {
03122 MILLIPOINT RectSide = GetSideOfBoundingBox(Side);
03123 if (RectSide == 0)
03124 {
03125
03126 return 0;
03127 }
03128
03129 double Percent = (double)Distance / (double)RectSide;
03130 return Percent * 100;
03131 }
03132
03133 MILLIPOINT CBrushEditDlg::GetSideOfBoundingBox(RectSideInfo RectSide)
03134 {
03135 BrushDefinition* pBrushDef = BrushComponent::FindBrushDefinition(EditData->m_BrushHandle);
03136 if (pBrushDef == NULL)
03137 {
03138
03139 return 0;
03140 }
03141
03142 DocRect BRect = pBrushDef->GetLargestBoundingBox();
03143 if (BRect.IsEmpty())
03144 {
03145
03146 return 0;
03147 }
03148
03149 MILLIPOINT Side = 0;
03150 switch (RectSide)
03151 {
03152 case WIDTH:
03153 Side = BRect.Width();
03154 break;
03155 case HEIGHT:
03156 Side = BRect.Height();
03157 break;
03158 case LONGEST:
03159 Side = BRect.Width() > BRect.Height() ? BRect.Width() : BRect.Height();
03160 break;
03161 default:
03162 ERROR3("Invalid side info passed to CBrushEditDlg::GetSideOfBoundingBox");
03163 Side = BRect.Width();
03164 break;
03165 }
03166
03167 return Side;
03168 }
03169
03170 MILLIPOINT CBrushEditDlg::GetPercentageAsDistance(double Percent, RectSideInfo RectSide)
03171 {
03172 MILLIPOINT Side = GetSideOfBoundingBox(RectSide);
03173
03174 MILLIPOINT ReturnVal = (MILLIPOINT)(((double)Side) * (Percent / 100));
03175 return ReturnVal;
03176 }
03177
03178
03179
03180
03181 String_32 CBrushEditDlg::GetRandomRangeText(INT32 SliderVal)
03182 {
03183 String_32 RangeText(_T(" "));
03184 if (SliderVal < MIN_RANDOM_SLIDER || SliderVal > MAX_RANDOM_SLIDER)
03185 {
03186 ERROR3("Slider value is out of range in CBrushEditDlg::GetRandomRangeText");
03187 return RangeText;
03188 }
03189 UINT32 BaseVal = 100;
03190 UINT32 MinVal = 100 ;
03191 UINT32 MaxVal = 100 ;
03192
03193
03194 PathProcessorBrush::GetRandomLimits(BaseVal, SliderVal, &MinVal, &MaxVal);
03195
03196
03197 String_32 MinString;
03198 String_32 MaxString;
03199 String_32 MiddleString = _T(" - ");
03200 Convert::LongToString((INT32)MinVal, &MinString);
03201 Convert::LongToString((INT32)MaxVal, &MaxString);
03202
03203
03204 RangeText += MinString;
03205 RangeText += MiddleString;
03206 RangeText += MaxString;
03207
03208 return RangeText;
03209
03210 }
03211
03212
03213 String_32 CBrushEditDlg::GetRotationRandomText(INT32 SliderVal)
03214 {
03215 String_32 RangeText(_T(" "));
03216 if (SliderVal < MIN_RANDOM_SLIDER || SliderVal > MAX_RANDOM_SLIDER)
03217 {
03218 ERROR3("Slider value is out of range in CBrushEditDlg::GetRandomRangeText");
03219 return RangeText;
03220 }
03221 UINT32 BaseVal = 100;
03222 UINT32 MinVal = 100 ;
03223 UINT32 MaxVal = 100 ;
03224
03225
03226 PathProcessorBrush::GetRotationRandomLimits(BaseVal, SliderVal, &MinVal, &MaxVal);
03227
03228
03229
03230 String_32 MinString;
03231 String_32 MaxString;
03232 String_32 MiddleString = _T(" - ");
03233 Convert::LongToString((INT32)MinVal, &MinString);
03234 Convert::LongToString((INT32)MaxVal, &MaxString);
03235
03236
03237 RangeText += MinString;
03238 RangeText += MiddleString;
03239 RangeText += MaxString;
03240
03241 return RangeText;
03242 }
03243
03244
03245
03246 void CBrushEditDlg::SetRandomRangeText(CGadgetID SliderID)
03247 {
03248 BOOL Valid = FALSE;
03249 INT32 SliderVal = 0;
03250 if (SliderID == _R(IDC_SLIDERBRUSHSPACINGMAXRAND))
03251 {
03252 SliderVal = GetLongGadgetValue (_R(IDC_SLIDERBRUSHSPACINGMAXRAND), MIN_RANDOM_SLIDER, MAX_RANDOM_SLIDER, 0, &Valid);
03253 if (Valid)
03254 {
03255 SliderVal = (MAX_RANDOM_SLIDER - SliderVal) + MIN_RANDOM_SLIDER;
03256 String_32 RangeText = GetRandomRangeText(SliderVal);
03257 SetStringGadgetValue(_R(IDC_STATICBRUSHSPACINGRAND1), RangeText);
03258 }
03259 }
03260 else if (SliderID == _R(IDC_SLIDEROFFSETVALUEMAXRAND))
03261 {
03262 SliderVal = GetLongGadgetValue(_R(IDC_SLIDEROFFSETVALUEMAXRAND), MIN_RANDOM_SLIDER, MAX_RANDOM_SLIDER, 0, &Valid);
03263 if (Valid)
03264 {
03265 SliderVal = (MAX_RANDOM_SLIDER - SliderVal) + MIN_RANDOM_SLIDER;
03266 String_32 RangeText = TEXT("");
03267
03268 String_32 MinString = TEXT("0 - ");
03269 String_32 MaxString = TEXT("");;
03270 Convert::LongToString((INT32)SliderVal, &MaxString);
03271
03272 RangeText += MinString;
03273 RangeText += MaxString;
03274 SetStringGadgetValue(_R(IDC_STATICOFFSETRAND), RangeText);
03275 }
03276 }
03277 else if (SliderID == _R(IDC_SLIDERBRUSHSCALINGMAXRAND))
03278 {
03279 SliderVal = GetLongGadgetValue(_R(IDC_SLIDERBRUSHSCALINGMAXRAND), MinScalingSlider, MaxScalingSlider, 0, &Valid);
03280 if (Valid)
03281 {
03282 SliderVal = (MaxScalingSlider - SliderVal) + MinScalingSlider;
03283 String_32 RangeText = GetRandomRangeText(SliderVal);
03284 SetStringGadgetValue(_R(IDC_STATICSCALINGRAND), RangeText);
03285 }
03286 }
03287 else if (SliderID == _R(IDC_SLIDERROTATEANGLEMAXRAND))
03288 {
03289
03290
03291 SliderVal = GetLongGadgetValue(_R(IDC_SLIDERROTATEANGLEMAXRAND), MIN_RANDOM_SLIDER, MAX_ROTATION_RANDOM_SLIDER, 0, &Valid);
03292 if (Valid)
03293 {
03294 SliderVal = (MAX_ROTATION_RANDOM_SLIDER - SliderVal) + MIN_RANDOM_SLIDER;
03295
03296 double MaxAngle = double(SliderVal);
03297
03298
03299 String_32 RangeText(_T(""));
03300 String_32 MinString;
03301 String_32 MaxString;
03302 String_32 MiddleString = _T(" - ");
03303 Convert::LongToString(0, &MinString);
03304 Convert::LongToString(INT32(MaxAngle), &MaxString);
03305
03306 RangeText = MinString;
03307 RangeText += MiddleString;
03308 RangeText += MaxString;
03309
03310 SetStringGadgetValue(_R(IDC_STATICROTATIONRAND), RangeText);
03311 }
03312 }
03313 else if (SliderID == _R(IDC_SLIDERSCALINGPRESSURE))
03314 {
03315 SliderVal = GetLongGadgetValue(_R(IDC_SLIDERSCALINGPRESSURE), MIN_PRESSURE_SLIDER, MAX_PRESSURE_SLIDER, 0, &Valid);
03316 if (Valid)
03317 {
03318
03319
03320 String_32 MinString = TEXT("");
03321 Convert::LongToString((INT32)SliderVal, &MinString);
03322
03323
03324 String_32 MaxString = TEXT(" - 100");
03325
03326 MinString += MaxString;
03327 SetStringGadgetValue(_R(IDC_STATICSCALINGPRESS), MinString);
03328 }
03329 }
03330 else if (SliderID == _R(IDC_SLIDERSATURATIONRANDOM))
03331 {
03332
03333 SliderVal = GetLongGadgetValue(_R(IDC_SLIDERSATURATIONRANDOM), MIN_RANDOM_SLIDER, MAX_RANDOM_SAT_SLIDER, 0, &Valid);
03334 if (Valid)
03335 {
03336 SliderVal = MAX_RANDOM_SAT_SLIDER - SliderVal;
03337 String_32 RangeText(_T(""));
03338 String_32 MinString;
03339 String_32 MaxString;
03340 String_32 MiddleString = _T(" - ");
03341 Convert::LongToString(0, &MinString);
03342 Convert::LongToString(SliderVal, &MaxString);
03343
03344 RangeText = MinString;
03345 RangeText += MiddleString;
03346 RangeText += MaxString;
03347
03348 SetStringGadgetValue(_R(IDC_STATICSATRAND), RangeText);
03349 }
03350 }
03351 else if (SliderID == _R(IDC_SLIDERHUERANDOM))
03352 {
03353 SliderVal = GetLongGadgetValue(_R(IDC_SLIDERHUERANDOM), MIN_RANDOM_SLIDER, MAX_RANDOM_HUE_SLIDER, 0, &Valid);
03354 if (Valid)
03355 {
03356 SliderVal = MAX_RANDOM_HUE_SLIDER - SliderVal;
03357
03358
03359
03360
03361 String_32 MinString = TEXT("0 - ");
03362 String_32 MaxString = TEXT("");
03363 Convert::LongToString((INT32)SliderVal, &MaxString);
03364
03365 MinString += MaxString;
03366 SetStringGadgetValue(_R(IDC_STATICSCALINGPRESS), MinString);
03367
03368 }
03369 }
03370 else if (SliderID == _R(IDC_SLIDERTRANSPPRESSURE))
03371 {
03372 SliderVal = GetLongGadgetValue(_R(IDC_SLIDERTRANSPPRESSURE), MIN_RANDOM_SLIDER, MAX_RANDOM_SLIDER, 0, &Valid);
03373 if (Valid)
03374 {
03375 SliderVal = MAX_RANDOM_SLIDER - SliderVal;
03376 String_32 RangeText = GetRandomText(SliderVal, MAX_RANDOM_SLIDER);
03377 SetStringGadgetValue(_R(IDC_STATICTRANSPPRESSURE), RangeText);
03378 }
03379 }
03380 }
03381
03382 String_32 CBrushEditDlg::GetRandomText(INT32 Rand, INT32 MaxRand)
03383 {
03384 INT32 Base = 100;
03385 INT32 MinVal = Base;
03386 INT32 MaxVal = Base;
03387
03388 double RandomFactor = (double)Rand / 100;
03389 RandomFactor++;
03390
03391 if (RandomFactor != 0)
03392 {
03393 MinVal = (INT32)((double)Base / RandomFactor);
03394 MaxVal =(INT32)((double)Base * RandomFactor);
03395 }
03396
03397
03398 String_32 RangeText(_T(""));
03399
03400
03401 String_32 MinString;
03402 String_32 MaxString;
03403 String_32 MiddleString = _T(" - ");
03404 Convert::LongToString(MinVal, &MinString);
03405 Convert::LongToString(MaxVal, &MaxString);
03406
03407
03408 RangeText += MinString;
03409 RangeText += MiddleString;
03410 RangeText += MaxString;
03411
03412 return RangeText;
03413 }
03414
03415
03416
03417 void CBrushEditDlg::CreateNewBrush()
03418 {
03419
03420
03421 BrushHandle ThisHandle = EditData->m_BrushHandle;
03422
03423
03424 Document* pDoc = Document::GetCurrent();
03425 if (pDoc == NULL)
03426 {
03427 ERROR3("Document is NULL in CBrushEditDlg::BrushEditDlgOnOK");
03428 return;
03429 }
03430
03431 BrushComponent* pBrushComp = (BrushComponent*)pDoc->GetDocComponent(CC_RUNTIME_CLASS(BrushComponent));
03432 if (pBrushComp == NULL)
03433 {
03434 ERROR3("Brush component is null in CBrushEditDlg::BrushEditDlgOnOK");
03435 return;
03436 }
03437
03438 BrushDefinition* pBrushDef = pBrushComp->FindBrushDefinition(ThisHandle);
03439
03440 if (pBrushDef == NULL)
03441 {
03442 ERROR3("Brush definition is NULL in CBrushEditDlg::BrushEditDlgOnOK");
03443 return;
03444 }
03445
03446
03447 BrushDefinition* pNewBrushDef = pBrushDef->Copy();
03448
03449 if (pNewBrushDef == NULL)
03450 return;
03451
03452
03453 pNewBrushDef->SetMembersFromData(*EditData);
03454 pNewBrushDef->SetBrushScaling(1.0);
03455
03456 UINT32 LastBrush = pBrushComp->GetNumberOfBrushes() - 1;
03457
03458 BrushHandle NewHandle = pBrushComp->AddNewItem(pNewBrushDef, TRUE);
03459
03460
03461 if (NewHandle > LastBrush)
03462 BROADCAST_TO_ALL(NewBrushMsg());
03463 else
03464
03465 TRACEUSER( "Diccon", _T("Tried to make an identical brush\n"));
03466
03467 EditData->m_BrushHandle = NewHandle;
03468
03469
03470 }
03471