The Battle for Wesnoth
1.21.0-dev
Loading...
Searching...
No Matches
gui
dialogs
transient_message.cpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2009 - 2025
3
by 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
#define GETTEXT_DOMAIN "wesnoth-lib"
17
18
#include "
gui/dialogs/transient_message.hpp
"
19
20
#include "
gui/widgets/window.hpp
"
21
#include "
log.hpp
"
22
23
#include "
gettext.hpp
"
24
25
namespace
gui2
26
{
27
namespace
dialogs
28
{
29
30
REGISTER_DIALOG
(transient_message)
31
32
transient_message
::
transient_message
(const
std
::
string
& title,
33
const
bool
title_use_markup,
34
const
std
::
string
&
message
,
35
const
bool
message_use_markup,
36
const
std
::
string
&
image
)
37
:
modal_dialog
(window_id())
38
, hide_title_(title.empty())
39
, hide_image_(
image
.empty())
40
{
41
register_label(
"title"
,
true
, title, title_use_markup);
42
register_label(
"message"
,
true
,
message
, message_use_markup);
43
register_image(
"image"
,
true
,
image
);
44
}
45
46
void
transient_message::pre_show
()
47
{
48
if
(
hide_title_
) {
49
widget
& title = find_widget<widget>(
"title"
);
50
title.
set_visible
(
widget::visibility::invisible
);
51
}
52
53
if
(
hide_image_
) {
54
widget
&
image
= find_widget<widget>(
"image"
);
55
image
.set_visible(
widget::visibility::invisible
);
56
}
57
}
58
}
// namespace dialogs
59
60
void
show_transient_message
(
const
std::string& title,
61
const
std::string&
message
,
62
const
std::string&
image
,
63
const
bool
message_use_markup,
64
const
bool
title_use_markup)
65
{
66
dialogs::transient_message
dlg(
67
title, title_use_markup,
message
, message_use_markup,
image
);
68
69
dlg.
show
();
70
}
71
72
void
show_transient_error_message
(
const
std::string&
message
,
73
const
std::string&
image
,
74
const
bool
message_use_markup)
75
{
76
LOG_STREAM
(err,
lg::general
()) <<
message
;
77
show_transient_message
(
_
(
"Error"
),
message
,
image
, message_use_markup);
78
}
79
80
}
// namespace gui2
gui2::dialogs::message
Main class to show messages to the user.
Definition
message.hpp:36
gui2::dialogs::modal_dialog
Abstract base class for all modal dialogs.
Definition
modal_dialog.hpp:146
gui2::dialogs::modal_dialog::show
bool show(const unsigned auto_close_time=0)
Shows the window.
Definition
modal_dialog.cpp:51
gui2::dialogs::transient_message
Shows a transient message.
Definition
transient_message.hpp:27
gui2::dialogs::transient_message::hide_title_
bool hide_title_
Definition
transient_message.hpp:38
gui2::dialogs::transient_message::pre_show
virtual void pre_show() override
Actions to be taken before showing the window.
Definition
transient_message.cpp:46
gui2::dialogs::transient_message::hide_image_
bool hide_image_
Definition
transient_message.hpp:39
gui2::widget
Base class for all widgets.
Definition
widget.hpp:55
gui2::widget::set_visible
void set_visible(const visibility visible)
Definition
widget.cpp:479
gui2::widget::visibility::invisible
@ invisible
The user set the widget invisible, that means:
gettext.hpp
_
static std::string _(const char *str)
Definition
gettext.hpp:100
window.hpp
This file contains the window object, this object is a top level container which has the event manage...
log.hpp
Standard logging facilities (interface).
LOG_STREAM
#define LOG_STREAM(level, domain)
Definition
log.hpp:278
REGISTER_DIALOG
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
Definition
modal_dialog.hpp:89
dialogs
Various uncategorised dialogs.
gui2
Generic file dialog.
Definition
draw_manager.hpp:21
gui2::show_transient_error_message
void show_transient_error_message(const std::string &message, const std::string &image, const bool message_use_markup)
Shows a transient error message to the user.
Definition
transient_message.cpp:72
gui2::show_transient_message
void show_transient_message(const std::string &title, const std::string &message, const std::string &image, const bool message_use_markup, const bool title_use_markup)
Shows a transient message to the user.
Definition
transient_message.cpp:60
image
Functions to load and save images from/to disk.
Definition
image_modifications.cpp:37
lg::general
log_domain & general()
Definition
log.cpp:365
std
STL namespace.
transient_message.hpp
Generated by
1.9.8