You are on page 1of 1

CHAPTER 4: Graphics Graphic attributes 129

 If there is an IGraphicAttributeUtils::Create<XXX>Command method for the attribute you want to


apply, call that method, passing the attribute value. These methods create
kGfxApplyAttrOverrideCmdBoss or kBoss_GfxStateApplyROAttributeCmd internally.

 Create an appropriate command. For information on what such a command should do, see “Applying
graphic attributes to the active selection”. If the attribute you want to apply is a rendering attribute,
use kBoss_GfxStateApplyROAttributeCmd; if the attribute is not a rendering attribute, use
kGfxApplyAttrOverrideCmdBoss. Process the command.

Sample code

 BscDNDDragSource

 BscShpActionComponent

Related APIs

 Graphic attributes — IGraphicsAttributeUtils

 CmdUtils

 CreateObject

Getting one graphic attribute of a page item


You can get a specific graphic attribute value, like stroke weight or fill color, from a page item.

Solution

1. Acquire IGraphicStyleDescriptor by querying the interface on the page item.

2. Look for an appropriate Get method on IGraphicAttributeUtils; for example, GetStrokeWeight for
stroke weight. If such a method exists, call it to get the attribute value.

3. If no Get method is available for the graphic attribute you want, call that QueryAttribute method on
the IGraphicStyleDescriptor directly, passing in the attribute ClassID and interface ID of the attribute
value.

Sample code

SnpManipulateGraphicAttributes

Related APIs

IGraphicsAttributeUtils

Getting all graphic attributes of a page item


You can get a list of all graphic attributes of a page item.

You might also like