summaryrefslogtreecommitdiffstats
path: root/examples/tablet
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-11-08 12:31:36 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-11-08 12:31:36 -0600
commitd796c9dd933ab96ec83b9a634feedd5d32e1ba3f (patch)
tree6e3dcca4f77e20ec8966c666aac7c35bd4704053 /examples/tablet
downloadtqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.tar.gz
tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.zip
Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731
Diffstat (limited to 'examples/tablet')
-rw-r--r--examples/tablet/canvas.cpp178
-rw-r--r--examples/tablet/canvas.h65
-rw-r--r--examples/tablet/main.cpp35
-rw-r--r--examples/tablet/scribble.cpp134
-rw-r--r--examples/tablet/scribble.h49
-rw-r--r--examples/tablet/tablet.doc11
-rw-r--r--examples/tablet/tablet.pro12
-rw-r--r--examples/tablet/tabletstats.cpp194
-rw-r--r--examples/tablet/tabletstats.h70
-rw-r--r--examples/tablet/tabletstatsbase.ui298
10 files changed, 1046 insertions, 0 deletions
diff --git a/examples/tablet/canvas.cpp b/examples/tablet/canvas.cpp
new file mode 100644
index 000000000..6d5c0fe75
--- /dev/null
+++ b/examples/tablet/canvas.cpp
@@ -0,0 +1,178 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include "canvas.h"
+
+#include <qapplication.h>
+#include <qpainter.h>
+#include <qevent.h>
+#include <qrect.h>
+
+const bool no_writing = FALSE;
+
+Canvas::Canvas( TQWidget *parent, const char *name, WFlags fl )
+ : TQWidget( parent, name, WStaticContents | fl ),
+ pen( TQt::red, 3 ), polyline(3),
+ mousePressed( FALSE ), oldPressure( 0 ), saveColor( red ),
+ buffer( width(), height() )
+{
+
+ if ((qApp->argc() > 0) && !buffer.load(qApp->argv()[1]))
+ buffer.fill( colorGroup().base() );
+ setBackgroundMode( TQWidget::PaletteBase );
+#ifndef QT_NO_CURSOR
+ setCursor( TQt::crossCursor );
+#endif
+}
+
+void Canvas::save( const TQString &filename, const TQString &format )
+{
+ if ( !no_writing )
+ buffer.save( filename, format.upper() );
+}
+
+void Canvas::clearScreen()
+{
+ buffer.fill( colorGroup().base() );
+ repaint( FALSE );
+}
+
+void Canvas::mousePressEvent( TQMouseEvent *e )
+{
+ mousePressed = TRUE;
+ polyline[2] = polyline[1] = polyline[0] = e->pos();
+}
+
+void Canvas::mouseReleaseEvent( TQMouseEvent * )
+{
+ mousePressed = FALSE;
+}
+
+void Canvas::mouseMoveEvent( TQMouseEvent *e )
+{
+ if ( mousePressed ) {
+ TQPainter painter;
+ painter.begin( &buffer );
+ painter.setPen( pen );
+ polyline[2] = polyline[1];
+ polyline[1] = polyline[0];
+ polyline[0] = e->pos();
+ painter.drawPolyline( polyline );
+ painter.end();
+
+ TQRect r = polyline.boundingRect();
+ r = r.normalize();
+ r.setLeft( r.left() - penWidth() );
+ r.setTop( r.top() - penWidth() );
+ r.setRight( r.right() + penWidth() );
+ r.setBottom( r.bottom() + penWidth() );
+
+ bitBlt( this, r.x(), r.y(), &buffer, r.x(), r.y(), r.width(), r.height() );
+ }
+}
+
+void Canvas::tabletEvent( TQTabletEvent *e )
+{
+ e->accept();
+ // change the width based on range of pressure
+ if ( e->device() == TQTabletEvent::Stylus ) {
+ if ( e->pressure() >= 0 && e->pressure() <= 32 )
+ pen.setColor( saveColor.light(175) );
+ else if ( e->pressure() > 32 && e->pressure() <= 64 )
+ pen.setColor( saveColor.light(150) );
+ else if ( e->pressure() > 64 && e->pressure() <= 96 )
+ pen.setColor( saveColor.light(125) );
+ else if ( e->pressure() > 96 && e->pressure() <= 128 )
+ pen.setColor( saveColor );
+ else if ( e->pressure() > 128 && e->pressure() <= 160 )
+ pen.setColor( saveColor.dark(150) );
+ else if ( e->pressure() > 160 && e->pressure() <= 192 )
+ pen.setColor( saveColor.dark(200) );
+ else if ( e->pressure() > 192 && e->pressure() <= 224 )
+ pen.setColor( saveColor.dark(250) );
+ else // pressure > 224
+ pen.setColor( saveColor.dark(300) );
+ } else if ( e->device() == TQTabletEvent::Eraser
+ && pen.color() != backgroundColor() ) {
+ pen.setColor( backgroundColor() );
+ }
+
+ int xt = e->xTilt();
+ int yt = e->yTilt();
+ if ( ( xt > -15 && xt < 15 ) && ( yt > -15 && yt < 15 ) )
+ pen.setWidth( 3 );
+ else if ( ((xt < -15 && xt > -30) || (xt > 15 && xt < 30)) &&
+ ((yt < -15 && yt > -30) || (yt > 15 && yt < 30 )) )
+ pen.setWidth( 6 );
+ else if ( ((xt < -30 && xt > -45) || (xt > 30 && xt < 45)) &&
+ ((yt < -30 && yt > -45) || (yt > 30 && yt < 45)) )
+ pen.setWidth( 9 );
+ else if ( (xt < -45 || xt > 45 ) && ( yt < -45 || yt > 45 ) )
+ pen.setWidth( 12 );
+
+ switch ( e->type() ) {
+ case TQEvent::TabletPress:
+ mousePressed = TRUE;
+ polyline[2] = polyline[1] = polyline[0] = e->pos();
+ break;
+ case TQEvent::TabletRelease:
+ mousePressed = FALSE;
+ break;
+ case TQEvent::TabletMove:
+ if ( mousePressed ) {
+ TQPainter painter;
+ painter.begin( &buffer );
+ painter.setPen( pen );
+ polyline[2] = polyline[1];
+ polyline[1] = polyline[0];
+ polyline[0] = e->pos();
+ painter.drawPolyline( polyline );
+ painter.end();
+
+ TQRect r = polyline.boundingRect();
+ r = r.normalize();
+ r.setLeft( r.left() - penWidth() );
+ r.setTop( r.top() - penWidth() );
+ r.setRight( r.right() + penWidth() );
+ r.setBottom( r.bottom() + penWidth() );
+
+ bitBlt( this, r.x(), r.y(), &buffer, r.x(), r.y(), r.width(),
+ r.height() );
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void Canvas::resizeEvent( TQResizeEvent *e )
+{
+ TQWidget::resizeEvent( e );
+
+ int w = width() > buffer.width() ?
+ width() : buffer.width();
+ int h = height() > buffer.height() ?
+ height() : buffer.height();
+
+ TQPixmap tmp( buffer );
+ buffer.resize( w, h );
+ buffer.fill( colorGroup().base() );
+ bitBlt( &buffer, 0, 0, &tmp, 0, 0, tmp.width(), tmp.height() );
+}
+
+void Canvas::paintEvent( TQPaintEvent *e )
+{
+ TQWidget::paintEvent( e );
+
+ TQMemArray<TQRect> rects = e->region().rects();
+ for ( uint i = 0; i < rects.count(); i++ ) {
+ TQRect r = rects[(int)i];
+ bitBlt( this, r.x(), r.y(), &buffer, r.x(), r.y(), r.width(), r.height() );
+ }
+}
diff --git a/examples/tablet/canvas.h b/examples/tablet/canvas.h
new file mode 100644
index 000000000..24268b95d
--- /dev/null
+++ b/examples/tablet/canvas.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qpen.h>
+#include <qpixmap.h>
+#include <qpoint.h>
+#include <qpointarray.h>
+#include <qwidget.h>
+
+
+#ifndef _MY_CANVAS_
+#define _MY_CANVAS_
+
+
+class Canvas : public TQWidget
+{
+ Q_OBJECT
+
+public:
+ Canvas( TQWidget *parent = 0, const char *name = 0, WFlags fl = 0 );
+ virtual ~Canvas() {};
+
+ void setPenColor( const TQColor &c )
+ { saveColor = c;
+ pen.setColor( saveColor ); }
+
+ void setPenWidth( int w )
+ { pen.setWidth( w ); }
+
+ TQColor penColor()
+ { return pen.color(); }
+
+ int penWidth()
+ { return pen.width(); }
+
+ void save( const TQString &filename, const TQString &format );
+
+ void clearScreen();
+
+protected:
+ virtual void mousePressEvent( TQMouseEvent *e );
+ virtual void mouseReleaseEvent( TQMouseEvent *e );
+ virtual void mouseMoveEvent( TQMouseEvent *e );
+ virtual void resizeEvent( TQResizeEvent *e );
+ virtual void paintEvent( TQPaintEvent *e );
+ virtual void tabletEvent( TQTabletEvent *e );
+
+ TQPen pen;
+ TQPointArray polyline;
+
+ bool mousePressed;
+ int oldPressure;
+ TQColor saveColor;
+
+ TQPixmap buffer;
+
+};
+
+#endif
diff --git a/examples/tablet/main.cpp b/examples/tablet/main.cpp
new file mode 100644
index 000000000..7f97aa964
--- /dev/null
+++ b/examples/tablet/main.cpp
@@ -0,0 +1,35 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include "scribble.h"
+#include "tabletstats.h"
+#include <qapplication.h>
+#include <qtabwidget.h>
+
+
+int main( int argc, char **argv )
+{
+ TQApplication a( argc, argv );
+ TQTabWidget tab;
+ Scribble scribble(&tab, "scribble");
+ TabletStats tabStats( &tab, "tablet stats" );
+
+ scribble.setMinimumSize( 500, 350 );
+ tabStats.setMinimumSize( 500, 350 );
+ tab.addTab(&scribble, "Scribble" );
+ tab.addTab(&tabStats, "Tablet Stats" );
+
+ a.setMainWidget( &tab );
+ if ( TQApplication::desktop()->width() > 550
+ && TQApplication::desktop()->height() > 366 )
+ tab.show();
+ else
+ tab.showMaximized();
+ return a.exec();
+}
diff --git a/examples/tablet/scribble.cpp b/examples/tablet/scribble.cpp
new file mode 100644
index 000000000..356a4277b
--- /dev/null
+++ b/examples/tablet/scribble.cpp
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include "canvas.h"
+#include "scribble.h"
+
+#include <qapplication.h>
+#include <qevent.h>
+#include <qpainter.h>
+#include <qtoolbar.h>
+#include <qtoolbutton.h>
+#include <qspinbox.h>
+#include <qtooltip.h>
+#include <qrect.h>
+#include <qpoint.h>
+#include <qcolordialog.h>
+#include <qfiledialog.h>
+#include <qcursor.h>
+#include <qimage.h>
+#include <qstrlist.h>
+#include <qpopupmenu.h>
+#include <qintdict.h>
+
+
+
+Scribble::Scribble( TQWidget *parent, const char *name )
+ : TQMainWindow( parent, name )
+{
+ canvas = new Canvas( this );
+ setCentralWidget( canvas );
+
+ TQToolBar *tools = new TQToolBar( this );
+
+ bSave = new TQToolButton( TQPixmap(), "Save", "Save as PNG image", this, SLOT( slotSave() ), tools );
+ bSave->setText( "Save as..." );
+
+ tools->addSeparator();
+
+ bPColor = new TQToolButton( TQPixmap(), "Choose Pen Color", "Choose Pen Color", this, SLOT( slotColor() ), tools );
+ bPColor->setText( "Choose Pen Color..." );
+
+ tools->addSeparator();
+
+ bPWidth = new TQSpinBox( 1, 20, 1, tools );
+ TQToolTip::add( bPWidth, "Choose Pen Width" );
+ connect( bPWidth, SIGNAL( valueChanged( int ) ), this, SLOT( slotWidth( int ) ) );
+ bPWidth->setValue( 3 );
+
+ tools->addSeparator();
+
+ bClear = new TQToolButton( TQPixmap(), "Clear Screen", "Clear Screen", this, SLOT( slotClear() ), tools );
+ bClear->setText( "Clear Screen" );
+}
+
+/*
+
+Scribble::Scribble( TQWidget *parent, const char *name )
+ : TQMainWindow( parent, name )
+{
+ canvas = new Canvas( this );
+ setCentralWidget( canvas );
+
+ TQToolBar *tools = new TQToolBar( this );
+
+ bSave = new TQPushButton( "Save as...", tools );
+
+ tools->addSeparator();
+
+ bPColor = new TQPushButton( "Choose Pen Color...", tools );
+ // bPColor->setText( "Choose Pen Color..." );
+
+ tools->addSeparator();
+
+ bPWidth = new TQSpinBox( 1, 20, 1, tools );
+ TQToolTip::add( bPWidth, "Choose Pen Width" );
+ connect( bPWidth, SIGNAL( valueChanged( int ) ), this, SLOT( slotWidth( int ) ) );
+ bPWidth->setValue( 3 );
+
+ tools->addSeparator();
+
+ bClear = new TQPushButton( "Clear Screen", tools );
+ TQObject::connect( bSave, SIGNAL( clicked() ), this, SLOT( slotSave() ) );
+ TQObject::connect( bPColor, SIGNAL( clicked() ), this, SLOT( slotColor() ) );
+ TQObject::connect( bClear, SIGNAL( clicked() ), this, SLOT( slotClear() ) );
+
+}
+
+ */
+void Scribble::slotSave()
+{
+ TQPopupMenu *menu = new TQPopupMenu( 0 );
+ TQIntDict<TQString> formats;
+ formats.setAutoDelete( TRUE );
+
+ for ( unsigned int i = 0; i < TQImageIO::outputFormats().count(); i++ ) {
+ TQString str = TQString( TQImageIO::outputFormats().at( i ) );
+ formats.insert( menu->insertItem( TQString( "%1..." ).arg( str ) ), new TQString( str ) );
+ }
+
+ menu->setMouseTracking( TRUE );
+ int id = menu->exec( bSave->mapToGlobal( TQPoint( 0, bSave->height() + 1 ) ) );
+
+ if ( id != -1 ) {
+ TQString format = *formats[ id ];
+
+ TQString filename = TQFileDialog::getSaveFileName( TQString::null, TQString( "*.%1" ).arg( format.lower() ), this );
+ if ( !filename.isEmpty() )
+ canvas->save( filename, format );
+ }
+
+ delete menu;
+}
+
+void Scribble::slotColor()
+{
+ TQColor c = TQColorDialog::getColor( canvas->penColor(), this );
+ canvas->setPenColor( c );
+}
+
+void Scribble::slotWidth( int w )
+{
+ canvas->setPenWidth( w );
+}
+
+void Scribble::slotClear()
+{
+ canvas->clearScreen();
+}
diff --git a/examples/tablet/scribble.h b/examples/tablet/scribble.h
new file mode 100644
index 000000000..de5749bed
--- /dev/null
+++ b/examples/tablet/scribble.h
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#ifndef SCRIBBLE_H
+#define SCRIBBLE_H
+
+#include <qmainwindow.h>
+#include <qpen.h>
+#include <qpoint.h>
+#include <qpixmap.h>
+#include <qwidget.h>
+#include <qstring.h>
+#include <qpointarray.h>
+
+class TQMouseEvent;
+class TQResizeEvent;
+class TQPaintEvent;
+class TQSpinBox;
+class TQToolButton;
+class Canvas;
+
+class Scribble : public TQMainWindow
+{
+ Q_OBJECT
+
+public:
+ Scribble( TQWidget *parent = 0, const char *name = 0 );
+
+protected:
+ Canvas* canvas;
+
+ TQSpinBox *bPWidth;
+ TQToolButton *bPColor, *bSave, *bClear;
+
+protected slots:
+ void slotSave();
+ void slotColor();
+ void slotWidth( int );
+ void slotClear();
+
+};
+
+#endif
diff --git a/examples/tablet/tablet.doc b/examples/tablet/tablet.doc
new file mode 100644
index 000000000..8ee77f8fc
--- /dev/null
+++ b/examples/tablet/tablet.doc
@@ -0,0 +1,11 @@
+/*! \page tablet-example.html
+
+ \ingroup examples
+ \title Tablet Example
+
+ This example shows how to interact with a tablet device.
+
+ See \c{$QTDIR/examples/tablet} for the source code.
+*/
+
+
diff --git a/examples/tablet/tablet.pro b/examples/tablet/tablet.pro
new file mode 100644
index 000000000..b7b32eaba
--- /dev/null
+++ b/examples/tablet/tablet.pro
@@ -0,0 +1,12 @@
+##############################################################
+# Automatically generated by qmake Thu Jul 26 13:46:03 2001
+##############################################################
+TEMPLATE = app
+TARGET = tablet
+
+REQUIRES = tablet
+
+# Input
+HEADERS += canvas.h scribble.h tabletstats.h
+INTERFACES += tabletstatsbase.ui
+SOURCES += canvas.cpp main.cpp scribble.cpp tabletstats.cpp
diff --git a/examples/tablet/tabletstats.cpp b/examples/tablet/tabletstats.cpp
new file mode 100644
index 000000000..ac3617e0f
--- /dev/null
+++ b/examples/tablet/tabletstats.cpp
@@ -0,0 +1,194 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qpainter.h>
+#include <math.h>
+
+#include "tabletstats.h"
+
+MyOrientation::MyOrientation( TQWidget *parent, const char *name )
+ : TQFrame( parent, name, WRepaintNoErase )
+{
+// TQSizePolicy mySize( TQSizePolicy::Minimum, TQSizePolicy::Expanding );
+// setSizePolicy( mySize );
+ setFrameStyle( TQFrame::Box | TQFrame::Sunken );
+}
+
+MyOrientation::~MyOrientation()
+{
+}
+
+void MyOrientation::newOrient( int tiltX, int tiltY )
+{
+ double PI = 3.14159265359;
+ int realWidth,
+ realHeight,
+ hypot, // a faux hypoteneus, to mess with calculations
+ shaX,
+ shaY;
+ static int oldX = 0,
+ oldY = 0;
+ realWidth = width() - 2 * frameWidth();
+ realHeight = height() - 2 * frameWidth();
+
+
+
+ TQRect cr( 0 + frameWidth(), 0 + frameWidth(), realWidth, realHeight );
+ TQPixmap pix( cr.size() );
+ pix.fill( this, cr.topLeft() );
+ TQPainter p( &pix );
+
+ if ( realWidth > realHeight )
+ hypot = realHeight / 2;
+ else
+ hypot = realWidth / 2;
+
+ // create a shadow...
+ shaX = int(hypot * sin( tiltX * (PI / 180) ));
+ shaY = int(hypot * sin( tiltY * (PI / 180) ));
+
+ p.translate( realWidth / 2, realHeight / 2 );
+ p.setPen( backgroundColor() );
+ p.drawLine( 0, 0, oldX, oldY );
+ p.setPen( foregroundColor() );
+ p.drawLine( 0, 0,shaX, shaY );
+ oldX = shaX;
+ oldY = shaY;
+ p.end();
+
+ TQPainter p2( this );
+ p2.drawPixmap( cr.topLeft(), pix );
+ p2.end();
+}
+
+
+StatsCanvas::StatsCanvas( TQWidget *parent, const char* name )
+ : Canvas( parent, name, WRepaintNoErase )
+{
+ TQSizePolicy mySize( TQSizePolicy::Expanding, TQSizePolicy::Minimum );
+ setSizePolicy( mySize );
+}
+
+StatsCanvas::~StatsCanvas()
+{
+}
+
+void StatsCanvas::tabletEvent( TQTabletEvent *e )
+{
+ static TQRect oldR( -1, -1, -1, -1);
+ TQPainter p;
+
+ e->accept();
+ switch( e->type() ) {
+ case TQEvent::TabletPress:
+ qDebug( "Tablet Press" );
+ mousePressed = TRUE;
+ break;
+ case TQEvent::TabletRelease:
+ qDebug( "Tablet Release" );
+ mousePressed = FALSE;
+ clearScreen();
+ break;
+ default:
+ break;
+ }
+
+ r.setRect( e->x() - e->pressure() / 2,
+ e->y() - e->pressure() / 2, e->pressure(), e->pressure() );
+ TQRect tmpR = r | oldR;
+ oldR = r;
+
+ update( tmpR );
+ emit signalNewTilt( e->xTilt(), e->yTilt() );
+ emit signalNewDev( e->device() );
+ emit signalNewLoc( e->x(), e->y() );
+ emit signalNewPressure( e->pressure() );
+}
+
+void StatsCanvas::mouseMoveEvent( TQMouseEvent *e )
+{
+ qDebug( "Mouse Move" );
+ // do nothing
+ TQWidget::mouseMoveEvent( e );
+}
+
+
+void StatsCanvas::mousePressEvent( TQMouseEvent *e )
+{
+ qDebug( "Mouse Press" );
+ TQWidget::mousePressEvent( e );
+}
+
+void StatsCanvas::mouseReleaseEvent( TQMouseEvent *e )
+{
+ qDebug( "Mouse Release" );
+ TQWidget::mouseReleaseEvent( e );
+}
+
+void StatsCanvas::paintEvent( TQPaintEvent *e )
+{
+ TQPainter p;
+ p.begin( &buffer );
+ p.fillRect( e->rect(), colorGroup().base() );
+
+ // draw a circle if we have the tablet down
+ if ( mousePressed ) {
+ p.setBrush( red );
+ p.drawEllipse( r );
+ }
+ bitBlt( this, e->rect().x(), e->rect().y(), &buffer, e->rect().x(),
+ e->rect().y(), e->rect().width(), e->rect().height() );
+ p.end();
+}
+
+TabletStats::TabletStats( TQWidget *parent, const char *name )
+ : TabletStatsBase( parent, name )
+{
+ lblXPos->setMinimumSize( lblXPos->sizeHint() );
+ lblYPos->setMinimumSize( lblYPos->sizeHint() );
+ lblPressure->setMinimumSize( lblPressure->sizeHint() );
+ lblDev->setMinimumSize( lblDev->sizeHint() );
+ lblXTilt->setMinimumSize( lblXTilt->sizeHint() );
+ lblYTilt->setMinimumSize( lblYTilt->sizeHint() );
+
+ TQObject::connect( statCan, SIGNAL(signalNewTilt(int, int)),
+ orient, SLOT(newOrient(int, int)) );
+ TQObject::connect( statCan, SIGNAL(signalNewTilt(int, int)),
+ this, SLOT(slotTiltChanged(int, int)) );
+ TQObject::connect( statCan, SIGNAL(signalNewDev(int)),
+ this, SLOT(slotDevChanged(int)) );
+ TQObject::connect( statCan, SIGNAL(signalNewLoc(int,int)),
+ this, SLOT( slotLocationChanged(int,int)) );
+}
+
+TabletStats::~TabletStats()
+{
+}
+
+void TabletStats::slotDevChanged( int newDev )
+{
+ if ( newDev == TQTabletEvent::Stylus )
+ lblDev->setText( tr("Stylus") );
+ else if ( newDev == TQTabletEvent::Eraser )
+ lblDev->setText( tr("Eraser") );
+}
+
+void TabletStats::slotLocationChanged( int newX, int newY )
+{
+ lblXPos->setNum( newX );
+ lblYPos->setNum( newY );
+}
+
+void TabletStats::slotTiltChanged( int newTiltX, int newTiltY )
+{
+ lblXTilt->setNum( newTiltX );
+ lblYTilt->setNum( newTiltY );
+}
diff --git a/examples/tablet/tabletstats.h b/examples/tablet/tabletstats.h
new file mode 100644
index 000000000..fca8960fa
--- /dev/null
+++ b/examples/tablet/tabletstats.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#ifndef _TABLET_STATS_
+#define _TABLET_STATS_
+
+#include <qwidget.h>
+#include <qframe.h>
+#include "canvas.h"
+#include "tabletstatsbase.h"
+
+class TQLabel;
+
+class MyOrientation : public TQFrame
+{
+ Q_OBJECT
+public:
+ MyOrientation( TQWidget *parent = 0, const char *name = 0 );
+ virtual ~MyOrientation();
+
+public slots:
+ void newOrient( int tiltX, int tiltY );
+
+};
+
+class StatsCanvas : public Canvas
+{
+ Q_OBJECT
+public:
+ StatsCanvas( TQWidget *parent = 0, const char* name = 0 );
+ ~StatsCanvas();
+signals:
+ void signalNewPressure( int );
+ void signalNewTilt( int, int );
+ void signalNewDev( int );
+ void signalNewLoc( int, int );
+
+protected:
+ void tabletEvent( TQTabletEvent *e );
+ void mouseMoveEvent( TQMouseEvent *e );
+ void paintEvent( TQPaintEvent *e );
+ void mousePressEvent( TQMouseEvent *e );
+ void mouseReleaseEvent( TQMouseEvent *e );
+
+private:
+ TQRect r;
+};
+
+class TabletStats : public TabletStatsBase
+{
+ Q_OBJECT
+public:
+ TabletStats( TQWidget *parent, const char* name );
+ ~TabletStats();
+
+private slots:
+ void slotTiltChanged( int newTiltX, int newTiltY );
+ void slotDevChanged( int newDev );
+ void slotLocationChanged( int newX, int newY );
+
+protected:
+};
+
+#endif
diff --git a/examples/tablet/tabletstatsbase.ui b/examples/tablet/tabletstatsbase.ui
new file mode 100644
index 000000000..5c2c16640
--- /dev/null
+++ b/examples/tablet/tabletstatsbase.ui
@@ -0,0 +1,298 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>TabletStatsBase</class>
+<layoutdefaults spacing="6" margin="11"/>
+<widget class="TQWidget">
+ <property name="name">
+ <cstring>TabletStatsBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>657</width>
+ <height>527</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Form1</string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>Layout7</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>Layout5</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>X Pos:</string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>lblXPos</cstring>
+ </property>
+ <property name="text">
+ <string>0</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>Layout4</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>TextLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>Y Pos:</string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>lblYPos</cstring>
+ </property>
+ <property name="text">
+ <string>0</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>Layout3</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>TextLabel5</cstring>
+ </property>
+ <property name="text">
+ <string>Pressure:</string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>lblPressure</cstring>
+ </property>
+ <property name="text">
+ <string>0</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>Layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>TextLabel7</cstring>
+ </property>
+ <property name="text">
+ <string>Device:</string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>lblDev</cstring>
+ </property>
+ <property name="text">
+ <string>0</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>TextLabel9</cstring>
+ </property>
+ <property name="text">
+ <string>Tilt Information</string>
+ </property>
+ <property name="alignment">
+ <set>AlignAuto|AlignCenter</set>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>Layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>TextLabel10</cstring>
+ </property>
+ <property name="text">
+ <string>X Tilt:</string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>lblXTilt</cstring>
+ </property>
+ <property name="text">
+ <string>000</string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>TextLabel12</cstring>
+ </property>
+ <property name="text">
+ <string>Y Tilt:</string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>lblYTilt</cstring>
+ </property>
+ <property name="text">
+ <string>000</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="MyOrientation">
+ <property name="name">
+ <cstring>orient</cstring>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="StatsCanvas">
+ <property name="name">
+ <cstring>statCan</cstring>
+ </property>
+ </widget>
+ </hbox>
+</widget>
+<customwidgets>
+ <customwidget>
+ <class>MyOrientation</class>
+ <header location="local">tabletstats.h</header>
+ <sizehint>
+ <width>-1</width>
+ <height>-1</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>7</hordata>
+ <verdata>7</verdata>
+ </sizepolicy>
+ <pixmap>image0</pixmap>
+ <slot access="public" specifier="">slotNewOrient( int, int )</slot>
+ <slot access="public" specifier="">slotNewOrient( int, int )</slot>
+ <slot access="public" specifier="">slotNewOrient( int, int )</slot>
+ <slot access="public" specifier="">slotNewOrient( int, int )</slot>
+ </customwidget>
+ <customwidget>
+ <class>StatsCanvas</class>
+ <header location="local">tabletstats.h</header>
+ <sizehint>
+ <width>-1</width>
+ <height>-1</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>7</hordata>
+ <verdata>7</verdata>
+ </sizepolicy>
+ <pixmap>image1</pixmap>
+ <signal>signalNewPressure( int )</signal>
+ <signal>signalNewTilt( int, int )</signal>
+ <signal>signalNewDev( int )</signal>
+ <signal>signalNewLoc( int, int )</signal>
+ </customwidget>
+</customwidgets>
+<images>
+ <image name="image0">
+ <data format="XPM.GZ" length="45">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523250004143a55a6b2e0026630c4f</data>
+ </image>
+ <image name="image1">
+ <data format="XPM.GZ" length="4366">789c6dd7596fe3460c07f0f7fd14c1f26d51702dd9b22d147dc81de776eea4e80375f84a9cd3499c14fdeea5867f0e9a62e30ac6af43cd509c43de9f3f56ae8e0f567efcfcf6b290c5b45c2927f2bcf2a37a9dcf3ffefceb8fbfbf7d4fd395e6bf566725fdfedbb7efc3c54ab972f8705f37e09182d23c2d935670616eb7e032ba1f2c8ddb895bda7027cd1b1704f753bbff32385787761ab8db49889fc2a5c517e3688b7f70237e64eeb4103f89b6f8307e27f1785a8d0eedbc61ee74ac9d37e13e9e8fdcc8ffde8dfb2b18f9d269b0783bb1bb13fa970eece35fb8ad9d42ff599a65663e8f96f07c355ce17939dac6fb0c168fe71ccee1757716269f76e00ae3bf4687785ab811df327713f477e6467bbf7137f578b932c7f6398cfc64c38df84318f9ca96dbdaf934dac67f80f1fc5cbb31df9b6ed4ff39daea59997b09eeb7fcc4fb97118c78eebb91cf89bb6bf9df9b7b09c6aba3adbf0cce905fee467c0ae736bff2d4b8d7eea13ef402e7585f891bf7cfdca8e72eecf53888b6fd29e67e82f13ea3adff1337f65b096788ef455bfdd6828b5ede6b07afc215bc63ee27663987bd1ebde8d09f5cc0785e1ebaf1bc398cfd401f6eece7f03c7dcdbf57847881339b2fbe73a37d0fced1fe116df377067b3ddfcc79827caf61d4438edcd85f29ecf37beab6fee412f6e7b17cf579fba15ed481bd9e63b7b5f3ad394f10bf05fb7e9f9805f35d147066e71d8ddc187f1c6debe10e169cf7095cb7cc7d37de178f8df38ee7c3b3e8506f9ec019bc84bdde5d73cc671a6deba1070beab98cb6fa6fbb313f27708dfcc7e622b57c6923dace7fbbbfccf3bc13fc0257c8f7d98df6697419fabb300bd61f1dc219d6ff3a5c637db4cd458ae7a1687bde63379ea7057791ff73b43ddf0d2c989f81dbe285a3adfdc08df18730e697a2311eea53a27e1cce7be94862f5a002ceccb26a2e529c979bb0cfcf07ecfdcfdcd86f4bb38f276f6e9c0f5dd8ebb11f6df319f68368bdc5e6eb29dae66bcd5ca4c8770ad738ffdfdd589f73b38f4f68f7f165df8df558b9118ff14bd49b6ea22dfe18aeb1ff6a37ceb770be149d52701ebeb8edfd45b730eee7d48df3e63ddac6db71e37df5e8c6fbae6daebcde1d377eaf84f928aa52709e3ec035ced3cc1ce393681befd58df7d71adcc5ef917337ceb3eb689b9ff07ba5cc4ac1fcbec235f6ebc06df3cd8766bf5f166eaccf891bfbf718467df9c08de76b455bbe7b30d60b87f55056558dfecedc961f1d99eb14f5bb73e33c0feff34afbb7e7a347736cafa2edfec28df82bb88b7aecb9b15fc3fc54759d16b6fe6f616f5f8fb6faedba51cf1bd8f3bb8c0eed127e3fd45d374517557017f6f909f35beb5f9985f755380f46e1aff170d17c9858b8e052af5f7d571665f15cf388c73ce1a95e33befdcf35d6cf1dcff95eef7988f1053ff2133f6bdb23bff0825ff98ddf79c91ffcc9abbca6f1ebbcc1a5c5f3a6c66df136ef68ec8077798ff7f9800ff9888f79c8277cca677cce177cc914e245b378d69eaef89a6fb8c509a7dce60e67fadde51ef739e79c98886dbe463c25a1824aaaa8e62e8d684c139ad28c6e35be4b7734a77bbea007b6fa95daff95463fd2133dd30b2de8355c737aa3775aeae7833eb5ffd5d8ff8cd6689d53daa04d5ae8d8cdb5c543bdeb43a3b7b5971d8d1f205e347e97f6689f0e62df877444c7e18e916634a4133afdd2ff199d6befdef7055dd2155dd30db528d1fe979486fe3dff19559c501b7d7728a3aed634a11ef529d7e8a1e8f4ebf3c6fe799f8e859abe45a410ad141f4825b57aa4e32e65fc357f9968fb945e45ef945bb9d359c8b82d737d27dc37f973ef6bfef2a0f18ff224cff2220b79953779d7194bf45beb231ff2f925ff5b59d5b63559970ded719387b225dbb2d3cc70537f19c8ee97fcc7b227fb3a5b4f722087a8d1428ee438440fe5e47ff5bfe33539d53c97dc15963339970beac932cced50b319cba5e63f88fdcff954aee43acca55e7ae736226f349781b4249154dac8bf928eaeef73ad9dfe234fe772896b28039a484fa3fb92175c90ade7b05f3674fd9d86ab2e84ee8ae6af647de3ea22ae34ba2e463c8afb4b576a31b61d3a5cd02a3d84cf2a3c2826c5b4d9c3c5cce28b5931d3091f696547faff7ff5bdd9c468fffffcfeed5fd8c2e305</data>
+ </image>
+</images>
+<connections>
+ <connection language="C++">
+ <sender>statCan</sender>
+ <signal>signalNewPressure( int )</signal>
+ <receiver>lblPressure</receiver>
+ <slot>setNum(int)</slot>
+ </connection>
+</connections>
+</UI>