StrokeTypeItem Class Reference

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

#include <sgstroke.h>

Inheritance diagram for StrokeTypeItem:

LineAttrItem SGDisplayItem SGDisplayNode CCObject SimpleCCObject List of all members.

Public Member Functions

 StrokeTypeItem (StrokeTypeAttrValue *pStroke, const String &strDescription)
 Constructs a user-interface item representing a stroke type.
 ~StrokeTypeItem ()
 Destructor.
virtual StrokeTypeAttrValueGetStrokeTypeAttrValue ()
virtual StrokeDefinitionGetStrokeDefinition ()
 Get the StrokeDefinition for this item.
virtual StrokeHandle GetStrokeHandle ()
 Get the StrokeHandle for this item.
virtual BOOL IsRepeating ()
 Determins if the stroke repeats.
virtual INT32 NumRepeats ()
 See Returns.
virtual BOOL OverridesFill ()
 Determins if the stroke overrides the fill or not.
virtual BOOL OverridesTrans ()
 Determins if the stroke overrides transparency or not.
virtual void RenderItem (RenderRegion *pRender, DocRect *pDocRect, INT32 Width=c_nDefaultLineWidth)
 Renders a representation of the stroke into the given renderregion. This is used by the line properties dialog since all the stuff needed seems to be private...
virtual void UpdateGalleryItem ()
 Updates the gallery item's cached data to represent any changes this Stoke might have had done to it. Also redraw the gallery if necessary.

Private Member Functions

 CC_DECLARE_DYNAMIC (StrokeTypeItem)
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.

Private Attributes

StrokeTypeAttrValuepStrokeDef

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 121 of file sgstroke.h.


Constructor & Destructor Documentation

StrokeTypeItem::StrokeTypeItem StrokeTypeAttrValue pStroke,
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:
pStroke - a pointer to an attribute to be used for this [INPUTS] stroke type. This now belongs to the StrokeTypeItem, so you must not delete it strDescription - a text description of this user-interface item
- [OUTPUTS]
Returns:
-

Definition at line 143 of file sgstroke.cpp.

00144               : LineAttrItem(strDescription, BELOW)
00145 {
00146     ERROR3IF(pStroke == NULL, "Illegal NULL param");
00147     pStrokeDef = pStroke;
00148 }

StrokeTypeItem::~StrokeTypeItem  ) 
 

Destructor.

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

Definition at line 163 of file sgstroke.cpp.

00164 {
00165     if (pStrokeDef != NULL)
00166         delete pStrokeDef;
00167 }


Member Function Documentation

StrokeTypeItem::CC_DECLARE_DYNAMIC StrokeTypeItem   )  [private]
 

NodeAttribute * StrokeTypeItem::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 211 of file sgstroke.cpp.

00212 {
00213     return(pStrokeDef->MakeNode());
00214 }

CCRuntimeClass ** StrokeTypeItem::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 253 of file sgstroke.cpp.

00254 {
00255     static CCRuntimeClass* aprtc[] =
00256     {
00257         CC_RUNTIME_CLASS(AttrStrokeType),
00258         NULL
00259     };
00260 
00261     return aprtc;
00262 }

MILLIPOINT StrokeTypeItem::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 314 of file sgstroke.cpp.

00315 {
00316     // I would like the gap to be the same all the way around
00317     return(GetVertGap());
00318 }

StrokeDefinition * StrokeTypeItem::GetStrokeDefinition void   )  [virtual]
 

Get the StrokeDefinition for this item.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/3/97
Returns:
The StrokeDefinition for this item

Definition at line 430 of file sgstroke.cpp.

00431 {
00432     StrokeHandle Handle = GetStrokeHandle();
00433     if(Handle != StrokeHandle(-1))
00434         return StrokeComponent::FindStroke(Handle);
00435 
00436     return NULL;
00437 }

StrokeHandle StrokeTypeItem::GetStrokeHandle  )  [virtual]
 

Get the StrokeHandle for this item.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/3/97
Returns:
The StrokeHandle for this item, or StrokeHandle_NoStroke if strife

Definition at line 451 of file sgstroke.cpp.

