File indexing completed on 2024-04-21 14:55:51

0001 /* This file is part of the KDE libraries
0002  *
0003  * Copyright (C) 1997 Martin Jones (mjones@kde.org)
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Library General Public
0007  * License as published by the Free Software Foundation; either
0008  * version 2 of the License, or (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * Library General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Library General Public License
0016  * along with this library; see the file COPYING.LIB.  If not, write to
0017  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019 */
0020 
0021 #ifndef KCOLORVALUESELECTOR_H
0022 #define KCOLORVALUESELECTOR_H
0023 
0024 #include "kselector.h"
0025 #include "kcolorchoosermode.h"
0026 #include <kdelibs4support_export.h>
0027 #include <QPixmap>
0028 
0029 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KColorValueSelector : public KSelector
0030 {
0031     Q_OBJECT
0032     Q_PROPERTY(int hue READ hue WRITE setHue)
0033     Q_PROPERTY(int saturation READ saturation WRITE setSaturation)
0034     Q_PROPERTY(int colorValue READ colorValue WRITE setColorValue)
0035 public:
0036     /**
0037      * Constructs a widget for color selection.
0038      */
0039     KDELIBS4SUPPORT_DEPRECATED explicit KColorValueSelector(QWidget *parent = nullptr);
0040     /**
0041      * Constructs a widget for color selection with a given orientation
0042      */
0043     KDELIBS4SUPPORT_DEPRECATED explicit KColorValueSelector(Qt::Orientation o, QWidget *parent = nullptr);
0044 
0045     ~KColorValueSelector() override;
0046 
0047     /**
0048      * Updates the widget's contents.
0049      */
0050     void updateContents();
0051 
0052     /**
0053      * Returns the current hue value.
0054      *
0055      * @return               The hue value (0-359)
0056      */
0057     int hue() const;
0058 
0059     /**
0060      * Sets the hue value. Doesn't automatically update the widget;
0061      * you have to call updateContents manually.
0062      *
0063      * @param     hue         Sets the hue value (0-359)
0064      */
0065     void setHue(int hue);
0066 
0067     /**
0068      * Returns the current saturation value.
0069      *
0070      * @return                The saturation value (0-255)
0071      */
0072     int saturation() const;
0073 
0074     /**
0075      * Sets the saturation value. Doesn't automatically update the widget;
0076      * you have to call updateContents manually.
0077      *
0078      * @param     saturation      Sets the saturation value (0-255)
0079      */
0080     void setSaturation(int saturation);
0081 
0082     /**
0083      * Returns the current color value.
0084      *
0085      * @return                The color value (0-255)
0086      */
0087     int colorValue() const;
0088 
0089     /**
0090      * Sets the color value. Doesn't automatically update the widget;
0091      * you have to call updateContents manually.
0092      *
0093      * @param     colorValue      Sets the color value (0-255)
0094      */
0095     void setColorValue(int colorValue);
0096 
0097     /**
0098      * Sets the chooser mode. Doesn't automatically update the widget;
0099      * you have to call updateContents manually.
0100      *
0101      * @param     chooserMode     Sets the chooser mode (one of the KColorChooserMode constants)
0102      */
0103     void setChooserMode(KColorChooserMode chooserMode);
0104 
0105     /**
0106      * Returns the current chooser mode.
0107      *
0108      * @return                The chooser mode (one of the KColorChooserMode constants)
0109      */
0110     KColorChooserMode chooserMode() const;
0111 
0112 protected:
0113     /**
0114      * Draws the contents of the widget on a pixmap,
0115      * which is used for buffering.
0116      */
0117     virtual void drawPalette(QPixmap *pixmap);
0118     void resizeEvent(QResizeEvent *) override;
0119 
0120     /**
0121      * Reimplemented from KSelector. The drawing is
0122      * buffered in a pixmap here. As real drawing
0123      * routine, drawPalette() is used.
0124      */
0125     void drawContents(QPainter *painter) override;
0126 
0127 private:
0128     class Private;
0129     friend class Private;
0130 
0131     Private *const d;
0132 
0133     Q_DISABLE_COPY(KColorValueSelector)
0134 };
0135 
0136 #endif /* KCOLORVALUESELECTOR_H */
0137