DashPatternAttribute Class Reference

Attribute for dash pattern style of paths. More...

#include <attrval.h>

Inheritance diagram for DashPatternAttribute:

AttributeValue CCObject SimpleCCObject List of all members.

Public Member Functions

 DashPatternAttribute ()
 Default Constructor for dash pattern attribute.
 ~DashPatternAttribute ()
 Destructor for dash pattern attribute.
BOOL SetDashPattern (DashRec &NewDash)
 Sets the dash pattern for this attribute.
BOOL SetStockDashPattern (StockDash NewDash)
 Sets the dash pattern for this attribute.
BOOL SetDeviceDashPattern (DashRec &NewDash, INT32 PixelSize)
 Checks a dash pattern to see if it is one of the built in ones and if so then sets the ID to be correct. Not the best way but a) its quick, b) it works, c) not three million big rebuilds of 330 files to get it rightSets the dash pattern for this attribute.
BOOL SetDeviceStockDashPattern (StockDash NewDash, INT32 PixelSize)
 Sets the dash pattern for this attribute.
INT32 operator== (DashPatternAttribute &)
virtual void Restore (RenderRegion *, BOOL)
 Restores the dash pattern attribute for the given render region. i.e. all lines drawn will now be drawn with this dash pattern.
virtual void Render (RenderRegion *, BOOL Temp=FALSE)
 Sets the dash pattern attribute for the given render region. i.e. all lines drawn will now be drawn with this dash pattern.
virtual void SimpleCopy (AttributeValue *)
virtual NodeAttributeMakeNode ()
 Makes the appropriate NodeAttribute-derivative from an dash-pattern attribute.
BOOL IsDifferent (AttributeValue *pAttr)
 Compare two AttributeValue objects. The base class version always returns TRUE - derived classes should override this function to provide functionality.

Static Public Member Functions

static BOOL Init ()
 Registers line width attribute, and provides a default attribute to give non-dotted lines.

Public Attributes

DashRec DashPattern

Detailed Description

Attribute for dash pattern style of paths.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/01/94
See also:
FillColourAttribute; StrokeColourAttribute; LineWidthAttribute; StartArrowAttribute; EndArrowAttribute; StartCapAttribute; EndCapAttribute; JoinTypeAttribute; MitreLimitAttribute; WindingRuleAttribute

Definition at line 422 of file attrval.h.


Constructor & Destructor Documentation

DashPatternAttribute::DashPatternAttribute  ) 
 

Default Constructor for dash pattern attribute.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/10/94
Returns:
Errors: -
See also:
-

Definition at line 647 of file attr.cpp.

00648 {
00649     DashPattern.Elements = 0;
00650     DashPattern.DashStart = 0;
00651 
00652     DashPattern.ElementData = NULL;
00653 
00654     DashPattern.LineWidth = 72000/4;
00655 }

DashPatternAttribute::~DashPatternAttribute  ) 
 

Destructor for dash pattern attribute.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/10/94
See also:
-

Definition at line 668 of file attr.cpp.

00669 {
00670     if (DashPattern.ElementData)
00671         delete DashPattern.ElementData;
00672 }


Member Function Documentation

BOOL DashPatternAttribute::Init void   )  [static]
 

Registers line width attribute, and provides a default attribute to give non-dotted lines.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/10/94
Returns:
TRUE - initialised ok; FALSE if not.

Errors: Out of memory.

See also:
AttributeManager

Reimplemented from SimpleCCObject.

Definition at line 1541 of file attr.cpp.

01542 {
01543     // Default to non-dotted lines
01544     DashPatternAttribute *pAttr = new DashPatternAttribute;
01545     if (pAttr == NULL)
01546         return FALSE;
01547 
01548     UINT32 ID = AttributeManager::RegisterDefaultAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), 
01549                                                          pAttr);
01550     if (ID == ATTR_BAD_ID)
01551         return FALSE;
01552     ENSURE(ID == ATTR_DASHPATTERN, "Incorrect ID for dash pattern attribute!");
01553     return TRUE;
01554 }

