Sleeping Wombat GUI  0.100
swGUI
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
sw::gui::EventsSystem Class Reference

Events management. More...

#include <EventsSystem.h>

Public Member Functions

 ~EventsSystem ()=default
 
const RegisteredEventRegisterEvent (const char *eventName, RoutingStrategy strategy, TypeID ownerType, TypeID eventTypeId)
 Registers new event and return idetifier used in DelegateContainers. More...
 
bool RaiseEvent (const RegisteredEvent *eventInfo, UIElement *sender, IEventArgsOPtr &&arguments)
 Sends event to visual tree using RoutingStrategy specyfied in eventInfo. More...
 
bool RaiseForwardEvent (const RegisteredEvent *eventInfo, UIElement *sender, IEventArgs *arguments)
 Sends event in response to other event. Use this function when you are in event handler and you want to send the same event structure under different name. Good example is UIElement::MouseRightButtonDown which is sent by UIElement in response to UIElement::MouseDown event sent by EventsSystem. More...
 
template<typename ArgumentType >
bool RaiseEvent (const RegisteredEvent *eventInfo, UIElement *sender, ArgumentType *arguments, EventHandlerPointer< ArgumentType > handler)
 

Static Public Member Functions

static EventsSystemGet ()
 

Private Member Functions

template<typename ArgumentType >
bool RaiseDirectEvent (const RegisteredEvent *eventInfo, UIElement *sender, ArgumentType *arguments, EventHandlerPointer< ArgumentType > handler)
 
template<typename ArgumentType >
bool RaiseBubbleEvent (const RegisteredEvent *eventInfo, UIElement *sender, ArgumentType *arguments, EventHandlerPointer< ArgumentType > handler)
 
template<typename ArgumentType >
bool RaiseTunnelEvent (const RegisteredEvent *eventInfo, UIElement *sender, ArgumentType *arguments, EventHandlerPointer< ArgumentType > handler)
 
template<typename ArgumentType >
void RaiseTunnelEventForParents (const RegisteredEvent *eventInfo, UIElement *sender, ArgumentType *arguments, UIElement *raiseForElement, EventHandlerPointer< ArgumentType > handler)
 Calls recursivly event for parents. More...
 
template<typename ArgumentType >
bool RaiseEventImpl (const RegisteredEvent *eventInfo, UIElement *sender, ArgumentType *arguments, EventHandlerPointer< ArgumentType > handler)
 
 EventsSystem ()
 

Private Attributes

EventType m_counter
 
std::mutex m_registerMutex
 
std::set< RegisteredEventm_registeredEvents
 

Detailed Description

Events management.

For now this class stores only registered events. Think about future use.

Registering events needs to be in separate dll, otherwise controls can't register their static variables.

All calsses derived from UIElement can register they own events.

Constructor & Destructor Documentation

sw::gui::EventsSystem::~EventsSystem ( )
default
sw::gui::EventsSystem::EventsSystem ( )
explicitprivate

Member Function Documentation

EventsSystem & sw::gui::EventsSystem::Get ( )
static
template<typename ArgumentType >
bool sw::gui::EventsSystem::RaiseBubbleEvent ( const RegisteredEvent eventInfo,
UIElement sender,
ArgumentType *  arguments,
EventHandlerPointer< ArgumentType >  handler 
)
inlineprivate
template<typename ArgumentType >
bool sw::gui::EventsSystem::RaiseDirectEvent ( const RegisteredEvent eventInfo,
UIElement sender,
ArgumentType *  arguments,
EventHandlerPointer< ArgumentType >  handler 
)
inlineprivate
bool sw::gui::EventsSystem::RaiseEvent ( const RegisteredEvent eventInfo,
UIElement sender,
IEventArgsOPtr &&  arguments 
)

Sends event to visual tree using RoutingStrategy specyfied in eventInfo.

template<typename ArgumentType >
bool sw::gui::EventsSystem::RaiseEvent ( const RegisteredEvent eventInfo,
UIElement sender,
ArgumentType *  arguments,
EventHandlerPointer< ArgumentType >  handler 
)
inline
template<typename ArgumentType >
bool sw::gui::EventsSystem::RaiseEventImpl ( const RegisteredEvent eventInfo,
UIElement sender,
ArgumentType *  arguments,
EventHandlerPointer< ArgumentType >  handler 
)
inlineprivate
bool sw::gui::EventsSystem::RaiseForwardEvent ( const RegisteredEvent eventInfo,
UIElement sender,
IEventArgs arguments 
)

Sends event in response to other event. Use this function when you are in event handler and you want to send the same event structure under different name. Good example is UIElement::MouseRightButtonDown which is sent by UIElement in response to UIElement::MouseDown event sent by EventsSystem.

Parameters
[in]argumentsArguments structure. Note that this structure is raw pointer and you are not owner of it. Never use this function when you created event structure on your own. This couses memory leaks.
template<typename ArgumentType >
bool sw::gui::EventsSystem::RaiseTunnelEvent ( const RegisteredEvent eventInfo,
UIElement sender,
ArgumentType *  arguments,
EventHandlerPointer< ArgumentType >  handler 
)
inlineprivate
template<typename ArgumentType >
void sw::gui::EventsSystem::RaiseTunnelEventForParents ( const RegisteredEvent eventInfo,
UIElement sender,
ArgumentType *  arguments,
UIElement raiseForElement,
EventHandlerPointer< ArgumentType >  handler 
)
inlineprivate

Calls recursivly event for parents.

const RegisteredEvent * sw::gui::EventsSystem::RegisterEvent ( const char *  eventName,
RoutingStrategy  strategy,
TypeID  ownerType,
TypeID  eventTypeId 
)

Registers new event and return idetifier used in DelegateContainers.

Member Data Documentation

EventType sw::gui::EventsSystem::m_counter
private
std::set< RegisteredEvent > sw::gui::EventsSystem::m_registeredEvents
private
std::mutex sw::gui::EventsSystem::m_registerMutex
private

The documentation for this class was generated from the following files: