FreeRDP
Loading...
Searching...
No Matches
SdlInputWidget Class Reference

#include <sdl_input.hpp>

Inheritance diagram for SdlInputWidget:
Collaboration diagram for SdlInputWidget:

Public Types

enum  { SDL_INPUT_MASK = 1 , SDL_INPUT_READONLY = 2 }
 

Public Member Functions

 SdlInputWidget (SDL_Renderer *renderer, std::string label, std::string initial, Uint32 flags, size_t offset, size_t width, size_t height)
 
 SdlInputWidget (SdlInputWidget &&other) noexcept
 
 SdlInputWidget (const SdlInputWidget &other)=delete
 
SdlInputWidgetoperator= (const SdlInputWidget &other)=delete
 
SdlInputWidgetoperator= (SdlInputWidget &&other)=delete
 
bool fill_label (SDL_Renderer *renderer, SDL_Color color)
 
bool update_label (SDL_Renderer *renderer)
 
bool set_mouseover (SDL_Renderer *renderer, bool mouseOver)
 
bool set_highlight (SDL_Renderer *renderer, bool highlight)
 
bool update_input (SDL_Renderer *renderer)
 
bool resize_input (size_t size)
 
bool set_str (SDL_Renderer *renderer, const std::string &text)
 
bool remove_str (SDL_Renderer *renderer, size_t count)
 
bool append_str (SDL_Renderer *renderer, const std::string &text)
 
const SDL_Rect & input_rect () const
 
std::string value () const
 
bool readonly () const
 
 SdlInputWidget (std::shared_ptr< SDL_Renderer > &renderer, const SDL_FRect &rect)
 
 SdlInputWidget (std::shared_ptr< SDL_Renderer > &renderer, const SDL_FRect &rect, SDL_IOStream *ops)
 
 SdlInputWidget (SdlInputWidget &&other) noexcept
 
 SdlInputWidget (const SdlInputWidget &other)=delete
 
SdlInputWidgetoperator= (const SdlInputWidget &other)=delete
 
SdlInputWidgetoperator= (SdlInputWidget &&other) noexcept=delete
 
std::string text () const
 
- Public Member Functions inherited from SdlSelectableWidget
 SdlSelectableWidget (std::shared_ptr< SDL_Renderer > &renderer, const SDL_FRect &rect)
 
 SdlSelectableWidget (SdlSelectableWidget &&other) noexcept
 
 SdlSelectableWidget (const SdlSelectableWidget &other)=delete
 
SdlSelectableWidgetoperator= (const SdlSelectableWidget &other)=delete
 
SdlSelectableWidgetoperator= (SdlSelectableWidget &&other)=delete
 
bool highlight (bool enable)
 
bool mouseover (bool enable)
 
- Public Member Functions inherited from SdlWidget
 SdlWidget (SDL_Renderer *renderer, SDL_Rect rect, bool input)
 
 SdlWidget (SdlWidget &&other) noexcept
 
bool fill (SDL_Renderer *renderer, SDL_Color color)
 
bool fill (SDL_Renderer *renderer, const std::vector< SDL_Color > &colors)
 
bool update_text (SDL_Renderer *renderer, const std::string &text, SDL_Color fgcolor)
 
bool update_text (SDL_Renderer *renderer, const std::string &text, SDL_Color fgcolor, SDL_Color bgcolor)
 
bool wrap () const
 
bool set_wrap (bool wrap=true, size_t width=0)
 
const SDL_Rect & rect () const
 
 SdlWidget (const SdlWidget &other)=delete
 
SdlWidgetoperator= (const SdlWidget &other)=delete
 
SdlWidgetoperator= (SdlWidget &&other)=delete
 
 SdlWidget (std::shared_ptr< SDL_Renderer > &renderer, const SDL_FRect &rect)
 
 SdlWidget (const SdlWidget &other)=delete
 
 SdlWidget (SdlWidget &&other) noexcept
 
SdlWidgetoperator= (const SdlWidget &other)=delete
 
SdlWidgetoperator= (SdlWidget &&other)=delete
 
bool fill (SDL_Color color) const
 
bool fill (const std::vector< SDL_Color > &colors) const
 
