InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SnpGraphicHelper Class Reference

#include <SnpGraphicHelper.h>

Public Types

enum  JoinType { kJTMiter, kJTRound, kJTBevel }
 
enum  LineCap { kLCButt, kLCRound, kLCSquare }
 

Public Member Functions

 SnpGraphicHelper (const UIDList &itemList)
 
 SnpGraphicHelper (const UIDRef &itemRef)
 
virtual ~SnpGraphicHelper ()
 
ErrorCode ApplyAttributes ()
 
void Reset (const UIDList &itemList)
 
void Reset (const UIDRef &itemRef)
 
void AddStrokeWeight (const PMReal &strokeWeight)
 
virtual UID GetNamedSwatch (const PMString &swatchName, IDataBase *iDataBase)
 
void AddStrokeRendering (const UID &swatchUID)
 
void AddFillRendering (const UID &swatchUID)
 
void AddCornerImplementation (const ClassID &pathCornerClassID)
 
void AddCornerRadius (const PMReal &cornerRadius)
 
void AddLineImplementation (const ClassID &pathStrokerClassID)
 
void AddLineEndEndImplementation (const ClassID &pathEndStrokerClassID)
 
void AddJoinType (const SnpGraphicHelper::JoinType joinType)
 
void AddLineCap (const SnpGraphicHelper::LineCap lineCap)
 
void AddDashedValues (const K2Vector< PMReal > &dashAndGapValues)
 
IImageDataAccessQueryImageDataAccess ()
 
UIDRef GetGraphicFrame ()
 

Detailed Description

Helper methods to perform basics of manipulating graphics.

Graphic attributes control how a path is drawn.

Graphic attributes have a common parent boss class kGraphicsAttrBoss and have the signature interface IGraphicAttributeInfo. Check out the documentation page for interface IGraphicAttributeInfo for a list of all graphic attributes supported by the API.

The attributes applied to a page item can be accessed via the item's IGraphicStyleDescriptor interface.

IGraphicAttributeUtils is a facade that helps create, apply and detect graphic attributes. It provides helpers for the most common attributes like stroke weight, stroke and fill colour. If there is no wrapper method provided to create the graphic attribute you are interested in you need to use CreateObject a boss object of the necessary class and fill out its data interfaces. The sample code that deals with kDashedAttributeValuesBoss below shows an example of this.

kGfxApplyMultAttributesCmdBoss is a command that allows you to apply graphic attributes to a page item. You can apply as many attributes as you want by processing this command.

See Also
IGraphicAttributeUtils
kGfxApplyMultAttributesCmdBoss
IApplyMultAttributesCmdData
IGraphicAttributeInfo
IGraphicStyleDescriptor

Member Enumeration Documentation

Available line join types.

Available line caps.

Constructor & Destructor Documentation

SnpGraphicHelper::SnpGraphicHelper (const UIDListitemList)

Constructor.

Parameters
itemListidentifies the items the helper will target.
SnpGraphicHelper::SnpGraphicHelper (const UIDRefitemRef)

Constructor.

Parameters
itemRefidentifies a single item the helper will target.
SnpGraphicHelper::~SnpGraphicHelper ()
virtual

Destructor

Member Function Documentation

void SnpGraphicHelper::AddCornerImplementation (const ClassIDpathCornerClassID)

Controls corner effect drawing (rounded, fancy, bevelled, etc.). Corner effects are drawn by boss classes that aggregate an IPathCorner interface.

Parameters
pathCornerClassIDtype of corner effect (see IPathCorner).
void SnpGraphicHelper::AddCornerRadius (const PMRealcornerRadius)

Controls radius of corner effect.

Parameters
cornerRadiusradius in points the corner effect should draw with.
See Also
SnpGraphicHelper::AddCornerImplementation
void SnpGraphicHelper::AddDashedValues (const K2Vector< PMReal > & dashAndGapValues)

Controls the lengths of dashes and gaps when drawing dashed lines.

