neoGFX
Cross-platform C++ app/game engine
i_event.hpp
Go to the documentation of this file.
1 // event.hpp
2 /*
3 Transplanted from neogfx C++ GUI Library
4 Copyright (c) 2015-2018 Leigh Johnston. All Rights Reserved.
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 3 of the License, or
9 (at your option) any later version.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 #include <neolib/neolib.hpp>
23 #include <neolib/jar.hpp>
24 #include <neolib/i_map.hpp>
25 
26 namespace neolib
27 {
28  struct event_destroyed : std::logic_error { event_destroyed() : std::logic_error{ "neolib::event_destroyed" } {} };
29  struct event_queue_destroyed : std::logic_error { event_queue_destroyed() : std::logic_error{ "neolib::event_queue_destroyed" } {} };
30 
31  class i_event : public i_cookie_consumer
32  {
33  public:
34  virtual ~i_event() = default;
35  public:
36  virtual void release_control() = 0;
37  virtual void handle_in_same_thread_as_emitter(cookie aHandleId) = 0;
38  public:
39  virtual void pre_trigger() const = 0;
40  public:
41  virtual void push_context() const = 0;
42  virtual void pop_context() const = 0;
43  public:
44  virtual bool accepted() const = 0;
45  virtual void accept() const = 0;
46  virtual void ignore() const = 0;
47  public:
48  virtual bool filtered() const = 0;
49  virtual void filter_added() const = 0;
50  virtual void filter_removed() const = 0;
51  virtual void filters_removed() const = 0;
52  };
53 
55  {
56  public:
57  virtual ~i_event_control() = default;
58  public:
59  virtual void add_ref() = 0;
60  virtual void release() = 0;
61  virtual bool valid() const = 0;
62  virtual i_event& get() const = 0;
63  public:
64  virtual void reset() = 0;
65  };
66 
68  {
69  public:
70  virtual ~i_event_callback() = default;
71  public:
72  virtual const i_event& event() const = 0;
73  virtual void call() const = 0;
74  };
75 
77  {
78  public:
79  virtual ~i_event_filter() = default;
80  public:
81  virtual void pre_filter_event(const i_event& aEvent) = 0;
82  virtual void filter_event(const i_event& aEvent) = 0;
83  };
84 
86  {
87  public:
88  virtual void install_event_filter(i_event_filter& aFilter, const i_event& aEvent) = 0;
89  virtual void uninstall_event_filter(i_event_filter& aFilter, const i_event& aEvent) = 0;
90  virtual void uninstall_event_filter(const i_event& aEvent) = 0;
91  public:
92  virtual void pre_filter_event(const i_event& aEvent) const = 0;
93  virtual void filter_event(const i_event& aEvent) const = 0;
94  };
95 }
uint32_t cookie
Definition: jar.hpp:49