VarWidthItem Class Reference

Represents a stroke type user-interface item within the line gallery. More...

#include <sgstroke.h>

Inheritance diagram for VarWidthItem:

LineAttrItem SGDisplayItem SGDisplayNode CCObject SimpleCCObject List of all members.

Public Member Functions

 VarWidthItem (VariableWidthAttrValue *pAttr, const String &strDescription)
 Constructs a user-interface item representing a stroke type.
 ~VarWidthItem ()
 Destructor.
void RenderAttributes (RenderRegion *pRegion)

Private Member Functions

 CC_DECLARE_DYNAMIC (VarWidthItem)
virtual void SetAttributes (RenderRegion *pRegion) const
 Sets the stroke typeattributes in the given render-region to render this item correctly.
virtual NodeAttributeCreateNewAttribute (BOOL fIsAdjust) const
 Create a NodeAttribute representing the attribute this item applies.
virtual MILLIPOINT GetWidth () const
 Called by the line gallery formatting code.
virtual CCRuntimeClass ** GetAttribRuntimeClasses () const
 Used when searching for display items representing the selection's current attributes.
virtual BOOL IsEqualValueToAny (NodeAttribute **ppOtherAttribs) const
 Used when searching for display items representing the selection's current attributes.
virtual MILLIPOINT GetHorzGap () const
 Called by the formatting code to determine the gap between items of this type.
virtual BOOL ItemSelected (NodeAttribute *pAttr)
 utility fn called when the item is selected. As we now wish to apply both the stroke type item and the variable width item through one UI action we must do so here. Notes: This was implemented so that the user could apply a variable width stroke with just one click. As we have abaondoned the idea of keeping the different stroke types for this release it has been decided that we will only have the basic stroke type which will automatically be applied when you select a variable width

Private Attributes

VariableWidthAttrValuepAttrDef

Detailed Description

Represents a stroke type user-interface item within the line gallery.

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

Definition at line 167 of file sgstroke.h.


Constructor & Destructor Documentation

VarWidthItem::VarWidthItem VariableWidthAttrValue pAttr,
const String strDescription
 

Constructs a user-interface item representing a stroke type.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/3/97
Parameters:
pAttr - a pointer to an attribute to be used for this [INPUTS] stroke type. This now belongs to the VarWidthItem, so you must not delete it strDescription - a text description of this user-interface item
- [OUTPUTS]
Returns:
-

Definition at line 606 of file sgstroke.cpp.

00607               : LineAttrItem(strDescription, BELOW)
00608 {
00609     ERROR3IF(pAttr == NULL, "Illegal NULL param");
00610     pAttrDef = pAttr;
00611 }

VarWidthItem::~VarWidthItem  ) 
 

Destructor.

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

Definition at line 626 of file sgstroke.cpp.

00627 {
00628     if (pAttrDef != NULL)
00629         delete pAttrDef;
00630 }


Member Function Documentation

VarWidthItem::CC_DECLARE_DYNAMIC VarWidthItem   )  [private]
 

NodeAttribute * VarWidthItem::CreateNewAttribute BOOL  fIsAdjust  )  const [private, virtual]
 

Create a NodeAttribute representing the attribute this item applies.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/3/97
Returns:
A pointer to a NodeAttribute-derivative that this user-interface item represents, ie. a line-width attribute that can be passed to the attribute manager.

Implements LineAttrItem.

Definition at line 679 of file sgstroke.cpp.

00680 {
00681     return(pAttrDef->MakeNode());
00682 }

CCRuntimeClass ** VarWidthItem::GetAttribRuntimeClasses  )  const [private, virtual]
 

Used when searching for display items representing the selection's current attributes.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/3/97
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The run-time class of the line attribute this type of display item represents.

Implements LineAttrItem.

Definition at line 721 of file sgstroke.cpp.

00722 {
00723     static CCRuntimeClass* aprtc[] =
00724     {
00725         CC_RUNTIME_CLASS(AttrVariableWidth),
00726         NULL
00727     };
00728 
00729     return aprtc;
00730 }

MILLIPOINT VarWidthItem::GetHorzGap  )  const [private, virtual]
 

Called by the formatting code to determine the gap between items of this type.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/3/97
Returns:
The horizontal gap between this item and another item of the same type, in millipoints.

Reimplemented from LineAttrItem.

Definition at line 782 of file sgstroke.cpp.

00783 {
00784     // I would like the gap to be the same all the way around
00785     return(GetVertGap());
00786 }

MILLIPOINT VarWidthItem::GetWidth void   )  const [private, virtual]
 

Called by the line gallery formatting code.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/3/97
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The width of a line-width item, in millipoints.

Reimplemented from LineAttrItem.

Definition at line 699 of file sgstroke.cpp.

00700 {
00701     return 2 * LineAttrItem::GetWidth() / 3;
00702 }

BOOL VarWidthItem::IsEqualValueToAny NodeAttribute **  ppOtherAttribs  )  const [private, virtual]
 

Used when searching for display items representing the selection's current attributes.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/3/97
Parameters:
pOtherAttrib the attribute value to compare this item to [INPUTS]
- [OUTPUTS]
Returns:
TRUE if this item represents the same attribute value as the given attribute.

Implements LineAttrItem.

Definition at line 749 of file sgstroke.cpp.

