Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/gui.git] / src / Qtx / Qtx.h
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // File:      Qtx.h
20 // Author:    Sergey TELKOV
21
22 #ifndef QTX_H
23 #define QTX_H
24
25 #if defined QTX_EXPORTS
26 #if defined WIN32
27 #define QTX_EXPORT _declspec( dllexport )
28 #else
29 #define QTX_EXPORT  
30 #endif
31 #else
32 #if defined WIN32
33 #define QTX_EXPORT _declspec( dllimport )
34 #else
35 #define QTX_EXPORT  
36 #endif
37 #endif
38
39 #if defined SOLARIS
40 #define bool  int
41 #define false 0
42 #define true  1
43 #endif
44
45 #ifndef INCLUDE_MENUITEM_DEF
46 #define INCLUDE_MENUITEM_DEF
47 #endif
48
49 #include <qnamespace.h>
50
51 #ifndef QT_VERSION
52 #define QT_VER 0
53 #else
54 #if QT_VERSION >= 0x30000
55 #define QT_VER 3
56 #else
57 #if QT_VERSION >= 300
58 #define QT_VER 3
59 #else
60 #if QT_VERSION >= 200
61 #define QT_VER 2
62 #else
63 #if QT_VERSION >= 100
64 #define QT_VER 1
65 #endif
66 #endif
67 #endif
68 #endif
69 #endif
70
71 #include <qimage.h>
72 #include <qpixmap.h>
73
74 class QObject;
75 class QString;
76 class QWidget;
77 class QToolBar;
78 class QGroupBox;
79 class QPopupMenu;
80 class QWidgetList;
81
82 template <class> class QValueList;
83
84 #if QT_VER < 3
85 #define QPtrList QList
86 #define QPtrListIterator QListIterator
87 #endif
88
89 typedef QValueList<int>    QIntList;
90 typedef QValueList<short>  QShortList;
91 typedef QValueList<double> QDoubleList;
92
93 /*!
94   \class Qtx
95   \brief Set of auxiliary static methods
96 */
97 class QTX_EXPORT Qtx : public Qt
98 {
99 public:
100   enum AlignmentFlags
101   {
102     AlignOutLeft   = AlignVCenter  << 2,
103     AlignOutRight  = AlignOutLeft  << 2,
104     AlignOutTop    = AlignOutRight << 2,
105     AlignOutBottom = AlignOutTop   << 2
106   };
107
108   static void    setTabOrder( QWidget*, ... );
109   static void    setTabOrder( const QWidgetList& );
110   static void    alignWidget( QWidget*, const QWidget*, const int );
111
112   static void    simplifySeparators( QToolBar* );
113   static void    simplifySeparators( QPopupMenu*, const bool = true );
114
115   static bool    isParent( QObject*, QObject* );
116
117   static QString extension( const QString& );
118   static QString dir( const QString&, const bool = true );
119   static QString file( const QString&, const bool = true );
120
121   static QString library( const QString& );
122
123   static QString tmpDir();
124   static bool    mkDir( const QString& );
125   static bool    rmDir( const QString& );
126   static bool    dos2unix( const QString& );
127   static QString addSlash( const QString& );
128
129   static int     rgbSet( const QColor& );
130   static int     rgbSet( const int, const int, const int );
131
132   static void    rgbSet( const int, QColor& );
133   static void    rgbSet( const int, int&, int&, int& );
134
135   static QColor  scaleColor( const int, const int, const int );
136   static void    scaleColors( const int, QValueList<QColor>& );
137
138   static QImage  grayscale( const QImage& );
139   static QPixmap grayscale( const QPixmap& );
140   static QImage  transparentImage( const int, const int, const int = -1 );
141   static QPixmap transparentPixmap( const int, const int, const int = -1 );
142   static QPixmap composite( const QPixmap&, const int, const int, const QPixmap& = QPixmap() );
143 };
144
145 #endif