Back to index

salome-gui  6.5.0
QtxBackgroundTool.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 // File:      QtxBackgroundTool.h
00021 // Author:    Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
00022 
00023 #ifndef QTXBACKGROUNDTOOL_H
00024 #define QTXBACKGROUNDTOOL_H
00025 
00026 #include "Qtx.h"
00027 #include "QtxDialog.h"
00028 
00029 #include <QWidget>
00030 #include <QMap>
00031 
00032 class QCheckBox;
00033 class QComboBox;
00034 class QStackedWidget;
00035 class QLineEdit;
00036 class QPushButton;
00037 class QtxColorButton;
00038 
00039 class QTX_EXPORT QtxBackgroundTool : public QWidget
00040 {
00041   enum { Color, Gradient };
00042   enum { TypeRole = Qt::UserRole, IdRole };
00043 
00044   Q_OBJECT
00045 
00046 public:
00047   QtxBackgroundTool( QWidget* = 0 );
00048   QtxBackgroundTool( Qt::Orientation, QWidget* = 0 );
00049   virtual ~QtxBackgroundTool();
00050 
00051   Qtx::BackgroundData data() const;
00052   void                setData( const Qtx::BackgroundData& );
00053 
00054   void                gradients( QStringList&, QIntList& ) const;
00055   void                setGradients( const QStringList&, const QIntList& = QIntList() );
00056 
00057   bool                isModeAllowed( Qtx::BackgroundMode ) const;
00058   void                setModeAllowed( Qtx::BackgroundMode, bool = true );
00059 
00060   bool                isTextureModeAllowed( Qtx::TextureMode ) const;
00061   void                setTextureModeAllowed( Qtx::TextureMode, bool = true );
00062 
00063   bool                isTextureAllowed() const;
00064   void                setTextureAllowed( bool = true );
00065 
00066   QString             imageFormats() const;
00067   void                setImageFormats( const QString& );
00068 
00069   Qt::Orientation     orientation() const;
00070   void                setOrientation( Qt::Orientation );
00071 
00072 private:
00073   void                init( Qt::Orientation );
00074   void                internalUpdate();
00075 
00076 private slots:
00077   void                updateState();
00078   void                browse();
00079   
00080 private:
00081   QComboBox*          myModeCombo;
00082   QStackedWidget*     myCContainer;
00083   QWidget*            myTContainer;
00084   QCheckBox*          myTextureCheck;
00085   QLineEdit*          myFileName;
00086   QPushButton*        myBrowseBtn;
00087   QComboBox*          myTextureMode;
00088   QtxColorButton*     myFirstColor;
00089   QtxColorButton*     mySecondColor;
00090   QStringList         myGradients;
00091   QIntList            myGradientsIds;
00092   bool                myTextureAllowed;
00093   QMap<int, bool>     myTypesAllowed;
00094   QMap<int, bool>     myTextureTypesAllowed;
00095   QString             myImageFormats;
00096   int                 myLastGradient;
00097 };
00098 
00099 class QTX_EXPORT QtxBackgroundDialog : public QtxDialog
00100 {
00101   Q_OBJECT
00102 
00103 public:
00104   QtxBackgroundDialog( QWidget* = 0 );
00105   QtxBackgroundDialog( const Qtx::BackgroundData&, QWidget* = 0 );
00106   virtual ~QtxBackgroundDialog();
00107 
00108   void                       setData( const Qtx::BackgroundData& );
00109   Qtx::BackgroundData        data() const;
00110 
00111   static Qtx::BackgroundData getBackground( const Qtx::BackgroundData& = Qtx::BackgroundData(),
00112                                        QWidget* = 0,
00113                                        bool = true, bool = true, bool = true, bool = true,
00114                                        const QStringList& = QStringList(),
00115                                        const QIntList& = QIntList(),
00116                                        const QString& = QString() );
00117   static Qtx::BackgroundData getBackground( const Qtx::BackgroundData&,
00118                                        QWidget*,
00119                                        const QIntList&,
00120                                        bool = true, bool = true, bool = true, bool = true,
00121                                        const QStringList& = QStringList(),
00122                                        const QIntList& = QIntList(),
00123                                        const QString& = QString() );
00124 
00125 
00126   void                       setGradients( const QStringList&, const QIntList& = QIntList() );
00127   void                       setModeAllowed( Qtx::BackgroundMode, bool = true );
00128   void                       setTextureAllowed( bool = true );
00129   void                       setTextureModeAllowed( Qtx::TextureMode, bool = true );
00130   void                       setImageFormats( const QString& );
00131 
00132 private:
00133   void                       init();
00134 
00135 private:
00136   QtxBackgroundTool*         myTool;
00137 };
00138 
00139 #endif // QTXBACKGROUNDTOOL_H