Creating the view

A content view works in conjunction with a model to display data. The model contains the data, and the primary responsibility of the content view is to visually display that data. To display the data in a given model, you need a view that knows how to display the data in that model. When a document is opened, the Presentation framework streams in the model and then creates an instance of the view associated with the model. The view should be able to do the necessary conversion from the model's raw data to the visual representation, interpreting color, layout, and so on.

To display the data in a TTilesModel, the Tiles program has a TTilesView. TTilesView maps each kind of tile (rock, paper, or scissors) to a particular MGraphic, or drawable object. When TTilesView is constructed, it calls a protected function that builds an MGraphic for each kind of tile, and stores these objects in an array.

The primary TTilesView function is DrawContents, the function that the framework calls whenever the display needs to be redrawn. The DrawContents function:

  1. Gets read-only access to the TTilesModel
  2. Reads the data from the model using the model's public accessor functions
  3. Displays the data, using the map of MGraphic objects to choose the correct drawable object
TTilesView inherits from TDocumentComponentView, the standard view class provided by the Presentation framework. TDocumentComponentView builds on the functionality provided by TContentView, one of the primary view classes provided by the Desktop frameworks.



[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