Objective Chart : PART I User’s Guide : Chapter 12 Objective Chart and MFC : The View Classes
The View Classes
Objective Chart provides four view classes that support user interaction with the chart. SRGraphView and SRGScrollView are derived from CView and CScrollView, respectively. SREGraphView and SREScrollView are specialized versions of SRGraphView and SRGScrollView that can be embedded in non-view type windows such as a control in a dialog box. Each of the view classes also includes handlers for several chart-specific menu commands.
As provided, the view classes, SRGraphView and SRGScrollView, do assume that the SRGraph object is stored in the document (a CGraphDoc in fact). This is only necessary to support the Communication Document feature that allows data in other documents to be updated when data items on a graph are changed by dragging. These view classes are easily overridden to use any SRGraph object.
To use SRGraphView or SRGScrollView without a CGraphDoc:
1. Override the GetGraph() function to return a pointer to the SRGraph object, wherever it is stored.
2. Call SetHasDocument(FALSE), usually in the view constructor, to disable the CommDoc feature.
SRGraphView
Based on the standard MFC CView class, this specialized view class performs a number of useful functions that many chart applications require. It handles feedback from mouse positions, data zooming, print pagination, print preview, and chart tips as well as handling the display of the chart.
SRGScrollView
SRGScrollView enhances CScrollView in the same way that SRGraphView enhances CView. It implements the same functionality in a scrollable window. SRGScrollView can be used to display large graphs or charts with fine detail.
SREGraphView
SREGraphView is a simple derivative of SRGraphView that does not require a document or a frame window. It can be used to embed a chart on a CStatic control in a dialog box or form view, as well as in other types of windows.
SREGraphView has a public member, SRGraph* m_pGraph, that must be set to point to an existing SRGraph object (wherever it is stored) before the view is drawn. Typically, this pointer would be set in OnInitialUpdate().
If the SREGraphView object is not used in a dialog or form view, the member function SetAutoDelete(TRUE) must be called so that the view object is deleted when its window is destroyed. If the SREGraphView object has a parent CDialog or CFormView, then the parent takes care of deleting the object and m_bAutoDelete should be FALSE, the default value.
SREScrollView
SREScrollView is a derivative of SRGScrollView that can be used in a dialog box or form view or other windows outside the document/view framework. Like SREGraphView, the m_pGraph member and SetAutoDelete() flag must be set appropriately.