summaryrefslogtreecommitdiffstats
path: root/buildtools/autotools/kimporticonview.cpp
blob: d696ab2e9e7667acc4d16cbaf1f90953512f8a87 (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
/***************************************************************************
                             -------------------
    begin                : 19.01.2003
    copyright            : (C) 2002 by Victor Röder
    email                : victor_roeder@gmx.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include <tqfontmetrics.h>
#include <tqpainter.h>
#include <tqrect.h>
#include <tqwidget.h>

#include <tdeglobalsettings.h>
#include <tdelocale.h>
#include <kwordwrap.h>

#include "kimporticonview.h"


KImportIconView::KImportIconView(const TQString& strIntro, TQWidget *parent, const char *name)
  : KFileDnDIconView(parent, name)
{
	m_strIntro = strIntro;
	m_bDropped = false;

	setAcceptDrops ( true );
}


KImportIconView::~KImportIconView()
{
}

void KImportIconView::drawContents ( TQPainter *p, int cx, int cy, int cw, int ch )
{
    if ( !m_bDropped)
    {
        TQIconView::drawContents ( p, cx, cy, cw, ch );

        p->save();
        TQFont font ( p->font() );
        font.setBold ( true );
        font.setFamily ( "Helvetica [Adobe]" );
        font.setPointSize ( 10 );
        p->setFont ( font );
        p->setPen ( TQPen ( TDEGlobalSettings::highlightColor() ) );

        TQRect rect = frameRect();
        TQFontMetrics fm ( p->font() );
        rect.setLeft ( rect.left() + 30 );
        rect.setRight ( rect.right() - 30 );

        resizeContents ( contentsWidth(), contentsHeight() );

        // word-wrap the string
        KWordWrap* wordWrap1 = KWordWrap::formatText( fm, rect, AlignHCenter | WordBreak, m_strIntro );
        KWordWrap* wordWrap2 = KWordWrap::formatText( fm, rect, AlignHCenter | WordBreak, i18n("Or just use the buttons.") );

        TQRect introRect1 = wordWrap1->boundingRect();
		TQRect introRect2 = wordWrap2->boundingRect();

        wordWrap1->drawText ( p, ( ( frameRect().right() - introRect1.right() ) / 2 ), ( ( frameRect().bottom() - introRect1.bottom() ) / 2 ) - 20, AlignHCenter | AlignVCenter );
        wordWrap2->drawText ( p, ( ( frameRect().right() - introRect2.right() ) / 2 ), ( ( frameRect().bottom() - introRect2.bottom() ) / 2 ) + introRect1.bottom(), AlignHCenter | AlignVCenter );

        p->restore();
    }
    else
    {
        TQIconView::drawContents ( p, cx, cy, cw, ch );
    }
}

void KImportIconView::somethingDropped ( bool dropped )
{
    m_bDropped = dropped;
}

#include "kimporticonview.moc"