CMvcViewport Class

class CMvcViewport: public IMvcViewport, public IEventRouterImpl

This template is used to define viewport classes that interact with a given type of model and controller. The base class template argument is usually a class that supports the IVisual interface. The model class template argument defines the type of model that the viewport will observe and render, and is usually strongly-typed. The controller class template argument defines the type of controller that the viewport interacts with. The association from the viewport to the controller is usually a weakly-typed one. Generally speaking, the viewport only needs to route events to the controller.

This class inherits the IMvcViewport template interface, passing it the model class and controller class arguments.

This class also inherits the IEventRouter interface, so that it can route events to event listeners. Events are always routed to the controller. Derived viewport classes can override the RouteEvent method and implement custom routing.

Defined in: MvcViewport.h

Class Template Arguments

_Visual

Base class for the viewport.

_Model

Base class for models to be used with the viewport.

_Ctlr

Base class for controllers to be used with the viewport.

Class Members

CMvcViewport()

Viewport constructor.

virtual ~CMvcViewport()

Viewport destructor.

ModelClass* m_pModel

Pointer to the model.

ControllerClass* m_pCtlr

Pointer to the controller.

bool m_bAutoDelCtlr

Flag to indicate if controller should be deleted when the viewport is deleted.

virtual BOOL Create(HWND hWndParent, LPRECT rc)

Creates the viewport given a parent window and a rectangle.

virtual ModelClass* GetModel() const

Get a pointer to the model associated with this viewport.

virtual void SetModel(ModelClass* pModel)

Assign a model to the viewport.

virtual BOOL CreateController()

Create the default controller for this viewport.

virtual void SetController(ControllerClass* pController, const bool bAutoDelCtlr = false)

Set the controller for this viewport.

virtual ControllerClass* GetController()

Get a pointer to the controller for this viewport.

ULONG STDMETHODCALLTYPE AddRef()

Add a reference to this object.

ULONG STDMETHODCALLTYPE Release()

Release a reference to this object.

virtual void OnUpdate(ISubject* pSubject, IMessage* pMsg)

The function reacts to notifications of change on the subject it is observing.

virtual void OnPrepareDC(CDC* pDC)

Prepare graphics context for rendering.

virtual bool RouteEvent(IEvent* pIEvent)

Routes event objects to event listeners.