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

#include <sdl_input_widget_pair.hpp>

Public Types

enum  { SDL_INPUT_MASK = 1 , SDL_INPUT_READONLY = 2 }
 

Public Member Functions

 SdlInputWidgetPair (std::shared_ptr< SDL_Renderer > &renderer, const std::string &label, const std::string &initial, Uint32 flags, size_t offset, size_t width, size_t height)
 
 SdlInputWidgetPair (SdlInputWidgetPair &&other) noexcept
 
 SdlInputWidgetPair (const SdlInputWidgetPair &other)=delete
 
SdlInputWidgetPairoperator= (const SdlInputWidgetPair &other)=delete
 
SdlInputWidgetPairoperator= (SdlInputWidgetPair &&other)=delete
 
bool set_mouseover (bool mouseOver)
 
bool set_highlight (bool highlight)
 
bool set_str (const std::string &text)
 
bool remove_str (size_t count)
 
bool append_str (const std::string &text)
 
const SDL_FRect & input_rect () const
 
std::string value () const
 
bool readonly () const
 
bool update ()
 

Protected Member Functions

bool update_input_text (const std::string &txt)
 

Protected Attributes

Uint32 _vpadding = 5
 
Uint32 _hpadding = 10
 

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.

Definition at line 29 of file sdl_input_widget_pair.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Definition at line 32 of file sdl_input_widget_pair.hpp.

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

Constructor & Destructor Documentation

◆ SdlInputWidgetPair()

SdlInputWidgetPair::SdlInputWidgetPair ( std::shared_ptr< SDL_Renderer > &  renderer,
const std::string &  label,
const std::string &  initial,
Uint32  flags,
size_t  offset,
size_t  width,
size_t  height 
)

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.

Definition at line 34 of file sdl_input_widget_pair.cpp.

37 : _flags(flags), _label(renderer, { 0, static_cast<float>(offset * (height + _vpadding)),
38 static_cast<float>(width), static_cast<float>(height) }),
39 _input(renderer, { static_cast<float>(width + _hpadding),
40 static_cast<float>(offset * (height + _vpadding)),
41 static_cast<float>(width), static_cast<float>(height) })
42{
43 _label.update_text(label);
44 update_input_text(initial);
45}

Member Function Documentation

◆ append_str()

bool SdlInputWidgetPair::append_str ( const std::string &  text)

Definition at line 83 of file sdl_input_widget_pair.cpp.

84{
85 if (readonly())
86 return true;
87
88 auto itext = _text;
89 itext.append(text);
90 return update_input_text(itext);
91}

◆ input_rect()

const SDL_FRect & SdlInputWidgetPair::input_rect ( ) const

Definition at line 93 of file sdl_input_widget_pair.cpp.

94{
95 return _input.rect();
96}

◆ readonly()

bool SdlInputWidgetPair::readonly ( ) const

Definition at line 103 of file sdl_input_widget_pair.cpp.

104{
105 return (_flags & SDL_INPUT_READONLY) != 0;
106}

◆ remove_str()

bool SdlInputWidgetPair::remove_str ( size_t  count)

Definition at line 70 of file sdl_input_widget_pair.cpp.

71{
72 if (readonly())
73 return true;
74
75 auto text = _text;
76 if (text.empty())
77 return true;
78
79 auto newsize = text.size() - std::min<size_t>(text.size(), count);
80 return update_input_text(text.substr(0, newsize));
81}

◆ set_highlight()

bool SdlInputWidgetPair::set_highlight ( bool  highlight)

Definition at line 56 of file sdl_input_widget_pair.cpp.

57{
58 if (readonly())
59 return true;
60 return _input.highlight(highlight);
61}

◆ set_mouseover()

bool SdlInputWidgetPair::set_mouseover ( bool  mouseOver)

Definition at line 49 of file sdl_input_widget_pair.cpp.

50{
51 if (readonly())
52 return true;
53 return _input.mouseover(mouseOver);
54}

◆ set_str()

bool SdlInputWidgetPair::set_str ( const std::string &  text)

Definition at line 63 of file sdl_input_widget_pair.cpp.

64{
65 if (readonly())
66 return true;
67 return update_input_text(text);
68}

◆ update()

bool SdlInputWidgetPair::update ( )

Definition at line 108 of file sdl_input_widget_pair.cpp.

109{
110 // TODO: Draw the pair area
111 if (!_label.update())
112 return false;
113 if (!_input.update())
114 return false;
115 return true;
116}

◆ update_input_text()

bool SdlInputWidgetPair::update_input_text ( const std::string &  txt)
protected

Definition at line 118 of file sdl_input_widget_pair.cpp.

119{
120 _text = txt;
121 auto text = txt;
122
123 if (_flags & SDL_INPUT_MASK)
124 {
125 std::fill(text.begin(), text.end(), '*');
126 }
127
128 return _input.update_text(text);
129}

◆ value()

std::string SdlInputWidgetPair::value ( ) const

Definition at line 98 of file sdl_input_widget_pair.cpp.

99{
100 return _text;
101}

Field Documentation

◆ _hpadding

Uint32 SdlInputWidgetPair::_hpadding = 10
protected

Definition at line 66 of file sdl_input_widget_pair.hpp.

◆ _vpadding

Uint32 SdlInputWidgetPair::_vpadding = 5
protected

Definition at line 65 of file sdl_input_widget_pair.hpp.


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