cgv
Loading...
Searching...
No Matches
mouse_event.h
1#pragma once
2
3#include "event.h"
4
5#include "lib_begin.h"
6
7namespace cgv {
8 namespace gui {
9
10
21
30
32class CGV_API mouse_event : public event
33{
34protected:
36 short x;
38 short y;
40 short dx;
42 short dy;
44 unsigned char action;
46 unsigned char button_state;
48 unsigned char button;
50 unsigned char flags;
52 std::string dnd_text;
53public:
55 mouse_event(int x, int y, MouseAction _action, unsigned char _button_state = 0, unsigned char _button = 0, short _dx = 0, short _dy = 0, unsigned char _modifiers = 0, unsigned char _toggle_keys = 0, double _time = 0);
57 void stream_out(std::ostream& os) const;
59 void stream_in(std::istream& is);
61 short get_x() const;
63 short get_y() const;
65 short get_dx() const;
67 short get_dy() const;
69 MouseAction get_action() const;
71 unsigned char get_button_state() const;
73 unsigned char get_button() const;
75 const std::string& get_dnd_text() const;
76
78 void set_x(short _x);
80 void set_y(short _y);
82 void set_dx(short _dx);
84 void set_dy(short _dy);
86 void set_action(MouseAction _action);
88 void set_button_state(unsigned char _button_state);
90 void set_button(unsigned char _button);
92 void set_dnd_text(const std::string& text);
93};
94
95 }
96}
97
98#include <cgv/config/lib_end.h>
event(unsigned int _kind=EID_NONE, unsigned char _modifiers=0, unsigned char _toggle_keys=0, double _time=0)
construct event from its kind
Definition event.cxx:20
void set_dy(short _dy)
set for move and drag events the difference in y to the previous position, for wheel events the amoun...
void set_dx(short _dx)
set for move and drag events the difference in x to the previous position
short get_y() const
current mouse y position (origin is top-left of window)
short dx
change in x position
Definition mouse_event.h:40
void set_x(short _x)
set current mouse x position
short y
y position of mouse pointer
Definition mouse_event.h:38
void set_button_state(unsigned char _button_state)
set the button state as values from MouseButton combined with a logical or-operation
unsigned char action
store MouseAction
Definition mouse_event.h:44
void stream_in(std::istream &is)
read from stream
short dy
change in y position
Definition mouse_event.h:42
void set_button(unsigned char _button)
set the pressed or released button for a button press or release action
unsigned char flags
store mouse event flags
Definition mouse_event.h:50
MouseAction get_action() const
return the mouse action
unsigned char button
store the pressed button
Definition mouse_event.h:48
void set_action(MouseAction _action)
return the mouse action
short get_dx() const
for move and drag events the difference in x to the previous position
std::string dnd_text
the texted resulting from a drag and drop event
Definition mouse_event.h:52
void stream_out(std::ostream &os) const
write to stream
short get_x() const
current mouse x position (origin is top-left of window)
unsigned char button_state
store the button state
Definition mouse_event.h:46
void set_y(short _y)
set current mouse y position
unsigned char get_button_state() const
return the button state as values from MouseButton combined with a logical or-operation
void set_dnd_text(const std::string &text)
set the drag&drop text
short x
x position of mouse pointer
Definition mouse_event.h:36
mouse_event(int x, int y, MouseAction _action, unsigned char _button_state=0, unsigned char _button=0, short _dx=0, short _dy=0, unsigned char _modifiers=0, unsigned char _toggle_keys=0, double _time=0)
construct a mouse
short get_dy() const
for move and drag events the difference in y to the previous position, for wheel events the amount th...
const std::string & get_dnd_text() const
only valid in a MA_RELEASE event with the flag MF_DND set, return the text resulting from the drag&dr...
unsigned char get_button() const
return the pressed or released button for a button press or release action
namespace that holds the abstract gui interface
Definition vr_calib.cxx:10
MouseButton
different mouse buttons that can be ored together to specify the button state
Definition mouse_event.h:24
@ MB_MIDDLE_BUTTON
middle button
Definition mouse_event.h:27
@ MB_NO_BUTTON
no button
Definition mouse_event.h:25
@ MB_RIGHT_BUTTON
right button
Definition mouse_event.h:28
@ MB_LEFT_BUTTON
left button
Definition mouse_event.h:26
MouseAction
different actions that a mouse can perform
Definition mouse_event.h:12
@ MA_PRESS
mouse button pressed
Definition mouse_event.h:13
@ MA_LEAVE
mouse leave window action
Definition mouse_event.h:19
@ MA_MOVE
mouse pointer moved
Definition mouse_event.h:16
@ MA_ENTER
mouse enter window action
Definition mouse_event.h:18
@ MA_WHEEL
mouse wheel moved
Definition mouse_event.h:15
@ MA_DRAG
mouse drag action
Definition mouse_event.h:17
@ MA_RELEASE
mouse button released
Definition mouse_event.h:14
this header is dependency free
Definition print.h:11