add more spacing
[personal-kdebase.git] / workspace / kdm / kfrontend / themer / kdmrect.cpp
blob1629fa7a6e14573bcb38ca47de135edf08940a18
1 /*
2 * Copyright (C) 2003 by Unai Garro <ugarro@users.sourceforge.net>
3 * Copyright (C) 2004 by Enrico Ros <rosenric@dei.unipd.it>
4 * Copyright (C) 2004 by Stephan Kulow <coolo@kde.org>
5 * Copyright (C) 2004 by Oswald Buddenhagen <ossi@kde.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #include "kdmrect.h"
23 #include "kdmthemer.h"
25 #include <QPainter>
27 KdmRect::KdmRect( QObject *parent, const QDomNode &node )
28 : KdmItem( parent, node )
30 itemType = "rect";
31 if (!isVisible())
32 return;
34 // Set default values for rect (note: strings are already Null)
35 rect.active.present = false;
36 rect.prelight.present = false;
38 // Read RECT TAGS
39 QDomNodeList childList = node.childNodes();
40 for (int nod = 0; nod < childList.count(); nod++) {
41 QDomNode child = childList.item( nod );
42 QDomElement el = child.toElement();
43 QString tagName = el.tagName();
45 if (tagName == "normal") {
46 parseColor( el, rect.normal.color );
47 } else if (tagName == "active") {
48 rect.active.present = true;
49 parseColor( el, rect.active.color );
50 } else if (tagName == "prelight") {
51 rect.prelight.present = true;
52 parseColor( el, rect.prelight.color );
57 void
58 KdmRect::drawContents( QPainter *p, const QRect &r )
60 // choose the correct rect class
61 RectStruct::RectClass *rClass = &rect.normal;
62 if (state == Sactive && rect.active.present)
63 rClass = &rect.active;
64 if (state == Sprelight && rect.prelight.present)
65 rClass = &rect.prelight;
67 if (!rClass->color.isValid())
68 return;
70 p->fillRect( r, QBrush( rClass->color ) );
73 void
74 KdmRect::statusChanged( bool descend )
76 KdmItem::statusChanged( descend );
77 if (!rect.active.present && !rect.prelight.present)
78 return;
79 if ((state == Sprelight && !rect.prelight.present) ||
80 (state == Sactive && !rect.active.present))
81 return;
82 needUpdate();
85 #include "kdmrect.moc"