00750 {
00751     if (*ppOtherAttribs == NULL)
00752         return(FALSE);
00753 
00754     AttrVariableWidth* pAttr = (AttrVariableWidth *) *ppOtherAttribs;
00755     ERROR3IF(!pAttr->IsKindOf(CC_RUNTIME_CLASS(AttrVariableWidth)),
00756                 "VarWidthItem::IsEqualValueToAny - unexpected object type");
00757 
00758     if (pAttr != NULL)
00759     {
00760         VariableWidthAttrValue *pOther = (VariableWidthAttrValue *) pAttr->GetAttributeValue();
00761         return((*pAttrDef) == (*pOther));
00762     }
00763 
00764     return(FALSE);
00765 }

BOOL VarWidthItem::ItemSelected NodeAttribute pAttribute  )  [private, virtual]
 

utility fn called when the item is selected. As we now wish to apply both the stroke type item and the variable width item through one UI action we must do so here. Notes: This was implemented so that the user could apply a variable width stroke with just one click. As we have abaondoned the idea of keeping the different stroke types for this release it has been decided that we will only have the basic stroke type which will automatically be applied when you select a variable width

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/1/2000
Parameters:
pNewAttr - the attribute that we are about to apply [INPUTS]
- [OUTPUTS]
Returns:
TRUE if we want the line gallery to go ahead and apply the attribute, FALSE if we applied it ourselves.

Reimplemented from LineAttrItem.

Definition at line 807 of file sgstroke.cpp.

00808 {
00809     if (pAttribute == NULL || !pAttribute->IsKindOf(CC_RUNTIME_CLASS(AttrVariableWidth)))
00810     {
00811         ERROR3("Invalid attribute in VarWidthItem::ItemSelected");
00812         return FALSE;
00813     }
00814 
00815     // if we're applying a default then we should also apply an old-style stroke so...
00816     PathProcessorStroke* PPS = NULL;
00817     VariableWidthAttrValue* pVal = (VariableWidthAttrValue*)pAttribute->GetAttributeValue();
00818     if (pVal->GetWidthFunction() != NULL)
00819     {
00820         // If not a default then create the PathProcessor for the stroke attribute
00821         // The default case will fall through with NULL and create an old-style stroke
00822         PPS = new PathProcessorStroke;
00823         if (PPS == NULL)
00824             return FALSE;
00825     }
00826 
00827     StrokeTypeAttrValue NewStroke(PPS);
00828     AttrStrokeType* pAttrStroke = (AttrStrokeType*)NewStroke.MakeNode();
00829 
00830     if (pAttrStroke == NULL)
00831         return FALSE;
00832 
00833     List AttribsList;
00834     NodeAttributePtrItem* pStrokeAttrPtr = new NodeAttributePtrItem;
00835     if (pStrokeAttrPtr == NULL)
00836     {
00837         delete pAttrStroke;
00838         return TRUE;
00839     }
00840     pStrokeAttrPtr->NodeAttribPtr = pAttrStroke;
00841 
00842     // in order to apply the attributes simultaneously we need a list
00843     AttribsList.AddHead(pStrokeAttrPtr);
00844 
00845     NodeAttributePtrItem* pVarWidthPtr = new NodeAttributePtrItem;
00846     if (pVarWidthPtr == NULL)
00847     {
00848         pStrokeAttrPtr->NodeAttribPtr = NULL;
00849         delete pAttrStroke;
00850         delete pStrokeAttrPtr;
00851         return TRUE;
00852     }
00853     pVarWidthPtr->NodeAttribPtr = pAttribute;
00854 
00855     AttribsList.AddHead(pVarWidthPtr);
00856 
00857     AttributeManager::AttributesSelected(AttribsList, _R(IDS_STROKEAPPLY_UNDO));
00858 
00859     // We don't need the list of attrs anymore
00860     NodeAttributePtrItem* pAttrItem = (NodeAttributePtrItem*)AttribsList.GetHead();
00861     while (pAttrItem)
00862     {
00863         delete (pAttrItem->NodeAttribPtr);
00864         pAttrItem->NodeAttribPtr = NULL;
00865         pAttrItem = (NodeAttributePtrItem*)AttribsList.GetNext(pAttrItem);
00866     }
00867     AttribsList.DeleteAll(); // tidyup  
00868 
00869     BROADCAST_TO_ALL(StrokeMsg());
00870     return FALSE; // means do not go ahead and apply pAttribute again
00871 }

void VarWidthItem::RenderAttributes RenderRegion pRegion  )  [inline]
 

Definition at line 176 of file sgstroke.h.

00176 { SetAttributes (pRegion); }

void VarWidthItem::SetAttributes RenderRegion pRegion  )  const [private, virtual]
 

Sets the stroke typeattributes in the given render-region to render this item correctly.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/3/97
Parameters:
pRegion - the render-region to draw into [INPUTS]

Implements LineAttrItem.

Definition at line 648 of file sgstroke.cpp.

00649 {
00650     // Set a 16pt line width - nice & thick
00651     pRegion->SetLineWidth(16000);
00652 
00653     // Set the line width (this overrides the "default" line width set by the caller).
00654     pAttrDef->Render(pRegion, FALSE);
00655 
00656     // Set a path processor up so that the variable line width is used when stroking
00657     StrokeTypeAttrValue *pStroke = new StrokeTypeAttrValue(new PathProcessorStroke);
00658     if (pStroke != NULL)
00659         pStroke->Render(pRegion, TRUE);
00660 }


Member Data Documentation

VariableWidthAttrValue* VarWidthItem::pAttrDef [private]
 

Definition at line 188 of file sgstroke.h.


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