CPP   29

display.h

Guest on 19th August 2021 01:30:01 AM

  1. /****************************************************************************
  2. ** $Id: qt/display.h   3.3.6   edited Aug 31 $
  3. **
  4. ** Copyright (C) Trolltech AS.  All rights reserved.
  5. **
  6. ** This file is part of an example program for Qt.  This example
  7. ** program may be used, distributed and modified without limitation.
  8. **
  9. *****************************************************************************/
  10.  
  11. #ifndef DISPLAY_H
  12. #define DISPLAY_H
  13.  
  14. #ifndef QT_H
  15. #include <qwidget.h>
  16. #include <qframe.h>
  17. #endif // QT_H
  18.  
  19. class QTimer;
  20. class QDial;
  21. class QLCDNumber;
  22. class QProgressBar;
  23. class QSpinBox;
  24. class Screen;
  25. class Curve;
  26.  
  27. class DisplayWidget : public QWidget {
  28.     Q_OBJECT
  29. public:
  30.     DisplayWidget( QWidget *parent=0, const char *name=0 );
  31.  
  32.     void run();
  33.     void stop();
  34.  
  35. protected:
  36.     virtual void showEvent( QShowEvent * );
  37.     virtual void hideEvent( QHideEvent * );
  38.  
  39. private slots:
  40.     void tick();
  41.  
  42. private:
  43.     Screen *screen;
  44.     QDial *dial;
  45.     Curve *curve;
  46.     QSpinBox *spin;
  47.     QLCDNumber *lcd;
  48.     int lcdval;
  49.     QProgressBar *bar;
  50.     int tbar;
  51.     QTimer *timer;
  52. };
  53.  
  54. class Screen : public QFrame {
  55.     Q_OBJECT
  56. public:
  57.     enum { FrameWidth = 3 };
  58.     Screen( QWidget *parent=0, const char *name=0 );
  59.     ~Screen();
  60.    
  61.     void animate();
  62.  
  63. public slots:
  64.     void setStep( int s );
  65.  
  66. protected:
  67.     virtual void drawContents( QPainter * );
  68.     virtual void resizeEvent( QResizeEvent * );
  69.  
  70. private:
  71.     int *yval;
  72.     int pos0; // buffer pointer for x == 0
  73.     int t0;   // time parameter at x == 0
  74.     int step;
  75. };
  76.  
  77. class Curve : public QFrame {
  78.     Q_OBJECT
  79.     enum { FrameWidth = 3 };
  80. public:
  81.     Curve( QWidget *parent=0, const char *name=0 );
  82.  
  83.     void animate();
  84. public slots:
  85.     void setFactor( int );
  86.  
  87. protected:
  88.     virtual void drawContents( QPainter * );
  89.  
  90. private:
  91.     int shift, n;
  92. };
  93.  
  94. #endif // PLOT_H

Raw Paste


Login or Register to edit or fork this paste. It's free.