Symbols can also be created programmatically. Remember, a symbol is a component that has the capability of linking to another symbol and of bearing a label. Each component can also act as a composite, which means it can consist of other components. Usually, a symbol is a collection of primitive components.
You can create a new symbol by adding subcomponents to it. You can collect subcomponents into a set and then pass it to the Create() method, as in Example 12.
CODSymbolComponent* pNewSymbol = new CODSymbolComponent(); pNewSymbol->Create(&setComponents); |
Or, you can add the subcomponents one by one using the AppendChild() or InsertChild() methods, as in Example 13.
CODImageComponent* pImageComp = new CODImageComponent(); pImageComp->Create(IDR_IMAGE1, pDC); CODSymbolComponent* pNewSymbol = new CODSymbolComponent(); pNewSymbol->AppenChild(pImageComp) |
Remember that each composite component has its own coordinate system. If you added a rectangle with corners at (0,0) and (10,10), it would appear at the top left corner of the symbol whenever the symbol is displayed on the screen.
Copyright © Rogue Wave Software, Inc. All Rights Reserved.
The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.