bool update_text (const std::string &text)
 
bool wrap () const
 
bool set_wrap (bool wrap=true, size_t width=0)
 
const SDL_FRect & rect () const
 
bool update ()
 

Protected Member Functions

bool update_input (SDL_Renderer *renderer, SDL_Color fgcolor)
 
- Protected Member Functions inherited from SdlSelectableWidget
bool updateInternal () override
 
- Protected Member Functions inherited from SdlWidget
virtual bool clear () const
 

Additional Inherited Members

- Static Public Member Functions inherited from SdlWidget
static bool error_ex (Sint32 res, const char *what, const char *file, size_t line, const char *fkt)
 
static bool error_ex (bool success, const char *what, const char *file, size_t line, const char *fkt)
 
- Protected Attributes inherited from SdlSelectableWidget
SDL_Color _highlightcolor = { 0xcd, 0xca, 0x35, 0x60 }
 
SDL_Color _mouseovercolor = { 0x66, 0xff, 0x66, 0x60 }
 
- Protected Attributes inherited from SdlWidget
std::shared_ptr< SDL_Renderer > _renderer {}
 
SDL_Color _backgroundcolor = { 0x56, 0x56, 0x56, 0xff }
 
SDL_Color _fontcolor = { 0xd1, 0xcf, 0xcd, 0xff }
 
std::string _text
 

Detailed Description

FreeRDP: A Remote Desktop Protocol Implementation SDL Client helper dialogs

Copyright 2023 Armin Novak armin.nosp@m..nov.nosp@m.ak@th.nosp@m.inca.nosp@m.st.co.nosp@m.m

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

FreeRDP: A Remote Desktop Protocol Implementation SDL Client helper dialogs

Copyright 2025 Armin Novak armin.nosp@m..nov.nosp@m.ak@th.nosp@m.inca.nosp@m.st.co.nosp@m.m Copyright 2025 Thincast Technologies GmbH

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition at line 28 of file sdl_input.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Definition at line 31 of file sdl_input.hpp.

32 {
33 SDL_INPUT_MASK = 1,
34 SDL_INPUT_READONLY = 2
35 };

Constructor & Destructor Documentation

◆ SdlInputWidget() [1/3]

SdlInputWidget::SdlInputWidget ( SDL_Renderer *  renderer,
std::string  label,
std::string  initial,
Uint32  flags,
size_t  offset,
size_t  width,
size_t  height 
)

Definition at line 43 of file sdl_input.cpp.

45 : _flags(flags), _text(std::move(initial)), _text_label(std::move(label)),
46 _label(renderer,
47 { 0, static_cast<int>(offset * (height + vpadding)), static_cast<int>(width),
48 static_cast<int>(height) },
49 false),
50 _input(renderer,
51 { static_cast<int>(width + hpadding), static_cast<int>(offset * (height + vpadding)),
52 static_cast<int>(width), static_cast<int>(height) },
53 true),
54 _highlight(false), _mouseover(false)
55{
56}

◆ SdlInputWidget() [2/3]

SdlInputWidget::SdlInputWidget ( SdlInputWidget &&  other)
defaultnoexcept

Definition at line 58 of file sdl_input.cpp.

59 : _flags(other._flags), _text(std::move(other._text)),
60 _text_label(std::move(other._text_label)), _label(std::move(other._label)),
61 _input(std::move(other._input)), _highlight(other._highlight), _mouseover(other._mouseover)
62{
63}

◆ SdlInputWidget() [3/3]

SdlInputWidget::SdlInputWidget ( std::shared_ptr< SDL_Renderer > &  renderer,
const SDL_FRect &  rect 
)

FreeRDP: A Remote Desktop Protocol Implementation SDL Client helper dialogs

Copyright 2025 Armin Novak armin.nosp@m..nov.nosp@m.ak@th.nosp@m.inca.nosp@m.st.co.nosp@m.m Copyright 2025 Thincast Technologies GmbH

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition at line 22 of file sdl_input_widget.cpp.

23 : SdlSelectableWidget(renderer, rect)
24{
25 init();
26}

Member Function Documentation

◆ append_str()

bool SdlInputWidget::append_str ( SDL_Renderer *  renderer,
const std::string &  text 
)

