CBrushEditDlg Class Reference

#include <brushdlg.h>

Inheritance diagram for CBrushEditDlg:

DialogTabOp DialogOp Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 CBrushEditDlg ()
 Default constructor for CBrushEditDlg.
 ~CBrushEditDlg ()
 Destructor.
void Do (OpDescriptor *)
 launches the brush edit dialog, this method will determine which brush it is editing from the document selection.
void DoWithParam (OpDescriptor *, OpParam *OwningGadgetParams)
 launches the brush edit dialog, however this the BrushData to initialise the dialog is provided through the opparam. Note: I don't think that we use this method anymore.
virtual MsgResult Message (Msg *)
 Message proc for this dialog.
void CreateNewBrush ()
void HandleBrushEditSpacingMsg (DialogMsg *Msg)
 Subhandler for messages from the spacing tab, except for the edit box and sliders, which have their own handlers.
void HandleBrushEditOffsetMsg (DialogMsg *Msg)
 Subhandler for messages from the offset tab, except for the edit box and sliders, which have their own handlers.
void HandleBrushEditScalingMsg (DialogMsg *Msg)
 Subhandler for messages from the scaling tab, except for the edit box and sliders, which have their own handlers.
void HandleBrushEditEffectMsg (DialogMsg *Msg)
 Subhandler for messages from the rotation tab, except for the edit box and sliders, which have their own handlers.
void HandleBrushEditSequenceMsg (DialogMsg *Msg)
 Subhandler for messages from the transparency tab, except for the edit box and sliders, which have their own handlers.
void HandleBrushFillMsg (DialogMsg *Msg)
 Subhandler for messages from the fill tab, except for the edit box and sliders, which have their own handlers.
void InvokeVia (CBrushGadget &pInvokeWith, BrushData *pInvokeOn, AttrBrushType *pBrush, BOOL &bMany)
 I'm not entirely sure what this does, perhaps Chris will be able to elaborate, I think they were once used as part of launching the dialog, but I think they are no longer used.
void InvokeVia (CBrushGadget &pInvokeWith, BrushData *pInvokeOn, AttrBrushType *pBrush, AttrBrushType *pOrigBrush, BOOL &bMany)
void InvokeVia (CBrushGadget &pInvokeWith, BrushHandle Handle)
virtual BOOL RegisterYourPagesInOrderPlease ()
 This virtual function will get called to give you a chance to add pages to your DialogTabOp. This function will usually make multiple calls to AddAPage to register the initial set of pages to be contained in the tab dialog. The pages should all be the same size and be registered in the left to right order in which you wish them to appear.
void ReInitialiseDialog (BrushData *pData)
void SetDialogTitle (String_256 Title)

Static Public Member Functions

static BOOL Init ()
 the init function to register us as an Op
static OpState GetState (String_256 *, OpDescriptor *)
 Determines whether or not we can launch this op. We are allowed to launch in the following circumstances:
  • Any tool, one AttrBrushType in the selection
  • FreeHandTool, as above OR brush selected in the brush combo and no document selection.

static AttrBrushTypeGetSingleSelectedBrushAttribute ()

Static Public Attributes

static const UINT32 IDD = _R(IDD_BRUSHEDIT)
static const CDlgMode Mode = MODELESS

Private Member Functions

void HideShuffleIrrelevantButtons ()
 Because CPropertySheets only let you have an OK, Apply,Cancel, and Help button, we must rename these for our own devious ends and swap their positions.
