CODRulerComponent Class

class CODRulerComponent: public CODPointComponent

The ruler component draws either a horizontal or vertical ruler within its bounds. In order to perform conversions, the ruler component is passed a pointer to an  IODRuler interface. The unit of measurement used for the ruler is determined by calling IODRuler::GetUnitOfMeasure on the ruler interface passed in. The OD_PROP_RULER_ORIENTATION property determines whether the ruler is horizontal or vertical. The OD_PROP_RULER_ORIENTATION property can be set to either odg_nHorizontalRuler or odg_nVerticalRuler. The  OnDraw method draws the hash marks and numbers on the ruler.

The ruler can draw up to 7 levels of detail. Each level of detail is a set of hash marks that are separated by a given increment value determined by the unit of measure. For example, the levels of detail for inches are 36, 12, 1, 1/2, 1/4, 1/8 and 1/16 inches. The OD_PROP_LOWER_DETAIL_THRESHOLD and OD_PROP_UPPER_DETAIL_THRESHOLD properties specify the minimum and maximum number of pixels that a given level of detail must occupy in order to be drawn on the ruler. In other words, if a given level of detail is too small or too large it isn't drawn.

The following properties are added to the component by this class:

OD_PROP_FILL, OD_PROP_LINE, OD_PROP_FONT, OD_PROP_RULER_ORIENTATION, OD_PROP_UPPER_DETAIL_THRESHOLD, OD_PROP_LOWER_DETAIL_THRESHOLD

Defined in: OdRulerComp.h

See Also

Component Property Identifiers

Class Members

 CODRulerComponent(IODRuler* pIRuler = NULL)

Constructor.

 CODRulerComponent(const CODRulerComponent& src)

Copy constructor.

virtual  ~CODRulerComponent()

Destructor.

IODRuler* m_pIRuler

Pointer to ruler object for unit of measure and conversions.

CPoint m_ptRulerOrg

Point on ruler that represents the origin.

CFont* m_pVerticalFont

Rotated font used for drawing vertical ruler.

BOOL  Create(const int nOrientation, const CRect& rcBounds)

Creates the ruler component.

void SetRuler(IODRuler* pIRuler)

Sets the ruler interface.

int  GetOrientation() const

Return the ruler orientation

CODRulerComponent&  operator=(const CODRulerComponent& src)

Assignment operator.

virtual CODComponent*  Dup() const

Create a duplicate copy of this object.

CRect  GetLocalBounds() const

Gets the local points to the given logical rectangle.

BOOL  SetLocalBounds(const CRect& rect)

Sets the local points to the given logical rectangle.

virtual void  OnPrepareDC(CDC* pDC)

Creates GDI objects and sets up the device context for drawing.

virtual void  OnCleanupDC(CDC* pDC)

Frees GDI objects and restores the state of the device context.

virtual void  OnDraw(CDC* pDC)

Draws the ruler component onto a device context.

virtual void  CalculateRgn(CODRgn* pRgn)

Calculates the bounding rectangle of the component.

virtual void  CalculateLogicalUnits(CDC* pDC)

Convert any real-world measurements, such as points, to logical units using the given device context.

virtual void  Serialize(CArchive& ar)

Serializes the label component.