kcolordialog.h
/* This file is part of the KDE libraries
Copyright (C) 1997 Martin Jones (mjones@kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
//----------------------------------------------------------------------
// KDE color selection dialog.
// layout management added Oct 1997 by Mario Weilguni
// <mweilguni@sime.com>
#ifndef KDELIBS_KCOLORDIALOG_H
#define KDELIBS_KCOLORDIALOG_H
#ifdef Q_WS_QWS
// FIXME(E): Do we need the KColorDialog extra functionality in Qt Embedded?
#include <qcolordialog.h>
#define KColorDialog QColorDialog
#else //UNIX, WIN32
#include <kdialogbase.h>
#include <qframe.h>
#include <qpixmap.h>
#include <qgridview.h>
#include "kselect.h"
class QComboBox;
class QLineEdit;
class KListBox;
class KPalette;
class KColorCells;
class KDEUI_EXPORT KHSSelector : public KXYSelector
{
Q_OBJECT
public:
KHSSelector( QWidget *parent=0, const char *name=0 );
protected:
virtual void drawPalette( QPixmap *pixmap );
virtual void resizeEvent( QResizeEvent * );
virtual void drawContents( QPainter *painter );
private:
void updateContents();
QPixmap pixmap;
protected:
virtual void virtual_hook( int id, void* data );
private:
class KHSSelectorPrivate;
KHSSelectorPrivate *d;
};
class KValueSelectorPrivate;
class KDEUI_EXPORT KValueSelector : public KSelector
{
Q_OBJECT
public:
KValueSelector( QWidget *parent=0, const char *name=0 );
KValueSelector( Orientation o, QWidget *parent = 0, const char *name = 0 );
int hue() const
{ return _hue; }
void setHue( int h )
{ _hue = h; }
int saturation() const
{ return _sat; }
void setSaturation( int s )
{ _sat = s; }
void updateContents();
protected:
virtual void drawPalette( QPixmap *pixmap );
virtual void resizeEvent( QResizeEvent * );
virtual void drawContents( QPainter *painter );
private:
int _hue;
int _sat;
QPixmap pixmap;
protected:
virtual void virtual_hook( int id, void* data );
private:
class KValueSelectorPrivate;
KValueSelectorPrivate *d;
};
class KDEUI_EXPORT KColor : public QColor
{
public:
KColor();
KColor( const KColor &col);
KColor( const QColor &col);
KColor& operator=( const KColor& col);
bool operator==( const KColor& col) const;
void setHsv(int _h, int _s, int _v);
void setRgb(int _r, int _g, int _b);
void rgb(int *_r, int *_g, int *_b) const;
void hsv(int *_h, int *_s, int *_v) const;
protected:
int h;
int s;
int v;
int r;
int g;
int b;
private:
class KColorPrivate;
KColorPrivate *d;
};
class KDEUI_EXPORT KPaletteTable : public QWidget
{
Q_OBJECT
public:
KPaletteTable( QWidget *parent, int minWidth=210, int cols = 16);
~KPaletteTable();
void addToCustomColors( const QColor &);
void addToRecentColors( const QColor &);
QString palette() const;
public slots:
void setPalette(const QString &paletteName);
signals:
void colorSelected( const QColor &, const QString & );
void colorDoubleClicked( const QColor &, const QString & );
protected slots:
void slotColorCellSelected( int );
void slotColorCellDoubleClicked( int );
void slotColorTextSelected( const QString &colorText );
void slotSetPalette( const QString &_paletteName );
void slotShowNamedColorReadError( void );
protected:
void readNamedColor( void );
protected:
QString i18n_customColors;
QString i18n_recentColors;
QString i18n_namedColors;
QComboBox *combo;
KColorCells *cells;
QScrollView *sv;
KListBox *mNamedColorList;
KPalette *mPalette;
int mMinWidth;
int mCols;
private:
virtual void setPalette(const QPalette& p) { QWidget::setPalette(p); }
protected:
virtual void virtual_hook( int id, void* data );
private:
class KPaletteTablePrivate;
KPaletteTablePrivate *d;
};
class KDEUI_EXPORT KColorCells : public QGridView
{
Q_OBJECT
public:
KColorCells( QWidget *parent, int rows, int cols );
~KColorCells();
void setColor( int colNum, const QColor &col );
QColor color( int indx ) const
{ return colors[indx]; }
int numCells() const
{ return numRows() * numCols(); }
void setShading(bool _shade) { shade = _shade; }
void setAcceptDrags(bool _acceptDrags) { acceptDrags = _acceptDrags; }
int getSelected() const
{ return selected; }
signals:
void colorSelected( int col );
void colorDoubleClicked( int col );
protected:
virtual void paintCell( QPainter *painter, int row, int col );
virtual void resizeEvent( QResizeEvent * );
virtual void mouseReleaseEvent( QMouseEvent * );
virtual void mousePressEvent( QMouseEvent * );
virtual void mouseMoveEvent( QMouseEvent * );
virtual void dragEnterEvent( QDragEnterEvent *);
virtual void dropEvent( QDropEvent *);
virtual void mouseDoubleClickEvent( QMouseEvent * );
int posToCell(const QPoint &pos, bool ignoreBorders=false);
QColor *colors;
bool inMouse;
QPoint mPos;
int selected;
bool shade;
bool acceptDrags;
protected:
virtual void virtual_hook( int id, void* data );
private:
class KColorCellsPrivate;
KColorCellsPrivate *d;
};
class KDEUI_EXPORT KColorPatch : public QFrame
{
Q_OBJECT
public:
KColorPatch( QWidget *parent );
virtual ~KColorPatch();
void setColor( const QColor &col );
signals:
void colorChanged( const QColor&);
protected:
virtual void drawContents( QPainter *painter );
virtual void mouseMoveEvent( QMouseEvent * );
virtual void dragEnterEvent( QDragEnterEvent *);
virtual void dropEvent( QDropEvent *);
private:
QColor color;
uint pixel;
int colContext;
protected:
virtual void virtual_hook( int id, void* data );
private:
class KColorPatchPrivate;
KColorPatchPrivate *d;
};
class KDEUI_EXPORT KColorDialog : public KDialogBase
{
Q_OBJECT
public:
KColorDialog( QWidget *parent = 0L, const char *name = 0L,
bool modal = false );
~KColorDialog();
QColor color() const;
static int getColor( QColor &theColor, QWidget *parent=0L );
static int getColor( QColor &theColor, const QColor& defaultColor, QWidget *parent=0L );
static QColor grabColor(const QPoint &p);
void setDefaultColor( const QColor& defaultCol );
QColor defaultColor() const;
public slots:
void setColor( const QColor &col );
signals:
void colorSelected( const QColor &col );
private slots:
void slotRGBChanged( void );
void slotHSVChanged( void );
void slotHtmlChanged( void );
void slotHSChanged( int, int );
void slotVChanged( int );
void slotColorSelected( const QColor &col );
void slotColorSelected( const QColor &col, const QString &name );
void slotColorDoubleClicked( const QColor &col, const QString &name );
void slotColorPicker();
void slotAddToCustomColors();
void slotDefaultColorClicked();
void slotWriteSettings();
private:
void readSettings();
void setRgbEdit( const KColor &col );
void setHsvEdit( const KColor &col );
void setHtmlEdit( const KColor &col );
void _setColor( const KColor &col, const QString &name=QString::null );
void showColor( const KColor &color, const QString &name );
protected:
virtual void mouseReleaseEvent( QMouseEvent * );
virtual void keyPressEvent( QKeyEvent * );
virtual bool eventFilter( QObject *obj, QEvent *ev );
protected:
virtual void virtual_hook( int id, void* data );
private:
class KColorDialogPrivate;
KColorDialogPrivate *d;
};
#endif // !Q_WS_QWS
#endif // KDELIBS_KCOLORDIALOG_H
KHSSelector
Widget for Hue/Saturation colour selection.
Definition: kcolordialog.h:58
KPalette
KPaletteTable
A color palette in table form.
Definition: kcolordialog.h:198
KDialogBase
A dialog base class with standard buttons and predefined layouts.
Definition: kdialogbase.h:191
KDialogBase::keyPressEvent
virtual void keyPressEvent(QKeyEvent *e)
Maps some keys to the actions buttons.
Definition: kdialogbase.cpp:1553
KPaletteTable::i18n_namedColors
QString i18n_namedColors
KDE4: remove
Definition: kcolordialog.h:228
KColorCells
A table of editable color cells.
Definition: kcolordialog.h:253
KValueSelector
Widget for color value selection.
Definition: kcolordialog.h:102
KColor
A color class that preserves both RGB and HSV values.
Definition: kcolordialog.h:164
KColorPatch
A color displayer.
Definition: kcolordialog.h:311
KSelector::drawContents
virtual void drawContents(QPainter *)
Override this function to draw the contents of the control.
Definition: kselect.cpp:367
KColorDialog
A color selection dialog.
Definition: kcolordialog.h:377
KPaletteTable::i18n_customColors
QString i18n_customColors
Definition: kcolordialog.h:225
KXYSelector
KXYSelector is the base class for other widgets which provides the ability to choose from a two-dimen...
Definition: kselect.h:43
KListBox
A variant of QListBox that honors KDE's system-wide settings.
Definition: klistbox.h:40
KSelector
KSelector is the base class for other widgets which provides the ability to choose from a one-dimensi...
Definition: kselect.h:159
KXYSelector::drawContents
virtual void drawContents(QPainter *)
Override this function to draw the contents of the widget.
Definition: kselect.cpp:217

KDE Home | KDE Accessibility Home | Description of Access Keys