FreeRDP
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
SDL3/dialogs/sdl_input.hpp
1
20#pragma once
21
22#include <vector>
23#include <string>
24
25#include <SDL3/SDL.h>
26#include "sdl_widget.hpp"
27
29{
30 public:
31 enum
32 {
33 SDL_INPUT_MASK = 1,
34 SDL_INPUT_READONLY = 2
35 };
36
37 SdlInputWidget(std::shared_ptr<SDL_Renderer>& renderer, std::string label, std::string initial,
38 Uint32 flags, size_t offset, size_t width, size_t height);
39 SdlInputWidget(SdlInputWidget&& other) noexcept;
40 SdlInputWidget(const SdlInputWidget& other) = delete;
41 ~SdlInputWidget() = default;
42
43 SdlInputWidget& operator=(const SdlInputWidget& other) = delete;
44 SdlInputWidget& operator=(SdlInputWidget&& other) = delete;
45
46 bool fill_label(std::shared_ptr<SDL_Renderer>& renderer, SDL_Color color);
47 bool update_label(std::shared_ptr<SDL_Renderer>& renderer);
48
49 bool set_mouseover(std::shared_ptr<SDL_Renderer>& renderer, bool mouseOver);
50 bool set_highlight(std::shared_ptr<SDL_Renderer>& renderer, bool highlight);
51 bool update_input(std::shared_ptr<SDL_Renderer>& renderer) const;
52
53 bool set_str(std::shared_ptr<SDL_Renderer>& renderer, const std::string& text);
54 bool remove_str(std::shared_ptr<SDL_Renderer>& renderer, size_t count);
55 bool append_str(std::shared_ptr<SDL_Renderer>& renderer, const std::string& text);
56
57 [[nodiscard]] const SDL_FRect& input_rect() const;
58 [[nodiscard]] std::string value() const;
59
60 [[nodiscard]] bool readonly() const;
61
62 protected:
63 bool update_input(std::shared_ptr<SDL_Renderer>& renderer, SDL_Color fgcolor) const;
64
65 private:
66 Uint32 _flags{};
67 std::string _text;
68 std::string _text_label;
69 SdlWidget _label;
70 SdlWidget _input;
71 bool _highlight;
72 bool _mouseover;
73};