summaryrefslogtreecommitdiffstats
path: root/digikam/themedesigner/themedicongroupitem.cpp
blob: 585bd525b4efa473292c8bd5404ea54e2eae7de8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* ============================================================
 *
 * This file is a part of digiKam project
 * http://www.digikam.org
 *
 * Date        : 2005-07-15
 * Description : themed icon group item 
 * 
 * Copyright (C) 2005 by Renchi Raju <renchi at pooh.tam.uiuc.edu>
 *
 * 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, 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.
 *
 * ============================================================ */

// TQt includes.

#include <tqpixmap.h>
#include <tqpainter.h>

// KDE includes.

#include <klocale.h>

// Local includes.

#include "themeengine.h"
#include "themediconview.h"
#include "themedicongroupitem.h"

namespace Digikam
{

ThemedIconGroupItem::ThemedIconGroupItem(ThemedIconView* view)
                   : IconGroupItem(view), m_view(view)
{    
}

ThemedIconGroupItem::~ThemedIconGroupItem()
{    
}

void ThemedIconGroupItem::paintBanner()
{
    TQRect r(0, 0, rect().width(), rect().height());

    TQPixmap pix(m_view->bannerPixmap());
    
    TQFont fn(m_view->font());
    fn.setBold(true);
    int fnSize = fn.pointSize();
    bool usePointSize;
    if (fnSize > 0) 
    {
        fn.setPointSize(fnSize+2);
        usePointSize = true;
    }
    else 
    {
        fnSize = fn.pixelSize();
        fn.setPixelSize(fnSize+2);
        usePointSize = false;
    }

    TQPainter p(&pix);
    p.setPen(ThemeEngine::instance()->textSelColor());
    p.setFont(fn);

    TQRect tr;
    p.drawText(5, 5, r.width(), r.height(),
               TQt::AlignLeft | TQt::AlignTop, i18n("Album Banner"),
               -1, &tr);

    r.setY(tr.height() + 2);

    if (usePointSize)
        fn.setPointSize(m_view->font().pointSize());
    else
        fn.setPixelSize(m_view->font().pixelSize());

    fn.setBold(false);
    p.setFont(fn);

    p.drawText(5, r.y(), r.width(), r.height(),
               TQt::AlignLeft | TQt::AlignVCenter, i18n("July 2007 - 10 Items"));
    
    p.end();

    r = rect();
    r = TQRect(iconView()->contentsToViewport(TQPoint(r.x(), r.y())),
              TQSize(r.width(), r.height()));
    
    bitBlt(iconView()->viewport(), r.x(), r.y(), &pix,
           0, 0, r.width(), r.height());
}

}  // NameSpace Digikam