void InitBrushSpacing (BOOL OnlyForUnitChange=FALSE)
void InitBrushOffset (BOOL OnlyForUnitChange=FALSE)
void InitBrushScaling (BOOL OnlyForUnitChange=FALSE)
void InitBrushEffects (BOOL OnlyForUnitChange=FALSE)
void InitBrushSequence (BOOL OnlyForUnitChange=FALSE)
void InitBrushFill (BOOL OnlyForUnitChange=FALSE)
void ReInitBrushSpacing ()
void ReInitBrushOffset ()
void ReInitBrushScaling ()
void ReInitBrushEffects ()
void ReInitBrushSequence ()
void ReInitBrushFill ()
void ReInitUnitDependantFields (CDlgResID ThePage)
void InitComboPathOffsetType ()
void InitSequenceType ()
void HandleCommit (DialogMsg *Msg)
void HandleSelectionChange (DialogMsg *Msg)
void HandleButtonDown (DialogMsg *Msg)
void HandleSliderPosChanging (DialogMsg *Msg)
void HandleSliderPosSet (DialogMsg *Msg)
void ReadButtons (DialogMsg *Msg)
void ReadRadios (DialogMsg *Msg)
void ReadEditBox (DialogMsg *Msg)
void ReadComboBox (DialogMsg *Msg)
void ReadCheckBox (DialogMsg *Msg)
void ReadSlider (DialogMsg *Msg)
void WriteSliders (DialogMsg *Msg)
void UpdateEditBox (CGadgetID GadgetToUpdate)
void LaunchOp ()
UINT32 GetNewRandomNumber (UINT32 OldNumber)
void ReInitPage (CDlgResID PageID)
BOOL GetAttributeNodeFromDefinition ()
void HandleDocSelectionChange ()
void RefreshActivePage ()
void GetSpacingRange (double *, double *)
void SetSpacingSlider ()
void SetSpacingIncrSlider ()
void SetOffsetValSlider ()
void GetOffsetRange (double *, double *)
MILLIPOINT GetSideOfBoundingBox (RectSideInfo RectInfo)
double GetDistanceAsPercentageOfBBox (MILLIPOINT Distance, RectSideInfo RectInfo)
MILLIPOINT GetPercentageAsDistance (double Percent, RectSideInfo RectInfo)
void ChangeButtonText ()
 Because CPropertySheets only let you have an OK, Apply,Cancel, and Help button, we must rename these for our own devious ends.
void SetRandomRangeText (CGadgetID SliderID)
String_32 GetRandomRangeText (INT32 SliderVal)
String_32 GetRotationRandomText (INT32 SliderVal)
String_32 GetRandomText (INT32 Value, INT32 MaxValue)
virtual BOOL AddControlsToHelper ()
 We need to subclass our edit box controls so we're adding them to the helper here.
virtual void RemoveControlsFromHelper ()
 removing the edit controls from the helper

Private Attributes

CBrushGadgetm_pOwningGadget
CGadgetID Id_m
BrushDataOriginalData
BrushDataEditData
BrushData m_LastData
BrushHandle m_Handle
AttrBrushTypepAttrBrush_m
AttrBrushTypepOrigAttrBrush_m
ChangeBrushType ChangeType_m
ChangeBrushOpParam ChangeParam_m
BOOL FirstTime
BOOL EditingBrushDef
BOOL m_bDisableOps
RenderPreviewType RenderType
DocUnitListpDocUnitList
UnitType CurrentUserUnitType
BOOL m_bDisableGadgets
BOOL m_bPreventUpdateSet
BOOL m_SliderStarted
BOOL UsingRandomSpacing
BOOL UsingRandomOffset
BOOL UsingRandomScaling
CGadgetID EditGadgetLostFocus

Static Private Attributes

static BOOL m_bIsOpen = FALSE

Detailed Description

Definition at line 112 of file brushdlg.h.


Constructor & Destructor Documentation

CBrushEditDlg::CBrushEditDlg  ) 
 

Default constructor for CBrushEditDlg.

Author:
This comment by Diccon (function originally by ChrisS)
Date:
Comment added 15/12/2000
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 220 of file brushdlg.cpp.

00221     : DialogTabOp/*DialogOp*/( 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 }

CBrushEditDlg::~CBrushEditDlg  ) 
 

Destructor.

Author:
This comment by Diccon (function originally by ChrisS)
Date:
Comment added 15/12/2000
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 260 of file brushdlg.cpp.

00261 {
00262     if (OriginalData != NULL)
00263         delete (OriginalData);
00264     if (EditData != NULL)
00265         delete (EditData);
00266 }


Member Function Documentation

BOOL CBrushEditDlg::AddControlsToHelper  )  [private, virtual]
 

We need to subclass our edit box controls so we're adding them to the helper here.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/7/2000
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if all went well, FALSE if something went wrong

Errors: -

See also:
DialogControlHelper class (DlgCtHlp.h/.cpp)

Reimplemented from DialogOp.

Definition at line 557 of file brushdlg.cpp.

00558 {
00559     // basically we just add 'em in one by one
00560     BOOL ok = AddDialogControlToHelper(_R(IDC_EDITBRUSHSPACING), _R(IDD_BRUSHEDITSPACING));
00561 //  if (ok) ok = AddDialogControlToHelper(_R(IDC_EDITBRUSHSPACINGINCRCONST), _R(IDD_BRUSHEDITSPACING));
00562     if (ok) ok = AddDialogControlToHelper(_R(IDC_EDITPATHOFFSETVALUE), _R(IDD_BRUSHEDITOFFSET));
00563 //  if (ok) ok = AddDialogControlToHelper(_R(IDC_EDITPATHOFFSETINCRCONST), _R(IDD_BRUSHEDITOFFSET));
00564 //  if (ok) ok = AddDialogControlToHelper(_R(IDC_EDITSCALINGINCRCONST), _R(IDD_BRUSHEDITSCALING));
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 }