Parameters
dashAndGapValuesindex 0 gives length of dash, index 1 gives length of gap.
void SnpGraphicHelper::AddFillRendering (const UIDswatchUID)

Controls fill colour.

Parameters
swatchUIDspecifies the swatch (use ISwatchUtils or SnpGraphicHelper::GetNamedSwatch to locate the swatch you want to use).
void SnpGraphicHelper::AddJoinType (const SnpGraphicHelper::JoinType joinType)

Controls how line joins draw.

Parameters
joinType
void SnpGraphicHelper::AddLineCap (const SnpGraphicHelper::LineCap lineCap)

Controls how the end of lines draws.

Parameters
lineCap
void SnpGraphicHelper::AddLineEndEndImplementation (const ClassIDpathEndStrokerClassID)

Controls line end effects like arrowheads and circles. Path ends are drawn by boss classes that aggregate an IPathEndStroker interface.

Parameters
pathEndStrokerClassIDtype of path end stroker.
void SnpGraphicHelper::AddLineImplementation (const ClassIDpathStrokerClassID)

Controls whether path draws as a solid, dashed or dotted line or another custom line effect. Paths are drawn by boss classes that aggregate an IPathStroker interface.

Parameters
pathStrokerClassIDtype of stroker (see IPathStroker).
void SnpGraphicHelper::AddStrokeRendering (const UIDswatchUID)

Controls stroke colour. Note if the stroke has no colour it won't get rendered.

Parameters
swatchUIDspecifies the swatch (use ISwatchUtils or SnpGraphicHelper::GetNamedSwatch to locate the swatch you want to use).
void SnpGraphicHelper::AddStrokeWeight (const PMRealstrokeWeight)

Controls stroke weight.

Parameters
strokeWeightdesired stroke weight.
ErrorCode SnpGraphicHelper::ApplyAttributes ()

Apply the graphic attributes. Use the method like this:

SnpGraphicHelper graphicsHelper(itemList); graphicsHelper.AddStrokeWeight(4.0); UID swatchUID = graphicsHelper.GetNamedSwatch(PMString("Black"), itemList.GetDataBase()); graphicsHelper.AddStrokeRendering(swatchUID); graphicsHelper.ApplyAttributes();

Returns
kSuccess on success, other ErrorCode otherwise.
UIDRef SnpGraphicHelper::GetGraphicFrame ()

Get graphic frame of a single graphic frame or item. Note: if the helper is constructed with multiple items, only the first frame is returned

Returns
UIDRef of the graphic frame.
We are not sure if the selection is the frame or the graphic item.

The following sample shows code segment returning an UIDRef of the graphic frame no matter which is selected. A reverse of QueryImageDataAccess() method

UID SnpGraphicHelper::GetNamedSwatch (const PMStringswatchName,
IDataBaseiDataBase 
)
virtual

Get the named swatch's UID from the specified database.

Parameters
swatchNamethe swatch name.
iDataBasethe database to check.
Returns
swatch UID of the specified swatch name, kInvalidUID if not found.
See Also
ISwatchUtils.
IImageDataAccess * SnpGraphicHelper::QueryImageDataAccess ()

Query graphic page item of a single graphic frame or item. Note: if the helper is constructed with multiple items, only the first item is returned

Returns
pointer to the graphic item.
We are not sure if the selection is the frame or the graphic item.

The following sample shows code segment returning an imagePtr pointing to the graphic item. This code checks for availability of IImageDataAccess, you are free to use other conditions, such as IID_IGRAPHICITEM.

void SnpGraphicHelper::Reset (const UIDListitemList)

Reset the items the helper will target, call this when you want to use a single instance of SnpGraphicHelper to target different items.

Parameters
itemListidentifies the items the helper will target.
void SnpGraphicHelper::Reset (const UIDRefitemRef)

Reset the item the helper will target, call this when you want to use a single instance of SnpGraphicHelper to target a different item.

Parameters
itemRefidentifies a single item the helper will target.