The Battle for Wesnoth  1.19.5+dev
tooltips.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2024
3  by David White <dave@whitevine.net>
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 #pragma once
17 
19 #include "sdl/rect.hpp"
20 
21 #include <string>
22 
23 namespace tooltips {
24 
26 {
27 public:
28  manager();
29  ~manager();
30  // TLD interface
31  virtual void layout() override;
32  virtual bool expose(const rect& region) override;
33  virtual rect screen_location() override;
34 };
35 
36 void clear_tooltips();
37 void clear_tooltips(const SDL_Rect& rect);
38 int add_tooltip(const SDL_Rect& rect, const std::string& message, const std::string& action ="");
39 bool update_tooltip(int id, const SDL_Rect& rect, const std::string& message);
40 void remove_tooltip(int id);
41 void process(int mousex, int mousey);
42 
43 // Check if we clicked on a tooltip having an action.
44 // If it is, then execute the action and return true
45 // (only possible action are opening help page for the moment)
46 bool click(int mousex, int mousey);
47 
48 }
A top-level drawable item (TLD), such as a window.
virtual bool expose(const rect &region) override
Draw the portion of the drawable intersecting region to the screen.
Definition: tooltips.cpp:217
virtual void layout() override
Finalize the size and position of the drawable and its children, and invalidate any regions requiring...
Definition: tooltips.cpp:207
virtual rect screen_location() override
The location of the TLD on the screen, in drawing coordinates.
Definition: tooltips.cpp:231
tooltips.
Definition: tooltips.cpp:191
bool click(int mousex, int mousey)
Definition: tooltips.cpp:356
int add_tooltip(const SDL_Rect &origin, const std::string &message, const std::string &action)
Definition: tooltips.cpp:299
void clear_tooltips()
Definition: tooltips.cpp:241
void remove_tooltip(int id)
Definition: tooltips.cpp:289
void process(int mousex, int mousey)
Definition: tooltips.cpp:340
bool update_tooltip(int id, const SDL_Rect &origin, const std::string &message)
Definition: tooltips.cpp:267
Contains the SDL_Rect helper code.
An abstract description of a rectangle with integer coordinates.
Definition: rect.hpp:47