Current selection management

There can be any number of selections in a GrafEdit application at any given time. Selections represent collections of canvas graphics in the canvas representation. One selection is identified as the current selection and is visually distinct in the user interface from the other selections. The current selection is the target for commands, particularly commands invoked from menus.

Adopting or setting

The current selection is adopted or set by calling AdoptCurrentSelection or SetCurrentSelection.

      void AdoptCurrentSelection( MCanvasSelection* aSelection );
      void SetCurrentSelection( MCanvasSelection& ) = 0;

Retrieving

The current selection is retrieved by calling CopyCurrentSelection.

    MCanvasSelection* CopyCurrentSelection () const;

Creating

A new empty selection is created by calling CreateEmptySelection.

    MCanvasSelection* CreateEmptySelection () const;
A simple GrafEdit program can implement the above functions based on an MCanvasSelection member variable in the canvas view. However, TStandardCanvasView delegates AdoptCurrentSelection and CopyCurrentSelection to the TStandardCanvasPresenterState, and CreateEmptySelection to the TStandardCanvasModel.

TCanvasView derived classes need to register for notifications of changes to the underlying representation and have the representation call functions to keep the canvas view in sync with the representation. TStandardCanvasView handles this for you.


[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