The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
message.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2011 - 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 * @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
20 */
21
22#pragma once
23
25#include "sdl/point.hpp"
26
27namespace gui2
28{
29
30namespace 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 */
45struct 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 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. */
70
71 /** The size of the entity requesting to show a tooltip. */
73};
74
75/** The message for MESSAGE_SHOW_HELPTIP. */
77{
78 message_show_helptip(const std::string& message_, const point& location_, const 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. */
88
89 /** The size of the entity requesting to show a helptip. */
91};
92
93} // namespace event
94
95} // namespace gui2
Generic file dialog.
The message for MESSAGE_SHOW_HELPTIP.
Definition message.hpp:77
const point location
The location where to show the helptip.
Definition message.hpp:87
const std::string message
The message to show on the helptip.
Definition message.hpp:84
message_show_helptip(const std::string &message_, const point &location_, const rect &source_rect_)
Definition message.hpp:78
const rect source_rect
The size of the entity requesting to show a helptip.
Definition message.hpp:90
The message for MESSAGE_SHOW_TOOLTIP.
Definition message.hpp:59
const point location
The location where to show the tooltip.
Definition message.hpp:69
const std::string message
The message to show on the tooltip.
Definition message.hpp:66
const rect source_rect
The size of the entity requesting to show a tooltip.
Definition message.hpp:72
message_show_tooltip(const std::string &message_, const point &location_, const rect &source_rect_)
Definition message.hpp:60
The message callbacks hold a reference to a message.
Definition message.hpp:46
message(const message &)=delete
Holds a 2D point.
Definition point.hpp:25
An abstract description of a rectangle with integer coordinates.
Definition rect.hpp:49