option.hh
Go to the documentation of this file.
1 #ifndef _OPTION_H_
2 #define _OPTION_H_
3 
4 #include <string>
5 #include "worldfile.hh"
6 
7 #include <FL/Fl_Menu_Bar.H>
8 #include <FL/Fl_Menu_Item.H>
9 
10 namespace Stg {
11  class World;
19  class Option {
20  private:
21  friend bool compare( const Option* lhs, const Option* rhs );
22 
23  std::string optName;
24  bool value;
26  std::string wf_token;
27  std::string shortcut;
28  Fl_Menu_* menu;
29  int menuIndex;
30  Fl_Callback* menuCb;
31  Fl_Widget* menuCbWidget;
32  World* _world;
33 
34  public:
35  Option( const std::string& n,
36  const std::string& tok,
37  const std::string& key,
38  bool v,
39  World *world );
40 
41  const std::string name() const { return optName; }
42  inline bool isEnabled() const { return value; }
43  inline bool val() const { return value; }
44  inline operator bool() { return val(); }
45  inline bool operator<( const Option& rhs ) const
46  {
47  puts( "comparing" );
48  return optName<rhs.optName;
49  }
50  void set( bool val );
51  void invert() { set( !value ); }
52 
53 // // Comparator to dereference Option pointers and compare their strings
54 // struct optComp {
55 // inline bool operator()( const Option* a, const Option* b ) const
56 // //{ return lhs->operator<(*rhs); }
57 // { return a->optName < b->optName; }
58 // };
59 
60 
61  void createMenuItem( Fl_Menu_Bar* menu, std::string path );
62  void menuCallback( Fl_Callback* cb, Fl_Widget* w );
63  static void toggleCb( Fl_Widget* w, void* p );
64  void Load( Worldfile* wf, int section );
65  void Save( Worldfile* wf, int section );
66 
67  std::string htname;
68  };
69 }
70 
71 #endif