The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
message.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2017 by Mark de Wever <koraq@xs4all.nl>
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 /**
16  * @file
17  * This file contains the defintions for the @ref gui2::event::message class.
18  *
19  * The class is used in the @ref gui2::event::signal_message_function
20  */
21 
22 #pragma once
23 
24 #include "gui/widgets/helper.hpp"
25 
26 #include <SDL_rect.h>
27 
28 namespace gui2
29 {
30 
31 namespace event
32 {
33 
34 /**
35  * The message callbacks hold a reference to a message.
36  *
37  * The contents of the message differ per type. This class is a base with a
38  * virtual destructor, which makes it possible to use a dynamic_cast on the
39  * class received to make sure the proper message type is send.
40  *
41  * This means all messages used in the events need to be derived from this
42  * class. When a message needs no `content' it can send this class as message.
43  * This is done by:
44  * * @ref REQUEST_PLACEMENT
45  */
46 struct message
47 {
48  message() = default;
49 
50  // Disallow copying because constructing a copy loses the exact type.
51  message(const message&) = delete;
52 
53  virtual ~message()
54  {
55  }
56 };
57 
58 /** The message for MESSAGE_SHOW_TOOLTIP. */
60 {
61  message_show_tooltip(const std::string& message_, const point& location_, const SDL_Rect& source_rect_)
62  : message(message_), location(location_), source_rect(source_rect_)
63  {
64  }
65 
66  /** The message to show on the tooltip. */
68 
69  /** The location where to show the tooltip. */
70  const point location;
71 
72  /** The size of the entity requesting to show a tooltip. */
73  const SDL_Rect source_rect;
74 };
75 
76 /** The message for MESSAGE_SHOW_HELPTIP. */
78 {
79  message_show_helptip(const std::string& message_, const point& location_, const SDL_Rect& source_rect_)
80  : message(message_), location(location_), source_rect(source_rect_)
81  {
82  }
83 
84  /** The message to show on the helptip. */
86 
87  /** The location where to show the helptip. */
88  const point location;
89 
90  /** The size of the entity requesting to show a helptip. */
91  const SDL_Rect source_rect;
92 };
93 
94 } // namespace event
95 
96 } // namespace gui2
const std::string message
The message to show on the tooltip.
Definition: message.hpp:67
std::vector< char_t > string
const std::string message
The message to show on the helptip.
Definition: message.hpp:85
const point location
The location where to show the tooltip.
Definition: message.hpp:70
The message for MESSAGE_SHOW_HELPTIP.
Definition: message.hpp:77
const SDL_Rect source_rect
The size of the entity requesting to show a tooltip.
Definition: message.hpp:73
const point location
The location where to show the helptip.
Definition: message.hpp:88
Generic file dialog.
Definition: field-fwd.hpp:22
The message callbacks hold a reference to a message.
Definition: message.hpp:46
const SDL_Rect source_rect
The size of the entity requesting to show a helptip.
Definition: message.hpp:91
message_show_helptip(const std::string &message_, const point &location_, const SDL_Rect &source_rect_)
Definition: message.hpp:79
message_show_tooltip(const std::string &message_, const point &location_, const SDL_Rect &source_rect_)
Definition: message.hpp:61
The message for MESSAGE_SHOW_TOOLTIP.
Definition: message.hpp:59
virtual ~message()
Definition: message.hpp:53
Holds a 2D point.
Definition: point.hpp:22