guit  0.1
 All Classes Functions Variables Typedefs Enumerations Friends
gcombobox.hpp
1 //
2 // Gadgets that open a menu of options
3 // Guit GUI Toolkit
4 // Copyright © 2020 Eric Lecolinet. All rights reserved.
5 // http://www.telecom-paris.fr/~elc
6 //
7 
8 #ifndef Guit_ComboBox_hpp
9 #define Guit_ComboBox_hpp
10 #include <gchoicebox.hpp>
11 namespace guit {
12 
16 class GOptionBox : public GChoiceBox {
17 protected:
18  GOptionBox(GadgetType&, GString const& css_and_title);
19 
20 public:
21  ~GOptionBox();
22  GOptionBox(GString const& css_and_title = "");
23  GOptionBox& clone(GClone const&) override;
24 
26  GItem& selector();
27 
29  GMenu& menu();
30 
31  using GBox::add;
32  void add(Gadget* child, int index = -1) override;
33  void add(Gadget& child, int index = -1) override {GOptionBox::add(&child, index);}
34 
35  using GBox::remove;
36  bool remove(Gadget* child) override;
37  bool removeAt(int index) override;
38  void removeChildren(Remove mode = Remove::InContent) override;
39 
40  //child(), childindex() etc. A REVOIR !!!!!
41 
43  static GType& Type();
44  GType& type() const override {return Type();}
45 
48  gptr<GItem> selector_;
49  gptr<GMenu> menu_;
50  void init(GRender* parrender) override;
51  void initChildren(GRender* parrender) override;
52  void initClone(Gadget& from, GClone const&) override;
53  void setChoiceImpl(GChoice& c, bool add_to_list) override;
54  GBox& itemBox() override;
55  GBox const& itemBox() const override;
56  virtual void changeCB(GEvent&);
58 };
59 
60 GOptionBox& OptionBox(GString const& css_and_title = "");
61 
62 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
63 
66 class GComboBox : public GOptionBox {
67 protected:
68  GComboBox(GadgetType&, GString const& css_and_title);
69 
70 public:
71  GComboBox(GString const& css_and_title = "");
72  GComboBox& clone(GClone const&) override;
73 
76 
78  static GType& Type();
79  GType& type() const override {return Type();}
80 };
81 
82 GComboBox& ComboBox(GString const& css_and_title = "");
83 
84 }
85 #endif