libyui-qt
Loading...
Searching...
No Matches
YQBarGraph.h
1/*
2 Copyright (C) 2000-2012 Novell, Inc
3 This library is free software; you can redistribute it and/or modify
4 it under the terms of the GNU Lesser General Public License as
5 published by the Free Software Foundation; either version 2.1 of the
6 License, or (at your option) version 3.0 of the License. This library
7 is distributed in the hope that it will be useful, but WITHOUT ANY
8 WARRANTY; without even the implied warranty of MERCHANTABILITY or
9 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10 License for more details. You should have received a copy of the GNU
11 Lesser General Public License along with this library; if not, write
12 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13 Floor, Boston, MA 02110-1301 USA
14*/
15
16
17/*-/
18
19 File: YQBarGraph.h
20
21 Author: Stefan Hundhammer <shundhammer@suse.de>
22
23/-*/
24
25
26#ifndef YQBarGraph_h
27#define YQBarGraph_h
28
29#include <QFrame>
30#include <QEvent>
31#include <QVector>
32#include <yui/YBarGraph.h>
33
34using namespace std;
35
36
37class YQBarGraph : public QFrame, public YBarGraph
38{
39 Q_OBJECT
40 Q_PROPERTY(QString BackgroundColors READ backgroundColors WRITE setBackgroundColors DESIGNABLE true)
41 Q_PROPERTY(QString ForegroundColors READ foregroundColors WRITE setForegroundColors DESIGNABLE true)
42
43public:
44
48 YQBarGraph( YWidget * parent );
49
53 virtual ~YQBarGraph();
54
60 virtual void doUpdate();
61
67 virtual void setEnabled( bool enabled );
68
74 virtual int preferredWidth();
75
81 virtual int preferredHeight();
82
88 virtual void setSize( int newWidth, int newHeight );
89
90
91protected:
92
96 virtual bool event( QEvent * event );
97
103 virtual void paintEvent( QPaintEvent * painter );
104
108 YColor defaultSegmentColor( unsigned index );
109
114 YColor defaultTextColor( unsigned index );
115
120 QString segmentText( unsigned index ) const;
121
128 int findSegment( int xPos ) const;
129
130
131 // QSS doesn't allow to store a list of QColors, that's the reason
132 // why we use QString and store the colors in the following format:
133 //
134 // YQBarGraph
135 // {
136 // qproperty-BackgroundColors: "#aabbcc,#bbccdd,#eeff00"";
137 // qproperty-ForegroundColors: "black,yellow,white";
138 // }
139
140 QString backgroundColors();
141 void setBackgroundColors( QString colors );
142
143 QString foregroundColors();
144 void setForegroundColors( QString colors );
145
146
147 //
148 // Data members
149 //
150
151
152 QString _foregroundColors;
153 QString _backgroundColors;
154
155 QVector<int> _segStart; // x position of each segment
156};
157
158
159#endif // YQBarGraph_h
Definition YQBarGraph.h:38
virtual bool event(QEvent *event)
Definition YQBarGraph.cc:98
virtual ~YQBarGraph()
Definition YQBarGraph.cc:55
virtual int preferredWidth()
Definition YQBarGraph.cc:281
virtual int preferredHeight()
Definition YQBarGraph.cc:307
YColor defaultSegmentColor(unsigned index)
Definition YQBarGraph.cc:207
virtual void setEnabled(bool enabled)
Definition YQBarGraph.cc:273
virtual void setSize(int newWidth, int newHeight)
Definition YQBarGraph.cc:333
virtual void paintEvent(QPaintEvent *painter)
Definition YQBarGraph.cc:114
int findSegment(int xPos) const
Definition YQBarGraph.cc:82
YColor defaultTextColor(unsigned index)
Definition YQBarGraph.cc:238
virtual void doUpdate()
Definition YQBarGraph.cc:62
QString segmentText(unsigned index) const
Definition YQBarGraph.cc:69