summaryrefslogtreecommitdiffstats
path: root/qtjava/javalib/examples/showimg/ImageViewer.java
diff options
context:
space:
mode:
Diffstat (limited to 'qtjava/javalib/examples/showimg/ImageViewer.java')
-rw-r--r--qtjava/javalib/examples/showimg/ImageViewer.java144
1 files changed, 72 insertions, 72 deletions
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;