![]() | InDesign SDK 20.5 |
#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) |
| IImageDataAccess * | QueryImageDataAccess () |
| UIDRef | GetGraphicFrame () |
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.
Available line join types.
Available line caps.
| SnpGraphicHelper::SnpGraphicHelper | ( | const UIDList & | itemList | ) |
Constructor.
| itemList | identifies the items the helper will target. |
| SnpGraphicHelper::SnpGraphicHelper | ( | const UIDRef & | itemRef | ) |
Constructor.
| itemRef | identifies a single item the helper will target. |
| virtual |
Destructor
| void SnpGraphicHelper::AddCornerImplementation | ( | const ClassID & | pathCornerClassID | ) |
Controls corner effect drawing (rounded, fancy, bevelled, etc.). Corner effects are drawn by boss classes that aggregate an IPathCorner interface.
| pathCornerClassID | type of corner effect (see IPathCorner). |
| void SnpGraphicHelper::AddCornerRadius | ( | const PMReal & | cornerRadius | ) |
Controls radius of corner effect.
| cornerRadius | radius in points the corner effect should draw with. |
Controls the lengths of dashes and gaps when drawing dashed lines.
| dashAndGapValues | index 0 gives length of dash, index 1 gives length of gap. |
| void SnpGraphicHelper::AddFillRendering | ( | const UID & | swatchUID | ) |
Controls fill colour.
| swatchUID | specifies 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.
| joinType |
| void SnpGraphicHelper::AddLineCap | ( | const SnpGraphicHelper::LineCap | lineCap | ) |
Controls how the end of lines draws.
| lineCap |
| void SnpGraphicHelper::AddLineEndEndImplementation | ( | const ClassID & | pathEndStrokerClassID | ) |
Controls line end effects like arrowheads and circles. Path ends are drawn by boss classes that aggregate an IPathEndStroker interface.
| pathEndStrokerClassID | type of path end stroker. |
| void SnpGraphicHelper::AddLineImplementation | ( | const ClassID & | pathStrokerClassID | ) |
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.
| pathStrokerClassID | type of stroker (see IPathStroker). |
| void SnpGraphicHelper::AddStrokeRendering | ( | const UID & | swatchUID | ) |
Controls stroke colour. Note if the stroke has no colour it won't get rendered.
| swatchUID | specifies the swatch (use ISwatchUtils or SnpGraphicHelper::GetNamedSwatch to locate the swatch you want to use). |
| void SnpGraphicHelper::AddStrokeWeight | ( | const PMReal & | strokeWeight | ) |
Controls stroke weight.
| strokeWeight | desired 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();
| 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
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
Get the named swatch's UID from the specified database.
| swatchName | the swatch name. |
| iDataBase | the database to check. |
| 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
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 UIDList & | itemList | ) |
Reset the items the helper will target, call this when you want to use a single instance of SnpGraphicHelper to target different items.
| itemList | identifies the items the helper will target. |
| void SnpGraphicHelper::Reset | ( | const UIDRef & | itemRef | ) |
Reset the item the helper will target, call this when you want to use a single instance of SnpGraphicHelper to target a different item.
| itemRef | identifies a single item the helper will target. |