Qt 4.8
qcolordialog.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QCOLORDIALOG_H
43 #define QCOLORDIALOG_H
44 
45 #include <QtGui/qdialog.h>
46 
48 
50 
51 QT_MODULE(Gui)
52 
53 #ifndef QT_NO_COLORDIALOG
54 
56 
58 {
59  Q_OBJECT
62  QColor currentColor;
63  ColorDialogOptions options;
64 
65 public:
67  ShowAlphaChannel = 0x00000001,
68  NoButtons = 0x00000002,
69  DontUseNativeDialog = 0x00000004
70  };
71 
72  Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)
73 
74  explicit QColorDialog(QWidget *parent = 0);
75  explicit QColorDialog(const QColor &initial, QWidget *parent = 0);
76  ~QColorDialog();
77 
78  void setCurrentColor(const QColor &color);
79  QColor currentColor() const;
80 
81  QColor selectedColor() const;
82 
83  void setOption(ColorDialogOption option, bool on = true);
84  bool testOption(ColorDialogOption option) const;
85  void setOptions(ColorDialogOptions options);
86  ColorDialogOptions options() const;
87 
88 #ifdef Q_NO_USING_KEYWORD
89  void open() { QDialog::open(); }
90 #else
91  using QDialog::open;
92 #endif
93  void open(QObject *receiver, const char *member);
94 
95  void setVisible(bool visible);
96 
97  // ### Qt 5: merge overloads with title = QString()
98  static QColor getColor(const QColor &initial, QWidget *parent, const QString &title,
99  ColorDialogOptions options = 0);
100  static QColor getColor(const QColor &initial = Qt::white, QWidget *parent = 0);
101 
102  // obsolete
103  static QRgb getRgba(QRgb rgba = 0xffffffff, bool *ok = 0, QWidget *parent = 0);
104 
105  // ### Qt 5: use QColor in signatures
106  static int customCount();
107  static QRgb customColor(int index);
108  static void setCustomColor(int index, QRgb color);
109  static void setStandardColor(int index, QRgb color);
110 
111 #ifdef QT3_SUPPORT
112  static QColor getColor(const QColor &init, QWidget *parent, const char *name)
113  { Q_UNUSED(name); return getColor(init, parent); }
114  static QRgb getRgba(QRgb rgba, bool *ok, QWidget *parent, const char *name)
115  { Q_UNUSED(name); return getRgba(rgba, ok, parent); }
116 #endif
117 
118 Q_SIGNALS:
119  void currentColorChanged(const QColor &color);
120  void colorSelected(const QColor &color);
121 
122 protected:
123  void changeEvent(QEvent *event);
124  void done(int result);
125 
126 private:
128 
129  Q_PRIVATE_SLOT(d_func(), void _q_addCustom())
130  Q_PRIVATE_SLOT(d_func(), void _q_newHsv(int h, int s, int v))
131  Q_PRIVATE_SLOT(d_func(), void _q_newColorTypedIn(QRgb rgb))
132  Q_PRIVATE_SLOT(d_func(), void _q_newCustom(int, int))
133  Q_PRIVATE_SLOT(d_func(), void _q_newStandard(int, int))
134 #if defined(Q_WS_MAC)
135  Q_PRIVATE_SLOT(d_func(), void _q_macRunNativeAppModalPanel())
136 #endif
137 
138  friend class QColorShower;
139 };
140 
141 Q_DECLARE_OPERATORS_FOR_FLAGS(QColorDialog::ColorDialogOptions)
142 
143 #endif // QT_NO_COLORDIALOG
144 
146 
148 
149 #endif // QCOLORDIALOG_H
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
ColorDialogOption
This enum specifies various options that affect the look and feel of a color dialog.
Definition: qcolordialog.h:66
unsigned int QRgb
Definition: qrgb.h:53
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
EventRef event
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
Definition: qglobal.h:2348
The QDialog class is the base class of dialog windows.
Definition: qdialog.h:56
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
#define Q_PRIVATE_SLOT(d, signature)
Definition: qobjectdefs.h:73
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_SIGNALS
Definition: qobjectdefs.h:72
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QColorDialog class provides a dialog widget for specifying colors.
Definition: qcolordialog.h:57
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global operator|() functions for Flags...
Definition: qglobal.h:2355
static bool init
const char * name
virtual void changeEvent(QEvent *)
This event handler can be reimplemented to handle state changes.
Definition: qwidget.cpp:9170
#define Q_OBJECT
Definition: qobjectdefs.h:157
#define rgb(r, g, b)
Definition: qcolor_p.cpp:130
virtual void done(int)
Closes the dialog and sets its result code to r.
Definition: qdialog.cpp:617
quint16 index
void open()
Shows the dialog as a window modal dialog, returning immediately.
Definition: qdialog.cpp:492
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
#define QT_END_HEADER
Definition: qglobal.h:137
void setVisible(bool visible)
Reimplemented Function
Definition: qdialog.cpp:756
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729