| # kdeui Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# kcolordialog.h

    00001 /* This file is part of the KDE libraries
    00002     Copyright (C) 1997 Martin Jones (mjones@kde.org)
    00003
    00004     This library is free software; you can redistribute it and/or
    00005     modify it under the terms of the GNU Library General Public
    00006     License as published by the Free Software Foundation; either
    00007     version 2 of the License, or (at your option) any later version.
    00008
    00009     This library is distributed in the hope that it will be useful,
    00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00012     Library General Public License for more details.
    00013
    00014     You should have received a copy of the GNU Library General Public License
    00015     along with this library; see the file COPYING.LIB.  If not, write to
    00016     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00017     Boston, MA 02111-1307, USA.
    00018 */
    00019 //----------------------------------------------------------------------
    00020 // KDE color selection dialog.
    00021
    00022 // layout managment added Oct 1997 by Mario Weilguni
    00023 // <mweilguni@sime.com>
    00024
    00025 #ifndef __KCOLORDIALOG_H__
    00026 #define __KCOLORDIALOG_H__
    00027
    00028 #ifdef Q_WS_QWS
    00029 // FIXME(E): Do we need the KColorDialog extra functionality in Qt Embedded?
    00030 #include <qcolordialog.h>
    00031 #define KColorDialog QColorDialog
    00032 #else
    00033 #include <kdialogbase.h>
    00034 #include <qframe.h>
    00035 #include <qpixmap.h>
    00036 #include <qgridview.h>
    00037
    00038 #include "kselect.h"
    00039
    00040 class QComboBox;
    00041 class QLineEdit;
    00042 class KListBox;
    00043 class KPalette;
    00044 class KColorCells;
    00045
    00046
    00056 class KHSSelector : public KXYSelector
    00057 {
    00058   Q_OBJECT
    00059
    00060 public:
    00064   KHSSelector( QWidget *parent=0, const char *name=0 );
    00065
    00066 protected:
    00071   virtual void drawPalette( QPixmap *pixmap );
    00075   virtual void resizeEvent( QResizeEvent * );
    00081   virtual void drawContents( QPainter *painter );
    00082
    00083 private:
    00084   void updateContents();
    00085   QPixmap pixmap;
    00086
    00087 protected:
    00088   virtual void virtual_hook( int id, void* data );
    00089 private:
    00090   class KHSSelectorPrivate;
    00091   KHSSelectorPrivate *d;
    00092 };
    00093
    00094
    00095 class KValueSelectorPrivate;
    00103 class KValueSelector : public KSelector
    00104 {
    00105   Q_OBJECT
    00106
    00107 public:
    00111   KValueSelector( QWidget *parent=0, const char *name=0 );
    00115   KValueSelector( Orientation o, QWidget *parent = 0, const char *name = 0 );
    00116
    00117   int hue() const
    00118         { return _hue; }
    00119   void setHue( int h )
    00120         { _hue = h; }
    00121   int saturation() const
    00122         { return _sat; }
    00123   void setSaturation( int s )
    00124         { _sat = s; }
    00125
    00126   void updateContents();
    00127 protected:
    00132   virtual void drawPalette( QPixmap *pixmap );
    00136   virtual void resizeEvent( QResizeEvent * );
    00142   virtual void drawContents( QPainter *painter );
    00143
    00144 private:
    00145   int _hue;
    00146   int _sat;
    00147   QPixmap pixmap;
    00148
    00149 protected:
    00150   virtual void virtual_hook( int id, void* data );
    00151 private:
    00152   class KValueSelectorPrivate;
    00153   KValueSelectorPrivate *d;
    00154 };
    00155
    00156
    00157 class KColor : public QColor
    00158 {
    00159 public:
    00160   KColor();
    00161   KColor( const KColor &col);
    00162   KColor( const QColor &col);
    00163
    00164   KColor& operator=( const KColor& col);
    00165
    00166   bool operator==( const KColor& col) const;
    00167
    00168   void setHsv(int _h, int _s, int _v);
    00169   void setRgb(int _r, int _g, int _b);
    00170
    00171   void rgb(int *_r, int *_g, int *_b) const;
    00172   void hsv(int *_h, int *_s, int *_v) const;
    00173 protected:
    00174   int h;
    00175   int s;
    00176   int v;
    00177   int r;
    00178   int g;
    00179   int b;
    00180
    00181 private:
    00182   class KColorPrivate;
    00183   KColorPrivate *d;
    00184 };
    00185
    00191 class KPaletteTable : public QWidget
    00192 {
    00193   Q_OBJECT
    00194 public:
    00195   KPaletteTable( QWidget *parent, int minWidth=210, int cols = 16);
    00196   ~KPaletteTable();
    00197   void addToCustomColors( const QColor &);
    00198   void addToRecentColors( const QColor &);
    00199   QString palette() const;
    00200 public slots:
    00201   void setPalette(const QString &paletteName);
    00202 signals:
    00203   void colorSelected( const QColor &, const QString & );
    00204   void colorDoubleClicked( const QColor &, const QString & );
    00205
    00206 protected slots:
    00207   void slotColorCellSelected( int );
    00208   void slotColorCellDoubleClicked( int );
    00209   void slotColorTextSelected( const QString &colorText );
    00210   void slotSetPalette( const QString &_paletteName );
    00211   void slotShowNamedColorReadError( void );
    00212
    00213 protected:
    00214   void readNamedColor( void );
    00215
    00216 protected:
    00217   QString i18n_customColors;
    00218   QString i18n_recentColors;
    00219   QString i18n_namedColors;
    00220   QComboBox *combo;
    00221   KColorCells *cells;
    00222   QScrollView *sv;
    00223   KListBox *mNamedColorList;
    00224   KPalette *mPalette;
    00225   int mMinWidth;
    00226   int mCols;
    00227
    00228 private:
    00229
    00230   virtual void setPalette(const QPalette& p) { QWidget::setPalette(p); }
    00231 protected:
    00232   virtual void virtual_hook( int id, void* data );
    00233 private:
    00234   class KPaletteTablePrivate;
    00235   KPaletteTablePrivate *d;
    00236 };
    00237
    00238
    00244 class KColorCells : public QGridView
    00245 {
    00246   Q_OBJECT
    00247 public:
    00248   KColorCells( QWidget *parent, int rows, int cols );
    00249   ~KColorCells();
    00250
    00251   void setColor( int colNum, const QColor &col );
    00252   QColor color( int indx ) const
    00253   {     return colors[indx]; }
    00254   int numCells() const
    00255   {     return numRows() * numCols(); }
    00256
    00257   void setShading(bool _shade) { shade = _shade; }
    00258
    00259   void setAcceptDrags(bool _acceptDrags) { acceptDrags = _acceptDrags; }
    00260
    00261   int getSelected() const
    00262   {     return selected; }
    00263
    00264   signals:
    00265   void colorSelected( int col );
    00266   void colorDoubleClicked( int col );
    00267
    00268 protected:
    00272   virtual void paintCell( QPainter *painter, int row, int col );
    00276   virtual void resizeEvent( QResizeEvent * );
    00280   virtual void mouseReleaseEvent( QMouseEvent * );
    00284   virtual void mousePressEvent( QMouseEvent * );
    00288   virtual void mouseMoveEvent( QMouseEvent * );
    00292   virtual void dragEnterEvent( QDragEnterEvent *);
    00296   virtual void dropEvent( QDropEvent *);
    00297
    00301   virtual void mouseDoubleClickEvent( QMouseEvent * );
    00302
    00303   int posToCell(const QPoint &pos, bool ignoreBorders=false);
    00304
    00305   QColor *colors;
    00306   bool inMouse;
    00307   QPoint mPos;
    00308   int   selected;
    00309   bool shade;
    00310   bool acceptDrags;
    00311
    00312 protected:
    00313   virtual void virtual_hook( int id, void* data );
    00314 private:
    00315   class KColorCellsPrivate;
    00316   KColorCellsPrivate *d;
    00317 };
    00318
    00326 class KColorPatch : public QFrame
    00327 {
    00328   Q_OBJECT
    00329 public:
    00330   KColorPatch( QWidget *parent );
    00331   virtual ~KColorPatch();
    00332
    00333   void setColor( const QColor &col );
    00334
    00335 signals:
    00336   void colorChanged( const QColor&);
    00337
    00338 protected:
    00342   virtual void drawContents( QPainter *painter );
    00346   virtual void mouseMoveEvent( QMouseEvent * );
    00350   virtual void dragEnterEvent( QDragEnterEvent *);
    00354   virtual void dropEvent( QDropEvent *);
    00355
    00356 private:
    00357   QColor color;
    00358   uint pixel;
    00359   int colContext;
    00360
    00361 protected:
    00362   virtual void virtual_hook( int id, void* data );
    00363 private:
    00364   class KColorPatchPrivate;
    00365   KColorPatchPrivate *d;
    00366 };
    00367
    00405 class KColorDialog : public KDialogBase
    00406 {
    00407   Q_OBJECT
    00408
    00409   public:
    00413     KColorDialog( QWidget *parent = 0L, const char *name = 0L,
    00414                   bool modal = FALSE );
    00418     ~KColorDialog();
    00419
    00423     QColor color() const;
    00424
    00433     static int getColor( QColor &theColor, QWidget *parent=0L );
    00434
    00447     static int getColor( QColor &theColor, const QColor& defaultColor, QWidget *parent=0L );
    00448
    00452     static QColor grabColor(const QPoint &p);
    00453
    00460     void setDefaultColor( const QColor& defaultCol );
    00461
    00465     QColor defaultColor() const;
    00466
    00467   public slots:
    00471     void setColor( const QColor &col );
    00472
    00473   signals:
    00479     void colorSelected( const QColor &col );
    00480
    00481   private slots:
    00482     void slotRGBChanged( void );
    00483     void slotHSVChanged( void );
    00484     void slotHtmlChanged( void );
    00485     void slotHSChanged( int, int );
    00486     void slotVChanged( int );
    00487     void slotColorSelected( const QColor &col );
    00488     void slotColorSelected( const QColor &col, const QString &name );
    00489     void slotColorDoubleClicked( const QColor &col, const QString &name );
    00490     void slotColorPicker();
    00491     void slotAddToCustomColors();
    00492     void slotDefaultColorClicked();
    00496     void slotWriteSettings();
    00497
    00498   private:
    00502     void readSettings();
    00503
    00504     void setRgbEdit( const KColor &col );
    00505     void setHsvEdit( const KColor &col );
    00506     void setHtmlEdit( const KColor &col );
    00507     void _setColor( const KColor &col, const QString &name=QString::null );
    00508     void showColor( const KColor &color, const QString &name );
    00509
    00510   protected:
    00514     virtual void mouseReleaseEvent( QMouseEvent * );
    00518     virtual void keyPressEvent( QKeyEvent * );
    00519
    00520   protected:
    00521     virtual void virtual_hook( int id, void* data );
    00522   private:
    00523     class KColorDialogPrivate;
    00524     KColorDialogPrivate *d;
    00525 };
    00526
    00527 #endif          // Q_WS_QWS
    00528 #endif          // __KCOLORDIALOG_H__
    00529

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 12:56:20 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001