base data structures
[fanfix.git] / src / jexer / event / TMouseEvent.java
CommitLineData
df8de03f
KL
1/**
2 * Jexer - Java Text User Interface
3 *
4 * Version: $Id$
5 *
6 * Author: Kevin Lamonte, <a href="mailto:kevin.lamonte@gmail.com">kevin.lamonte@gmail.com</a>
7 *
8 * License: LGPLv3 or later
9 *
10 * Copyright: This module is licensed under the GNU Lesser General
11 * Public License Version 3. Please see the file "COPYING" in this
12 * directory for more information about the GNU Lesser General Public
13 * License Version 3.
14 *
15 * Copyright (C) 2015 Kevin Lamonte
16 *
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public License
19 * as published by the Free Software Foundation; either version 3 of
20 * the License, or (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful, but
23 * WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * General Public License for more details.
26 *
27 * You should have received a copy of the GNU Lesser General Public
28 * License along with this program; if not, see
29 * http://www.gnu.org/licenses/, or write to the Free Software
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
31 * 02110-1301 USA
32 */
33package jexer.event;
34
35/**
36 * This class encapsulates several kinds of mouse input events.
37 */
38public class TMouseEvent extends TInputEvent {
39
40 enum Type {
41 /**
42 * Mouse motion. X and Y will have screen coordinates.
43 */
44 MOUSE_MOTION,
45
46 /**
47 * Mouse button down. X and Y will have screen coordinates.
48 */
49 MOUSE_DOWN,
50
51 /**
52 * Mouse button up. X and Y will have screen coordinates.
53 */
54 MOUSE_UP
55 }
56
57 /**
58 * Type of event, one of MOUSE_MOTION, MOUSE_UP, or MOUSE_DOWN, or
59 * KEYPRESS
60 */
61 public Type type;
62
63 /**
64 * Mouse X - relative coordinates
65 */
66 public int x;
67
68 /**
69 * Mouse Y - relative coordinates
70 */
71 public int y;
72
73 /**
74 * Mouse X - absolute screen coordinates
75 */
76 public int absoluteX;
77
78 /**
79 * Mouse Y - absolute screen coordinate
80 */
81 public int absoluteY;
82
83 /**
84 * Mouse button 1 (left button)
85 */
86 public boolean mouse1;
87
88 /**
89 * Mouse button 2 (right button)
90 */
91 public boolean mouse2;
92
93 /**
94 * Mouse button 3 (middle button)
95 */
96 public boolean mouse3;
97
98 /**
99 * Mouse wheel UP (button 4)
100 */
101 public boolean mouseWheelUp;
102
103 /**
104 * Mouse wheel DOWN (button 5)
105 */
106 public boolean mouseWheelDown;
107
108 /**
109 * Public contructor
110 *
111 * @param type the type of event, MOUSE_MOTION, MOUSE_DOWN, or MOUSE_UP
112 */
113 public TMouseEvent(Type type) {
114 this.type = type;
115 }
116
117 /**
118 * Make human-readable description of this event
119 */
120 @Override
121 public String toString() {
122 return String.format("Mouse: %s x %d y %d absoluteX %d absoluteY %d 1 %s 2 %s 3 %s DOWN %s UP %s",
123 type,
124 x, y,
125 absoluteX, absoluteY,
126 mouse1,
127 mouse2,
128 mouse3,
129 mouseWheelUp,
130 mouseWheelDown);
131 }
132
133}