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.
23 #include "kdmthemer.h"
27 KdmRect::KdmRect( QObject
*parent
, const QDomNode
&node
)
28 : KdmItem( parent
, node
)
34 // Set default values for rect (note: strings are already Null)
35 rect
.active
.present
= false;
36 rect
.prelight
.present
= false;
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
);
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())
70 p
->fillRect( r
, QBrush( rClass
->color
) );
74 KdmRect::statusChanged( bool descend
)
76 KdmItem::statusChanged( descend
);
77 if (!rect
.active
.present
&& !rect
.prelight
.present
)
79 if ((state
== Sprelight
&& !rect
.prelight
.present
) ||
80 (state
== Sactive
&& !rect
.active
.present
))
85 #include "kdmrect.moc"