33#include "kis_global.h"
36#include "kis_input_device.h"
44#if defined(HAVE_XINPUTEXT)
45#define EXTENDED_X11_TABLET_SUPPORT
51#if defined(EXTENDED_X11_TABLET_SUPPORT)
52#include <X11/extensions/XInput.h>
59class KisButtonPressEvent;
60class KisButtonReleaseEvent;
61class KisDoubleClickEvent;
62class KisCanvasWidgetPainter;
64class KisCanvasWidget :
public TQObject {
70 virtual ~KisCanvasWidget();
75 void enableMoveEventCompressionHint(
bool enableMoveCompression) { m_enableMoveEventCompressionHint = enableMoveCompression; }
77 virtual KisCanvasWidgetPainter *createPainter() = 0;
79#ifdef EXTENDED_X11_TABLET_SUPPORT
80 static KisInputDevice findActiveInputDevice();
81 virtual void selectTabletDeviceEvents() = 0;
83 static void selectTabletDeviceEvents(TQWidget *widget);
87 static void initX11Support();
91 void sigGotPaintEvent(TQPaintEvent*);
92 void sigGotEnterEvent(TQEvent*);
93 void sigGotLeaveEvent(TQEvent*);
94 void sigGotMouseWheelEvent(TQWheelEvent*);
95 void sigGotKeyPressEvent(TQKeyEvent*);
96 void sigGotKeyReleaseEvent(TQKeyEvent*);
97 void sigGotDragEnterEvent(TQDragEnterEvent*);
98 void sigGotDropEvent(TQDropEvent*);
99 void sigGotMoveEvent(KisMoveEvent *);
100 void sigGotButtonPressEvent(KisButtonPressEvent *);
101 void sigGotButtonReleaseEvent(KisButtonReleaseEvent *);
102 void sigGotDoubleClickEvent(KisDoubleClickEvent *);
105 void widgetGotPaintEvent(TQPaintEvent *event);
106 void widgetGotMousePressEvent(TQMouseEvent *event);
107 void widgetGotMouseReleaseEvent(TQMouseEvent *event);
108 void widgetGotMouseDoubleClickEvent(TQMouseEvent *event);
109 void widgetGotMouseMoveEvent(TQMouseEvent *event);
110 void widgetGotTabletEvent(TQTabletEvent *event);
111 void widgetGotEnterEvent(TQEvent *event );
112 void widgetGotLeaveEvent(TQEvent *event);
113 void widgetGotWheelEvent(TQWheelEvent *event);
114 void widgetGotKeyPressEvent(TQKeyEvent *event);
115 void widgetGotKeyReleaseEvent(TQKeyEvent *event);
116 void widgetGotDragEnterEvent(TQDragEnterEvent *event);
117 void widgetGotDropEvent(TQDropEvent *event);
118 void moveEvent(KisMoveEvent *event);
119 void buttonPressEvent(KisButtonPressEvent *event);
120 void buttonReleaseEvent(KisButtonReleaseEvent *event);
121 void doubleClickEvent(KisDoubleClickEvent *event);
122 void translateTabletEvent(KisEvent *event);
126 bool m_enableMoveEventCompressionHint;
127 double m_lastPressure;
134 bool x11Event(XEvent *event, Display *x11Display, WId winId, TQPoint widgetOriginPos);
135 static TQt::ButtonState translateX11ButtonState(
int state);
136 static TQt::ButtonState translateX11Button(
unsigned int button);
138 static bool X11SupportInitialised;
141 static long X11AltMask;
142 static long X11MetaMask;
147#ifdef EXTENDED_X11_TABLET_SUPPORT
150 class X11TabletDevice
154 X11TabletDevice(
const XDeviceInfo *deviceInfo);
156 bool mightBeTabletDevice()
const {
return m_mightBeTabletDevice; }
158 XID id()
const {
return m_deviceId; }
159 XDevice *xDevice()
const {
return m_XDevice; }
160 TQString name()
const {
return m_name; }
162 KisInputDevice inputDevice()
const {
return m_inputDevice; }
163 void setInputDevice(KisInputDevice inputDevice) { m_inputDevice = inputDevice; }
165 void setEnabled(
bool enabled);
166 bool enabled()
const;
168 TQ_INT32 numAxes()
const;
170 void setXAxis(TQ_INT32 axis);
171 void setYAxis(TQ_INT32 axis);
172 void setPressureAxis(TQ_INT32 axis);
173 void setXTiltAxis(TQ_INT32 axis);
174 void setYTiltAxis(TQ_INT32 axis);
175 void setWheelAxis(TQ_INT32 axis);
176 void setToolIDAxis(TQ_INT32 axis);
177 void setSerialNumberAxis(TQ_INT32 axis);
179 static const TQ_INT32 NoAxis = -1;
180 static const TQ_INT32 DefaultAxis = -2;
182 TQ_INT32 xAxis()
const;
183 TQ_INT32 yAxis()
const;
184 TQ_INT32 pressureAxis()
const;
185 TQ_INT32 xTiltAxis()
const;
186 TQ_INT32 yTiltAxis()
const;
187 TQ_INT32 wheelAxis()
const;
188 TQ_INT32 toolIDAxis()
const;
189 TQ_INT32 serialNumberAxis()
const;
191 void readSettingsFromConfig();
192 void writeSettingsToConfig();
195 int buttonPressEvent()
const {
return m_buttonPressEvent; }
196 int buttonReleaseEvent()
const {
return m_buttonReleaseEvent; }
197 int motionNotifyEvent()
const {
return m_motionNotifyEvent; }
198 int proximityInEvent()
const {
return m_proximityInEvent; }
199 int proximityOutEvent()
const {
return m_proximityOutEvent; }
201 void enableEvents(TQWidget *widget)
const;
207 State(
const KisPoint& pos,
double pressure,
const KisVector2D& tilt,
double wheel,
208 TQ_UINT32 toolID, TQ_UINT32 serialNumber);
211 KisPoint pos()
const {
return m_pos; }
212 double pressure()
const {
return m_pressure; }
214 KisVector2D tilt()
const {
return m_tilt; }
215 double wheel()
const {
return m_wheel; }
217 TQ_UINT32 toolID()
const {
return m_toolID; }
218 TQ_UINT32 serialNumber()
const {
return m_serialNumber; }
226 TQ_UINT32 m_serialNumber;
229 State translateAxisData(
const int *axisData)
const;
232 double translateAxisValue(
int value,
const XAxisInfo& axisInfo)
const;
239 bool m_mightBeTabletDevice;
240 KisInputDevice m_inputDevice;
246 TQ_INT32 m_pressureAxis;
247 TQ_INT32 m_xTiltAxis;
248 TQ_INT32 m_yTiltAxis;
249 TQ_INT32 m_wheelAxis;
250 TQ_INT32 m_toolIDAxis;
251 TQ_INT32 m_serialNumberAxis;
253 TQValueVector<XAxisInfo> m_axisInfo;
255 int m_motionNotifyEvent;
256 int m_buttonPressEvent;
257 int m_buttonReleaseEvent;
258 int m_proximityInEvent;
259 int m_proximityOutEvent;
261 TQValueVector<XEventClass> m_eventClassList;
264 typedef std::map<XID, X11TabletDevice> X11XIDTabletDeviceMap;
265 static X11XIDTabletDeviceMap& tabletDeviceMap();
268 static int X11DeviceMotionNotifyEvent;
269 static int X11DeviceButtonPressEvent;
270 static int X11DeviceButtonReleaseEvent;
271 static int X11ProximityInEvent;
272 static int X11ProximityOutEvent;
274 static X11XIDTabletDeviceMap X11TabletDeviceMap;
281class KisCanvas :
public TQObject {
286 KisCanvas(TQWidget *parent,
const char *name);
287 virtual ~KisCanvas();
292 void enableMoveEventCompressionHint(
bool enableMoveCompression);
294 bool isOpenGLCanvas()
const;
299 bool cursorIsOverCanvas()
const;
305 void handleKeyEvent(TQEvent *e);
311 void update(
const TQRect& r);
312 void update(
int x,
int y,
int width,
int height);
314 void repaint(
bool erase);
315 void repaint(
int x,
int y,
int width,
int height,
bool erase =
true);
316 void repaint(
const TQRect& r,
bool erase =
true);
317 void repaint(
const TQRegion& r,
bool erase =
true);
319 void updateGeometry();
321#if defined(EXTENDED_X11_TABLET_SUPPORT)
322 void selectTabletDeviceEvents();
326 void sigGotPaintEvent(TQPaintEvent*);
327 void sigGotEnterEvent(TQEvent*);
328 void sigGotLeaveEvent(TQEvent*);
329 void sigGotMouseWheelEvent(TQWheelEvent*);
330 void sigGotKeyPressEvent(TQKeyEvent*);
331 void sigGotKeyReleaseEvent(TQKeyEvent*);
332 void sigGotDragEnterEvent(TQDragEnterEvent*);
333 void sigGotDropEvent(TQDropEvent*);
334 void sigGotMoveEvent(KisMoveEvent *);
335 void sigGotButtonPressEvent(KisButtonPressEvent *);
336 void sigGotButtonReleaseEvent(KisButtonReleaseEvent *);
337 void sigGotDoubleClickEvent(KisDoubleClickEvent *);
342 friend class KisView;
343 friend class KisCanvasPainter;
347 TQWidget *TQPaintDeviceWidget()
const;
349 TQGLWidget *OpenGLWidget()
const;
351 void createTQPaintDeviceCanvas();
353 void createOpenGLCanvas(TQGLWidget *sharedContextWidget);
357 void setGeometry(
int x,
int y,
int width,
int height);
359 void setUpdatesEnabled(
bool updatesEnabled);
360 bool isUpdatesEnabled()
const;
362 void setFocusPolicy(TQWidget::FocusPolicy focusPolicy);
364 const TQCursor& cursor()
const;
365 void setCursor(
const TQCursor& cursor);
367 KisCanvasWidgetPainter *createPainter();
368 KisCanvasWidget *canvasWidget()
const;
372 void createCanvasWidget(
bool useOpenGL, TQGLWidget *sharedContextWidget = 0);
374 void createCanvasWidget(
bool useOpenGL);
378 KisCanvasWidget *m_canvasWidget;
379 bool m_enableMoveEventCompressionHint;