From d796c9dd933ab96ec83b9a634feedd5d32e1ba3f Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 8 Nov 2011 12:31:36 -0600 Subject: Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731 --- examples/tablet/scribble.cpp | 134 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 examples/tablet/scribble.cpp (limited to 'examples/tablet/scribble.cpp') 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +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 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(); +} -- cgit v1.2.1