sklineedit.cpp

00001 /****************************************************************************
00002  * Copyright (c) 2005 Alexander Wiedenbruch <mail@wiedenbruch.de>
00003  *
00004  * This file is part of SuperKaramba.
00005  *
00006  *  SuperKaramba is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  SuperKaramba is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with SuperKaramba; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019  ****************************************************************************/
00020 
00021 #include "sklineedit.h"
00022 #include "karamba.h"
00023 #include "kdebug.h"
00024 
00025 SKLineEdit::SKLineEdit(QWidget *w, Input *i) : QLineEdit(w), m_input(i)
00026 {
00027   frameColor = Qt::gray;
00028   setBackgroundColor(Qt::white);
00029 }
00030 
00031 SKLineEdit::~SKLineEdit()
00032 {
00033 }
00034 
00035 void SKLineEdit::drawFrame(QPainter *p)
00036 {
00037   p->setPen(frameColor);
00038   p->drawRect(frameRect());
00039 }
00040 
00041 void SKLineEdit::drawContents(QPainter *p)
00042 {
00043   QLineEdit::drawContents(p);
00044 }
00045 
00046 void SKLineEdit::setFrameColor(QColor c)
00047 {
00048   frameColor = c;
00049   repaint();
00050 }
00051 
00052 void SKLineEdit::setBackgroundColor(QColor c)
00053 {
00054   QLineEdit::setBackgroundColor(c);
00055   repaint();
00056 }
00057 
00058 QColor SKLineEdit::getFrameColor() const
00059 {
00060   return frameColor;
00061 }
00062 
00063 void SKLineEdit::keyPressEvent(QKeyEvent* e)
00064 {
00065   QLineEdit::keyPressEvent(e);
00066 
00067   if(!e->text().isEmpty())
00068   {
00069     karamba* k = static_cast<karamba*>(parent());
00070     k->keyPressed(e->text(), m_input);
00071   }
00072 }
00073 
00074 void SKLineEdit::keyReleaseEvent(QKeyEvent* e)
00075 {
00076   QLineEdit::keyReleaseEvent(e);
00077 }
00078 
00079 Input* SKLineEdit::getInput()
00080 {
00081   return m_input;
00082 }
KDE Home | KDE Accessibility Home | Description of Access Keys