krita

kis_input_device.h

00001 /*
00002  *  Copyright (c) 2006 Adrian Page <adrian@pagenet.plus.com>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 
00019 #ifndef KIS_INPUT_DEVICE_H_
00020 #define KIS_INPUT_DEVICE_H_
00021 
00022 #include <qvaluevector.h>
00023 
00024 class KisInputDevice {
00025 public:
00026     KisInputDevice();
00027 
00028     static KisInputDevice allocateInputDevice();
00029     static QValueVector<KisInputDevice> inputDevices();
00030 
00031     friend inline bool operator==(const KisInputDevice&, const KisInputDevice&);
00032     friend inline bool operator!=(const KisInputDevice&, const KisInputDevice&);
00033 
00034     friend inline bool operator<(const KisInputDevice &, const KisInputDevice &);
00035     friend inline bool operator>(const KisInputDevice &, const KisInputDevice &);
00036 
00037     static KisInputDevice mouse();     // Standard mouse                
00038     static KisInputDevice stylus();    // Wacom stylus via QTabletEvent 
00039     static KisInputDevice eraser();    // Wacom eraser via QTabletEvent 
00040     static KisInputDevice puck();      // Wacom puck via QTabletEvent   
00041     static KisInputDevice unknown();   
00042 
00043 private:
00044     KisInputDevice(Q_INT32 id) : m_id(id) {}
00045 
00046     Q_INT32 id() const { return m_id; }
00047 
00048     static void allocateDefaultDevicesIfNeeded();
00049     static KisInputDevice allocateNextDevice();
00050 
00051 private:
00052      Q_INT32 m_id;
00053 
00054      static Q_INT32 NextInputDeviceID;
00055      static QValueVector<KisInputDevice> InputDevices;
00056 
00057      static KisInputDevice Mouse;
00058      static KisInputDevice Stylus;
00059      static KisInputDevice Eraser;
00060      static KisInputDevice Puck;
00061      static KisInputDevice Unknown;
00062 };
00063 
00064 inline bool operator==(const KisInputDevice &a, const KisInputDevice &b)
00065 { 
00066     return a.id() == b.id(); 
00067 }
00068 
00069 inline bool operator!=(const KisInputDevice &a, const KisInputDevice &b)
00070 { 
00071     return a.id() != b.id();
00072 }
00073 
00074 inline bool operator<(const KisInputDevice &a, const KisInputDevice &b)
00075 {
00076     return a.id() < b.id();
00077 }
00078 
00079 
00080 inline bool operator>(const KisInputDevice &a, const KisInputDevice &b)
00081 {
00082     return a.id() > b.id();
00083 }
00084 
00085 #endif // KIS_INPUT_DEVICE_H_
00086 
KDE Home | KDE Accessibility Home | Description of Access Keys