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

CircleTool Class Reference

A Tool subclass used to create circles on the canvas. More...

Inheritance diagram for CircleTool:

Tool Object List of all members.

Public Methods

 CircleTool ()
void start ()
 midDraw is set to false, indicating that we're not in the middle of creating a circle.

int mouseClick (const Position &pos)
 If we're in the middle of creating a circle, then firstPosition is used with pos to create a new circle in the drawing.

void stop ()
 called when another tool is selected


Private Attributes

bool midDraw
 Indicates if the user is in the middle of creating a circle.

Position first
 Holds the position of the user's first click while we wait for the second.


Static Private Attributes

CircleTool::Factory factory

Detailed Description

A Tool subclass used to create circles on the canvas.


Constructor & Destructor Documentation

CircleTool::CircleTool   [inline]
 

00009 : Tool("circle-button.bmp"), midDraw(false), first() {}


Member Function Documentation

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

If we're in the middle of creating a circle, then firstPosition is used with pos to create a new circle in the drawing.

Otherwise, we store the position of the click and set midDraw to true to wait for the next click.

Implements Tool.

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

void CircleTool::start   [inline, virtual]
 

midDraw is set to false, indicating that we're not in the middle of creating a circle.

Implements Tool.

00014                {
00015     midDraw = false;
00016   }

void CircleTool::stop   [inline, virtual]
 

called when another tool is selected

Implements Tool.

00039 {}


Member Data Documentation

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

Position CircleTool::first [private]
 

Holds the position of the user's first click while we wait for the second.

bool CircleTool::midDraw [private]
 

Indicates if the user is in the middle of creating a circle.


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