1 /****************************************************************************
2 ** $Id: richtext.cpp,v 1.1 2004/03/17 22:46:13 smolik Exp $
4 ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
6 ** This file is part of an example program for Qt. This example
7 ** program may be used, distributed and modified without limitation.
9 *****************************************************************************/
15 #include <qpushbutton.h>
16 #include <qtextview.h>
18 #include <qapplication.h>
20 static const char* publisherExamples[] = {
21 "<b>Saying 1:</b><br>"
23 "<big>Evil is that which one believes of others. It is a sin to believe evil "
24 "of others, but it is seldom a mistake.</big><br><br>"
25 "<center><i>-- H.L. Mencken</i></center>",
27 "<b>Saying 2:</b><br>"
29 "<big>A well-used door needs no oil on its hinges.<br>"
30 "A swift-flowing steam does not grow stagnant.<br>"
31 "Neither sound nor thoughts can travel through a vacuum.<br>"
32 "Software rots if not used.<br><br>"
33 "These are great mysteries.</big><br><br>"
34 "<center><i>-- Geoffrey James, \"The Tao of Programming\"</i></center>",
39 static const char* subscriberExamples[] = {
40 "<b>Example 1:</b><br>"
42 "<big>Evil is that which one believes of others. It is a sin to believe evil "
43 "of others, but it is seldom a mistake.</big><br><br>"
44 "<center><i>-- H.L. Mencken</i></center>",
46 "<b>Example 2:</b><br>"
48 "<big>A well-used door needs no oil on its hinges.<br>"
49 "A swift-flowing steam does not grow stagnant.<br>"
50 "Neither sound nor thoughts can travel through a vacuum.<br>"
51 "Software rots if not used.<br><br>"
52 "These are great mysteries.</big><br><br>"
53 "<center><i>-- Geoffrey James, \"The Tao of Programming\"</i></center>",
59 MyRichText::MyRichText( QWidget *parent, const char *name )
60 : QVBox( parent, name )
64 view = new QTextView( this );
66 paper.setPixmap( QPixmap( "marble.png" ) );
67 if ( paper.pixmap() != 0 )
68 view->setPaper( paper );
70 view->setPaper( white );
72 view->setMinimumSize( 450, 250 );
74 QHBox *buttons = new QHBox( this );
75 buttons->setMargin( 5 );
77 bClose = new QPushButton( "&Close", buttons );
78 bPrev = new QPushButton( "<< &Prev", buttons );
79 bNext = new QPushButton( "&Next >>", buttons );
81 bPrev->setEnabled( FALSE );
83 connect( bClose, SIGNAL(clicked()), this, SLOT(close()) );
84 connect( bPrev, SIGNAL( clicked() ), this, SLOT( prev() ) );
85 connect( bNext, SIGNAL( clicked() ), this, SLOT( next() ) );
89 void MyRichText::setTextPublisher()
92 sayings=publisherExamples;
93 view->setText(sayings[0]);
97 void MyRichText::setTextSubscriber()
100 sayings=subscriberExamples;
101 view->setText(sayings[0]);
104 void MyRichText::prev()
111 view->setText( sayings[num] );
114 bPrev->setEnabled( FALSE );
116 bNext->setEnabled( TRUE );
119 void MyRichText::next()
121 if ( !sayings[++num] )
124 view->setText( sayings[num] );
126 if ( !sayings[num + 1] )
127 bNext->setEnabled( FALSE );
129 bPrev->setEnabled( TRUE );