TTool manages the overall tool appearance and behavior.
MToolTarget defines what a tool works on.
TToolInteractor is created by the tool to respond to input and take appropriate action (usually a command).
Command classes are created by interactors to change tool targets.
TToolCommandBinding binds a command to a tool target.
MToolHandler services the needs of tools, and represents the part of the application that supports cursor tools.
TToolNegotiator determines when a tool will work on an application and
invoke it.
One current tool is associated with the mouse device at any given time. When a mouse event is detected at a point on the canvas, the Cursor Tools framework identifies the cursor tool bound to the mouse device. The identified cursor tool provides information to the Cursor Tools framework on how it works and the type of selection on which it works.
NOTE Currently each document has its own current tool. Any application in the document can create a new tool and make it the current tool.
Applications in a document explicitly support cursor tools by dispatching positionally targeted events, such as mouse events, to a tool negotiator on a viewbyview basis so that an application can have some views that support cursor tools and other views that do not. Each view designates a tool handler to answer requests of the Cursor Tools framework.
TCanvasView overrides the TView::DispatchPositionalEvent function to delegate the handling of all positionally targeted events to the Cursor Tools framework. An example of a positionally targeted event is a mouse down at a point on the canvas to begin drawing a specific canvas graphic.
TCanvasView mixes in MToolHandler and identifies itself to the Cursor Tools framework as the application tool handler. The Cursor Tools framework determines when a tool is prepared to work on the canvas view (for example, draw the canvas graphic) and calls the canvas view back as a tool handler. The Cursor Tools framework calls one of two MToolHandler functions depending on the tool type, which are CreateToolTarget or CreateToolInteractor as shown in Figure 20
The Cursor Tools framework handles events dispatched to it from an application by identifying the current tool, determining if the tool will work with the event, and if the application can support the current tool.
Cursor tools work on targets. Each cursor tool specifies the type of target that it supports and relies on the interface of the target class to perform the necessary actions (drawing, selecting, or whatever). When a tool attempts to work at a specific location in a view of an application that supports tools, the Cursor Tools framework asks the application's tool handler to create a target of the type that the tool wants at that location. If the application can, it creates and returns a target for the cursor tool to work on.
If the application succeeded in creating an acceptable target, the Cursor Tools framework invokes the cursor tool. The cursor tool creates and starts an interactor, which in turn, binds and executes a command against the target. By modifying the target, the cursor tool changes the application data.
[Contents]
[Previous]
[Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.