diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-07-10 15:24:15 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-07-10 15:24:15 -0500 |
commit | bd0f3345a938b35ce6a12f6150373b0955b8dd12 (patch) | |
tree | 7a520322212d48ebcb9fbe1087e7fca28b76185c /examples/tablet | |
download | qt3-bd0f3345a938b35ce6a12f6150373b0955b8dd12.tar.gz qt3-bd0f3345a938b35ce6a12f6150373b0955b8dd12.zip |
Add Qt3 development HEAD version
Diffstat (limited to 'examples/tablet')
-rw-r--r-- | examples/tablet/canvas.cpp | 178 | ||||
-rw-r--r-- | examples/tablet/canvas.h | 65 | ||||
-rw-r--r-- | examples/tablet/main.cpp | 35 | ||||
-rw-r--r-- | examples/tablet/scribble.cpp | 134 | ||||
-rw-r--r-- | examples/tablet/scribble.h | 49 | ||||
-rw-r--r-- | examples/tablet/tablet.doc | 11 | ||||
-rw-r--r-- | examples/tablet/tablet.pro | 12 | ||||
-rw-r--r-- | examples/tablet/tabletstats.cpp | 194 | ||||
-rw-r--r-- | examples/tablet/tabletstats.h | 70 | ||||
-rw-r--r-- | examples/tablet/tabletstatsbase.ui | 298 |
10 files changed, 1046 insertions, 0 deletions
diff --git a/examples/tablet/canvas.cpp b/examples/tablet/canvas.cpp new file mode 100644 index 0000000..bb026ea --- /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 Qt. 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( QWidget *parent, const char *name, WFlags fl ) + : QWidget( parent, name, WStaticContents | fl ), + pen( Qt::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( QWidget::PaletteBase ); +#ifndef QT_NO_CURSOR + setCursor( Qt::crossCursor ); +#endif +} + +void Canvas::save( const QString &filename, const QString &format ) +{ + if ( !no_writing ) + buffer.save( filename, format.upper() ); +} + +void Canvas::clearScreen() +{ + buffer.fill( colorGroup().base() ); + repaint( FALSE ); +} + +void Canvas::mousePressEvent( QMouseEvent *e ) +{ + mousePressed = TRUE; + polyline[2] = polyline[1] = polyline[0] = e->pos(); +} + +void Canvas::mouseReleaseEvent( QMouseEvent * ) +{ + mousePressed = FALSE; +} + +void Canvas::mouseMoveEvent( QMouseEvent *e ) +{ + if ( mousePressed ) { + QPainter painter; + painter.begin( &buffer ); + painter.setPen( pen ); + polyline[2] = polyline[1]; + polyline[1] = polyline[0]; + polyline[0] = e->pos(); + painter.drawPolyline( polyline ); + painter.end(); + + QRect 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( QTabletEvent *e ) +{ + e->accept(); + // change the width based on range of pressure + if ( e->device() == QTabletEvent::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() == QTabletEvent::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 QEvent::TabletPress: + mousePressed = TRUE; + polyline[2] = polyline[1] = polyline[0] = e->pos(); + break; + case QEvent::TabletRelease: + mousePressed = FALSE; + break; + case QEvent::TabletMove: + if ( mousePressed ) { + QPainter painter; + painter.begin( &buffer ); + painter.setPen( pen ); + polyline[2] = polyline[1]; + polyline[1] = polyline[0]; + polyline[0] = e->pos(); + painter.drawPolyline( polyline ); + painter.end(); + + QRect 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( QResizeEvent *e ) +{ + QWidget::resizeEvent( e ); + + int w = width() > buffer.width() ? + width() : buffer.width(); + int h = height() > buffer.height() ? + height() : buffer.height(); + + QPixmap tmp( buffer ); + buffer.resize( w, h ); + buffer.fill( colorGroup().base() ); + bitBlt( &buffer, 0, 0, &tmp, 0, 0, tmp.width(), tmp.height() ); +} + +void Canvas::paintEvent( QPaintEvent *e ) +{ + QWidget::paintEvent( e ); + + QMemArray<QRect> rects = e->region().rects(); + for ( uint i = 0; i < rects.count(); i++ ) { + QRect 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 0000000..2f3b502 --- /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 Qt. 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 QWidget +{ + Q_OBJECT + +public: + Canvas( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); + virtual ~Canvas() {}; + + void setPenColor( const QColor &c ) + { saveColor = c; + pen.setColor( saveColor ); } + + void setPenWidth( int w ) + { pen.setWidth( w ); } + + QColor penColor() + { return pen.color(); } + + int penWidth() + { return pen.width(); } + + void save( const QString &filename, const QString &format ); + + void clearScreen(); + +protected: + virtual void mousePressEvent( QMouseEvent *e ); + virtual void mouseReleaseEvent( QMouseEvent *e ); + virtual void mouseMoveEvent( QMouseEvent *e ); + virtual void resizeEvent( QResizeEvent *e ); + virtual void paintEvent( QPaintEvent *e ); + virtual void tabletEvent( QTabletEvent *e ); + + QPen pen; + QPointArray polyline; + + bool mousePressed; + int oldPressure; + QColor saveColor; + + QPixmap buffer; + +}; + +#endif diff --git a/examples/tablet/main.cpp b/examples/tablet/main.cpp new file mode 100644 index 0000000..a80a109 --- /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 Qt. 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 ) +{ + QApplication a( argc, argv ); + QTabWidget 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 ( QApplication::desktop()->width() > 550 + && QApplication::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 0000000..48fd1ef --- /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 Qt. 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( QWidget *parent, const char *name ) + : QMainWindow( parent, name ) +{ + canvas = new Canvas( this ); + setCentralWidget( canvas ); + + QToolBar *tools = new QToolBar( this ); + + bSave = new QToolButton( QPixmap(), "Save", "Save as PNG image", this, SLOT( slotSave() ), tools ); + bSave->setText( "Save as..." ); + + tools->addSeparator(); + + bPColor = new QToolButton( QPixmap(), "Choose Pen Color", "Choose Pen Color", this, SLOT( slotColor() ), tools ); + bPColor->setText( "Choose Pen Color..." ); + + tools->addSeparator(); + + bPWidth = new QSpinBox( 1, 20, 1, tools ); + QToolTip::add( bPWidth, "Choose Pen Width" ); + connect( bPWidth, SIGNAL( valueChanged( int ) ), this, SLOT( slotWidth( int ) ) ); + bPWidth->setValue( 3 ); + + tools->addSeparator(); + + bClear = new QToolButton( QPixmap(), "Clear Screen", "Clear Screen", this, SLOT( slotClear() ), tools ); + bClear->setText( "Clear Screen" ); +} + +/* + +Scribble::Scribble( QWidget *parent, const char *name ) + : QMainWindow( parent, name ) +{ + canvas = new Canvas( this ); + setCentralWidget( canvas ); + + QToolBar *tools = new QToolBar( this ); + + bSave = new QPushButton( "Save as...", tools ); + + tools->addSeparator(); + + bPColor = new QPushButton( "Choose Pen Color...", tools ); + // bPColor->setText( "Choose Pen Color..." ); + + tools->addSeparator(); + + bPWidth = new QSpinBox( 1, 20, 1, tools ); + QToolTip::add( bPWidth, "Choose Pen Width" ); + connect( bPWidth, SIGNAL( valueChanged( int ) ), this, SLOT( slotWidth( int ) ) ); + bPWidth->setValue( 3 ); + + tools->addSeparator(); + + bClear = new QPushButton( "Clear Screen", tools ); + QObject::connect( bSave, SIGNAL( clicked() ), this, SLOT( slotSave() ) ); + QObject::connect( bPColor, SIGNAL( clicked() ), this, SLOT( slotColor() ) ); + QObject::connect( bClear, SIGNAL( clicked() ), this, SLOT( slotClear() ) ); + +} + + */ +void Scribble::slotSave() +{ + QPopupMenu *menu = new QPopupMenu( 0 ); + QIntDict<QString> formats; + formats.setAutoDelete( TRUE ); + + for ( unsigned int i = 0; i < QImageIO::outputFormats().count(); i++ ) { + QString str = QString( QImageIO::outputFormats().at( i ) ); + formats.insert( menu->insertItem( QString( "%1..." ).arg( str ) ), new QString( str ) ); + } + + menu->setMouseTracking( TRUE ); + int id = menu->exec( bSave->mapToGlobal( QPoint( 0, bSave->height() + 1 ) ) ); + + if ( id != -1 ) { + QString format = *formats[ id ]; + + QString filename = QFileDialog::getSaveFileName( QString::null, QString( "*.%1" ).arg( format.lower() ), this ); + if ( !filename.isEmpty() ) + canvas->save( filename, format ); + } + + delete menu; +} + +void Scribble::slotColor() +{ + QColor c = QColorDialog::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 0000000..3a40b64 --- /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 Qt. 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 QMouseEvent; +class QResizeEvent; +class QPaintEvent; +class QSpinBox; +class QToolButton; +class Canvas; + +class Scribble : public QMainWindow +{ + Q_OBJECT + +public: + Scribble( QWidget *parent = 0, const char *name = 0 ); + +protected: + Canvas* canvas; + + QSpinBox *bPWidth; + QToolButton *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 0000000..8ee77f8 --- /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 0000000..b7b32ea --- /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 0000000..a6e91fb --- /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 Qt. 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( QWidget *parent, const char *name ) + : QFrame( parent, name, WRepaintNoErase ) +{ +// QSizePolicy mySize( QSizePolicy::Minimum, QSizePolicy::Expanding ); +// setSizePolicy( mySize ); + setFrameStyle( QFrame::Box | QFrame::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(); + + + + QRect cr( 0 + frameWidth(), 0 + frameWidth(), realWidth, realHeight ); + QPixmap pix( cr.size() ); + pix.fill( this, cr.topLeft() ); + QPainter 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(); + + QPainter p2( this ); + p2.drawPixmap( cr.topLeft(), pix ); + p2.end(); +} + + +StatsCanvas::StatsCanvas( QWidget *parent, const char* name ) + : Canvas( parent, name, WRepaintNoErase ) +{ + QSizePolicy mySize( QSizePolicy::Expanding, QSizePolicy::Minimum ); + setSizePolicy( mySize ); +} + +StatsCanvas::~StatsCanvas() +{ +} + +void StatsCanvas::tabletEvent( QTabletEvent *e ) +{ + static QRect oldR( -1, -1, -1, -1); + QPainter p; + + e->accept(); + switch( e->type() ) { + case QEvent::TabletPress: + qDebug( "Tablet Press" ); + mousePressed = TRUE; + break; + case QEvent::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() ); + QRect 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( QMouseEvent *e ) +{ + qDebug( "Mouse Move" ); + // do nothing + QWidget::mouseMoveEvent( e ); +} + + +void StatsCanvas::mousePressEvent( QMouseEvent *e ) +{ + qDebug( "Mouse Press" ); + QWidget::mousePressEvent( e ); +} + +void StatsCanvas::mouseReleaseEvent( QMouseEvent *e ) +{ + qDebug( "Mouse Release" ); + QWidget::mouseReleaseEvent( e ); +} + +void StatsCanvas::paintEvent( QPaintEvent *e ) +{ + QPainter 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( QWidget *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() ); + + QObject::connect( statCan, SIGNAL(signalNewTilt(int, int)), + orient, SLOT(newOrient(int, int)) ); + QObject::connect( statCan, SIGNAL(signalNewTilt(int, int)), + this, SLOT(slotTiltChanged(int, int)) ); + QObject::connect( statCan, SIGNAL(signalNewDev(int)), + this, SLOT(slotDevChanged(int)) ); + QObject::connect( statCan, SIGNAL(signalNewLoc(int,int)), + this, SLOT( slotLocationChanged(int,int)) ); +} + +TabletStats::~TabletStats() +{ +} + +void TabletStats::slotDevChanged( int newDev ) +{ + if ( newDev == QTabletEvent::Stylus ) + lblDev->setText( tr("Stylus") ); + else if ( newDev == QTabletEvent::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 0000000..03b557c --- /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 Qt. 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 QLabel; + +class MyOrientation : public QFrame +{ + Q_OBJECT +public: + MyOrientation( QWidget *parent = 0, const char *name = 0 ); + virtual ~MyOrientation(); + +public slots: + void newOrient( int tiltX, int tiltY ); + +}; + +class StatsCanvas : public Canvas +{ + Q_OBJECT +public: + StatsCanvas( QWidget *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( QTabletEvent *e ); + void mouseMoveEvent( QMouseEvent *e ); + void paintEvent( QPaintEvent *e ); + void mousePressEvent( QMouseEvent *e ); + void mouseReleaseEvent( QMouseEvent *e ); + +private: + QRect r; +}; + +class TabletStats : public TabletStatsBase +{ + Q_OBJECT +public: + TabletStats( QWidget *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 0000000..34b44dc --- /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="QWidget"> + <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="QLayoutWidget"> + <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="QLayoutWidget"> + <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="QLabel"> + <property name="name"> + <cstring>TextLabel1</cstring> + </property> + <property name="text"> + <string>X Pos:</string> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>lblXPos</cstring> + </property> + <property name="text"> + <string>0</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget"> + <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="QLabel"> + <property name="name"> + <cstring>TextLabel3</cstring> + </property> + <property name="text"> + <string>Y Pos:</string> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>lblYPos</cstring> + </property> + <property name="text"> + <string>0</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget"> + <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="QLabel"> + <property name="name"> + <cstring>TextLabel5</cstring> + </property> + <property name="text"> + <string>Pressure:</string> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>lblPressure</cstring> + </property> + <property name="text"> + <string>0</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget"> + <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="QLabel"> + <property name="name"> + <cstring>TextLabel7</cstring> + </property> + <property name="text"> + <string>Device:</string> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>lblDev</cstring> + </property> + <property name="text"> + <string>0</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QLabel"> + <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="QLayoutWidget"> + <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="QLabel"> + <property name="name"> + <cstring>TextLabel10</cstring> + </property> + <property name="text"> + <string>X Tilt:</string> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>lblXTilt</cstring> + </property> + <property name="text"> + <string>000</string> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>TextLabel12</cstring> + </property> + <property name="text"> + <string>Y Tilt:</string> + </property> + </widget> + <widget class="QLabel"> + <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> |