void CBrushEditDlg::ChangeButtonText  )  [private]
 

Because CPropertySheets only let you have an OK, Apply,Cancel, and Help button, we must rename these for our own devious ends.

Author:
This comment by Diccon (function originally by ChrisS)
Date:
Comment added 15/12/2000
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 1276 of file brushdlg.cpp.

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 }

void CBrushEditDlg::CreateNewBrush  ) 
 

Definition at line 3417 of file brushdlg.cpp.

03418 {
03419     // as we are basically making a copy of an existing definition we can use the nodetree
03420     // of the existing definition, so we need to obtain a pointer to it.
03421     BrushHandle ThisHandle = EditData->m_BrushHandle;
03422 
03423     // get the brush component from the document
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     // ask the definition to copy itself
03447     BrushDefinition* pNewBrushDef = pBrushDef->Copy();
03448 
03449     if (pNewBrushDef == NULL)
03450         return;
03451 
03452     // copy our brush data to the definition
03453     pNewBrushDef->SetMembersFromData(*EditData);
03454     pNewBrushDef->SetBrushScaling(1.0);
03455     // find out how many brushes there are
03456     UINT32 LastBrush = pBrushComp->GetNumberOfBrushes() - 1;
03457 
03458     BrushHandle NewHandle = pBrushComp->AddNewItem(pNewBrushDef, TRUE);
03459 
03460     // tell the world who we are
03461     if (NewHandle > LastBrush)
03462         BROADCAST_TO_ALL(NewBrushMsg());
03463     else
03464         //ERROR3("Tried to make an identical brush");
03465         TRACEUSER( "Diccon", _T("Tried to make an identical brush\n"));
03466 
03467     EditData->m_BrushHandle = NewHandle;
03468 
03469 
03470 }

void CBrushEditDlg::Do OpDescriptor  )  [virtual]
 

launches the brush edit dialog, this method will determine which brush it is editing from the document selection.

Author:
This comment by Diccon (function originally by ChrisS)
Date:
Comment added 15/12/2000
Parameters:
not used [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from Operation.

Definition at line 376 of file brushdlg.cpp.

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     // this fn. is called from the ViewContextMenu without any params so here we must initialise it ourselves
00390     //m_pOwningGadget = FreeHandInfoBarOp::GetSpareGadget();
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     // we want to see if there is a brush in the selection, in which case grab its data so we
00403     // can initialise everything ok.   Otherwise keep everything disabled
00404     AttrBrushType* pAttrBrush = GetSingleSelectedBrushAttribute();
00405     if (pAttrBrush != NULL)
00406     {
00407         *EditData = pAttrBrush->GetBrushData();
00408         *OriginalData = *EditData;
00409         m_bDisableGadgets = FALSE;
00410         //initialise our opparam with the original data, just in case we want to do change all
00411         ChangeParam_m.SetValues(*EditData);
00412         String_256 Name = EditData->m_Name;
00413         SetName(&Name);
00414     }
00415     else
00416     {
00417         // If we are in the freehand tool then we can launch so long as the tool selected brush is not default
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                     // the definition allocates a new data object for us
00428                     delete EditData;
00429                     EditData = pDef->GetBrushData();
00430                     EditData->m_BrushHandle = Handle;
00431                     *OriginalData = *EditData;
00432                     m_bDisableGadgets = FALSE;
00433                     //initialise our opparam with the original data, just in case we want to do change all
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 }

void CBrushEditDlg::DoWithParam OpDescriptor ,
OpParam OwningGadgetParams
[virtual]
 

launches the brush edit dialog, however this the BrushData to initialise the dialog is provided through the opparam. Note: I don't think that we use this method anymore.

Author:
This comment by Diccon (function originally by ChrisS)
Date:
Comment added 15/12/2000
Parameters:
OwningGadgetParams - recast to get a BrushData object [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from Operation.

Definition at line 468 of file brushdlg.cpp.

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     // if theres already one open the don't
00477     if (WindowID != NULL && IsOpen() && IsWindowVisible())
00478         return;
00479 
00480     EditData = new BrushData (*(reinterpret_cast<BrushData*> ((void*)(OwningGadgetParams->Param2))));
00481     // if we're editing the definition then we had to create a brush data from scratch so delete 
00482     // it here
00483     if (EditingBrushDef)
00484     {
00485         BrushData* DeleteData = ((reinterpret_cast<BrushData*> ((void *)(OwningGadgetParams->Param2))));
00486         delete DeleteData;
00487     }
00488     //EditData = reinterpret_cast<BrushData*> (OwningGadgetParams->Param2);
00489     OriginalData = new BrushData (*EditData);
00490 
00491     //initialise our opparam with the original data, just in case we want to do change all
00492     ChangeParam_m.SetValues(*EditData);
00493 
00494     m_bDisableGadgets = FALSE;
00495 
00496 PORTNOTE("other", "Disabled CBrushGadget")
00497 #ifndef EXCLUDE_FROM_XARALX
00498     // get the ID
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     // tell the owning gadget that this dialog has opened
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 }

BOOL CBrushEditDlg::GetAttributeNodeFromDefinition  )  [private]
 

