Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Qtx.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 
23 // File: Qtx.h
24 // Author: Sergey TELKOV
25 //
26 #ifndef QTX_H
27 #define QTX_H
28 
29 #if defined WIN32
30 # if defined QTX_EXPORTS || defined qtx_EXPORTS
31 # define QTX_EXPORT _declspec( dllexport )
32 # else
33 # define QTX_EXPORT _declspec( dllimport )
34 # endif
35 #else
36 # define QTX_EXPORT
37 #endif
38 
39 #if defined SOLARIS
40 #define bool int
41 #define false 0
42 #define true 1
43 #endif
44 
45 #include <QString>
46 #include <QList>
47 #include <QFont>
48 #include <QColor>
49 #include <QImage>
50 #include <QPixmap>
51 #include <QGradient>
52 
53 class QObject;
54 class QWidget;
55 class QCompleter;
56 
57 typedef QList<int> QIntList;
61 
63 {
64 public:
66  typedef enum
67  {
68  AlignLeft = Qt::AlignLeft,
69  AlignLeading = Qt::AlignLeading,
70  AlignRight = Qt::AlignRight,
71  AlignTrailing = Qt::AlignTrailing,
72  AlignHCenter = Qt::AlignHCenter,
73  AlignJustify = Qt::AlignJustify,
74  AlignAbsolute = Qt::AlignAbsolute,
75  AlignHorizontal_Mask = Qt::AlignHorizontal_Mask,
76 
77  AlignTop = Qt::AlignTop,
78  AlignBottom = Qt::AlignBottom,
79  AlignVCenter = Qt::AlignVCenter,
80  AlignVertical_Mask = Qt::AlignVertical_Mask,
81 
82  AlignCenter = Qt::AlignCenter,
83 
84  AlignOutLeft = Qt::AlignVCenter << 2,
85  AlignOutRight = AlignOutLeft << 2,
86  AlignOutTop = AlignOutRight << 2,
87  AlignOutBottom = AlignOutTop << 2
88  } AlignmentFlags;
89 
91  typedef enum {
94  PT_Directory
95  } PathType;
96 
98  enum {
99  AppropriateRole = Qt::UserRole + 100
100  };
101 
102  typedef enum {
105  Toggled
106  } Appropriate;
107 
109  typedef enum {
112  Auto
113  } SubstMode;
114 
116  typedef enum {
120  } VisibilityState;
121 
123  typedef enum {
124  ShowText = 0x001,
125  ShowIcon = 0x010,
126  ShowAll = ShowText | ShowIcon
127  } HeaderViewFlags;
128 
130  typedef enum {
131  IdType
132  } CustomDataType;
133 
135  typedef enum {
136  NoBackground, // no (invalid) background data
137  ColorBackground, // single color
138  SimpleGradientBackground, // simple two-color gradient
139  CustomGradientBackground // custom (complex) gradient
140  } BackgroundMode;
141 
143  typedef enum {
144  CenterTexture, // center texture
145  TileTexture, // tile texture
146  StretchTexture, // stretch texture
147  } TextureMode;
148 
150  {
151  public:
152  Localizer();
153  ~Localizer();
154  private:
155  QString myCurLocale;
156  };
157 
159  {
160  public:
161  CmdLineArgs();
162  ~CmdLineArgs();
163 
164  int argc() const;
165  char** argv() const;
166 
167  private:
168  int myArgc;
169  char** myArgv;
170  };
171 
173  {
174  public:
175  BackgroundData();
176  BackgroundData( const QColor& );
177  BackgroundData( int, const QColor&, const QColor& );
178  BackgroundData( const QGradient& );
179  virtual ~BackgroundData();
180 
181  bool operator==( const BackgroundData&) const;
182  inline bool operator!=( const BackgroundData& other ) const
183  { return !operator==( other ); }
184 
185  bool isValid() const;
186 
187  BackgroundMode mode() const;
188  void setMode( const BackgroundMode );
189 
190  TextureMode texture( QString& ) const;
191  void setTexture( const QString&, TextureMode = Qtx::CenterTexture );
192  bool isTextureShown() const;
193  void setTextureShown( bool );
194 
195  QColor color() const;
196  void setColor( const QColor& );
197 
198  int gradient( QColor&, QColor& ) const;
199  void setGradient( int, const QColor&, const QColor& );
200 
201  const QGradient* gradient() const;
202  void setGradient( const QGradient& );
203 
204  private:
207  QString myFileName;
210  QGradient myGradient;
212  };
213 
214  static QString toQString( const char*, const int = -1 );
215  static QString toQString( const short*, const int = -1 );
216  static QString toQString( const unsigned char*, const int = -1 );
217  static QString toQString( const unsigned short*, const int = -1 );
218 
219  static void setTabOrder( QWidget*, ... );
220  static void setTabOrder( const QWidgetList& );
221  static void alignWidget( QWidget*, const QWidget*, const int );
222 
223  static void simplifySeparators( QWidget*, const bool = true );
224 
225  static bool isParent( QObject*, QObject* );
226  static QObject* findParent( QObject*, const char* );
227 
228  static QString dir( const QString&, const bool = true );
229  static QString file( const QString&, const bool = true );
230  static QString extension( const QString&, const bool = false );
231 
232  static QString library( const QString& );
233 
234  static QString tmpDir();
235  static bool mkDir( const QString& );
236  static bool rmDir( const QString& );
237  static bool dos2unix( const QString& );
238  static QString addSlash( const QString& );
239 
240  static QCompleter* pathCompleter( const PathType, const QString& = QString() );
241  static QString findEnvVar( const QString&, int&, int& );
242  static QString makeEnvVarSubst( const QString&, const SubstMode = Auto );
243 
244  static int rgbSet( const QColor& );
245  static int rgbSet( const int, const int, const int );
246 
247  static QColor rgbSet( const int );
248  static void rgbSet( const int, int&, int&, int& );
249 
250  static QColor scaleColor( const int, const int, const int );
251  static void scaleColors( const int, QColorList& );
252 
253  static QPixmap scaleIcon( const QPixmap&, const unsigned, const unsigned = 0 );
254  static QImage grayscale( const QImage& );
255  static QPixmap grayscale( const QPixmap& );
256  static QImage transparentImage( const int, const int, const int = -1 );
257  static QPixmap transparentPixmap( const int, const int, const int = -1 );
258  static QPixmap composite( const QPixmap&, const int, const int, const QPixmap& = QPixmap() );
259 
260  static QString colorToString( const QColor& );
261  static bool stringToColor( const QString&, QColor& );
262  static QString biColorToString( const QColor&, const int );
263  static bool stringToBiColor( const QString&, QColor&, int& );
264  static QColor mainColorToSecondary( const QColor&, int );
265 
266  static QString gradientToString( const QLinearGradient& );
267  static QString gradientToString( const QRadialGradient& );
268  static QString gradientToString( const QConicalGradient& );
269  static bool stringToLinearGradient( const QString&, QLinearGradient& );
270  static bool stringToRadialGradient( const QString&, QRadialGradient& );
271  static bool stringToConicalGradient( const QString&, QConicalGradient& );
272 
273  static QString backgroundToString( const BackgroundData& );
274  static BackgroundData stringToBackground( const QString& );
275 
276  static long versionToId( const QString& );
277 
278  static QString qtDir( const QString& = QString());
279 
280  static QFont stringToFont( const QString& fontDescription );
281 
282 #ifndef WIN32
283  static void* getDisplay();
284  static Qt::HANDLE getVisual();
285 #endif
286 };
287 
288 #endif