Kodi Development 22.0
for Binary and Script based Add-Ons
 
Loading...
Searching...
No Matches
Spin.h
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../c-api/gui/controls/spin.h"
12#include "../Window.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace controls
21{
22
23//==============================================================================
96
97//==============================================================================
114//------------------------------------------------------------------------------
115
116class ATTR_DLL_LOCAL CSpin : public CAddonGUIControlBase
117{
118public:
119 //============================================================================
126 CSpin(CWindow* window, int controlId) : CAddonGUIControlBase(window)
127 {
128 m_controlHandle = m_interface->kodi_gui->window->get_control_spin(
129 m_interface->kodiBase, m_Window->GetControlHandle(), controlId);
130 if (!m_controlHandle)
132 "kodi::gui::controls::CSpin can't create control class from Kodi !!!");
133 }
134 //----------------------------------------------------------------------------
135
136 //============================================================================
140 ~CSpin() override = default;
141 //----------------------------------------------------------------------------
142
143 //============================================================================
149 void SetVisible(bool visible)
150 {
151 m_interface->kodi_gui->control_spin->set_visible(m_interface->kodiBase, m_controlHandle,
152 visible);
153 }
154 //----------------------------------------------------------------------------
155
156 //============================================================================
162 void SetEnabled(bool enabled)
163 {
164 m_interface->kodi_gui->control_spin->set_enabled(m_interface->kodiBase, m_controlHandle,
165 enabled);
166 }
167 //----------------------------------------------------------------------------
168
169 //============================================================================
175 void SetText(const std::string& text)
176 {
177 m_interface->kodi_gui->control_spin->set_text(m_interface->kodiBase, m_controlHandle,
178 text.c_str());
179 }
180 //----------------------------------------------------------------------------
181
182 //============================================================================
186 void Reset()
187 {
188 m_interface->kodi_gui->control_spin->reset(m_interface->kodiBase, m_controlHandle);
189 }
190 //----------------------------------------------------------------------------
191
192 //============================================================================
201 {
202 m_interface->kodi_gui->control_spin->set_type(m_interface->kodiBase, m_controlHandle,
203 (int)type);
204 }
205 //----------------------------------------------------------------------------
206
207 //============================================================================
216 void AddLabel(const std::string& label, const std::string& value)
217 {
218 m_interface->kodi_gui->control_spin->add_string_label(m_interface->kodiBase, m_controlHandle,
219 label.c_str(), value.c_str());
220 }
221 //----------------------------------------------------------------------------
222
223 //============================================================================
232 void AddLabel(const std::string& label, int value)
233 {
234 m_interface->kodi_gui->control_spin->add_int_label(m_interface->kodiBase, m_controlHandle,
235 label.c_str(), value);
236 }
237 //----------------------------------------------------------------------------
238
239 //============================================================================
247 void SetStringValue(const std::string& value)
248 {
249 m_interface->kodi_gui->control_spin->set_string_value(m_interface->kodiBase, m_controlHandle,
250 value.c_str());
251 }
252 //----------------------------------------------------------------------------
253
254 //============================================================================
262 std::string GetStringValue() const
263 {
264 std::string value;
265 char* ret = m_interface->kodi_gui->control_spin->get_string_value(m_interface->kodiBase,
266 m_controlHandle);
267 if (ret != nullptr)
268 {
269 if (std::strlen(ret))
270 value = ret;
271 m_interface->free_string(m_interface->kodiBase, ret);
272 }
273 return value;
274 }
275 //----------------------------------------------------------------------------
276
277 //============================================================================
292 void SetIntRange(int start, int end)
293 {
294 m_interface->kodi_gui->control_spin->set_int_range(m_interface->kodiBase, m_controlHandle,
295 start, end);
296 }
297 //----------------------------------------------------------------------------
298
299 //============================================================================
310 void SetIntValue(int value)
311 {
312 m_interface->kodi_gui->control_spin->set_int_value(m_interface->kodiBase, m_controlHandle,
313 value);
314 }
315 //----------------------------------------------------------------------------
316
317 //============================================================================
327 int GetIntValue() const
328 {
329 return m_interface->kodi_gui->control_spin->get_int_value(m_interface->kodiBase,
330 m_controlHandle);
331 }
332 //----------------------------------------------------------------------------
333
334 //============================================================================
352 void SetFloatRange(float start, float end)
353 {
354 m_interface->kodi_gui->control_spin->set_float_range(m_interface->kodiBase, m_controlHandle,
355 start, end);
356 }
357 //----------------------------------------------------------------------------
358
359 //============================================================================
371 void SetFloatValue(float value)
372 {
373 m_interface->kodi_gui->control_spin->set_float_value(m_interface->kodiBase, m_controlHandle,
374 value);
375 }
376 //----------------------------------------------------------------------------
377
378 //============================================================================
384 float GetFloatValue() const
385 {
386 return m_interface->kodi_gui->control_spin->get_float_value(m_interface->kodiBase,
387 m_controlHandle);
388 }
389 //----------------------------------------------------------------------------
390
391 //============================================================================
403 void SetFloatInterval(float interval)
404 {
405 m_interface->kodi_gui->control_spin->set_float_interval(m_interface->kodiBase, m_controlHandle,
406 interval);
407 }
408 //----------------------------------------------------------------------------
409};
410
411} /* namespace controls */
412} /* namespace gui */
413} /* namespace kodi */
414
415#endif /* __cplusplus */
Definition ListItem.h:26
Definition Window.h:110
Definition Spin.h:117
@ ADDON_LOG_FATAL
4 : To notify fatal unrecoverable errors, which can may also indicate upcoming crashes.
Definition addon_base.h:197
CSpin(CWindow *window, int controlId)
Construct a new control.
Definition Spin.h:126
void SetFloatInterval(float interval)
To set the interval steps of spin, as default is it 0.1 If it becomes changed with this function will...
Definition Spin.h:403
void SetIntRange(int start, int end)
To set the the range as integer of slider, e.g. -10 is the slider start and e.g. +10 is the from here...
Definition Spin.h:292
void SetIntValue(int value)
Set the slider position with the given integer value. The Range must be defined with a call from SetI...
Definition Spin.h:310
void SetType(AddonGUISpinControlType type)
To set the with SpinControlType defined types of spin.
Definition Spin.h:200
void SetStringValue(const std::string &value)
To change the spin to position with them string as value.
Definition Spin.h:247
void Reset()
To reset spin control to defaults.
Definition Spin.h:186
float GetFloatValue() const
To get the current position as float value.
Definition Spin.h:384
void SetVisible(bool visible)
Set the control on window to visible.
Definition Spin.h:149
void SetText(const std::string &text)
To set the text string on spin control.
Definition Spin.h:175
void AddLabel(const std::string &label, const std::string &value)
To add a label entry in spin defined with a value as string.
Definition Spin.h:216
AddonGUISpinControlType
The values here defines the used value format for steps on spin control.
Definition Spin.h:104
~CSpin() override=default
Destructor.
void SetEnabled(bool enabled)
Set's the control's enabled/disabled state.
Definition Spin.h:162
void SetFloatValue(float value)
Set the spin position with the given float value. The Range can be defined with a call from SetIntRan...
Definition Spin.h:371
int GetIntValue() const
To get the current position as integer value.
Definition Spin.h:327
std::string GetStringValue() const
To get the current spin control position with text string value.
Definition Spin.h:262
void AddLabel(const std::string &label, int value)
To add a label entry in spin defined with a value as integer.
Definition Spin.h:232
void SetFloatRange(float start, float end)
To set the the range as float of spin, e.g. -25.0 is the spin start and e.g. +25.0 is the from here d...
Definition Spin.h:352
@ ADDON_SPIN_CONTROL_TYPE_TEXT
One spin step interpreted as text string.
Definition Spin.h:110
@ ADDON_SPIN_CONTROL_TYPE_PAGE
One spin step interpreted as a page change value.
Definition Spin.h:112
@ ADDON_SPIN_CONTROL_TYPE_INT
One spin step interpreted as integer.
Definition Spin.h:106
@ ADDON_SPIN_CONTROL_TYPE_FLOAT
One spin step interpreted as floating point value.
Definition Spin.h:108
void ATTR_DLL_LOCAL Log(const ADDON_LOG loglevel, const char *format,...)
Add a message to Kodi's log.
Definition AddonBase.h:1938