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/drawlines/README | 3 + examples/drawlines/connect.cpp | 132 +++++++++++++++++++++++++++++++++++++++ examples/drawlines/drawlines.doc | 20 ++++++ examples/drawlines/drawlines.pro | 9 +++ 4 files changed, 164 insertions(+) create mode 100644 examples/drawlines/README create mode 100644 examples/drawlines/connect.cpp create mode 100644 examples/drawlines/drawlines.doc create mode 100644 examples/drawlines/drawlines.pro (limited to 'examples/drawlines') diff --git a/examples/drawlines/README b/examples/drawlines/README new file mode 100644 index 000000000..2a7c577c6 --- /dev/null +++ b/examples/drawlines/README @@ -0,0 +1,3 @@ +The connect program connects points with lines. Drag the mouse +inside the widget and release it. It was inspired by an example in a +Windows book. diff --git a/examples/drawlines/connect.cpp b/examples/drawlines/connect.cpp new file mode 100644 index 000000000..cfd785ba7 --- /dev/null +++ b/examples/drawlines/connect.cpp @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** 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 +#include +#include +#include + + +const int MAXPOINTS = 2000; // maximum number of points +const int MAXCOLORS = 40; + + +// +// ConnectWidget - draws connected lines +// + +class ConnectWidget : public TQWidget +{ +public: + ConnectWidget( TQWidget *parent=0, const char *name=0 ); + ~ConnectWidget(); +protected: + void paintEvent( TQPaintEvent * ); + void mousePressEvent( TQMouseEvent *); + void mouseReleaseEvent( TQMouseEvent *); + void mouseMoveEvent( TQMouseEvent *); +private: + TQPoint *points; // point array + TQColor *colors; // color array + int count; // count = number of points + bool down; // TRUE if mouse down +}; + + +// +// Constructs a ConnectWidget. +// + +ConnectWidget::ConnectWidget( TQWidget *parent, const char *name ) + : TQWidget( parent, name, WStaticContents ) +{ + setBackgroundColor( white ); // white background + count = 0; + down = FALSE; + points = new TQPoint[MAXPOINTS]; + colors = new TQColor[MAXCOLORS]; + for ( int i=0; ipos(); // add point + paint.drawPoint( e->pos() ); // plot point + } +} + + +// +// Create and display a ConnectWidget. +// + +int main( int argc, char **argv ) +{ + TQApplication a( argc, argv ); + ConnectWidget connect; +#ifndef QT_NO_WIDGET_TOPEXTRA // for TQt/Embedded minimal build + connect.setCaption( "TQt Example - Draw lines"); +#endif + a.setMainWidget( &connect ); + connect.show(); + return a.exec(); +} diff --git a/examples/drawlines/drawlines.doc b/examples/drawlines/drawlines.doc new file mode 100644 index 000000000..f0abeec3b --- /dev/null +++ b/examples/drawlines/drawlines.doc @@ -0,0 +1,20 @@ + +/* +*/ +/*! \page drawlines-example.html + + \ingroup examples + \title Connect the Points + + This example shows very simple mouse-based user interaction and + painting without any world transform matrix or other advanced + features. Run the program, click the button, move the mouse, + release the button, and watch the lines get drawn. + +
+ + Implementation: + + \include drawlines/connect.cpp +*/ + diff --git a/examples/drawlines/drawlines.pro b/examples/drawlines/drawlines.pro new file mode 100644 index 000000000..7c4eeb8c1 --- /dev/null +++ b/examples/drawlines/drawlines.pro @@ -0,0 +1,9 @@ +TEMPLATE = app +TARGET = drawlines + +CONFIG += qt warn_on release +DEPENDPATH = ../../include + + +HEADERS = +SOURCES = connect.cpp -- cgit v1.2.1