The Battle for Wesnoth
1.17.12+dev
gui
widgets
password_box.hpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2009 - 2022
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
/**
38
* @ingroup GUIWidgetWML
39
*
40
* Key |Type |Default |Description
41
* -------------|------------------------------------|---------|-----------
42
* label | @ref guivartype_t_string "t_string"|"" |The initial text of the password box.
43
*/
44
class
password_box
:
public
text_box
45
{
46
public
:
47
explicit
password_box
(
const
implementation::builder_password_box
& builder);
48
49
/** Inherited from text_box_base. */
50
virtual
void
set_value(
const
std::string& text)
override
;
51
std::string
get_real_value
()
const
52
{
53
return
real_value_;
54
}
55
56
57
protected
:
58
void
insert_char(
const
std::string& unicode)
override
;
59
void
paste_selection(
const
bool
mouse)
override
;
60
void
delete_selection()
override
;
61
62
// We do not override copy_selection because we
63
// actually want it to copy just the stars
64
65
private
:
66
67
std::string
real_value_
;
68
69
public
:
70
/** Static type getter that does not rely on the widget being constructed. */
71
static
const
std::string&
type
();
72
73
private
:
74
/** See @ref styled_widget::get_control_type. */
75
virtual
const
std::string& get_control_type()
const override
;
76
};
77
78
// }---------- BUILDER -----------{
79
80
namespace
implementation
81
{
82
83
// copy & paste from builder_text_box...
84
// does it make more sense to inherit from it?
85
struct
builder_password_box
:
public
builder_styled_widget
86
{
87
public
:
88
explicit
builder_password_box
(
const
config
& cfg);
89
90
using
builder_styled_widget::build
;
91
92
virtual
std::unique_ptr<widget>
build
()
const override
;
93
94
private
:
95
std::string
history_
;
96
};
97
98
}
// namespace implementation
99
100
// }------------ END --------------
101
102
}
// namespace gui2
gui2::implementation::builder_password_box::history_
std::string history_
Definition:
password_box.hpp:95
gui2::implementation::builder_styled_widget
Definition:
styled_widget.hpp:541
gui2::text_box
Class for a single line text area.
Definition:
text_box.hpp:141
gui2
Generic file dialog.
Definition:
draw_manager.hpp:19
gui2::implementation::builder_password_box
Definition:
password_box.hpp:85
gui2::builder_widget::build
virtual std::unique_ptr< widget > build() const =0
gui2::password_box::get_real_value
std::string get_real_value() const
Definition:
password_box.hpp:51
desktop::notifications::type
type
Definition:
notifications.hpp:24
gui2::build
std::unique_ptr< window > build(const builder_window::window_resolution &definition)
Builds a window.
Definition:
window_builder.cpp:38
config
A config object defines a single node in a WML file, with access to child nodes.
Definition:
config.hpp:60
implementation
Contains the implementation details for lexical_cast and shouldn't be used directly.
text_box.hpp
gui2::password_box::real_value_
std::string real_value_
Definition:
password_box.hpp:67
gui2::password_box
Key Type Default Description label t_string"" The initial text of the password box.
Definition:
password_box.hpp:44
Generated by
1.8.13