swatch.hpp
Go to the documentation of this file.
1 
22 #ifndef COLOR_WIDGETS_SWATCH_HPP
23 #define COLOR_WIDGETS_SWATCH_HPP
24 
25 #include <QWidget>
26 #include <QPen>
27 #include "color_palette.hpp"
28 
29 namespace color_widgets {
30 
34 class Swatch : public QWidget
35 {
36  Q_OBJECT
37 
41  Q_PROPERTY(const ColorPalette& palette READ palette WRITE setPalette NOTIFY paletteChanged)
45  Q_PROPERTY(int selected READ selected WRITE setSelected NOTIFY selectedChanged)
46 
50  Q_PROPERTY(QSize colorSize READ colorSize WRITE setColorSize NOTIFY colorSizeChanged)
51 
53 
57  Q_PROPERTY(QPen border READ border WRITE setBorder NOTIFY borderChanged)
58 
69  Q_PROPERTY(int forcedRows READ forcedRows WRITE setForcedRows NOTIFY forcedRowsChanged)
70 
82 
87  Q_PROPERTY(bool readOnly READ readOnly WRITE setReadOnly NOTIFY readOnlyChanged)
88 
89 
90 public:
92  {
93  Hint,
96  };
97  Q_ENUMS(ColorSizePolicy)
98 
99  Swatch(QWidget* parent = 0);
100  ~Swatch();
101 
102  QSize sizeHint() const Q_DECL_OVERRIDE;
103  QSize minimumSizeHint() const Q_DECL_OVERRIDE;
104 
105  const ColorPalette& palette() const;
107  int selected() const;
111  QColor selectedColor() const;
112 
118  int indexAt(const QPoint& p);
119 
124  QColor colorAt(const QPoint& p);
125 
126  QSize colorSize() const;
128  QPen border() const;
129 
130  int forcedRows() const;
131  int forcedColumns() const;
132 
133  bool readOnly() const;
134 
135 public slots:
136  void setPalette(const ColorPalette& palette);
137  void setSelected(int selected);
138  void clearSelection();
139  void setColorSize(const QSize& colorSize);
141  void setBorder(const QPen& border);
142  void setForcedRows(int forcedRows);
144  void setReadOnly(bool readOnly);
148  void removeSelected();
149 
150 signals:
151  void paletteChanged(const ColorPalette& palette);
152  void selectedChanged(int selected);
153  void colorSelected(const QColor& color);
154  void colorSizeChanged(const QSize& colorSize);
156  void doubleClicked(int index);
157  void rightClicked(int index);
158  void forcedRowsChanged(int forcedRows);
160  void readOnlyChanged(bool readOnly);
161  void borderChanged(const QPen& border);
162 
163 protected:
164  bool event(QEvent* event) Q_DECL_OVERRIDE;
165 
166  void paintEvent(QPaintEvent* event) Q_DECL_OVERRIDE;
167 
168  void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE;
169 
170  void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
171  void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
172  void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
173  void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
174  void wheelEvent(QWheelEvent* event) Q_DECL_OVERRIDE;
175 
176  void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE;
177  void dragMoveEvent(QDragMoveEvent* event) Q_DECL_OVERRIDE;
178  void dragLeaveEvent(QDragLeaveEvent *event) Q_DECL_OVERRIDE;
179  void dropEvent(QDropEvent* event) Q_DECL_OVERRIDE;
180 
181 protected slots:
185  void paletteModified();
186 
187 private:
188  class Private;
189  Private* p;
190 };
191 
192 
193 } // namespace color_widgets
194 #endif // COLOR_WIDGETS_SWATCH_HPP
color
color
Definition: color.h:16
color_widgets::Swatch::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE
Definition: swatch.cpp:520
color_widgets::Swatch::borderChanged
void borderChanged(const QPen &border)
color_widgets::Swatch::colorAt
QColor colorAt(const QPoint &p)
Color at the given position within the widget.
Definition: swatch.cpp:294
color_widgets::Swatch::Minimum
@ Minimum
Can expand but not contract.
Definition: swatch.hpp:94
color_widgets::Swatch::dropEvent
void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE
Definition: swatch.cpp:603
color_widgets::Swatch::p
Private * p
Definition: swatch.hpp:188
color_widgets::Swatch::setForcedRows
void setForcedRows(int forcedRows)
Definition: swatch.cpp:714
color_widgets::Swatch::dragLeaveEvent
void dragLeaveEvent(QDragLeaveEvent *event) Q_DECL_OVERRIDE
Definition: swatch.cpp:598
color_widgets::Swatch::colorSizePolicy
ColorSizePolicy colorSizePolicy
Definition: swatch.hpp:52
color_widgets::Swatch::minimumSizeHint
QSize minimumSizeHint() const Q_DECL_OVERRIDE
Definition: swatch.cpp:248
color_widgets::Swatch::readOnlyChanged
void readOnlyChanged(bool readOnly)
color_widgets::Swatch::colorSizeChanged
void colorSizeChanged(const QSize &colorSize)
color_widgets::Swatch::selected
int selected
Currently selected color (-1 if no color is selected)
Definition: swatch.hpp:45
color_widgets::Swatch::dragMoveEvent
void dragMoveEvent(QDragMoveEvent *event) Q_DECL_OVERRIDE
Definition: swatch.cpp:591
color_widgets::Swatch::setReadOnly
void setReadOnly(bool readOnly)
Definition: swatch.cpp:731
color_widgets::Swatch::removeSelected
void removeSelected()
Remove the currently seleceted color.
Definition: swatch.cpp:494
color_widgets::ColorPalette
Definition: color_palette.hpp:34
color_widgets::Swatch::event
bool event(QEvent *event) Q_DECL_OVERRIDE
Definition: swatch.cpp:740
color_widgets::Swatch::mouseDoubleClickEvent
void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE
Definition: swatch.cpp:552
color_widgets::Swatch::keyPressEvent
void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE
Definition: swatch.cpp:399
color_widgets::Swatch::colorSelected
void colorSelected(const QColor &color)
color_widgets::Swatch::setColorSizePolicy
void setColorSizePolicy(ColorSizePolicy colorSizePolicy)
Definition: swatch.cpp:681
color_widgets::Swatch::forcedColumnsChanged
void forcedColumnsChanged(int forcedColumns)
color_widgets::Swatch::colorSize
QSize colorSize
Preferred size for a color square.
Definition: swatch.hpp:50
color_widgets::Swatch::ColorSizePolicy
ColorSizePolicy
Definition: swatch.hpp:91
color_widgets::Swatch::forcedColumns
int forcedColumns
Forces the Swatch to display that many columns of colors.
Definition: swatch.hpp:81
color_widgets::Swatch::mousePressEvent
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE
Definition: swatch.cpp:504
color_widgets::Swatch::paletteChanged
void paletteChanged(const ColorPalette &palette)
color_widgets::Swatch::selectedChanged
void selectedChanged(int selected)
color_widgets
Definition: color_dialog.hpp:33
color_widgets::Swatch::setForcedColumns
void setForcedColumns(int forcedColumns)
Definition: swatch.cpp:702
color_widgets::Swatch::Swatch
Swatch(QWidget *parent=0)
Definition: swatch.cpp:210
color_palette.hpp
color_widgets::Swatch::Private
Definition: swatch.cpp:38
color_widgets::Swatch
A widget drawing a palette.
Definition: swatch.hpp:34
color_widgets::Swatch::sizeHint
QSize sizeHint() const Q_DECL_OVERRIDE
Definition: swatch.cpp:235
color_widgets::Swatch::setColorSize
void setColorSize(const QSize &colorSize)
Definition: swatch.cpp:670
color_widgets::Swatch::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE
Definition: swatch.cpp:544
color_widgets::Swatch::palette
const ColorPalette palette
Palette shown by the widget.
Definition: swatch.hpp:41
color_widgets::Swatch::paintEvent
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE
Definition: swatch.cpp:326
color_widgets::Swatch::setPalette
void setPalette(const ColorPalette &palette)
Definition: swatch.cpp:299
color_widgets::Swatch::setBorder
void setBorder(const QPen &border)
Definition: swatch.cpp:774
color_widgets::Swatch::forcedRows
int forcedRows
Forces the Swatch to display that many rows of colors.
Definition: swatch.hpp:69
color_widgets::Swatch::Hint
@ Hint
The size is just a hint.
Definition: swatch.hpp:93
color_widgets::Swatch::setSelected
void setSelected(int selected)
Definition: swatch.cpp:307
color_widgets::Swatch::dragEnterEvent
void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE
Definition: swatch.cpp:573
color_widgets::Swatch::paletteModified
void paletteModified()
Connected to the internal palette object to keep eveything consistent.
Definition: swatch.cpp:652
color_widgets::Swatch::wheelEvent
void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE
Definition: swatch.cpp:562
color_widgets::Swatch::~Swatch
~Swatch()
Definition: swatch.cpp:230
color_widgets::Swatch::readOnly
bool readOnly
Whether the palette can be modified via user interaction.
Definition: swatch.hpp:87
color_widgets::Swatch::indexAt
int indexAt(const QPoint &p)
Color index at the given position within the widget.
Definition: swatch.cpp:275
color_widgets::Swatch::Fixed
@ Fixed
Must be exactly as specified.
Definition: swatch.hpp:95
color_widgets::Swatch::doubleClicked
void doubleClicked(int index)
color_widgets::Swatch::colorSizePolicyChanged
void colorSizePolicyChanged(ColorSizePolicy colorSizePolicy)
color_widgets::Swatch::border
QPen border
Border around the colors.
Definition: swatch.hpp:57
color_widgets::Swatch::clearSelection
void clearSelection()
Definition: swatch.cpp:321
color_widgets::Swatch::rightClicked
void rightClicked(int index)
color_widgets::Swatch::selectedColor
QColor selectedColor() const
Color at the currently selected index.
Definition: swatch.cpp:270
color_widgets::Swatch::forcedRowsChanged
void forcedRowsChanged(int forcedRows)


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:47