Tulip  4.8.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
ColorButton.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef COLORBUTTON_H
22 #define COLORBUTTON_H
23 
24 #include <QPushButton>
25 
26 #include <tulip/tulipconf.h>
27 #include <tulip/Color.h>
28 #include <tulip/TulipMetaTypes.h>
29 
30 namespace tlp {
31 
32 class TLP_QT_SCOPE ChooseColorButton : public QPushButton {
33  Q_OBJECT
34  Q_PROPERTY(QColor color READ color WRITE setColor)
35  Q_PROPERTY(Color tulipColor READ tulipColor WRITE setTulipColor)
36 
37 public:
38  explicit ChooseColorButton(QWidget *parent = NULL);
39 
40  QColor color() const;
41  Color tulipColor() const;
42 
43  void setDialogParent(QWidget* w);
44 
45 protected:
46  QColor _color;
47  QWidget* _dialogParent;
48  QString _dialogTitle;
49 
50 signals:
51  void colorChanged(QColor);
52  void tulipColorChanged(Color);
53 
54 public slots:
55  void setColor(const QColor&);
56  void setTulipColor(const Color&);
57  void setDialogTitle(const QString&);
58 
59 protected slots:
60  void chooseColor();
61 };
62 
63 class TLP_QT_SCOPE ColorButton : public ChooseColorButton {
64  Q_OBJECT
65 
66 public:
67  explicit ColorButton(QWidget *parent = NULL): ChooseColorButton(parent) {}
68 protected:
69  void paintEvent(QPaintEvent *);
70 };
71 
72 }
73 
74 #endif // COLORBUTTON_H
75 ///@endcond