Change notification

The canvas view presents an up-to-date display of canvas graphics in the representation. When the view holds a simple list, it is easy to stay up-to-date because whenever a change occurs, the view can call TView::Invalidate. However, when the data is stored in a model, more is required to keep the canvas view up-to-date with the data in the model because the model does not have access to the view.

Because GrafEdit programs are often built on top of a variety of underlying data sets, it is important to have the flexibility to decide which events are interesting and need to be connected to which types of view invalidation. For this purpose, the following functions are defined in TCanvasView:

      void TCanvasView::ConnectNotification
    ( TRequestBasedMemberFunctionConnectionTo aCanvasView ); void TCanvasView::RegisterNotificationInterest
    (TRequestBasedMemberFunctionConnectionTo aCanvasView); void TCanvasView::DisconnectNotification
    ( TRequestBasedMemberFunctionConnectionTo aCanvasView ); void TCanvasView::HandleUnknownNotification( const TNotification aNotification );
ConnectNotification and DisconnectNotification need be overridden only to replace the standard TRequestBasedMemberFunctionNotification with another type of notification, or to add additional connection and disconnection steps.

RegisterNotificationInterest is overridden to register interest and to define the associated functions to call. This function has a connection parameter. An implementation of this function should call AddInterest on this connection and pass it a TInterest instance that represents a type of event. Thereafter, any notifications associated with that interest will be received.

An optional function can be passed to AddInterest to identify which function to call for notifications associated with the interest. In this case, the identified function, which must be implemented in the canvas view derived class, is called whenever a notification for that interest is received. If the member function is not provided, then HandleUnknownNotification is called and should be implemented.


[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