The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
transient_message.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2016 by Mark de Wever <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #define GETTEXT_DOMAIN "wesnoth-lib"
16 
18 
20 #include "gui/widgets/settings.hpp"
21 #include "gui/widgets/window.hpp"
22 #include "log.hpp"
23 
24 #include "gettext.hpp"
25 
26 namespace gui2
27 {
28 
29 REGISTER_DIALOG(transient_message)
30 
32  const bool title_use_markup,
33  const std::string& message,
34  const bool message_use_markup,
35  const std::string& image)
36  : hide_title_(title.empty()), hide_image_(image.empty())
37 {
38  register_label("title", true, title, title_use_markup);
39  register_label("message", true, message, message_use_markup);
40  register_image("image", true, image);
41 }
42 
44 {
45  if(hide_title_) {
46  twidget& title = find_widget<twidget>(&window, "title", false);
48  }
49 
50  if(hide_image_) {
51  twidget& image = find_widget<twidget>(&window, "image", false);
53  }
54 }
55 
57  const std::string& title,
58  const std::string& message,
59  const std::string& image,
60  const bool message_use_markup,
61  const bool title_use_markup,
62  const bool restore_background)
63 {
65  title, title_use_markup, message, message_use_markup, image);
66 
67  dlg.set_restore(restore_background);
68  dlg.show(video);
69 }
70 
72  const std::string& message,
73  const std::string& image,
74  const bool message_use_markup)
75 {
76  LOG_STREAM(err, lg::general()) << message << '\n';
78  video, _("Error"), message, image, message_use_markup);
79 }
80 
81 } // namespace gui2
virtual void pre_show(twindow &window)
Inherited from tdialog.
bool show(CVideo &video, const unsigned auto_close_time=0)
Shows the window.
Definition: dialog.cpp:34
Definition: video.hpp:58
void show_transient_error_message(CVideo &video, const std::string &message, const std::string &image, const bool message_use_markup)
Shows a transient error message to the user.
This file contains the window object, this object is a top level container which has the event manage...
REGISTER_DIALOG(label_settings)
STL namespace.
Shows a transient message.
void show_transient_message(CVideo &video, const std::string &title, const std::string &message, const std::string &image, const bool message_use_markup, const bool title_use_markup, const bool restore_background)
Shows a transient message to the user.
#define LOG_STREAM(level, domain)
Definition: log.hpp:188
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:62
A class inherited from ttext_box that displays its input as stars.
Definition: field-fwd.hpp:23
The user set the widget invisible, that means:
Definition: widget.hpp:103
static UNUSEDNOWARN std::string _(const char *str)
Definition: gettext.hpp:82
This file contains the settings handling of the widget library.
void set_restore(const bool restore)
Definition: dialog.hpp:171
log_domain & general()
Definition: log.cpp:103
logger & err()
Definition: log.cpp:79
Base class for all widgets.
Definition: widget.hpp:49
this module manages the cache of images.
Definition: image.cpp:75
Standard logging facilities (interface).
GLsizei GLenum GLuint GLuint GLsizei char * message
Definition: glew.h:2499
void set_visible(const tvisible::scoped_enum visible)
Definition: widget.cpp:445
GLsizei const GLcharARB ** string
Definition: glew.h:4503