The Battle for Wesnoth
1.19.5+dev
gui
widgets
password_box.hpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2009 - 2024
3
by Thomas Baumhauer <thomas.baumhauer@NOSPAMgmail.com>, Mark de Wever <koraq@xs4all.nl>
4
Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY.
12
13
See the COPYING file for more details.
14
*/
15
16
#pragma once
17
18
#include "
gui/widgets/text_box.hpp
"
19
20
21
/**
22
* A class inherited from text_box that displays
23
* its input as stars
24
*
25
* @todo This implementation is quite a hack that
26
* needs to be rewritten cleanly
27
*/
28
namespace
gui2
29
{
30
namespace
implementation
31
{
32
struct
builder_password_box;
33
}
34
35
// ------------ WIDGET -----------{
36
37
class
password_box
:
public
text_box
38
{
39
public
:
40
explicit
password_box
(
const
implementation::builder_password_box
& builder);
41
42
/** Inherited from text_box_base. */
43
virtual
void
set_value
(
const
std::string&
text
)
override
;
44
std::string
get_real_value
()
const
45
{
46
return
real_value_
;
47
}
48
49
50
protected
:
51
void
insert_char
(
const
std::string& unicode)
override
;
52
void
paste_selection
()
override
;
53
void
delete_selection
()
override
;
54
55
// We do not override copy_selection because we
56
// actually want it to copy just the stars
57
58
private
:
59
60
std::string
real_value_
;
61
62
public
:
63
/** Static type getter that does not rely on the widget being constructed. */
64
static
const
std::string&
type
();
65
66
private
:
67
/** See @ref styled_widget::get_control_type. */
68
virtual
const
std::string&
get_control_type
()
const override
;
69
};
70
71
// }---------- BUILDER -----------{
72
73
namespace
implementation
74
{
75
76
// copy & paste from builder_text_box...
77
// does it make more sense to inherit from it?
78
struct
builder_password_box
:
public
builder_styled_widget
79
{
80
public
:
81
explicit
builder_password_box
(
const
config
& cfg);
82
83
using
builder_styled_widget::build
;
84
85
virtual
std::unique_ptr<widget>
build
()
const override
;
86
87
private
:
88
std::string
history_
;
89
};
90
91
}
// namespace implementation
92
93
// }------------ END --------------
94
95
}
// namespace gui2
config
A config object defines a single node in a WML file, with access to child nodes.
Definition:
config.hpp:172
gui2::password_box
Definition:
password_box.hpp:38
gui2::password_box::real_value_
std::string real_value_
Definition:
password_box.hpp:60
gui2::password_box::delete_selection
void delete_selection() override
Deletes the current selection.
Definition:
password_box.cpp:53
gui2::password_box::set_value
virtual void set_value(const std::string &text) override
Inherited from text_box_base.
Definition:
password_box.cpp:42
gui2::password_box::paste_selection
void paste_selection() override
Pastes the current selection.
Definition:
password_box.cpp:92
gui2::password_box::get_control_type
virtual const std::string & get_control_type() const override
See styled_widget::get_control_type.
Definition:
password_box.cpp:107
gui2::password_box::get_real_value
std::string get_real_value() const
Definition:
password_box.hpp:44
gui2::password_box::password_box
password_box(const implementation::builder_password_box &builder)
Definition:
password_box.cpp:36
gui2::password_box::insert_char
void insert_char(const std::string &unicode) override
Inserts a character at the cursor.
Definition:
password_box.cpp:70
gui2::password_box::type
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
Definition:
password_box.cpp:101
gui2::text_box_base::text
const std::string & text() const
Definition:
text_box_base.hpp:145
gui2::text_box
A widget that allows the user to input text in single line.
Definition:
text_box.hpp:125
gui2
Generic file dialog.
Definition:
draw_manager.hpp:21
implementation
Contains the implementation details for lexical_cast and shouldn't be used directly.
gui2::implementation::builder_password_box
Definition:
password_box.hpp:79
gui2::implementation::builder_password_box::build
virtual std::unique_ptr< widget > build() const override
Definition:
password_box.cpp:122
gui2::implementation::builder_password_box::history_
std::string history_
Definition:
password_box.hpp:88
gui2::implementation::builder_password_box::builder_password_box
builder_password_box(const config &cfg)
Definition:
password_box.cpp:117
gui2::implementation::builder_styled_widget
Definition:
styled_widget.hpp:534
gui2::implementation::builder_styled_widget::build
virtual std::unique_ptr< widget > build() const=0
text_box.hpp
Generated by
1.9.1