itom 2.2.1
K:/git-itom/sources/itom/itomWidgets/colorDialog.h
00001 /*=========================================================================
00002 
00003   Library:   CTK
00004 
00005   Copyright (c) Kitware Inc.
00006 
00007   Licensed under the Apache License, Version 2.0 (the "License");
00008   you may not use this file except in compliance with the License.
00009   You may obtain a copy of the License at
00010 
00011       http://www.apache.org/licenses/LICENSE-2.0.txt
00012 
00013   Unless required by applicable law or agreed to in writing, software
00014   distributed under the License is distributed on an "AS IS" BASIS,
00015   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016   See the License for the specific language governing permissions and
00017   limitations under the License.
00018 
00019 =========================================================================*/
00020 
00021 #ifndef COLORDIALOG_H
00022 #define COLORDIALOG_H
00023 
00024 // Qt includes
00025 #include <QColorDialog>
00026 
00027 // CTK includes
00028 #include "commonWidgets.h"
00029 
00030 class ColorDialogPrivate;
00031 
00035 class ITOMWIDGETS_EXPORT ColorDialog : public QColorDialog
00036 {
00037   Q_OBJECT
00038 
00039 public:
00043   explicit ColorDialog(QWidget* parent = 0);
00044   explicit ColorDialog(const QColor& initial, QWidget* parent = 0);
00045   virtual ~ColorDialog();
00046 
00057   inline void addTab(QWidget* widget, const QString& label);
00058 
00062   void insertTab(int tabIndex, QWidget* widget, const QString& label);
00063 
00067   void removeTab(int index);
00068 
00070   void setCurrentTab(int index);
00071 
00074   QWidget* widget(int index)const;
00075 
00078   int indexOf(QWidget* widget)const;
00079 
00081   QString colorName()const;
00082 
00090   static QColor getColor(const QColor &initial, QWidget *parent,
00091                          const QString &title, ColorDialogOptions options = 0);
00095   static QString getColorName();
00096 
00101   static inline void addDefaultTab(QWidget* widget, const QString& label,
00102                                    const char* colorSignal = 0,
00103                                    const char* nameSignal = 0);
00107   static void insertDefaultTab(int tabIndex, QWidget* widget, const QString& label,
00108                                const char* colorSignal = 0,
00109                                const char* nameSignal = 0);
00112   static void setDefaultTab(int index);
00113 
00114 public Q_SLOTS:
00116   void setColor(const QColor& color);
00117 
00120   void setColorName(const QString& name);
00121 
00122 Q_SIGNALS:
00123   void currentColorNameChanged(const QString& colorName);
00124 
00125 protected Q_SLOTS:
00126   void resetColorName();
00127 
00128 protected:
00129   QScopedPointer<ColorDialogPrivate> d_ptr;
00130 
00131   static QList<QWidget*> DefaultTabs;
00132   static int DefaultTab;
00133   static QString LastColorName;
00134 private:
00135   Q_DECLARE_PRIVATE(ColorDialog);
00136   Q_DISABLE_COPY(ColorDialog);
00137 };
00138 
00139 //------------------------------------------------------------------------------
00140 void ColorDialog::addTab(QWidget* widget, const QString& label)
00141 {
00142   this->insertTab(-1, widget, label);
00143 }
00144 
00145 //------------------------------------------------------------------------------
00146 void ColorDialog::addDefaultTab(QWidget* widget, const QString& label,
00147                                    const char* colorSignal,
00148                                    const char* nameSignal)
00149 {
00150   ColorDialog::insertDefaultTab(-1, widget, label, colorSignal, nameSignal);
00151 }
00152 
00153 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties Friends