Sleeping Wombat GUI  0.100
swGUI
EventHandlers.h
Go to the documentation of this file.
1 #pragma once
2 
9 #include "DelegateContainer.h"
10 #include "IEventArgs.h"
11 
12 
13 namespace sw {
14 namespace gui
15 {
16 
17 struct IEventArgs;
18 struct RegisteredEvent;
19 
20 
25 {
26  template< typename EventArgType > friend class EventProxy;
27 private:
28 
29  DelegatesContainerBaseOPtr m_delegatesList;
30 
31 public:
32  explicit EventHandlers();
33 
37 
38 private:
41 
44  DelegatesContainerBase* AddContainer ( DelegatesContainerBaseOPtr&& container );
45 
48  bool RemoveContainer ( EventType eventID );
49 
54  bool RaiseEvent ( const RegisteredEvent* eventInfo, UIElement* sender, IEventArgsOPtr&& arguments );
55 
57 
58 private:
59  // Internal
60 
62  bool Exists ( EventType eventID );
63 };
64 
65 
66 
67 
68 } // gui
69 } // sw
70 
71 #define REGISTER_EVENT_DECLARATION( name, strategy, className, argsType ) \
72 static const ::sw::gui::RegisteredEvent* s ## name; \
73 ::sw::gui::EventProxy< argsType > name() { return ::sw::gui::EventProxy< argsType >( m_eventHandlers, s ## name ); }
74 
75 #define REGISTER_EVENT_DEFINITION( name, strategy, className, argsType ) \
76 const ::sw::gui::RegisteredEvent* className::s ## name = ::sw::gui::EventsSystem::Get().RegisterEvent( #name, ::sw::gui::strategy, TypeID::get< className >(), TypeID::get< argsType >() );
77 
Base class for delegates containers.
Definition: DelegateContainer.h:52
Definition: DirectInputModule.cpp:11
bool Exists(EventType eventID)
Checks if container exists.
Definition: EventHandlers.cpp:111
Interface for all controls in tree.
Definition: UIElement.h:57
uint32 EventType
Event type identifier.
Definition: RegisteredEvent.h:19
DelegatesContainerBase * FindContainer(EventType eventID)
Search for events container.
Definition: EventHandlers.cpp:26
bool RaiseEvent(const RegisteredEvent *eventInfo, UIElement *sender, IEventArgsOPtr &&arguments)
Sends event to visual tree using RoutingStrategy specyfied in eventInfo. Calls EventsSystem::RaiseEve...
Definition: EventHandlers.cpp:99
DelegatesContainerBase * AddContainer(DelegatesContainerBaseOPtr &&container)
Adds delegates container.
Definition: EventHandlers.cpp:47
bool RemoveContainer(EventType eventID)
Removes container with deelgates.
Definition: EventHandlers.cpp:65
EventHandlers()
Definition: EventHandlers.cpp:20
DelegatesContainerBaseOPtr m_delegatesList
Definition: EventHandlers.h:29
Container class for delegates.
Definition: EventHandlers.h:24
Structure describes event registered by controls.
Definition: RegisteredEvent.h:38
Helper class for accessing event.
Definition: EventProxy.h:24