Back to index

texmacs  1.0.7.15
event_codes.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : event_codes.hpp
00004 * DESCRIPTION: Unique codes for each event and
00005 *              modules for creating the corresponding events.
00006 * COPYRIGHT  : (C) 1999  Joris van der Hoeven
00007 *******************************************************************************
00008 * This software falls under the GNU general public license version 3 or later.
00009 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00010 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00011 ******************************************************************************/
00012 
00013 #ifndef EVENT_CODES_H
00014 #define EVENT_CODES_H
00015 
00016 /*** basic events ***/
00017 #define GET_SIZE_EVENT        0x00000000
00018 #define GET_WIDGET_EVENT      0x00000001
00019 #define SET_WIDGET_EVENT      0x00000002
00020 #define ATTACH_WINDOW_EVENT   0x00000003
00021 #define POSITION_EVENT        0x00000004
00022 #define MOVE_EVENT            0x00000005
00023 #define RESIZE_EVENT          0x00000006
00024 #define DESTROY_EVENT         0x00000007
00025 #define KEYPRESS_EVENT        0x00000008
00026 #define KEYBOARD_FOCUS_EVENT  0x00000009
00027 #define MOUSE_EVENT           0x0000000a
00028 #define ALARM_EVENT           0x0000000b
00029 #define CLEAR_EVENT           0x0000000c
00030 #define REPAINT_EVENT         0x0000000d
00031 #define UPDATE_EVENT          0x0000000e
00032 #define REFRESH_EVENT         0x0000000f
00033 #define INVALIDATE_EVENT      0x00000010
00034 #define KEYBOARD_GRAB_EVENT   0x00000011
00035 #define MOUSE_GRAB_EVENT      0x00000012
00036 #define REQUEST_ALARM_EVENT   0x00000013
00037 #define FIND_CHILD_EVENT      0x00000014
00038 
00039 /*** composite events ***/
00040 #define CLEAN_EVENT           0x00000015
00041 #define INSERT_EVENT          0x00000016
00042 #define REMOVE_EVENT          0x00000017
00043 
00044 /*** attribute events ***/
00045 #define GET_INTEGER_EVENT     0x00000018
00046 #define GET_DOUBLE_EVENT      0x00000019
00047 #define GET_STRING_EVENT      0x0000001a
00048 #define GET_COORD1_EVENT      0x0000001b
00049 #define GET_COORD2_EVENT      0x0000001c
00050 #define GET_COORD3_EVENT      0x0000001d
00051 #define GET_COORD4_EVENT      0x0000001e
00052 #define SET_INTEGER_EVENT     0x0000001f
00053 #define SET_DOUBLE_EVENT      0x00000020
00054 #define SET_STRING_EVENT      0x00000021
00055 #define SET_COORD1_EVENT      0x00000022
00056 #define SET_COORD2_EVENT      0x00000023
00057 #define SET_COORD3_EVENT      0x00000024
00058 #define SET_COORD4_EVENT      0x00000025
00059 
00060 /*** scroll events ***/
00061 #define SCROLL_EVENT          0x00000026
00062 
00063 /*** shared implementation for event_ptr<> ***/
00064 template<class R> struct event_ptr;
00065 
00066 class event_ptr_base {
00067   event_rep* rep;
00068 public:
00069   event_ptr_base (const event_ptr_base &ev) :
00070     rep (ev.rep) { rep->ref_count++; }
00071   event_ptr_base (const event& ev) : rep (ev.rep) { rep->ref_count++; }
00072   ~event_ptr_base () { if ((--rep->ref_count)==0) tm_delete (rep); }
00073   operator event () { return event (rep); }
00074   event_rep* operator -> () { return rep; }
00075   event_ptr_base& operator = (const event_ptr_base& ev) {
00076     ev.rep->ref_count++;
00077     if ((--rep->ref_count)==0) tm_delete (rep);
00078     rep=ev.rep;
00079     return *this;
00080   }
00081 };
00082 
00083 /*** event_ptr template ***/
00084 template<class R> struct event_ptr : private event_ptr_base {
00085   inline event_ptr (const event_ptr<R>& ev) : event_ptr_base(ev) {}
00086   inline event_ptr (const event& ev) : event_ptr_base(ev) {}
00087   inline ~event_ptr () {}
00088   inline event_ptr<R>& operator = (const event_ptr<R>& ev) {
00089     return static_cast<event_ptr<R>&>(event_ptr_base::operator=(ev)); }
00090   inline operator event()  {
00091     return event_ptr_base::operator event(); }
00092   inline R* operator -> () {
00093     return static_cast<R*>(event_ptr_base::operator->()); }
00094 };
00095 
00096 #define EVENT(PTR) typedef event_ptr<PTR##_rep> PTR; 
00097 
00098 #endif // defined EVENT_CODES_H