Stock Viewer subsystem

The Stock Viewer subsystem supports the Stock Viewer window. The user drags a stock name from the Stock Picker to the Stock Viewer to display graphed stock information.

In the current implementation of this program, stock data can be viewed in six formats: daily, weekly, or monthly summaries, by price or by volume. You might choose to provide support for additional views of stock data.

NOTE When a user first opens a Stock Viewer it automatically displays sample stock data.


The user launches a Stock Viewer document by opening a TViewerStationery object. The stationery creates a model and a presenter state which, in turn, creates a TViewerPresenter. This presenter creates a TViewerContentView and TGraphView.

When a user first opens the Stock Viewer, it automatically displays sample stock data. It creates a TLocalStockData object containing contrived stock information in the form of a TCollectionOf<TStockDay> object. The TLocalStockData object owns the contrived information and returns it in its CopyData function. For each TStockDay, semi-random values are generated for the high, low, closing price, and volume.

TDocumentComponentStationery objects create a model and presenter state and put them in a TDocumentComponent. The document component can then be embedded in a compound document. The RunDocument command instantiates the document component stationery object of your choice, creates and opens a compound document using the resultant document component.

The model and selection typically require a lot of support code. To reduce this work load, Stock Browser takes advantage of TAtomicModelOn and TAtomicSelectionOn when exporting stocks from the picker and storing the stock data for an individual stock in the Stock Viewer.

TAtomicModelOn and TAtomicSelectionOn are convenience classes designed to ease the burden of constantly deriving from TModel, TModelSelection and MDataExchanger when the data being modeled is a simple, atomic piece of data. For example, if you were creating a document that contained information about one employee only, you could use TAtomicModelOn<TEmployeeRecord> and TAtomicSelectionOn<TEmployeeRecord>. TAtomicModelOn provides generic functions for retrieving the modeled data for reading or writing, putting new data into the model and swapping the model data with new data.

TAtomicSelectionOn implements copy/paste functionality in a general way by replacing the model data with the pasted data, if it is of the same type. Data can't be orphaned from a TAtomicModelOn because TAtomicModelOn is designed to represent a piece of data--representing nothing violates this design.

TGUIPresenterState is the standard Presentation framework presenter state class. When you are creating a Presentation framework program, you derive from it to provide persistent presentation information for your document component.

The Stock Viewer uses TViewerPresenterState to hold on to the current graph constructor across sessions. When the user selects a graph constructor from the View menu, that graph constructor replaces the one in the presenter state. Each time TGraphView reconstructs its graph, it uses the graph constructor from the presenter state.

TPresenterStateSelection is used to specify the presenter state that is to be the target of a document component or presenter state command. It is used by the Stock Viewer as the target of a TSetGraphConstructorCommand, when such a command is executed to replace the presenter state's graph constructor object.

The main job of a presenter is to create the main content view and menus. TGUIPresenter is the standard Presentation framework presenter class from which Stock Viewer derives TViewerPresenter to create a TViewerContentView object as the main content view for the Stock Viewer document component. Because TViewerContentView requires a TGraphView object to display the model data in a graphical form, this presenter creates the TGraphView and adopts it into the TViewerContentView.

TGraphView owns a TStandardGraph object. When TViewerContentView receives notification of new stock data (which occurs when the stock data in the model changes) or a new graph constructor is selected by the user, it calls upon its TGraphView object to reconstruct its graph and then TViewerContentView calls Invalidate. This causes the view system to call TViewerContentView's and TGraphView's DrawContents function which redraws the graph and updates damaged or invalidated areas of the view.

TMenu is the CommonPoint class to use to provide menus.

TSetGraphConstructorCommand is a command class derived from TCommandOn. Using TCommandControlStateOn, the viewer puts the TSetGraphConstructorCommand objects in the View menu. When the user selects an item from the View menu, a TSetGraphConstructorCommand object is executed to replace the graph constructor in the presenter state.

TDOMDocumentComponentView is a view class that inherits and implements standard drag-and-drop behavior. This is a preliminary solution to the problem solved by the Taligent Selection Tool documented sample.

TDocumentComponentView is the standard view class to use when displaying model data in a Presentation framework program. It provides many helpful functions for getting the model or presenter state and their data.

TPriceDrawer (not shown) derives from TGraphDrawer and keeps its own copy of the stock information to be graphed. It displays a symbol indicating the high, low and closing price for each individual day of trading. TVolumeDrawer (not shown) derives from TBarDrawer and takes in its constructor a TCollectionOf<TStockDay> from which TBarDrawer extracts the volume information to be graphed.

TStockGraphConstructor is an abstract class which provides protocol for setting up a TStandardGraph with the right drawer objects. The concrete classes derived from TStockGraphConstructor parse the stock data and set up drawers that are appropriate to the type of graph being displayed.



[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker