/**************************************************************************** ** ** 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 TQT_NO_WIDGET_TOPEXTRA // for TQt/Embedded minimal build connect.setCaption( "TQt Example - Draw lines"); #endif a.setMainWidget( &connect ); connect.show(); return a.exec(); }