UserAttribute Class Reference

Represent a line width of a path. This may be a simple stroking operator such as a constant line width, or a complex one such as variable line widths or an airbrush stroke operator. (I'd say it stores a "key" string and an associated "value" string for implementation of URLs and other such stuff, but if you say it stores a line width, who am I to argue? ;-). More...

#include <userattr.h>

Inheritance diagram for UserAttribute:

AttributeValue CCObject SimpleCCObject List of all members.

Public Member Functions

 UserAttribute ()
UserAttributeoperator= (const UserAttribute &other)
 Assignment operator for UserAttributes.
virtual void Restore (RenderRegion *, BOOL)
 Again, restoring a User Attribute does nothing.
virtual void Render (RenderRegion *, BOOL Temp=FALSE)
 Rendering a User Attribute does nothing. That's what this function does.
virtual NodeAttributeMakeNode ()
 Make a AttrUser node from this line width attribute.
BOOL IsDifferent (AttributeValue *pAttr)
 See base class version.
virtual void SimpleCopy (AttributeValue *)
 Copies both bits of the data from pValue.
virtual BOOL Blend (BlendAttrParam *pBlendParam)
 Blends this attr val with the attr val held in pBlendParam.
virtual BOOL RenderStroke (RenderRegion *, Path *)

Static Public Member Functions

static BOOL Init ()
 There's no need for this function at the moment but I'll leave it in in case someone needs it in the future.

Public Attributes

StringBase Key
StringBase LongKey
StringBase Value
const Stylem_pStyle

Detailed Description

Represent a line width of a path. This may be a simple stroking operator such as a constant line width, or a complex one such as variable line widths or an airbrush stroke operator. (I'd say it stores a "key" string and an associated "value" string for implementation of URLs and other such stuff, but if you say it stores a line width, who am I to argue? ;-).

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com> (Actually, it was more likely to be Graham, cos Tim quit a few months before)
Date:
15/06/94 (More like mid '96 if you ask me)

Definition at line 125 of file userattr.h.


Constructor & Destructor Documentation

UserAttribute::UserAttribute  ) 
 

FUNCTIONS FOR THE UserATTRIBUTE CLASS (Graham 18/8/96)

Definition at line 147 of file userattr.cpp.

00148   : m_pStyle(0)
00149 {
00150     // To ensure default constructed UserAttributes can be copied, alloc the strings.
00151     if (!Key.Alloc(0) || !LongKey.Alloc(0) || !Value.Alloc(0)) return;
00152 }


Member Function Documentation

BOOL UserAttribute::Blend BlendAttrParam pBlendParam  )  [virtual]
 

Blends this attr val with the attr val held in pBlendParam.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> from Markn
Date:
15/8/96
Parameters:
pBlendParam = ptr to param holding all data needed for the attr val to blend [INPUTS]
if TRUE returned, pBlendParam->GetBlendedAttrVal() will get ptr to the blended attr val [OUTPUTS] if FALSE returned, pBlendParam->GetBlendedAttrVal() will return NULL
Returns:
TRUE if successful, FALSE otherwaie
See also:
-

Reimplemented from AttributeValue.

Definition at line 344 of file userattr.cpp.

00345 {
00346     // Check entry param
00347     ERROR3IF(pBlendParam == NULL,"NULL entry param");
00348     if (pBlendParam == NULL) return FALSE;
00349 
00350     // Check that the pointer to the other User attr val is not NULL, and is a UserAttribute
00351     UserAttribute* pOtherUserAttr = (UserAttribute*) pBlendParam->GetOtherAttrVal();
00352     ERROR3IF(pOtherUserAttr == NULL,"NULL other attr val");
00353     ERROR3IF(!IS_A(pOtherUserAttr, UserAttribute),"other attr val not a user attr");
00354     if (pOtherUserAttr == NULL || !IS_A(pOtherUserAttr, UserAttribute)) return FALSE;
00355 
00356     //Graham: Here's the change. If the Keys of the attributes are not the same, we must
00357     //not blend these attributes.
00358     if (Key != pOtherUserAttr->Key && LongKey != pOtherUserAttr->LongKey)
00359     {
00360         return FALSE;
00361     }
00362 
00363     // Get a new UserAttribute to hold the blended version, (return FALSE if this fails)
00364     UserAttribute* pBlendedUserAttr = new UserAttribute;
00365     if (pBlendedUserAttr == NULL) return FALSE;
00366 
00367     //Graham: For blending two User Attributes with the same Key, we simply
00368     //use the first User Attribute for the first half of the blend, and the
00369     //second User Attribute for the second half of the blend.
00370     StringBase* pStr;   
00371     if (pBlendParam->GetBlendRatio() < 0.5)
00372         pStr = &Value;
00373     else
00374         pStr = &(pOtherUserAttr->Value);
00375     
00376     ERRORIF(!pBlendedUserAttr->Value.Alloc(pStr->Length()), _R(IDE_NOMORE_MEMORY), FALSE);
00377     pBlendedUserAttr->Value = *pStr;
00378     
00379     // Store the ptr to the new blended User width attr val
00380     pBlendParam->SetBlendedAttrVal(pBlendedUserAttr);
00381     return TRUE;
00382 }

BOOL UserAttribute::Init void   )  [static]
 

