diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-12-05 15:55:57 -0600 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-12-05 15:55:57 -0600 |
commit | 9ba04742771370f59740e32e11c5f3a1e6a1b70a (patch) | |
tree | c81c34dae2b3b1ea73801bf18a960265dc4207f7 /qtjava/javalib/examples/showimg | |
parent | 1a96c45b22d01378202d9dc7ed9c47acd30f966e (diff) | |
download | tdebindings-9ba04742771370f59740e32e11c5f3a1e6a1b70a.tar.gz tdebindings-9ba04742771370f59740e32e11c5f3a1e6a1b70a.zip |
Initial TQt conversion
Diffstat (limited to 'qtjava/javalib/examples/showimg')
-rw-r--r-- | qtjava/javalib/examples/showimg/ImageIconProvider.java | 12 | ||||
-rw-r--r-- | qtjava/javalib/examples/showimg/ImageTextEditor.java | 56 | ||||
-rw-r--r-- | qtjava/javalib/examples/showimg/ImageViewer.java | 144 | ||||
-rw-r--r-- | qtjava/javalib/examples/showimg/Main.java | 14 | ||||
-rw-r--r-- | qtjava/javalib/examples/showimg/README | 2 |
5 files changed, 114 insertions, 114 deletions
diff --git a/qtjava/javalib/examples/showimg/ImageIconProvider.java b/qtjava/javalib/examples/showimg/ImageIconProvider.java index 5d3dba76..0a73a6b7 100644 --- a/qtjava/javalib/examples/showimg/ImageIconProvider.java +++ b/qtjava/javalib/examples/showimg/ImageIconProvider.java @@ -12,10 +12,10 @@ import org.kde.qt.*; import java.util.ArrayList; -class ImageIconProvider extends QFileIconProvider +class ImageIconProvider extends TQFileIconProvider { ArrayList fmts; - QPixmap imagepm; + TQPixmap imagepm; @@ -53,15 +53,15 @@ ImageIconProvider( ) this(null, null); } -ImageIconProvider( QWidget parent, String name ) +ImageIconProvider( TQWidget parent, String name ) { super( parent, name ); - imagepm = new QPixmap(image_xpm); - fmts = QImage.inputFormats(); + imagepm = new TQPixmap(image_xpm); + fmts = TQImage.inputFormats(); } -public QPixmap pixmap( QFileInfo fi ) +public TQPixmap pixmap( TQFileInfo fi ) { String ext = fi.extension().toUpperCase(); if ( fmts.indexOf(ext) != -1 ) { diff --git a/qtjava/javalib/examples/showimg/ImageTextEditor.java b/qtjava/javalib/examples/showimg/ImageTextEditor.java index 6c11c1a4..691bdf5b 100644 --- a/qtjava/javalib/examples/showimg/ImageTextEditor.java +++ b/qtjava/javalib/examples/showimg/ImageTextEditor.java @@ -11,48 +11,48 @@ import org.kde.qt.*; -class ImageTextEditor extends QDialog +class ImageTextEditor extends TQDialog { -private QImage image; -private QComboBox languages; -private QComboBox keys; -private QMultiLineEdit text; -private QLineEdit newlang; -private QLineEdit newkey; +private TQImage image; +private TQComboBox languages; +private TQComboBox keys; +private TQMultiLineEdit text; +private TQLineEdit newlang; +private TQLineEdit newkey; -ImageTextEditor( QImage i, QWidget parent ) +ImageTextEditor( TQImage i, TQWidget parent ) { this(i, parent, null, 0); } -ImageTextEditor( QImage i, QWidget parent, String name, int f ) +ImageTextEditor( TQImage i, TQWidget parent, String name, int f ) { super(parent,name,true,f); image = i; - QVBoxLayout vbox = new QVBoxLayout(this,8); + TQVBoxLayout vbox = new TQVBoxLayout(this,8); vbox.setAutoAdd(true); - QGrid controls = new QGrid(3,QGrid.Horizontal,this); + TQGrid controls = new TQGrid(3,TQGrid.Horizontal,this); controls.setSpacing(8); - QLabel l; - l=new QLabel("Language",controls); l.setAlignment(AlignCenter); - l=new QLabel("Key",controls); l.setAlignment(AlignCenter); - new QLabel("",controls); // dummy - languages = new QComboBox(controls); - keys = new QComboBox(controls); - QPushButton remove = new QPushButton("Remove",controls); - - newlang = new QLineEdit(controls); - newkey = new QLineEdit(controls); - QPushButton add = new QPushButton("Add",controls); - - text = new QMultiLineEdit(this); - - QHBox hbox = new QHBox(this); - QPushButton cancel = new QPushButton("Cancel",hbox); - QPushButton ok = new QPushButton("OK",hbox); + TQLabel l; + l=new TQLabel("Language",controls); l.setAlignment(AlignCenter); + l=new TQLabel("Key",controls); l.setAlignment(AlignCenter); + new TQLabel("",controls); // dummy + languages = new TQComboBox(controls); + keys = new TQComboBox(controls); + TQPushButton remove = new TQPushButton("Remove",controls); + + newlang = new TQLineEdit(controls); + newkey = new TQLineEdit(controls); + TQPushButton add = new TQPushButton("Add",controls); + + text = new TQMultiLineEdit(this); + + TQHBox hbox = new TQHBox(this); + TQPushButton cancel = new TQPushButton("Cancel",hbox); + TQPushButton ok = new TQPushButton("OK",hbox); connect(add,SIGNAL("clicked()"), this,SLOT("addText()")); diff --git a/qtjava/javalib/examples/showimg/ImageViewer.java b/qtjava/javalib/examples/showimg/ImageViewer.java index 0b419ea9..c902e413 100644 --- a/qtjava/javalib/examples/showimg/ImageViewer.java +++ b/qtjava/javalib/examples/showimg/ImageViewer.java @@ -11,24 +11,24 @@ import org.kde.qt.*; import java.util.*; -class ImageViewer extends QWidget +class ImageViewer extends TQWidget { private int conversion_flags; private int alloc_context; private String filename; -private QImage image = new QImage(); // the loaded image -private QPixmap pm = new QPixmap(); // the converted pixmap -private QPixmap pmScaled; // the scaled pixmap - -private QMenuBar menubar; -private QPopupMenu file; -private QPopupMenu saveimage; -private QPopupMenu savepixmap; -private QPopupMenu edit; -private QPopupMenu options; - -private QWidget helpmsg; -private QLabel status; +private TQImage image = new TQImage(); // the loaded image +private TQPixmap pm = new TQPixmap(); // the converted pixmap +private TQPixmap pmScaled; // the scaled pixmap + +private TQMenuBar menubar; +private TQPopupMenu file; +private TQPopupMenu saveimage; +private TQPopupMenu savepixmap; +private TQPopupMenu edit; +private TQPopupMenu options; + +private TQWidget helpmsg; +private TQLabel status; private int si, sp, ac, co, mo, fd, bd, // Menu item ids td, ta, ba, fa, au, ad, dd, ss, cc, t1, t8, t32; @@ -44,12 +44,12 @@ private static ImageViewer other = null; /* In the constructor, we just pass the standard parameters on to - QWidget. + TQWidget. The menu uses a single slot to simplify the process of adding more items to the options menu. */ -ImageViewer( QWidget parent, String name, int wFlags ) +ImageViewer( TQWidget parent, String name, int wFlags ) { super( parent, name, wFlags ); conversion_flags = PreferDither; @@ -61,12 +61,12 @@ ImageViewer( QWidget parent, String name, int wFlags ) clicky[0] = -1; alloc_context = 0; - menubar = new QMenuBar(this); - menubar.setSeparator( QMenuBar.InWindowsStyle ); + menubar = new TQMenuBar(this); + menubar.setSeparator( TQMenuBar.InWindowsStyle ); - ArrayList fmt = QImage.outputFormats(); - saveimage = new QPopupMenu( menubar ); - savepixmap = new QPopupMenu( menubar ); + ArrayList fmt = TQImage.outputFormats(); + saveimage = new TQPopupMenu( menubar ); + savepixmap = new TQPopupMenu( menubar ); Iterator it = fmt.iterator(); while (it.hasNext()) { String f = (String) it.next(); @@ -76,23 +76,23 @@ ImageViewer( QWidget parent, String name, int wFlags ) connect( saveimage, SIGNAL("activated(int)"), this, SLOT("saveImage(int)") ); connect( savepixmap, SIGNAL("activated(int)"), this, SLOT("savePixmap(int)") ); - file = new QPopupMenu( menubar ); + file = new TQPopupMenu( menubar ); menubar.insertItem( "&File", file ); - file.insertItem( "&New window", this, SLOT("newWindow()"), new QKeySequence(CTRL+Key_N) ); - file.insertItem( "&Open...", this, SLOT("openFile()"), new QKeySequence(CTRL+Key_O) ); + file.insertItem( "&New window", this, SLOT("newWindow()"), new TQKeySequence(CTRL+Key_N) ); + file.insertItem( "&Open...", this, SLOT("openFile()"), new TQKeySequence(CTRL+Key_O) ); si = file.insertItem( "Save image", saveimage ); sp = file.insertItem( "Save pixmap", savepixmap ); file.insertSeparator(); - file.insertItem( "E&xit", qApp(), SLOT("quit()"), new QKeySequence(CTRL+Key_Q) ); + file.insertItem( "E&xit", qApp(), SLOT("quit()"), new TQKeySequence(CTRL+Key_Q) ); - edit = new QPopupMenu( menubar ); + edit = new TQPopupMenu( menubar ); menubar.insertItem( "&Edit", edit ); - edit.insertItem("&Copy", this, SLOT("copy()"), new QKeySequence(CTRL+Key_C)); - edit.insertItem("&Paste", this, SLOT("paste()"), new QKeySequence(CTRL+Key_V)); + edit.insertItem("&Copy", this, SLOT("copy()"), new TQKeySequence(CTRL+Key_C)); + edit.insertItem("&Paste", this, SLOT("paste()"), new TQKeySequence(CTRL+Key_V)); edit.insertSeparator(); - edit.insertItem("&Horizontal flip", this, SLOT("hFlip()"), new QKeySequence(ALT+Key_H)); - edit.insertItem("&Vertical flip", this, SLOT("vFlip()"), new QKeySequence(ALT+Key_V)); - edit.insertItem("&Rotate 180", this, SLOT("rot180()"), new QKeySequence(ALT+Key_R)); + edit.insertItem("&Horizontal flip", this, SLOT("hFlip()"), new TQKeySequence(ALT+Key_H)); + edit.insertItem("&Vertical flip", this, SLOT("vFlip()"), new TQKeySequence(ALT+Key_V)); + edit.insertItem("&Rotate 180", this, SLOT("rot180()"), new TQKeySequence(ALT+Key_R)); edit.insertSeparator(); edit.insertItem("&Text...", this, SLOT("editText()")); edit.insertSeparator(); @@ -100,7 +100,7 @@ ImageViewer( QWidget parent, String name, int wFlags ) t8 = edit.insertItem( "Convert to &8 bit", this, SLOT("to8Bit()") ); t32 = edit.insertItem( "Convert to &32 bit", this, SLOT("to32Bit()") ); - options = new QPopupMenu( menubar ); + options = new TQPopupMenu( menubar ); menubar.insertItem( "&Options", options ); ac = options.insertItem( "AutoColor" ); co = options.insertItem( "ColorOnly" ); @@ -119,21 +119,21 @@ ImageViewer( QWidget parent, String name, int wFlags ) options.insertSeparator(); ss = options.insertItem( "Smooth scaling" ); cc = options.insertItem( "Use color context" ); - if ( QApplication.colorSpec() == QApplication.ManyColor ) + if ( TQApplication.colorSpec() == TQApplication.ManyColor ) options.setItemEnabled( cc, false ); options.setCheckable( true ); setMenuItemFlags(); menubar.insertSeparator(); - QPopupMenu help = new QPopupMenu( menubar ); + TQPopupMenu help = new TQPopupMenu( menubar ); menubar.insertItem( "&Help", help ); - help.insertItem( "Help!", this, SLOT("giveHelp()"), new QKeySequence(CTRL+Key_H) ); + help.insertItem( "Help!", this, SLOT("giveHelp()"), new TQKeySequence(CTRL+Key_H) ); connect( options, SIGNAL("activated(int)"), this, SLOT("doOption(int)") ); - status = new QLabel(this); - status.setFrameStyle( QFrame.WinPanel | QFrame.Sunken ); + status = new TQLabel(this); + status.setFrameStyle( TQFrame.WinPanel | TQFrame.Sunken ); status.setFixedHeight( fontMetrics().height() + 4 ); setMouseTracking( true ); @@ -142,7 +142,7 @@ ImageViewer( QWidget parent, String name, int wFlags ) void cleanUp() { if ( alloc_context != 0 ) - QColor.destroyAllocContext( alloc_context ); + TQColor.destroyAllocContext( alloc_context ); if ( other == this ) other = null; } @@ -218,10 +218,10 @@ void setMenuItemFlags() // Options boolean may_need_color_dithering = !valid_image - || image.depth() == 32 && QPixmap.defaultDepth() < 24; + || image.depth() == 32 && TQPixmap.defaultDepth() < 24; boolean may_need_dithering = may_need_color_dithering || image.depth() > 1 && options.isItemChecked(mo) - || image.depth() > 1 && QPixmap.defaultDepth() == 1; + || image.depth() > 1 && TQPixmap.defaultDepth() == 1; boolean has_alpha_mask = !valid_image || image.hasAlphaBuffer(); options.setItemEnabled( fd, may_need_dithering ); @@ -320,11 +320,11 @@ void updateStatus() void saveImage( int item ) { String fmt = saveimage.text(item); - String savefilename = QFileDialog.getSaveFileName("", "", + String savefilename = TQFileDialog.getSaveFileName("", "", this, filename); if ( !savefilename.equals("") ) if ( !image.save( savefilename, fmt ) ) - QMessageBox.warning( this, "Save failed", "Error saving file" ); + TQMessageBox.warning( this, "Save failed", "Error saving file" ); } /* @@ -333,11 +333,11 @@ void saveImage( int item ) void savePixmap( int item ) { String fmt = savepixmap.text(item); - String savefilename = QFileDialog.getSaveFileName("", + String savefilename = TQFileDialog.getSaveFileName("", "", this, filename); if ( !savefilename.equals("") ) if ( !pmScaled.save( savefilename, fmt ) ) - QMessageBox.warning( this, "Save failed", "Error saving file" ); + TQMessageBox.warning( this, "Save failed", "Error saving file" ); } @@ -353,7 +353,7 @@ void newWindow() */ void openFile() { - String newfilename = QFileDialog.getOpenFileName(); + String newfilename = TQFileDialog.getOpenFileName(); if ( !newfilename.equals("") ) { loadImage( newfilename ) ; repaint(); // show image in widget @@ -374,7 +374,7 @@ boolean loadImage( String fileName ) filename = fileName; boolean ok = false; if ( ! filename.equals("") ) { - QApplication.setOverrideCursor( waitCursor() ); // this might take time + TQApplication.setOverrideCursor( waitCursor() ); // this might take time ok = image.load(filename, null); pickx[0] = -1; clickx[0] = -1; @@ -399,7 +399,7 @@ boolean loadImage( String fileName ) pm.resize(0,0); // couldn't load image update(); } - QApplication.restoreOverrideCursor(); // restore original cursor + TQApplication.restoreOverrideCursor(); // restore original cursor } updateStatus(); setMenuItemFlags(); @@ -413,20 +413,20 @@ boolean reconvertImage() if ( image.isNull() ) return false; if ( alloc_context != 0 ) { - QColor.destroyAllocContext( alloc_context ); + TQColor.destroyAllocContext( alloc_context ); alloc_context = 0; } if ( useColorContext() ) { - alloc_context = QColor.enterAllocContext(); + alloc_context = TQColor.enterAllocContext(); // Clear the image to hide flickering palette - QPainter painter = new QPainter(this); + TQPainter painter = new TQPainter(this); painter.eraseRect(0, menubar.heightForWidth( width() ), width(), height()); } - QApplication.setOverrideCursor( waitCursor() ); // this might take time + TQApplication.setOverrideCursor( waitCursor() ); // this might take time if ( pm.convertFromImage(image, conversion_flags) ) { - pmScaled = new QPixmap(); + pmScaled = new TQPixmap(); scale(); resize( width(), height() ); success = true; // load successful @@ -435,10 +435,10 @@ boolean reconvertImage() } updateStatus(); setMenuItemFlags(); - QApplication.restoreOverrideCursor(); // restore original cursor + TQApplication.restoreOverrideCursor(); // restore original cursor if ( useColorContext() ) - QColor.leaveAllocContext(); + TQColor.leaveAllocContext(); return success; // true if loaded OK } @@ -464,7 +464,7 @@ void scale() if ( image.isNull() ) return; - QApplication.setOverrideCursor( waitCursor() ); // this might take time + TQApplication.setOverrideCursor( waitCursor() ); // this might take time if ( width() == pm.width() && h == pm.height() ) { // no need to scale if widget pmScaled = pm; // size equals pixmap size @@ -473,13 +473,13 @@ void scale() pmScaled.convertFromImage(image.smoothScale(width(), h), conversion_flags); } else { - QWMatrix m = new QWMatrix(); // transformation matrix + TQWMatrix m = new TQWMatrix(); // transformation matrix m.scale(((double)width())/pm.width(),// define scale factors ((double)h)/pm.height()); - pmScaled = (QPixmap) pm.xForm( m ); // create scaled pixmap + pmScaled = (TQPixmap) pm.xForm( m ); // create scaled pixmap } } - QApplication.restoreOverrideCursor(); // restore original cursor + TQApplication.restoreOverrideCursor(); // restore original cursor } /* @@ -487,7 +487,7 @@ void scale() scale() to fit the pixmap to the new widget size. */ -protected void resizeEvent( QResizeEvent e ) +protected void resizeEvent( TQResizeEvent e ) { status.setGeometry(0, height() - status.height(), width(), status.height()); @@ -505,7 +505,7 @@ protected void resizeEvent( QResizeEvent e ) erase(); } -protected boolean convertEvent( QMouseEvent e, int[] x, int[] y) +protected boolean convertEvent( TQMouseEvent e, int[] x, int[] y) { if ( pm.size().width() != 0 || pm.size().height() != 0 ) { int h = height() - menubar.heightForWidth( width() ) - status.height(); @@ -521,12 +521,12 @@ protected boolean convertEvent( QMouseEvent e, int[] x, int[] y) return false; } -protected void mousePressEvent( QMouseEvent e ) +protected void mousePressEvent( TQMouseEvent e ) { may_be_other = convertEvent(e, clickx, clicky); } -protected void mouseReleaseEvent( QMouseEvent e ) +protected void mouseReleaseEvent( TQMouseEvent e ) { if ( may_be_other ) other = this; @@ -535,7 +535,7 @@ protected void mouseReleaseEvent( QMouseEvent e ) /* Record the pixel position of interest. */ -protected void mouseMoveEvent( QMouseEvent e ) +protected void mouseMoveEvent( TQMouseEvent e ) { if (convertEvent(e,pickx,picky)) { updateStatus(); @@ -553,10 +553,10 @@ protected void mouseMoveEvent( QMouseEvent e ) an error message if no legal pixmap has been loaded. */ -protected void paintEvent( QPaintEvent e ) +protected void paintEvent( TQPaintEvent e ) { if ( pm.size().width() != 0 || pm.size().height() != 0 ) { // is an image loaded? - QPainter painter = new QPainter(this); + TQPainter painter = new TQPainter(this); painter.setClipRect(e.rect()); painter.drawPixmap(0, menubar.heightForWidth( width() ), pmScaled); } @@ -576,7 +576,7 @@ void giveHelp() + "</blockquote>" + "<p>Supported input formats:" + "<blockquote>"; - Iterator it = QImage.inputFormatList().iterator(); + Iterator it = TQImage.inputFormatList().iterator(); if (it.hasNext()) helptext += (String) it.next(); while (it.hasNext()) { @@ -584,8 +584,8 @@ void giveHelp() } helptext += "</blockquote>"; - helpmsg = new QMessageBox( "Help", helptext, - QMessageBox.Information, QMessageBox.Ok, 0, 0, null, null, false ); + helpmsg = new TQMessageBox( "Help", helptext, + TQMessageBox.Information, TQMessageBox.Ok, 0, 0, null, null, false ); } helpmsg.show(); helpmsg.raise(); @@ -608,7 +608,7 @@ void copyFrom(ImageViewer s) dy = picky[0]; sy -= sh-1; } - bitBlt( new QPixmap(image), dx, dy, new QPixmap(s.image), sx, sy, sw, sh ); + bitBlt( new TQPixmap(image), dx, dy, new TQPixmap(s.image), sx, sy, sw, sh ); reconvertImage(); repaint( image.hasAlphaBuffer() ); } @@ -631,19 +631,19 @@ void rot180() void copy() { - QApplication.clipboard().setImage(image); // Less information loss + TQApplication.clipboard().setImage(image); // Less information loss } void paste() { - QImage p = QApplication.clipboard().image(); + TQImage p = TQApplication.clipboard().image(); if ( !p.isNull() ) { filename = "pasted"; setImage(p); } } -void setImage(QImage newimage) +void setImage(TQImage newimage) { image = newimage; diff --git a/qtjava/javalib/examples/showimg/Main.java b/qtjava/javalib/examples/showimg/Main.java index a72a39c9..97cc30a6 100644 --- a/qtjava/javalib/examples/showimg/Main.java +++ b/qtjava/javalib/examples/showimg/Main.java @@ -15,20 +15,20 @@ public class Main { public static void main(String[] args) { if ( args.length > 0 && args[0].equals("-m") ) { - QApplication.setColorSpec( QApplication.ManyColor ); + TQApplication.setColorSpec( TQApplication.ManyColor ); } else if ( args.length > 1 && args[1].equals("-n") ) { - QApplication.setColorSpec( QApplication.NormalColor ); + TQApplication.setColorSpec( TQApplication.NormalColor ); } else { - QApplication.setColorSpec( QApplication.CustomColor ); + TQApplication.setColorSpec( TQApplication.CustomColor ); } - QApplication.setFont( new QFont("Helvetica", 12) ); - QApplication a = new QApplication( args ); + TQApplication.setFont( new TQFont("Helvetica", 12) ); + TQApplication a = new TQApplication( args ); ImageIconProvider iip = new ImageIconProvider(); - QFileDialog.setIconProvider( iip ); + TQFileDialog.setIconProvider( iip ); if ( args.length == 0 ) { // Create a window which looks after its own existence. @@ -47,7 +47,7 @@ public static void main(String[] args) } } - QObject.connect(Qt.qApp(), Qt.SIGNAL("lastWindowClosed()"), Qt.qApp(), Qt.SLOT("quit()")); + TQObject.connect(Qt.qApp(), Qt.SIGNAL("lastWindowClosed()"), Qt.qApp(), Qt.SLOT("quit()")); a.exec(); return; diff --git a/qtjava/javalib/examples/showimg/README b/qtjava/javalib/examples/showimg/README index a6c9ca98..cf29b844 100644 --- a/qtjava/javalib/examples/showimg/README +++ b/qtjava/javalib/examples/showimg/README @@ -3,7 +3,7 @@ conversion facilities available. The CuteWidget can read a file into a pixmap and resizes the displayed pixmap when the widget is resized. Note that the function CuteWidget::paintEvent uses the drawPixmap function -of QPainter to display the pixmap, the bitBlt function can also be used to +of TQPainter to display the pixmap, the bitBlt function can also be used to display pixmaps. If you have installed the Qt imageio extension (see extensions/imageio |