kaddressbook

colorlistbox.h

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   TQ_OBJECT
00030 
00031   public:
00032     ColorListBox( TQWidget *parent=0, const char * name=0, WFlags f=0 );
00033     void setColor( uint index, const TQColor &color );
00034     TQColor color( uint index ) const;
00035 
00036   public slots:
00037     virtual void setEnabled( bool state );
00038 
00039   protected:
00040     void dragEnterEvent( TQDragEnterEvent *e );
00041     void dragLeaveEvent( TQDragLeaveEvent *e );
00042     void dragMoveEvent( TQDragMoveEvent *e );
00043     void dropEvent( TQDropEvent *e );
00044 
00045   private slots:
00046     void newColor( int index );
00047 
00048   private:
00049     int mCurrentOnDragEnter;
00050 
00051 };
00052 
00053 
00054 class ColorListItem : public TQListBoxItem
00055 {
00056   public:
00057     ColorListItem( const TQString &text, const TQColor &color=TQt::black );
00058     const TQColor &color( void );
00059     void  setColor( const TQColor &color );
00060 
00061   protected:
00062     virtual void paint( TQPainter * );
00063     virtual int height( const TQListBox * ) const;
00064     virtual int width( const TQListBox * ) const;
00065 
00066   private:
00067     TQColor mColor;
00068     int mBoxWidth;
00069 };
00070 
00071 #endif
00072