41 #ifndef INCLUDED_DISTI_EVENTS_H
42 #define INCLUDED_DISTI_EVENTS_H
96 SHIFT_STATE = 0x00010000,
97 CAPS_LOCK_STATE = 0x00020000,
98 CTRL_STATE = 0x00040000,
99 ALT_STATE = 0x00080000,
100 NUM_LOCK_STATE = 0x00100000,
101 META_STATE = 0x00400000,
102 SCROLL_LOCK_STATE = 0x00800000,
103 BUTTON1_STATE = 0x01000000,
104 BUTTON2_STATE = 0x02000000,
105 BUTTON3_STATE = 0x04000000
127 : eventType( source.eventType )
128 , eventSubtype( source.eventSubtype )
192 , winLoc( source.winLoc )
193 , lCoords( source.lCoords )
194 , oCoords( source.oCoords )
344 , _initiator( initiator )
348 int size = (int)strlen( eventName ) + 1;
349 _eventName =
new char[ size ];
350 #if defined( _WIN32 )
351 strcpy_s( _eventName, size, eventName );
353 strcpy( _eventName, eventName );
357 size = (int)strlen( eventData ) + 1;
358 _eventData =
new char[ size ];
359 #if defined( _WIN32 )
360 strcpy_s( _eventData, size, eventData );
362 strcpy( _eventData, eventData );
375 , _initiator( initiator )
426 int size = (int)strlen( newName ) + 1;
427 _eventName =
new char[ size ];
428 #if defined( _WIN32 )
429 strcpy_s( _eventName, size, newName );
431 strcpy( _eventName, newName );
461 int size = (int)strlen( newData ) + 1;
462 _eventData =
new char[ size ];
463 #if defined( _WIN32 )
464 strcpy_s( _eventData, size, newData );
466 strcpy( _eventData, newData );
476 if( !_eventName || !eventName )
481 return ( 0 == strcmp( _eventName, eventName ) );
489 if( !_eventData || !eventData )
494 return ( 0 == strcmp( _eventData, eventData ) );
501 if( self->ParentGroup() )
503 self->ParentGroup()->handle( event );
505 else if( dynamic_cast<ComponentBase*>(
self ) )
508 self->handle( event );
527 bool is = ( objEvent && objEvent->
EventNameIs( eventName ) );
528 if( is && eventData )
536 #define ON( event, subevent ) if( ( ev->eventType == ( event ) ) && ( ev->eventSubtype == ( subevent ) ) )
539 #define ON_MOUSE_UP( btnMask ) if( ( ev->eventType == EVENT_MOUSE ) && ( ev->eventSubtype == MOUSE_UP ) && ( (btnMask)&mev->buttonMask ) )
542 #define ON_MOUSE_DOWN( btnMask ) if( ( ev->eventType == EVENT_MOUSE ) && ( ev->eventSubtype == MOUSE_DOWN ) && ( (btnMask)&mev->buttonMask ) )
545 #define ON_MOUSE_DRAG( btnMask ) if( ( ev->eventType == EVENT_MOUSE ) && ( ev->eventSubtype == MOUSE_DRAG ) && ( (btnMask)&mev->buttonMask ) )
548 #define ON_KEY_DOWN( testKey ) if( ( ev->eventType == EVENT_KEYBOARD ) && OnKeyEvent( kev, true, int( testKey ) ) )
551 #define ON_KEY_UP( testKey ) if( ( ev->eventType == EVENT_KEYBOARD_UP ) && OnKeyEvent( kev, true, int( testKey ) ) )
554 #define ON_KEY_DOWN_WITH_MODIFIER( testKey, modifierMask ) if( ( ev->eventType == EVENT_KEYBOARD ) && OnKeyEvent( kev, true, int( testKey ), modifierMask ) )
557 #define ON_KEY_UP_WITH_MODIFIER( testKey, modifierMask ) if( ( ev->eventType == EVENT_KEYBOARD_UP ) && OnKeyEvent( kev, true, int( testKey ), modifierMask ) )
560 #define ON_SPECIAL_KEY_DOWN( keySym ) if( ( ev->eventType == EVENT_KEYBOARD ) && OnKeyEvent( kev, false, int( keySym ) ) )
563 #define ON_SPECIAL_KEY_UP( keySym ) if( ( ev->eventType == EVENT_KEYBOARD_UP ) && OnKeyEvent( kev, false, int( keySym ) ) )
566 #define ON_SPECIAL_KEY_DOWN_WITH_MODIFIER( keySym, modifierMask ) if( ( ev->eventType == EVENT_KEYBOARD ) && OnKeyEvent( kev, false, int( keySym ), modifierMask ) )
569 #define ON_SPECIAL_KEY_UP_WITH_MODIFIER( keySym, modifierMask ) if( ( ev->eventType == EVENT_KEYBOARD_UP ) && OnKeyEvent( kev, false, int( keySym ), modifierMask ) )
572 #define ON_ANY_KEY_DOWN() if( ( ev->eventType == EVENT_KEYBOARD ) )
575 #define ON_ANY_KEY_UP() if( ( ev->eventType == EVENT_KEYBOARD_UP ) )
604 bool keySuccess =
false;
612 if( CTRL_STATE & modifierMask )
615 key = std::tolower( key );
616 keySuccess = ( key == kev->
keysym );
625 keySuccess = ( key == kev->
keysym );
633 bool modSuccess = ( 0 != ( modifierMask & kev->
modifiers ) || ( 0 == modifierMask && 0 == (
int( SHIFT_STATE | CTRL_STATE | ALT_STATE | META_STATE ) & kev->
modifiers ) ) );
635 return ( keySuccess && modSuccess );
640 class EventCompressor
643 typedef DisplayObject* ( T::*EventSenderCbType )( DisplayEvent* ev );
646 MouseEvent _lastCompressedEvent;
647 bool _lastEventWasCompressed;
648 EventSenderCbType _handleCb;
650 bool _sendingCompressed;
654 void Active(
bool val ) { _active = val; }
655 bool Active() {
return _active; }
657 EventCompressor( T* objectPtr, EventSenderCbType cb )
658 : _lastEventWasCompressed( false )
660 , _objectPtr( objectPtr )
661 , _sendingCompressed( false )
673 if( !_active || _sendingCompressed )
678 bool compressed =
false;
683 if( !_lastEventWasCompressed || ( _lastEventWasCompressed && _lastCompressedEvent.eventType == ev.
eventType && _lastCompressedEvent.eventSubtype == ev.
eventSubtype && _lastCompressedEvent.cursorID == mev->
cursorID ) )
686 _lastCompressedEvent = *mev;
687 _lastEventWasCompressed =
true;
695 SendAnyCompressedEvents();
700 void SendAnyCompressedEvents()
703 if( _sendingCompressed )
708 if( _lastEventWasCompressed )
710 _sendingCompressed =
true;
712 ( _objectPtr->*( _handleCb ) )( &_lastCompressedEvent );
714 _sendingCompressed =
false;
716 _lastEventWasCompressed =
false;
723 #endif // INCLUDED_DISTI_EVENTS_H
int keysym
Definition: events.h:313
unsigned short eventSubtype
Definition: events.h:116
unsigned short eventType
Definition: events.h:115
MouseButtonType_e
Definition: events.h:84
void EmitObjectEvent(DisplayObject *self, ObjectEvent *event)
Definition: events.h:499
float & x
Definition: events.h:159
float & z
Definition: events.h:161
The disti::ComponentBase class.
DisplayEvent(const DisplayEvent &source)
Definition: events.h:126
bool ObjectEventIs(DisplayEvent *event, const char *eventName, const char *eventData=NULL)
Definition: events.h:524
The disti::Group class. Implements groups of objects.
float & lx
Definition: events.h:163
float & ox
Definition: events.h:167
KeyboardEvent(const KeyboardEvent &source)
Definition: events.h:286
KeyboardEvent()
Definition: events.h:277
ObjectEvent(DisplayObject *initiator, unsigned short eventSubtypeArg)
Definition: events.h:373
LocationEvent()
Definition: events.h:175
bool OnKeyEvent(KeyboardEvent *kev, bool alphaNumeric, int key, int modifierMask=0)
Definition: events.h:602
MouseEvent(const MouseEvent &source)
Definition: events.h:235
SpecialKeyState_e
Definition: events.h:93
The disti::Timer class. An OS portable timing class.
int modifiers
Definition: events.h:315
Vector winLoc
Definition: events.h:149
A file for all GL Studio files to include.
MouseEventType_e
Definition: events.h:68
const char * EventName() const
Definition: events.h:403
The disti::DisplayObject class and global enumerations.
DisplayObject * Initiator() const
Definition: events.h:394
int modifiers
Definition: events.h:268
float & ly
Definition: events.h:164
Vector oCoords
Definition: events.h:155
KeyboardEvent operator=(const KeyboardEvent &source)
Definition: events.h:304
float & oy
Definition: events.h:168
unsigned int cursorID
Definition: events.h:269
EventType_e
Definition: events.h:58
void Initiator(DisplayObject *initiator)
Definition: events.h:399
Vector lCoords
Definition: events.h:152
unsigned char buttonMask
Definition: events.h:266
MouseEvent operator=(const MouseEvent &source)
Definition: events.h:256
bool EventDataIs(const char *eventData) const
Definition: events.h:487
float & y
Definition: events.h:160
float & oz
Definition: events.h:169
MouseEvent(const LocationEvent &source)
Definition: events.h:245
LocationEvent operator=(const LocationEvent &source)
Definition: events.h:208
DisplayEvent()
Definition: events.h:119
void EventData(const char *newData)
Definition: events.h:454
ObjectEvent(DisplayObject *initiator, const char *eventName, const char *eventData=NULL)
Definition: events.h:342
MouseEvent()
Definition: events.h:224
virtual ~DisplayEvent()
Definition: events.h:133
const char * EventData() const
Definition: events.h:438
KeyboardEvent(const LocationEvent &source)
Definition: events.h:295
unsigned char clicks
Definition: events.h:267
bool CompressEvent(const DisplayEvent &ev)
Definition: events.h:671
bool EventNameIs(const char *eventName) const
Definition: events.h:474
Definition: bmpimage.h:46
LocationEvent(const LocationEvent &source)
Definition: events.h:190
float & lz
Definition: events.h:165
void EventName(const char *newName)
Definition: events.h:419
int event_text
Definition: events.h:314