Objective Views : Chapter 9 Properties : Property Objects
Property Objects
Objective Views stores property values as objects in a cache. The CODProperty class is the base class for property values. Classes derived from CODProperty represent either specific data types or nested properties. A nested property is a container for other property values. The CODProperty class ties a property value and a property ID into a single object.
Property value objects are usually accessed only through a property container interface. The CODComponent class does provide methods for accessing property value objects directly, however it is usually more convenient to get and set property values through the property container interfaces. It is sometimes useful to manipulate nested or compound properties directly.
The description of a property is maintained by a separate object, which is an instance of the CProperty class defined by the SFL Properties package. The CProperty class implements the IProperty interface, which provides access to the ID, name, description, data type, and other information that describes a property. Storing the value of a property separately from its registered description is more efficient in terms of space. The CODProperty class and its derivatives only store the property ID and property value and should not be confused with SFL’s CProperty class and IProperty interface. The CODProperty class and its derivatives are described below.
CODProperty
The CODProperty class is the base class for property values. It stores a property ID and has a group of GetValue() and SetValue() methods for storing and retrieving the property value. The GetValue() and SetValue() methods are overloaded for various data types and the default implementation for these methods throws the exception CODPropertyConversionException. Classes derived from CODProperty override the appropriate GetValue() and SetValue() methods. Classes derived from CODProperty represent either specific data types such as string, integer, or Boolean properties or they represent nested properties. A nested property is a property that contains other property values and implements the IODPropertyContainer interface.
CODBoolProperty
The Boolean property represents a simple Boolean value.
CODEditProperties
The edit properties determine what actions the end-user can take on a particular component. This is a nested property that contains the following sub-properties.
OD_EDIT_READONLY – Indicates if the component can be modified.
OD_EDIT_CANSELECT – Indicates if the component can be selected.
OD_EDIT_CANMOVE – Indicates if the component can be moved.
OD_EDIT_CANROTATE – Indicates if the component can be rotated.
OD_EDIT_CANSCALE – Indicates if the component can be scaled.
OD_EDIT_CANSTRETCH – Indicates if the component can be scaled out of proportion.
OD_EDIT_CANEDITPROPS – Indicates if the component’s properties can be modified.
OD_EDIT_CANCONTAIN – Indicates if the component supports containment.
OD_EDIT_CANEDITVERTICES – Indicates if the component’s vertices may be edited.
CODFillProperties
This is a nested property that describes the brush used to fill the interior of a component. Note that only components with closed interiors can be filled. The CODFillProperties class contains data members that describe a GDI brush. The CreateBrush() member function creates a brush using the fill properties and returns it to the caller. The GetBrush() member function returns a cached brush that matches the fill properties. The CODFillProperties class contains the following sub-properties.
OD_FILL_COLOR – RGB color value for brush.
OD_FILL_TRANSPARENT – Indicates whether to use transparent fill.
OD_FILL_STYLE – Indicates the GDI brush style (BS_SOLID, BS_HOLLOW, BS_HATCHED, BS_PATTERN, etc.)
OD_FILL_HATCH – Indicates the hatch style (HS_HORIZONTAL, HS_VERTICAL, HS_FDIAGONAL, etc.)
OD_FILL_BKMODE – Background fill mode (TRANSPARENT or OPAQUE)
OD_FILL_BKCOLOR – RGB color to use for background fill.
CODFontProperties
This is a nested property that describes the font used for text drawn by a component. The CODFontProperties class contains data members that describe a GDI font. The CreateFont() member function creates a font using the font properties and returns it to the caller. The GetFont() member function returns a cached font that matches the font properties. The CODFontProperties class contains the following sub-properties.
OD_FONT_FACE_NAME – Name of font (i.e. Times New Roman, Arial, etc.).
OD_FONT_POINT_SIZE – Size of font in points.
OD_FONT_COLOR – Text foreground color.
OD_FONT_WEIGHT – Font weight (FW_NORMAL, FW_BOLD, FW_THIN, etc.)
OD_FONT_ITALIC – Flag to indicate if italic should be used.
OD_FONT_UNDERLINE – Flag to indicate if underline should be used.
OD_FONT_STRIKEOUT – Flag to indicate if strikeout should be used.
OD_FONT_HEIGHT – Height of font in logical units.
Note that setting the point size of the font recalculates the font height and vice versa. The point size and the font height are two different ways of measuring the size of the font, so they are kept synchronized.
CODIntProperty
The integer property represents a simple integer value.
CODLineOrientation
The line orientation property determines the orientation of an object in relation to a line. This class can be used to orient labels and other components along a given line or link. CODLineOrientation is a nested property that contains the following sub-properties.
OD_LINEORIENTATION_PCTALONG – Percentage along the line
OD_LINEORIENTATION_ANCHOR – Anchor point
OD_LINEORIENTATION_DISTANCE – Distance or offset from line
The orientation consists of a percentage along the given line, an anchor point, and an offset value. The percentage along value is used to calculate a position on the line based on a percentage of the line length. The anchor point is an OD_CONTROL_POINT value that indicates the point on the label or component that should coincide with the calculated point on the line. The offset value is a distance in logical units away from the line to offset the final calculated point. This is a distance along an imaginary perpendicular bisecting line.
CODLineProperties
This is a nested property that describes the pen used to draw the lines and vector graphics of a component. The CODLineProperties class contains data members that describe a GDI pen. The CreatePen() member function creates a pen using the line properties and returns it to the caller. The GetPen() member function returns a cached pen that matches the line properties. The CODLineProperties class contains the following sub-properties.
OD_LINE_COLOR – RGB value indicating the color of the pen
OD_LINE_TRANSPARENT – Indicates if lines are transparent or not
OD_LINE_WIDTH – Width of the pen in points
OD_LINE_STYLE – Pen style (PS_SOLID, PS_DASH, PS_DOT, etc.)
It is important to note that due to limitations in the MFC graphics implementation, only lines of width zero (meaning they are always drawn one pixel wide) can have a style other than solid.
CODOrientationProperties
The orientation properties determine how a label component is positioned in relation to its associated symbol component. You can set label components to appear at a predefined place, such as centered below the symbol, or they can be free floating. CODOrientationProperties is a nested property containing the following sub-properties.
OD_ORIENTATION_CTLPOINT – An OD_CONTROL_POINT value that indicates a position on the bounds of a component.
OD_ORIENTATION_HORZSPACING – Horizontal offset from the control point.
OD_ORIENTATION_VERTSPACING – Vertical offset from the control point.
CODStringProperty
The string property represents a simple string value.