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;
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
bool val() const
Definition: option.hh:43
bool isEnabled() const
Definition: option.hh:42
World class
Definition: stage.hh:814
The Stage library uses its own namespace.
Definition: canvas.hh:8
friend bool compare(const Option *lhs, const Option *rhs)
static void toggleCb(Fl_Widget *w, void *p)
Definition: option.cc:44
std::string htname
Definition: option.hh:67
Fl_Callback * menuCb
Definition: option.hh:30
void invert()
Definition: option.hh:51
std::string wf_token
Definition: option.hh:26
Fl_Widget * menuCbWidget
Definition: option.hh:31
void Save(Worldfile *wf, int section)
Definition: option.cc:39
void createMenuItem(Fl_Menu_Bar *menu, std::string path)
Definition: option.cc:58
const std::string name() const
Definition: option.hh:41
World * _world
Definition: option.hh:32
bool operator<(const Option &rhs) const
Definition: option.hh:45
void menuCallback(Fl_Callback *cb, Fl_Widget *w)
Definition: option.cc:53
Option(const std::string &n, const std::string &tok, const std::string &key, bool v, World *world)
Definition: option.cc:9
std::string optName
Definition: option.hh:23
bool value
Definition: option.hh:24
void Load(Worldfile *wf, int section)
Definition: option.cc:33
std::string shortcut
Definition: option.hh:27
int menuIndex
Definition: option.hh:29
Fl_Menu_ * menu
Definition: option.hh:28


stage
Author(s): Richard Vaughan , Brian Gerkey , Reed Hedges , Andrew Howard , Toby Collett , Pooya Karimian , Jeremy Asher , Alex Couture-Beil , Geoff Biggs , Rich Mattes , Abbas Sadat
autogenerated on Mon Jun 10 2019 15:06:09