libtdepim

clicklineedit.cpp
1/*
2 This file is part of libtdepim.
3 Copyright (c) 2004 Daniel Molkentin <molkentin@kde.org>
4 based on code by Cornelius Schumacher <schumacher@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22
23#include "clicklineedit.h"
24
25#include "tqpainter.h"
26
27using namespace KPIM;
28
29ClickLineEdit::ClickLineEdit(TQWidget *parent, const TQString &msg, const char* name) :
30 KLineEdit(parent, name)
31{
32 mDrawClickMsg = true;
33 setClickMessage( msg );
34}
35
36ClickLineEdit::~ClickLineEdit() {}
37
38
39void ClickLineEdit::setClickMessage( const TQString &msg )
40{
41 mClickMessage = msg;
42 repaint();
43}
44
45void ClickLineEdit::setText( const TQString &txt )
46{
47 mDrawClickMsg = txt.isEmpty();
48 repaint();
49 KLineEdit::setText( txt );
50}
51
52void ClickLineEdit::drawContents( TQPainter *p )
53{
54 KLineEdit::drawContents( p );
55
56 if ( mDrawClickMsg == true && !hasFocus() ) {
57 TQPen tmp = p->pen();
58 p->setPen( palette().color( TQPalette::Disabled, TQColorGroup::Text ) );
59 TQRect cr = contentsRect();
60 p->drawText( cr, AlignAuto|AlignVCenter, mClickMessage );
61 p->setPen( tmp );
62 }
63}
64
65void ClickLineEdit::focusInEvent( TQFocusEvent *ev )
66{
67 if ( mDrawClickMsg == true )
68 {
69 mDrawClickMsg = false;
70 repaint();
71 }
72 TQLineEdit::focusInEvent( ev );
73}
74
75void ClickLineEdit::focusOutEvent( TQFocusEvent *ev )
76{
77 if ( text().isEmpty() )
78 {
79 mDrawClickMsg = true;
80 repaint();
81 }
82 TQLineEdit::focusOutEvent( ev );
83}
84
85#include "clicklineedit.moc"
TDEPIM classes for drag and drop of mails.