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