chalk

kis_input_device.h
1/*
2 * Copyright (c) 2006 Adrian Page <adrian@pagenet.plus.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19#ifndef KIS_INPUT_DEVICE_H_
20#define KIS_INPUT_DEVICE_H_
21
22#include <tqvaluevector.h>
23
24class KisInputDevice {
25public:
26 KisInputDevice();
27
28 static KisInputDevice allocateInputDevice();
29 static TQValueVector<KisInputDevice> inputDevices();
30
31 friend inline bool operator==(const KisInputDevice&, const KisInputDevice&);
32 friend inline bool operator!=(const KisInputDevice&, const KisInputDevice&);
33
34 friend inline bool operator<(const KisInputDevice &, const KisInputDevice &);
35 friend inline bool operator>(const KisInputDevice &, const KisInputDevice &);
36
37 static KisInputDevice mouse(); // Standard mouse
38 static KisInputDevice stylus(); // Wacom stylus via TQTabletEvent
39 static KisInputDevice eraser(); // Wacom eraser via TQTabletEvent
40 static KisInputDevice puck(); // Wacom puck via TQTabletEvent
41 static KisInputDevice unknown();
42
43private:
44 KisInputDevice(TQ_INT32 id) : m_id(id) {}
45
46 TQ_INT32 id() const { return m_id; }
47
48 static void allocateDefaultDevicesIfNeeded();
49 static KisInputDevice allocateNextDevice();
50
51private:
52 TQ_INT32 m_id;
53
54 static TQ_INT32 NextInputDeviceID;
55 static TQValueVector<KisInputDevice> InputDevices;
56
57 static KisInputDevice Mouse;
58 static KisInputDevice Stylus;
59 static KisInputDevice Eraser;
60 static KisInputDevice Puck;
61 static KisInputDevice Unknown;
62};
63
64inline bool operator==(const KisInputDevice &a, const KisInputDevice &b)
65{
66 return a.id() == b.id();
67}
68
69inline bool operator!=(const KisInputDevice &a, const KisInputDevice &b)
70{
71 return a.id() != b.id();
72}
73
74inline bool operator<(const KisInputDevice &a, const KisInputDevice &b)
75{
76 return a.id() < b.id();
77}
78
79
80inline bool operator>(const KisInputDevice &a, const KisInputDevice &b)
81{
82 return a.id() > b.id();
83}
84
85#endif // KIS_INPUT_DEVICE_H_
86