BOOL DashPatternAttribute::IsDifferent AttributeValue pAttr  )  [virtual]
 

Compare two AttributeValue objects. The base class version always returns TRUE - derived classes should override this function to provide functionality.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/04/94
Parameters:
pAttr - the attribute to compare against this one. [INPUTS]
Returns:
TRUE if objects represent different attributes (e.g. one is red and the other is blue); FALSE otherwise (i.e. they represent the same attribute, e.g. both represent 0.25pt lines).
See also:
AttributeManager::ApplyBasedOnDefaults

Reimplemented from AttributeValue.

Definition at line 1561 of file attr.cpp.

01562 {
01563     ENSURE(GetRuntimeClass() == pAttr->GetRuntimeClass(), 
01564            "Different attribute types in AttributeValue::IsDifferent()");
01565     return !(((DashPatternAttribute *) pAttr)->DashPattern == DashPattern);
01566 }

NodeAttribute * DashPatternAttribute::MakeNode  )  [virtual]
 

Makes the appropriate NodeAttribute-derivative from an dash-pattern attribute.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/7/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
A pointer to a NodeAttribute.

Errors: -

See also:
AttributeValue::MakeNode

Reimplemented from AttributeValue.

Definition at line 1520 of file attr.cpp.

01521 {
01522     AttrDashPattern* pAttr = new AttrDashPattern;
01523     pAttr->Value.SimpleCopy(this);
01524     return pAttr;
01525 }

INT32 DashPatternAttribute::operator== DashPatternAttribute  ) 
 

void DashPatternAttribute::Render RenderRegion pRegion,
BOOL  Temp = FALSE
[virtual]
 

Sets the dash pattern attribute for the given render region. i.e. all lines drawn will now be drawn with this dash pattern.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/10/94
Parameters:
pRegion - the render region to render this attribute into. [INPUTS]
See also:
-

Implements AttributeValue.

Definition at line 687 of file attr.cpp.

00688 {
00689     pRegion->SetDashPattern(this, Temp);
00690 }

void DashPatternAttribute::Restore RenderRegion pRegion,
BOOL  Temp
[virtual]
 

Restores the dash pattern attribute for the given render region. i.e. all lines drawn will now be drawn with this dash pattern.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/10/94
Parameters:
pRegion - the render region to restore the attribute into. [INPUTS] Temp - TRUE if this is a temporary attribute, FALSE if it is permanent (e.g. it's in a document tree).
See also:
-

Implements AttributeValue.

Definition at line 707 of file attr.cpp.

00708 {
00709     pRegion->RestoreDashPattern(this, Temp);
00710 }

BOOL DashPatternAttribute::SetDashPattern DashRec NewDash  ) 
 

Sets the dash pattern for this attribute.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/10/94
Returns:
Errors: No memory.
See also:
-

Definition at line 724 of file attr.cpp.

00725 {
00726     DashPattern.Elements            = NewDash.Elements;
00727     DashPattern.DashStart           = NewDash.DashStart;
00728     DashPattern.LineWidth           = NewDash.LineWidth;
00729     DashPattern.DashID              = NewDash.DashID;
00730     DashPattern.ScaleWithLineWidth  = NewDash.ScaleWithLineWidth;
00731 
00732     if (NewDash.Elements == 0)
00733         return TRUE;
00734 
00735     if (DashPattern.ElementData != NULL)
00736         delete DashPattern.ElementData;
00737 
00738     DashPattern.ElementData = new INT32[NewDash.Elements];
00739 
00740     if (DashPattern.ElementData == NULL)
00741         return FALSE;
00742 
00743     for (INT32 element = 0; element < NewDash.Elements; element++)
00744     {
00745         DashPattern.ElementData[element] = NewDash.ElementData[element];
00746     }
00747 
00748     return TRUE;
00749 }

BOOL DashPatternAttribute::SetDeviceDashPattern DashRec NewDash,
INT32  PixelSize
 

