Version: 6.3.1

src/Qtx/Qtx.h

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // File:      Qtx.h
00024 // Author:    Sergey TELKOV
00025 //
00026 #ifndef QTX_H
00027 #define QTX_H
00028 
00029 #if defined WIN32
00030 #  if defined QTX_EXPORTS || defined qtx_EXPORTS
00031 #    define QTX_EXPORT _declspec( dllexport )
00032 #  else
00033 #    define QTX_EXPORT _declspec( dllimport )
00034 #  endif
00035 #else
00036 #  define QTX_EXPORT  
00037 #endif
00038 
00039 #if defined SOLARIS
00040 #define bool  int
00041 #define false 0
00042 #define true  1
00043 #endif
00044 
00045 #include <QString>
00046 #include <QList>
00047 #include <QColor>
00048 #include <QImage>
00049 #include <QPixmap>
00050 
00051 class QObject;
00052 class QWidget;
00053 class QCompleter;
00054 class QLinearGradient;
00055 class QRadialGradient;
00056 class QConicalGradient;
00057 
00058 typedef QList<int>    QIntList;       
00059 typedef QList<short>  QShortList;     
00060 typedef QList<double> QDoubleList;    
00061 typedef QList<QColor> QColorList;     
00062 
00063 class QTX_EXPORT Qtx
00064 {
00065 public:
00067   typedef enum
00068   {
00069     AlignLeft            = Qt::AlignLeft,            
00070     AlignLeading         = Qt::AlignLeading,         
00071     AlignRight           = Qt::AlignRight,           
00072     AlignTrailing        = Qt::AlignTrailing,        
00073     AlignHCenter         = Qt::AlignHCenter,         
00074     AlignJustify         = Qt::AlignJustify,         
00075     AlignAbsolute        = Qt::AlignAbsolute,        
00076     AlignHorizontal_Mask = Qt::AlignHorizontal_Mask, 
00077 
00078     AlignTop             = Qt::AlignTop,             
00079     AlignBottom          = Qt::AlignBottom,          
00080     AlignVCenter         = Qt::AlignVCenter,         
00081     AlignVertical_Mask   = Qt::AlignVertical_Mask,   
00082 
00083     AlignCenter          = Qt::AlignCenter,          
00084 
00085     AlignOutLeft         = Qt::AlignVCenter  << 2,   
00086     AlignOutRight        = AlignOutLeft      << 2,   
00087     AlignOutTop          = AlignOutRight     << 2,   
00088     AlignOutBottom       = AlignOutTop       << 2    
00089   } AlignmentFlags;
00090 
00092   typedef enum { 
00093     PT_OpenFile,      
00094     PT_SaveFile,      
00095     PT_Directory      
00096   } PathType;
00097 
00099   enum { 
00100     AppropriateRole = Qt::UserRole + 100   
00101   };
00102 
00103   typedef enum {
00104         Shown,   
00105         Hidden,  
00106         Toggled  
00107   } Appropriate;  
00108 
00110   typedef enum {
00111         Always, 
00112         Never,  
00113         Auto    
00114   } SubstMode;
00115 
00117   typedef enum {
00118     ShownState,             
00119     HiddenState,            
00120     UnpresentableState,     
00121   } VisibilityState;
00122 
00124   typedef enum {
00125     ShowText = 0x001,                
00126     ShowIcon = 0x010,                
00127     ShowAll  = ShowText | ShowIcon   
00128   } HeaderViewFlags;
00129 
00130   //Type of the custom data
00131   typedef enum {
00132     IdType
00133   } CustomDataType;
00134 
00135 
00136 
00137   class QTX_EXPORT Localizer
00138   {
00139   public:
00140     Localizer();
00141     ~Localizer();
00142   private:
00143     QString myCurLocale;
00144   };
00145 
00146   static QString     toQString( const char*, const int = -1 );
00147   static QString     toQString( const short*, const int = -1 );
00148   static QString     toQString( const unsigned char*, const int = -1 );
00149   static QString     toQString( const unsigned short*, const int = -1 );
00150 
00151   static void        setTabOrder( QWidget*, ... );
00152   static void        setTabOrder( const QWidgetList& );
00153   static void        alignWidget( QWidget*, const QWidget*, const int );
00154 
00155   static void        simplifySeparators( QWidget*, const bool = true );
00156 
00157   static bool        isParent( QObject*, QObject* );
00158   static QObject*    findParent( QObject*, const char* );
00159 
00160   static QString     dir( const QString&, const bool = true );
00161   static QString     file( const QString&, const bool = true );
00162   static QString     extension( const QString&, const bool = false );
00163 
00164   static QString     library( const QString& );
00165 
00166   static QString     tmpDir();
00167   static bool        mkDir( const QString& );
00168   static bool        rmDir( const QString& );
00169   static bool        dos2unix( const QString& );
00170   static QString     addSlash( const QString& );
00171 
00172   static QCompleter* pathCompleter( const PathType, const QString& = QString() );
00173   static QString     findEnvVar( const QString&, int&, int& );
00174   static QString     makeEnvVarSubst( const QString&, const SubstMode = Auto );
00175 
00176   static int         rgbSet( const QColor& );
00177   static int         rgbSet( const int, const int, const int );
00178 
00179   static QColor      rgbSet( const int );
00180   static void        rgbSet( const int, int&, int&, int& );
00181 
00182   static QColor      scaleColor( const int, const int, const int );
00183   static void        scaleColors( const int, QColorList& );
00184 
00185   static QPixmap     scaleIcon( const QPixmap&, const unsigned, const unsigned = 0 );
00186   static QImage      grayscale( const QImage& );
00187   static QPixmap     grayscale( const QPixmap& );
00188   static QImage      transparentImage( const int, const int, const int = -1 );
00189   static QPixmap     transparentPixmap( const int, const int, const int = -1 );
00190   static QPixmap     composite( const QPixmap&, const int, const int, const QPixmap& = QPixmap() );
00191 
00192   static QString     colorToString( const QColor& );
00193   static bool        stringToColor( const QString&, QColor& );
00194 
00195   static QString     gradientToString( const QLinearGradient& );
00196   static QString     gradientToString( const QRadialGradient& );
00197   static QString     gradientToString( const QConicalGradient& );
00198   static bool        stringToLinearGradient( const QString&, QLinearGradient& );
00199   static bool        stringToRadialGradient( const QString&, QRadialGradient& );
00200   static bool        stringToConicalGradient( const QString&, QConicalGradient& );
00201 
00202 #ifndef WIN32
00203   static void*       getDisplay();
00204   static Qt::HANDLE  getVisual();
00205 #endif
00206 };
00207 
00208 #endif
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS