Tulip  5.0.0
Large graphs analysis and drawing
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  QString text() const;
42  Color tulipColor() const;
43 
44  void setDialogParent(QWidget* w);
45 
46 protected:
47  QColor _color;
48  QString _text;
49  QWidget* _dialogParent;
50  QString _dialogTitle;
51 
52 signals:
53  void colorChanged(QColor);
54  void tulipColorChanged(Color);
55 
56 public slots:
57  void setColor(const QColor&);
58  void setText(const QString& text);
59  void setTulipColor(const Color&);
60  void setDialogTitle(const QString&);
61 
62 protected slots:
63  void chooseColor();
64 };
65 
66 class TLP_QT_SCOPE ColorButton : public ChooseColorButton {
67  Q_OBJECT
68 
69 public:
70  explicit ColorButton(QWidget *parent = NULL): ChooseColorButton(parent) {}
71 protected:
72  void paintEvent(QPaintEvent *);
73 };
74 
75 }
76 
77 #endif // COLORBUTTON_H
78 ///@endcond