summaryrefslogtreecommitdiffstats
path: root/knode/knwidgets.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /knode/knwidgets.cpp
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'knode/knwidgets.cpp')
-rw-r--r--knode/knwidgets.cpp159
1 files changed, 159 insertions, 0 deletions
diff --git a/knode/knwidgets.cpp b/knode/knwidgets.cpp
new file mode 100644
index 00000000..d71624eb
--- /dev/null
+++ b/knode/knwidgets.cpp
@@ -0,0 +1,159 @@
+/*
+ knwidgets.cpp
+
+ KNode, the KDE newsreader
+ Copyright (c) 1999-2004 the KNode authors.
+ See file AUTHORS for details
+
+ 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.
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
+*/
+
+#include <qpainter.h>
+#include <qpixmap.h>
+
+#include "knwidgets.h"
+
+
+//====================================================================================
+
+KNListBoxItem::KNListBoxItem(const QString& text, QPixmap *pm)
+{
+ p_m=pm;
+ setText(text);
+}
+
+
+KNListBoxItem::~KNListBoxItem()
+{
+}
+
+
+void KNListBoxItem::paint(QPainter *p)
+{
+
+ QFontMetrics fm = p->fontMetrics();
+
+ int tYPos=0, tXPos=3, pYPos=0;
+
+ tYPos = fm.ascent() + fm.leading()/2; // vertical text position
+
+ if(p_m) {
+
+ tXPos=p_m->width() + 6;
+
+ if ( p_m->height() < fm.height() ) {
+ //tYPos = fm.ascent() + fm.leading()/2;
+ pYPos = (fm.height() - p_m->height())/2;}
+ else {
+ tYPos = p_m->height()/2 - fm.height()/2 + fm.ascent();
+ pYPos = 0;
+ }
+ p->drawPixmap( 3, pYPos , *p_m );
+ }
+
+
+ p->drawText( tXPos, tYPos, text() );
+}
+
+
+int KNListBoxItem::height(const QListBox *lb) const
+{
+ if(p_m)
+ return QMAX( p_m->height(), lb->fontMetrics().lineSpacing() + 1 );
+ else
+ return (lb->fontMetrics().lineSpacing() + 1);
+}
+
+
+int KNListBoxItem::width(const QListBox *lb) const
+{
+ if(p_m)
+ return (p_m->width() + lb->fontMetrics().width( text() ) + 6);
+ else
+ return (lb->fontMetrics().width( text() ) + 6);
+}
+
+
+//====================================================================================
+
+// **** listbox for dialogs **************************************************
+
+KNDialogListBox::KNDialogListBox(bool alwaysIgnore, QWidget * parent, const char * name)
+ : QListBox(parent, name), a_lwaysIgnore(alwaysIgnore)
+{
+}
+
+
+KNDialogListBox::~KNDialogListBox()
+{
+}
+
+
+void KNDialogListBox::keyPressEvent(QKeyEvent *e)
+{
+ if ((a_lwaysIgnore || !(hasFocus()&&isVisible()))&&((e->key()==Key_Enter)||(e->key()==Key_Return)))
+ e->ignore();
+ else
+ QListBox::keyPressEvent(e);
+}
+
+
+//====================================================================================
+
+
+KNDockWidgetHeaderDrag::KNDockWidgetHeaderDrag(QWidget *focusWidget, KDockWidgetAbstractHeader* parent, KDockWidget* dock, const char* name )
+ : KDockWidgetHeaderDrag(parent, dock, name), f_ocus(false)
+{
+ connect(focusWidget, SIGNAL(focusChanged(QFocusEvent*)), SLOT(slotFocusChanged(QFocusEvent*)));
+}
+
+
+KNDockWidgetHeaderDrag::~KNDockWidgetHeaderDrag()
+{
+}
+
+
+void KNDockWidgetHeaderDrag::slotFocusChanged(QFocusEvent *e)
+{
+ if(e->gotFocus()) {
+ f_ocus = true;
+ } else if(e->lostFocus()) {
+ f_ocus = false;
+ }
+ update();
+}
+
+
+void KNDockWidgetHeaderDrag::paintEvent(QPaintEvent* ev)
+{
+ if (!f_ocus) {
+ KDockWidgetHeaderDrag::paintEvent(ev);
+ return;
+ }
+
+ QPixmap drawBuffer(width(), height());
+ QPainter paint;
+
+ paint.begin(&drawBuffer);
+ paint.fillRect(drawBuffer.rect(), QBrush(colorGroup().brush(QColorGroup::Background)));
+
+ paint.setPen(palette().active().highlight());
+ paint.drawLine(1, 2, width(), 2);
+ paint.drawLine(1, 3, width(), 3);
+ paint.drawLine(1, 5, width(), 5);
+ paint.drawLine(1, 6, width(), 6);
+
+ bitBlt( this,0,0,&drawBuffer,0,0,width(),height());
+ paint.end();
+}
+
+
+//====================================================================================
+
+#include "knwidgets.moc"