Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

graph.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 
00021 #include <qframe.h>
00022 #include <qarray.h>
00023 #include <qstringlist.h>
00024 
00025 class GraphData
00026 {
00027 public:
00028     void clear();
00029     void addItem( const QString &name, int value );
00030 
00031     const QString &name( int i ) const { return names[i]; }
00032     int value( int i ) const { return values[i]; }
00033     unsigned count() const { return values.size(); }
00034 
00035 private:
00036     QStringList names;
00037     QArray<int> values;
00038 };
00039 
00040 class Graph : public QFrame
00041 {
00042     Q_OBJECT
00043 public:
00044     Graph( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
00045 
00046     void setData( const GraphData *p ) { data = p; }
00047 
00048 protected:
00049     const GraphData *data;
00050 };
00051 
00052 class PieGraph : public Graph
00053 {
00054     Q_OBJECT
00055 public:
00056     PieGraph( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
00057 
00058 protected:
00059     virtual void drawContents( QPainter *p );
00060 };
00061 
00062 class BarGraph : public Graph
00063 {
00064     Q_OBJECT
00065 public:
00066     BarGraph( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
00067 
00068 protected:
00069     virtual void drawContents( QPainter *p );
00070     void drawSegment( QPainter *p, const QRect &r, const QColor &c );
00071 };
00072 
00073 class GraphLegend : public QFrame
00074 {
00075     Q_OBJECT
00076 public:
00077     GraphLegend( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
00078 
00079     void setData( const GraphData *p );
00080     virtual QSize sizeHint() const;
00081     void setOrientation(Orientation o);
00082 
00083 protected:
00084     virtual void drawContents( QPainter *p );
00085 
00086 private:
00087     const GraphData *data;
00088     bool horz;
00089 };

Generated on Sat Nov 5 16:16:44 2005 for OPIE by  doxygen 1.4.2