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

ExitTool Class Reference

A Tool subclass that allows the user to terminate the program. More...

Inheritance diagram for ExitTool:

Tool Object List of all members.

Public Methods

 ExitTool ()
void save_and_exit ()
 Prompts the user and terminates the program.

void start ()
 When the user selects this tool, just calls save_and_exit.

int mouseClick (const Position &)
 If the user clicks on the canvas, again just call save_and_exit.

void stop ()
 called when another tool is selected


Static Public Attributes

ExitTool::Factory factory

Detailed Description

A Tool subclass that allows the user to terminate the program.


Constructor & Destructor Documentation

ExitTool::ExitTool   [inline]
 

00013 : Tool("exit-button.bmp") {}


Member Function Documentation

int ExitTool::mouseClick const Position &    [inline, virtual]
 

If the user clicks on the canvas, again just call save_and_exit.

Implements Tool.

00052                                    {
00053     save_and_exit();
00054     return 1;
00055   }

void ExitTool::save_and_exit   [inline]
 

Prompts the user and terminates the program.

First, the user is asked for a filename to save the drawing. Saving isn't implemented, so this automatically fails; after a second confirmation, the program is terminated with the Terminate() function.

00021                        {
00022     // We try to be friendly:
00023     // If someone doesn't actually want to quit, we
00024     // given them a way out.
00025     // If the filename doesn't work, we see
00026     // if they still want to quit.
00027     cout << "Filename to write to [don't quit] ";
00028     string filename;
00029     getline(cin,filename);
00030     if (filename.empty()) return;
00031     if (DrawFile::write_file(filename,drawing)) {
00032       Terminate();
00033       //NB: The terminate command doesn't immediately quit.
00034       return;
00035     }
00036     cout << "File '" << filename <<
00037       "' cannot be written." << endl;
00038     cout << "Quit anyway ? [no] ";
00039     string response;
00040     getline(cin,response);
00041     response =  Utilities::lower_case(response);
00042     if (response == "y" || response == "yes") Terminate();
00043     else cout << "Continuing..." << endl;
00044   }

void ExitTool::start   [inline, virtual]
 

When the user selects this tool, just calls save_and_exit.

Implements Tool.

00047                {
00048     save_and_exit();
00049   }

void ExitTool::stop   [inline, virtual]
 

called when another tool is selected

Implements Tool.

00057 {}


Member Data Documentation

ExitTool::Factory ExitTool::factory [static]
 


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