summaryrefslogtreecommitdiffstats
path: root/tdeprint/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tdeprint/tests')
-rw-r--r--tdeprint/tests/Makefile.am15
-rw-r--r--tdeprint/tests/back.xpm105
-rw-r--r--tdeprint/tests/drawdemo.cpp253
-rw-r--r--tdeprint/tests/drawdemo.h30
-rw-r--r--tdeprint/tests/forward.xpm110
-rw-r--r--tdeprint/tests/helpwindow.cpp351
-rw-r--r--tdeprint/tests/helpwindow.h65
-rw-r--r--tdeprint/tests/home.xpm119
-rw-r--r--tdeprint/tests/main.cpp41
-rw-r--r--tdeprint/tests/richpage.cpp85
-rw-r--r--tdeprint/tests/richpage.h24
11 files changed, 1198 insertions, 0 deletions
diff --git a/tdeprint/tests/Makefile.am b/tdeprint/tests/Makefile.am
new file mode 100644
index 000000000..53021a6e2
--- /dev/null
+++ b/tdeprint/tests/Makefile.am
@@ -0,0 +1,15 @@
+INCLUDES = -I$(top_srcdir)/tdeprint -I$(top_srcdir) $(all_includes)
+
+check_PROGRAMS = helpviewer drawdemo
+
+helpviewer_SOURCES = helpwindow.cpp main.cpp richpage.cpp
+helpviewer_METASOURCES = helpwindow.moc
+helpviewer_LDADD = $(top_builddir)/tdeprint/libtdeprint.la
+helpviewer_LDFLAGS = $(all_libraries)
+
+drawdemo_SOURCES = drawdemo.cpp
+drawdemo_METASOURCES = drawdemo.moc
+drawdemo_LDADD = $(top_builddir)/tdeprint/libtdeprint.la
+drawdemo_LDFLAGS = $(all_libraries)
+
+EXTRA_DIST = home.xpm back.xpm forward.xpm
diff --git a/tdeprint/tests/back.xpm b/tdeprint/tests/back.xpm
new file mode 100644
index 000000000..ac57ecd0b
--- /dev/null
+++ b/tdeprint/tests/back.xpm
@@ -0,0 +1,105 @@
+/* XPM */
+static char * back_xpm[] = {
+"16 16 86 1",
+" c None",
+". c #3269D2",
+"+ c #326CD7",
+"@ c #3472E5",
+"# c #5183E0",
+"$ c #5B88DC",
+"% c #3472E4",
+"& c #326BD4",
+"* c #3368CA",
+"= c #326AD3",
+"- c #4980E6",
+"; c #A8C2F5",
+"> c #E4EBF8",
+", c #F2F5FB",
+"' c #EBF0FA",
+") c #B9CCF0",
+"! c #5789E4",
+"~ c #3269CE",
+"{ c #326AD2",
+"] c #6494EC",
+"^ c #D4E0F4",
+"/ c #E1E9F8",
+"( c #ABC1EC",
+"_ c #DCE6F6",
+": c #799FE5",
+"< c #3269CF",
+"[ c #C4D4F1",
+"} c #CDDAF4",
+"| c #FFFFFF",
+"1 c #CBD9F3",
+"2 c #5A8AE3",
+"3 c #3467C4",
+"4 c #90B1EC",
+"5 c #B8CCEE",
+"6 c #EDF2FA",
+"7 c #B7CAEE",
+"8 c #97B3E4",
+"9 c #3873E0",
+"0 c #A1BAE9",
+"a c #A3BCEA",
+"b c #E7EEF9",
+"c c #95B1E6",
+"d c #4987F8",
+"e c #3B80FF",
+"f c #3471E3",
+"g c #4A7FE2",
+"h c #8CACE5",
+"i c #CEDFFF",
+"j c #3676EB",
+"k c #447CE5",
+"l c #6E99E8",
+"m c #B9CEF4",
+"n c #3C81FF",
+"o c #3776EB",
+"p c #3C66B6",
+"q c #3572E4",
+"r c #4686FC",
+"s c #D0E0FE",
+"t c #9DC0FF",
+"u c #6DA1FF",
+"v c #4083FF",
+"w c #4887FC",
+"x c #4888FC",
+"y c #D1E1FE",
+"z c #6CA0FF",
+"A c #4083FE",
+"B c #4486FC",
+"C c #4687FC",
+"D c #4A80E4",
+"E c #6696EE",
+"F c #D8E4FA",
+"G c #3766BE",
+"H c #346ACC",
+"I c #6C94E0",
+"J c #7EA3E6",
+"K c #DEE7F8",
+"L c #3469CB",
+"M c #356ACC",
+"N c #658EDB",
+"O c #8DACE7",
+"P c #8EADE8",
+"Q c #3569CA",
+"R c #3E71CF",
+"S c #5E88D5",
+"T c #6E95DC",
+"U c #3E70CF",
+" ",
+" .+@#$%&* ",
+" =-;>,,')!~ ",
+" {]^//((//_:~ ",
+" <-[}}(||(}}123 ",
+" &455(||655578= ",
+" 90a(||baaacdef ",
+" gh(||||||||iej ",
+" klm|||||||||nop",
+" qrrs||ittttuv% ",
+" &wxxy||znABCw= ",
+" *DEEEF||EEEEDG ",
+" HIJJJKKJJJIL ",
+" MNOPPPPONQ ",
+" 3RSTTSUG ",
+" p "};
diff --git a/tdeprint/tests/drawdemo.cpp b/tdeprint/tests/drawdemo.cpp
new file mode 100644
index 000000000..20fc3d12e
--- /dev/null
+++ b/tdeprint/tests/drawdemo.cpp
@@ -0,0 +1,253 @@
+/****************************************************************************
+** $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.
+**
+*****************************************************************************/
+
+#include <tqwidget.h>
+#include <tqpainter.h>
+#include <kprinter.h>
+#include <tqpushbutton.h>
+#include <tqradiobutton.h>
+#include <tqbuttongroup.h>
+#include <kapplication.h>
+#include <tqapplication.h>
+#include <math.h>
+
+
+//
+// This function draws a color wheel.
+// The coordinate system x=(0..500), y=(0..500) spans the paint device.
+//
+
+void drawColorWheel( TQPainter *p )
+{
+ TQFont f( "times", 18, TQFont::Bold );
+ p->setFont( f );
+ p->setPen( Qt::black );
+ p->setWindow( 0, 0, 500, 500 ); // defines coordinate system
+
+ for ( int i=0; i<36; i++ ) { // draws 36 rotated rectangles
+
+ TQWMatrix matrix;
+ matrix.translate( 250.0F, 250.0F ); // move to center
+ matrix.shear( 0.0F, 0.3F ); // twist it
+ matrix.rotate( (float)i*10 ); // rotate 0,10,20,.. degrees
+ p->setWorldMatrix( matrix ); // use this world matrix
+
+ TQColor c;
+ c.setHsv( i*10, 255, 255 ); // rainbow effect
+ p->setBrush( c ); // solid fill with color c
+ p->drawRect( 70, -10, 80, 10 ); // draw the rectangle
+
+ TQString n;
+ n.sprintf( "H=%d", i*10 );
+ p->drawText( 80+70+5, 0, n ); // draw the hue number
+ }
+}
+
+
+//
+// This function draws a few lines of text using different fonts.
+//
+
+void drawFonts( TQPainter *p )
+{
+ static const char *fonts[] = { "Helvetica", "Courier", "Times", 0 };
+ static int sizes[] = { 10, 12, 18, 24, 36, 0 };
+ int f = 0;
+ int y = 0;
+ while ( fonts[f] ) {
+ int s = 0;
+ while ( sizes[s] ) {
+ TQFont font( fonts[f], sizes[s] );
+ p->setFont( font );
+ TQFontMetrics fm = p->fontMetrics();
+ y += fm.ascent();
+ p->drawText( 10, y, "Quartz Glyph Job Vex'd Cwm Finks" );
+ y += fm.descent();
+ s++;
+ }
+ f++;
+ }
+}
+
+
+//
+// This function draws some tqshapes
+//
+
+void drawShapes( TQPainter *p )
+{
+ TQBrush b1( Qt::blue );
+ TQBrush b2( Qt::green, Qt::Dense6Pattern ); // green 12% fill
+ TQBrush b3( Qt::NoBrush ); // void brush
+ TQBrush b4( Qt::CrossPattern ); // black cross pattern
+
+ p->setPen( Qt::red );
+ p->setBrush( b1 );
+ p->drawRect( 10, 10, 200, 100 );
+ p->setBrush( b2 );
+ p->drawRoundRect( 10, 150, 200, 100, 20, 20 );
+ p->setBrush( b3 );
+ p->drawEllipse( 250, 10, 200, 100 );
+ p->setBrush( b4 );
+ p->drawPie( 250, 150, 200, 100, 45*16, 90*16 );
+}
+
+
+typedef void (*draw_func)(TQPainter*);
+
+struct DrawThing {
+ draw_func f;
+ const char *name;
+};
+
+//
+// You can add your draw function here.
+// Leave the zeros at the end of the array!
+//
+
+DrawThing ourDrawFunctions[] = {
+ { drawColorWheel, "Draw color wheel" },
+ { drawFonts, "Draw fonts" },
+ { drawShapes, "Draw tqshapes" },
+ { 0, 0 } };
+
+
+#include "drawdemo.h"
+
+//
+// Construct the DrawView with buttons.
+//
+
+DrawView::DrawView()
+{
+ setCaption( "Qt Draw Demo Application" );
+ setBackgroundColor( white );
+
+ // Create a button group to contain all buttons
+ bgroup = new TQButtonGroup( this );
+ bgroup->resize( 200, 200 );
+ connect( bgroup, TQT_SIGNAL(clicked(int)), TQT_SLOT(updateIt(int)) );
+
+ // Calculate the size for the radio buttons
+ int maxwidth = 80;
+ int i;
+ const char *n;
+ TQFontMetrics fm = bgroup->fontMetrics();
+ for ( i=0; (n=ourDrawFunctions[i].name) != 0; i++ ) {
+ int w = fm.width( n );
+ maxwidth = QMAX(w,maxwidth);
+ }
+ maxwidth = maxwidth + 20; // add 20 pixels
+
+ for ( i=0; (n=ourDrawFunctions[i].name) != 0; i++ ) {
+ TQRadioButton *rb = new TQRadioButton( n, bgroup );
+ rb->setGeometry( 10, i*30+10, maxwidth, 30 );
+ if ( i == 0 )
+ rb->setChecked( true );
+ }
+
+ drawindex = 0; // draw first thing
+ maxindex = i;
+
+ maxwidth += 40; // now size of bgroup
+
+ printer = new KPrinter;
+
+ // Create and setup the print button
+ print = new TQPushButton( "Print...", bgroup );
+ print->resize( 80, 30 );
+ print->move( maxwidth/2 - print->width()/2, maxindex*30+20 );
+ connect( print, TQT_SIGNAL(clicked()), TQT_SLOT(printIt()) );
+
+ bgroup->resize( maxwidth, print->y()+print->height()+10 );
+
+ resize( 640,300 );
+}
+
+//
+// Clean up
+//
+DrawView::~DrawView()
+{
+#ifndef QT_NO_PRINTER
+ delete printer;
+#endif
+}
+
+//
+// Called when a radio button is clicked.
+//
+
+void DrawView::updateIt( int index )
+{
+ if ( index < maxindex ) {
+ drawindex = index;
+ update();
+ }
+}
+
+//
+// Calls the drawing function as specified by the radio buttons.
+//
+
+void DrawView::drawIt( TQPainter *p )
+{
+ (*ourDrawFunctions[drawindex].f)(p);
+}
+
+//
+// Called when the print button is clicked.
+//
+
+void DrawView::printIt()
+{
+#ifndef QT_NO_PRINTER
+ if ( printer->setup( this ) ) {
+ TQPainter paint( printer );
+ drawIt( &paint );
+ }
+#endif
+}
+
+//
+// Called when the widget needs to be updated.
+//
+
+void DrawView::paintEvent( TQPaintEvent * )
+{
+ TQPainter paint( this );
+ drawIt( &paint );
+}
+
+//
+// Called when the widget has been resized.
+// Moves the button group to the upper right corner
+// of the widget.
+
+void DrawView::resizeEvent( TQResizeEvent * )
+{
+ bgroup->move( width()-bgroup->width(), 0 );
+}
+
+
+//
+// Create and display our widget.
+//
+
+#include "drawdemo.moc"
+
+int main( int argc, char **argv )
+{
+ KApplication app( argc, argv, "drawdemo" );
+ DrawView draw;
+ app.setMainWidget( &draw );
+ draw.show();
+ return app.exec();
+}
diff --git a/tdeprint/tests/drawdemo.h b/tdeprint/tests/drawdemo.h
new file mode 100644
index 000000000..963da64db
--- /dev/null
+++ b/tdeprint/tests/drawdemo.h
@@ -0,0 +1,30 @@
+#ifndef DRAWDEMO_H
+#define DRAWDEMO_H
+
+//
+// DrawView has installable draw routines, just add a function pointer
+// and a text in the table above.
+//
+
+class DrawView : public TQWidget
+{
+ Q_OBJECT
+public:
+ DrawView();
+ ~DrawView();
+public slots:
+ void updateIt( int );
+ void printIt();
+protected:
+ void drawIt( TQPainter * );
+ void paintEvent( TQPaintEvent * );
+ void resizeEvent( TQResizeEvent * );
+private:
+ KPrinter *printer;
+ TQButtonGroup *bgroup;
+ QPushButton *print;
+ int drawindex;
+ int maxindex;
+};
+
+#endif
diff --git a/tdeprint/tests/forward.xpm b/tdeprint/tests/forward.xpm
new file mode 100644
index 000000000..7eadb1474
--- /dev/null
+++ b/tdeprint/tests/forward.xpm
@@ -0,0 +1,110 @@
+/* XPM */
+static char * forward_xpm[] = {
+"16 16 91 1",
+" c None",
+". c #3269D2",
+"+ c #326CD7",
+"@ c #3472E5",
+"# c #5183E0",
+"$ c #5B88DC",
+"% c #3472E4",
+"& c #326BD4",
+"* c #3368CA",
+"= c #326AD3",
+"- c #4980E6",
+"; c #A8C2F5",
+"> c #E4EBF8",
+", c #F2F5FB",
+"' c #EBF0FA",
+") c #B9CCF0",
+"! c #5789E4",
+"~ c #3269CE",
+"{ c #326AD2",
+"] c #6494EC",
+"^ c #D4E0F4",
+"/ c #E1E9F8",
+"( c #AAC4F4",
+"_ c #DCE6F6",
+": c #799FE5",
+"< c #3269CF",
+"[ c #C4D4F1",
+"} c #CDDAF4",
+"| c #FFFFFF",
+"1 c #A5C1F4",
+"2 c #CBD9F3",
+"3 c #5A8AE3",
+"4 c #3467C4",
+"5 c #90B1EC",
+"6 c #B8CCEE",
+"7 c #ECF1FA",
+"8 c #A0BDF2",
+"9 c #B7CAEE",
+"0 c #97B3E4",
+"a c #3873E0",
+"b c #A1BAE9",
+"c c #94B2EB",
+"d c #85A9EC",
+"e c #D8E4FA",
+"f c #95B4EF",
+"g c #4987F8",
+"h c #3B80FF",
+"i c #3471E3",
+"j c #4A7FE2",
+"k c #8CACE5",
+"l c #6CA0FF",
+"m c #3676EB",
+"n c #447CE5",
+"o c #6E99E8",
+"p c #9EC0FF",
+"q c #3C81FF",
+"r c #3776EB",
+"s c #3C66B6",
+"t c #3572E4",
+"u c #4686FC",
+"v c #73A4FD",
+"w c #A0C2FE",
+"x c #A0C2FF",
+"y c #CEE0FF",
+"z c #3D82FF",
+"A c #4083FF",
+"B c #4887FC",
+"C c #4888FC",
+"D c #4084FF",
+"E c #6DA0FF",
+"F c #D2E2FE",
+"G c #4486FC",
+"H c #4687FC",
+"I c #4A80E4",
+"J c #6696EE",
+"K c #DAE6FA",
+"L c #3766BE",
+"M c #346ACC",
+"N c #6C94E0",
+"O c #7EA3E6",
+"P c #E0E9F9",
+"Q c #3469CB",
+"R c #356ACC",
+"S c #658EDB",
+"T c #8DACE7",
+"U c #8EADE8",
+"V c #3569CA",
+"W c #3E71CF",
+"X c #5E88D5",
+"Y c #6E95DC",
+"Z c #3E70CF",
+" ",
+" .+@#$%&* ",
+" =-;>,,')!~ ",
+" {]^//((//_:~ ",
+" <-[}}}||1}}234 ",
+" &566667||8690= ",
+" abcdddde||fghi ",
+" jke||||||||lhm ",
+" no|||||||||pqrs",
+" tuvwxxpy||yzA% ",
+" &BCCCDE||FGHB= ",
+" *IJJJJ||KJJJIL ",
+" MNOOOPPOOONQ ",
+" RSTUUUUTSV ",
+" 4WXYYXZL ",
+" s "};
diff --git a/tdeprint/tests/helpwindow.cpp b/tdeprint/tests/helpwindow.cpp
new file mode 100644
index 000000000..bee755d20
--- /dev/null
+++ b/tdeprint/tests/helpwindow.cpp
@@ -0,0 +1,351 @@
+/****************************************************************************
+** $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.
+**
+*****************************************************************************/
+
+#include "helpwindow.h"
+#include "richpage.h"
+#include <tqstatusbar.h>
+#include <tqpixmap.h>
+#include <tqpopupmenu.h>
+#include <kmenubar.h>
+#include <ktoolbar.h>
+#include <kstatusbar.h>
+#include <tqtoolbutton.h>
+#include <tqiconset.h>
+#include <tqfile.h>
+#include <tqtextstream.h>
+#include <tqstylesheet.h>
+#include <tqmessagebox.h>
+#include <tqfiledialog.h>
+#include <tqapplication.h>
+#include <tqcombobox.h>
+#include <tqevent.h>
+#include <tqlineedit.h>
+#include <tqobjectlist.h>
+#include <tqfileinfo.h>
+#include <tqdatastream.h>
+#include <kprinter.h>
+#include <tqsimplerichtext.h>
+#include <tqpainter.h>
+#include <tqpaintdevicemetrics.h>
+
+#include <ctype.h>
+
+HelpWindow::HelpWindow( const TQString& home_, const TQString& _path,
+ TQWidget* parent, const char *name )
+ : KMainWindow( parent, name, WDestructiveClose ),
+ pathCombo( 0 ), selectedURL()
+{
+ readHistory();
+ readBookmarks();
+
+ browser = new TQTextBrowser( this );
+ browser->mimeSourceFactory()->setFilePath( _path );
+ browser->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
+ connect( browser, TQT_SIGNAL( textChanged() ),
+ this, TQT_SLOT( textChanged() ) );
+
+ setCentralWidget( browser );
+
+ if ( !home_.isEmpty() )
+ browser->setSource( home_ );
+
+ connect( browser, TQT_SIGNAL( highlighted( const TQString&) ),
+ statusBar(), TQT_SLOT( message( const TQString&)) );
+
+ resize( 640,700 );
+
+ TQPopupMenu* file = new TQPopupMenu( this );
+ file->insertItem( "&New Window", this, TQT_SLOT( newWindow() ), ALT | Key_N );
+ file->insertItem( "&Open File", this, TQT_SLOT( openFile() ), ALT | Key_O );
+ file->insertItem( "&Print", this, TQT_SLOT( print() ), ALT | Key_P );
+ file->insertSeparator();
+ file->insertItem( "&Close", this, TQT_SLOT( close() ), ALT | Key_Q );
+ file->insertItem( "E&xit", tqApp, TQT_SLOT( closeAllWindows() ), ALT | Key_X );
+
+ // The same three icons are used twice each.
+ TQIconSet icon_back( TQPixmap("back.xpm") );
+ TQIconSet icon_forward( TQPixmap("forward.xpm") );
+ TQIconSet icon_home( TQPixmap("home.xpm") );
+
+ TQPopupMenu* go = new TQPopupMenu( this );
+ backwardId = go->insertItem( icon_back,
+ "&Backward", browser, TQT_SLOT( backward() ),
+ ALT | Key_Left );
+ forwardId = go->insertItem( icon_forward,
+ "&Forward", browser, TQT_SLOT( forward() ),
+ ALT | Key_Right );
+ go->insertItem( icon_home, "&Home", browser, TQT_SLOT( home() ) );
+
+ TQPopupMenu* help = new TQPopupMenu( this );
+ help->insertItem( "&About ...", this, TQT_SLOT( about() ) );
+ help->insertItem( "About &Qt ...", this, TQT_SLOT( aboutQt() ) );
+
+ hist = new TQPopupMenu( this );
+ TQStringList::Iterator it = history.begin();
+ for ( ; it != history.end(); ++it )
+ mHistory[ hist->insertItem( *it ) ] = *it;
+ connect( hist, TQT_SIGNAL( activated( int ) ),
+ this, TQT_SLOT( histChosen( int ) ) );
+
+ bookm = new TQPopupMenu( this );
+ bookm->insertItem( tr( "Add Bookmark" ), this, TQT_SLOT( addBookmark() ) );
+ bookm->insertSeparator();
+
+ TQStringList::Iterator it2 = bookmarks.begin();
+ for ( ; it2 != bookmarks.end(); ++it2 )
+ mBookmarks[ bookm->insertItem( *it2 ) ] = *it2;
+ connect( bookm, TQT_SIGNAL( activated( int ) ),
+ this, TQT_SLOT( bookmChosen( int ) ) );
+
+ menuBar()->insertItem( tr("&File"), file );
+ menuBar()->insertItem( tr("&Go"), go );
+ menuBar()->insertItem( tr( "History" ), hist );
+ menuBar()->insertItem( tr( "Bookmarks" ), bookm );
+ menuBar()->insertSeparator();
+ menuBar()->insertItem( tr("&Help"), help );
+
+ menuBar()->setItemEnabled( forwardId, false);
+ menuBar()->setItemEnabled( backwardId, false);
+ connect( browser, TQT_SIGNAL( backwardAvailable( bool ) ),
+ this, TQT_SLOT( setBackwardAvailable( bool ) ) );
+ connect( browser, TQT_SIGNAL( forwardAvailable( bool ) ),
+ this, TQT_SLOT( setForwardAvailable( bool ) ) );
+
+
+ TQToolBar* toolbar = new TQToolBar( this );
+ addToolBar( toolbar, "Toolbar");
+ TQToolButton* button;
+
+ button = new TQToolButton( icon_back, tr("Backward"), "", browser, TQT_SLOT(backward()), toolbar );
+ connect( browser, TQT_SIGNAL( backwardAvailable(bool) ), button, TQT_SLOT( setEnabled(bool) ) );
+ button->setEnabled( false );
+ button = new TQToolButton( icon_forward, tr("Forward"), "", browser, TQT_SLOT(forward()), toolbar );
+ connect( browser, TQT_SIGNAL( forwardAvailable(bool) ), button, TQT_SLOT( setEnabled(bool) ) );
+ button->setEnabled( false );
+ button = new TQToolButton( icon_home, tr("Home"), "", browser, TQT_SLOT(home()), toolbar );
+
+ toolbar->addSeparator();
+
+ pathCombo = new TQComboBox( true, toolbar );
+ connect( pathCombo, TQT_SIGNAL( activated( const TQString & ) ),
+ this, TQT_SLOT( pathSelected( const TQString & ) ) );
+ toolbar->setStretchableWidget( pathCombo );
+ setRightJustification( true );
+ setDockEnabled( DockLeft, false );
+ setDockEnabled( DockRight, false );
+
+ pathCombo->insertItem( home_ );
+
+ browser->setFocus();
+}
+
+
+void HelpWindow::setBackwardAvailable( bool b)
+{
+ menuBar()->setItemEnabled( backwardId, b);
+}
+
+void HelpWindow::setForwardAvailable( bool b)
+{
+ menuBar()->setItemEnabled( forwardId, b);
+}
+
+
+void HelpWindow::textChanged()
+{
+ if ( browser->documentTitle().isNull() )
+ setCaption( browser->context() );
+ else
+ setCaption( browser->documentTitle() ) ;
+
+ selectedURL = caption();
+ if ( !selectedURL.isEmpty() && pathCombo ) {
+ bool exists = false;
+ int i;
+ for ( i = 0; i < pathCombo->count(); ++i ) {
+ if ( pathCombo->text( i ) == selectedURL ) {
+ exists = true;
+ break;
+ }
+ }
+ if ( !exists ) {
+ pathCombo->insertItem( selectedURL, 0 );
+ pathCombo->setCurrentItem( 0 );
+ mHistory[ hist->insertItem( selectedURL ) ] = selectedURL;
+ } else
+ pathCombo->setCurrentItem( i );
+ selectedURL = TQString::null;
+ }
+}
+
+HelpWindow::~HelpWindow()
+{
+ history.clear();
+ TQMap<int, TQString>::Iterator it = mHistory.begin();
+ for ( ; it != mHistory.end(); ++it )
+ history.append( *it );
+
+ TQFile f( TQDir::currentDirPath() + "/.history" );
+ f.open( IO_WriteOnly );
+ TQDataStream s( &f );
+ s << history;
+ f.close();
+
+ bookmarks.clear();
+ TQMap<int, TQString>::Iterator it2 = mBookmarks.begin();
+ for ( ; it2 != mBookmarks.end(); ++it2 )
+ bookmarks.append( *it2 );
+
+ TQFile f2( TQDir::currentDirPath() + "/.bookmarks" );
+ f2.open( IO_WriteOnly );
+ TQDataStream s2( &f2 );
+ s2 << bookmarks;
+ f2.close();
+}
+
+void HelpWindow::about()
+{
+ TQMessageBox::about( this, "HelpViewer Example",
+ "<p>This example implements a simple HTML help viewer "
+ "using Qt's rich text capabilities</p>"
+ "<p>It's just about 100 lines of C++ code, so don't expect too much :-)</p>"
+ );
+}
+
+
+void HelpWindow::aboutQt()
+{
+ TQMessageBox::aboutQt( this, "QBrowser" );
+}
+
+void HelpWindow::openFile()
+{
+#ifndef QT_NO_FILEDIALOG
+ TQString fn = TQFileDialog::getOpenFileName( TQString::null, TQString::null, this );
+ if ( !fn.isEmpty() )
+ browser->setSource( fn );
+#endif
+}
+
+void HelpWindow::newWindow()
+{
+ ( new HelpWindow(browser->source(), "qbrowser") )->show();
+}
+
+#define KDE_PRINT
+void HelpWindow::print()
+{
+#ifdef KDE_PRINT
+ KPrinter printer;
+#else
+ TQPrinter printer;
+#endif
+ printer.setFullPage(true);
+ printer.setDocName("Help Viewer");
+ printer.setDocFileName("my_document");
+#ifdef KDE_PRINT
+ printer.addDialogPage(new RichPage());
+ printer.addStandardPage(KPrinter::FilesPage);
+#endif
+ if ( printer.setup(this) ) {
+ TQPainter p( &printer );
+ TQPaintDeviceMetrics metrics(p.device());
+ int dpix = metrics.logicalDpiX();
+ int dpiy = metrics.logicalDpiY();
+#ifdef KDE_PRINT
+ const int margin = printer.option("app-rich-margin").toInt(); // pt
+#else
+ const int margin = 72; // pt
+#endif
+ TQRect body(margin*dpix/72, margin*dpiy/72,
+ metrics.width()-margin*dpix/72*2,
+ metrics.height()-margin*dpiy/72*2 );
+#ifdef KDE_PRINT
+ TQFont font(printer.option("app-rich-fontname"), printer.option("app-rich-fontsize").toInt());
+#else
+ TQFont font("times",10);
+#endif
+ TQSimpleRichText richText( browser->text(), font, browser->context(), browser->styleSheet(),
+ browser->mimeSourceFactory(), body.height() );
+ richText.setWidth( &p, body.width() );
+ TQRect view( body );
+ int page = 1;
+ do {
+ richText.draw( &p, body.left(), body.top(), view, tqcolorGroup() );
+ view.moveBy( 0, body.height() );
+ p.translate( 0 , -body.height() );
+ p.setFont( font );
+ p.drawText( view.right() - p.fontMetrics().width( TQString::number(page) ),
+ view.bottom() + p.fontMetrics().ascent() + 5, TQString::number(page) );
+ if ( view.top() >= richText.height() )
+ break;
+ printer.newPage();
+ page++;
+ } while (true);
+ }
+}
+
+void HelpWindow::pathSelected( const TQString &_path )
+{
+ browser->setSource( _path );
+ TQMap<int, TQString>::Iterator it = mHistory.begin();
+ bool exists = false;
+ for ( ; it != mHistory.end(); ++it ) {
+ if ( *it == _path ) {
+ exists = true;
+ break;
+ }
+ }
+ if ( !exists )
+ mHistory[ hist->insertItem( _path ) ] = _path;
+}
+
+void HelpWindow::readHistory()
+{
+ if ( TQFile::exists( TQDir::currentDirPath() + "/.history" ) ) {
+ TQFile f( TQDir::currentDirPath() + "/.history" );
+ f.open( IO_ReadOnly );
+ TQDataStream s( &f );
+ s >> history;
+ f.close();
+ while ( history.count() > 20 )
+ history.remove( history.begin() );
+ }
+}
+
+void HelpWindow::readBookmarks()
+{
+ if ( TQFile::exists( TQDir::currentDirPath() + "/.bookmarks" ) ) {
+ TQFile f( TQDir::currentDirPath() + "/.bookmarks" );
+ f.open( IO_ReadOnly );
+ TQDataStream s( &f );
+ s >> bookmarks;
+ f.close();
+ }
+}
+
+void HelpWindow::histChosen( int i )
+{
+ if ( mHistory.contains( i ) )
+ browser->setSource( mHistory[ i ] );
+}
+
+void HelpWindow::bookmChosen( int i )
+{
+ if ( mBookmarks.contains( i ) )
+ browser->setSource( mBookmarks[ i ] );
+}
+
+void HelpWindow::addBookmark()
+{
+ mBookmarks[ bookm->insertItem( caption() ) ] = caption();
+}
+
+#include "helpwindow.moc"
diff --git a/tdeprint/tests/helpwindow.h b/tdeprint/tests/helpwindow.h
new file mode 100644
index 000000000..c444b8144
--- /dev/null
+++ b/tdeprint/tests/helpwindow.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+** $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.
+**
+*****************************************************************************/
+
+#ifndef HELPWINDOW_H
+#define HELPWINDOW_H
+
+#include <kmainwindow.h>
+#include <tqtextbrowser.h>
+#include <tqstringlist.h>
+#include <tqmap.h>
+#include <tqdir.h>
+
+class TQComboBox;
+class TQPopupMenu;
+
+class HelpWindow : public KMainWindow
+{
+ Q_OBJECT
+public:
+ HelpWindow( const TQString& home_, const TQString& path, TQWidget* parent = 0, const char *name=0 );
+ ~HelpWindow();
+
+private slots:
+ void setBackwardAvailable( bool );
+ void setForwardAvailable( bool );
+
+ void textChanged();
+ void about();
+ void aboutQt();
+ void openFile();
+ void newWindow();
+ void print();
+
+ void pathSelected( const TQString & );
+ void histChosen( int );
+ void bookmChosen( int );
+ void addBookmark();
+
+private:
+ void readHistory();
+ void readBookmarks();
+
+ TQTextBrowser* browser;
+ TQComboBox *pathCombo;
+ int backwardId, forwardId;
+ TQString selectedURL;
+ TQStringList history, bookmarks;
+ TQMap<int, TQString> mHistory, mBookmarks;
+ TQPopupMenu *hist, *bookm;
+
+};
+
+
+
+
+
+#endif
+
diff --git a/tdeprint/tests/home.xpm b/tdeprint/tests/home.xpm
new file mode 100644
index 000000000..1cb22447f
--- /dev/null
+++ b/tdeprint/tests/home.xpm
@@ -0,0 +1,119 @@
+/* XPM */
+static char * home_xpm[] = {
+"16 16 100 2",
+" c None",
+". c #3269D2",
+"+ c #326CD7",
+"@ c #3472E5",
+"# c #5183E0",
+"$ c #5B88DC",
+"% c #3472E4",
+"& c #326BD4",
+"* c #3368CA",
+"= c #326AD3",
+"- c #4980E6",
+"; c #A8C2F5",
+"> c #E4EBF8",
+", c #F2F5FB",
+"' c #EBF0FA",
+") c #B9CCF0",
+"! c #5789E4",
+"~ c #3269CE",
+"{ c #326AD2",
+"] c #6494EC",
+"^ c #D4E0F4",
+"/ c #E1E9F8",
+"( c #A3BCEA",
+"_ c #DCE6F6",
+": c #799FE5",
+"< c #3269CF",
+"[ c #C4D4F1",
+"} c #CDDAF4",
+"| c #FDFDFE",
+"1 c #DDE6F7",
+"2 c #CBD9F3",
+"3 c #5A8AE3",
+"4 c #3467C4",
+"5 c #90B1EC",
+"6 c #B8CCEE",
+"7 c #D5E1F5",
+"8 c #FFFFFF",
+"9 c #FBFCFE",
+"0 c #CEDCF3",
+"a c #B7CAEE",
+"b c #97B3E4",
+"c c #3873E0",
+"d c #A1BAE9",
+"e c #C9D8F2",
+"f c #FCFDFE",
+"g c #B5C8ED",
+"h c #4987F8",
+"i c #3B80FF",
+"j c #3471E3",
+"k c #4A7FE2",
+"l c #8CACE5",
+"m c #8FADE6",
+"n c #BFD0F0",
+"o c #FAFCFE",
+"p c #79A9FF",
+"q c #3676EB",
+"r c #447CE5",
+"s c #6E99E8",
+"t c #9BB8EF",
+"u c #F5F9FF",
+"v c #6098FF",
+"w c #3776EB",
+"x c #3C66B6",
+"y c #3572E4",
+"z c #4686FC",
+"A c #4E8BFC",
+"B c #5D95FC",
+"C c #C2D7FE",
+"D c #9DC0FF",
+"E c #AAC8FF",
+"F c #5591FF",
+"G c #4586FF",
+"H c #4887FC",
+"I c #4888FC",
+"J c #BAD2FD",
+"K c #3C81FF",
+"L c #A1C2FD",
+"M c #4687FC",
+"N c #4A80E4",
+"O c #6696EE",
+"P c #C6D7F8",
+"Q c #B2CAF6",
+"R c #3766BE",
+"S c #346ACC",
+"T c #6C94E0",
+"U c #7EA3E6",
+"V c #B0C7EF",
+"W c #CEDCF5",
+"X c #C0D2F2",
+"Y c #A6BFED",
+"Z c #3469CB",
+"` c #356ACC",
+" . c #658EDB",
+".. c #8DACE7",
+"+. c #8EADE8",
+"@. c #3569CA",
+"#. c #3E71CF",
+"$. c #5E88D5",
+"%. c #6E95DC",
+"&. c #3E70CF",
+" ",
+" . + @ # $ % & * ",
+" = - ; > , , ' ) ! ~ ",
+" { ] ^ / / ( ( ( / _ : ~ ",
+" < - [ } } ( / | 1 ( } 2 3 4 ",
+" & 5 6 6 ( 7 | 8 9 0 ( a b = ",
+" c d ( ( e | 8 8 8 f g h i j ",
+" k l m n 8 8 8 8 8 8 o p i q ",
+" r s t f 8 8 8 8 8 8 8 u v w x ",
+" y z A B C 8 8 D D 8 E F G % ",
+" & H I I J 8 8 K K 8 L M H = ",
+" * N O O P 8 8 O O 8 Q O N R ",
+" S T U V W X U U W Y T Z ",
+" ` ...+.+.+.+... .@. ",
+" 4 #.$.%.%.$.&.R ",
+" x "};
diff --git a/tdeprint/tests/main.cpp b/tdeprint/tests/main.cpp
new file mode 100644
index 000000000..a1dc6b5e0
--- /dev/null
+++ b/tdeprint/tests/main.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+** $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.
+**
+*****************************************************************************/
+
+#include "helpwindow.h"
+#include <kapplication.h>
+#include <tqwindowsstyle.h>
+#include <tqstylesheet.h>
+#include <stdlib.h>
+
+
+int main( int argc, char ** argv )
+{
+ KApplication a(argc, argv, "helpviewer");
+
+ TQString home;
+ if (argc > 1)
+ home = argv[1];
+ else
+ home = TQString(getenv("QTDIR")) + "/doc/html/index.html";
+
+
+ HelpWindow *help = new HelpWindow(home, ".", 0, "help viewer");
+
+ if ( TQApplication::desktop()->width() > 400
+ && TQApplication::desktop()->height() > 500 )
+ help->show();
+ else
+ help->showMaximized();
+
+ TQObject::connect( &a, TQT_SIGNAL(lastWindowClosed()),
+ &a, TQT_SLOT(quit()) );
+
+ return a.exec();
+}
diff --git a/tdeprint/tests/richpage.cpp b/tdeprint/tests/richpage.cpp
new file mode 100644
index 000000000..30da712de
--- /dev/null
+++ b/tdeprint/tests/richpage.cpp
@@ -0,0 +1,85 @@
+#include "richpage.h"
+
+#include <tqlabel.h>
+#include <tqspinbox.h>
+#include <tqcombobox.h>
+#include <tqfontdatabase.h>
+#include <tqlayout.h>
+
+RichPage::RichPage(TQWidget *parent, const char *name)
+: KPrintDialogPage(parent,name)
+{
+ m_title = "Rich Text Options";
+
+ margin_ = new TQSpinBox(this);
+ margin_->setRange(1,999);
+ margin_->setValue(72);
+
+ fontsize_ = new TQSpinBox(this);
+ fontsize_->setRange(4,100);
+ fontsize_->setValue(10);
+
+ fontname_ = new TQComboBox(this);
+ QFontDatabase db;
+ QStringList fonts = db.families();
+ fontname_->insertStringList(fonts);
+ fontname_->setCurrentItem(fonts.findIndex(TQString::tqfromLatin1("times")));
+ if (fontname_->currentItem() < 0) fontname_->setCurrentItem(0);
+
+ QLabel *l1 = new TQLabel("Margin:",this);
+ QLabel *l2 = new TQLabel("Font name:",this);
+ QLabel *l3 = new TQLabel("Font size:",this);
+
+ QHBoxLayout *s1 = new TQHBoxLayout(0, 0, 10);
+ QHBoxLayout *s2 = new TQHBoxLayout(0, 0, 10);
+ QVBoxLayout *main_ = new TQVBoxLayout(this, 10, 10);
+
+ main_->addLayout(s1,0);
+ main_->addSpacing(20);
+ main_->addLayout(s2,0);
+ main_->addStretch(1);
+
+ s1->addWidget(l1,0);
+ s1->addWidget(margin_,0);
+ s1->addStretch(1);
+
+ s2->addWidget(l2,0);
+ s2->addWidget(fontname_,0);
+ s2->addSpacing(20);
+ s2->addWidget(l3,0);
+ s2->addWidget(fontsize_,0);
+ s2->addStretch(1);
+}
+
+RichPage::~RichPage()
+{
+}
+
+void RichPage::setOptions(const TQMap<TQString,TQString>& opts)
+{
+ QString value;
+
+ value = opts["app-rich-margin"];
+ if (!value.isEmpty())
+ margin_->setValue(value.toInt());
+
+ value = opts["app-rich-fontname"];
+ if (!value.isEmpty())
+ for (int i=0;i<fontname_->count();i++)
+ if (fontname_->text(i) == value)
+ {
+ fontname_->setCurrentItem(i);
+ break;
+ }
+
+ value = opts["app-rich-fontsize"];
+ if (!value.isEmpty())
+ fontsize_->setValue(value.toInt());
+}
+
+void RichPage::getOptions(TQMap<TQString,TQString>& opts, bool)
+{
+ opts["app-rich-margin"] = margin_->text();
+ opts["app-rich-fontname"] = fontname_->currentText();
+ opts["app-rich-fontsize"] = fontsize_->text();
+}
diff --git a/tdeprint/tests/richpage.h b/tdeprint/tests/richpage.h
new file mode 100644
index 000000000..33e4304e7
--- /dev/null
+++ b/tdeprint/tests/richpage.h
@@ -0,0 +1,24 @@
+#ifndef RICHPAGE_H
+#define RICHPAGE_H
+
+#include <kprintdialogpage.h>
+
+class TQSpinBox;
+class TQComboBox;
+
+class RichPage : public KPrintDialogPage
+{
+public:
+ RichPage(TQWidget *parent = 0, const char *name = 0);
+ ~RichPage();
+
+ void setOptions(const TQMap<TQString,TQString>& opts);
+ void getOptions(TQMap<TQString,TQString>& opts, bool incldef = false);
+
+private:
+ QSpinBox *margin_;
+ QComboBox *fontname_;
+ QSpinBox *fontsize_;
+};
+
+#endif