Definition at line 1939 of file brushdlg.cpp.

01940 {
01941     // just a quick check to see if we're in the right place
01942     if (!EditingBrushDef)
01943         return FALSE;
01944 
01945     // we need to get hold of the brush component from the document
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     // wipe our existing attribute
01958     if (pAttrBrush_m != NULL)
01959     {
01960         delete pAttrBrush_m;
01961         pAttrBrush_m = NULL;
01962     }
01963 
01964     // ask the component for a new one
01965     pAttrBrush_m = pBrushComp->CreateAttributeNode(m_Handle);
01966 
01967     // did we get it?
01968     if (pAttrBrush_m == NULL)
01969         return FALSE;
01970 
01971     return TRUE;
01972 }

double CBrushEditDlg::GetDistanceAsPercentageOfBBox MILLIPOINT  Distance,
RectSideInfo  RectInfo
[private]
 

Definition at line 3120 of file brushdlg.cpp.

03121 {
03122     MILLIPOINT RectSide = GetSideOfBoundingBox(Side);
03123     if (RectSide == 0)
03124     {
03125 //      ERROR3("Bounding rect is empty in CBrushEditDlg::GetSpacingRange");
03126         return 0;
03127     }
03128 
03129     double Percent = (double)Distance / (double)RectSide;
03130     return Percent * 100;
03131 }

UINT32 CBrushEditDlg::GetNewRandomNumber UINT32  OldNumber  )  [private]
 

Definition at line 1975 of file brushdlg.cpp.

01976 {
01977    // seed the random number generator
01978    srand( (unsigned)time( NULL ) );
01979     
01980    UINT32 Rand = (UINT32)rand();
01981    // make sure its not the same (unlikely)
01982    while (Rand == OldNumber)
01983        Rand = (UINT32)rand();
01984     
01985    return Rand;
01986 }

void CBrushEditDlg::GetOffsetRange double *  ,
double * 
[private]
 

Definition at line 3092 of file brushdlg.cpp.

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     //  ERROR3("Bounding rect is empty in CBrushEditDlg::GetSpacingRange");
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 }

MILLIPOINT CBrushEditDlg::GetPercentageAsDistance double  Percent,
RectSideInfo  RectInfo
[private]
 

Definition at line 3170 of file brushdlg.cpp.

03171 {
03172     MILLIPOINT Side = GetSideOfBoundingBox(RectSide);
03173 
03174     MILLIPOINT ReturnVal = (MILLIPOINT)(((double)Side) * (Percent / 100));
03175     return ReturnVal;
03176 }

String_32 CBrushEditDlg::GetRandomRangeText INT32  SliderVal  )  [private]
 

Definition at line 3181 of file brushdlg.cpp.

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     // the actual limits are worked out in the PPB static function
03194     PathProcessorBrush::GetRandomLimits(BaseVal, SliderVal, &MinVal, &MaxVal);
03195 
03196     // annoyingly we now need to recast our values as long
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 }

String_32 CBrushEditDlg::GetRandomText INT32  Value,
INT32  MaxValue
[private]
 

Definition at line 3382 of file brushdlg.cpp.

03383 {
03384     INT32 Base = 100;
03385     INT32 MinVal = Base;
03386     INT32 MaxVal = Base;
03387 
03388     double RandomFactor = (double)Rand / 100;
03389     RandomFactor++; // = (RandomFactor * MaxRand);
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     // annoyingly we now need to recast our values as long
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 }

String_32 CBrushEditDlg::GetRotationRandomText INT32  SliderVal  )  [private]
 

Definition at line 3213 of file brushdlg.cpp.

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     // the actual limits are worked out in the PPB static function
03226     PathProcessorBrush::GetRotationRandomLimits(BaseVal, SliderVal, &MinVal, &MaxVal);
03227 
03228     //double MinValDegrees = 
03229     // annoyingly we now need to recast our values as long
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 }

