From ea318d1431c89e647598c510c4245c6571aa5f46 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Thu, 26 Jan 2012 23:32:43 -0600 Subject: Update to latest tqt3 automated conversion --- doc/html/qmag-example.html | 296 ++++++++++++++++++++++----------------------- 1 file changed, 148 insertions(+), 148 deletions(-) (limited to 'doc/html/qmag-example.html') diff --git a/doc/html/qmag-example.html b/doc/html/qmag-example.html index 2a6e5b034..c13c4c62b 100644 --- a/doc/html/qmag-example.html +++ b/doc/html/qmag-example.html @@ -52,24 +52,24 @@ magnified area as a .bmp file. ** *****************************************************************************/ -#include <qcombobox.h> -#include <qpushbutton.h> -#include <qpixmap.h> -#include <qimage.h> -#include <qlabel.h> -#include <qfiledialog.h> -#include <qregexp.h> +#include <ntqcombobox.h> +#include <ntqpushbutton.h> +#include <ntqpixmap.h> +#include <ntqimage.h> +#include <ntqlabel.h> +#include <ntqfiledialog.h> +#include <ntqregexp.h> -#include <qapplication.h> -#include <qpainter.h> -#include <qwmatrix.h> +#include <ntqapplication.h> +#include <ntqpainter.h> +#include <ntqwmatrix.h> -class MagWidget : public TQWidget +class MagWidget : public TQWidget { Q_OBJECT public: - MagWidget( TQWidget *parent=0, const char *name=0 ); + MagWidget( TQWidget *parent=0, const char *name=0 ); public slots: void setZoom( int ); @@ -90,21 +90,21 @@ private: void grabAround(TQPoint pos); void grab(); - TQComboBox *zoom; - TQComboBox *refresh; - TQPushButton *saveButton; - TQPushButton *multiSaveButton; - TQPushButton *quitButton; - TQPixmap pm; // pixmap, magnified - TQPixmap p; // pixmap - TQImage image; // image of pixmap (for RGB) - TQLabel *rgb; + TQComboBox *zoom; + TQComboBox *refresh; + TQPushButton *saveButton; + TQPushButton *multiSaveButton; + TQPushButton *quitButton; + TQPixmap pm; // pixmap, magnified + TQPixmap p; // pixmap + TQImage image; // image of pixmap (for RGB) + TQLabel *rgb; int yoffset; // pixels in addition to the actual picture int z; // magnification factor int r; // autorefresh rate (index into refreshrates) bool grabbing; // TRUE if qmag is currently grabbing int grabx, graby; - TQString multifn; // filename for multisave + TQString multifn; // filename for multisave }; @@ -123,8 +123,8 @@ static const int timer[] = { 0, 20, 250, 333, 500, 1000, 2000, 3000, 5000, 10000 }; -MagWidget::MagWidget( TQWidget *parent, const char *name ) - : TQWidget( parent, name) +MagWidget::MagWidget( TQWidget *parent, const char *name ) + : TQWidget( parent, name) { z = 1; // default zoom (100%) r = 0; // default refresh (none) @@ -132,51 +132,51 @@ static const int timer[] = { #ifdef COMPLEX_GUI int w=0, x=0, n; - zoom = new TQComboBox( FALSE, this ); - Q_CHECK_PTR(zoom); - zoom->insertStrList( zoomfactors, 9 ); - connect( zoom, SIGNAL(activated(int)), SLOT(setZoom(int)) ); + zoom = new TQComboBox( FALSE, this ); + Q_CHECK_PTR(zoom); + zoom->insertStrList( zoomfactors, 9 ); + connect( zoom, SIGNAL(activated(int)), SLOT(setZoom(int)) ); - refresh = new TQComboBox( FALSE, this ); - Q_CHECK_PTR(refresh); - refresh->insertStrList( refreshrates, 9 ); - connect( refresh, SIGNAL(activated(int)), SLOT(setRefresh(int)) ); + refresh = new TQComboBox( FALSE, this ); + Q_CHECK_PTR(refresh); + refresh->insertStrList( refreshrates, 9 ); + connect( refresh, SIGNAL(activated(int)), SLOT(setRefresh(int)) ); for( n=0; n<9; n++) { - int w2 = zoom->fontMetrics().width( zoomfactors[n] ); + int w2 = zoom->fontMetrics().width( zoomfactors[n] ); w = TQMAX(w2, w); } - zoom->setGeometry( 2, 2, w+30, 20 ); + zoom->setGeometry( 2, 2, w+30, 20 ); x = w+34; w = 0; for( n=0; n<9; n++) { - int w2 = refresh->fontMetrics().width( refreshrates[n] ); + int w2 = refresh->fontMetrics().width( refreshrates[n] ); w = TQMAX(w2, w); } - refresh->setGeometry( x, 2, w+30, 20 ); - - saveButton = new TQPushButton( this ); - Q_CHECK_PTR(saveButton); - connect( saveButton, SIGNAL(clicked()), this, SLOT(save()) ); - saveButton->setText( "Save" ); - saveButton->setGeometry( x+w+30+2, 2, - 10+saveButton->fontMetrics().width("Save"), 20 ); - - multiSaveButton = new TQPushButton( this ); - multiSaveButton->setToggleButton(TRUE); - Q_CHECK_PTR(multiSaveButton); - connect( multiSaveButton, SIGNAL(clicked()), this, SLOT(multiSave()) ); - multiSaveButton->setText( "MultiSave" ); - multiSaveButton->setGeometry( saveButton->geometry().right() + 2, 2, - 10+multiSaveButton->fontMetrics().width("MultiSave"), 20 ); - - quitButton = new TQPushButton( this ); - Q_CHECK_PTR(quitButton); - connect( quitButton, SIGNAL(clicked()), qApp, SLOT(quit()) ); - quitButton->setText( "Quit" ); - quitButton->setGeometry( multiSaveButton->geometry().right() + 2, 2, - 10+quitButton->fontMetrics().width("Quit"), 20 ); + refresh->setGeometry( x, 2, w+30, 20 ); + + saveButton = new TQPushButton( this ); + Q_CHECK_PTR(saveButton); + connect( saveButton, SIGNAL(clicked()), this, SLOT(save()) ); + saveButton->setText( "Save" ); + saveButton->setGeometry( x+w+30+2, 2, + 10+saveButton->fontMetrics().width("Save"), 20 ); + + multiSaveButton = new TQPushButton( this ); + multiSaveButton->setToggleButton(TRUE); + Q_CHECK_PTR(multiSaveButton); + connect( multiSaveButton, SIGNAL(clicked()), this, SLOT(multiSave()) ); + multiSaveButton->setText( "MultiSave" ); + multiSaveButton->setGeometry( saveButton->geometry().right() + 2, 2, + 10+multiSaveButton->fontMetrics().width("MultiSave"), 20 ); + + quitButton = new TQPushButton( this ); + Q_CHECK_PTR(quitButton); + connect( quitButton, SIGNAL(clicked()), qApp, SLOT(quit()) ); + quitButton->setText( "Quit" ); + quitButton->setGeometry( multiSaveButton->geometry().right() + 2, 2, + 10+quitButton->fontMetrics().width("Quit"), 20 ); #else zoom = 0; multiSaveButton = 0; @@ -185,29 +185,29 @@ static const int timer[] = { setRefresh(1); setZoom(5); - rgb = new TQLabel( this ); - Q_CHECK_PTR( rgb ); - rgb->setText( "" ); - rgb->setAlignment( AlignVCenter ); - rgb->resize( width(), rgb->fontMetrics().height() + 4 ); + rgb = new TQLabel( this ); + Q_CHECK_PTR( rgb ); + rgb->setText( "" ); + rgb->setAlignment( AlignVCenter ); + rgb->resize( width(), rgb->fontMetrics().height() + 4 ); #ifdef COMPLEX_GUI - yoffset = zoom->height() // top buttons + yoffset = zoom->height() // top buttons + 4 // space around top buttons - + rgb->height(); // color-value text height - setMinimumSize( quitButton->pos().x(), yoffset+20 ); - resize( quitButton->geometry().topRight().x() + 2, yoffset+60 ); + + rgb->height(); // color-value text height + setMinimumSize( quitButton->pos().x(), yoffset+20 ); + resize( quitButton->geometry().topRight().x() + 2, yoffset+60 ); #else yoffset = 0; - resize(350,350); + resize(350,350); #endif grabx = graby = -1; grabbing = FALSE; - setMouseTracking( TRUE ); // and do let me know what pixel I'm at, eh? + setMouseTracking( TRUE ); // and do let me know what pixel I'm at, eh? - grabAround( TQPoint(grabx=qApp->desktop()->width()/2, graby=qApp->desktop()->height()/2) ); + grabAround( TQPoint(grabx=qApp->desktop()->width()/2, graby=qApp->desktop()->height()/2) ); } @@ -224,35 +224,35 @@ void MagWidget::setZoom( int index ) void MagWidget::setRefresh( int index ) { r = index; - killTimers(); + killTimers(); if (index && !grabbing) - startTimer( timer[r] ); + startTimer( timer[r] ); } void MagWidget::save() { - if ( !p.isNull() ) { - killTimers(); - TQString fn = TQFileDialog::getSaveFileName(); - if ( !fn.isEmpty() ) - p.save( fn, "BMP" ); + if ( !p.isNull() ) { + killTimers(); + TQString fn = TQFileDialog::getSaveFileName(); + if ( !fn.isEmpty() ) + p.save( fn, "BMP" ); if ( r ) - startTimer( timer[r] ); + startTimer( timer[r] ); } } void MagWidget::multiSave() { - if ( !p.isNull() ) { + if ( !p.isNull() ) { multifn = ""; // stops saving - multifn = TQFileDialog::getSaveFileName(); - if ( multifn.isEmpty() ) - multiSaveButton->setOn(FALSE); + multifn = TQFileDialog::getSaveFileName(); + if ( multifn.isEmpty() ) + multiSaveButton->setOn(FALSE); if ( !r ) - p.save( multifn, "BMP" ); + p.save( multifn, "BMP" ); } else { - multiSaveButton->setOn(FALSE); + multiSaveButton->setOn(FALSE); } } @@ -267,156 +267,156 @@ void MagWidget::grab() int x,y, w,h; - w = (width()+z-1)/z; - h = (height()+z-1-yoffset)/z; + w = (width()+z-1)/z; + h = (height()+z-1-yoffset)/z; if ( w<1 || h<1 ) return; // don't ask too much from the window system :) x = grabx-w/2; // find a suitable position to grab from y = graby-h/2; - if ( x + w > TQApplication::desktop()->width() ) - x = TQApplication::desktop()->width()-w; + if ( x + w > TQApplication::desktop()->width() ) + x = TQApplication::desktop()->width()-w; else if ( x < 0 ) x = 0; - if ( y + h > TQApplication::desktop()->height() ) - y = TQApplication::desktop()->height()-h; + if ( y + h > TQApplication::desktop()->height() ) + y = TQApplication::desktop()->height()-h; else if ( y < 0 ) y = 0; - p = TQPixmap::grabWindow( TQApplication::desktop()->winId(), x, y, w, h ); - image = p.convertToImage(); - TQWMatrix m; // after getting it, scale it - m.scale( (double)z, (double)z ); - pm = p.xForm( m ); + p = TQPixmap::grabWindow( TQApplication::desktop()->winId(), x, y, w, h ); + image = p.convertToImage(); + TQWMatrix m; // after getting it, scale it + m.scale( (double)z, (double)z ); + pm = p.xForm( m ); - if ( !multiSaveButton || !multiSaveButton->isOn() ) - repaint( FALSE ); // and finally repaint, flicker-free + if ( !multiSaveButton || !multiSaveButton->isOn() ) + repaint( FALSE ); // and finally repaint, flicker-free } -void MagWidget::paintEvent( TQPaintEvent * ) +void MagWidget::paintEvent( TQPaintEvent * ) { - if ( !pm.isNull() ) { - TQPainter paint( this ); - paint.drawPixmap( 0, zoom ? zoom->height()+4 : 0, pm, + if ( !pm.isNull() ) { + TQPainter paint( this ); + paint.drawPixmap( 0, zoom ? zoom->height()+4 : 0, pm, 0,0, width(), height()-yoffset ); } } -void MagWidget::mousePressEvent( TQMouseEvent *e ) +void MagWidget::mousePressEvent( TQMouseEvent *e ) { if ( !grabbing ) { // prepare to grab... grabbing = TRUE; - killTimers(); - grabMouse( crossCursor ); + killTimers(); + grabMouse( crossCursor ); grabx = -1; graby = -1; } else { // REALLY prepare to grab - grabx = mapToGlobal(e->pos()).x(); - graby = mapToGlobal(e->pos()).y(); + grabx = mapToGlobal(e->pos()).x(); + graby = mapToGlobal(e->pos()).y(); } } -void MagWidget::mouseReleaseEvent( TQMouseEvent * e ) +void MagWidget::mouseReleaseEvent( TQMouseEvent * e ) { if ( grabbing && grabx >= 0 && graby >= 0 ) { grabbing = FALSE; grabAround(e->pos()); - releaseMouse(); + releaseMouse(); } } void MagWidget::grabAround(TQPoint pos) { int rx, ry; - rx = mapToGlobal(pos).x(); - ry = mapToGlobal(pos).y(); + rx = mapToGlobal(pos).x(); + ry = mapToGlobal(pos).y(); int w = TQABS(rx-grabx); int h = TQABS(ry-graby); if ( w > 10 && h > 10 ) { int pz; pz = 1; - while ( w*pz*h*pz < width()*(height()-yoffset) && - w*pz < TQApplication::desktop()->width() && - h*pz < TQApplication::desktop()->height() ) + while ( w*pz*h*pz < width()*(height()-yoffset) && + w*pz < TQApplication::desktop()->width() && + h*pz < TQApplication::desktop()->height() ) pz++; - if ( (w*pz*h*pz - width()*(height()-yoffset)) > - (width()*(height()-yoffset) - w*(pz-1)*h*(pz-1)) ) + if ( (w*pz*h*pz - width()*(height()-yoffset)) > + (width()*(height()-yoffset) - w*(pz-1)*h*(pz-1)) ) pz--; if ( pz < 1 ) pz = 1; if ( pz > 8 ) pz = 8; if ( zoom ) - zoom->setCurrentItem( pz-1 ); + zoom->setCurrentItem( pz-1 ); z = pz; grabx = TQMIN(rx, grabx) + w/2; graby = TQMIN(ry, graby) + h/2; - resize( w*z, h*z+yoffset ); + resize( w*z, h*z+yoffset ); } grab(); if ( r ) - startTimer( timer[r] ); + startTimer( timer[r] ); } -void MagWidget::mouseMoveEvent( TQMouseEvent *e ) +void MagWidget::mouseMoveEvent( TQMouseEvent *e ) { - if ( grabbing || pm.isNull() || - e->pos().y() > height() - (zoom ? zoom->fontMetrics().height() - 4 : 0) || - e->pos().y() < (zoom ? zoom->height()+4 : 4) ) { - rgb->setText( "" ); + if ( grabbing || pm.isNull() || + e->pos().y() > height() - (zoom ? zoom->fontMetrics().height() - 4 : 0) || + e->pos().y() < (zoom ? zoom->height()+4 : 4) ) { + rgb->setText( "" ); } else { int x,y; x = e->pos().x() / z; - y = (e->pos().y() - ( zoom ? zoom->height() : 0 ) - 4) / z; - TQString pixelinfo; - if ( image.valid(x,y) ) + y = (e->pos().y() - ( zoom ? zoom->height() : 0 ) - 4) / z; + TQString pixelinfo; + if ( image.valid(x,y) ) { - TQRgb px = image.pixel(x,y); - pixelinfo.sprintf(" %3d,%3d,%3d #%02x%02x%02x", - qRed(px), qGreen(px), qBlue(px), - qRed(px), qGreen(px), qBlue(px)); + TQRgb px = image.pixel(x,y); + pixelinfo.sprintf(" %3d,%3d,%3d #%02x%02x%02x", + qRed(px), qGreen(px), qBlue(px), + qRed(px), qGreen(px), qBlue(px)); } - TQString label; - label.sprintf( "x=%d, y=%d %s", + TQString label; + label.sprintf( "x=%d, y=%d %s", x+grabx, y+graby, (const char*)pixelinfo ); - rgb->setText( label ); + rgb->setText( label ); } } -void MagWidget::focusOutEvent( TQFocusEvent * ) +void MagWidget::focusOutEvent( TQFocusEvent * ) { - rgb->setText( "" ); + rgb->setText( "" ); } -void MagWidget::timerEvent( TQTimerEvent * ) +void MagWidget::timerEvent( TQTimerEvent * ) { grab(); /* - if ( multiSaveButton->isOn() && !multifn.isEmpty() ) { - TQRegExp num("[0-9][0-9]*"); + if ( multiSaveButton->isOn() && !multifn.isEmpty() ) { + TQRegExp num("[0-9][0-9]*"); int start; int len; - if ((start=num.match(multifn,0,&len))>=0) - multifn.replace(num, - TQString().setNum(multifn.mid(start,len).toInt()+1) + if ((start=num.match(multifn,0,&len))>=0) + multifn.replace(num, + TQString().setNum(multifn.mid(start,len).toInt()+1) ); - p.save( multifn, "BMP" ); + p.save( multifn, "BMP" ); } */ } -void MagWidget::resizeEvent( TQResizeEvent * ) +void MagWidget::resizeEvent( TQResizeEvent * ) { - rgb->setGeometry( 0, height() - rgb->height(), width(), rgb->height() ); + rgb->setGeometry( 0, height() - rgb->height(), width(), rgb->height() ); grab(); } @@ -426,11 +426,11 @@ void MagWidget::grabAround(TQPoint pos) int main( int argc, char **argv ) { - TQApplication a( argc, argv ); + TQApplication a( argc, argv ); MagWidget m; - a.setMainWidget( &m ); - m.show(); - return a.exec(); + a.setMainWidget( &m ); + m.show(); + return a.exec(); } -- cgit v1.2.3