summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/TextBox.h
diff options
context:
space:
mode:
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/TextBox.h')
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/TextBox.h176
1 files changed, 176 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/TextBox.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/TextBox.h
new file mode 100644
index 0000000..9d8976e
--- /dev/null
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/TextBox.h
@@ -0,0 +1,176 @@
1#pragma once
2/*
3 * Copyright (C) 2005-2017 Team KODI
4 * http://kodi.tv
5 *
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with KODI; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include "../../AddonBase.h"
23#include "../Window.h"
24
25namespace kodi
26{
27namespace gui
28{
29namespace controls
30{
31
32 //============================================================================
33 ///
34 /// \defgroup cpp_kodi_gui_controls_CTextBox Control Text Box
35 /// \ingroup cpp_kodi_gui
36 /// @brief \cpp_class{ kodi::gui::controls::CTextBox }
37 /// **Used to show a multi-page piece of text**
38 ///
39 /// The text box control can be used to display descriptions, help texts or
40 /// other larger texts. It corresponds to the representation which is also to
41 /// be seen on the CDialogTextViewer.
42 ///
43 /// It has the header \ref TextBox.h "#include <kodi/gui/controls/TextBox.h>"
44 /// be included to enjoy it.
45 ///
46 /// Here you find the needed skin part for a \ref Text_Box "textbox control".
47 ///
48 /// @note The call of the control is only possible from the corresponding
49 /// window as its class and identification number is required.
50 ///
51 class CTextBox : public CAddonGUIControlBase
52 {
53 public:
54 //==========================================================================
55 ///
56 /// \ingroup cpp_kodi_gui_controls_CTextBox
57 /// @brief Construct a new control
58 ///
59 /// @param[in] window related window control class
60 /// @param[in] controlId Used skin xml control id
61 ///
62 CTextBox(CWindow* window, int controlId)
63 : CAddonGUIControlBase(window)
64 {
65 m_controlHandle = m_interface->kodi_gui->window->get_control_text_box(m_interface->kodiBase, m_Window->GetControlHandle(), controlId);
66 if (!m_controlHandle)
67 kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::CTextBox can't create control class from Kodi !!!");
68 }
69 //--------------------------------------------------------------------------
70
71 //==========================================================================
72 ///
73 /// \ingroup cpp_kodi_gui_controls_CTextBox
74 /// @brief Destructor
75 ///
76 ~CTextBox() override = default;
77 //--------------------------------------------------------------------------
78
79 //==========================================================================
80 ///
81 /// \ingroup cpp_kodi_gui_controls_CTextBox
82 /// @brief Set the control on window to visible
83 ///
84 /// @param[in] visible If true visible, otherwise hidden
85 ///
86 void SetVisible(bool visible)
87 {
88 m_interface->kodi_gui->control_text_box->set_visible(m_interface->kodiBase, m_controlHandle, visible);
89 }
90 //--------------------------------------------------------------------------
91
92 //==========================================================================
93 ///
94 /// \ingroup cpp_kodi_gui_controls_CTextBox
95 /// @brief To reset box an remove all the text
96 ///
97 void Reset()
98 {
99 m_interface->kodi_gui->control_text_box->reset(m_controlHandle, m_controlHandle);
100 }
101 //--------------------------------------------------------------------------
102
103 //==========================================================================
104 ///
105 /// \ingroup cpp_kodi_gui_controls_CTextBox
106 /// @brief To set the text on box
107 ///
108 /// @param[in] text Text to show
109 ///
110 void SetText(const std::string& text)
111 {
112 m_interface->kodi_gui->control_text_box->set_text(m_interface->kodiBase, m_controlHandle, text.c_str());
113 }
114 //--------------------------------------------------------------------------
115
116 //==========================================================================
117 ///
118 /// \ingroup cpp_kodi_gui_controls_CTextBox
119 /// @brief Get the used text from control
120 ///
121 /// @return Text shown
122 ///
123 std::string GetText() const
124 {
125 std::string text;
126 char* ret = m_interface->kodi_gui->control_text_box->get_text(m_interface->kodiBase, m_controlHandle);
127 if (ret != nullptr)
128 {
129 if (std::strlen(ret))
130 text = ret;
131 m_interface->free_string(m_interface->kodiBase, ret);
132 }
133 return text;
134 }
135 //--------------------------------------------------------------------------
136
137 //==========================================================================
138 ///
139 /// \ingroup cpp_kodi_gui_controls_CTextBox
140 /// @brief To scroll text on other position
141 ///
142 /// @param[in] position The line position to scroll to
143 ///
144 void Scroll(unsigned int position)
145 {
146 m_interface->kodi_gui->control_text_box->scroll(m_interface->kodiBase, m_controlHandle, position);
147 }
148 //--------------------------------------------------------------------------
149
150 //==========================================================================
151 ///
152 /// \ingroup cpp_kodi_gui_controls_CTextBox
153 /// @brief To set automatic scrolling of textbox
154 ///
155 /// Specifies the timing and conditions of any autoscrolling this textbox
156 /// should have. Times are in milliseconds. The content is delayed for the
157 /// given delay, then scrolls at a rate of one line per time interval until
158 /// the end. If the repeat tag is present, it then delays for the repeat
159 /// time, fades out over 1 second, and repeats. It does not wrap or reset
160 /// to the top at the end of the scroll.
161 ///
162 /// @param[in] delay Content delay
163 /// @param[in] time One line per time interval
164 /// @param[in] repeat Delays with given time, fades out over 1
165 /// second, and repeats
166 ///
167 void SetAutoScrolling(int delay, int time, int repeat)
168 {
169 m_interface->kodi_gui->control_text_box->set_auto_scrolling(m_interface->kodiBase, m_controlHandle, delay, time, repeat);
170 }
171 //--------------------------------------------------------------------------
172 };
173
174} /* namespace controls */
175} /* namespace gui */
176} /* namespace kodi */