The Battle for Wesnoth
1.17.23+dev
gui
widgets
password_box.hpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2009 - 2023
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
config
A config object defines a single node in a WML file, with access to child nodes.
Definition:
config.hpp:161
gui2::password_box
Definition:
password_box.hpp:45
gui2::password_box::real_value_
std::string real_value_
Definition:
password_box.hpp:67
gui2::password_box::delete_selection
void delete_selection() override
Deletes the current selection.
Definition:
password_box.cpp:55
gui2::password_box::set_value
virtual void set_value(const std::string &text) override
Inherited from text_box_base.
Definition:
password_box.cpp:44
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:109
gui2::password_box::get_real_value
std::string get_real_value() const
Definition:
password_box.hpp:51
gui2::password_box::password_box
password_box(const implementation::builder_password_box &builder)
Definition:
password_box.cpp:38
gui2::password_box::paste_selection
void paste_selection(const bool mouse) override
Pastes the current selection.
Definition:
password_box.cpp:94
gui2::password_box::insert_char
void insert_char(const std::string &unicode) override
Inserts a character at the cursor.
Definition:
password_box.cpp:72
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:103
gui2::text_box_base::text
const std::string & text() const
Definition:
text_box_base.hpp:87
gui2::text_box
Class for a single line text area.
Definition:
text_box.hpp:142
gui2
Generic file dialog.
Definition:
draw_manager.hpp:19
implementation
Contains the implementation details for lexical_cast and shouldn't be used directly.
gui2::implementation::builder_password_box
Definition:
password_box.hpp:86
gui2::implementation::builder_password_box::build
virtual std::unique_ptr< widget > build() const override
Definition:
password_box.cpp:124
gui2::implementation::builder_password_box::history_
std::string history_
Definition:
password_box.hpp:95
gui2::implementation::builder_password_box::builder_password_box
builder_password_box(const config &cfg)
Definition:
password_box.cpp:119
gui2::implementation::builder_styled_widget
Definition:
styled_widget.hpp:542
gui2::implementation::builder_styled_widget::build
virtual std::unique_ptr< widget > build() const=0
text_box.hpp
Generated by
1.9.1