33#include "kis_global.h"
36#include "kis_input_device.h"
47#if defined(HAVE_XINPUTEXT) && !defined(Q_OS_IRIX)
48#define EXTENDED_X11_TABLET_SUPPORT
54#if defined(EXTENDED_X11_TABLET_SUPPORT)
55#include <X11/extensions/XInput.h>
62class KisButtonPressEvent;
63class KisButtonReleaseEvent;
64class KisDoubleClickEvent;
65class KisCanvasWidgetPainter;
67class KisCanvasWidget :
public TQObject {
73 virtual ~KisCanvasWidget();
78 void enableMoveEventCompressionHint(
bool enableMoveCompression) { m_enableMoveEventCompressionHint = enableMoveCompression; }
80 virtual KisCanvasWidgetPainter *createPainter() = 0;
82#ifdef EXTENDED_X11_TABLET_SUPPORT
83 static KisInputDevice findActiveInputDevice();
84 virtual void selectTabletDeviceEvents() = 0;
86 static void selectTabletDeviceEvents(TQWidget *widget);
90 static void initX11Support();
94 void sigGotPaintEvent(TQPaintEvent*);
95 void sigGotEnterEvent(TQEvent*);
96 void sigGotLeaveEvent(TQEvent*);
97 void sigGotMouseWheelEvent(TQWheelEvent*);
98 void sigGotKeyPressEvent(TQKeyEvent*);
99 void sigGotKeyReleaseEvent(TQKeyEvent*);
100 void sigGotDragEnterEvent(TQDragEnterEvent*);
101 void sigGotDropEvent(TQDropEvent*);
102 void sigGotMoveEvent(KisMoveEvent *);
103 void sigGotButtonPressEvent(KisButtonPressEvent *);
104 void sigGotButtonReleaseEvent(KisButtonReleaseEvent *);
105 void sigGotDoubleClickEvent(KisDoubleClickEvent *);
108 void widgetGotPaintEvent(TQPaintEvent *event);
109 void widgetGotMousePressEvent(TQMouseEvent *event);
110 void widgetGotMouseReleaseEvent(TQMouseEvent *event);
111 void widgetGotMouseDoubleClickEvent(TQMouseEvent *event);
112 void widgetGotMouseMoveEvent(TQMouseEvent *event);
113 void widgetGotTabletEvent(TQTabletEvent *event);
114 void widgetGotEnterEvent(TQEvent *event );
115 void widgetGotLeaveEvent(TQEvent *event);
116 void widgetGotWheelEvent(TQWheelEvent *event);
117 void widgetGotKeyPressEvent(TQKeyEvent *event);
118 void widgetGotKeyReleaseEvent(TQKeyEvent *event);
119 void widgetGotDragEnterEvent(TQDragEnterEvent *event);
120 void widgetGotDropEvent(TQDropEvent *event);
121 void moveEvent(KisMoveEvent *event);
122 void buttonPressEvent(KisButtonPressEvent *event);
123 void buttonReleaseEvent(KisButtonReleaseEvent *event);
124 void doubleClickEvent(KisDoubleClickEvent *event);
125 void translateTabletEvent(KisEvent *event);
129 bool m_enableMoveEventCompressionHint;
130 double m_lastPressure;
137 bool x11Event(XEvent *event, Display *x11Display, WId winId, TQPoint widgetOriginPos);
138 static TQt::ButtonState translateX11ButtonState(
int state);
139 static TQt::ButtonState translateX11Button(
unsigned int button);
141 static bool X11SupportInitialised;
144 static long X11AltMask;
145 static long X11MetaMask;
150#ifdef EXTENDED_X11_TABLET_SUPPORT
153 class X11TabletDevice
157 X11TabletDevice(
const XDeviceInfo *deviceInfo);
159 bool mightBeTabletDevice()
const {
return m_mightBeTabletDevice; }
161 XID id()
const {
return m_deviceId; }
162 XDevice *xDevice()
const {
return m_XDevice; }
163 TQString name()
const {
return m_name; }
165 KisInputDevice inputDevice()
const {
return m_inputDevice; }
166 void setInputDevice(KisInputDevice inputDevice) { m_inputDevice = inputDevice; }
168 void setEnabled(
bool enabled);
169 bool enabled()
const;
171 TQ_INT32 numAxes()
const;
173 void setXAxis(TQ_INT32 axis);
174 void setYAxis(TQ_INT32 axis);
175 void setPressureAxis(TQ_INT32 axis);
176 void setXTiltAxis(TQ_INT32 axis);
177 void setYTiltAxis(TQ_INT32 axis);
178 void setWheelAxis(TQ_INT32 axis);
179 void setToolIDAxis(TQ_INT32 axis);
180 void setSerialNumberAxis(TQ_INT32 axis);
182 static const TQ_INT32 NoAxis = -1;
183 static const TQ_INT32 DefaultAxis = -2;
185 TQ_INT32 xAxis()
const;
186 TQ_INT32 yAxis()
const;
187 TQ_INT32 pressureAxis()
const;
188 TQ_INT32 xTiltAxis()
const;
189 TQ_INT32 yTiltAxis()
const;
190 TQ_INT32 wheelAxis()
const;
191 TQ_INT32 toolIDAxis()
const;
192 TQ_INT32 serialNumberAxis()
const;
194 void readSettingsFromConfig();
195 void writeSettingsToConfig();
198 int buttonPressEvent()
const {
return m_buttonPressEvent; }
199 int buttonReleaseEvent()
const {
return m_buttonReleaseEvent; }
200 int motionNotifyEvent()
const {
return m_motionNotifyEvent; }
201 int proximityInEvent()
const {
return m_proximityInEvent; }
202 int proximityOutEvent()
const {
return m_proximityOutEvent; }
204 void enableEvents(TQWidget *widget)
const;
210 State(
const KisPoint& pos,
double pressure,
const KisVector2D& tilt,
double wheel,
211 TQ_UINT32 toolID, TQ_UINT32 serialNumber);
214 KisPoint pos()
const {
return m_pos; }
215 double pressure()
const {
return m_pressure; }
217 KisVector2D tilt()
const {
return m_tilt; }
218 double wheel()
const {
return m_wheel; }
220 TQ_UINT32 toolID()
const {
return m_toolID; }
221 TQ_UINT32 serialNumber()
const {
return m_serialNumber; }
229 TQ_UINT32 m_serialNumber;
232 State translateAxisData(
const int *axisData)
const;
235 double translateAxisValue(
int value,
const XAxisInfo& axisInfo)
const;
242 bool m_mightBeTabletDevice;
243 KisInputDevice m_inputDevice;
249 TQ_INT32 m_pressureAxis;
250 TQ_INT32 m_xTiltAxis;
251 TQ_INT32 m_yTiltAxis;
252 TQ_INT32 m_wheelAxis;
253 TQ_INT32 m_toolIDAxis;
254 TQ_INT32 m_serialNumberAxis;
256 TQValueVector<XAxisInfo> m_axisInfo;
258 int m_motionNotifyEvent;
259 int m_buttonPressEvent;
260 int m_buttonReleaseEvent;
261 int m_proximityInEvent;
262 int m_proximityOutEvent;
264 TQValueVector<XEventClass> m_eventClassList;
267 typedef std::map<XID, X11TabletDevice> X11XIDTabletDeviceMap;
268 static X11XIDTabletDeviceMap& tabletDeviceMap();
271 static int X11DeviceMotionNotifyEvent;
272 static int X11DeviceButtonPressEvent;
273 static int X11DeviceButtonReleaseEvent;
274 static int X11ProximityInEvent;
275 static int X11ProximityOutEvent;
277 static X11XIDTabletDeviceMap X11TabletDeviceMap;
284class KisCanvas :
public TQObject {
289 KisCanvas(TQWidget *parent,
const char *name);
290 virtual ~KisCanvas();
295 void enableMoveEventCompressionHint(
bool enableMoveCompression);
297 bool isOpenGLCanvas()
const;
302 bool cursorIsOverCanvas()
const;
308 void handleKeyEvent(TQEvent *e);
314 void update(
const TQRect& r);
315 void update(
int x,
int y,
int width,
int height);
317 void repaint(
bool erase);
318 void repaint(
int x,
int y,
int width,
int height,
bool erase =
true);
319 void repaint(
const TQRect& r,
bool erase =
true);
320 void repaint(
const TQRegion& r,
bool erase =
true);
322 void updateGeometry();
324#if defined(EXTENDED_X11_TABLET_SUPPORT)
325 void selectTabletDeviceEvents();
329 void sigGotPaintEvent(TQPaintEvent*);
330 void sigGotEnterEvent(TQEvent*);
331 void sigGotLeaveEvent(TQEvent*);
332 void sigGotMouseWheelEvent(TQWheelEvent*);
333 void sigGotKeyPressEvent(TQKeyEvent*);
334 void sigGotKeyReleaseEvent(TQKeyEvent*);
335 void sigGotDragEnterEvent(TQDragEnterEvent*);
336 void sigGotDropEvent(TQDropEvent*);
337 void sigGotMoveEvent(KisMoveEvent *);
338 void sigGotButtonPressEvent(KisButtonPressEvent *);
339 void sigGotButtonReleaseEvent(KisButtonReleaseEvent *);
340 void sigGotDoubleClickEvent(KisDoubleClickEvent *);
345 friend class KisView;
346 friend class KisCanvasPainter;
350 TQWidget *TQPaintDeviceWidget()
const;
352 TQGLWidget *OpenGLWidget()
const;
354 void createTQPaintDeviceCanvas();
356 void createOpenGLCanvas(TQGLWidget *sharedContextWidget);
360 void setGeometry(
int x,
int y,
int width,
int height);
362 void setUpdatesEnabled(
bool updatesEnabled);
363 bool isUpdatesEnabled()
const;
365 void setFocusPolicy(TQWidget::FocusPolicy focusPolicy);
367 const TQCursor& cursor()
const;
368 void setCursor(
const TQCursor& cursor);
370 KisCanvasWidgetPainter *createPainter();
371 KisCanvasWidget *canvasWidget()
const;
375 void createCanvasWidget(
bool useOpenGL, TQGLWidget *sharedContextWidget = 0);
377 void createCanvasWidget(
bool useOpenGL);
381 KisCanvasWidget *m_canvasWidget;
382 bool m_enableMoveEventCompressionHint;
A double-based point class that can return it's coordinates approximated to integers.