canvas::edit::rectangle - Editing a rectangle on a canvas
This package provides a class whose instances handle editing a rectangle on a canvas. Instances can be configured with regard to the visual appearance of the markers denoting the rectangle's corners. Note that instances do not store the edited rectangle themselves, but delegate this to a configurable object.
The rectangle editor internally uses an instance of package canvas::edit::points, and inherits all the options and behaviours for it. The color options are additionally applied to the rectangle element of this editor
Beyond that it provides an option, -rect-config, to customize the rectangle item used to render the rectangle through its corners. Note that it cannot overide the inherited color options.
During interaction instances execute a state machine where the user creates two points, at which point the system completes the rectangle with the missing corners and reports it. At that point the system prevents adding more points. Dragging the points is still possible, enabling resizing and moving the rectangle. Deleting any corner deletes the entire rectangle, at which point the system is again ready for the creation of a new rectangle from two points.
This, the class command, creates and configures a new instance of a rectangle editor, named objectName. The instance will be connected to the specified canvas widget.
The result of the command is the fully qualified name of the instance command.
The options accepted here, and their values, are explained in the section Options.
Instances of the rectangle editors provide the following API:
This method destroys the rectangle editor and releases all its internal resources.
Note that this operation does not destroy the items the editor managed on the attached canvas, nor the canvas itself.
The result of the method is an empty string.
This method activates editing of the rectangle on the canvas. This is the default after instance creation. A call is ignored if the editor is already active.
The result of the method is an empty string.
The complementary method is disable. The interogatory method for the current state is active.
This method disables editing of the rectangle on the canvas. A call is ignored if the editor is already disabled.
The result of the method is an empty string.
The complementary method is enable. The interogatory method for the current state is active.
This method queries the editor state.
The result of the method is a boolean value, true if the editor is active, and false otherwise, i.e. disabled.
The methods to change the state are enable and disable.
This method programmatically set the rectangle from the border coordinates. This writes over a previous (possibly partial) rectangle.
The result of the method is an empty string.
Note that this method goes through the whole set of callbacks invoked when corners are created, i.e. -create-cmd, and, more importantly, -data-cmd.
This is the method through which to load a pre-existing rectangle into an editor instance.
This method programmatically removes the rectangle from the editor, making the way free for creating a new one.
The result of the method is an empty string.
Note that this method goes through the same callbacks invoked when the user interactively removes a corner, i.e. -data-cmd.
The class command accepts the following options
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category canvas of the Tklib Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.