CMvcLogicalPart Class

class CMvcLogicalPart: public _Base, public ILogCoordinatesImpl, public IZoom

An MvcLogicalPart is a type of visual part that establish its own logical coordinate system and adds support for zooming and panning. You may already be familar with a logical coordinate system from MFC's CScrollView and the SetWindowExt/SetViewportExt members of the CDC. It is basically the same idea. The logical part establishes a unit of measure which it uses to measure and draw to its client area. That unit of measure may be pixels, inches, millimeters or something application-specific. When the logical part is instructed to draw itself, it first prepares the given DC so that its units of measure are in effect for its subsequent drawing.

The logical part maintains a ratio which defines the number of logical units per unit in the container. In other words, the container may have its own logical coordinate system which is different than this logical parts. The logical part uses this ratio to map from the parent's units to its own and vice versa. This mapping ratio is officially known in Windows parlence as the "extents". It is important to recognize that extents are not the same as size. The extents specify a very simple ratio that allows us to transform a logical point or size to a container point or size and vice versa. For example, an extent would specify "5 logical units map to 2 container units on the X axis". The logical part maintains an extents structure which stores these ratios for the X and Y axes. The extents struct is used by the LPtoCP and CPtoLP members to map logical points and sizes in the logical part to points and size in the container and vice versa.

There is another important characteristic of MvcLogicalPart: they can be nested. Like any visual component, a logical part can be a child of another logical part. This means a child can establish an entirely different mapping mode than its parent. For example, the parent could measure its client area in inches, while its child measures its own client area in twips.

Defined in: MvcLogicalPart.h

Class Template Arguments

_Base

Base class for the logical part.

Class Members

float m_fScaleWidth

The horizontal scaling factor

float m_fScaleHeight

The vertical scaling factor

CPoint TopLeftLog() const

Returns top, left edge of logical bounds.

CPoint TopRightLog() const

Returns the top-right edge of the logical bounds

CPoint BottomLeftLog() const

Returns bottom, left edge of logical bounds

CPoint BottomRightLog() const

Returns bottom, right edge of logical bounds

CPoint GetLogCenter() const

Returns the current center point in logical units

virtual void SetLogCenter(int x, int y)

Center the logical rectangle about the given point

CRect GetClippedLogBounds() const

Returns the logical bounds as a rectangle clipped to the virtual size

virtual void SetAxisExtents(MvcAxis axis, int logical, int container)

Sets the logical and container extents for an axis

virtual void GetAxisExtents(MvcAxis axis, int& logical, int& container)

Gets the logical and container extents for an axis

virtual CSize SetLogScaling(float fScaleWidth=(float)1.0, float fScaleHeight=(float)1.0)

Set scaling ratio for the logical extents

virtual CSize ScaleRelative(float fScaleWidth=(float)1.0, float fScaleHeight=(float)1.0)

Sets the scaling factors relative to their current value

virtual CSize SetMagnification(const int nPctX, const int nPctY)

Set logical scaling as percent magnification.

virtual CSize GetMagnification() const

Get logical scaling as percent magnification.

virtual CSize IncreaseMagnification(const int nPctX, const int nPctY)

Increase logical scaling by a percentage

virtual CSize DecreaseMagnification(const int nPctX, const int nPctY)

Decrease logical scaling by a percentage

virtual void ZoomExtents(CSize& szWndExt, CSize& szVpExt) const

Adjust window and viewport extents for magnification.

virtual CRect Pan(int xOff,int yOff)

Moves this logical part's defining logical rectangle by the specified deltas

virtual void LineUp(BOOL bVertical = TRUE)

Moves one line up.

virtual void LineDown(BOOL bVertical = TRUE)

Moves one line down.

virtual void PageUp(BOOL bVertical = TRUE)

Moves one page up.

virtual void PageDown(BOOL bVertical = TRUE)

Moves one page down.

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

Invalidate the specified component's entire rectangle