summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Edit.h
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
committermanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
commitbe933ef2241d79558f91796cc5b3a161f72ebf9c (patch)
treefe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Edit.h
parent5f8335c1e49ce108ef3481863833c98efa00411b (diff)
downloadkodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip
sync with upstream
Diffstat (limited to 'xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Edit.h')
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Edit.h217
1 files changed, 217 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Edit.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Edit.h
new file mode 100644
index 0000000..00c6231
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Edit.h
@@ -0,0 +1,217 @@
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/edit.h"
12#include "../Window.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace controls
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_gui_windows_controls_CEdit Control Edit
25/// @ingroup cpp_kodi_gui_windows_controls
26/// @brief @cpp_class{ kodi::gui::controls::CEdit }
27/// **Editable window text control used as an input control for the osd keyboard
28/// and other input fields**\n
29/// The edit control allows a user to input text in Kodi.
30///
31/// You can choose the font, size, colour, location and header of the text to be
32/// displayed.
33///
34/// It has the header @ref Edit.h "#include <kodi/gui/controls/Edit.h>"
35/// be included to enjoy it.
36///
37/// Here you find the needed skin partfor a @ref skin_Edit_control "edit control".
38///
39/// @note The call of the control is only possible from the corresponding
40/// window as its class and identification number is required.
41///
42
43//==============================================================================
44// see gui/definition.h for use of group "cpp_kodi_gui_windows_controls_CEdit_Defs"
45///
46/// @defgroup cpp_kodi_gui_windows_controls_CEdit_Defs Definitions, structures and enumerators
47/// @ingroup cpp_kodi_gui_windows_controls_CEdit
48/// @brief **Library definition values**
49///
50
51class ATTRIBUTE_HIDDEN CEdit : public CAddonGUIControlBase
52{
53public:
54 //============================================================================
55 /// @ingroup cpp_kodi_gui_windows_controls_CEdit
56 /// @brief Construct a new control.
57 ///
58 /// @param[in] window Related window control class
59 /// @param[in] controlId Used skin xml control id
60 ///
61 CEdit(CWindow* window, int controlId) : CAddonGUIControlBase(window)
62 {
63 m_controlHandle = m_interface->kodi_gui->window->get_control_edit(
64 m_interface->kodiBase, m_Window->GetControlHandle(), controlId);
65 if (!m_controlHandle)
66 kodi::Log(ADDON_LOG_FATAL,
67 "kodi::gui::control::CEdit can't create control class from Kodi !!!");
68 }
69 //----------------------------------------------------------------------------
70
71 //============================================================================
72 /// @ingroup cpp_kodi_gui_windows_controls_CEdit
73 /// @brief Destructor.
74 ///
75 ~CEdit() override = default;
76 //----------------------------------------------------------------------------
77
78 //============================================================================
79 /// @ingroup cpp_kodi_gui_windows_controls_CEdit
80 /// @brief Set the control on window to visible.
81 ///
82 /// @param[in] visible If true visible, otherwise hidden
83 ///
84 void SetVisible(bool visible)
85 {
86 m_interface->kodi_gui->control_edit->set_visible(m_interface->kodiBase, m_controlHandle,
87 visible);
88 }
89 //----------------------------------------------------------------------------
90
91 //============================================================================
92 /// @ingroup cpp_kodi_gui_windows_controls_CEdit
93 /// @brief Set's the control's enabled/disabled state.
94 ///
95 /// @param[in] enabled If true enabled, otherwise disabled
96 ///
97 void SetEnabled(bool enabled)
98 {
99 m_interface->kodi_gui->control_edit->set_enabled(m_interface->kodiBase, m_controlHandle,
100 enabled);
101 }
102 //----------------------------------------------------------------------------
103
104 //============================================================================
105 /// @ingroup cpp_kodi_gui_windows_controls_CEdit
106 /// @brief To set the text string on edit control.
107 ///
108 /// @param[in] label Text to show
109 ///
110 void SetLabel(const std::string& label)
111 {
112 m_interface->kodi_gui->control_edit->set_label(m_interface->kodiBase, m_controlHandle,
113 label.c_str());
114 }
115 //----------------------------------------------------------------------------
116
117 //============================================================================
118 /// @ingroup cpp_kodi_gui_windows_controls_CEdit
119 /// @brief Returns the text heading for this edit control.
120 ///
121 /// @return Heading text
122 ///
123 std::string GetLabel() const
124 {
125 std::string label;
126 char* ret =
127 m_interface->kodi_gui->control_edit->get_label(m_interface->kodiBase, m_controlHandle);
128 if (ret != nullptr)
129 {
130 if (std::strlen(ret))
131 label = ret;
132 m_interface->free_string(m_interface->kodiBase, ret);
133 }
134 return label;
135 }
136 //----------------------------------------------------------------------------
137
138 //============================================================================
139 /// @ingroup cpp_kodi_gui_windows_controls_CEdit
140 /// @brief Set's text heading for this edit control.
141 ///
142 /// @param[in] text string or unicode - text string.
143 ///
144 void SetText(const std::string& text)
145 {
146 m_interface->kodi_gui->control_edit->set_text(m_interface->kodiBase, m_controlHandle,
147 text.c_str());
148 }
149 //----------------------------------------------------------------------------
150
151 //============================================================================
152 /// @ingroup cpp_kodi_gui_windows_controls_CEdit
153 /// @brief Returns the text value for this edit control.
154 ///
155 /// @return Text value of control
156 ///
157 std::string GetText() const
158 {
159 std::string text;
160 char* ret =
161 m_interface->kodi_gui->control_edit->get_text(m_interface->kodiBase, m_controlHandle);
162 if (ret != nullptr)
163 {
164 if (std::strlen(ret))
165 text = ret;
166 m_interface->free_string(m_interface->kodiBase, ret);
167 }
168 return text;
169 }
170 //----------------------------------------------------------------------------
171
172 //============================================================================
173 /// @ingroup cpp_kodi_gui_windows_controls_CEdit
174 /// @brief Set the cursor position on text.
175 ///
176 /// @param[in] position The position to set
177 ///
178 void SetCursorPosition(unsigned int position)
179 {
180 m_interface->kodi_gui->control_edit->set_cursor_position(m_interface->kodiBase, m_controlHandle,
181 position);
182 }
183 //----------------------------------------------------------------------------
184
185 //============================================================================
186 /// @ingroup cpp_kodi_gui_windows_controls_CEdit
187 /// @brief To get current cursor position on text field.
188 ///
189 /// @return The current cursor position
190 ///
191 unsigned int GetCursorPosition()
192 {
193 return m_interface->kodi_gui->control_edit->get_cursor_position(m_interface->kodiBase,
194 m_controlHandle);
195 }
196 //----------------------------------------------------------------------------
197
198 //============================================================================
199 /// @ingroup cpp_kodi_gui_windows_controls_CEdit
200 /// @brief To set field input type which are defined on @ref AddonGUIInputType.
201 ///
202 /// @param[in] type The @ref AddonGUIInputType "Add-on input type" to use
203 /// @param[in] heading The heading text for related keyboard dialog
204 ///
205 void SetInputType(AddonGUIInputType type, const std::string& heading)
206 {
207 m_interface->kodi_gui->control_edit->set_input_type(m_interface->kodiBase, m_controlHandle,
208 static_cast<int>(type), heading.c_str());
209 }
210 //----------------------------------------------------------------------------
211};
212
213} /* namespace controls */
214} /* namespace gui */
215} /* namespace kodi */
216
217#endif /* __cplusplus */