]>
Dogcows Code - chaz/yoink/blob - src/event.hh
2 /*******************************************************************************
4 Copyright (c) 2009, Charles McGarvey
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
10 * Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
12 * Redistributions in binary form must reproduce the above copyright notice,
13 this list of conditions and the following disclaimer in the documentation
14 and/or other materials provided with the distribution.
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *******************************************************************************/
33 #include "bz/object.h"
44 left_click_down
= 1<<1,
46 right_click_down
= 1<<3,
47 right_click_up
= 1<<4,
48 other_click_down
= 1<<5,
49 other_click_up
= 1<<6,
69 edit_select_all
= 1<<30,
74 // This constructor is for keyboard events:
75 event( type theType
, // What happened?
76 unsigned char keycode
, // The ASCII value.
77 int modifiers
, // Ctrl, Shift, Opt, etc...
78 bool isRepeat
) : // Is the key held down?
79 type_(theType
), keycode_(keycode
), modifiers_(modifiers
),
83 id_
= getIdentifier();
86 // This constructor is for mouse events:
87 event( type theType
, // What happened?
88 vec2d location
, // Where? (window coordinates)
89 vec2d delta
, // How far has it moved?
90 int nClick
, // How many consecutive clicks?
91 float pressure
) : // How hard was it pushed?
92 type_(theType
), location_(location
), delta_(delta
), nClick_(nClick
),
96 id_
= getIdentifier();
99 // This constructor is for other event types:
100 event( type theType
) : type_(theType
) // What happened?
103 id_
= getIdentifier();
106 // Accessors for all event types:
107 type
kind() const { return type_
; }
108 const date
& timestamp() const { return timestamp_
; }
109 unsigned int identifier() const { return id_
; }
111 void *userInfo() const { return userInfo_
; }
112 void setUserInfo( void* userInfo
) { userInfo_
= userInfo
; }
113 unsigned int tag() const { return tag_
; }
114 void setTag( unsigned int tag
) { tag_
= tag
; }
116 // Accessors for keyboard events:
117 unsigned char keycode() const { return keycode_
; }
118 int modifiers() const { return modifiers_
; }
119 bool isRepeat() const { return isRepeat_
; }
121 // Accessors for mouse events:
122 const vec2d
& location() const { return location_
; }
123 const vec2d
& delta() const { return delta_
; }
124 int clicks() const { return nClick_
; }
125 float pressure() const { return pressure_
; }
128 unsigned int getIdentifier() {
129 static unsigned int identifier
= 1;
139 unsigned char keycode_
;
140 unsigned char modifiers_
;
This page took 0.036773 seconds and 5 git commands to generate.