There's no need for this function at the moment but I'll leave it in in case someone needs it in the future.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/8/96
Returns:
TRUE - initialised ok; FALSE if not.
This function usually registers Default Attributes (see commented out code below). There's never a need to register a Default User Attribute.

Returns:
Errors: None
See also:
AttributeManager

Reimplemented from SimpleCCObject.

Definition at line 202 of file userattr.cpp.

00203 {
00204     UserAttribute *pAttr = new UserAttribute;
00205     if (pAttr == NULL)
00206         return FALSE;
00207 
00208     UINT32 ID = AttributeManager::RegisterDefaultAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), 
00209                                                          pAttr);
00210     if (ID == ATTR_BAD_ID)
00211         return FALSE;
00212     ENSURE(ID == ATTR_USERATTRIBUTE, "Incorrect ID for attribute!");
00213     return TRUE;
00214 }

BOOL UserAttribute::IsDifferent AttributeValue pAttr  )  [virtual]
 

See base class version.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> from Tim
Date:
12/04/94
Returns:
Errors: The two attributes are not of the same type.
See also:
AttributeValue::IsDifferent

Reimplemented from AttributeValue.

Definition at line 315 of file userattr.cpp.

00316 {
00317     ENSURE_NOT_NULL(pAttr);
00318 
00319     ENSURE(GetRuntimeClass() == pAttr->GetRuntimeClass(), 
00320            "Different attribute types in AttributeValue::IsDifferent()");
00321 
00322     ENSURE_KIND(pAttr, UserAttribute);
00323     UserAttribute* const pUserAttrVal = (UserAttribute*)pAttr;
00324 
00325     // LongKey should always start with Key
00326     return pUserAttrVal->LongKey != LongKey || pUserAttrVal->Value != Value;
00327 }

NodeAttribute * UserAttribute::MakeNode  )  [virtual]
 

Make a AttrUser node from this line width attribute.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/04/94
Returns:
Pointer to the new node, or NULL if out of memory.

Errors: Out of memory

See also:
AttributeValue::MakeNode

Reimplemented from AttributeValue.

Definition at line 291 of file userattr.cpp.

00292 {
00293     // Create new attribute node
00294     AttrUser *pAttr = new AttrUser();
00295 
00296     // Copy attribute value into the new node.
00297     pAttr->Value.SimpleCopy(this);
00298 
00299     // Return the new node
00300     return pAttr;
00301 }

UserAttribute & UserAttribute::operator= const UserAttribute other  ) 
 

Assignment operator for UserAttributes.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/9/99
Returns:
Errors: _R(IDE_NOMORE_MEMORY) Notes: *DOESN'T* COPY THE m_pStyle MEMBER! What the hell is that doing in this class, anyway??
See also:
UserAttribute::SimpleCopy; AttrUser::CopyNodeContents

Definition at line 168 of file userattr.cpp.

00169 {
00170     if (Key.Alloc(other.Key.Length()) &&
00171         LongKey.Alloc(other.LongKey.Length()) &&
00172         Value.Alloc(other.Value.Length()))
00173     {       
00174         Key = other.Key;
00175         LongKey = other.LongKey;
00176         Value = other.Value;
00177     }
00178 
00179     return *this;
00180 }

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

Rendering a User Attribute does nothing. That's what this function does.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/8/96
Parameters:
pRegion - the render region to render this attribute into. [INPUTS]
See also:
UserAttribute; RenderStack; AttributeValue; NodeAttribute; ValueAttribute::Restore; ValueAttribute::SimpleCopy; AttributeValue::Render; AttributeValue::Restore; AttributeValue::SimpleCopy

Implements AttributeValue.

Definition at line 231 of file userattr.cpp.

00232 {
00233     //Do nothing
00234 }

virtual BOOL UserAttribute::RenderStroke RenderRegion ,
Path
[inline, virtual]
 

Definition at line 144 of file userattr.h.

00144 { return FALSE; }

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

Again, restoring a User Attribute does nothing.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
03/02/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:
UserAttribute; RenderStack; AttributeValue; NodeAttribute; ValueAttribute::Render; ValueAttribute::SimpleCopy; AttributeValue::Render; AttributeValue::Restore; AttributeValue::SimpleCopy

Implements AttributeValue.

Definition at line 253 of file userattr.cpp.

00254 {
00255     // Do nothing
00256 }

void UserAttribute::SimpleCopy AttributeValue pValue  )  [virtual]
 

Copies both bits of the data from pValue.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/8/96
Parameters:
pValue - pointer to the AttributeValue to copy. [INPUTS]
See also:
ValueAttribute; RenderStack; AttributeValue; NodeAttribute; ValueAttribute::Render; ValueAttribute::Restore; AttributeValue::Render; AttributeValue::Restore; AttributeValue::SimpleCopy

Implements AttributeValue.

Definition at line 272 of file userattr.cpp.

00273 {
00274     *this = *((UserAttribute*) pValue);
00275 }


Member Data Documentation

StringBase UserAttribute::Key
 

Definition at line 146 of file userattr.h.

StringBase UserAttribute::LongKey
 

Definition at line 147 of file userattr.h.

const Style* UserAttribute::m_pStyle
 

Definition at line 149 of file userattr.h.

StringBase UserAttribute::Value
 

Definition at line 148 of file userattr.h.


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