The Battle for Wesnoth  1.15.1+dev
clickable_item.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2018 by Mark de Wever <koraq@xs4all.nl>
3  Part of the Battle for Wesnoth Project https://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 #pragma once
16 
18 
19 namespace gui2
20 {
21 
22 /**
23  * Small concept class.
24  *
25  * Parts of the engine inherit this class so we can have generic
26  * clickable items. This is mainly for the button and the repeating button
27  * classes.
28  *
29  * The reason for having the click functions here is that not all subclasses
30  * need to implement the click event in the same way; e.g. the repeating button
31  * clicks on the mouse down event and the normal button on the mouse click
32  * event.
33  *
34  * Common signal handlers:
35  * - connect_signal_mouse_left_click
36  * - disconnect_signal_mouse_left_click
37  */
39 {
40 public:
41  virtual ~clickable_item()
42  {
43  }
44 
45  /**
46  * Connects a signal handler for a 'click' event.
47  *
48  * What the click is depends on the subclass.
49  *
50  * @param signal The signal to connect.
51  */
52  virtual void connect_click_handler(const event::signal_function& signal)
53  = 0;
54 
55  /**
56  * Disconnects a signal handler for a 'click' event.
57  *
58  * What the click is depends on the subclass.
59  *
60  * @param signal The signal to disconnect (should be the same
61  * as send to the connect call.
62  */
63  virtual void disconnect_click_handler(const event::signal_function& signal)
64  = 0;
65 };
66 
67 } // namespace gui2
Generic file dialog.
Definition: field-fwd.hpp:22
virtual void connect_click_handler(const event::signal_function &signal)=0
Connects a signal handler for a &#39;click&#39; event.
std::function< void(widget &dispatcher, const ui_event event, bool &handled, bool &halt)> signal_function
Callback function signature.
Definition: dispatcher.hpp:42
virtual void disconnect_click_handler(const event::signal_function &signal)=0
Disconnects a signal handler for a &#39;click&#39; event.
Small concept class.