1 /****************************************************************************
2 ** $Id: richtext.cpp,v 1.5 2004/04/20 08:37:21 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>Publisher Example 1:</b><br>"
24 "<pre>ORTEInit();<br>"
25 "d=<b>ORTEDomainAppCreate</b>(ORTE_DEFAULT_DOMAIN,NULL,NULL,ORTE_FALSE);<br>"
26 "<b>ORTETypeRegisterAdd</b>(d,\"HelloMsg\",NULL,NULL,64);<br>"
27 "NTPTIME_BUILD(persistence,3);<br>"
28 "p=<b>ORTEPublicationCreate</b>(<br>"
30 " \"Example HelloMsg\", /* Topic */<br>"
31 " \"HelloMsg\", /* Type */<br>"
32 " &instance2Send, /* Instance */<br>"
33 " &persistence, /* Persistance */<br>"
34 " 1, /* Strength */<br>"
39 "<b>Example 2:</b><br>"
41 "<big>A well-used door needs no oil on its hinges.<br>"
42 "A swift-flowing steam does not grow stagnant.<br>"
43 "Neither sound nor thoughts can travel through a vacuum.<br>"
44 "Software rots if not used.<br><br>"
45 "These are great mysteries.</big><br><br>"
46 "<center><i>-- Geoffrey James, \"The Tao of Programming\"</i></center>",
51 static const char* subscriberExamples[] = {
52 "<b>Subscriber Example 1:</b><br>"
55 "<pre>ORTEInit();<br>"
56 "d=<b>ORTEDomainAppCreate</b>(ORTE_DEFAULT_DOMAIN,NULL,NULL,ORTE_FALSE);<br>"
57 "<b>ORTETypeRegisterAdd</b>(d,\"HelloMsg\",NULL,NULL,64);<br>"
58 "NTPTIME_BUILD(persistence,3);<br>"
59 "s=<b>ORTESubscriptionCreate</b>(<br>"
63 " \"Example HelloMsg\", /* Topic */<br>"
64 " \"HelloMsg\", /* Type */<br>"
65 " &instance2Recv, /* Instance */<br>"
66 " &deadline, /* Deadline */<br>"
67 " &minimumSeparation, /* Minimum Separation */<br>"
68 " recvCallBack, /* CallBack function */<br>"
70 "void <b>recvCallBack</b>(const ORTERecvInfo *info,<br>"
71 " void *vinstance, void *recvCallBackParam) {<br>"
72 " char *instance=(char*)vinstance;<br><br>"
73 " switch (info->status) {<br>"
75 " printf(\"%s\",instance);<br>"
78 " printf(\"deadline occured\");<br>"
83 "<b>Example 2:</b><br>"
85 "<big>A well-used door needs no oil on its hinges.<br>"
86 "A swift-flowing steam does not grow stagnant.<br>"
87 "Neither sound nor thoughts can travel through a vacuum.<br>"
88 "Software rots if not used.<br><br>"
89 "These are great mysteries.</big><br><br>"
90 "<center><i>-- Geoffrey James, \"The Tao of Programming\"</i></center>",
96 MyRichText::MyRichText( QWidget *parent, const char *name )
97 : QVBox( parent, name )
101 view = new QTextView( this );
103 paper.setPixmap( QPixmap( "marble.png" ) );
104 if ( paper.pixmap() != 0 )
105 view->setPaper( paper );
107 view->setPaper( white );
109 view->setMinimumSize( 500, 250 );
111 QHBox *buttons = new QHBox( this );
112 buttons->setMargin( 5 );
114 bClose = new QPushButton( "&Close", buttons );
115 bPrev = new QPushButton( "<< &Prev", buttons );
116 bNext = new QPushButton( "&Next >>", buttons );
118 bPrev->setEnabled( FALSE );
120 connect( bClose, SIGNAL(clicked()), this, SLOT(close()) );
121 connect( bPrev, SIGNAL( clicked() ), this, SLOT( prev() ) );
122 connect( bNext, SIGNAL( clicked() ), this, SLOT( next() ) );
126 void MyRichText::setTextPublisher()
129 sayings=publisherExamples;
130 view->setText(sayings[0]);
134 void MyRichText::setTextSubscriber()
137 sayings=subscriberExamples;
138 view->setText(sayings[0]);
141 void MyRichText::prev()
148 view->setText( sayings[num] );
151 bPrev->setEnabled( FALSE );
153 bNext->setEnabled( TRUE );
156 void MyRichText::next()
158 if ( !sayings[++num] )
161 view->setText( sayings[num] );
163 if ( !sayings[num + 1] )
164 bNext->setEnabled( FALSE );
166 bPrev->setEnabled( TRUE );