Checks a dash pattern to see if it is one of the built in ones and if so then sets the ID to be correct. Not the best way but a) its quick, b) it works, c) not three million big rebuilds of 330 files to get it rightSets the dash pattern for this attribute.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/10/94
Returns:
Errors: No memory.
See also:
-

Definition at line 1349 of file attr.cpp.

01350 {
01351     SetDashPattern(NewDash);
01352 
01353     if (DashPattern.Elements == 0)
01354         return TRUE;
01355 
01356     DashPattern.DashStart *= PixelSize;
01357 
01358     for (INT32 element = 0; element < DashPattern.Elements; element++)
01359     {
01360         DashPattern.ElementData[element] *= PixelSize;
01361     }
01362 
01363     return TRUE;
01364 }

BOOL DashPatternAttribute::SetDeviceStockDashPattern StockDash  NewDash,
INT32  PixelSize
 

Sets the dash pattern for this attribute.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/10/94
Returns:
Errors: No memory.
See also:
-

Definition at line 1378 of file attr.cpp.

01379 {
01380     SetStockDashPattern(NewDash);
01381 
01382     if (DashPattern.Elements == 0)
01383         return TRUE;
01384 
01385     const INT32 DashUnit = DashPattern.LineWidth;
01386 
01387     DashPattern.DashStart = (DashPattern.DashStart/DashUnit) * (PixelSize);
01388 
01389     for (INT32 element = 0; element < DashPattern.Elements; element++)
01390     {
01391         DashPattern.ElementData[element] = (DashPattern.ElementData[element]/DashUnit) * (PixelSize);
01392     }
01393 
01394     return TRUE;
01395 }

BOOL DashPatternAttribute::SetStockDashPattern StockDash  NewDash  ) 
 

Sets the dash pattern for this attribute.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/10/94
Returns:
Errors: No memory.
See also:
-

Definition at line 763 of file attr.cpp.

