]> Dogcows Code - chaz/yoink/blobdiff - src/event.hh
big batch of progress
[chaz/yoink] / src / event.hh
index 84a073e34b8d0fb717be08815bbe25b6ea3bc2c2..8ca219a925917109e6c09bd50135e373a7c142cd 100644 (file)
 
 #ifndef _EVENT_HH_
 #define _EVENT_HH_
-
-#include "bz/date.h"
-#include "bz/object.h"
-
-
-namespace bz {
        
+#include <SDL/SDL.h>
 
-class event
-{
-public:
-       typedef enum
-       {
-               left_click_down         = 1<<1,
-               left_click_up           = 1<<2,
-               right_click_down        = 1<<3,
-               right_click_up          = 1<<4,
-               other_click_down        = 1<<5,
-               other_click_up          = 1<<6,
-               mouse_moved                     = 1<<7,
-               mouse_entered           = 1<<8,
-               mouse_exited            = 1<<9,
-               key_down                        = 1<<10,
-               key_up                          = 1<<11,
-               activated                       = 1<<12,
-               iconified                       = 1<<13,
-               deactivated                     = 1<<14,
-
-               file_new                        = 1<<20,
-               file_open                       = 1<<21,
-               file_revert                     = 1<<22,
-               file_save                       = 1<<23,
-               file_save_as            = 1<<24,
-               edit_undo                       = 1<<25,
-               edit_redo                       = 1<<26,
-               edit_copy                       = 1<<27,
-               edit_cut                        = 1<<28,
-               edit_paste                      = 1<<29,
-               edit_select_all         = 1<<30,
-               app_quit                        = 1<<31,
-               any                                     = 0xffffffffU
-       } type;
-
-       // This constructor is for keyboard events:
-       event( type theType,                                            // What happened?
-                  unsigned char keycode,                               // The ASCII value.
-                  int modifiers,                                               // Ctrl, Shift, Opt, etc...
-                  bool isRepeat ) :                                    // Is the key held down?
-               type_(theType), keycode_(keycode), modifiers_(modifiers),
-               isRepeat_(isRepeat)
-       {
-               timestamp_ = date();
-               id_ = getIdentifier();
-       }
-       
-       // This constructor is for mouse events:
-       event( type theType,                                            // What happened?
-                  vec2d location,                                              // Where? (window coordinates)
-                  vec2d delta,                                                 // How far has it moved?
-                  int nClick,                                                  // How many consecutive clicks?
-                  float pressure ) :                                   // How hard was it pushed?
-               type_(theType), location_(location), delta_(delta), nClick_(nClick),
-               pressure_(pressure)
-       {
-               timestamp_ = date();
-               id_ = getIdentifier();
-       }
 
-       // This constructor is for other event types:
-       event( type theType ) : type_(theType)          // What happened?
-       {
-               timestamp_ = date();
-               id_ = getIdentifier();
-       }
+namespace dc {
 
-       // Accessors for all event types:
-       type kind() const { return type_; }
-       const date& timestamp() const { return timestamp_; }
-       unsigned int identifier() const { return id_; }
 
-       void *userInfo() const { return userInfo_; }
-       void setUserInfo( void* userInfo ) { userInfo_ = userInfo; }
-       unsigned int tag() const { return tag_; }
-       void setTag( unsigned int tag ) { tag_ = tag; }
+// The event handling in SDL is so big that it would take more time than it's
+// worth to add an object-oriented abstraction layer that would completely cover
+// what SDL has already layed down.  Fortunately, SDL event structures are easy
+// to work with, and it is not the purpose of this library to completely hide
+// its dependencies and provide full functionality.
 
-       // Accessors for keyboard events:
-       unsigned char keycode() const { return keycode_; }
-       int modifiers() const { return modifiers_; }
-       bool isRepeat() const { return isRepeat_; }
+typedef SDL_Event event;
 
-       // Accessors for mouse events:
-       const vec2d& location() const { return location_; }
-       const vec2d& delta() const { return delta_; }
-       int clicks() const { return nClick_; }
-       float pressure() const { return pressure_; }
 
-private:
-       unsigned int getIdentifier() {
-               static unsigned int identifier = 1;
-               return identifier++;
-       }
-
-       type type_;
-       date timestamp_;
-       unsigned int id_;
-       void *userInfo_;
-       unsigned int tag_;
-
-       unsigned char keycode_;
-       unsigned char modifiers_;
-       bool isRepeat_;
-
-       vec2d location_;
-       vec2d delta_;
-       int nClick_;
-       float pressure_;
-};
-       
 } // namespace dc
 
 #endif // _EVENT_HH_
 
+/** vim: set ts=4 sw=4 tw=80: *************************************************/
+
This page took 0.01852 seconds and 4 git commands to generate.