summaryrefslogtreecommitdiffstats
path: root/qtjava/javalib/examples/richtext
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit90825e2392b2d70e43c7a25b8a3752299a933894 (patch)
treee33aa27f02b74604afbfd0ea4f1cfca8833d882a /qtjava/javalib/examples/richtext
downloadtdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz
tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'qtjava/javalib/examples/richtext')
-rw-r--r--qtjava/javalib/examples/richtext/Main.java32
-rw-r--r--qtjava/javalib/examples/richtext/MyRichText.java150
-rw-r--r--qtjava/javalib/examples/richtext/marble.pngbin0 -> 26015 bytes
3 files changed, 182 insertions, 0 deletions
diff --git a/qtjava/javalib/examples/richtext/Main.java b/qtjava/javalib/examples/richtext/Main.java
new file mode 100644
index 00000000..887afb2a
--- /dev/null
+++ b/qtjava/javalib/examples/richtext/Main.java
@@ -0,0 +1,32 @@
+/***************************************************************************
+* $Id$
+**
+* Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
+**
+* This file is part of an example program for Qt. This example
+* program may be used, distributed and modified without limitation.
+**
+****************************************************************************/
+
+import org.kde.qt.*;
+
+public class Main {
+
+public static void main(String[] args)
+{
+ QApplication a = new QApplication( args );
+
+ MyRichText richtext = new MyRichText();
+ richtext.resize( 450, 350 );
+ richtext.setCaption( "Qt Example - Richtext" );
+ a.setMainWidget( richtext );
+ richtext.show();
+
+ a.exec();
+ return;
+}
+
+ static {
+ qtjava.initialize();
+ }
+}
diff --git a/qtjava/javalib/examples/richtext/MyRichText.java b/qtjava/javalib/examples/richtext/MyRichText.java
new file mode 100644
index 00000000..5234e3c8
--- /dev/null
+++ b/qtjava/javalib/examples/richtext/MyRichText.java
@@ -0,0 +1,150 @@
+/***************************************************************************
+* $Id$
+**
+* Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
+**
+* This file is part of an example program for Qt. This example
+* program may be used, distributed and modified without limitation.
+**
+****************************************************************************/
+
+import org.kde.qt.*;
+
+
+class MyRichText extends QVBox
+{
+
+protected QTextView view;
+protected QPushButton bClose, bNext, bPrev;
+protected int num;
+
+
+
+static String[] sayings = {
+ "<b>Saying 1:</b><br>"
+ + "<hr><br><br>"
+ + "<big>Evil is that which one believes of others. It is a sin to believe evil "
+ + "of others, but it is seldom a mistake.</big><br><br>"
+ + "<center><i>-- H.L. Mencken</i></center>",
+
+ "<b>Saying 2:</b><br>"
+ + "<hr><br><br>"
+ + "<big>A well-used door needs no oil on its hinges.<br>"
+ + "A swift-flowing steam does not grow stagnant.<br>"
+ + "Neither sound nor thoughts can travel through a vacuum.<br>"
+ + "Software rots if not used.<br><br>"
+ + "These are great mysteries.</big><br><br>"
+ + "<center><i>-- Geoffrey James, \"The Tao of Programming\"</i></center>",
+
+ "<b>Saying 3:</b><br>"
+ + "<hr><br><br>"
+ + "<big>Show business is just like high school, except you get paid.</big><br><br>"
+ + "<center><i>-- Martin Mull</i></center>",
+
+ "<b>Saying 4:</b><br>"
+ + "<hr><br><br>"
+ + "<big><b>The Least Successful Executions</b><br>"
+ + "<twocolumn><p> History has furnished us with two executioners worthy of attention. "
+ + "The first performed in Sydney in Australia. In 1803 three attempts were "
+ + "made to hang a Mr. Joseph Samuels. On the first two of these the rope "
+ + "snapped, while on the third Mr. Samuels just hung there peacefully until he "
+ + "and everyone else got bored. Since he had proved unsusceptible to capital "
+ + "punishment, he was reprieved.</p>"
+ + "<p> The most important British executioner was Mr. James Berry who "
+ + "tried three times in 1885 to hang Mr. John Lee at Exeter Jail, but on each "
+ + "occasion failed to get the trap door open.<!p>"
+ + "<p> In recognition of this achievement, the Home Secretary commuted "
+ + "Lee's sentence to \"life\" imprisonment. He was released in 1917, emigrated "
+ + "to America and lived until 1933.</p></twocolumn></big><br><br>"
+ + "<center><i>-- Stephen Pile, \"The Book of Heroic Failures\"</i></center>",
+
+ "<b>Saying 5:</b><br>"
+ + "<hr><br><br>"
+ + "<big>If you can, help others. If you can't, at least don't hurt others.</big><br><br>"
+ + "<center><i>-- the Dalai Lama</i></center>",
+
+ "<b>Saying 6:</b><br>"
+ + "<hr><br><br>"
+ + "<big>Television has brought back murder into the home -- where it belongs.</big><br><br>"
+ + "<center><i>-- Alfred Hitchcock</i></center>",
+
+ "<b>Saying 7:</b><br>"
+ + "<hr><br><br>"
+ + "<big>I don't know who my grandfather was; I am much more concerned to know "
+ + "what his grandson will be.</big><br><br>"
+ + "<center><i>-- Abraham Lincoln</i></center>"
+
+ };
+
+
+MyRichText( )
+{
+ this(null, null);
+}
+
+MyRichText( QWidget parent, String name )
+{
+ super( parent, name );
+ setMargin( 5 );
+
+ view = new QTextView( this );
+ view.setText( "This is a <b>Test</b> with <i>italic</i> <u>stuff</u>" );
+ QBrush paper = new QBrush();
+ paper.setPixmap( new QPixmap( "../richtext/marble.png" ) );
+ if ( paper.pixmap() != null )
+ view.setPaper( paper );
+ else
+ view.setPaper( new QBrush(white()) );
+
+ view.setText( sayings[0] );
+ view.setMinimumSize( 450, 250 );
+
+ QHBox buttons = new QHBox( this );
+ buttons.setMargin( 5 );
+
+ bClose = new QPushButton( "&Close", buttons );
+ bPrev = new QPushButton( "<< &Prev", buttons );
+ bNext = new QPushButton( "&Next >>", buttons );
+
+ bPrev.setEnabled( false );
+
+ connect( bClose, SIGNAL(" clicked()"), qApp(), SLOT(" quit()") );
+ connect( bPrev, SIGNAL(" clicked()"), this, SLOT(" prev()") );
+ connect( bNext, SIGNAL(" clicked()"), this, SLOT(" next()") );
+
+ num = 0;
+}
+
+void prev()
+{
+ if ( num <= 0 )
+ return;
+
+ num--;
+
+ view.setText( sayings[num] );
+
+ if ( num == 0 )
+ bPrev.setEnabled( false );
+
+ bNext.setEnabled( true );
+}
+
+void next()
+{
+ if ( ++num >= sayings.length )
+ return;
+
+ view.setText( sayings[num] );
+
+ if ( num + 1 == sayings.length )
+ bNext.setEnabled( false );
+
+ bPrev.setEnabled( true );
+}
+
+
+
+
+}
+
diff --git a/qtjava/javalib/examples/richtext/marble.png b/qtjava/javalib/examples/richtext/marble.png
new file mode 100644
index 00000000..49ea3098
--- /dev/null
+++ b/qtjava/javalib/examples/richtext/marble.png
Binary files differ