41 #ifndef INCLUDED_DISTI_EVENTS_H
42 #define INCLUDED_DISTI_EVENTS_H
94 SHIFT_STATE = 0x00010000,
95 CAPS_LOCK_STATE = 0x00020000,
96 CTRL_STATE = 0x00040000,
97 ALT_STATE = 0x00080000,
98 NUM_LOCK_STATE = 0x00100000,
99 META_STATE = 0x00400000,
100 SCROLL_LOCK_STATE = 0x00800000,
101 BUTTON1_STATE = 0x01000000,
102 BUTTON2_STATE = 0x02000000,
103 BUTTON3_STATE = 0x04000000
125 : eventType( source.eventType )
126 , eventSubtype( source.eventSubtype )
190 , winLoc( source.winLoc )
191 , lCoords( source.lCoords )
192 , oCoords( source.oCoords )
342 , _initiator( initiator )
346 int size = (int)strlen( eventName ) + 1;
347 _eventName =
new char[ size ];
348 #if defined( _WIN32 )
349 strcpy_s( _eventName, size, eventName );
351 strcpy( _eventName, eventName );
355 size = (int)strlen( eventData ) + 1;
356 _eventData =
new char[ size ];
357 #if defined( _WIN32 )
358 strcpy_s( _eventData, size, eventData );
360 strcpy( _eventData, eventData );
373 , _initiator( initiator )
424 int size = (int)strlen( newName ) + 1;
425 _eventName =
new char[ size ];
426 #if defined( _WIN32 )
427 strcpy_s( _eventName, size, newName );
429 strcpy( _eventName, newName );
459 int size = (int)strlen( newData ) + 1;
460 _eventData =
new char[ size ];
461 #if defined( _WIN32 )
462 strcpy_s( _eventData, size, newData );
464 strcpy( _eventData, newData );
474 if( !_eventName || !eventName )
479 return ( 0 == strcmp( _eventName, eventName ) );
487 if( !_eventData || !eventData )
492 return ( 0 == strcmp( _eventData, eventData ) );
499 if( self->ParentGroup() )
501 self->ParentGroup()->handle( event );
503 else if( dynamic_cast<ComponentBase*>(
self ) )
506 self->handle( event );
525 bool is = ( objEvent && objEvent->
EventNameIs( eventName ) );
526 if( is && eventData )
534 #define ON( event, subevent ) if( ( ev->eventType == ( event ) ) && ( ev->eventSubtype == ( subevent ) ) )
537 #define ON_MOUSE_UP( btnMask ) if( ( ev->eventType == EVENT_MOUSE ) && ( ev->eventSubtype == MOUSE_UP ) && ( (btnMask)&mev->buttonMask ) )
540 #define ON_MOUSE_DOWN( btnMask ) if( ( ev->eventType == EVENT_MOUSE ) && ( ev->eventSubtype == MOUSE_DOWN ) && ( (btnMask)&mev->buttonMask ) )
543 #define ON_MOUSE_DRAG( btnMask ) if( ( ev->eventType == EVENT_MOUSE ) && ( ev->eventSubtype == MOUSE_DRAG ) && ( (btnMask)&mev->buttonMask ) )
546 #define ON_KEY_DOWN( testKey ) if( ( ev->eventType == EVENT_KEYBOARD ) && OnKeyEvent( kev, true, int( testKey ) ) )
549 #define ON_KEY_UP( testKey ) if( ( ev->eventType == EVENT_KEYBOARD_UP ) && OnKeyEvent( kev, true, int( testKey ) ) )
552 #define ON_KEY_DOWN_WITH_MODIFIER( testKey, modifierMask ) if( ( ev->eventType == EVENT_KEYBOARD ) && OnKeyEvent( kev, true, int( testKey ), modifierMask ) )
555 #define ON_KEY_UP_WITH_MODIFIER( testKey, modifierMask ) if( ( ev->eventType == EVENT_KEYBOARD_UP ) && OnKeyEvent( kev, true, int( testKey ), modifierMask ) )
558 #define ON_SPECIAL_KEY_DOWN( keySym ) if( ( ev->eventType == EVENT_KEYBOARD ) && OnKeyEvent( kev, false, int( keySym ) ) )
561 #define ON_SPECIAL_KEY_UP( keySym ) if( ( ev->eventType == EVENT_KEYBOARD_UP ) && OnKeyEvent( kev, false, int( keySym ) ) )
564 #define ON_SPECIAL_KEY_DOWN_WITH_MODIFIER( keySym, modifierMask ) if( ( ev->eventType == EVENT_KEYBOARD ) && OnKeyEvent( kev, false, int( keySym ), modifierMask ) )
567 #define ON_SPECIAL_KEY_UP_WITH_MODIFIER( keySym, modifierMask ) if( ( ev->eventType == EVENT_KEYBOARD_UP ) && OnKeyEvent( kev, false, int( keySym ), modifierMask ) )
570 #define ON_ANY_KEY_DOWN() if( ( ev->eventType == EVENT_KEYBOARD ) )
573 #define ON_ANY_KEY_UP() if( ( ev->eventType == EVENT_KEYBOARD_UP ) )
602 bool keySuccess =
false;
610 if( CTRL_STATE & modifierMask )
613 key = std::tolower( key );
614 keySuccess = ( key == kev->
keysym );
623 keySuccess = ( key == kev->
keysym );
631 bool modSuccess = ( 0 != ( modifierMask & kev->
modifiers ) || ( 0 == modifierMask && 0 == (
int( SHIFT_STATE | CTRL_STATE | ALT_STATE | META_STATE ) & kev->
modifiers ) ) );
633 return ( keySuccess && modSuccess );
638 class EventCompressor
641 typedef DisplayObject* ( T::*EventSenderCbType )( DisplayEvent* ev );
644 MouseEvent _lastCompressedEvent;
645 bool _lastEventWasCompressed;
646 EventSenderCbType _handleCb;
648 bool _sendingCompressed;
652 void Active(
bool val ) { _active = val; }
653 bool Active() {
return _active; }
655 EventCompressor( T* objectPtr, EventSenderCbType cb )
656 : _lastEventWasCompressed( false )
658 , _objectPtr( objectPtr )
659 , _sendingCompressed( false )
671 if( !_active || _sendingCompressed )
676 bool compressed =
false;
681 if( !_lastEventWasCompressed || ( _lastEventWasCompressed && _lastCompressedEvent.eventType == ev.
eventType && _lastCompressedEvent.eventSubtype == ev.
eventSubtype && _lastCompressedEvent.cursorID == mev->
cursorID ) )
684 _lastCompressedEvent = *mev;
685 _lastEventWasCompressed =
true;
693 SendAnyCompressedEvents();
698 void SendAnyCompressedEvents()
701 if( _sendingCompressed )
706 if( _lastEventWasCompressed )
708 _sendingCompressed =
true;
710 ( _objectPtr->*( _handleCb ) )( &_lastCompressedEvent );
712 _sendingCompressed =
false;
714 _lastEventWasCompressed =
false;
721 #endif // INCLUDED_DISTI_EVENTS_H
int keysym
Definition: events.h:311
unsigned short eventSubtype
Definition: events.h:114
unsigned short eventType
Definition: events.h:113
MouseButtonType_e
Definition: events.h:82
void EmitObjectEvent(DisplayObject *self, ObjectEvent *event)
Definition: events.h:497
float & x
Definition: events.h:157
float & z
Definition: events.h:159
The disti::ComponentBase class.
DisplayEvent(const DisplayEvent &source)
Definition: events.h:124
bool ObjectEventIs(DisplayEvent *event, const char *eventName, const char *eventData=NULL)
Definition: events.h:522
The disti::Group class. Implements groups of objects.
float & lx
Definition: events.h:161
float & ox
Definition: events.h:165
KeyboardEvent(const KeyboardEvent &source)
Definition: events.h:284
KeyboardEvent()
Definition: events.h:275
ObjectEvent(DisplayObject *initiator, unsigned short eventSubtypeArg)
Definition: events.h:371
LocationEvent()
Definition: events.h:173
bool OnKeyEvent(KeyboardEvent *kev, bool alphaNumeric, int key, int modifierMask=0)
Definition: events.h:600
MouseEvent(const MouseEvent &source)
Definition: events.h:233
SpecialKeyState_e
Definition: events.h:91
The disti::Timer class. An OS portable timing class.
int modifiers
Definition: events.h:313
Vector winLoc
Definition: events.h:147
A file for all GL Studio files to include.
MouseEventType_e
Definition: events.h:68
const char * EventName() const
Definition: events.h:401
The disti::DisplayObject class and global enumerations.
DisplayObject * Initiator() const
Definition: events.h:392
int modifiers
Definition: events.h:266
float & ly
Definition: events.h:162
Vector oCoords
Definition: events.h:153
KeyboardEvent operator=(const KeyboardEvent &source)
Definition: events.h:302
float & oy
Definition: events.h:166
unsigned int cursorID
Definition: events.h:267
EventType_e
Definition: events.h:58
void Initiator(DisplayObject *initiator)
Definition: events.h:397
Vector lCoords
Definition: events.h:150
unsigned char buttonMask
Definition: events.h:264
MouseEvent operator=(const MouseEvent &source)
Definition: events.h:254
bool EventDataIs(const char *eventData) const
Definition: events.h:485
float & y
Definition: events.h:158
float & oz
Definition: events.h:167
MouseEvent(const LocationEvent &source)
Definition: events.h:243
LocationEvent operator=(const LocationEvent &source)
Definition: events.h:206
DisplayEvent()
Definition: events.h:117
void EventData(const char *newData)
Definition: events.h:452
ObjectEvent(DisplayObject *initiator, const char *eventName, const char *eventData=NULL)
Definition: events.h:340
MouseEvent()
Definition: events.h:222
virtual ~DisplayEvent()
Definition: events.h:131
const char * EventData() const
Definition: events.h:436
KeyboardEvent(const LocationEvent &source)
Definition: events.h:293
unsigned char clicks
Definition: events.h:265
bool CompressEvent(const DisplayEvent &ev)
Definition: events.h:669
bool EventNameIs(const char *eventName) const
Definition: events.h:472
Definition: bmpimage.h:46
LocationEvent(const LocationEvent &source)
Definition: events.h:188
float & lz
Definition: events.h:163
void EventName(const char *newName)
Definition: events.h:417
int event_text
Definition: events.h:312