Kodi Development 22.0
for Binary and Script based Add-Ons
 
Loading...
Searching...
No Matches
TextBox.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/text_box.h"
12#include "../Window.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace controls
21{
22
23//============================================================================
42class ATTR_DLL_LOCAL CTextBox : public CAddonGUIControlBase
43{
44public:
45 //==========================================================================
52 CTextBox(CWindow* window, int controlId) : CAddonGUIControlBase(window)
53 {
54 m_controlHandle = m_interface->kodi_gui->window->get_control_text_box(
55 m_interface->kodiBase, m_Window->GetControlHandle(), controlId);
56 if (!m_controlHandle)
58 "kodi::gui::controls::CTextBox can't create control class from Kodi !!!");
59 }
60 //--------------------------------------------------------------------------
61
62 //==========================================================================
66 ~CTextBox() override = default;
67 //--------------------------------------------------------------------------
68
69 //==========================================================================
75 void SetVisible(bool visible)
76 {
77 m_interface->kodi_gui->control_text_box->set_visible(m_interface->kodiBase, m_controlHandle,
78 visible);
79 }
80 //--------------------------------------------------------------------------
81
82 //==========================================================================
86 void Reset() { m_interface->kodi_gui->control_text_box->reset(m_controlHandle, m_controlHandle); }
87 //--------------------------------------------------------------------------
88
89 //==========================================================================
95 void SetText(const std::string& text)
96 {
97 m_interface->kodi_gui->control_text_box->set_text(m_interface->kodiBase, m_controlHandle,
98 text.c_str());
99 }
100 //--------------------------------------------------------------------------
101
102 //==========================================================================
108 std::string GetText() const
109 {
110 std::string text;
111 char* ret =
112 m_interface->kodi_gui->control_text_box->get_text(m_interface->kodiBase, m_controlHandle);
113 if (ret != nullptr)
114 {
115 if (std::strlen(ret))
116 text = ret;
117 m_interface->free_string(m_interface->kodiBase, ret);
118 }
119 return text;
120 }
121 //--------------------------------------------------------------------------
122
123 //==========================================================================
129 void Scroll(unsigned int position)
130 {
131 m_interface->kodi_gui->control_text_box->scroll(m_interface->kodiBase, m_controlHandle,
132 position);
133 }
134 //--------------------------------------------------------------------------
135
136 //==========================================================================
152 void SetAutoScrolling(int delay, int time, int repeat)
153 {
154 m_interface->kodi_gui->control_text_box->set_auto_scrolling(
155 m_interface->kodiBase, m_controlHandle, delay, time, repeat);
156 }
157 //--------------------------------------------------------------------------
158};
159
160} /* namespace controls */
161} /* namespace gui */
162} /* namespace kodi */
163
164#endif /* __cplusplus */
Definition ListItem.h:26
Definition Window.h:110
Definition TextBox.h:43
@ ADDON_LOG_FATAL
4 : To notify fatal unrecoverable errors, which can may also indicate upcoming crashes.
Definition addon_base.h:197
void Scroll(unsigned int position)
To scroll text on other position.
Definition TextBox.h:129
std::string GetText() const
Get the used text from control.
Definition TextBox.h:108
void Reset()
To reset box an remove all the text.
Definition TextBox.h:86
void SetVisible(bool visible)
Set the control on window to visible.
Definition TextBox.h:75
void SetText(const std::string &text)
To set the text on box.
Definition TextBox.h:95
~CTextBox() override=default
Destructor.
void SetAutoScrolling(int delay, int time, int repeat)
To set automatic scrolling of textbox.
Definition TextBox.h:152
CTextBox(CWindow *window, int controlId)
Construct a new control.
Definition TextBox.h:52
void ATTR_DLL_LOCAL Log(const ADDON_LOG loglevel, const char *format,...)
Add a message to Kodi's log.
Definition AddonBase.h:1938