TermOx
password_edit.hpp
1 #ifndef TERMOX_WIDGET_WIDGETS_PASSWORD_EDIT_HPP
2 #define TERMOX_WIDGET_WIDGETS_PASSWORD_EDIT_HPP
3 #include <termox/painter/glyph.hpp>
4 #include <termox/painter/painter.hpp>
5 #include <termox/widget/widgets/line_edit.hpp>
6 
7 namespace ox {
8 
10 
13 class Password_edit : public Line_edit {
14  public:
15  struct Parameters {
16  Glyph veil = U'*';
17  bool show_contents = false;
18  };
19 
20  public:
21  explicit Password_edit(Glyph veil = U'*', bool show_contents = false);
22 
23  explicit Password_edit(Parameters p);
24 
25  public:
27  void set_veil(Glyph x);
28 
30  [[nodiscard]] auto veil() const -> Glyph;
31 
33  void show_contents(bool enable);
34 
36  [[nodiscard]] auto shows_contents() const -> bool;
37 
38  protected:
39  auto paint_event(Painter& p) -> bool;
40 
41  private:
42  Glyph veil_ = U'*';
43  bool show_contents_ = false;
44 
45  private:
46  using Line_edit::disable_validator;
47  using Line_edit::set_validator;
48  using Line_edit::validator;
49  using Textline_base::alignment;
50  using Textline_base::clear_on_focus;
51  using Textline_base::focus_in_action;
52  using Textline_base::nothing_on_focus;
53  using Textline_base::set_alignment;
54  using Textline_base::set_focus_in_action;
55 };
56 
57 } // namespace ox
58 #endif // TERMOX_WIDGET_WIDGETS_PASSWORD_EDIT_HPP
Definition: line_edit.hpp:16
Contains functions to paint Glyphs to a Widget's screen area.
Definition: painter.hpp:21
A Line_edit that veils the input characters so the contents are hidden.
Definition: password_edit.hpp:13
auto paint_event(Painter &p) -> bool
Handles Paint_event objects.
Definition: password_edit.cpp:24
void show_contents(bool enable)
Display each input char instead of veil if enable is true.
Definition: password_edit.cpp:20
auto veil() const -> Glyph
Return the currently set veil.
Definition: password_edit.cpp:18
void set_veil(Glyph x)
Set the Glyph that is show in place of the actual input Glyphs.
Definition: password_edit.cpp:16
auto shows_contents() const -> bool
Return true if input chars are not hidden.
Definition: password_edit.cpp:22
void enable(bool enable=true)
Enable this Widget and send an Enable_event to itself.
Definition: widget.cpp:89
void nothing_on_focus()
Does nothing on focus in event.
Definition: textline_base.cpp:55
auto alignment() const noexcept -> ox::Align
Return the current alignment.
Definition: textline_base.cpp:46
void set_focus_in_action(Action x)
Set the Action that occurs on focus in events.
Definition: textline_base.cpp:51
auto focus_in_action() const noexcept -> Action
Return the currently used focus in event Action.
Definition: textline_base.cpp:57
void clear_on_focus()
Clear the text on focus in event, restoring if nothing edited.
Definition: textline_base.cpp:53
void set_alignment(ox::Align x)
Set either Left or Right Alignment, asserts with other alignments.
Definition: textline_base.cpp:40
Holds a description of a paintable tile on the screen.
Definition: glyph.hpp:11
Definition: password_edit.hpp:15