StrokeTypeAttrValue Class Reference

StrokeType attribute value StrokeType attributes describe the stroking characteristics for a path. More...

#include <strkattr.h>

Inheritance diagram for StrokeTypeAttrValue:

AttributeValue CCObject SimpleCCObject List of all members.

Public Member Functions

 StrokeTypeAttrValue (PathProcessorStroke *pPathProcessor=NULL)
 Default Constuctor for StrokeTypeAttrValue.
 ~StrokeTypeAttrValue ()
 Destructor Deletes any attached PathProcessor (see the constructor).
virtual void Render (RenderRegion *pRegion, BOOL Temp=FALSE)
 Sets the StrokeTypeAttrValue attribute for the given render region.
virtual void Restore (RenderRegion *pRegion, BOOL Temp)
 Restores the StrokeTypeAttrValue attribute for the given render region.
virtual void GoingOutOfScope (RenderRegion *pRegion)
 A sister function to Render().
virtual void SimpleCopy (AttributeValue *pValue)
 See AttributeValue::SimpleCopy.
virtual NodeAttributeMakeNode ()
 Make a new attribute node for this type of attr value - see base class.
virtual BOOL IsDifferent (AttributeValue *pAttr)
 Determines if this AttrValue is different from the given one.
virtual StrokeTypeAttrValueoperator= (StrokeTypeAttrValue &Attrib)
 Assignment operator.
virtual INT32 operator== (const StrokeTypeAttrValue &Attrib)
 Comparison operator.
void SetPathProcessor (PathProcessorStroke *pNewProcessor)
 To set the path processor used by this object. The processor is now "owned" by this attribute, and will be auto-deleted upon destruction.
PathProcessorStrokeGetPathProcessor (void) const
BOOL DoBecomeA (BecomeA *pBecomeA, Node *pParent)
 To convert our stroke into something more palatable. pParent should always be a nodepath.

Static Public Member Functions

static BOOL Init (void)
 Registers a default attribute of this type with the attribute manager.

Private Attributes

PathProcessorStrokepProcessor

Detailed Description

StrokeType attribute value StrokeType attributes describe the stroking characteristics for a path.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97
Notes: This AttrValue just contains a pointer to a path processor which will stroke paths after some given fashion. The pointer may be NULL, in which case new-style stroking is disabled, and old-style "lines" will be rendered.

Definition at line 147 of file strkattr.h.


Constructor & Destructor Documentation

StrokeTypeAttrValue::StrokeTypeAttrValue PathProcessorStroke pPathProcessor = NULL  ) 
 

Default Constuctor for StrokeTypeAttrValue.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97
Parameters:
pPathProcessor - the stroke path-processor which will do the stroking [INPUTS] effect "applied" by this attribute. NULL indicates that this attribute does no stroking (i.e. that the path should have an old-style "line")
NOTE that this object is NOW OWNED by this StrokeTypeAttrValue, and will be deleted when the attribute value is deleted.

Definition at line 617 of file strkattr.cpp.

00618 {
00619     // Remember our processor, and let it know that we "own" it
00620     pProcessor = pPathProcessor;
00621     if (pProcessor != NULL)
00622         pProcessor->SetParentAttr(this);
00623 }

StrokeTypeAttrValue::~StrokeTypeAttrValue  ) 
 

Destructor Deletes any attached PathProcessor (see the constructor).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97

Definition at line 639 of file strkattr.cpp.

00640 {
00641     if (pProcessor != NULL)
00642         delete pProcessor;
00643 }


Member Function Documentation

BOOL StrokeTypeAttrValue::DoBecomeA BecomeA pBecomeA,
Node pParent
 

To convert our stroke into something more palatable. pParent should always be a nodepath.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/3/2000
Parameters:
pBecomeA - the object that tells us what to become, and recieves the results [INPUTS] pParent - the node that this attribute is applied to
[OUTPUTS] 
Returns:
TRUE if everything went ok,
Notes: Due to problems with bevelling and contouring this function does not get called in the normal DoBecomeA procedure unless you specifically locate this attribute and call this function directly.

Definition at line 967 of file strkattr.cpp.

