summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Edit.h
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2017-07-23 16:59:43 +0200
committermanuel <manuel@mausz.at>2017-07-23 16:59:43 +0200
commit4c3251ec645c8b71820dab7e51e612e5919d4e75 (patch)
tree9533268a93e58fc2e16de1b8ee3fafe3784e5225 /xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Edit.h
parentf44ecaa4f27e7538ddcad66d40e543bffa2d2d86 (diff)
downloadkodi-pvr-build-4c3251ec645c8b71820dab7e51e612e5919d4e75.tar.gz
kodi-pvr-build-4c3251ec645c8b71820dab7e51e612e5919d4e75.tar.bz2
kodi-pvr-build-4c3251ec645c8b71820dab7e51e612e5919d4e75.zip
sync with upstream
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Edit.h')
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Edit.h276
1 files changed, 276 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Edit.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Edit.h
new file mode 100644
index 0000000..83eeede
--- /dev/null
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Edit.h
@@ -0,0 +1,276 @@
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_CEdit Control Edit
35 /// \ingroup cpp_kodi_gui
36 /// @brief \cpp_class{ kodi::gui::controls::CEdit }
37 /// **Editable window text control used as an input control for the osd keyboard
38 /// and other input fields**
39 ///
40 /// The edit control allows a user to input text in Kodi. You can choose the
41 /// font, size, colour, location and header of the text to be displayed.
42 ///
43 /// It has the header \ref Edit.h "#include <kodi/gui/controls/Edit.h>"
44 /// be included to enjoy it.
45 ///
46 /// Here you find the needed skin part for a \ref skin_Edit_control
47 /// "edit control".
48 ///
49 /// @note The call of the control is only possible from the corresponding
50 /// window as its class and identification number is required.
51 ///
52
53 //============================================================================
54 // see gui/definition.h for use of group "cpp_kodi_gui_controls_CEdit_Defs"
55 ///
56 /// \defgroup cpp_kodi_gui_controls_CEdit_Defs Definitions, structures and enumerators
57 /// \ingroup cpp_kodi_gui_controls_CEdit
58 /// @brief **Library definition values**
59 ///
60
61} /* namespace controls */
62} /* namespace gui */
63} /* namespace kodi */
64
65//============================================================================
66///
67/// \ingroup cpp_kodi_gui_controls_CEdit_Defs
68/// @{
69/// @anchor AddonGUIInputType
70/// @brief Text input types used on kodi::gui::controls::CEdit
71enum AddonGUIInputType
72{
73 /// Text inside edit control only readable
74 ADDON_INPUT_TYPE_READONLY = -1,
75 /// Normal text entries
76 ADDON_INPUT_TYPE_TEXT = 0,
77 /// To use on edit control only numeric numbers
78 ADDON_INPUT_TYPE_NUMBER,
79 /// To insert seconds
80 ADDON_INPUT_TYPE_SECONDS,
81 /// To insert time
82 ADDON_INPUT_TYPE_TIME,
83 /// To insert a date
84 ADDON_INPUT_TYPE_DATE,
85 /// Used for write in IP addresses
86 ADDON_INPUT_TYPE_IPADDRESS,
87 /// Text field used as password entry field with not visible text
88 ADDON_INPUT_TYPE_PASSWORD,
89 /// Text field used as password entry field with not visible text but
90 /// returned as MD5 value
91 ADDON_INPUT_TYPE_PASSWORD_MD5,
92 /// Use text field for search purpose
93 ADDON_INPUT_TYPE_SEARCH,
94 /// Text field as filter
95 ADDON_INPUT_TYPE_FILTER,
96 ///
97 ADDON_INPUT_TYPE_PASSWORD_NUMBER_VERIFY_NEW
98};
99/// @}
100//----------------------------------------------------------------------------
101
102namespace kodi
103{
104namespace gui
105{
106namespace controls
107{
108
109 class CEdit : public CAddonGUIControlBase
110 {
111 public:
112 //==========================================================================
113 ///
114 /// \ingroup cpp_kodi_gui_controls_CEdit
115 /// @brief Construct a new control
116 ///
117 /// @param[in] window related window control class
118 /// @param[in] controlId Used skin xml control id
119 ///
120 CEdit(CWindow* window, int controlId)
121 : CAddonGUIControlBase(window)
122 {
123 m_controlHandle = m_interface->kodi_gui->window->get_control_edit(m_interface->kodiBase, m_Window->GetControlHandle(), controlId);
124 if (!m_controlHandle)
125 kodi::Log(ADDON_LOG_FATAL, "kodi::gui::control::CEdit can't create control class from Kodi !!!");
126 }
127 //--------------------------------------------------------------------------
128
129 //==========================================================================
130 ///
131 /// \ingroup cpp_kodi_gui_controls_CEdit
132 /// @brief Destructor
133 ///
134 ~CEdit() override = default;
135 //--------------------------------------------------------------------------
136
137 //==========================================================================
138 ///
139 /// \ingroup cpp_kodi_gui_controls_CEdit
140 /// @brief Set the control on window to visible
141 ///
142 /// @param[in] visible If true visible, otherwise hidden
143 ///
144 void SetVisible(bool visible)
145 {
146 m_interface->kodi_gui->control_edit->set_visible(m_interface->kodiBase, m_controlHandle, visible);
147 }
148 //--------------------------------------------------------------------------
149
150 //==========================================================================
151 ///
152 /// \ingroup cpp_kodi_gui_controls_CEdit
153 /// @brief Set's the control's enabled/disabled state
154 ///
155 /// @param[in] enabled If true enabled, otherwise disabled
156 ///
157 void SetEnabled(bool enabled)
158 {
159 m_interface->kodi_gui->control_edit->set_enabled(m_interface->kodiBase, m_controlHandle, enabled);
160 }
161 //--------------------------------------------------------------------------
162
163 //==========================================================================
164 ///
165 /// \ingroup cpp_kodi_gui_controls_CEdit
166 /// @brief To set the text string on edit control
167 ///
168 /// @param[in] label Text to show
169 ///
170 void SetLabel(const std::string& label)
171 {
172 m_interface->kodi_gui->control_edit->set_label(m_interface->kodiBase, m_controlHandle, label.c_str());
173 }
174 //--------------------------------------------------------------------------
175
176 //==========================================================================
177 ///
178 /// \ingroup cpp_kodi_gui_controls_CEdit
179 /// @brief Returns the text heading for this edit control.
180 ///
181 /// @return Heading text
182 ///
183 std::string GetLabel() const
184 {
185 std::string label;
186 char* ret = m_interface->kodi_gui->control_edit->get_label(m_interface->kodiBase, m_controlHandle);
187 if (ret != nullptr)
188 {
189 if (std::strlen(ret))
190 label = ret;
191 m_interface->free_string(m_interface->kodiBase, ret);
192 }
193 return label;
194 }
195 //--------------------------------------------------------------------------
196
197 //==========================================================================
198 ///
199 /// \ingroup cpp_kodi_gui_controls_CEdit
200 /// @brief Set's text heading for this edit control.
201 ///
202 /// @param[in] text string or unicode - text string.
203 ///
204 void SetText(const std::string& text)
205 {
206 m_interface->kodi_gui->control_edit->set_text(m_interface->kodiBase, m_controlHandle, text.c_str());
207 }
208 //--------------------------------------------------------------------------
209
210 //==========================================================================
211 ///
212 /// \ingroup cpp_kodi_gui_controls_CEdit
213 /// @brief Returns the text value for this edit control.
214 ///
215 /// @return Text value of control
216 ///
217 std::string GetText() const
218 {
219 std::string text;
220 char* ret = m_interface->kodi_gui->control_edit->get_text(m_interface->kodiBase, m_controlHandle);
221 if (ret != nullptr)
222 {
223 if (std::strlen(ret))
224 text = ret;
225 m_interface->free_string(m_interface->kodiBase, ret);
226 }
227 return text;
228 }
229 //--------------------------------------------------------------------------
230
231 //==========================================================================
232 ///
233 /// \ingroup cpp_kodi_gui_controls_CEdit
234 /// @brief Set the cursor position on text.
235 ///
236 /// @param[in] iPosition The position to set
237 ///
238 void SetCursorPosition(unsigned int iPosition)
239 {
240 m_interface->kodi_gui->control_edit->set_cursor_position(m_interface->kodiBase, m_controlHandle, iPosition);
241 }
242 //--------------------------------------------------------------------------
243
244 //==========================================================================
245 ///
246 /// \ingroup cpp_kodi_gui_controls_CEdit
247 /// @brief To get current cursor position on text field
248 ///
249 /// @return The current cursor position
250 ///
251 unsigned int GetCursorPosition()
252 {
253 return m_interface->kodi_gui->control_edit->get_cursor_position(m_interface->kodiBase, m_controlHandle);
254 }
255 //--------------------------------------------------------------------------
256
257 //==========================================================================
258 ///
259 /// \ingroup cpp_kodi_gui_controls_CEdit
260 /// @brief To set field input type which are defined on \ref AddonGUIInputType
261 ///
262 /// @param[in] type The \ref AddonGUIInputType "Add-on input type"
263 /// to use
264 /// @param[in] heading The heading text for related keyboard
265 /// dialog
266 ///
267 void SetInputType(AddonGUIInputType type, const std::string& heading)
268 {
269 m_interface->kodi_gui->control_edit->set_input_type(m_interface->kodiBase, m_controlHandle, static_cast<int>(type), heading.c_str());
270 }
271 //--------------------------------------------------------------------------
272 };
273
274} /* namespace controls */
275} /* namespace gui */
276} /* namespace kodi */