MILLIPOINT CBrushEditDlg::GetSideOfBoundingBox RectSideInfo  RectInfo  )  [private]
 

Definition at line 3133 of file brushdlg.cpp.

03134 {
03135     BrushDefinition* pBrushDef = BrushComponent::FindBrushDefinition(EditData->m_BrushHandle);
03136     if (pBrushDef == NULL)
03137     {
03138     //  ERROR3("No brush definition in CBrushEditDlg::GetLongestSideOfBoundingBox");
03139         return 0;
03140     }
03141     
03142     DocRect BRect = pBrushDef->GetLargestBoundingBox();
03143     if (BRect.IsEmpty())
03144     {
03145         //ERROR3("Bounding rect is empty in CBrushEditDlg::GetSpacingRange");
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 }

AttrBrushType * CBrushEditDlg::GetSingleSelectedBrushAttribute  )  [static]
 

Definition at line 2903 of file brushdlg.cpp.

02904 {
02905     AttrBrushType* pAttrBrush = NULL;
02906     List NodeList;
02907     BevelTools::BuildListOfSelectedNodes(&NodeList, CC_RUNTIME_CLASS(AttrBrushType));
02908     BrushData Data; // initialises to default values
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 }

void CBrushEditDlg::GetSpacingRange double *  ,
double * 
[private]
 

Definition at line 3064 of file brushdlg.cpp.

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 }

OpState CBrushEditDlg::GetState String_256 pHelpString,
OpDescriptor
[static]
 

Determines whether or not we can launch this op. We are allowed to launch in the following circumstances:

  • Any tool, one AttrBrushType in the selection
  • FreeHandTool, as above OR brush selected in the brush combo and no document selection.

Author:
This comment by Diccon (function originally by ChrisS)
Date:
Comment added 15/12/2000
Parameters:
not used [INPUTS]
- [OUTPUTS]
Returns:
the OpState indicating whether or not this op is greyed
Note also that we can only ever have one instance of the dialog open at once
Returns:
Errors: -
See also:
-

Definition at line 332 of file brushdlg.cpp.

00333 {
00334     static OpState DialogState;
00335     
00336     DialogState.Greyed = TRUE;
00337 
00338     // if we have a single brush in the selection then we're ok
00339     AttrBrushType* pAttrBrush = GetSingleSelectedBrushAttribute();
00340     
00341     if (pAttrBrush != NULL && pAttrBrush->GetBrushHandle() != BrushHandle_NoBrush)
00342         DialogState.Greyed = FALSE;
00343 
00344     // if we're in the freehand tool and we our current brush is not default then we're also ok
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     // we only ever want one instance of the dialog so check our static member
00353     if (m_bIsOpen)
00354         DialogState.Greyed = TRUE;
00355 
00356     return (DialogState);
00357 }

void CBrushEditDlg::HandleBrushEditEffectMsg DialogMsg Msg  ) 
 

Subhandler for messages from the rotation tab, except for the edit box and sliders, which have their own handlers.

Author:
This comment by Diccon (function originally by ChrisS)
Date:
Comment added 15/12/2000
Parameters:
Msg - the message to handle [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 1003 of file brushdlg.cpp.

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 }

void CBrushEditDlg::HandleBrushEditOffsetMsg DialogMsg Msg  ) 
 

Subhandler for messages from the offset tab, except for the edit box and sliders, which have their own handlers.

Author:
This comment by Diccon (function originally by ChrisS)
Date:
Comment added 15/12/2000
Parameters:
Msg - the message to handle [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 924 of file brushdlg.cpp.

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 }

void CBrushEditDlg::HandleBrushEditScalingMsg DialogMsg Msg  ) 
 

Subhandler for messages from the scaling tab, except for the edit box and sliders, which have their own handlers.

Author:
This comment by Diccon (function originally by ChrisS)
Date:
Comment added 15/12/2000
Parameters:
Msg - the message to handle [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 963 of file brushdlg.cpp.

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 }

void CBrushEditDlg::HandleBrushEditSequenceMsg DialogMsg Msg  ) 
 

Subhandler for messages from the transparency tab, except for the edit box and sliders, which have their own handlers.

Author:
This comment by Diccon (function originally by ChrisS)
Date:
Comment added 15/12/2000
Parameters:
Msg - the message to handle [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 1043 of file brushdlg.cpp.

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 }

void CBrushEditDlg::HandleBrushEditSpacingMsg DialogMsg Msg  ) 
 

Subhandler for messages from the spacing tab, except for the edit box and sliders, which have their own handlers.

Author:
This comment by Diccon (function originally by ChrisS)
Date:
Comment added 15/12/2000
Parameters:
Msg