FreeRDP
Loading...
Searching...
No Matches
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(SDL_Renderer* renderer, std::string label, std::string initial, Uint32 flags,
38 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(SDL_Renderer* renderer, SDL_Color color);
47 bool update_label(SDL_Renderer* renderer);
48
49 bool set_mouseover(SDL_Renderer* renderer, bool mouseOver);
50 bool set_highlight(SDL_Renderer* renderer, bool highlight);
51 bool update_input(SDL_Renderer* renderer);
52 bool resize_input(size_t size);
53
54 bool set_str(SDL_Renderer* renderer, const std::string& text);
55 bool remove_str(SDL_Renderer* renderer, size_t count);
56 bool append_str(SDL_Renderer* renderer, const std::string& text);
57
58 [[nodiscard]] const SDL_FRect& input_rect() const;
59 [[nodiscard]] std::string value() const;
60
61 [[nodiscard]] bool readonly() const;
62
63 protected:
64 bool update_input(SDL_Renderer* renderer, SDL_Color fgcolor);
65
66 private:
67 Uint32 _flags;
68 std::string _text;
69 std::string _text_label;
70 SdlWidget _label;
71 SdlWidget _input;
72 bool _highlight;
73 bool _mouseover;
74};