Final polisihing for KDE4:
[kdemultimedia.git] / kscd / ledlamp.cpp
blob5220bf7b586e47e12614b606245ff6c23cfea3c0
1 /* This file is part of the KDE libraries
2 Copyright (C) 1997 Richard Moore (moorer@cs.man.ac.uk)
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #include "ledlamp.h"
22 #include <qpainter.h>
23 #include <qbrush.h>
24 #include <qpen.h>
26 LedLamp::LedLamp(QWidget *parent, Type t) : QFrame(parent),
27 w( 10 ), h( 7 ), dx( 4 )
29 // Make sure we're in a sane state
30 s = Off;
32 // Set the frame style
33 // setFrameStyle(Sunken | Box);
34 //setGeometry(0,0,h+1,w+1);
35 ledtype = t;
36 } // LedLamp
38 void
39 LedLamp::drawContents(QPainter *painter)
41 //QBrush lightBrush(palette().color(foregroundRole()));
42 //QBrush darkBrush(palette().color(backgroundRole()));
44 //QPen darkPen(palette().color(backgroundRole()), 1);
45 //QPen lightPen(palette().color(foregroundRole()), 1);
47 QBrush lightBrush(palette().color(backgroundRole()));
48 QBrush darkBrush(palette().color(foregroundRole()));
50 QPen darkPen(palette().color(foregroundRole()), 1);
51 QPen lightPen(palette().color(backgroundRole()), 1);
53 switch(s) {
54 case On:
55 painter->setBrush(lightBrush);
56 switch (ledtype) {
57 case Rect:
58 painter->drawRect(1,1,w-3, h-2);
59 break;
60 case Loop:
61 painter->setBrush(lightBrush);
62 painter->setPen(lightPen);
64 painter->drawLine(0, 2, 0, h-2); // |
65 painter->drawLine(1, 1, w-4, 1); // ~
66 painter->drawLine(w-3, 2, w-3, h-2); // |
67 painter->drawLine(2, h-2, w-3, h-2); //_
68 painter->drawLine(w-6,0,w-6,2); // ---+
69 painter->drawLine(3,h-2,3,h); // +---
70 break;
72 break;
73 case Off:
74 painter->setBrush(darkBrush);
75 switch (ledtype) {
76 case Rect:
77 painter->drawRect(1,1,w-3, h-2);
78 break;
79 case Loop:
80 painter->setBrush(darkBrush);
81 painter->setPen(darkPen);
83 painter->fillRect(0,0,w,h, darkBrush);
85 painter->drawLine(0, 2, 0, h-2); // |
86 painter->drawLine(1, 1, w-4, 1); // ~
87 painter->drawLine(w-3, 2, w-3, h-2); // |
88 painter->drawLine(2, h-2, w-3, h-2); //_
89 painter->drawLine(w-6,0,w-6,2); // ---+
90 painter->drawLine(3,h-2,3,h); // +---
92 break;
94 break;
95 default:
96 fprintf(stderr, "LedLamp: INVALID State (%d)\n", s);
98 } // drawContents
100 #include "ledlamp.moc"