Definition at line 137 of file sdl_input.cpp.

138{
139 assert(renderer);
140 if (readonly())
141 return true;
142
143 _text.append(text);
144 if (!resize_input(_text.size()))
145 return false;
146 return update_input(renderer);
147}

◆ fill_label()

bool SdlInputWidget::fill_label ( SDL_Renderer *  renderer,
SDL_Color  color 
)

Definition at line 65 of file sdl_input.cpp.

66{
67 if (!_label.fill(renderer, color))
68 return false;
69 return _label.update_text(renderer, _text_label, labelfontcolor);
70}

◆ input_rect()

const SDL_Rect & SdlInputWidget::input_rect ( ) const

Definition at line 149 of file sdl_input.cpp.

150{
151 return _input.rect();
152}

◆ readonly()

bool SdlInputWidget::readonly ( ) const

Definition at line 159 of file sdl_input.cpp.

160{
161 return (_flags & SDL_INPUT_READONLY) != 0;
162}

◆ remove_str()

bool SdlInputWidget::remove_str ( SDL_Renderer *  renderer,
size_t  count 
)

Definition at line 123 of file sdl_input.cpp.

124{
125 if (readonly())
126 return true;
127
128 assert(renderer);
129 if (_text.empty())
130 return true;
131
132 if (!resize_input(_text.size() - count))
133 return false;
134 return update_input(renderer);
135}

◆ resize_input()

bool SdlInputWidget::resize_input ( size_t  size)

Definition at line 106 of file sdl_input.cpp.

107{
108 _text.resize(size);
109
110 return true;
111}

◆ set_highlight()

bool SdlInputWidget::set_highlight ( SDL_Renderer *  renderer,
bool  highlight 
)

Definition at line 85 of file sdl_input.cpp.

86{
87 if (readonly())
88 return true;
89 _highlight = highlight;
90 return update_input(renderer);
91}

◆ set_mouseover()

bool SdlInputWidget::set_mouseover ( SDL_Renderer *  renderer,
bool  mouseOver 
)

Definition at line 77 of file sdl_input.cpp.

78{
79 if (readonly())
80 return true;
81 _mouseover = mouseOver;
82 return update_input(renderer);
83}

◆ set_str()

bool SdlInputWidget::set_str ( SDL_Renderer *  renderer,
const std::string &  text 
)

Definition at line 113 of file sdl_input.cpp.

114{
115 if (readonly())
116 return true;
117 _text = text;
118 if (!resize_input(_text.size()))
119 return false;
120 return update_input(renderer);
121}

◆ text()

std::string SdlInputWidget::text ( ) const

Definition at line 30 of file sdl_input_widget.cpp.

31{
32 return _text;
33}

◆ update_input() [1/2]

bool SdlInputWidget::update_input ( SDL_Renderer *  renderer)

Definition at line 93 of file sdl_input.cpp.

94{
95 std::vector<SDL_Color> colors = { inputbackgroundcolor };
96 if (_highlight)
97 colors.push_back(inputhighlightcolor);
98 if (_mouseover)
99 colors.push_back(inputmouseovercolor);
100
101 if (!_input.fill(renderer, colors))
102 return false;
103 return update_input(renderer, inputfontcolor);
104}

◆ update_input() [2/2]

bool SdlInputWidget::update_input ( SDL_Renderer *  renderer,
SDL_Color  fgcolor 
)
protected

Definition at line 164 of file sdl_input.cpp.

165{
166 std::string text = _text;
167 if (!text.empty())
168 {
169 if (_flags & SDL_INPUT_MASK)
170 {
171 for (char& x : text)
172 x = '*';
173 }
174 }
175
176 return _input.update_text(renderer, text, fgcolor);
177}

◆ update_label()

bool SdlInputWidget::update_label ( SDL_Renderer *  renderer)

Definition at line 72 of file sdl_input.cpp.

73{
74 return _label.update_text(renderer, _text_label, labelfontcolor, labelbackgroundcolor);
75}

◆ value()

std::string SdlInputWidget::value ( ) const

Definition at line 154 of file sdl_input.cpp.

155{
156 return _text;
157}

The documentation for this class was generated from the following files: