File: ColorChooser.h

package info (click to toggle)
equalx 0.7.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,268 kB
  • sloc: cpp: 7,119; ansic: 98; sql: 10; makefile: 6
file content (65 lines) | stat: -rw-r--r-- 1,523 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef COLORCHOOSER_H
#define COLORCHOOSER_H

#include <QFrame>
#include <QColor>
#include <QMenu>

class ColorChooser : public QFrame
{
    Q_OBJECT
    
public:
    enum CHOICE{
        CHOICE_FG,
        CHOICE_BG
    };

    ColorChooser(QWidget *parent = 0, Qt::WindowFlags f = 0);
    ~ColorChooser();

    QColor fgColor() const { return mFgColor; }
    QColor bgColor() const {return mBgColor; }

    void setFgColor(const QString& name);
    void setFgColor(const QColor& color);
    void setBgColor(const QString& name);
    void setBgColor(const QColor& color);

    QSize	sizeHint () const;

signals: // SIGNALS
    void fgColorChanged(QColor);
    void bgColorChanged(QColor);

private slots:
    void onColorChosen(QAction* act);
    void showColorsDialog();

protected:
    void paintEvent(QPaintEvent *event);
    void resizeEvent ( QResizeEvent * event );

    void mousePressEvent ( QMouseEvent * event );

    void showMenu(ColorChooser::CHOICE chosen);
private:
    void setupColorsMenu();
    void addMenuAction(const QColor& fillColor, const QString& name);
    QIcon createIcon(const QColor& fillcolor) const;

    QColor mFgColor;
    QColor mBgColor;
    QColor mActiveColor; // color of active Area

    QRect mFgArea;
    QRect mBgArea;
    QLine mSeparator;
    QMenu mColorsMenu;
    ColorChooser::CHOICE mSwatch; // identifies which swatch is active (FG or BG)

    int mPadding; // widgets padding
    int mSeparatorWidth; // spacer width between color swatches
};

#endif // COLORCHOOSER_H