MWCRectTool.h
Classes
- MWCRectTool -- Base class for MultiWorldCanvas event-based rectangle tools (full description)
Interface
- Public Members
- MWCRectTool(Display::KeySym keysym = Display::K_Pointer_Button1, const Bool persistent = False)
- virtual ~MWCRectTool()
- virtual void disable()
- virtual void reset(Bool skipRefresh=False)
- Protected Members
- virtual void keyPressed(const WCPositionEvent &ev)
- virtual void keyReleased(const WCPositionEvent &ev)
- virtual void otherKeyPressed(const WCPositionEvent &ev)
- virtual void moved(const WCMotionEvent &ev)
- virtual void draw(const WCRefreshEvent&)
- virtual void doubleInside()
- virtual void doubleOutside()
- virtual void rectangleReady()
- virtual void get(Int &x1, Int &y1, Int &x2, Int &y2) const
- Private Members
- virtual void set(const Int &x1, const Int &y1, const Int &x2, const Int &y2)
- virtual void get(Int &x1, Int &y1) const
Review Status
- Date Reviewed:
- yyyy/mm/dd
WCTool
Etymology
MWCRectTool stands for MultiWorldCanvas Rectangle Tool
Synopsis
This class adds to its base WCTool to provide a tool for drawing,
resizing and moving rectangles on a WorldCanvas. While MWCRectTool
is not abstract, it performs no useful function. The programmer
should derive from this class, and implement the functions
doubleInside and doubleOutside, which are called when the user
double-clicks the key or mouse button inside or outside an existing
rectangle respectively. It is up to the programmer to decide what
double clicks inside and outside the rectangle correspond to,
although it is recommended that a double click inside correspond to
the main action of the tool, and a double click outside correspond
to a secondary action of the tool, if indeed a secondary action
exists.
The rectangle is drawn by dragging the mouse from one corner to
the diagonally opposite corner. Once constructed, the rectangle
can be resized by dragging its corners, or relocated by dragging
inside the rectangle. The rectangle is removed from the display
when the Esc key is pressed.
Example
Motivation
Many activities on the WorldCanvas will be based on the user drawing
a rectangle, and then proceeding to some action with that rectangle.
A nice example is zooming.
Member Description
MWCRectTool(Display::KeySym keysym = Display::K_Pointer_Button1, const Bool persistent = False)
Constructor
Destructor
virtual void disable()
Switch the tool off - this erases the rectangle, if any,
and calls the base class disable.
virtual void reset(Bool skipRefresh=False)
reset to non-existent, non-active rectangle.
Refreshes if necessary to erase (unless skipRefresh==True In
that case, the caller should do the refresh itself).
(Does not unregister from WCs or disable future event handling).
Functions called by the base class event handling operators--and
normally only those. This is the input that controls the rectangle's
appearance and action. When the rectangle is ready and double-click
is received, the doubleInside/Outside routine will be invoked.
draw the rectangle (if any) on the object's currently active WC.
Only to be called by the base class refresh event handler. Derived
objects should use refresh() if they need to redraw, but even that
is normally handled automatically.
Output callback functions--to be overridden in derived class.
Called when there is a double click inside/outside the rectangle
Called when a rectangle is ready and not being
edited. (Unused so far on the glish level (12/01)).
virtual void get(Int &x1, Int &y1, Int &x2, Int &y2) const
Retrieve the rectangle coordinates, in screen pixels.
Anchor (if applicable) is (x1,y1). Valid during the output callbacks;
to be used by them, as well as internally.
virtual void set(const Int &x1, const Int &y1, const Int &x2, const Int &y2)
set the pixel coordinates of the rectangle
virtual void get(Int &x1, Int &y1) const
get only the anchor point