From d796c9dd933ab96ec83b9a634feedd5d32e1ba3f Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 8 Nov 2011 12:31:36 -0600 Subject: Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731 --- examples/richtext/main.cpp | 24 +++++++ examples/richtext/marble.png | Bin 0 -> 25217 bytes examples/richtext/richtext.cpp | 141 +++++++++++++++++++++++++++++++++++++++++ examples/richtext/richtext.doc | 29 +++++++++ examples/richtext/richtext.h | 36 +++++++++++ examples/richtext/richtext.pro | 11 ++++ 6 files changed, 241 insertions(+) create mode 100644 examples/richtext/main.cpp create mode 100644 examples/richtext/marble.png create mode 100644 examples/richtext/richtext.cpp create mode 100644 examples/richtext/richtext.doc create mode 100644 examples/richtext/richtext.h create mode 100644 examples/richtext/richtext.pro (limited to 'examples/richtext') diff --git a/examples/richtext/main.cpp b/examples/richtext/main.cpp new file mode 100644 index 00000000..5e7ffff8 --- /dev/null +++ b/examples/richtext/main.cpp @@ -0,0 +1,24 @@ +/**************************************************************************** +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of an example program for TQt. This example +** program may be used, distributed and modified without limitation. +** +*****************************************************************************/ + +#include "richtext.h" +#include + +int main( int argc, char **argv ) +{ + TQApplication a( argc, argv ); + + MyRichText richtext; + richtext.resize( 450, 350 ); + richtext.setCaption( "TQt Example - Richtext" ); + a.setMainWidget( &richtext ); + richtext.show(); + + return a.exec(); +} diff --git a/examples/richtext/marble.png b/examples/richtext/marble.png new file mode 100644 index 00000000..5caf7eaa Binary files /dev/null and b/examples/richtext/marble.png differ diff --git a/examples/richtext/richtext.cpp b/examples/richtext/richtext.cpp new file mode 100644 index 00000000..e2b393ea --- /dev/null +++ b/examples/richtext/richtext.cpp @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of an example program for TQt. This example +** program may be used, distributed and modified without limitation. +** +*****************************************************************************/ + +#include "richtext.h" + +#include +#include +#include +#include +#include +#include + +static const char* 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
", + + 0 +}; + + +MyRichText::MyRichText( TQWidget *parent, const char *name ) + : TQVBox( parent, name ) +{ + setMargin( 5 ); + + view = new TQTextView( this ); + view->setText( "This is a Test with italic stuff" ); + TQBrush paper; + paper.setPixmap( TQPixmap( "../richtext/marble.png" ) ); + if ( paper.pixmap() != 0 ) + view->setPaper( paper ); + else + view->setPaper( white ); + + view->setText( sayings[0] ); + view->setMinimumSize( 450, 250 ); + + TQHBox *buttons = new TQHBox( this ); + buttons->setMargin( 5 ); + + bClose = new TQPushButton( "&Close", buttons ); + bPrev = new TQPushButton( "<< &Prev", buttons ); + bNext = new TQPushButton( "&Next >>", buttons ); + + bPrev->setEnabled( FALSE ); + + connect( bClose, SIGNAL( clicked() ), qApp, SLOT( tquit() ) ); + connect( bPrev, SIGNAL( clicked() ), this, SLOT( prev() ) ); + connect( bNext, SIGNAL( clicked() ), this, SLOT( next() ) ); + + num = 0; +} + +void MyRichText::prev() +{ + if ( num <= 0 ) + return; + + num--; + + view->setText( sayings[num] ); + + if ( num == 0 ) + bPrev->setEnabled( FALSE ); + + bNext->setEnabled( TRUE ); +} + +void MyRichText::next() +{ + if ( !sayings[++num] ) + return; + + view->setText( sayings[num] ); + + if ( !sayings[num + 1] ) + bNext->setEnabled( FALSE ); + + bPrev->setEnabled( TRUE ); +} + + + + + diff --git a/examples/richtext/richtext.doc b/examples/richtext/richtext.doc new file mode 100644 index 00000000..661e262c --- /dev/null +++ b/examples/richtext/richtext.doc @@ -0,0 +1,29 @@ +/* +*/ +/*! \page richtext-example.html + + \ingroup examples + \title Richtext + + In this example we demonstrate how to display rich text + in a widget. To do this some sayings taken from the famous + Unix "fortune" are displayed nicely formatted. + +
+ + Header file: + + \include richtext/richtext.h + +
+ + Implementation: + + \include richtext/richtext.cpp + +
+ + Main: + + \include richtext/main.cpp +*/ diff --git a/examples/richtext/richtext.h b/examples/richtext/richtext.h new file mode 100644 index 00000000..4c0baf75 --- /dev/null +++ b/examples/richtext/richtext.h @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of an example program for TQt. This example +** program may be used, distributed and modified without limitation. +** +*****************************************************************************/ + +#ifndef RICHTEXT_H +#define RICHTEXT_H + +#include + +class TQTextView; +class TQPushButton; + +class MyRichText : public TQVBox +{ + Q_OBJECT + +public: + MyRichText( TQWidget *parent = 0, const char *name = 0 ); + +protected: + TQTextView *view; + TQPushButton *bClose, *bNext, *bPrev; + int num; + +protected slots: + void prev(); + void next(); + +}; + +#endif diff --git a/examples/richtext/richtext.pro b/examples/richtext/richtext.pro new file mode 100644 index 00000000..b97b4abb --- /dev/null +++ b/examples/richtext/richtext.pro @@ -0,0 +1,11 @@ +TEMPLATE = app +TARGET = richtext + +CONFIG += qt warn_on release +DEPENDPATH = ../../include + +REQUIRES = medium-config + +HEADERS = richtext.h +SOURCES = main.cpp \ + richtext.cpp -- cgit v1.2.3