00968 {
00969     ERROR2IF(pBecomeA == NULL, FALSE, "BecomeA pointer is NULL in VariableWidthAttrValue::DoBecomeA");
00970     ERROR2IF(pParent == NULL, FALSE, "Parent node is NULL in VariableWidthAttrValue::DoBecomeA");
00971 
00972     if (pProcessor == NULL)
00973         return FALSE;
00974 
00975     if (!pBecomeA->BAPath())
00976         return FALSE;
00977 
00978     BOOL Success = FALSE;
00979 //  UINT32 Dummy = 0;
00980     // if we have a nodepath then we can simply use its member path, otherwise we
00981     // have to ask it to become a nodepath
00982     if (pParent->IsNodePath())
00983     {   
00984         // we have a special calculation for nodepaths, because we can use their path
00985         Success =  pProcessor->DoBecomeA(pBecomeA, &((NodePath*)pParent)->InkPath, pParent);
00986     }
00987     else if (pParent->CanBecomeA(pBecomeA))
00988     {
00989         // we must be applied to some arbitrary shape.  The thing is that we need to have
00990         // a path to pass to the PPB, so want to get a passback of all the paths in 
00991         // the node 
00992         
00993         // we need to allocate a path
00994         Path* pPath = new Path;
00995         if (pPath != NULL && pPath->Initialise())
00996         {
00997             PathBecomeA BecomeAPath(BECOMEA_PASSBACK, CC_RUNTIME_CLASS(NodePath), NULL, FALSE, pPath);
00998             if (pParent->DoBecomeA(&BecomeAPath))
00999             {
01000                 Success =  pProcessor->DoBecomeA(pBecomeA, pPath, pParent);
01001             }
01002             delete pPath;
01003         }
01004     }
01005     return Success;
01006 }

PathProcessorStroke* StrokeTypeAttrValue::GetPathProcessor void   )  const [inline]
 

Definition at line 174 of file strkattr.h.

00174 { return(pProcessor); };

void StrokeTypeAttrValue::GoingOutOfScope RenderRegion pRegion  )  [virtual]
 

A sister function to Render().

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/1/97
Parameters:
pRegion - the render region the attribute is in use by [INPUTS]
This is called by a render region when an attribute goes out of scope, i.e. when the attribute is no longer in use and is popped off the stack for the last time. (Do NOT confuse this with being pushed onto the render stack when overridden by another attr)

It gives the attribute a chance to remove any PathProcessor(s) it added to the RenderRegion when it was Render()ed.

Notes: This attribute makes sure it removes any PathProcessor it added to handle path stroking in StrokeTypeAttrValue::Render

See also:
StrokeTypeAttrValue::Render()

Reimplemented from AttributeValue.

Definition at line 764 of file strkattr.cpp.

00765 {
00766     if (pProcessor != NULL)
00767         pRegion->PopPathProcessor();
00768 }

BOOL StrokeTypeAttrValue::Init void   )  [static]
 

Registers a default attribute of this type with the attribute manager.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97
Returns:
TRUE if it initilised successfully

Reimplemented from SimpleCCObject.

Definition at line 660 of file strkattr.cpp.

00661 {
00662     // The default attribute is one that has no effect (i.e. produces old-style "lines")
00663     StrokeTypeAttrValue *pAttr = new StrokeTypeAttrValue;
00664     if (pAttr == NULL)
00665         return FALSE;
00666 
00667     UINT32 ID = AttributeManager::RegisterDefaultAttribute(CC_RUNTIME_CLASS(StrokeTypeAttrValue),
00668                                                             pAttr);
00669 
00670     ERROR2IF(ID == ATTR_BAD_ID, FALSE, "Bad ID when Initialising StrokeTypeAttrValue");
00671 
00672     return(TRUE);
00673 }

BOOL StrokeTypeAttrValue::IsDifferent AttributeValue pAttr  )  [virtual]
 

Determines if this AttrValue is different from the given one.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97
Returns:
Errors: ERROR3 if the two attributes are not of the same type
See also:
AttributeValue::IsDifferent

Reimplemented from AttributeValue.

Definition at line 842 of file strkattr.cpp.

00843 {
00844     ERROR3IF(!pAttr->IsKindOf(CC_RUNTIME_CLASS(StrokeTypeAttrValue)),
00845                 "Different attribute types in StrokeTypeAttrValue::IsDifferent()");
00846 
00847     // Check they are NOT the same using the == operator
00848     return ( !(*((StrokeTypeAttrValue *)pAttr) == *this) );
00849 }

NodeAttribute * StrokeTypeAttrValue::MakeNode  )  [virtual]
 

Make a new attribute node for this type of attr value - see base class.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97
Returns:
Pointer to the new node, or NULL if out of memory.
See also:
AttributeValue::MakeNode

Reimplemented from AttributeValue.

Definition at line 811 of file strkattr.cpp.

00812 {
00813     // Create new attribute node
00814     AttrStrokeType *pAttr = new AttrStrokeType;
00815     if (pAttr == NULL)
00816         return NULL;
00817 
00818     // Copy attribute value (if any) into the new node.
00819     if (pAttr->GetAttributeValue() != NULL)
00820         pAttr->GetAttributeValue()->SimpleCopy(this);
00821 
00822     return(pAttr);
00823 }

StrokeTypeAttrValue & StrokeTypeAttrValue::operator= StrokeTypeAttrValue Attrib  )  [virtual]
 

