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

ColorTool Class Reference

A Tool subclass used to change the color of objects. More...

Inheritance diagram for ColorTool:

Tool Object List of all members.

Public Methods

 ColorTool ()
void add_feature (string name, string value)
 Tool overrides add_feature in order to be able to set its bitmap_name variable from the "image" key.

void start ()
 When the tool is first clicked, it sets the color of all currently-selected objects by using Drawing's Selection class, and the provided iteration functions.

int mouseClick (const Position &pos)
 When the tool is clicked, it figures out which object was clicked and sets the color of that object.

void stop ()
 called when another tool is selected


Private Attributes

color the_color
 The color that this tool sets.


Static Private Attributes

ColorTool::Factory factory

Detailed Description

A Tool subclass used to change the color of objects.

A single instance of ColorTool is only able to set a single predetermined color. Normally, multiple instances of ColorTool would be created, one for each color that should appear in the tool window. The color for each instance is set with the "color" feature in add_feature.


Constructor & Destructor Documentation

ColorTool::ColorTool   [inline]
 

00019 : Tool("unknown-color.bmp") {}


Member Function Documentation

void ColorTool::add_feature string    name,
string    value
[inline, virtual]
 

Tool overrides add_feature in order to be able to set its bitmap_name variable from the "image" key.

Reimplemented from Tool.

00021                                               {
00022     if (name == "color") {
00023       if (!Utilities::from_string(value,the_color)) {
00024         throw unknown_feature("unknown color name");
00025       }
00026       add_feature("image",value + "-button.bmp");
00027     } else {
00028       Tool::add_feature(name,value);
00029     }
00030   }

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

When the tool is clicked, it figures out which object was clicked and sets the color of that object.

Implements Tool.

00048                                       {
00049     DrawElement* de = drawing->get_contents()->find_hit(pos);
00050     if (de) {
00051       de->set_color(the_color);
00052       return 1;
00053     } else {
00054       return 0;
00055     }
00056   }

void ColorTool::start   [inline, virtual]
 

When the tool is first clicked, it sets the color of all currently-selected objects by using Drawing's Selection class, and the provided iteration functions.

Implements Tool.

00036                {
00037     for (Drawing::Selection i = drawing->begin_selection();
00038          i != drawing->end_selection();
00039          ++i) {
00040       (*i)->set_color(the_color);
00041     }
00042     drawing->set_current_color(the_color);
00043   }

void ColorTool::stop   [inline, virtual]
 

called when another tool is selected

Implements Tool.

00058 {}


Member Data Documentation

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

color ColorTool::the_color [private]
 

The color that this tool sets.


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