krita

kis_input_device.cc

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.g
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 #include "kis_input_device.h"
00020 
00021 #define UNKNOWN_INPUT_DEVICE_ID -1
00022 #define FIRST_INPUT_DEVICE_ID 0
00023 
00024 Q_INT32 KisInputDevice::NextInputDeviceID = FIRST_INPUT_DEVICE_ID;
00025 
00026 KisInputDevice KisInputDevice::Mouse;
00027 KisInputDevice KisInputDevice::Stylus;
00028 KisInputDevice KisInputDevice::Eraser;
00029 KisInputDevice KisInputDevice::Puck;
00030 KisInputDevice KisInputDevice::Unknown(UNKNOWN_INPUT_DEVICE_ID);
00031 
00032 QValueVector<KisInputDevice> KisInputDevice::InputDevices;
00033 
00034 KisInputDevice::KisInputDevice()
00035 {
00036     m_id = UNKNOWN_INPUT_DEVICE_ID;
00037 }
00038 
00039 KisInputDevice KisInputDevice::allocateNextDevice()
00040 {
00041     KisInputDevice inputDevice(NextInputDeviceID);
00042     NextInputDeviceID++;
00043     InputDevices.append(inputDevice);
00044 
00045     return inputDevice;
00046 }
00047 
00048 KisInputDevice KisInputDevice::allocateInputDevice()
00049 {
00050     allocateDefaultDevicesIfNeeded();
00051 
00052     return allocateNextDevice();
00053 }
00054 
00055 void KisInputDevice::allocateDefaultDevicesIfNeeded()
00056 {
00057     if (NextInputDeviceID == FIRST_INPUT_DEVICE_ID) {
00058         Mouse = allocateNextDevice();
00059         Stylus = allocateNextDevice();
00060         Eraser = allocateNextDevice();
00061         Puck = allocateNextDevice();
00062     }
00063 }
00064 
00065 QValueVector<KisInputDevice> KisInputDevice::inputDevices()
00066 {
00067     allocateDefaultDevicesIfNeeded();
00068 
00069     return InputDevices;
00070 }
00071 
00072 KisInputDevice KisInputDevice::mouse()
00073 {
00074     allocateDefaultDevicesIfNeeded();
00075     return Mouse;
00076 }
00077 
00078 KisInputDevice KisInputDevice::stylus()
00079 {
00080     allocateDefaultDevicesIfNeeded();
00081     return Stylus;
00082 }
00083 
00084 KisInputDevice KisInputDevice::eraser()
00085 {
00086     allocateDefaultDevicesIfNeeded();
00087     return Eraser;
00088 }
00089 
00090 KisInputDevice KisInputDevice::puck()
00091 {
00092     allocateDefaultDevicesIfNeeded();
00093     return Puck;
00094 }
00095 
00096 KisInputDevice KisInputDevice::unknown()   
00097 {
00098     allocateDefaultDevicesIfNeeded();
00099     return Unknown;
00100 }
00101 
KDE Home | KDE Accessibility Home | Description of Access Keys