41 #ifndef INCLUDED_DISTI_EVENTS_H
42 #define INCLUDED_DISTI_EVENTS_H
95 SHIFT_STATE = 0x00010000,
96 CAPS_LOCK_STATE = 0x00020000,
97 CTRL_STATE = 0x00040000,
98 ALT_STATE = 0x00080000,
99 NUM_LOCK_STATE = 0x00100000,
100 META_STATE = 0x00400000,
101 SCROLL_LOCK_STATE = 0x00800000,
102 BUTTON1_STATE = 0x01000000,
103 BUTTON2_STATE = 0x02000000,
104 BUTTON3_STATE = 0x04000000
126 : eventType( source.eventType )
127 , eventSubtype( source.eventSubtype )
191 , winLoc( source.winLoc )
192 , lCoords( source.lCoords )
193 , oCoords( source.oCoords )
343 , _initiator( initiator )
347 int size = (int)strlen( eventName ) + 1;
348 _eventName =
new char[ size ];
349 #if defined( _WIN32 )
350 strcpy_s( _eventName, size, eventName );
352 strcpy( _eventName, eventName );
356 size = (int)strlen( eventData ) + 1;
357 _eventData =
new char[ size ];
358 #if defined( _WIN32 )
359 strcpy_s( _eventData, size, eventData );
361 strcpy( _eventData, eventData );
374 , _initiator( initiator )
425 int size = (int)strlen( newName ) + 1;
426 _eventName =
new char[ size ];
427 #if defined( _WIN32 )
428 strcpy_s( _eventName, size, newName );
430 strcpy( _eventName, newName );
460 int size = (int)strlen( newData ) + 1;
461 _eventData =
new char[ size ];
462 #if defined( _WIN32 )
463 strcpy_s( _eventData, size, newData );
465 strcpy( _eventData, newData );
475 if( !_eventName || !eventName )
480 return ( 0 == strcmp( _eventName, eventName ) );
488 if( !_eventData || !eventData )
493 return ( 0 == strcmp( _eventData, eventData ) );
500 if( self->ParentGroup() )
502 self->ParentGroup()->handle( event );
504 else if( dynamic_cast<ComponentBase*>(
self ) )
507 self->handle( event );
526 bool is = ( objEvent && objEvent->
EventNameIs( eventName ) );
527 if( is && eventData )
535 #define ON( event, subevent ) if( ( ev->eventType == ( event ) ) && ( ev->eventSubtype == ( subevent ) ) )
538 #define ON_MOUSE_UP( btnMask ) if( ( ev->eventType == EVENT_MOUSE ) && ( ev->eventSubtype == MOUSE_UP ) && ( (btnMask)&mev->buttonMask ) )
541 #define ON_MOUSE_DOWN( btnMask ) if( ( ev->eventType == EVENT_MOUSE ) && ( ev->eventSubtype == MOUSE_DOWN ) && ( (btnMask)&mev->buttonMask ) )
544 #define ON_MOUSE_DRAG( btnMask ) if( ( ev->eventType == EVENT_MOUSE ) && ( ev->eventSubtype == MOUSE_DRAG ) && ( (btnMask)&mev->buttonMask ) )
547 #define ON_KEY_DOWN( testKey ) if( ( ev->eventType == EVENT_KEYBOARD ) && OnKeyEvent( kev, true, int( testKey ) ) )
550 #define ON_KEY_UP( testKey ) if( ( ev->eventType == EVENT_KEYBOARD_UP ) && OnKeyEvent( kev, true, int( testKey ) ) )
553 #define ON_KEY_DOWN_WITH_MODIFIER( testKey, modifierMask ) if( ( ev->eventType == EVENT_KEYBOARD ) && OnKeyEvent( kev, true, int( testKey ), modifierMask ) )
556 #define ON_KEY_UP_WITH_MODIFIER( testKey, modifierMask ) if( ( ev->eventType == EVENT_KEYBOARD_UP ) && OnKeyEvent( kev, true, int( testKey ), modifierMask ) )
559 #define ON_SPECIAL_KEY_DOWN( keySym ) if( ( ev->eventType == EVENT_KEYBOARD ) && OnKeyEvent( kev, false, int( keySym ) ) )
562 #define ON_SPECIAL_KEY_UP( keySym ) if( ( ev->eventType == EVENT_KEYBOARD_UP ) && OnKeyEvent( kev, false, int( keySym ) ) )
565 #define ON_SPECIAL_KEY_DOWN_WITH_MODIFIER( keySym, modifierMask ) if( ( ev->eventType == EVENT_KEYBOARD ) && OnKeyEvent( kev, false, int( keySym ), modifierMask ) )
568 #define ON_SPECIAL_KEY_UP_WITH_MODIFIER( keySym, modifierMask ) if( ( ev->eventType == EVENT_KEYBOARD_UP ) && OnKeyEvent( kev, false, int( keySym ), modifierMask ) )
571 #define ON_ANY_KEY_DOWN() if( ( ev->eventType == EVENT_KEYBOARD ) )
574 #define ON_ANY_KEY_UP() if( ( ev->eventType == EVENT_KEYBOARD_UP ) )
603 bool keySuccess =
false;
611 if( CTRL_STATE & modifierMask )
614 key = std::tolower( key );
615 keySuccess = ( key == kev->
keysym );
624 keySuccess = ( key == kev->
keysym );
632 bool modSuccess = ( 0 != ( modifierMask & kev->
modifiers ) || ( 0 == modifierMask && 0 == (
int( SHIFT_STATE | CTRL_STATE | ALT_STATE | META_STATE ) & kev->
modifiers ) ) );
634 return ( keySuccess && modSuccess );
639 class EventCompressor
642 typedef DisplayObject* ( T::*EventSenderCbType )( DisplayEvent* ev );
645 MouseEvent _lastCompressedEvent;
646 bool _lastEventWasCompressed;
647 EventSenderCbType _handleCb;
649 bool _sendingCompressed;
653 void Active(
bool val ) { _active = val; }
654 bool Active() {
return _active; }
656 EventCompressor( T* objectPtr, EventSenderCbType cb )
657 : _lastEventWasCompressed( false )
659 , _objectPtr( objectPtr )
660 , _sendingCompressed( false )
672 if( !_active || _sendingCompressed )
677 bool compressed =
false;
682 if( !_lastEventWasCompressed || ( _lastEventWasCompressed && _lastCompressedEvent.eventType == ev.
eventType && _lastCompressedEvent.eventSubtype == ev.
eventSubtype && _lastCompressedEvent.cursorID == mev->
cursorID ) )
685 _lastCompressedEvent = *mev;
686 _lastEventWasCompressed =
true;
694 SendAnyCompressedEvents();
699 void SendAnyCompressedEvents()
702 if( _sendingCompressed )
707 if( _lastEventWasCompressed )
709 _sendingCompressed =
true;
711 ( _objectPtr->*( _handleCb ) )( &_lastCompressedEvent );
713 _sendingCompressed =
false;
715 _lastEventWasCompressed =
false;
722 #endif // INCLUDED_DISTI_EVENTS_H
int keysym
Definition: events.h:312
unsigned short eventSubtype
Definition: events.h:115
unsigned short eventType
Definition: events.h:114
MouseButtonType_e
Definition: events.h:83
void EmitObjectEvent(DisplayObject *self, ObjectEvent *event)
Definition: events.h:498
float & x
Definition: events.h:158
float & z
Definition: events.h:160
The disti::ComponentBase class.
DisplayEvent(const DisplayEvent &source)
Definition: events.h:125
bool ObjectEventIs(DisplayEvent *event, const char *eventName, const char *eventData=NULL)
Definition: events.h:523
The disti::Group class. Implements groups of objects.
float & lx
Definition: events.h:162
float & ox
Definition: events.h:166
KeyboardEvent(const KeyboardEvent &source)
Definition: events.h:285
KeyboardEvent()
Definition: events.h:276
ObjectEvent(DisplayObject *initiator, unsigned short eventSubtypeArg)
Definition: events.h:372
LocationEvent()
Definition: events.h:174
bool OnKeyEvent(KeyboardEvent *kev, bool alphaNumeric, int key, int modifierMask=0)
Definition: events.h:601
MouseEvent(const MouseEvent &source)
Definition: events.h:234
SpecialKeyState_e
Definition: events.h:92
The disti::Timer class. An OS portable timing class.
int modifiers
Definition: events.h:314
Vector winLoc
Definition: events.h:148
A file for all GL Studio files to include.
MouseEventType_e
Definition: events.h:68
const char * EventName() const
Definition: events.h:402
The disti::DisplayObject class and global enumerations.
DisplayObject * Initiator() const
Definition: events.h:393
int modifiers
Definition: events.h:267
float & ly
Definition: events.h:163
Vector oCoords
Definition: events.h:154
KeyboardEvent operator=(const KeyboardEvent &source)
Definition: events.h:303
float & oy
Definition: events.h:167
unsigned int cursorID
Definition: events.h:268
EventType_e
Definition: events.h:58
void Initiator(DisplayObject *initiator)
Definition: events.h:398
Vector lCoords
Definition: events.h:151
unsigned char buttonMask
Definition: events.h:265
MouseEvent operator=(const MouseEvent &source)
Definition: events.h:255
bool EventDataIs(const char *eventData) const
Definition: events.h:486
float & y
Definition: events.h:159
float & oz
Definition: events.h:168
MouseEvent(const LocationEvent &source)
Definition: events.h:244
LocationEvent operator=(const LocationEvent &source)
Definition: events.h:207
DisplayEvent()
Definition: events.h:118
void EventData(const char *newData)
Definition: events.h:453
ObjectEvent(DisplayObject *initiator, const char *eventName, const char *eventData=NULL)
Definition: events.h:341
MouseEvent()
Definition: events.h:223
virtual ~DisplayEvent()
Definition: events.h:132
const char * EventData() const
Definition: events.h:437
KeyboardEvent(const LocationEvent &source)
Definition: events.h:294
unsigned char clicks
Definition: events.h:266
bool CompressEvent(const DisplayEvent &ev)
Definition: events.h:670
bool EventNameIs(const char *eventName) const
Definition: events.h:473
Definition: bmpimage.h:46
LocationEvent(const LocationEvent &source)
Definition: events.h:189
float & lz
Definition: events.h:164
void EventName(const char *newName)
Definition: events.h:418
int event_text
Definition: events.h:313