guit  0.1
 All Classes Functions Variables Typedefs Enumerations Friends
gchoice.hpp
1 //
2 // Exclusive selection.
3 // Guit GUI Toolkit
4 // Copyright © 2019/2020 Eric Lecolinet. All rights reserved.
5 // http://www.telecom-paris.fr/~elc
6 //
7 
8 #ifndef Guit_Choice_hpp
9 #define Guit_Choice_hpp
10 #include <gint.hpp>
11 namespace guit {
12 
18 class GChoice : public GInt {
19 public:
25  GChoice();
26  GChoice(int index);
27  GChoice(int index, int min, int max);
28  GChoice(GString const& index);
29  GChoice(GChoice const&);
31 
32  GChoice* clone(bool copy_value) const override;
33  GChoice* toChoice() override {return this;}
34 
38  int chosenIndex() const {return value_;}
39  Gadget* chosenItem(const GBox&) const;
41 
45  virtual void choose(int index) {set(index,false);}
46  virtual void choose(GBox&, Gadget* item);
47  virtual void choose(GBox&, GString const& name);
48  GChoice& operator=(int index) {set(index,false); return *this;}
49  GChoice& operator=(GInt const& index) {set(index,false); return *this;}
50  GChoice& operator=(GString const& index) {set(index); return *this;}
52 
55  GChoice& operator++() {increase(+1); return *this;}
56  GChoice& operator++(int) {increase(+1); return *this;}
57  GChoice& operator--() {increase(-1); return *this;}
58  GChoice& operator--(int) {increase(-1); return *this;}
60 
63  GChoice& operator+=(int value) {increase(value); return *this;}
64  GChoice& operator-=(int value) {increase(-value); return *this;}
65  using GInt::increase;
66  void increase(int const& value) override;
68 
69  using GType = GPropType_<GChoice,GInt>;
70  static GType& Type();
71  GType& type() const override {return Type();}
72 
75  virtual void addBoxChild(GBox&, Gadget* child, int pos);
76  void radioCB(GBox&);
77  void addModes(GadgetModes&) override;
78  void removeModes(GadgetModes&) override;
80 };
81 
84 GChoice& Choice();
85 GChoice& Choice(int index);
86 GChoice& Choice(int index, int min, int max);
87 GChoice& Choice(GString const& index);
89 
90 }
91 #endif