diff options
author | Fritz Elfert <felfert@to.com> | 2001-02-06 01:01:46 +0000 |
---|---|---|
committer | Fritz Elfert <felfert@to.com> | 2001-02-06 01:01:46 +0000 |
commit | a9fe8f28a4a9aaf1d9b84dbc6907849ace87f66e (patch) | |
tree | 0dd290cdf04cfd17a4ab4d0eb86bcb48137a02cb /kde2/plugins/pie3dwidget.cpp | |
parent | a8787d39b2bf1851cdea64a5e0eccc2aff7f15de (diff) | |
download | plptools-a9fe8f28a4a9aaf1d9b84dbc6907849ace87f66e.tar.gz plptools-a9fe8f28a4a9aaf1d9b84dbc6907849ace87f66e.tar.bz2 plptools-a9fe8f28a4a9aaf1d9b84dbc6907849ace87f66e.zip |
- Added KDE2 PropsDialog Plugin (incomplete)
- Fixed some KDE related autoconf stuff
- Added PlpDrive class for returning results from rfsv:devinfo
- Added auto-watch in ppsocket and finally got rid of the nasty
SIGPIPE bug. Now it's no more necessary to ignore SIGPIPE in
applications.
- Made constructors of rfsv16, rfsv32, rpcs16 and rpcs32 private to
enforce use of the factories.
- Removed error output in the factories and replaced that by error codes
which can be retrieved and evaluated by an application.
Diffstat (limited to 'kde2/plugins/pie3dwidget.cpp')
-rw-r--r-- | kde2/plugins/pie3dwidget.cpp | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/kde2/plugins/pie3dwidget.cpp b/kde2/plugins/pie3dwidget.cpp new file mode 100644 index 0000000..72a4578 --- /dev/null +++ b/kde2/plugins/pie3dwidget.cpp @@ -0,0 +1,120 @@ +/* + * This file is part of the KDE System Control Tool, + * Copyright (C)1999 Thorsten Westheider <twesthei@physik.uni-bielefeld.de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Pie3DWidget was inspired by Christian Poulter's KDiskFree + * + ****************************************************************************/ + +#include <qpainter.h> + +#include "pie3dwidget.h" + + +Pie3DWidget::Pie3DWidget(QWidget *parent, const char *name) : QWidget(parent, name), + _totalsize(0) +{ + _piecelist.setAutoDelete(true); + _piecelist.clear(); +} + + +void Pie3DWidget::addPiece(int size, const QColor& color) +{ + _totalsize += size; + + _piecelist.append(new Pie3DPiece(size, color)); + + repaint(); +} + + +int Pie3DWidget::heightForWidth(int w) const +{ + return (int) (w*0.6); +} + + +QSize Pie3DWidget::minimumSizeHint() const +{ + return QSize(60, 40); +} + + +QSize Pie3DWidget::sizeHint() const +{ + return QSize(width(), width()*0.6); +} + + +/* + * Protected methods + ********************/ + +void Pie3DWidget::paintEvent(QPaintEvent *ev) +{ + QPainter p; + QColor widgetbg = palette().normal().background(); + QColor black = QColor(black); + int w = width(); + int h = height(); + int pieh = h/4; + int halfrot = 180*16; + int fullrot = 360*16; + int bowpos = 0; + int i, bowlen, bowcut; + + if (_piecelist.isEmpty()) return; + + p.begin(this); + p.setClipRegion(ev->region()); + + for (Pie3DPiece *piece = _piecelist.first(); piece; piece = _piecelist.next()) + { + QPalette piecepal(piece->color(), widgetbg); + + bowlen = (int) (((double) piece->size())/_totalsize*fullrot); + + p.setPen((_piecelist.count() > 1) ? black : _piecelist.first()->color()); + p.setBrush(piecepal.normal().button()); + p.drawPie(0, 0, w, h-pieh, bowpos, bowlen); + + if (bowpos+bowlen >= halfrot) // Part of the footer is visible + { + bowcut = (bowpos < halfrot) ? halfrot-bowpos : 0; + bowpos += bowcut; + bowlen -= bowcut; + + p.setPen(piecepal.normal().mid()); + + for (i = 0; i < pieh; i++) p.drawArc(0, i, w, h-pieh, bowpos, bowlen); + } + + bowpos += bowlen; + } + + p.setPen(black); + + p.drawArc(0, 0, w, h-pieh, 0, fullrot); + p.drawArc(0, pieh-1, w, h-pieh, 0, -halfrot); + + p.drawLine(0, (h-pieh)/2, 0, (h+pieh)/2-1); + p.drawLine(w-1, (h-pieh)/2, w-1, (h+pieh)/2-1); + + p.end(); +} + |