Deriving a presenter class

In this step, instead of using TGUIPresenterFor<TTilesView> directly, the Tiles document component uses a presenter derived from TGUIPresenterFor<TTilesView>--TTilesPresenter--that builds a menu specifically for the Tiles program. TGUIPresenterFor<AView> derives from TGUIPresenter, which provides functions called by the Presentation framework to build menus and to control their behavior. You override these functions to build and manage the extended Tiles menu:


You determine which functions to override and how to implement them based on whether you built the menu with the cpConstructor tool. The cpConstructor tool puts interface elements into an archive associated with your program, so if you build the menu with the cpConstructor tool your presenter needs to retrieve the menu from that archive. If you don't want to build your menu using the cpConstructor tool, your presenter needs to build the Tiles menu programmatically.

You also implement menu items differently based on whether the menu was archived or not:

Overriding TGUIPresenter functions

To add menus to the presentation for a document component, you need to override HandleMenuActivate and HandleMenuDeactivate. The Presentation framework calls these functions whenever a presentation on your document component is activated or deactivated:

HandleMenuActivate and HandleMenuDeactivate should also call the parent functions to activate and deactivate any inherited menus.

You need to override the functions HandleMenuAction and HandleCurrentSelectionChange only when you reconstruct menus from an archive:

Storing the menu

TTilesPresenter uses a special helper class, TMenuHolder, to facilitate storing and activating the Tiles menu. TMenuHolder stores menu items and provides functions that activate and deactivate them. The TTilesPresenter HandleMenuActivate function builds the menu and stores it in a TMenuHolder object:


For more information about this class, you can examine the code in the files MenuHolder.h and MenuHolder.C in the directory ./TilesTutorial/05.Menus/Tiles.


[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