The Battle for Wesnoth  1.19.0-dev
event_executor.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2007 - 2024
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 #pragma once
17 
18 namespace gui2
19 {
20 
21 class event_handler;
22 
23 /**
24  * Event execution calls.
25  *
26  * Base class with all possible events, most widgets can ignore most of these,
27  * but they are available. In order to use an event simply override the
28  * execution function and implement the wanted behavior. The default behavior
29  * defined here is to do nothing.
30  *
31  * For more info about the event handling have a look at the event_handler
32  * class which 'translates' sdl events into 'widget' events.
33  */
35 {
36 public:
38  : wants_mouse_hover_(false)
42  {
43  }
44 
45  virtual ~event_executor()
46  {
47  }
48 
49  /***** ***** ***** setters / getters for members ***** ****** *****/
50 
51  void set_wants_mouse_hover(const bool hover = true)
52  {
53  wants_mouse_hover_ = hover;
54  }
55  bool wants_mouse_hover() const
56  {
57  return wants_mouse_hover_;
58  }
59 
60  void set_wants_mouse_left_double_click(const bool click = true)
61  {
63  }
65  {
67  }
68 
70  {
72  }
74  {
76  }
77 
79  {
81  return *this;
82  }
84  {
86  }
87 
88 private:
89  /** Does the widget want a hover event? See mouse_hover. */
91 
92  /**
93  * Does the widget want a left button double click? See
94  * mouse_left_button_double_click.
95  */
97 
98  /** See wants_mouse_left_double_click_ */
100 
101  /** See wants_mouse_left_double_click_ */
103 };
104 
105 } // namespace gui2
Event execution calls.
bool wants_mouse_left_double_click_
Does the widget want a left button double click? See mouse_left_button_double_click.
bool wants_mouse_right_double_click() const
bool wants_mouse_left_double_click() const
bool wants_mouse_middle_double_click_
See wants_mouse_left_double_click_.
bool wants_mouse_hover_
Does the widget want a hover event? See mouse_hover.
bool wants_mouse_hover() const
void set_wants_mouse_middle_double_click(const bool click=true)
bool wants_mouse_middle_double_click() const
void set_wants_mouse_left_double_click(const bool click=true)
void set_wants_mouse_hover(const bool hover=true)
event_executor & set_wants_mouse_right_double_click(const bool click=true)
bool wants_mouse_right_double_click_
See wants_mouse_left_double_click_.
Generic file dialog.
bool click(int mousex, int mousey)
Definition: tooltips.cpp:294