summaryrefslogtreecommitdiffstats
path: root/qtjava/javalib/examples/qwerty/Editor.java
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-12-05 15:55:57 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-12-05 15:55:57 -0600
commit9ba04742771370f59740e32e11c5f3a1e6a1b70a (patch)
treec81c34dae2b3b1ea73801bf18a960265dc4207f7 /qtjava/javalib/examples/qwerty/Editor.java
parent1a96c45b22d01378202d9dc7ed9c47acd30f966e (diff)
downloadtdebindings-9ba04742771370f59740e32e11c5f3a1e6a1b70a.tar.gz
tdebindings-9ba04742771370f59740e32e11c5f3a1e6a1b70a.zip
Initial TQt conversion
Diffstat (limited to 'qtjava/javalib/examples/qwerty/Editor.java')
-rw-r--r--qtjava/javalib/examples/qwerty/Editor.java126
1 files changed, 63 insertions, 63 deletions
diff --git a/qtjava/javalib/examples/qwerty/Editor.java b/qtjava/javalib/examples/qwerty/Editor.java
index ba11c685..3598c144 100644
--- a/qtjava/javalib/examples/qwerty/Editor.java
+++ b/qtjava/javalib/examples/qwerty/Editor.java
@@ -11,13 +11,13 @@
import org.kde.qt.*;
import java.util.ArrayList;
-class Editor extends QWidget
+class Editor extends TQWidget
{
-private QMenuBar m;
-private QMultiLineEdit e;
-private QPrinter printer = new QPrinter();
-private QPopupMenu save_as;
-private QPopupMenu open_as;
+private TQMenuBar m;
+private TQMultiLineEdit e;
+private TQPrinter printer = new TQPrinter();
+private TQPopupMenu save_as;
+private TQPopupMenu open_as;
private boolean changed;
@@ -38,42 +38,42 @@ Editor( )
this(null, null);
}
-Editor( QWidget parent , String name )
+Editor( TQWidget parent , String name )
{
super( parent, name, WDestructiveClose );
- m = new QMenuBar( this, "menu" );
+ m = new TQMenuBar( this, "menu" );
- QPopupMenu file = new QPopupMenu(this);
+ TQPopupMenu file = new TQPopupMenu(this);
m.insertItem( "&File", file );
- file.insertItem( "&New", this, SLOT("newDoc()"), new QKeySequence(ALT+Key_N) );
- file.insertItem( "&Open...", this, SLOT("load()"), new QKeySequence(ALT+Key_O) );
- file.insertItem( "&Save...", this, SLOT("save()"), new QKeySequence(ALT+Key_S) );
+ file.insertItem( "&New", this, SLOT("newDoc()"), new TQKeySequence(ALT+Key_N) );
+ file.insertItem( "&Open...", this, SLOT("load()"), new TQKeySequence(ALT+Key_O) );
+ file.insertItem( "&Save...", this, SLOT("save()"), new TQKeySequence(ALT+Key_S) );
file.insertSeparator();
- open_as = new QPopupMenu(file);
+ open_as = new TQPopupMenu(file);
file.insertItem( "Open &As", open_as );
- save_as = new QPopupMenu(file);
+ save_as = new TQPopupMenu(file);
file.insertItem( "Sa&ve As", save_as );
file.insertItem( "Add &Encoding", this, SLOT("addEncoding()") );
file.insertSeparator();
- file.insertItem( "&Print...", this, SLOT("print()"), new QKeySequence(ALT+Key_P) );
+ file.insertItem( "&Print...", this, SLOT("print()"), new TQKeySequence(ALT+Key_P) );
file.insertSeparator();
- file.insertItem( "&Close", this, SLOT("close()"),new QKeySequence(ALT+Key_W) );
- file.insertItem( "&Quit", qApp(), SLOT("closeAllWindows()"), new QKeySequence(ALT+Key_Q) );
+ file.insertItem( "&Close", this, SLOT("close()"),new TQKeySequence(ALT+Key_W) );
+ file.insertItem( "&Quit", qApp(), SLOT("closeAllWindows()"), new TQKeySequence(ALT+Key_Q) );
connect( save_as, SIGNAL("activated(int)"), this, SLOT("saveAsEncoding(int)") );
connect( open_as, SIGNAL("activated(int)"), this, SLOT("openAsEncoding(int)") );
rebuildCodecList();
- QPopupMenu edit = new QPopupMenu(m);
+ TQPopupMenu edit = new TQPopupMenu(m);
m.insertItem( "&Edit", edit );
- edit.insertItem( "To &Uppercase", this, SLOT("toUpper()"), new QKeySequence(ALT+Key_U) );
- edit.insertItem( "To &Lowercase", this, SLOT("toLower()"), new QKeySequence(ALT+Key_L) );
+ edit.insertItem( "To &Uppercase", this, SLOT("toUpper()"), new TQKeySequence(ALT+Key_U) );
+ edit.insertItem( "To &Lowercase", this, SLOT("toLower()"), new TQKeySequence(ALT+Key_L) );
edit.insertSeparator();
- edit.insertItem( "&Select Font" , this, SLOT("getFont()"), new QKeySequence(ALT+Key_F) );
+ edit.insertItem( "&Select Font" , this, SLOT("getFont()"), new TQKeySequence(ALT+Key_F) );
changed = false;
- e = new QMultiLineEdit( this, "editor" );
+ e = new TQMultiLineEdit( this, "editor" );
connect( e, SIGNAL(" textChanged()"), this, SLOT(" textChanged()") );
// We use Unifont - if you have it installed you'll see all
@@ -82,7 +82,7 @@ Editor( QWidget parent , String name )
// Unifont only comes in one pixel size, so we cannot let
// it change pixel size as the display DPI changes.
//
- QFont unifont = new QFont("unifont",16,50); unifont.setPixelSize(16);
+ TQFont unifont = new TQFont("unifont",16,50); unifont.setPixelSize(16);
e.setFont( unifont );
e.setFocus();
@@ -92,7 +92,7 @@ Editor( QWidget parent , String name )
public void getFont()
{
boolean[] ok = { true };
- QFont f = QFontDialog.getFont( ok, e.font() );
+ TQFont f = TQFontDialog.getFont( ok, e.font() );
if ( ok[0] ) {
e.setFont( f );
}
@@ -103,16 +103,16 @@ public void getFont()
void rebuildCodecList()
{
codecList = new ArrayList();
- QTextCodec codec = null;
+ TQTextCodec codec = null;
int i;
- for (i = 0; (codec = QTextCodec.codecForIndex(i)) != null; i++)
+ for (i = 0; (codec = TQTextCodec.codecForIndex(i)) != null; i++)
codecList.add( codec );
int n = codecList.size();
for (int pm=0; pm<2; pm++) {
- QPopupMenu menu = pm != 0 ? open_as : save_as;
+ TQPopupMenu menu = pm != 0 ? open_as : save_as;
menu.clear();
String local = "Local (";
- local += QTextCodec.codecForLocale().name();
+ local += TQTextCodec.codecForLocale().name();
local += ")";
menu.insertItem( local, Local );
menu.insertItem( "Unicode", Uni );
@@ -121,7 +121,7 @@ void rebuildCodecList()
if ( pm != 0 )
menu.insertItem( "[guess]", Guess );
for ( i = 0; i < n; i++ )
- menu.insertItem( ((QTextCodec) codecList.get(i)).name(), Codec + i );
+ menu.insertItem( ((TQTextCodec) codecList.get(i)).name(), Codec + i );
}
}
@@ -140,7 +140,7 @@ void newDoc()
void load()
{
- String fn = QFileDialog.getOpenFileName( "", "", this );
+ String fn = TQFileDialog.getOpenFileName( "", "", this );
if ( fn != null )
load( fn, -1 );
}
@@ -152,30 +152,30 @@ void load( String fileName )
void load( String fileName, int code )
{
- QFile f = new QFile( fileName );
- if ( !f.open( QIODevice.IO_ReadOnly ) )
+ TQFile f = new TQFile( fileName );
+ if ( !f.open( TQIODevice.IO_ReadOnly ) )
return;
e.setAutoUpdate( false );
- QTextStream t = new QTextStream(f);
+ TQTextStream t = new TQTextStream(f);
if ( code >= Codec )
- t.setCodec( (QTextCodec) codecList.get(code-Codec) );
+ t.setCodec( (TQTextCodec) codecList.get(code-Codec) );
else if ( code == Uni )
- t.setEncoding( QTextStream.Unicode );
+ t.setEncoding( TQTextStream.Unicode );
else if ( code == MBug )
- t.setEncoding( QTextStream.UnicodeReverse );
+ t.setEncoding( TQTextStream.UnicodeReverse );
else if ( code == Lat1 )
- t.setEncoding( QTextStream.Latin1 );
+ t.setEncoding( TQTextStream.Latin1 );
else if ( code == Guess ) {
- f = new QFile(fileName);
- f.open(QIODevice.IO_ReadOnly);
+ f = new TQFile(fileName);
+ f.open(TQIODevice.IO_ReadOnly);
StringBuffer buffer = new StringBuffer();
int l = 256;
l=(int)f.readBlock(buffer,l);
- QTextCodec codec = QTextCodec.codecForContent(buffer.toString(), l);
+ TQTextCodec codec = TQTextCodec.codecForContent(buffer.toString(), l);
if ( codec != null ) {
- QMessageBox.information(this,"Encoding","Codec: "+codec.name());
+ TQMessageBox.information(this,"Encoding","Codec: "+codec.name());
t.setCodec( codec );
}
}
@@ -192,7 +192,7 @@ void load( String fileName, int code )
void openAsEncoding( int code )
{
//storing filename (proper save) is left as an exercise...
- String fn = QFileDialog.getOpenFileName( "", "", this );
+ String fn = TQFileDialog.getOpenFileName( "", "", this );
if ( !fn.equals("") )
load( fn, code );
}
@@ -200,7 +200,7 @@ void openAsEncoding( int code )
boolean save()
{
//storing filename (proper save) is left as an exercise...
- String fn = QFileDialog.getSaveFileName( "", "", this );
+ String fn = TQFileDialog.getSaveFileName( "", "", this );
if ( !fn.equals("") )
return saveAs( fn );
return false;
@@ -209,21 +209,21 @@ boolean save()
void saveAsEncoding( int code )
{
//storing filename (proper save) is left as an exercise...
- String fn = QFileDialog.getSaveFileName( "", "", this );
+ String fn = TQFileDialog.getSaveFileName( "", "", this );
if ( !fn.equals("") )
saveAs( fn, code );
}
void addEncoding()
{
- String fn = QFileDialog.getOpenFileName( "", "*.map", this );
+ String fn = TQFileDialog.getOpenFileName( "", "*.map", this );
if ( !fn.equals("") ) {
- QFile f = new QFile(fn);
- if (f.open(QIODevice.IO_ReadOnly)) {
- if (QTextCodec.loadCharmap(f) != null) {
+ TQFile f = new TQFile(fn);
+ if (f.open(TQIODevice.IO_ReadOnly)) {
+ if (TQTextCodec.loadCharmap(f) != null) {
rebuildCodecList();
} else {
- QMessageBox.warning(null,"Charmap error",
+ TQMessageBox.warning(null,"Charmap error",
"The file did not contain a valid charmap.\n\n"
+ "A charmap file should look like this:\n"
+ " <code_set_name> thename\n"
@@ -248,22 +248,22 @@ boolean saveAs( String fileName )
boolean saveAs( String fileName, int code )
{
- QFile f = new QFile( fileName );
- if ( no_writing || !f.open( QIODevice.IO_WriteOnly ) ) {
- QMessageBox.warning(this,"I/O Error",
+ TQFile f = new TQFile( fileName );
+ if ( no_writing || !f.open( TQIODevice.IO_WriteOnly ) ) {
+ TQMessageBox.warning(this,"I/O Error",
"The file could not be opened.\n\n"
+fileName);
return false;
}
- QTextStream t = new QTextStream(f);
+ TQTextStream t = new TQTextStream(f);
if ( code >= Codec )
- t.setCodec( (QTextCodec) codecList.get(code-Codec) );
+ t.setCodec( (TQTextCodec) codecList.get(code-Codec) );
else if ( code == Uni )
- t.setEncoding( QTextStream.Unicode );
+ t.setEncoding( TQTextStream.Unicode );
else if ( code == MBug )
- t.setEncoding( QTextStream.UnicodeReverse );
+ t.setEncoding( TQTextStream.UnicodeReverse );
else if ( code == Lat1 )
- t.setEncoding( QTextStream.Latin1 );
+ t.setEncoding( TQTextStream.Latin1 );
t.writeRawBytes(e.text(), e.text().length());
f.close();
setCaption( fileName );
@@ -275,11 +275,11 @@ void print()
{
if ( printer.setup(this) ) { // opens printer dialog
printer.setFullPage(true); // we'll set our own margins
- QPainter p = new QPainter();
+ TQPainter p = new TQPainter();
p.begin( printer ); // paint on printer
p.setFont( e.font() );
- QFontMetrics fm = p.fontMetrics();
- QPaintDeviceMetrics metrics = new QPaintDeviceMetrics( printer ); // need width/height
+ TQFontMetrics fm = p.fontMetrics();
+ TQPaintDeviceMetrics metrics = new TQPaintDeviceMetrics( printer ); // need width/height
// of printer surface
int MARGIN = metrics.logicalDpiX() / 2; // half-inch margin
int yPos = MARGIN; // y position for each line
@@ -301,18 +301,18 @@ void print()
}
}
-protected void resizeEvent( QResizeEvent event )
+protected void resizeEvent( TQResizeEvent event )
{
if ( e != null && m != null )
e.setGeometry( 0, m.height(), width(), height() - m.height() );
}
-protected void closeEvent( QCloseEvent event )
+protected void closeEvent( TQCloseEvent event )
{
event.accept();
if ( changed ) { // the text has been changed
- switch ( QMessageBox.warning( this, "Qwerty",
+ switch ( TQMessageBox.warning( this, "Qwerty",
"Save changes to Document?",
tr("&Yes"),
tr("&No"),