You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
2.2 KiB
86 lines
2.2 KiB
15 years ago
|
/*
|
||
13 years ago
|
This file is part of libtdepim.
|
||
15 years ago
|
Copyright (c) 2004 Daniel Molkentin <molkentin@kde.org>
|
||
|
based on code by Cornelius Schumacher <schumacher@kde.org>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library 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
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
|
||
|
#include "clicklineedit.h"
|
||
|
|
||
15 years ago
|
#include "tqpainter.h"
|
||
15 years ago
|
|
||
|
using namespace KPIM;
|
||
|
|
||
13 years ago
|
ClickLineEdit::ClickLineEdit(TQWidget *parent, const TQString &msg, const char* name) :
|
||
|
KLineEdit(parent, name)
|
||
15 years ago
|
{
|
||
|
mDrawClickMsg = true;
|
||
|
setClickMessage( msg );
|
||
|
}
|
||
|
|
||
|
ClickLineEdit::~ClickLineEdit() {}
|
||
|
|
||
|
|
||
15 years ago
|
void ClickLineEdit::setClickMessage( const TQString &msg )
|
||
15 years ago
|
{
|
||
|
mClickMessage = msg;
|
||
14 years ago
|
tqrepaint();
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void ClickLineEdit::setText( const TQString &txt )
|
||
15 years ago
|
{
|
||
|
mDrawClickMsg = txt.isEmpty();
|
||
14 years ago
|
tqrepaint();
|
||
15 years ago
|
KLineEdit::setText( txt );
|
||
|
}
|
||
|
|
||
15 years ago
|
void ClickLineEdit::drawContents( TQPainter *p )
|
||
15 years ago
|
{
|
||
|
KLineEdit::drawContents( p );
|
||
|
|
||
|
if ( mDrawClickMsg == true && !hasFocus() ) {
|
||
15 years ago
|
TQPen tmp = p->pen();
|
||
|
p->setPen( palette().color( TQPalette::Disabled, TQColorGroup::Text ) );
|
||
|
TQRect cr = contentsRect();
|
||
15 years ago
|
p->drawText( cr, AlignAuto|AlignVCenter, mClickMessage );
|
||
|
p->setPen( tmp );
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void ClickLineEdit::focusInEvent( TQFocusEvent *ev )
|
||
15 years ago
|
{
|
||
|
if ( mDrawClickMsg == true )
|
||
|
{
|
||
|
mDrawClickMsg = false;
|
||
14 years ago
|
tqrepaint();
|
||
15 years ago
|
}
|
||
15 years ago
|
TQLineEdit::focusInEvent( ev );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void ClickLineEdit::focusOutEvent( TQFocusEvent *ev )
|
||
15 years ago
|
{
|
||
|
if ( text().isEmpty() )
|
||
|
{
|
||
|
mDrawClickMsg = true;
|
||
14 years ago
|
tqrepaint();
|
||
15 years ago
|
}
|
||
15 years ago
|
TQLineEdit::focusOutEvent( ev );
|
||
15 years ago
|
}
|
||
|
|
||
|
#include "clicklineedit.moc"
|