CODRulerWrapper_T Class

class CODRulerWrapper_T: public MvcWrapper_T, public MouseAdapter

This template class decorates a  CODViewport with a horizontal and vertical ruler in the left and top margins. This class maintains a pointer to a  CODRulerComponent for both the horizontal and vertical ruler. The virtual methods  CreateHorizontalRuler and  CreateVerticalRuler are used to create the horizontal and vertical rulers. These methods can be overriden by derived classes in order to supply a CODRulerComponent derivative for one or both rulers. The rectangle area formed by the intersection of the horizontal and vertical rulers is filled by a  CODComponent object that is created by  CreateRulerIntersection. By default, the ruler intersection is a  CODRectComponent. As with the ruler components, derived classes can override the creation of the intersection component and supply any type of CODComponent derivative.

The ruler components can be accessed using  GetHorizontalRuler and  GetVerticalRuler. Line, fill, and font properties can be set on the horizontal and vertical rulers using these accessor methods. For example, one can use the following syntax -

GetHorizontalRuler()-&gtSetValue(OD_PROP_FILL+OD_FILL_COLOR, RGB(0,255,0));

to set the color of the horizontal ruler to green.

One or both of the rulers can be hidden by setting the visible flag on the ruler component. A given ruler will also be invisible if its create method returns NULL. The function  SetRulerVisible is a convenience function that calls  CODComponent::SetVisible for a specified ruler to show or hide it.

The  SetRulerWidth method can be used to set the width of the rulers in real-world measurements. The measurement is converted into logical units using IODRuler::MeasureToLog and used to set the height of the horizontal ruler and the width of the vertical ruler.

The  CalcMargins method also uses the ruler width to determine the left and top margin values for the viewport wrapper. Note that  CalcMargins must convert the logical units into device units using LPtoDP, so it cannot be called until the viewport is connected to a valid window.

The function  RulerTrackPoint draws a vertical line on the horizontal ruler and a horizontal line on the vertical ruler to track a given point in the viewport. It is called as mouse move events are received, in order to track the current position of the mouse. The function  RulerTrackRect is similar to RulerTrackPoint, but it projects a given rectangle in the viewport onto the rulers. This class overrides  CODViewport::TrackMovement and  CODViewport::EraseTracking and calls RulerTrackRect in order to project the bounding rectangle of the moving components onto the rulers.

Defined in: OdRulerWrapper.h

Class Template Arguments

base_t

The class of the visual part to derive from.

Class Members

 CODRulerWrapper_T()

Construct a ruler wrapper.

virtual  ~CODRulerWrapper_T()

Destructor.

CODMeasure m_mRulerWidth

Width of rulers in real world units.

CODRulerComponent* m_pHorzRuler

Horizontal ruler component.

CODRulerComponent* m_pVertRuler

Vertical ruler component.

CODComponent* m_pRulerIntersection

Ruler intersection component.

BOOL m_bRulerTrackingEnabled

Boolean that indicates if ruler tracking is enabled or disabled.

COLORREF m_crRulerTracking

Color used for tracking on rulers.

CPoint m_ptLastTrackingPoint

Last point the was tracked on the ruler.

BOOL m_bEraseRulerTrackingPoint

Flag to indicate if ruler tracking must be erased.

CRect m_rcLastTrackingRect

Last rectangle that was tracked on the ruler.

BOOL m_bEraseRulerTrackingRect

Flag to indicate if ruler tracking must be erased.

virtual CODRulerComponent*  CreateHorizontalRuler(IODRuler* pIRuler)

Create the horizontal ruler component.

virtual CODRulerComponent*  CreateVerticalRuler(IODRuler* pIRuler)

Create the vertical ruler component.

virtual CODComponent*  CreateRulerIntersection()

Create the ruler intersection component.

CODRulerComponent*  GetHorizontalRuler()

Return a pointer to the horizontal ruler component.

CODRulerComponent*  GetVerticalRuler()

Return a pointer to the vertical ruler component.

CODComponent*  GetRulerIntersection()

Return a pointer to the ruler intersection component.

virtual void  SetRulerWidth(const CODMeasure& mRulerWidth)

Set the horizontal and vertical ruler width using a measurement.

void  SetRulerVisible(const int nOrientation, const BOOL bVisible)

Turn visibility for a given ruler on or off.

void  EnableRulerTracking(const BOOL bEnable)

Sets a flag that indicates whether ruler tracking is enabled or disabled.

void  SetRulerTrackingColor(const COLORREF crCursorTracking)

Set the color used for ruler tracking.

virtual void  DrawRulers(CDC* pDC)

Draw the rulers to a device context.

virtual void  DrawRulerIntersection(CDC* pDC)

Draw the ruler intersection to a device context.

virtual void  PrepareRulerDC(CDC* pDC, const int nOrientation)

Prepare a device context for either the horizontal or vertical ruler.

virtual void  PrepareRulerIntersectionDC(CDC* pDC)

Prepare a device context to draw the ruler intersection component.

CRect  CalcMargins()

Calculate the margins based on the ruler width.

virtual void  RulerTrackPoint(CDC* pDC, const CPoint& pt)

Draw projection of a given point in the viewport onto the rulers.

virtual void  RulerTrackRect(CDC* pDC, const CRect& rect)

Draw projection of a given rectangle in the viewport onto the rulers.

virtual BOOL Create(CWnd* pWnd, sfl::MvcVisualPart* pContainer)

Creates the viewport and optional controller.

virtual void  CalculateLogicalUnits(CDC* pDC)

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

virtual void SetVirtualOrigin(int x,int y)

Set the virtual origin of the viewport in logical units.

virtual void  SetVirtualSize(int cx,int cy)

Set the virtual size of the viewport in logical units.

inline void  SetVirtualSize(const CSize& szVirtual)

Set the virtual size of the viewport in logical units.

virtual CSize  SetSize(int cx, int cy)

Set the width and height of the viewport in the device units.

inline CSize  SetSize(const CSize& sz)

Set the width and height of the viewport in the device units.

virtual void InvalidateVisual(sfl::IVisual* pVisual, BOOL bErase = TRUE, BOOL bRepairNow = FALSE)

Invalidate the specified visual component.

virtual void  InvalidateRect(const CRect& rcLog, BOOL bErase = TRUE, BOOL bRepairNow = FALSE)

Invalidates the specified rectangle of this viewport in logical coordinates.

virtual void  Draw(CDC* pDC)

Draw the viewport and rulers to a device context.

virtual void  Erase(CDC* pDC)

Erases the viewport contents.

virtual bool  OnMouseMove(UINT nFlags, POINT pt)

Handle mouse move events.

virtual BOOL  TrackMovement(CODComponentSetTracker* pSetTracker, int nOffsetX, int nOffsetY)

Draws the tracking for components that are being moved.

virtual void  TrackScaling(CODComponentSetTracker* pSetTracker, float fScaleX, float fScaleY, OD_CONTROL_POINT nControlPoint)

Draws the tracking for components that are being scaled.

virtual OD_MOVEVERTEX_RC  TrackMovingVertex(CODComponentSetTracker* pSetTracker, int nVertexIndex, int nOffsetX, int nOffsetY)

Draws the tracking for a component whose vertex is being moved.

virtual void  EraseTracking(CODComponentSetTracker* pSetTracker)

Draw tracking for a set of components.