Version: 9.16.0
QtxColorButton.h
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, OPEN CASCADE
2//
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7//
8// This library is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20// File: QtxColorButton.h
21// Author: Sergey TELKOV
22//
23#ifndef QTXCOLORBUTTON_H
24#define QTXCOLORBUTTON_H
25
26#include "Qtx.h"
27
28#include <QMap>
29#include <QColor>
30#include <QPixmap>
31#include <QToolButton>
32
33class QPaintDevice;
34
36{
37 Q_OBJECT
38
39public:
40 QtxColorButton( QWidget* = 0 );
41 virtual ~QtxColorButton();
42
43 QColor color() const;
44 void setColor( const QColor& );
45
46 bool eventFilter( QObject*, QEvent* );
47
48 bool isAutoEnabled() const;
49 void setAutoEnabled( bool );
50
51 QString autoText() const;
52 void setAutoText( const QString& );
53
54 QSize sizeHint() const;
55
56signals:
57 void clicked( QColor );
58 void changed( QColor );
59
60private slots:
61 void onClicked( bool );
62 void onToggled( bool );
63
64 void onAboutToShow();
65 void onAutoClicked( bool );
66 void onDialogClicked( bool );
67
68protected:
69 virtual void paintEvent( QPaintEvent* );
70
71private:
72 QList<QColor> colorsList() const;
73
74 void updateState();
75 void updateButton( QToolButton* );
76 QPixmap buttonIcon( const QColor& ) const;
77 void drawColor( QPaintDevice*, const QColor&, const QColor& = Qt::black, const int = 1 ) const;
78
79private:
80 typedef QMap<const QToolButton*, QColor> ColorMap;
81
82private:
85};
86
87#endif
#define QTX_EXPORT
Definition: Qtx.h:36
For more information see QT documentation.
The QtxColorButton class implements a widget for color preference items editing.
Definition: QtxColorButton.h:36
ColorMap myColors
Definition: QtxColorButton.h:83
QToolButton * myAutoButton
Definition: QtxColorButton.h:84
QMap< const QToolButton *, QColor > ColorMap
Definition: QtxColorButton.h:80
void clicked(QColor)
This signal is emitted when the widget button is clicked by the user.
void changed(QColor)
This signal is emitted when the current color is changed.
Quantity_Color color(const QColor &)
Convert QColor object to Quantity_Color object.
Definition: OCCViewer.cxx:28