00764 {
00765     DashRec StockDash;
00766     DashElement DashArray[8];
00767 
00768     const INT32 DashUnit = StockDash.LineWidth;
00769 
00770     StockDash.DashID = NewDash;
00771 
00772     switch (NewDash)
00773     {
00774         case SD_SOLID:
00775             StockDash.Elements = 0;
00776             SetDashPattern(StockDash);
00777             break;
00778 
00779         case SD_DASH1:
00780             StockDash.Elements = 2;
00781             StockDash.DashStart = 0;
00782             StockDash.ElementData = DashArray;
00783             DashArray[0] = DashUnit*2;
00784             DashArray[1] = DashUnit*2;
00785 
00786             SetDashPattern(StockDash);
00787             break;
00788 
00789         case SD_DASH2:
00790             StockDash.Elements = 2;
00791             StockDash.DashStart = 0;
00792             StockDash.ElementData = DashArray;
00793             DashArray[0] = DashUnit*4;
00794             DashArray[1] = DashUnit*2;
00795 
00796             SetDashPattern(StockDash);
00797             break;
00798 
00799         case SD_DASH3:
00800             StockDash.Elements = 2;
00801             StockDash.DashStart = 0;
00802             StockDash.ElementData = DashArray;
00803             DashArray[0] = DashUnit*8;
00804             DashArray[1] = DashUnit*2;
00805 
00806             SetDashPattern(StockDash);
00807             break;
00808 
00809         case SD_DASH4:
00810             StockDash.Elements = 2;
00811             StockDash.DashStart = 0;
00812             StockDash.ElementData = DashArray;
00813             DashArray[0] = DashUnit*16;
00814             DashArray[1] = DashUnit*2;
00815 
00816             SetDashPattern(StockDash);
00817             break;
00818 
00819         case SD_DASH5:
00820             StockDash.Elements = 2;
00821             StockDash.DashStart = 0;
00822             StockDash.ElementData = DashArray;
00823             DashArray[0] = DashUnit*24;
00824             DashArray[1] = DashUnit*2;
00825 
00826             SetDashPattern(StockDash);
00827             break;
00828 
00829         case SD_DASH6:
00830             StockDash.Elements = 2;
00831             StockDash.DashStart = 0;
00832             StockDash.ElementData = DashArray;
00833             DashArray[0] = DashUnit*4;
00834             DashArray[1] = DashUnit*4;
00835 
00836             SetDashPattern(StockDash);
00837             break;
00838 
00839         case SD_DASH7:
00840             StockDash.Elements = 2;
00841             StockDash.DashStart = 0;
00842             StockDash.ElementData = DashArray;
00843             DashArray[0] = DashUnit*8;
00844             DashArray[1] = DashUnit*4;
00845 
00846             SetDashPattern(StockDash);
00847             break;
00848 
00849         case SD_DASH8:
00850             StockDash.Elements = 2;
00851             StockDash.DashStart = 0;
00852             StockDash.ElementData = DashArray;
00853             DashArray[0] = DashUnit*16;
00854             DashArray[1] = DashUnit*4;
00855 
00856             SetDashPattern(StockDash);
00857             break;
00858 
00859         case SD_DASH9:
00860             StockDash.Elements = 2;
00861             StockDash.DashStart = 0;
00862             StockDash.ElementData = DashArray;
00863             DashArray[0] = DashUnit*8;
00864             DashArray[1] = DashUnit*8;
00865 
00866             SetDashPattern(StockDash);
00867             break;
00868 
00869         case SD_DASH10:
00870             StockDash.Elements = 2;
00871             StockDash.DashStart = 0;
00872             StockDash.ElementData = DashArray;
00873             DashArray[0] = DashUnit*16;
00874             DashArray[1] = DashUnit*8;
00875 
00876             SetDashPattern(StockDash);
00877             break;
00878 
00879         case SD_DASH11:
00880             StockDash.Elements = 4;
00881             StockDash.DashStart = 0;
00882             StockDash.ElementData = DashArray;
00883             DashArray[0] = DashUnit*4;
00884             DashArray[1] = DashUnit*2;
00885             DashArray[2] = DashUnit*2;
00886             DashArray[3] = DashUnit*2;
00887 
00888             SetDashPattern(StockDash);
00889             break;
00890 
00891         case SD_DASH12:
00892             StockDash.Elements = 4;
00893             StockDash.DashStart = 0;
00894             StockDash.ElementData = DashArray;
00895             DashArray[0] = DashUnit*8;
00896             DashArray[1] = DashUnit*2;
00897             DashArray[2] = DashUnit*2;
00898             DashArray[3] = DashUnit*2;
00899 
00900             SetDashPattern(StockDash);
00901             break;
00902 
00903         case SD_DASH13:
00904             StockDash.Elements = 4;
00905             StockDash.DashStart = 0;
00906             StockDash.ElementData = DashArray;
00907             DashArray[0] = DashUnit*16;
00908             DashArray[1] = DashUnit*2;
00909             DashArray[2] = DashUnit*2;
00910             DashArray[3] = DashUnit*2;
00911 
00912             SetDashPattern(StockDash);
00913             break;
00914 
00915         case SD_DASH14:
00916             StockDash.Elements = 4;
00917             StockDash.DashStart = 0;
00918             StockDash.ElementData = DashArray;
00919             DashArray[0] = DashUnit*8;
00920             DashArray[1] = DashUnit*2;
00921             DashArray[2] = DashUnit*4;
00922             DashArray[3] = DashUnit*2;
00923 
00924             SetDashPattern(StockDash);
00925             break;
00926 
00927         case SD_DASH15:
00928             StockDash.Elements = 4;
00929             StockDash.DashStart = 0;
00930             StockDash.ElementData = DashArray;
00931             DashArray[0] = DashUnit*16;
00932             DashArray[1] = DashUnit*2;
00933             DashArray[2] = DashUnit*4;
00934             DashArray[3] = DashUnit*2;
00935 
00936             SetDashPattern(StockDash);
00937             break;
00938 
00939         case SD_DASH16:
00940             StockDash.Elements = 6;
00941             StockDash.DashStart = 0;
00942             StockDash.ElementData = DashArray;
00943             DashArray[0] = DashUnit*8;
00944             DashArray[1] = DashUnit*2;
00945             DashArray[2] = DashUnit*2;
00946             DashArray[3] = DashUnit*2;
00947             DashArray[4] = DashUnit*2;
00948             DashArray[5] = DashUnit*2;
00949 
00950             SetDashPattern(StockDash);
00951             break;
00952 
00953         case SD_DASH17:
00954             StockDash.Elements = 6;
00955             StockDash.DashStart = 0;
00956             StockDash.ElementData = DashArray;
00957             DashArray[0] = DashUnit*16;
00958             DashArray[1] = DashUnit*2;
00959             DashArray[2] = DashUnit*2;
00960             DashArray[3] = DashUnit*2;
00961             DashArray[4] = DashUnit*2;
00962             DashArray[5] = DashUnit*2;
00963 
00964             SetDashPattern(StockDash);
00965             break;
00966 
00967         case SD_DASH18:
00968             StockDash.Elements = 8;
00969             StockDash.DashStart = 0;
00970             StockDash.ElementData = DashArray;
00971             DashArray[0] = DashUnit*8;
00972             DashArray[1] = DashUnit*2;
00973             DashArray[2] = DashUnit*2;
00974             DashArray[3] = DashUnit*2;
00975             DashArray[4] = DashUnit*2;
00976             DashArray[5] = DashUnit*2;
00977             DashArray[6] = DashUnit*2;
00978             DashArray[7] = DashUnit*2;
00979 
00980             SetDashPattern(StockDash);
00981             break;
00982 
00983         case SD_DASH19:
00984             StockDash.Elements = 8;
00985             StockDash.DashStart = 0;
00986             StockDash.ElementData = DashArray;
00987             DashArray[0] = DashUnit*16;
00988             DashArray[1] = DashUnit*2;
00989             DashArray[2] = DashUnit*2;
00990             DashArray[3] = DashUnit*2;
00991             DashArray[4] = DashUnit*2;
00992             DashArray[5] = DashUnit*2;
00993             DashArray[6] = DashUnit*2;
00994             DashArray[7] = DashUnit*2;
00995 
00996             SetDashPattern(StockDash);
00997             break;
00998 
00999         case SD_DASH20:
01000             StockDash.Elements = 8;
01001             StockDash.DashStart = 0;
01002             StockDash.ElementData = DashArray;
01003             DashArray[0] = DashUnit*8;
01004             DashArray[1] = DashUnit*2;
01005             DashArray[2] = DashUnit*2;
01006             DashArray[3] = DashUnit*2;
01007             DashArray[4] = DashUnit*4;
01008             DashArray[5] = DashUnit*2;
01009             DashArray[6] = DashUnit*2;
01010             DashArray[7] = DashUnit*2;
01011 
01012             SetDashPattern(StockDash);
01013             break;
01014 
01015         case SD_DASH_GUIDELAYER:
01016             // This is the dash pattern used to render objects in guide layers with.
01017             // It's different to the others in that the dashed aren't scaled relative to the line width
01018             StockDash.Elements = 2;
01019             StockDash.DashStart = 0;
01020             StockDash.ElementData = DashArray;
01021             StockDash.ScaleWithLineWidth = FALSE;
01022             DashArray[0] = DashUnit*2;
01023             DashArray[1] = DashUnit*2;
01024 
01025             SetDashPattern(StockDash);
01026             break;
01027 
01028         default:
01029             StockDash.Elements = 0;
01030             StockDash.DashStart = 0;
01031             StockDash.ElementData = NULL;
01032 
01033             SetDashPattern(StockDash);
01034             break;
01035     }
01036 
01037     return TRUE;
01038 }

void DashPatternAttribute::SimpleCopy AttributeValue  )  [virtual]
 

Implements AttributeValue.

Definition at line 1556 of file attr.cpp.

01557 {
01558     DashPattern = ((DashPatternAttribute *) pValue)->DashPattern;
01559 }


Member Data Documentation

DashRec DashPatternAttribute::DashPattern
 

Definition at line 442 of file attrval.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:53:28 2007 for Camelot by  doxygen 1.4.4