option_button.h
1 /*************************************************************************/
2 /* option_button.h */
3 /*************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* http://www.godotengine.org */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
9 /* */
10 /* Permission is hereby granted, free of charge, to any person obtaining */
11 /* a copy of this software and associated documentation files (the */
12 /* "Software"), to deal in the Software without restriction, including */
13 /* without limitation the rights to use, copy, modify, merge, publish, */
14 /* distribute, sublicense, and/or sell copies of the Software, and to */
15 /* permit persons to whom the Software is furnished to do so, subject to */
16 /* the following conditions: */
17 /* */
18 /* The above copyright notice and this permission notice shall be */
19 /* included in all copies or substantial portions of the Software. */
20 /* */
21 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
22 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
23 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
24 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
25 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
26 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
27 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
28 /*************************************************************************/
29 #ifndef OPTION_BUTTON_H
30 #define OPTION_BUTTON_H
31 
32 #include "scene/gui/button.h"
33 #include "scene/gui/popup_menu.h"
37 class OptionButton : public Button {
38 
39  OBJ_TYPE( OptionButton, Button );
40 
41  PopupMenu *popup;
42  int current;
43 
44  void _selected(int p_which);
45  void _select(int p_which,bool p_emit=false);
46  void _select_int(int p_which);
47 
48  Array _get_items() const;
49  void _set_items(const Array& p_items);
50 
51  virtual void pressed();
52 protected:
53 
54  Size2 get_minimum_size() const;
55  void _notification(int p_what);
56  static void _bind_methods();
57 public:
58 
59  void add_icon_item(const Ref<Texture>& p_icon,const String& p_label,int p_ID=-1);
60  void add_item(const String& p_label,int p_ID=-1);
61 
62  void set_item_text(int p_idx,const String& p_text);
63  void set_item_icon(int p_idx,const Ref<Texture>& p_icon);
64  void set_item_ID(int p_idx,int p_ID);
65  void set_item_metadata(int p_idx,const Variant& p_metadata);
66  void set_item_disabled(int p_idx,bool p_disabled);
67 
68  String get_item_text(int p_idx) const;
69  Ref<Texture> get_item_icon(int p_idx) const;
70  int get_item_ID(int p_idx) const;
71  Variant get_item_metadata(int p_idx) const;
72  bool is_item_disabled(int p_idx) const;
73 
74 
75  int get_item_count() const;
76 
77  void add_separator();
78 
79  void clear();
80 
81  void select(int p_idx);
82  int get_selected() const;
83  int get_selected_ID() const;
84  Variant get_selected_metadata() const;
85 
86  void remove_item(int p_idx);
87 
88  virtual void get_translatable_strings(List<String> *p_strings) const;
89 
90  OptionButton();
91  ~OptionButton();
92 
93 };
94 
95 #endif
Definition: array.h:38
Definition: variant.h:74
Definition: math_2d.h:65
Definition: ustring.h:64
Definition: button.h:36
Definition: option_button.h:37
Definition: popup_menu.h:37