| # kdeui Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | 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 management 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 //UNIX, WIN32
    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
    00058 class KDEUI_EXPORT KHSSelector : public KXYSelector
    00059 {
    00060   Q_OBJECT
    00061
    00062 public:
    00066   KHSSelector( QWidget *parent=0, const char *name=0 );
    00067
    00068 protected:
    00073   virtual void drawPalette( QPixmap *pixmap );
    00074   virtual void resizeEvent( QResizeEvent * );
    00075
    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;
    00102 class KDEUI_EXPORT KValueSelector : public KSelector
    00103 {
    00104   Q_OBJECT
    00105
    00106 public:
    00110   KValueSelector( QWidget *parent=0, const char *name=0 );
    00114   KValueSelector( Orientation o, QWidget *parent = 0, const char *name = 0 );
    00115
    00116   int hue() const
    00117         { return _hue; }
    00118   void setHue( int h )
    00119         { _hue = h; }
    00120   int saturation() const
    00121         { return _sat; }
    00122   void setSaturation( int s )
    00123         { _sat = s; }
    00124
    00125   void updateContents();
    00126 protected:
    00131   virtual void drawPalette( QPixmap *pixmap );
    00132   virtual void resizeEvent( QResizeEvent * );
    00133
    00139   virtual void drawContents( QPainter *painter );
    00140
    00141 private:
    00142   int _hue;
    00143   int _sat;
    00144   QPixmap pixmap;
    00145
    00146 protected:
    00147   virtual void virtual_hook( int id, void* data );
    00148 private:
    00149   class KValueSelectorPrivate;
    00150   KValueSelectorPrivate *d;
    00151 };
    00152
    00153
    00164 class KDEUI_EXPORT KColor : public QColor
    00165 {
    00166 public:
    00167   KColor();
    00168   KColor( const KColor &col);
    00169   KColor( const QColor &col);
    00170
    00171   KColor& operator=( const KColor& col);
    00172
    00173   bool operator==( const KColor& col) const;
    00174
    00175   void setHsv(int _h, int _s, int _v);
    00176   void setRgb(int _r, int _g, int _b);
    00177
    00178   void rgb(int *_r, int *_g, int *_b) const;
    00179   void hsv(int *_h, int *_s, int *_v) const;
    00180 protected:
    00181   int h;
    00182   int s;
    00183   int v;
    00184   int r;
    00185   int g;
    00186   int b;
    00187
    00188 private:
    00189   class KColorPrivate;
    00190   KColorPrivate *d;
    00191 };
    00192
    00198 class KDEUI_EXPORT KPaletteTable : public QWidget
    00199 {
    00200   Q_OBJECT
    00201 public:
    00202   KPaletteTable( QWidget *parent, int minWidth=210, int cols = 16);
    00203   ~KPaletteTable();
    00204   void addToCustomColors( const QColor &);
    00205   void addToRecentColors( const QColor &);
    00206   QString palette() const;
    00207 public slots:
    00208   void setPalette(const QString &paletteName);
    00209 signals:
    00210   void colorSelected( const QColor &, const QString & );
    00211   void colorDoubleClicked( const QColor &, const QString & );
    00212
    00213 protected slots:
    00214   void slotColorCellSelected( int );
    00215   void slotColorCellDoubleClicked( int );
    00216   void slotColorTextSelected( const QString &colorText );
    00217   void slotSetPalette( const QString &_paletteName );
    00218   void slotShowNamedColorReadError( void );
    00219
    00220 protected:
    00221   void readNamedColor( void );
    00222
    00223 protected:
    00224   QString i18n_customColors;
    00225   QString i18n_recentColors;
    00226   QString i18n_namedColors;
    00227   QComboBox *combo;
    00228   KColorCells *cells;
    00229   QScrollView *sv;
    00230   KListBox *mNamedColorList;
    00231   KPalette *mPalette;
    00232   int mMinWidth;
    00233   int mCols;
    00234
    00235 private:
    00236
    00237   virtual void setPalette(const QPalette& p) { QWidget::setPalette(p); }
    00238 protected:
    00239   virtual void virtual_hook( int id, void* data );
    00240 private:
    00241   class KPaletteTablePrivate;
    00242   KPaletteTablePrivate *d;
    00243 };
    00244
    00245
    00251 class KDEUI_EXPORT KColorCells : public QGridView
    00252 {
    00253   Q_OBJECT
    00254 public:
    00255   KColorCells( QWidget *parent, int rows, int cols );
    00256   ~KColorCells();
    00257
    00258   void setColor( int colNum, const QColor &col );
    00259   QColor color( int indx ) const
    00260   { return colors[indx]; }
    00261   int numCells() const
    00262   { return numRows() * numCols(); }
    00263
    00264   void setShading(bool _shade) { shade = _shade; }
    00265
    00266   void setAcceptDrags(bool _acceptDrags) { acceptDrags = _acceptDrags; }
    00267
    00268   int getSelected() const
    00269   { return selected; }
    00270
    00271   signals:
    00272   void colorSelected( int col );
    00273   void colorDoubleClicked( int col );
    00274
    00275 protected:
    00276   virtual void paintCell( QPainter *painter, int row, int col );
    00277   virtual void resizeEvent( QResizeEvent * );
    00278   virtual void mouseReleaseEvent( QMouseEvent * );
    00279   virtual void mousePressEvent( QMouseEvent * );
    00280   virtual void mouseMoveEvent( QMouseEvent * );
    00281   virtual void dragEnterEvent( QDragEnterEvent *);
    00282   virtual void dropEvent( QDropEvent *);
    00283   virtual void mouseDoubleClickEvent( QMouseEvent * );
    00284
    00285   int posToCell(const QPoint &pos, bool ignoreBorders=false);
    00286
    00287   QColor *colors;
    00288   bool inMouse;
    00289   QPoint mPos;
    00290   int   selected;
    00291   bool shade;
    00292   bool acceptDrags;
    00293
    00294 protected:
    00295   virtual void virtual_hook( int id, void* data );
    00296 private:
    00297   class KColorCellsPrivate;
    00298   KColorCellsPrivate *d;
    00299 };
    00300
    00309 class KDEUI_EXPORT KColorPatch : public QFrame
    00310 {
    00311   Q_OBJECT
    00312 public:
    00313   KColorPatch( QWidget *parent );
    00314   virtual ~KColorPatch();
    00315
    00316   void setColor( const QColor &col );
    00317
    00318 signals:
    00319   void colorChanged( const QColor&);
    00320
    00321 protected:
    00322   virtual void drawContents( QPainter *painter );
    00323   virtual void mouseMoveEvent( QMouseEvent * );
    00324   virtual void dragEnterEvent( QDragEnterEvent *);
    00325   virtual void dropEvent( QDropEvent *);
    00326
    00327 private:
    00328   QColor color;
    00329   uint pixel;
    00330   int colContext;
    00331
    00332 protected:
    00333   virtual void virtual_hook( int id, void* data );
    00334 private:
    00335   class KColorPatchPrivate;
    00336   KColorPatchPrivate *d;
    00337 };
    00338
    00375 class KDEUI_EXPORT KColorDialog : public KDialogBase
    00376 {
    00377   Q_OBJECT
    00378
    00379   public:
    00383     KColorDialog( QWidget *parent = 0L, const char *name = 0L,
    00384           bool modal = false );
    00388     ~KColorDialog();
    00389
    00393     QColor color() const;
    00394
    00403     static int getColor( QColor &theColor, QWidget *parent=0L );
    00404
    00417     static int getColor( QColor &theColor, const QColor& defaultColor, QWidget *parent=0L );
    00418
    00422     static QColor grabColor(const QPoint &p);
    00423
    00430     void setDefaultColor( const QColor& defaultCol );
    00431
    00435     QColor defaultColor() const;
    00436
    00437   public slots:
    00441     void setColor( const QColor &col );
    00442
    00443   signals:
    00449     void colorSelected( const QColor &col );
    00450
    00451   private slots:
    00452     void slotRGBChanged( void );
    00453     void slotHSVChanged( void );
    00454     void slotHtmlChanged( void );
    00455     void slotHSChanged( int, int );
    00456     void slotVChanged( int );
    00457     void slotColorSelected( const QColor &col );
    00458     void slotColorSelected( const QColor &col, const QString &name );
    00459     void slotColorDoubleClicked( const QColor &col, const QString &name );
    00460     void slotColorPicker();
    00461     void slotAddToCustomColors();
    00462     void slotDefaultColorClicked();
    00466     void slotWriteSettings();
    00467
    00468   private:
    00472     void readSettings();
    00473
    00474     void setRgbEdit( const KColor &col );
    00475     void setHsvEdit( const KColor &col );
    00476     void setHtmlEdit( const KColor &col );
    00477     void _setColor( const KColor &col, const QString &name=QString::null );
    00478     void showColor( const KColor &color, const QString &name );
    00479
    00480   protected:
    00481     virtual void mouseReleaseEvent( QMouseEvent * );
    00482     virtual void keyPressEvent( QKeyEvent * );
    00483     virtual bool eventFilter( QObject *obj, QEvent *ev );
    00484
    00485   protected:
    00486     virtual void virtual_hook( int id, void* data );
    00487   private:
    00488     class KColorDialogPrivate;
    00489     KColorDialogPrivate *d;
    00490 };
    00491
    00492 #endif      // !Q_WS_QWS
    00493 #endif      // __KCOLORDIALOG_H__
    00494

This file is part of the documentation for kdeui Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:20:14 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003