option.hh

Go to the documentation of this file.
00001 #ifndef _OPTION_H_
00002 #define _OPTION_H_
00003 
00004 #include <string>
00005 #include "worldfile.hh"
00006 
00007 #include <FL/Fl_Menu_Bar.H>
00008 #include <FL/Fl_Menu_Item.H>
00009 
00010 namespace Stg {
00011     class World;
00019     class Option {
00020     private:
00021         friend bool compare( const Option* lhs, const Option* rhs );
00022 
00023         std::string optName;
00024         bool value;
00026         std::string wf_token; 
00027         std::string shortcut;
00028         Fl_Menu_* menu;
00029         int menuIndex;
00030         Fl_Callback* menuCb;
00031         Fl_Widget* menuCbWidget;
00032         World* _world;
00033       
00034     public:
00035         Option( std::string n, std::string tok, std::string key, bool v, World *world );      
00036 
00037         const std::string name() const { return optName; }
00038         inline bool isEnabled() const { return value; }
00039         inline bool val() const { return value; }
00040         inline operator bool() { return val(); }
00041         inline bool operator<( const Option& rhs ) const
00042             {
00043               puts( "comparing" );
00044               return optName<rhs.optName; 
00045             } 
00046         void set( bool val );
00047         void invert() { set( !value ); }
00048 
00049 //      // Comparator to dereference Option pointers and compare their strings
00050 //      struct optComp {
00051 //          inline bool operator()( const Option* a, const Option* b ) const
00052 //          //{ return lhs->operator<(*rhs); } 
00053 //              { return a->optName < b->optName; } 
00054 //      };
00055 
00056 
00057         void createMenuItem( Fl_Menu_Bar* menu, std::string path );
00058         void menuCallback( Fl_Callback* cb, Fl_Widget* w );
00059         static void toggleCb( Fl_Widget* w, void* p );
00060         void Load( Worldfile* wf, int section );
00061         void Save( Worldfile* wf, int section );      
00062 
00063       const char* htname;
00064     };
00065 }
00066     
00067 #endif

Generated on Tue Oct 20 15:42:05 2009 for Stage by  doxygen 1.6.1