Home

qtcolorpicker.h

This is the verbatim text of the qtcolorpicker.h include file. It is provided only for illustration; the copyright remains with Trolltech.


#ifndef QTCOLORPICKER_H
#define QTCOLORPICKER_H
#include <qpushbutton.h>
#include <qstring.h>
#include <qcolor.h>
#include <qgrid.h>

#include <qlabel.h>
#include <qgridview.h>
#include <qevent.h>

#if defined(Q_WS_WIN)
#  if !defined(QT_QTCOLORPICKER_EXPORT) && !defined(QT_QTCOLORPICKER_IMPORT)
#    define QT_QTCOLORPICKER_EXPORT
#  elif defined(QT_QTCOLORPICKER_IMPORT)
#    if defined(QT_QTCOLORPICKER_EXPORT)
#      undef QT_QTCOLORPICKER_EXPORT
#    endif
#    define QT_QTCOLORPICKER_EXPORT __declspec(dllimport)
#  elif defined(QT_QTCOLORPICKER_EXPORT)
#    undef QT_QTCOLORPICKER_EXPORT
#    define QT_QTCOLORPICKER_EXPORT __declspec(dllexport)
#  endif
#else
#  define QT_QTCOLORPICKER_EXPORT
#endif

class ColorPickerPopup;

class QT_QTCOLORPICKER_EXPORT QtColorPicker : public QPushButton
{
    Q_OBJECT

    Q_PROPERTY(bool colorDialog READ colorDialogEnabled WRITE setColorDialogEnabled)

public:
    QtColorPicker(QWidget *parent = 0, const char *name = 0,
		  int columns = -1, bool enableColorDialog = true);

    ~QtColorPicker();

    void insertColor(const QColor &color, const QString &text = QString::null, int index = -1);

    QColor currentColor() const;

    QColor color(int index) const;

    void setColorDialogEnabled(bool enabled);
    bool colorDialogEnabled() const;

    void setStandardColors();

    static QColor getColor(const QPoint &pos, bool allowCustomColors = true);

public slots:
    void setCurrentColor(const QColor &col);

signals:
    void colorChanged(const QColor &);

protected:
    void focusOutEvent(QFocusEvent *e);
    void paintEvent(QPaintEvent *e);

private slots:
    void buttonPressed();
    void popupClosed();

private:
    ColorPickerPopup *popup;
    QColor col;
    bool withColorDialog;
    int numCols;
    bool hasFocusRect;
    int labHeight;
    bool firstInserted;
    bool dirty;
};

#endif

Copyright © 2003-2006 TrolltechTrademarks
Qt Solutions