Kodi Development 22.0
for Binary and Script based Add-Ons
 
Loading...
Searching...
No Matches
Edit.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/edit.h"
12#include "../Window.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace controls
21{
22
23//==============================================================================
42
43//==============================================================================
44// see gui/definition.h for use of group "cpp_kodi_gui_windows_controls_CEdit_Defs"
50
51class ATTR_DLL_LOCAL CEdit : public CAddonGUIControlBase
52{
53public:
54 //============================================================================
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)
67 "kodi::gui::control::CEdit can't create control class from Kodi !!!");
68 }
69 //----------------------------------------------------------------------------
70
71 //============================================================================
75 ~CEdit() override = default;
76 //----------------------------------------------------------------------------
77
78 //============================================================================
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 //============================================================================
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 //============================================================================
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 //============================================================================
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 //============================================================================
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 //============================================================================
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 //============================================================================
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 //============================================================================
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 //============================================================================
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 */
Definition ListItem.h:26
Definition Window.h:110
Definition Edit.h:52
@ ADDON_LOG_FATAL
4 : To notify fatal unrecoverable errors, which can may also indicate upcoming crashes.
Definition addon_base.h:197
AddonGUIInputType
Text input types used on kodi::gui::controls::CEdit.
Definition edit.h:25
std::string GetText() const
Returns the text value for this edit control.
Definition Edit.h:157
std::string GetLabel() const
Returns the text heading for this edit control.
Definition Edit.h:123
CEdit(CWindow *window, int controlId)
Construct a new control.
Definition Edit.h:61
void SetVisible(bool visible)
Set the control on window to visible.
Definition Edit.h:84
void SetText(const std::string &text)
Set's text heading for this edit control.
Definition Edit.h:144
~CEdit() override=default
Destructor.
unsigned int GetCursorPosition()
To get current cursor position on text field.
Definition Edit.h:191
void SetEnabled(bool enabled)
Set's the control's enabled/disabled state.
Definition Edit.h:97
void SetLabel(const std::string &label)
To set the text string on edit control.
Definition Edit.h:110
void SetCursorPosition(unsigned int position)
Set the cursor position on text.
Definition Edit.h:178
void SetInputType(AddonGUIInputType type, const std::string &heading)
To set field input type which are defined on AddonGUIInputType.
Definition Edit.h:205
void ATTR_DLL_LOCAL Log(const ADDON_LOG loglevel, const char *format,...)
Add a message to Kodi's log.
Definition AddonBase.h:1938