summaryrefslogtreecommitdiffstats
path: root/qtjava/javalib/test
diff options
context:
space:
mode:
Diffstat (limited to 'qtjava/javalib/test')
-rw-r--r--qtjava/javalib/test/AppWizardBase.java209
-rw-r--r--qtjava/javalib/test/DirTest.java30
-rw-r--r--qtjava/javalib/test/FilePropsPageBase.java137
-rw-r--r--qtjava/javalib/test/Foo.java30
-rw-r--r--qtjava/javalib/test/ISBNValidator.java163
-rw-r--r--qtjava/javalib/test/KillerFilter.java56
-rw-r--r--qtjava/javalib/test/QTimerTest.java321
-rw-r--r--qtjava/javalib/test/ScribbleWindow.java302
-rw-r--r--qtjava/javalib/test/SignalForwarder.java31
9 files changed, 1279 insertions, 0 deletions
diff --git a/qtjava/javalib/test/AppWizardBase.java b/qtjava/javalib/test/AppWizardBase.java
new file mode 100644
index 00000000..48ae0dd3
--- /dev/null
+++ b/qtjava/javalib/test/AppWizardBase.java
@@ -0,0 +1,209 @@
+/****************************************************************************
+** Form implementation generated from reading ui file 'appwizardbase.ui'
+**
+** Created: Mon Feb 19 01:02:06 2001
+** by: The User Interface Compiler (uic)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+import org.kde.qt.*;
+
+public class AppWizardBase extends QWizard {
+ QGroupBox GroupBox8;
+ QCheckBox lsm_checkbox;
+ QLabel TextLabel7;
+ QComboBox license_combobox;
+ QLabel TextLabel2;
+ QLineEdit version_edit;
+ QLabel TextLabel5;
+ QMultiLineEdit desc_multiedit;
+ QGroupBox General;
+ QLabel TextLabel4;
+ QLabel TextLabel6;
+ QLabel TextLabel3;
+ QLineEdit company_edit;
+ QLineEdit email_edit;
+ QLineEdit author_edit;
+ QLabel TextLabel1;
+ QPushButton loadheader_button;
+ QPushButton newheader_button;
+ QMultiLineEdit header_multiedit;
+
+ QGridLayout grid;
+ QGridLayout GroupBox8Layout;
+ QGridLayout GeneralLayout;
+ QGridLayout grid_2;
+ QHBoxLayout Layout5;
+
+
+/*
+ * Constructs a AppWizardBase which is a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'
+ *
+ * The wizard will by default be modeless, unless you set 'modal' to
+ * true to construct a modal wizard.
+ */
+AppWizardBase( QWidget parent, String name, boolean modal, int fl )
+{
+ super( parent, name, modal, fl );
+ if ( name == null )
+ setName( "AppWizardBase" );
+ resize( 414, 437 );
+ setCaption( tr( "Application Wizard" ) );
+ QToolTip.add( this, tr( "" ) );
+
+ QWidget privateWidget = new QWidget( this, "privateWidget" );
+ grid = new QGridLayout( privateWidget );
+ grid.setSpacing( 6 );
+ grid.setMargin( 11 );
+
+ GroupBox8 = new QGroupBox( privateWidget, "GroupBox8" );
+ GroupBox8.setTitle( tr( "Project" ) );
+ GroupBox8.setColumnLayout(0, Qt.Vertical );
+ GroupBox8.layout().setSpacing( 0 );
+ GroupBox8.layout().setMargin( 0 );
+ GroupBox8Layout = new QGridLayout( GroupBox8.layout() );
+ GroupBox8Layout.setAlignment( Qt.AlignTop );
+ GroupBox8Layout.setSpacing( 6 );
+ GroupBox8Layout.setMargin( 11 );
+
+ lsm_checkbox = new QCheckBox( GroupBox8, "lsm_checkbox" );
+ lsm_checkbox.setText( tr( "generate lsm-File - (Linux Software Map)" ) );
+
+ GroupBox8Layout.addMultiCellWidget( lsm_checkbox, 1, 1, 0, 3 );
+
+ TextLabel7 = new QLabel( GroupBox8, "TextLabel7" );
+ TextLabel7.setText( tr( "License:" ) );
+
+ GroupBox8Layout.addWidget( TextLabel7, 0, 0 );
+
+ license_combobox = new QComboBox( false, GroupBox8, "license_combobox" );
+ license_combobox.insertItem( tr( "GPL" ) );
+ license_combobox.insertItem( tr( "LGPL" ) );
+ license_combobox.insertItem( tr( "BSD" ) );
+ license_combobox.insertItem( tr( "Artistic" ) );
+ license_combobox.insertItem( tr( "QPL" ) );
+ license_combobox.insertItem( tr( "Custom" ) );
+
+ GroupBox8Layout.addWidget( license_combobox, 0, 1 );
+
+ TextLabel2 = new QLabel( GroupBox8, "TextLabel2" );
+ TextLabel2.setText( tr( "Version:" ) );
+
+ GroupBox8Layout.addWidget( TextLabel2, 0, 2 );
+
+ version_edit = new QLineEdit( GroupBox8, "version_edit" );
+ version_edit.setText( tr( "0.1" ) );
+
+ GroupBox8Layout.addWidget( version_edit, 0, 3 );
+
+ TextLabel5 = new QLabel( GroupBox8, "TextLabel5" );
+ TextLabel5.setText( tr( "Description:" ) );
+
+ GroupBox8Layout.addMultiCellWidget( TextLabel5, 2, 2, 0, 1 );
+
+ desc_multiedit = new QMultiLineEdit( GroupBox8, "desc_multiedit" );
+
+ GroupBox8Layout.addMultiCellWidget( desc_multiedit, 3, 3, 0, 3 );
+
+ grid.addWidget( GroupBox8, 1, 0 );
+
+ General = new QGroupBox( privateWidget, "General" );
+ General.setTitle( tr( "General" ) );
+ General.setColumnLayout(0, Qt.Vertical );
+ General.layout().setSpacing( 0 );
+ General.layout().setMargin( 0 );
+ GeneralLayout = new QGridLayout( General.layout() );
+ GeneralLayout.setAlignment( Qt.AlignTop );
+ GeneralLayout.setSpacing( 6 );
+ GeneralLayout.setMargin( 11 );
+
+ TextLabel4 = new QLabel( General, "TextLabel4" );
+ TextLabel4.setText( tr( "Company:" ) );
+
+ GeneralLayout.addWidget( TextLabel4, 2, 0 );
+
+ TextLabel6 = new QLabel( General, "TextLabel6" );
+ TextLabel6.setText( tr( "Email:" ) );
+
+ GeneralLayout.addWidget( TextLabel6, 1, 0 );
+
+ TextLabel3 = new QLabel( General, "TextLabel3" );
+ TextLabel3.setText( tr( "Author:" ) );
+
+ GeneralLayout.addWidget( TextLabel3, 0, 0 );
+
+ company_edit = new QLineEdit( General, "company_edit" );
+
+ GeneralLayout.addWidget( company_edit, 2, 1 );
+
+ email_edit = new QLineEdit( General, "email_edit" );
+
+ GeneralLayout.addWidget( email_edit, 1, 1 );
+
+ author_edit = new QLineEdit( General, "author_edit" );
+
+ GeneralLayout.addWidget( author_edit, 0, 1 );
+
+ grid.addWidget( General, 0, 0 );
+ addPage( privateWidget, tr( "General" ) );
+
+ QWidget privateWidget_2 = new QWidget( this, "privateWidget_2" );
+ grid_2 = new QGridLayout( privateWidget_2 );
+ grid_2.setSpacing( 6 );
+ grid_2.setMargin( 11 );
+
+ Layout5 = new QHBoxLayout();
+ Layout5.setSpacing( 6 );
+ Layout5.setMargin( 0 );
+
+ TextLabel1 = new QLabel( privateWidget_2, "TextLabel1" );
+ TextLabel1.setText( tr( "headertemplate for your files:" ) );
+ Layout5.addWidget( TextLabel1 );
+ QSpacerItem spacer = new QSpacerItem( 0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum );
+ Layout5.addItem( spacer );
+
+ loadheader_button = new QPushButton( privateWidget_2, "loadheader_button" );
+ loadheader_button.setText( tr( "Load..." ) );
+ QToolTip.add( loadheader_button, tr( "" ) );
+ Layout5.addWidget( loadheader_button );
+
+ newheader_button = new QPushButton( privateWidget_2, "newheader_button" );
+ newheader_button.setText( tr( "New" ) );
+ QToolTip.add( newheader_button, tr( "Clears the pre-set headertemplate" ) );
+ Layout5.addWidget( newheader_button );
+
+ grid_2.addLayout( Layout5, 0, 0 );
+
+ header_multiedit = new QMultiLineEdit( privateWidget_2, "header_multiedit" );
+
+ grid_2.addWidget( header_multiedit, 1, 0 );
+ addPage( privateWidget_2, tr( "Header" ) );
+
+ // signals and slots connections
+ connect( loadheader_button, SIGNAL( "clicked()" ), this, SLOT( "slotLoadHeader()" ) );
+ connect( newheader_button, SIGNAL( "clicked()" ), this, SLOT( "slotNewHeader()" ) );
+
+ // tab order
+ setTabOrder( loadheader_button, newheader_button );
+ setTabOrder( newheader_button, header_multiedit );
+ setTabOrder( header_multiedit, author_edit );
+ setTabOrder( author_edit, email_edit );
+ setTabOrder( email_edit, company_edit );
+ setTabOrder( company_edit, license_combobox );
+ setTabOrder( license_combobox, version_edit );
+ setTabOrder( version_edit, lsm_checkbox );
+ setTabOrder( lsm_checkbox, desc_multiedit );
+}
+
+public void slotLoadHeader()
+{
+ qWarning( "AppWizardBase.slotLoadHeader(): Not implemented yet!" );
+}
+
+public void slotNewHeader()
+{
+ qWarning( "AppWizardBase.slotNewHeader(): Not implemented yet!" );
+}
+
+}
diff --git a/qtjava/javalib/test/DirTest.java b/qtjava/javalib/test/DirTest.java
new file mode 100644
index 00000000..1a694ed0
--- /dev/null
+++ b/qtjava/javalib/test/DirTest.java
@@ -0,0 +1,30 @@
+//import org.kde.qt.QApplication;
+//import org.kde.qt.QDir;
+import org.kde.qt.*;
+
+public class DirTest {
+ public static void main(String[] args)
+ {
+ QApplication myapp = new QApplication(args);
+
+ QDir mydir = new QDir("/tmp");
+ if ( mydir.match(new String [] {"*.bmp", "*.h"}, "foobar.bmp") ) {
+ System.out.println("foobar matches");
+ }
+
+ if ( ! mydir.match(new String[] {"*.bmp", "*.h"}, "baz.cpp") ) {
+ System.out.println("baz doesn't match");
+ }
+
+ QFile myobj = new QFile();
+ Object mytest;
+ System.out.println("myobj: " + myobj.toString());
+ mytest = (QDir) Qt.dynamicCast("QDir", myobj);
+ System.out.println("mytest: " + mytest.toString());
+ return;
+ }
+
+ static {
+ qtjava.initialize();
+ }
+}
diff --git a/qtjava/javalib/test/FilePropsPageBase.java b/qtjava/javalib/test/FilePropsPageBase.java
new file mode 100644
index 00000000..4fd11d27
--- /dev/null
+++ b/qtjava/javalib/test/FilePropsPageBase.java
@@ -0,0 +1,137 @@
+/****************************************************************************
+** Form interface generated from reading ui file 'filepropspagebase.ui'
+**
+** Created: Fri Nov 24 10:51:51 2000
+** by: The User Interface Compiler (uic)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+
+import org.kde.qt.*;
+
+public class FilePropsPageBase extends QWidget {
+ QGroupBox GroupBox7;
+ QLabel TextLabel1_2;
+ QLineEdit classname_edit;
+ QLabel TextLabel2_2;
+ QLineEdit baseclass_edit;
+ QLineEdit headerfile_edit;
+ QLabel implfile_label;
+ QLabel headerfile_label;
+ QLineEdit implfile_edit;
+ QLabel TextLabel5;
+ QLabel TextLabel6;
+ QListBox classes_listbox;
+ QMultiLineEdit desc_textview;
+
+ QGridLayout grid;
+ QGridLayout grid_2;
+
+
+/*
+ * Constructs a FilePropsPageBase which is a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'
+ */
+public FilePropsPageBase( QWidget parent, String name, int fl )
+{
+ super( parent, name, fl );
+ if ( name == null )
+ setName( "Form1" );
+ resize( 414, 366 );
+ setCaption( tr( "Form1" ) );
+ grid = new QGridLayout( this );
+ grid.setSpacing( 6 );
+ grid.setMargin( 11 );
+
+ GroupBox7 = new QGroupBox( this, "GroupBox7" );
+ GroupBox7.setTitle( tr( "Customize" ) );
+ GroupBox7.setColumnLayout(0, Qt.Vertical );
+ GroupBox7.layout().setSpacing( 0 );
+ GroupBox7.layout().setMargin( 0 );
+ grid_2 = new QGridLayout( GroupBox7.layout() );
+ grid_2.setAlignment( Qt.AlignTop );
+ grid_2.setSpacing( 6 );
+ grid_2.setMargin( 11 );
+
+ TextLabel1_2 = new QLabel( GroupBox7, "TextLabel1_2" );
+ TextLabel1_2.setText( tr( "Class name:" ) );
+
+ grid_2.addWidget( TextLabel1_2, 0, 0 );
+
+ classname_edit = new QLineEdit( GroupBox7, "classname_edit" );
+
+ grid_2.addWidget( classname_edit, 1, 0 );
+
+ TextLabel2_2 = new QLabel( GroupBox7, "TextLabel2_2" );
+ TextLabel2_2.setText( tr( "Base class:" ) );
+
+ grid_2.addWidget( TextLabel2_2, 2, 0 );
+
+ baseclass_edit = new QLineEdit( GroupBox7, "baseclass_edit" );
+
+ grid_2.addWidget( baseclass_edit, 3, 0 );
+
+ headerfile_edit = new QLineEdit( GroupBox7, "headerfile_edit" );
+
+ grid_2.addWidget( headerfile_edit, 1, 1 );
+
+ implfile_label = new QLabel( GroupBox7, "implfile_label" );
+ implfile_label.setText( tr( "Implementation file:" ) );
+
+ grid_2.addWidget( implfile_label, 2, 1 );
+
+ headerfile_label = new QLabel( GroupBox7, "headerfile_label" );
+ headerfile_label.setText( tr( "Header file:" ) );
+
+ grid_2.addWidget( headerfile_label, 0, 1 );
+
+ implfile_edit = new QLineEdit( GroupBox7, "implfile_edit" );
+
+ grid_2.addWidget( implfile_edit, 3, 1 );
+
+ grid.addMultiCellWidget( GroupBox7, 2, 2, 0, 1 );
+
+ TextLabel5 = new QLabel( this, "TextLabel5" );
+ TextLabel5.setText( tr( "Classes:" ) );
+
+ grid.addWidget( TextLabel5, 0, 0 );
+
+ TextLabel6 = new QLabel( this, "TextLabel6" );
+ TextLabel6.setText( tr( "Description:" ) );
+
+ grid.addWidget( TextLabel6, 0, 1 );
+
+ classes_listbox = new QListBox( this, "classes_listbox" );
+
+ grid.addWidget( classes_listbox, 1, 0 );
+
+ desc_textview = new QMultiLineEdit( this, "desc_textview" );
+ desc_textview.setEnabled( true );
+ desc_textview.setText( tr( "" ) );
+ desc_textview.setWordWrap( QMultiLineEdit.WidgetWidth );
+ desc_textview.setReadOnly( true );
+
+ grid.addWidget( desc_textview, 1, 1 );
+
+ // signals and slots connections
+ connect( classname_edit, SIGNAL( "textChanged(String)" ), this, SLOT( "slotClassnameChanged(String)" ) );
+ connect( classes_listbox, SIGNAL( "mouseButtonClicked(int,QListBoxItem,QPoint)" ), this, SLOT( "slotSelectionChanged()" ) );
+
+ // tab order
+ setTabOrder( classes_listbox, classname_edit );
+ setTabOrder( classname_edit, headerfile_edit );
+ setTabOrder( headerfile_edit, baseclass_edit );
+ setTabOrder( baseclass_edit, implfile_edit );
+}
+
+public void slotSelectionChanged()
+{
+ qWarning( "FilePropsPageBase.slotSelectionChanged(): Not implemented yet!" );
+}
+
+public void slotClassnameChanged(java.lang.String string)
+{
+ qWarning( "FilePropsPageBase.slotClassnameChanged(java.lang.String string): Not implemented yet!" );
+}
+
+}
diff --git a/qtjava/javalib/test/Foo.java b/qtjava/javalib/test/Foo.java
new file mode 100644
index 00000000..e4bddb6d
--- /dev/null
+++ b/qtjava/javalib/test/Foo.java
@@ -0,0 +1,30 @@
+import org.kde.qt.*;
+public class Foo extends AppWizardBase {
+/*
+ * Constructs a Foo which is a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'
+ *
+ * The wizard will by default be modeless, unless you set 'modal' to
+ * true to construct a modal wizard.
+ */
+Foo( QWidget parent, String name, boolean modal, int fl )
+{
+ super( parent, name, modal, fl );
+}
+
+/*
+ * public slot
+ */
+public void slotLoadHeader()
+{
+ qWarning( "AppWizardBase.slotLoadHeader() not yet implemented!" );
+}
+/*
+ * public slot
+ */
+public void slotNewHeader()
+{
+ qWarning( "AppWizardBase.slotNewHeader() not yet implemented!" );
+}
+
+}
diff --git a/qtjava/javalib/test/ISBNValidator.java b/qtjava/javalib/test/ISBNValidator.java
new file mode 100644
index 00000000..25744e11
--- /dev/null
+++ b/qtjava/javalib/test/ISBNValidator.java
@@ -0,0 +1,163 @@
+/** From 'Programming in Qt', page 180 */
+
+import org.kde.qt.*;
+
+/**
+ * A class that validates ISBN numbers. See the text for the
+ * specification.
+ */
+public class ISBNValidator extends QValidator
+{
+ public ISBNValidator()
+ {
+ super(null,null);
+ }
+
+ /**
+ * This method is called after every input. Since we can check every
+ * character as soon as it is entered, we only need to check one
+ * character at a time for validity. To determine whether
+ * the whole string is acceptable, we must look at the whole
+ * string
+ * Note that input can also be deleted. This makes it useless
+ * to save state (like the number of entered digits) between
+ * invocations of validate(), because we would have to keep an extra
+ * copy of the last string.
+ */
+ public int validate(StringBuffer text, int[] position)
+ {
+ int pos = position[0] - 1;
+
+ if( text.length() == 0 )
+ return Valid;
+
+ /* Protect against spurious calls to validate() */
+ if (pos > text.length() )
+ return Valid;
+
+ /* Anything but decimal digits and dashes is invalid. We only need
+ * to check the character at the cursor positions. This speeds
+ * things up massively.
+ */
+ if( !Character.isDigit(text.charAt(pos)) && ( text.charAt(pos) != '-' ) )
+ {
+ System.out.println( "Typed character is neither digit nor dash" );
+ return Invalid;
+ }
+
+ /* Dashes are only valid at position 1 (the second position),
+ * position 8 (if there was no dash at position 1), or position 9 (if
+ * there was a dash at position 1).
+ */
+ if( text.charAt(pos) == '-' )
+ {
+ if( pos != 1 && pos != 8 && pos != 9 )
+ {
+ System.out.println( "Dash at wrong position" );
+ return Invalid;
+ }
+
+ if( ( pos == 8 && text.charAt(1) == '-' ) ||
+ ( pos == 9 && text.charAt(1) != '-' ) )
+ {
+ System.out.println( "Dash at wrong position" );
+ return Invalid;
+ }
+ }
+
+ /* If the characters entered so far are valid, but the string
+ * contains less than ten digits, it could be made acceptable, but
+ * is not yet.
+ */
+ int numdigits = text.length();
+ if( text.length() > 1 && text.charAt(1) == '-' ) numdigits--;
+ if( text.length() > 8 && text.charAt(8) == '-' ) numdigits--;
+ if( text.length() > 9 && text.charAt(9) == '-' ) numdigits--;
+
+ if( numdigits < 10 )
+ {
+ System.out.println( "Less than ten digits; input valid but not yet acceptable" );
+ return Valid;
+ }
+
+ if( numdigits > 10 )
+ {
+ System.out.println( "More than ten digits; input invalid" );
+ return Invalid;
+ }
+
+ if( text.charAt(1) != '-' || text.charAt(9) != '-' )
+ {
+ System.out.println( "Ten digits, but dashes not in the right places. Could be fixed up" );
+ return Valid;
+ }
+
+ System.out.println( "Input acceptable" );
+ return Acceptable;
+ }
+
+ /**
+ * This method is called when the user has pressed return, but
+ * validate() has judged the string valid but not acceptable. Note
+ * that fixup() is not required to return an acceptable string. It is
+ * guaranteed that the caller will validate() the string once again
+ * after the call to fixup().
+ */
+ public void fixup(StringBuffer text)
+ {
+ /* We can fix the input only if the dashes are missing,
+ * since we cannot implement the missing digits. (We could at least
+ * compute the last one with the checksum algorithm, but won't do so
+ * here.)
+ */
+
+ /* If at least one digit has been entered but there is no dash at
+ * position 1, insert one.
+ */
+ if( text.length() > 1 && text.charAt(1) != '-' )
+ text.insert( 1, "-" );
+
+ /* If at least nine digits have been entered but there is no dash
+ * at position 10 (because of the last two lines, we can safely
+ * assume that the first dash is already in place), insert one.
+ */
+ if( text.length() > 10 /* nine digits plus dash */ && text.charAt(10) != '-' )
+ text.insert( 10, "-" );
+
+ }
+
+
+ public static void main(String[] args)
+ {
+ class ReturnReceiver extends QObject {
+ public void slotReturnPressed()
+ {
+ System.out.println( "return pressed - input accepted" );
+ }
+ }
+
+ QApplication myapp = new QApplication( args );
+
+ // create a line edit
+ QLineEdit myedit = new QLineEdit((QWidget) null);
+ myedit.resize( 100, 30 );
+
+ // create and assign a validator for the line edit
+ ISBNValidator myvalidator = new ISBNValidator();
+ myedit.setValidator(myvalidator);
+
+ // set up a receiver for the returnPressed() signal
+ ReturnReceiver receiver = new ReturnReceiver();
+ QObject.connect( myedit, SIGNAL( "returnPressed()" ),
+ receiver, SLOT( "slotReturnPressed()" ) );
+
+ myapp.setMainWidget( myedit );
+ myedit.show();
+ myapp.exec();
+ return;
+ }
+
+ static {
+ qtjava.initialize();
+ }
+}
diff --git a/qtjava/javalib/test/KillerFilter.java b/qtjava/javalib/test/KillerFilter.java
new file mode 100644
index 00000000..76481284
--- /dev/null
+++ b/qtjava/javalib/test/KillerFilter.java
@@ -0,0 +1,56 @@
+import org.kde.qt.*;
+
+public class KillerFilter extends QObject {
+
+ public boolean eventFilter( QObject object, QEvent event) {
+ if (event.type() == QEvent.MouseButtonPress) {
+ if ( ((QMouseEvent)event).button() == RightButton ) {
+ ((QWidget) object).close();
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ QApplication a = new QApplication(args);
+
+ QWidget toplevel = new QWidget();
+ toplevel.resize( 230, 130 );
+
+ QObject killerFilter = new KillerFilter();
+
+ QPushButton pb = new QPushButton(toplevel);
+ pb.setGeometry(10, 10, 100, 50 );
+ pb.setText( "pushbutton" );
+ pb.installEventFilter( killerFilter );
+
+ QLineEdit le = new QLineEdit( toplevel );
+ le.setGeometry( 10, 70, 100, 50 );
+ le.setText( "Line edit" );
+ le.installEventFilter( killerFilter );
+
+ QCheckBox cb = new QCheckBox( toplevel );
+ cb.setGeometry( 120, 10, 100, 50 );
+ cb.setText( "Check-box" );
+ cb.installEventFilter( killerFilter );
+
+ QRadioButton rb = new QRadioButton( toplevel );
+ rb.setGeometry( 120, 70, 100, 50 );
+ rb.setText( "Radio button" );
+ rb.installEventFilter( killerFilter );
+
+ a.setMainWidget(toplevel);
+ toplevel.show();
+ a.exec();
+ return;
+ }
+
+ static {
+ qtjava.initialize();
+ }
+}
diff --git a/qtjava/javalib/test/QTimerTest.java b/qtjava/javalib/test/QTimerTest.java
new file mode 100644
index 00000000..c81c2c70
--- /dev/null
+++ b/qtjava/javalib/test/QTimerTest.java
@@ -0,0 +1,321 @@
+ /**
+ * A class that lets the user draw with the mouse. The
+ * window knows how to redraw itself.
+ */
+
+import org.kde.qt.*;
+
+public class QTimerTest extends QWidget {
+
+ public static final int COLOR_MENU_ID_BLACK = 0;
+ public static final int COLOR_MENU_ID_RED = 1;
+ public static final int COLOR_MENU_ID_BLUE = 2;
+ public static final int COLOR_MENU_ID_GREEN = 3;
+ public static final int COLOR_MENU_ID_YELLOW = 4;
+
+ public static int eventCount = 0;
+
+ private QMenuBar _menubar;
+ private QPopupMenu _filemenu;
+ private QPopupMenu _colormenu;
+ private QPopupMenu _helpmenu;
+ private QScrollView _scrollview;
+ private ScribbleArea _scribblearea;
+
+ public class ScribbleArea extends QWidget {
+ private QPoint _last;
+ private QColor _currentcolor;
+
+ private QPixmap _buffer;
+ private QPopupMenu _popupmenu;
+
+ /**
+ * The constructor. Initializes the member variables.
+ */
+ ScribbleArea()
+ {
+ // initialize member variables
+ _buffer = new QPixmap();
+ _last = new QPoint();
+ _currentcolor = Qt.black();
+
+ // don't blank the window before repainting
+ setBackgroundMode( NoBackground );
+
+ // create a pop-up menu
+ _popupmenu = new QPopupMenu();
+ _popupmenu.insertItem( "&Clear", this, Qt.SLOT( "slotClearArea()" ) );
+ }
+
+ /**
+ * This slot sets the curren color for the scribble area. It will be
+ * connected with the colorChanged( QColor ) signal from the
+ * ScribbleWindow.
+ */
+ public void setColor( QColor new_color )
+ {
+ _currentcolor = new_color;
+ }
+
+ /**
+ * This slot clears the drawing area by filling the off-screen buffer with
+ * white and copying it over to the window.
+ */
+ public void slotClearArea()
+ {
+ // fill the off screen buffer with plain white
+ _buffer.fill( Qt.white() );
+
+ // and copy it over to the window
+ QPaintDevice.bitBlt( this, 0, 0, _buffer );
+ }
+
+
+ /**
+ * This method does the actual loading. It relies on QPixmap (and the
+ * underlying I/O machinery) to determine the filetype.
+ */
+ public void slotLoad( String filename )
+ {
+ if ( !_buffer.load( filename ) )
+ QMessageBox.warning( null, "Load error", "Could not load file" );
+
+ repaint(); // refresh the window
+ }
+
+
+ /**
+ * This method does the actual saving. We hard-code the file type as
+ * BMP. Unix users might want to replace this with something like XPM.
+ */
+ public void slotSave( String filename )
+ {
+ if( !_buffer.save( filename, "BMP" ) )
+ QMessageBox.warning( null, "Save error", "Could not save file" );
+ }
+
+
+ /**
+ * This method is called whenever the user presses the
+ * mouse over the window. It just records the position of the mouse
+ * at the time of the click.
+ */
+ public void mousePressEvent(QMouseEvent event)
+ {
+ if ( event.button() == RightButton )
+ _popupmenu.exec( QCursor.pos() );
+ else
+ {
+ _last = event.pos(); // retrieve the coordinates from the event
+ }
+ }
+
+
+ /**
+ * The method is called whenever the usr moves the mouse
+ * while the mouse button is pressed. If we had called
+ * setMouseTracking(true) before, the method would also be called
+ * when the mouse was moved with any button pressed. We know that
+ * we haven't, and thus don't have to check whether any buttons are
+ * pressed.
+ */
+ public void mouseMoveEvent(QMouseEvent event) {
+ // create a QPainter object for drawing onto the window
+ QPainter windowpainter = new QPainter();
+ // and another QPainter object for drawing int an off-screen pixmap
+ QPainter bufferpainter = new QPainter();
+
+ // start painting
+ windowpainter.begin( this ); // this painter paints onto the window
+ bufferpainter.begin( _buffer ); // and this one paints in the buffer
+
+ // set a standard pen with the currently selected color
+ windowpainter.setPen( _currentcolor );
+ bufferpainter.setPen( _currentcolor );
+
+ // draw a line in both the window and the buffer
+ windowpainter.drawLine( _last, event.pos() );
+ bufferpainter.drawLine( _last, event.pos() );
+
+ // done with painting
+ windowpainter.end();
+ bufferpainter.end();
+
+ // remember the current mouse position
+ _last = event.pos();
+ eventCount++;
+ }
+ /**
+ * This method is called whenever the widget needs
+ * painting, for example when it has been obscured and then revealed again.
+ */
+ public void paintEvent(QPaintEvent event) {
+ QPaintDevice.bitBlt(this, 0, 0, _buffer);
+ }
+
+ /**
+ * This method get called whenever the widget needs
+ * painting, for example, when it has been obscured and then revealed again.
+ */
+ public void resizeEvent(QResizeEvent event) {
+ QPixmap save = new QPixmap( _buffer );
+ _buffer.resize( event.size() );
+ _buffer.fill( Qt.white() );
+ QPaintDevice.bitBlt( _buffer, 0, 0, save );
+ }
+ }
+
+ QTimerTest()
+ {
+ /* The next lines build the menu bar. We first create the menus
+ * one by one, then add them to the menu bar. */
+ _filemenu = new QPopupMenu(); // create a file menu
+ _filemenu.insertItem( "&Load", this, Qt.SLOT( "slotLoad()" ) );
+ _filemenu.insertItem( "&Save", this, Qt.SLOT( "slotSave()" ) );
+ _filemenu.insertSeparator();
+ _filemenu.insertItem( "&Quit", Qt.qApp(), Qt.SLOT( "quit()" ) );
+
+ _colormenu = new QPopupMenu(); // create a color menu
+ _colormenu.insertItem( "B&lack", COLOR_MENU_ID_BLACK);
+ _colormenu.insertItem( "&Red", COLOR_MENU_ID_RED);
+ _colormenu.insertItem( "&Blue", COLOR_MENU_ID_BLUE);
+ _colormenu.insertItem( "&Green", COLOR_MENU_ID_GREEN);
+ _colormenu.insertItem( "&Yellow", COLOR_MENU_ID_YELLOW);
+ QObject.connect( _colormenu, SIGNAL( "activated(int)" ),
+ this, SLOT( "slotColorMenu(int)" ) );
+
+ _helpmenu = new QPopupMenu(); // create a help menu
+ _helpmenu.insertItem( "&About QtScribble", this, SLOT( "slotAbout()" ) );
+ _helpmenu.insertItem( "&About Qt", this, SLOT( "slotAboutQt()" ) );
+
+ _menubar = new QMenuBar( this, "" ); // create a menu bar
+ _menubar.insertItem( "&File", _filemenu );
+ _menubar.insertItem( "&Color", _colormenu );
+ _menubar.insertItem( "&Help", _helpmenu );
+
+ /* We create a QScrollView and a ScribbleArea. The ScribbleArea will
+ * be managed by the scroll view.*/
+ _scrollview = new QScrollView( this );
+ _scrollview.setGeometry( 0, _menubar.height(),
+ width(), height() - _menubar.height() );
+ _scribblearea = new ScribbleArea();
+ _scribblearea.setGeometry( 0, 0, 1000, 1000 );
+ _scrollview.addChild( _scribblearea );
+ QObject.connect( this, SIGNAL( "colorChanged(QColor)" ),
+ _scribblearea, SLOT( "setColor(QColor)" ) );
+ QObject.connect( this, SIGNAL( "save(java.lang.String)" ),
+ _scribblearea, SLOT( "slotSave(java.lang.String)" ) );
+ QObject.connect( this, SIGNAL( "load(java.lang.String)" ),
+ _scribblearea, SLOT( "slotLoad(java.lang.String)" ) );
+ }
+
+ public void resizeEvent( QResizeEvent event )
+ {
+ /* When the whole window is resized, we have to rearrange the geometry
+ * in the ScribbleWindow as well. Note that the ScribbleArea does not need
+ * to be changed. */
+ _scrollview.setGeometry( 0, _menubar.height(),
+ width(), height() - _menubar.height() );
+ }
+
+
+
+ public void slotAbout()
+ {
+ QMessageBox.information( this, "About QtScribble 5",
+ "This is the Scribble 5 application\n" +
+ "Copyright 1998 by Mathias Kalle Dalheimer\n"
+ );
+ }
+
+ public void slotAboutQt()
+ {
+ QMessageBox.aboutQt( this, "About Qt" );
+ }
+
+ public void slotColorMenu( int item )
+ {
+ switch( item )
+ {
+ case COLOR_MENU_ID_BLACK:
+ emit("colorChanged", Qt.black());
+ break;
+ case COLOR_MENU_ID_RED:
+ emit("colorChanged", Qt.darkRed());
+ break;
+ case COLOR_MENU_ID_BLUE:
+ emit("colorChanged", Qt.darkBlue());
+ break;
+ case COLOR_MENU_ID_GREEN:
+ emit("colorChanged", Qt.darkGreen());
+ break;
+ case COLOR_MENU_ID_YELLOW:
+ emit("colorChanged", Qt.yellow());
+ break;
+ }
+ }
+
+
+ /**
+ * This is the slot for the menu item File/Load. It opens a
+ * QFileDialog to ask the user for a filename, then emits a save()
+ * signal with the filename as parameter.
+ */
+ public void slotLoad()
+ {
+ /* Open a file dialog for loading. The default directory is the
+ * current directory, the filter *.bmp.
+ */
+ String filename = QFileDialog.getOpenFileName( ".", "*.bmp", this );
+ if ( !filename.equals("") )
+ emit("load", filename);
+ }
+
+ /**
+ * This is the slot for the menu item File/Load. It opens a
+ * QFileDialog to ask the user for a filename, then emits a save()
+ * signal with the filename as parameter.
+ */
+ public void slotSave()
+ {
+ /* Open a file dialog for saving. The default directory is the
+ * current directory, the filter *.bmp.
+ */
+ String filename = QFileDialog.getSaveFileName( ".", "*.bmp", this );
+ if ( !filename.equals("") )
+ emit("save", filename);
+ }
+
+ public void timerDone()
+ {
+// System.out.println("in timerDone...");
+ }
+
+ public static void main(String[] args)
+ {
+ QApplication myapp = new QApplication(args);
+ QTimerTest mywidget = new QTimerTest();
+ mywidget.setGeometry(50, 500, 400, 400);
+
+ QTimer timer = new QTimer( mywidget );
+ connect( timer, Qt.SIGNAL("timeout()"),
+ mywidget, Qt.SLOT("timerDone()") );
+ timer.start( 2000, false ); // 2 seconds single-shot
+
+ myapp.setMainWidget(mywidget);
+
+ AppWizardBase mywizard = new AppWizardBase(mywidget, "", false, 0);
+ mywizard.show();
+ FilePropsPageBase mypropspage = new FilePropsPageBase(mywidget, "", 0);
+ mypropspage.show();
+
+ mywidget.show();
+ myapp.exec();
+ System.out.println("event count: " + eventCount);
+ return;
+ }
+
+ static {
+ qtjava.initialize();
+ }
+}
diff --git a/qtjava/javalib/test/ScribbleWindow.java b/qtjava/javalib/test/ScribbleWindow.java
new file mode 100644
index 00000000..731b136f
--- /dev/null
+++ b/qtjava/javalib/test/ScribbleWindow.java
@@ -0,0 +1,302 @@
+/**
+ * A class that lets the user draw with the mouse. The
+ * window knows how to redraw itself.
+ */
+
+import org.kde.qt.*;
+
+public class ScribbleWindow extends QWidget {
+
+ public static final int COLOR_MENU_ID_BLACK = 0;
+ public static final int COLOR_MENU_ID_RED = 1;
+ public static final int COLOR_MENU_ID_BLUE = 2;
+ public static final int COLOR_MENU_ID_GREEN = 3;
+ public static final int COLOR_MENU_ID_YELLOW = 4;
+
+ private QMenuBar _menubar;
+ private QPopupMenu _filemenu;
+ private QPopupMenu _colormenu;
+ private QPopupMenu _helpmenu;
+ private QScrollView _scrollview;
+ private ScribbleArea _scribblearea;
+
+ public class ScribbleArea extends QWidget {
+ private QPoint _last;
+ private QColor _currentcolor;
+
+ private QPixmap _buffer;
+ private QPopupMenu _popupmenu;
+
+ /**
+ * The constructor. Initializes the member variables.
+ */
+ ScribbleArea()
+ {
+ // initialize member variables
+ _buffer = new QPixmap();
+ _last = new QPoint();
+ _currentcolor = black();
+
+ // don't blank the window before repainting
+ setBackgroundMode( NoBackground );
+
+ // create a pop-up menu
+ _popupmenu = new QPopupMenu();
+ _popupmenu.insertItem( "&Clear", this, SLOT( "slotClearArea()" ) );
+ }
+
+ /**
+ * This slot sets the curren color for the scribble area. It will be
+ * connected with the colorChanged( QColor ) signal from the
+ * ScribbleWindow.
+ */
+ public void setColor( QColor new_color )
+ {
+ _currentcolor = new_color;
+ }
+
+ /**
+ * This slot clears the drawing area by filling the off-screen buffer with
+ * white and copying it over to the window.
+ */
+ public void slotClearArea()
+ {
+ // fill the off screen buffer with plain white
+ _buffer.fill( white() );
+
+ // and copy it over to the window
+ bitBlt( this, 0, 0, _buffer );
+ }
+
+
+ /**
+ * This method does the actual loading. It relies on QPixmap (and the
+ * underlying I/O machinery) to determine the filetype.
+ */
+ public void slotLoad( String filename )
+ {
+ if ( !_buffer.load( filename ) )
+ QMessageBox.warning( null, "Load error", "Could not load file" );
+
+ repaint(); // refresh the window
+ }
+
+
+ /**
+ * This method does the actual saving. We hard-code the file type as
+ * BMP. Unix users might want to replace this with something like XPM.
+ */
+ public void slotSave( String filename )
+ {
+ if( !_buffer.save( filename, "BMP" ) )
+ QMessageBox.warning( null, "Save error", "Could not save file" );
+ }
+
+
+ /**
+ * This method is called whenever the user presses the
+ * mouse over the window. It just records the position of the mouse
+ * at the time of the click.
+ */
+ protected void mousePressEvent(QMouseEvent event)
+ {
+ if ( event.button() == RightButton )
+ _popupmenu.exec( QCursor.pos() );
+ else
+ {
+ _last = event.pos(); // retrieve the coordinates from the event
+ }
+ }
+
+
+ /**
+ * The method is called whenever the usr moves the mouse
+ * while the mouse button is pressed. If we had called
+ * setMouseTracking(true) before, the method would also be called
+ * when the mouse was moved with any button pressed. We know that
+ * we haven't, and thus don't have to check whether any buttons are
+ * pressed.
+ */
+ protected void mouseMoveEvent(QMouseEvent event) {
+ // create a QPainter object for drawing onto the window
+ QPainter windowpainter = new QPainter();
+ // and another QPainter object for drawing int an off-screen pixmap
+ QPainter bufferpainter = new QPainter();
+
+ // start painting
+ windowpainter.begin( this ); // this painter paints onto the window
+ bufferpainter.begin( _buffer ); // and this one paints in the buffer
+
+ // set a standard pen with the currently selected color
+ windowpainter.setPen( _currentcolor );
+ bufferpainter.setPen( _currentcolor );
+
+ // draw a line in both the window and the buffer
+ windowpainter.drawLine( _last, event.pos() );
+ bufferpainter.drawLine( _last, event.pos() );
+
+ // done with painting
+ windowpainter.end();
+ bufferpainter.end();
+
+ // remember the current mouse position
+ _last = event.pos();
+ }
+ /**
+ * This method is called whenever the widget needs
+ * painting, for example when it has been obscured and then revealed again.
+ */
+ protected void paintEvent(QPaintEvent event) {
+ bitBlt(this, 0, 0, _buffer);
+ }
+
+ /**
+ * This method get called whenever the widget needs
+ * painting, for example, when it has been obscured and then revealed again.
+ */
+ protected void resizeEvent(QResizeEvent event) {
+ QPixmap save = new QPixmap( _buffer );
+ _buffer.resize( event.size() );
+ _buffer.fill( white() );
+ bitBlt( _buffer, 0, 0, save );
+ }
+ }
+
+ ScribbleWindow()
+ {
+ /* The next lines build the menu bar. We first create the menus
+ * one by one, then add them to the menu bar. */
+ _filemenu = new QPopupMenu(); // create a file menu
+ _filemenu.insertItem( "&Load", this, SLOT( "slotLoad()" ) );
+ _filemenu.insertItem( "&Save", this, SLOT( "slotSave()" ) );
+ _filemenu.insertSeparator();
+ _filemenu.insertItem( "&Quit", qApp(), SLOT( "quit()" ) );
+
+ _colormenu = new QPopupMenu(); // create a color menu
+ _colormenu.insertItem( "B&lack", COLOR_MENU_ID_BLACK);
+ _colormenu.insertItem( "&Red", COLOR_MENU_ID_RED);
+ _colormenu.insertItem( "&Blue", COLOR_MENU_ID_BLUE);
+ _colormenu.insertItem( "&Green", COLOR_MENU_ID_GREEN);
+ _colormenu.insertItem( "&Yellow", COLOR_MENU_ID_YELLOW);
+ QObject.connect( _colormenu, SIGNAL( "activated( int )" ),
+ this, SLOT( "slotColorMenu( int )" ) );
+
+ _helpmenu = new QPopupMenu(); // create a help menu
+ _helpmenu.insertItem( "&About QtScribble", this, SLOT( "slotAbout()" ) );
+ _helpmenu.insertItem( "&About Qt", this, SLOT( "slotAboutQt()" ) );
+
+ _menubar = new QMenuBar( this, "" ); // create a menu bar
+ _menubar.insertItem( "&File", _filemenu );
+ _menubar.insertItem( "&Color", _colormenu );
+ _menubar.insertItem( "&Help", _helpmenu );
+
+ /* We create a QScrollView and a ScribbleArea. The ScribbleArea will
+ * be managed by the scroll view.*/
+ _scrollview = new QScrollView( this );
+ _scrollview.setGeometry( 0, _menubar.height(),
+ width(), height() - _menubar.height() );
+ _scribblearea = new ScribbleArea();
+ _scribblearea.setGeometry( 0, 0, 1000, 1000 );
+ _scrollview.addChild( _scribblearea );
+ QObject.connect( this, SIGNAL( "colorChanged( QColor )" ),
+ _scribblearea, SLOT( "setColor( QColor )" ) );
+ QObject.connect( this, SIGNAL( "save( String )" ),
+ _scribblearea, SLOT( "slotSave( String )" ) );
+ QObject.connect( this, SIGNAL( "load(String)" ),
+ _scribblearea, SLOT( "slotLoad( String )" ) );
+ }
+
+ protected void resizeEvent( QResizeEvent event )
+ {
+ /* When the whole window is resized, we have to rearrange the geometry
+ * in the ScribbleWindow as well. Note that the ScribbleArea does not need
+ * to be changed. */
+ _scrollview.setGeometry( 0, _menubar.height(),
+ width(), height() - _menubar.height() );
+ }
+
+
+
+ private void slotAbout()
+ {
+ QMessageBox.information( this, "About QtScribble 5",
+ "This is the Scribble 5 application\n" +
+ "Copyright 1998 by Mathias Kalle Dalheimer\n"
+ );
+ }
+
+ private void slotAboutQt()
+ {
+ QMessageBox.aboutQt( this, "About Qt" );
+ }
+
+ private void slotColorMenu( int item )
+ {
+ switch( item )
+ {
+ case COLOR_MENU_ID_BLACK:
+ emit("colorChanged", black());
+ break;
+ case COLOR_MENU_ID_RED:
+ emit("colorChanged", darkRed());
+ break;
+ case COLOR_MENU_ID_BLUE:
+ emit("colorChanged", darkBlue());
+ break;
+ case COLOR_MENU_ID_GREEN:
+ emit("colorChanged", darkGreen());
+ break;
+ case COLOR_MENU_ID_YELLOW:
+ emit("colorChanged", yellow());
+ break;
+ }
+ }
+
+
+ /**
+ * This is the slot for the menu item File/Load. It opens a
+ * QFileDialog to ask the user for a filename, then emits a save()
+ * signal with the filename as parameter.
+ */
+ private void slotLoad()
+ {
+ /* Open a file dialog for loading. The default directory is the
+ * current directory, the filter *.bmp.
+ */
+ String filename = QFileDialog.getOpenFileName( ".", "*.bmp", this );
+ if ( !filename.equals("") )
+ emit("load", filename);
+ }
+
+ /**
+ * This is the slot for the menu item File/Load. It opens a
+ * QFileDialog to ask the user for a filename, then emits a save()
+ * signal with the filename as parameter.
+ */
+ private void slotSave()
+ {
+ /* Open a file dialog for saving. The default directory is the
+ * current directory, the filter *.bmp.
+ */
+ String filename = QFileDialog.getSaveFileName( ".", "*.bmp", this );
+ if ( !filename.equals("") )
+ emit("save", filename);
+ }
+
+
+ public static void main(String[] args)
+ {
+ QApplication myapp = new QApplication(args);
+ ScribbleWindow mywidget = new ScribbleWindow();
+ mywidget.setGeometry(50, 500, 400, 400);
+
+ myapp.setMainWidget(mywidget);
+ mywidget.show();
+ myapp.exec();
+ return;
+ }
+
+ static {
+ qtjava.initialize();
+ }
+}
diff --git a/qtjava/javalib/test/SignalForwarder.java b/qtjava/javalib/test/SignalForwarder.java
new file mode 100644
index 00000000..332ba5e6
--- /dev/null
+++ b/qtjava/javalib/test/SignalForwarder.java
@@ -0,0 +1,31 @@
+import org.kde.qt.*;
+
+public class SignalForwarder extends QDialog {
+
+ SignalForwarder() {
+ QPushButton searchButton = new QPushButton("Search", this);
+ connect( searchButton, SIGNAL("clicked()"), this, SIGNAL("continueSearch()"));
+ connect( this, SIGNAL("continueSearch()"), this, SLOT("slotContinueSearch()"));
+ }
+
+ public void slotContinueSearch()
+ {
+ System.out.println("in continueSearch()...");
+ }
+
+ public static void main(String[] args)
+ {
+ QApplication myapp = new QApplication(args);
+
+ SignalForwarder signalForwarder = new SignalForwarder();
+ myapp.setMainWidget(signalForwarder);
+ signalForwarder.show();
+ myapp.exec();
+
+ return;
+ }
+
+ static {
+ qtjava.initialize();
+ }
+}