00001 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- 00002 #ifndef __eventhandler__hh 00003 #define __eventhandler__hh 00004 00005 extern "C" { 00006 #include <X11/Xlib.h> 00007 00008 #ifdef SHAPE 00009 #include <X11/extensions/shape.h> 00010 #endif // SHAPE 00011 00012 #ifdef XKB 00013 #include <X11/XKBlib.h> 00014 #endif // XKB 00015 00016 } 00017 00018 namespace otk { 00019 00020 class EventHandler { 00021 public: 00022 //! Dispatches events to one of the other handlers based on their type. 00023 virtual void handle(const XEvent &e); 00024 00025 //! Called whenever any key is pressed. 00026 virtual void keyPressHandler(const XKeyEvent &) {} 00027 00028 //! Called whenever any key is released. 00029 virtual void keyReleaseHandler(const XKeyEvent &) {} 00030 00031 //! Called whenever a button of the pointer is pressed. 00032 virtual void buttonPressHandler(const XButtonEvent &) {} 00033 00034 //! Called whenever a button of the pointer is released. 00035 virtual void buttonReleaseHandler(const XButtonEvent &) {} 00036 00037 //! Called whenever the pointer moved 00038 virtual void motionHandler(const XMotionEvent &) {} 00039 00040 //! Called whenever the pointer enters a window. 00041 virtual void enterHandler(const XCrossingEvent &) {} 00042 00043 //! Called whenever the pointer leaves a window. 00044 virtual void leaveHandler(const XCrossingEvent &) {} 00045 00046 //! Called when a window gains focus. 00047 virtual void focusHandler(const XFocusChangeEvent &) {} 00048 00049 //! Called when a window looses focus. 00050 virtual void unfocusHandler(const XFocusChangeEvent &) {} 00051 00052 //! Called when a window becomes visible to the user. 00053 virtual void exposeHandler(const XExposeEvent &) {} 00054 00055 //! Called to handle GraphicsExpose events. 00056 virtual void graphicsExposeHandler(const XGraphicsExposeEvent &) {} 00057 00058 //! Called to handle NoExpose events. 00059 virtual void noExposeEventHandler(const XNoExposeEvent &) {} 00060 00061 //! Called when the window requests a change in its z-order. 00062 virtual void circulateRequestHandler(const XCirculateRequestEvent &) 00063 {} 00064 00065 //! Called when a different client initiates a configure window request. 00066 virtual void configureRequestHandler(const XConfigureRequestEvent &) 00067 {} 00068 00069 //! Called when a different client tries to map a window. 00070 virtual void mapRequestHandler(const XMapRequestEvent &) {} 00071 00072 //! Called when another client attemps to change the size of a window. 00073 virtual void resizeRequestHandler(const XResizeRequestEvent &) {} 00074 00075 //! Called when the z-order of the window has changed. 00076 virtual void circulateHandler(const XCirculateEvent &) {} 00077 00078 //! Called when the window as been reconfigured. 00079 virtual void configureHandler(const XConfigureEvent &) {} 00080 00081 //! Called when a window is created. 00082 virtual void createHandler(const XCreateWindowEvent &) {} 00083 00084 //! Called when a window is destroyed. 00085 virtual void destroyHandler(const XDestroyWindowEvent &) {} 00086 00087 //! Called when a window is moved because of a change in the size of its 00088 //! parent. 00089 virtual void gravityHandler(const XGravityEvent &) {} 00090 00091 //! Called when a window is mapped. 00092 virtual void mapHandler(const XMapEvent &) {} 00093 00094 //! Called when the server generats a MappingNotify event 00095 virtual void mappingHandler(const XMappingEvent &) {} 00096 00097 //! Called when a window is reparented 00098 virtual void reparentHandler(const XReparentEvent &) {} 00099 00100 //! Called when a window is unmapped 00101 virtual void unmapHandler(const XUnmapEvent &) {} 00102 00103 //! Called when a the visibilty of a window changes 00104 virtual void visibilityHandler(const XVisibilityEvent &) {} 00105 00106 //! Called when the colormap changes, or is installed or unistalled 00107 virtual void colorMapHandler(const XColormapEvent &) {} 00108 00109 //! Called when a property of a window changes 00110 virtual void propertyHandler(const XPropertyEvent &) {} 00111 00112 //! Called when the client loses ownership of a selection 00113 virtual void selectionClearHandler(const XSelectionClearEvent &) {} 00114 00115 //! Called when a ConvertSelection protocol request is sent 00116 virtual void selectionHandler(const XSelectionEvent &) {} 00117 00118 //! Called when a SelectionEvent occurs 00119 virtual void selectionRequestHandler(const XSelectionRequestEvent &) {} 00120 00121 //! Called when a client calls XSendEvent 00122 /*! 00123 Some types of client messages are filtered out and sent to more specific 00124 event handler functions. 00125 */ 00126 virtual void clientMessageHandler(const XClientMessageEvent &); 00127 00128 #if defined(SHAPE) || defined(DOXYGEN_IGNORE) 00129 //! Called when a shape extension event fires 00130 virtual void shapeHandler(const XShapeEvent &) {} 00131 #endif // SHAPE 00132 00133 #if defined(XKB) || defined(DOXYGEN_IGNORE) 00134 //! Called when an xkb extension event fires 00135 virtual void xkbHandler(const XkbEvent &) {} 00136 #endif // XKB 00137 00138 virtual ~EventHandler(); 00139 00140 protected: 00141 /*! Constructor for the EventHandler class. 00142 This is protected so that EventHandlers can't be instantiated on their 00143 own. 00144 */ 00145 EventHandler(); 00146 00147 private: 00148 }; 00149 00150 } 00151 00152 #endif