/*************************************************************************** * $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 = { "Saying 1:
" + "


" + "Evil is that which one believes of others. It is a sin to believe evil " + "of others, but it is seldom a mistake.

" + "
-- H.L. Mencken
", "Saying 2:
" + "


" + "A well-used door needs no oil on its hinges.
" + "A swift-flowing steam does not grow stagnant.
" + "Neither sound nor thoughts can travel through a vacuum.
" + "Software rots if not used.

" + "These are great mysteries.


" + "
-- Geoffrey James, \"The Tao of Programming\"
", "Saying 3:
" + "


" + "Show business is just like high school, except you get paid.

" + "
-- Martin Mull
", "Saying 4:
" + "


" + "The Least Successful Executions
" + "

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.

" + "

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." + "

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.



" + "
-- Stephen Pile, \"The Book of Heroic Failures\"
", "Saying 5:
" + "


" + "If you can, help others. If you can't, at least don't hurt others.

" + "
-- the Dalai Lama
", "Saying 6:
" + "


" + "Television has brought back murder into the home -- where it belongs.

" + "
-- Alfred Hitchcock
", "Saying 7:
" + "


" + "I don't know who my grandfather was; I am much more concerned to know " + "what his grandson will be.

" + "
-- Abraham Lincoln
" }; MyRichText( ) { this(null, null); } MyRichText( QWidget parent, String name ) { super( parent, name ); setMargin( 5 ); view = new QTextView( this ); view.setText( "This is a Test with italic stuff" ); 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 ); } }