Inheritance diagram for RectangleTool:
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 |
|
|
|
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 } |
|
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 } |
|
called when another tool is selected
Implements Tool.
00038 {} |
|
|
|
When in the middle of creating a rectangle, this stores the position of the first click.
|
|
Set to true if the tool is in the middle of creating a rectangle.
|