1 /**
2 Numerical input text field.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.spinbox;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.traits;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.globalenums;
22 import godot.object;
23 import godot.classdb;
24 import godot.range;
25 import godot.control;
26 import godot.canvasitem;
27 import godot.node;
28 import godot.inputevent;
29 import godot.lineedit;
30 /**
31 Numerical input text field.
32 
33 SpinBox is a numerical input text field. It allows entering integers and floats.
34 $(B Example:)
35 
36 
37 var spin_box = SpinBox.new()
38 add_child(spin_box)
39 var line_edit = spin_box.get_line_edit()
40 line_edit.context_menu_enabled = false
41 spin_box.align = LineEdit.ALIGN_RIGHT
42 
43 
44 The above code will create a $(D SpinBox), disable context menu on it and set the text alignment to right.
45 See $(D Range) class for more options over the $(D SpinBox).
46 $(B Note:) $(D SpinBox) relies on an underlying $(D LineEdit) node. To theme a $(D SpinBox)'s background, add theme items for $(D LineEdit) and customize them.
47 */
48 @GodotBaseClass struct SpinBox
49 {
50 	package(godot) enum string _GODOT_internal_name = "SpinBox";
51 public:
52 @nogc nothrow:
53 	union { /** */ godot_object _godot_object; /** */ Range _GODOT_base; }
54 	alias _GODOT_base this;
55 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
56 	package(godot) __gshared bool _classBindingInitialized = false;
57 	package(godot) static struct GDNativeClassBinding
58 	{
59 		__gshared:
60 		@GodotName("_gui_input") GodotMethod!(void, InputEvent) _guiInput;
61 		@GodotName("_line_edit_focus_exit") GodotMethod!(void) _lineEditFocusExit;
62 		@GodotName("_line_edit_input") GodotMethod!(void, InputEvent) _lineEditInput;
63 		@GodotName("_range_click_timeout") GodotMethod!(void) _rangeClickTimeout;
64 		@GodotName("_text_entered") GodotMethod!(void, String) _textEntered;
65 		@GodotName("apply") GodotMethod!(void) apply;
66 		@GodotName("get_align") GodotMethod!(LineEdit.Align) getAlign;
67 		@GodotName("get_line_edit") GodotMethod!(LineEdit) getLineEdit;
68 		@GodotName("get_prefix") GodotMethod!(String) getPrefix;
69 		@GodotName("get_suffix") GodotMethod!(String) getSuffix;
70 		@GodotName("is_editable") GodotMethod!(bool) isEditable;
71 		@GodotName("set_align") GodotMethod!(void, long) setAlign;
72 		@GodotName("set_editable") GodotMethod!(void, bool) setEditable;
73 		@GodotName("set_prefix") GodotMethod!(void, String) setPrefix;
74 		@GodotName("set_suffix") GodotMethod!(void, String) setSuffix;
75 	}
76 	/// 
77 	pragma(inline, true) bool opEquals(in SpinBox other) const
78 	{ return _godot_object.ptr is other._godot_object.ptr; }
79 	/// 
80 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
81 	{ _godot_object.ptr = n; return null; }
82 	/// 
83 	pragma(inline, true) bool opEquals(typeof(null) n) const
84 	{ return _godot_object.ptr is n; }
85 	/// 
86 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
87 	mixin baseCasts;
88 	/// Construct a new instance of SpinBox.
89 	/// Note: use `memnew!SpinBox` instead.
90 	static SpinBox _new()
91 	{
92 		static godot_class_constructor constructor;
93 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("SpinBox");
94 		if(constructor is null) return typeof(this).init;
95 		return cast(SpinBox)(constructor());
96 	}
97 	@disable new(size_t s);
98 	/**
99 	
100 	*/
101 	void _guiInput(InputEvent arg0)
102 	{
103 		Array _GODOT_args = Array.make();
104 		_GODOT_args.append(arg0);
105 		String _GODOT_method_name = String("_gui_input");
106 		this.callv(_GODOT_method_name, _GODOT_args);
107 	}
108 	/**
109 	
110 	*/
111 	void _lineEditFocusExit()
112 	{
113 		Array _GODOT_args = Array.make();
114 		String _GODOT_method_name = String("_line_edit_focus_exit");
115 		this.callv(_GODOT_method_name, _GODOT_args);
116 	}
117 	/**
118 	
119 	*/
120 	void _lineEditInput(InputEvent arg0)
121 	{
122 		Array _GODOT_args = Array.make();
123 		_GODOT_args.append(arg0);
124 		String _GODOT_method_name = String("_line_edit_input");
125 		this.callv(_GODOT_method_name, _GODOT_args);
126 	}
127 	/**
128 	
129 	*/
130 	void _rangeClickTimeout()
131 	{
132 		Array _GODOT_args = Array.make();
133 		String _GODOT_method_name = String("_range_click_timeout");
134 		this.callv(_GODOT_method_name, _GODOT_args);
135 	}
136 	/**
137 	
138 	*/
139 	void _textEntered(in String arg0)
140 	{
141 		Array _GODOT_args = Array.make();
142 		_GODOT_args.append(arg0);
143 		String _GODOT_method_name = String("_text_entered");
144 		this.callv(_GODOT_method_name, _GODOT_args);
145 	}
146 	/**
147 	Applies the current value of this $(D SpinBox).
148 	*/
149 	void apply()
150 	{
151 		checkClassBinding!(typeof(this))();
152 		ptrcall!(void)(GDNativeClassBinding.apply, _godot_object);
153 	}
154 	/**
155 	
156 	*/
157 	LineEdit.Align getAlign() const
158 	{
159 		checkClassBinding!(typeof(this))();
160 		return ptrcall!(LineEdit.Align)(GDNativeClassBinding.getAlign, _godot_object);
161 	}
162 	/**
163 	Returns the $(D LineEdit) instance from this $(D SpinBox). You can use it to access properties and methods of $(D LineEdit).
164 	*/
165 	LineEdit getLineEdit()
166 	{
167 		checkClassBinding!(typeof(this))();
168 		return ptrcall!(LineEdit)(GDNativeClassBinding.getLineEdit, _godot_object);
169 	}
170 	/**
171 	
172 	*/
173 	String getPrefix() const
174 	{
175 		checkClassBinding!(typeof(this))();
176 		return ptrcall!(String)(GDNativeClassBinding.getPrefix, _godot_object);
177 	}
178 	/**
179 	
180 	*/
181 	String getSuffix() const
182 	{
183 		checkClassBinding!(typeof(this))();
184 		return ptrcall!(String)(GDNativeClassBinding.getSuffix, _godot_object);
185 	}
186 	/**
187 	
188 	*/
189 	bool isEditable() const
190 	{
191 		checkClassBinding!(typeof(this))();
192 		return ptrcall!(bool)(GDNativeClassBinding.isEditable, _godot_object);
193 	}
194 	/**
195 	
196 	*/
197 	void setAlign(in long _align)
198 	{
199 		checkClassBinding!(typeof(this))();
200 		ptrcall!(void)(GDNativeClassBinding.setAlign, _godot_object, _align);
201 	}
202 	/**
203 	
204 	*/
205 	void setEditable(in bool editable)
206 	{
207 		checkClassBinding!(typeof(this))();
208 		ptrcall!(void)(GDNativeClassBinding.setEditable, _godot_object, editable);
209 	}
210 	/**
211 	
212 	*/
213 	void setPrefix(in String prefix)
214 	{
215 		checkClassBinding!(typeof(this))();
216 		ptrcall!(void)(GDNativeClassBinding.setPrefix, _godot_object, prefix);
217 	}
218 	/**
219 	
220 	*/
221 	void setSuffix(in String suffix)
222 	{
223 		checkClassBinding!(typeof(this))();
224 		ptrcall!(void)(GDNativeClassBinding.setSuffix, _godot_object, suffix);
225 	}
226 	/**
227 	Sets the text alignment of the $(D SpinBox).
228 	*/
229 	@property LineEdit.Align _align()
230 	{
231 		return getAlign();
232 	}
233 	/// ditto
234 	@property void _align(long v)
235 	{
236 		setAlign(v);
237 	}
238 	/**
239 	If `true`, the $(D SpinBox) will be editable. Otherwise, it will be read only.
240 	*/
241 	@property bool editable()
242 	{
243 		return isEditable();
244 	}
245 	/// ditto
246 	@property void editable(bool v)
247 	{
248 		setEditable(v);
249 	}
250 	/**
251 	Adds the specified `prefix` string before the numerical value of the $(D SpinBox).
252 	*/
253 	@property String prefix()
254 	{
255 		return getPrefix();
256 	}
257 	/// ditto
258 	@property void prefix(String v)
259 	{
260 		setPrefix(v);
261 	}
262 	/**
263 	Adds the specified `suffix` string after the numerical value of the $(D SpinBox).
264 	*/
265 	@property String suffix()
266 	{
267 		return getSuffix();
268 	}
269 	/// ditto
270 	@property void suffix(String v)
271 	{
272 		setSuffix(v);
273 	}
274 }