~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kdm/kfrontend/themer/kdmrect.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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>
 
6
 *
 
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.
 
11
 *
 
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.
 
16
 *
 
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.
 
20
 */
 
21
 
 
22
#include "kdmrect.h"
 
23
#include "kdmthemer.h"
 
24
 
 
25
#include <QPainter>
 
26
 
 
27
KdmRect::KdmRect(QObject *parent, const QDomNode &node)
 
28
    : KdmItem(parent, node)
 
29
{
 
30
    itemType = "rect";
 
31
    if (!isVisible())
 
32
        return;
 
33
 
 
34
    // Set default values for rect (note: strings are already Null)
 
35
    rect.active.present = false;
 
36
    rect.prelight.present = false;
 
37
 
 
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();
 
44
 
 
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);
 
53
        }
 
54
    }
 
55
}
 
56
 
 
57
void
 
58
KdmRect::drawContents(QPainter *p, const QRect &r)
 
59
{
 
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;
 
66
 
 
67
    if (!rClass->color.isValid())
 
68
        return;
 
69
 
 
70
    p->fillRect(r, QBrush(rClass->color));
 
71
}
 
72
 
 
73
void
 
74
KdmRect::statusChanged(bool descend)
 
75
{
 
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();
 
83
}
 
84
 
 
85
#include "kdmrect.moc"