00452 {
00453     StrokeTypeAttrValue *pAttrValue = GetStrokeTypeAttrValue();
00454     if(pAttrValue != NULL)
00455     {
00456         PathProcessorStroke *pProcessor = pAttrValue->GetPathProcessor();
00457         if (pProcessor != NULL && pProcessor->IsKindOf(CC_RUNTIME_CLASS(PathProcessorStrokeVector)))
00458         {
00459             StrokeHandle Handle = ((PathProcessorStrokeVector *)pProcessor)->GetStrokeDefinition();
00460             return Handle;
00461         }
00462     }
00463 
00464     return StrokeHandle_NoStroke;
00465 }

virtual StrokeTypeAttrValue* StrokeTypeItem::GetStrokeTypeAttrValue  )  [inline, virtual]
 

Definition at line 132 of file sgstroke.h.

00132 {return pStrokeDef;}

MILLIPOINT StrokeTypeItem::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 231 of file sgstroke.cpp.

00232 {
00233     return 2 * LineAttrItem::GetWidth() / 3;
00234 }

BOOL StrokeTypeItem::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 281 of file sgstroke.cpp.

00282 {
00283     if (*ppOtherAttribs == NULL)    // When multiple attribs are selected, this will be NULL
00284         return(FALSE);
00285 
00286     AttrStrokeType* pAttr = (AttrStrokeType *) *ppOtherAttribs;
00287     ERROR3IF(!pAttr->IsKindOf(CC_RUNTIME_CLASS(AttrStrokeType)),
00288                 "StrokeTypeItem::IsEqualValueToAny - unexpected object type");
00289 
00290     if (pAttr != NULL)
00291     {
00292         StrokeTypeAttrValue *pOther = (StrokeTypeAttrValue *) pAttr->GetAttributeValue();
00293         return((*pStrokeDef) == (*pOther));
00294     }
00295 
00296     return(FALSE);
00297 }

BOOL StrokeTypeItem::IsRepeating  )  [virtual]
 

Determins if the stroke repeats.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/3/97
Returns:
TRUE if the stroke is a repeating stroke.

Definition at line 333 of file sgstroke.cpp.

00334 {
00335     BOOL Repeating = FALSE;
00336     StrokeDefinition *pStroke = GetStrokeDefinition();
00337     if (pStroke != NULL)
00338     {
00339         Repeating = pStroke->IsRepeating();
00340     }
00341 
00342     return Repeating;
00343 }

INT32 StrokeTypeItem::NumRepeats  )  [virtual]
 

See Returns.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/3/97
Returns:
Number of times the brush should be repeated along the line. If 0, then we work out the best based on the aspect ratio and line thickness.

Definition at line 358 of file sgstroke.cpp.

00359 {
00360     INT32 Repeats = 0;
00361     StrokeDefinition *pStroke = GetStrokeDefinition();
00362     if (pStroke != NULL)
00363     {
00364         Repeats = pStroke->NumRepeats();
00365     }
00366 
00367     return Repeats;
00368 }

BOOL StrokeTypeItem::OverridesFill  )  [virtual]
 

Determins if the stroke overrides the fill or not.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/3/97
Returns:
TRUE if the stroke's overrides fill flag is set

Definition at line 382 of file sgstroke.cpp.

00383 {
00384     BOOL OverridesFill = FALSE;
00385     StrokeDefinition *pStroke = GetStrokeDefinition();
00386     if (pStroke != NULL)
00387     {
00388         OverridesFill = pStroke->OverrideFill();
00389     }
00390 
00391     return OverridesFill;
00392 }

BOOL StrokeTypeItem::OverridesTrans  )  [virtual]
 

Determins if the stroke overrides transparency or not.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/3/97
Returns:
TRUE if the stroke's overrides transparency flag is set

Definition at line 406 of file sgstroke.cpp.

00407 {
00408     BOOL OverridesTrans = FALSE;
00409     StrokeDefinition *pStroke = GetStrokeDefinition();
00410     if (pStroke != NULL)
00411     {
00412         OverridesTrans = pStroke->OverrideTrans();
00413     }
00414 
00415     return OverridesTrans;
00416 }

void StrokeTypeItem::RenderItem RenderRegion pRender,
DocRect pDocRect,
INT32  Width = c_nDefaultLineWidth
[virtual]
 

Renders a representation of the stroke into the given renderregion. This is used by the line properties dialog since all the stuff needed seems to be private...

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/3/97
Parameters:
pRender - RenderRegion to render into [INPUTS] pDocRect - Rectangle to render

Definition at line 484 of file sgstroke.cpp.

