Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

RectangleTool Class Reference

A Tool subclass that allows the user to create Rectangle objects. More...

Inheritance diagram for RectangleTool:

Tool Object List of all members.

Public Methods

 RectangleTool ()
void start ()
 When the tool is first selected, clear the state to indicate that it's not in the middle of creating a rectangle.

int mouseClick (const Position &pos)
 When the user clicks in the canvas and the tool is not in the middle of creating a rectangle, the clicked position is stored, and midDraw is set to indicate that it is now creating a rectangle.

void stop ()
 called when another tool is selected


Private Attributes

bool midDraw
 Set to true if the tool is in the middle of creating a rectangle.

Position first
 When in the middle of creating a rectangle, this stores the position of the first click.


Static Private Attributes

RectangleTool::Factory factory

Detailed Description

A Tool subclass that allows the user to create Rectangle objects.


Constructor & Destructor Documentation

RectangleTool::RectangleTool   [inline]
 

00008 : Tool("rect-button.bmp"), midDraw(false), first() {}


Member Function Documentation

int RectangleTool::mouseClick const Position &    pos [inline, virtual]
 

When the user clicks in the canvas and the tool is not in the middle of creating a rectangle, the clicked position is stored, and midDraw is set to indicate that it is now creating a rectangle.

Otherwise, the stored position and the new click position is used to create a new Rectangle and place it on the canvas.

Implements Tool.

00024                                       {
00025     if (midDraw) {
00026       DrawElement* de = new Rectangle(first,pos,drawing->current_color());
00027       drawing->get_contents()->add_element(de);
00028       drawing->clear_selection();
00029       drawing->add_selection(de);
00030       midDraw = false;
00031     } else {
00032       first = pos;
00033       midDraw = true;
00034     }
00035     return 1;
00036   }

void RectangleTool::start   [inline, virtual]
 

When the tool is first selected, clear the state to indicate that it's not in the middle of creating a rectangle.

Implements Tool.

00013                {
00014     midDraw = false;
00015   }

void RectangleTool::stop   [inline, virtual]
 

called when another tool is selected

Implements Tool.

00038 {}


Member Data Documentation

RectangleTool::Factory RectangleTool::factory [static, private]
 

Position RectangleTool::first [private]
 

When in the middle of creating a rectangle, this stores the position of the first click.

bool RectangleTool::midDraw [private]
 

Set to true if the tool is in the middle of creating a rectangle.


The documentation for this class was generated from the following file:
Generated on Fri Nov 8 10:52:31 2002 for Draw by doxygen1.2.17