X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FQtx%2FQtx.h;h=cf7ba26c44aa6c9901594bc4eb50dff0e2ef4911;hb=389efae83b99d654509671e60af3eecf11b8278e;hp=3b8e4ddf3749d5c40d415fbf98672fdbf71644d7;hpb=2e750f9ded92337bc3c44e9d7388180974cc4a43;p=modules%2Fgui.git diff --git a/src/Qtx/Qtx.h b/src/Qtx/Qtx.h index 3b8e4ddf3..cf7ba26c4 100755 --- a/src/Qtx/Qtx.h +++ b/src/Qtx/Qtx.h @@ -1,21 +1,39 @@ +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + // File: Qtx.h // Author: Sergey TELKOV - +// #ifndef QTX_H #define QTX_H -#if defined QTX_EXPORTS #if defined WIN32 -#define QTX_EXPORT _declspec( dllexport ) -#else -#define QTX_EXPORT -#endif +# if defined QTX_EXPORTS || defined qtx_EXPORTS +# define QTX_EXPORT _declspec( dllexport ) +# else +# define QTX_EXPORT _declspec( dllimport ) +# endif #else -#if defined WIN32 -#define QTX_EXPORT _declspec( dllimport ) -#else -#define QTX_EXPORT -#endif +# define QTX_EXPORT #endif #if defined SOLARIS @@ -24,88 +42,228 @@ #define true 1 #endif -#ifndef INCLUDE_MENUITEM_DEF -#define INCLUDE_MENUITEM_DEF -#endif - -#include - -#ifndef QT_VERSION -#define QT_VER 0 -#else -#if QT_VERSION >= 0x30000 -#define QT_VER 3 -#else -#if QT_VERSION >= 300 -#define QT_VER 3 -#else -#if QT_VERSION >= 200 -#define QT_VER 2 -#else -#if QT_VERSION >= 100 -#define QT_VER 1 -#endif -#endif -#endif -#endif -#endif +#include +#include +#include +#include +#include +#include class QObject; -class QString; class QWidget; -class QToolBar; -class QGroupBox; -class QPopupMenu; -class QWidgetList; +class QCompleter; -template class QValueList; +typedef QList QIntList; //!< list of int values +typedef QList QShortList; //!< list of short int values +typedef QList QDoubleList; //!< list of double values +typedef QList QColorList; //!< list of colors -#if QT_VER < 3 -#define QPtrList QList -#define QPtrListIterator QListIterator -#endif - -typedef QValueList QIntList; -typedef QValueList QShortList; -typedef QValueList QDoubleList; - -class QTX_EXPORT Qtx : public Qt +class QTX_EXPORT Qtx { public: - enum AlignmentFlags - { - AlignOutLeft = AlignVCenter << 2, - AlignOutRight = AlignOutLeft << 2, - AlignOutTop = AlignOutRight << 2, - AlignOutBottom = AlignOutTop << 2 + //! Widget alignment flags + typedef enum + { + AlignLeft = Qt::AlignLeft, //!< align left side of one widget to the left side of another widget + AlignLeading = Qt::AlignLeading, //!< synonim for AlignLeft + AlignRight = Qt::AlignRight, //!< align right side of one widget to the right side of another widget + AlignTrailing = Qt::AlignTrailing, //!< synonim for AlignRight + AlignHCenter = Qt::AlignHCenter, //!< align one widget to the center of another widget in horizontal dimension + AlignJustify = Qt::AlignJustify, //!< synonym of Qt::AlignJustify + AlignAbsolute = Qt::AlignAbsolute, //!< synonym of Qt::AlignAbsolute + AlignHorizontal_Mask = Qt::AlignHorizontal_Mask, //!< synonym of Qt::AlignHorizontal_Mask + + AlignTop = Qt::AlignTop, //!< align top side of one widget to the top side of another widget + AlignBottom = Qt::AlignBottom, //!< align bottom side of one widget to the bottom side of another widget + AlignVCenter = Qt::AlignVCenter, //!< align one widget to the center of another widget in vertical dimension + AlignVertical_Mask = Qt::AlignVertical_Mask, //!< synonym of Qt::AlignVertical_Mask + + AlignCenter = Qt::AlignCenter, //!< align one widget to the center of another widget in both dimensions + + AlignOutLeft = Qt::AlignVCenter << 2, //!< align right side of one widget to the left side of another widget + AlignOutRight = AlignOutLeft << 2, //!< align left side of one widget to the right side of another widget + AlignOutTop = AlignOutRight << 2, //!< align bottom side of one widget to the top side of another widget + AlignOutBottom = AlignOutTop << 2 //!< align top side of one widget to the bottom side of another widget + } AlignmentFlags; + + //! Path type, indicates required directory/file operation + typedef enum { + PT_OpenFile, //!< the file is opened + PT_SaveFile, //!< the file is saved + PT_Directory //!< the directory path is required + } PathType; + + //! Custom data roles + enum { + AppropriateRole = Qt::UserRole + 100 //!< can be used to return \c true if data is appropriate + }; + + typedef enum { + Shown, //!< column should be always visible + Hidden, //!< column should be always hidden + Toggled //!< it should be possible to show/hide the column with help of popup menu + } Appropriate; //!< appropriate status + + //! Environment variables substitution mode + typedef enum { + Always, //!< substitute environment variable by it's value if variable exists, and "" otherwise + Never, //!< keep environment variable as is without any substitution + Auto //!< substitute environment variable by it's value if variable exists, and keep it as is otherwise + } SubstMode; + + //! object visibility state + typedef enum { + ShownState, //!< Object is shown in viewer + HiddenState, //!< Object is hidden in viewer + UnpresentableState, //!< Unpresentable object + } VisibilityState; + + //! Header view flags + typedef enum { + ShowText = 0x001, //!< Show only text in the header + ShowIcon = 0x010, //!< Show only icon in the header + ShowAll = ShowText | ShowIcon //!< Show icon and text in the header + } HeaderViewFlags; + + //! Type of the custom data (for custom tree model) + typedef enum { + IdType + } CustomDataType; + + //! Background mode + typedef enum { + NoBackground, // no (invalid) background data + ColorBackground, // single color + SimpleGradientBackground, // simple two-color gradient + CustomGradientBackground // custom (complex) gradient + } BackgroundMode; + + //! Texture mode + typedef enum { + CenterTexture, // center texture + TileTexture, // tile texture + StretchTexture, // stretch texture + } TextureMode; + + class QTX_EXPORT Localizer + { + public: + Localizer(); + ~Localizer(); + private: + QString myCurLocale; + }; + + class QTX_EXPORT BackgroundData + { + public: + BackgroundData(); + BackgroundData( const QColor& ); + BackgroundData( int, const QColor&, const QColor& ); + BackgroundData( const QGradient& ); + virtual ~BackgroundData(); + + bool operator==( const BackgroundData&) const; + inline bool operator!=( const BackgroundData& other ) const + { return !operator==( other ); } + + bool isValid() const; + + BackgroundMode mode() const; + void setMode( const BackgroundMode ); + + TextureMode texture( QString& ) const; + void setTexture( const QString&, TextureMode = Qtx::CenterTexture ); + bool isTextureShown() const; + void setTextureShown( bool ); + + QColor color() const; + void setColor( const QColor& ); + + int gradient( QColor&, QColor& ) const; + void setGradient( int, const QColor&, const QColor& ); + + const QGradient* gradient() const; + void setGradient( const QGradient& ); + + private: + BackgroundMode myMode; + TextureMode myTextureMode; + QString myFileName; + QColorList myColors; + int myGradientType; + QGradient myGradient; + bool myTextureShown; }; - static void setTabOrder( QWidget*, ... ); - static void setTabOrder( const QWidgetList& ); - static void alignWidget( QWidget*, const QWidget*, const int ); + static QString toQString( const char*, const int = -1 ); + static QString toQString( const short*, const int = -1 ); + static QString toQString( const unsigned char*, const int = -1 ); + static QString toQString( const unsigned short*, const int = -1 ); + + static void setTabOrder( QWidget*, ... ); + static void setTabOrder( const QWidgetList& ); + static void alignWidget( QWidget*, const QWidget*, const int ); + + static void simplifySeparators( QWidget*, const bool = true ); + + static bool isParent( QObject*, QObject* ); + static QObject* findParent( QObject*, const char* ); + + static QString dir( const QString&, const bool = true ); + static QString file( const QString&, const bool = true ); + static QString extension( const QString&, const bool = false ); - static void simplifySeparators( QToolBar* ); - static void simplifySeparators( QPopupMenu*, const bool = true ); + static QString library( const QString& ); - static bool isParent( QObject*, QObject* ); + static QString tmpDir(); + static bool mkDir( const QString& ); + static bool rmDir( const QString& ); + static bool dos2unix( const QString& ); + static QString addSlash( const QString& ); - static QString extension( const QString& ); - static QString dir( const QString&, const bool = true ); - static QString file( const QString&, const bool = true ); + static QCompleter* pathCompleter( const PathType, const QString& = QString() ); + static QString findEnvVar( const QString&, int&, int& ); + static QString makeEnvVarSubst( const QString&, const SubstMode = Auto ); - static QString library( const QString& ); + static int rgbSet( const QColor& ); + static int rgbSet( const int, const int, const int ); - static QString tmpDir(); - static bool mkDir( const QString& ); - static bool rmDir( const QString& ); - static bool dos2unix( const QString& ); - static QString addSlash( const QString& ); + static QColor rgbSet( const int ); + static void rgbSet( const int, int&, int&, int& ); - static int rgbSet( const QColor& ); - static int rgbSet( const int, const int, const int ); + static QColor scaleColor( const int, const int, const int ); + static void scaleColors( const int, QColorList& ); - static void rgbSet( const int, QColor& ); - static void rgbSet( const int, int&, int&, int& ); + static QPixmap scaleIcon( const QPixmap&, const unsigned, const unsigned = 0 ); + static QImage grayscale( const QImage& ); + static QPixmap grayscale( const QPixmap& ); + static QImage transparentImage( const int, const int, const int = -1 ); + static QPixmap transparentPixmap( const int, const int, const int = -1 ); + static QPixmap composite( const QPixmap&, const int, const int, const QPixmap& = QPixmap() ); + + static QString colorToString( const QColor& ); + static bool stringToColor( const QString&, QColor& ); + static QString biColorToString( const QColor&, const int ); + static bool stringToBiColor( const QString&, QColor&, int& ); + static QColor mainColorToSecondary( const QColor&, int ); + + static QString gradientToString( const QLinearGradient& ); + static QString gradientToString( const QRadialGradient& ); + static QString gradientToString( const QConicalGradient& ); + static bool stringToLinearGradient( const QString&, QLinearGradient& ); + static bool stringToRadialGradient( const QString&, QRadialGradient& ); + static bool stringToConicalGradient( const QString&, QConicalGradient& ); + + static QString backgroundToString( const BackgroundData& ); + static BackgroundData stringToBackground( const QString& ); + + static long versionToId( const QString& ); + +#ifndef WIN32 + static void* getDisplay(); + static Qt::HANDLE getVisual(); +#endif }; #endif