Assignment operator.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97
Parameters:
Attrib - the attribute to copy [INPUTS]

Definition at line 866 of file strkattr.cpp.

00867 {
00868     // Get rid of our old processor (if any)
00869     if (pProcessor != NULL)
00870         delete pProcessor;
00871     pProcessor = NULL;
00872 
00873     // Copy the other attr's processor. If this fails, we'll get back a NULL pointer,
00874     // and will simply "convert" into a simple no-stroke attribute.
00875     if (Attrib.pProcessor != NULL)
00876     {
00877         pProcessor = Attrib.pProcessor->Clone();
00878         if (pProcessor != NULL)
00879             pProcessor->SetParentAttr(this);
00880     }
00881 
00882     return(*this);
00883 }

INT32 StrokeTypeAttrValue::operator== const StrokeTypeAttrValue Attrib  )  [virtual]
 

Comparison operator.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97
Parameters:
Attrib - the attribute to compare this attribute with [INPUTS]
Returns:
TRUE if the attributes are considered equal

Definition at line 902 of file strkattr.cpp.

00903 {
00904     ERROR3IF(!Attrib.IsKindOf(CC_RUNTIME_CLASS(StrokeTypeAttrValue)),
00905                 "Other attribute value isn't an StrokeTypeAttrValue");
00906 
00907     StrokeTypeAttrValue *Other = (StrokeTypeAttrValue *) &Attrib;
00908 
00909     // Equal if they both have same processor (only applies if they are both NULL)
00910     if (pProcessor == Other->pProcessor)
00911         return(TRUE);
00912 
00913     // Otherwise, if one of them is NULL, they can't be the same
00914     if (pProcessor == NULL || Other->pProcessor == NULL)
00915         return(FALSE);
00916 
00917     // Finally, ask the processors if they are of the same type
00918     return(!pProcessor->IsDifferent(Other->pProcessor));
00919 }

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

Sets the StrokeTypeAttrValue attribute for the given render region.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97
Parameters:
pRegion - the render region to render this attribute into. [INPUTS]
Notes: This attribute makes itself current in the render region, and also (possibly) adds a PathProcessor to handle stroking of all future rendered paths (until the attr is "restored")

See also:
StrokeTypeAttrValue::Restore

Implements AttributeValue.

Definition at line 696 of file strkattr.cpp.

00697 {
00698     // Stack the current attribute and set ourselves up as the new one
00699     pRegion->SetStrokeType(this, Temp);
00700 
00701     // Find if we have a path processor to do the stroking, and if we do, 
00702     // stack a copy of it (a copy must be used to be thread-safe & bgrender-safe)
00703     if (pProcessor != NULL)
00704     {
00705         PathProcessorStroke *pNewProcessor = pProcessor->Clone();
00706         if (pNewProcessor != NULL)
00707             pRegion->PushPathProcessor(pNewProcessor);
00708     }
00709 }

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

Restores the StrokeTypeAttrValue attribute for the given render region.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97
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).
Notes: This attribute makes sure it removes any PathProcessor it added to handle path stroking in StrokeTypeAttrValue::Render

Implements AttributeValue.

Definition at line 731 of file strkattr.cpp.

00732 {
00733     pRegion->RestoreStrokeType(this, Temp);
00734 }

void StrokeTypeAttrValue::SetPathProcessor PathProcessorStroke pNewProcessor  ) 
 

To set the path processor used by this object. The processor is now "owned" by this attribute, and will be auto-deleted upon destruction.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97
Parameters:
pNewProcessor - The new PathProcessorStroke to be used by this attr. [INPUTS] May be NULL, in which case it sets "old style lines" stroking mode.

Definition at line 938 of file strkattr.cpp.

00939 {
00940     if (pProcessor != NULL)
00941         delete pProcessor;
00942 
00943     pProcessor = pNewProcessor;
00944     if (pProcessor != NULL)
00945         pProcessor->SetParentAttr(this);
00946 }

void StrokeTypeAttrValue::SimpleCopy AttributeValue pValue  )  [virtual]
 

See AttributeValue::SimpleCopy.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97
Parameters:
pValue - pointer to the AttributeValue to copy [INPUTS]

Implements AttributeValue.

Definition at line 785 of file strkattr.cpp.

00786 {
00787     ERROR3IF(!IS_A(pValue, StrokeTypeAttrValue),
00788                 "Invalid Attribute value passed to StrokeTypeAttrValue::SimpleCopy");
00789 
00790     // Just uses the assignment operator
00791     *this = *((StrokeTypeAttrValue *) pValue);
00792 }


Member Data Documentation

PathProcessorStroke* StrokeTypeAttrValue::pProcessor [private]
 

Definition at line 179 of file strkattr.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:01:33 2007 for Camelot by  doxygen 1.4.4