00485 {
00486     if(pRender == NULL || pDocRect == NULL)
00487     {
00488         ERROR3("StrokeTypeItem::RenderItem given null params");
00489         return;
00490     }
00491 
00492     pRender->SaveContext();
00493 
00494     // Make sure we're anti-aliasing
00495     Quality             AntiAliasQuality(Quality::QualityMax);
00496     QualityAttribute    AntiAliasQualityAttr(AntiAliasQuality);
00497     pRender->SetQuality(&AntiAliasQualityAttr,FALSE);
00498 
00499     // Render the background rectangle
00500     DialogColourInfo RedrawColours;
00501     pRender->SetLineColour(RedrawColours.DialogBack());
00502     pRender->SetFillColour(RedrawColours.DialogBack());
00503     pRender->DrawRect(pDocRect);
00504 
00505     // Draw the Saturation vs. Value square
00506     Path SquarePath;
00507     LinearFillAttribute ValueGradFill;
00508     LinearTranspFillAttribute TransFill;
00509 
00510     ValueGradFill.Colour    = DocColour(255L, 0L, 0L);
00511     ValueGradFill.EndColour = DocColour(255L, 255L, 255L);
00512 
00513     DocCoord ThePoint(pDocRect->lo.x, pDocRect->hi.y);
00514     ValueGradFill.SetStartPoint(&ThePoint);
00515     ThePoint = DocCoord(pDocRect->hi.x, pDocRect->hi.y);
00516     ValueGradFill.SetEndPoint(&ThePoint);
00517     ValueGradFill.SetEndPoint2(NULL);
00518 
00519     pRender->SetFillGeometry(&ValueGradFill, FALSE);            // Set Grad-filled
00520 
00521     //pRender->DrawRect(pDocRect);
00522 
00523 /*      SquarePath.Initialise(12, 12);
00524         SquarePath.FindStartOfPath();
00525 
00526         SquarePath.InsertMoveTo(ValSatSquare.lo);
00527         SquarePath.InsertLineTo(DocCoord(ValSatSquare.hi.x, ValSatSquare.lo.y));
00528         SquarePath.InsertLineTo(ValSatSquare.hi);
00529         SquarePath.InsertLineTo(DocCoord(ValSatSquare.lo.x, ValSatSquare.hi.y));
00530         SquarePath.IsFilled = TRUE;
00531 
00532         pRender->DrawPath(&SquarePath);     // Render the value square
00533 
00534         // Render a white linear-grad-transparency square over the top to get the
00535         // effect of the Saturation gradient
00536         pRender->SetFillColour(DocColour(0L, 0L, 0L));
00537 
00538         // Set transparency to circular 0% at center, 100% at radius, && plot it
00539         TransFill.SetStartPoint(&ValSatSquare.hi);
00540         ThePoint = DocCoord(ValSatSquare.hi.x, ValSatSquare.lo.y);
00541         TransFill.SetEndPoint(&ThePoint);
00542         TransFill.SetEndPoint2(NULL);
00543         TransFill.Transp        = 255;
00544         TransFill.EndTransp     = 0;
00545         TransFill.TranspType    = 2;        // 'Stained glass' transparency
00546 
00547         pRender->SetTranspFillGeometry(&TransFill, FALSE);
00548   */
00549 
00550 
00551     pRender->SetLineColour(RedrawColours.TextFore());
00552 
00553     SetAttributes(pRender);
00554     pRender->SetLineWidth((INT32)((double)Width * 0.8));
00555     DrawItem(pRender, *pDocRect);
00556 
00557     pRender->RestoreContext();
00558 }

void StrokeTypeItem::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 185 of file sgstroke.cpp.

00186 {
00187     // Set a 16pt line width - nice & thick
00188     pRegion->SetLineWidth(16000);
00189 
00190     // Set the line width (this overrides the "default" line width set by the caller).
00191     pStrokeDef->Render(pRegion, FALSE);
00192 }

void StrokeTypeItem::UpdateGalleryItem  )  [virtual]
 

Updates the gallery item's cached data to represent any changes this Stoke might have had done to it. Also redraw the gallery if necessary.

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

Definition at line 574 of file sgstroke.cpp.

00575 {
00576     StrokeDefinition *pStroke = GetStrokeDefinition();
00577     if(pStroke != NULL)
00578     {
00579         SetDescription(pStroke->GetStrokeName());
00580     }
00581 
00582     ForceRedrawOfMyself();
00583 }


Member Data Documentation

StrokeTypeAttrValue* StrokeTypeItem::pStrokeDef [private]
 

Definition at line 152 of file sgstroke.h.


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