kmail

colorlistbox.h

Go to the documentation of this file.
00001 /*
00002  *   kmail: KDE mail client
00003  *   This file: Copyright (C) 2000 Espen Sand, espen@kde.org
00004  *
00005  *   This program is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   This program is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with this program; if not, write to the Free Software
00017  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  *
00019  */
00020 
00021 #ifndef _COLOR_LISTBOX_H_
00022 #define _COLOR_LISTBOX_H_
00023 
00024 #include <klistbox.h>
00025 
00026 class ColorListBox : public KListBox
00027 {
00028   Q_OBJECT
00029 
00030   public:
00031     ColorListBox( QWidget *parent=0, const char * name=0, WFlags f=0 );
00032     void setColor( uint index, const QColor &color );
00033     QColor color( uint index ) const;
00034 signals:
00035     void changed();
00036 
00037   public slots:
00038     virtual void setEnabled( bool state );
00039 
00040   protected:
00041     void dragEnterEvent( QDragEnterEvent *e );
00042     void dragLeaveEvent( QDragLeaveEvent *e );
00043     void dragMoveEvent( QDragMoveEvent *e );
00044     void dropEvent( QDropEvent *e );
00045 
00046   private slots:
00047     void newColor( int index );
00048 
00049   private:
00050     int mCurrentOnDragEnter;
00051 
00052 };
00053 
00054 
00055 class ColorListItem : public QListBoxItem
00056 {
00057   public:
00058     ColorListItem( const QString &text, const QColor &color=Qt::black );
00059     const QColor &color( void );
00060     void  setColor( const QColor &color );
00061 
00062   protected:
00063     virtual void paint( QPainter * );
00064     virtual int height( const QListBox * ) const;
00065     virtual int width( const QListBox * ) const;
00066 
00067   private:
00068     QColor mColor;
00069     int mBoxWidth;
00070 };
00071 
00072 #endif
00073