CTK 0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
Loading...
Searching...
No Matches
ctkColorPickerButton.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Library: CTK
4
5 Copyright (c) Kitware Inc.
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0.txt
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18
19=========================================================================*/
20
21#ifndef __ctkColorPickerButton_h
22#define __ctkColorPickerButton_h
23
24// Qt includes
25#include <QPushButton>
26#include <QColor>
27
28// CTK includes
29#include "ctkWidgetsExport.h"
30class ctkColorPickerButtonPrivate;
31
38class CTK_WIDGETS_EXPORT ctkColorPickerButton : public QPushButton
39{
40 Q_OBJECT
41 Q_FLAGS(ColorDialogOption ColorDialogOptions)
42
43
45 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged USER true)
46
50 Q_PROPERTY(QString colorName READ colorName WRITE setColorName NOTIFY colorNameChanged)
51
55 Q_PROPERTY(bool displayColorName READ displayColorName WRITE setDisplayColorName DESIGNABLE true)
56
58 Q_PROPERTY(ColorDialogOptions dialogOptions READ dialogOptions WRITE setDialogOptions)
59public:
61 ShowAlphaChannel = 0x00000001,
62 NoButtons = 0x00000002,
63 DontUseNativeDialog = 0x00000004,
64 UseCTKColorDialog = 0x0000000C
65 };
66 Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)
67
68
69 explicit ctkColorPickerButton(QWidget* parent = 0);
70
74 explicit ctkColorPickerButton(const QString& text, QWidget* parent = 0 );
75
79 explicit ctkColorPickerButton(const QColor& color, const QString & text, QWidget* parent = 0 );
80
82
84 QColor color()const;
85
90 QString colorName()const;
91
95 void setColorName(const QString& name);
96
99 bool displayColorName()const;
100
104 void setDialogOptions(const ColorDialogOptions& options);
105 const ColorDialogOptions& dialogOptions() const;
106
110 virtual QSize sizeHint()const;
111
112public Q_SLOTS:
115 void setColor(const QColor& color);
116
121 void changeColor();
122
126 void setDisplayColorName(bool displayColorName);
127
128Q_SIGNALS:
131 void colorChanged(QColor);
132
134 void colorNameChanged(QString);
135
136protected Q_SLOTS:
137 void onToggled(bool change = true);
138
139protected:
140 virtual void paintEvent(QPaintEvent* event);
141
142 QScopedPointer<ctkColorPickerButtonPrivate> d_ptr;
143private :
144 Q_DECLARE_PRIVATE(ctkColorPickerButton);
145 Q_DISABLE_COPY(ctkColorPickerButton);
146};
147
149
150#endif
Q_DECLARE_OPERATORS_FOR_FLAGS(ctkVTKDataSetModel::AttributeTypes)