Version: 9.16.0
Qtx.h
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, 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
53class QObject;
54class QWidget;
55class QCompleter;
56
61
63{
64public:
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 {
121
123 typedef enum {
124 ShowNone = 0x000,
125 ShowText = 0x001,
126 ShowIcon = 0x010,
127 ShowAll = ShowText | ShowIcon
128 } HeaderViewFlags;
129
131 typedef enum {
132 IdType
133 } CustomDataType;
134
136 typedef enum {
137 NoBackground, // no (invalid) background data
138 ColorBackground, // single color
139 SimpleGradientBackground, // simple two-color gradient
140 CustomGradientBackground // custom (complex) gradient
141 } BackgroundMode;
142
144 typedef enum {
145 CenterTexture, // center texture
146 TileTexture, // tile texture
147 StretchTexture, // stretch texture
148 } TextureMode;
149
151 {
152 public:
153 Localizer();
154 Localizer( int, const char* );
155 ~Localizer();
156 private:
157 void init( int, const char* );
158 private:
161 };
162
164 {
165 public:
166 CmdLineArgs();
167 ~CmdLineArgs();
168
169 int argc() const;
170 char** argv() const;
171
172 private:
174 char** myArgv;
175 };
176
178 {
179 public:
181 BackgroundData( const QColor& );
182 BackgroundData( int, const QColor&, const QColor& );
183 BackgroundData( const QGradient& );
184 virtual ~BackgroundData();
185
186 bool operator==( const BackgroundData&) const;
187 inline bool operator!=( const BackgroundData& other ) const
188 { return !operator==( other ); }
189
190 bool isValid() const;
191
192 BackgroundMode mode() const;
193 void setMode( const BackgroundMode );
194
195 TextureMode texture( QString& ) const;
196 void setTexture( const QString&, TextureMode = Qtx::CenterTexture );
197 bool isTextureShown() const;
198 void setTextureShown( bool );
199
200 QColor color() const;
201 void setColor( const QColor& );
202
203 int gradient( QColor&, QColor& ) const;
204 void setGradient( int, const QColor&, const QColor& );
205
206 const QGradient* gradient() const;
207 void setGradient( const QGradient& );
208
209 private:
212 QString myFileName;
215 QGradient myGradient;
217 };
218
219 static QString toQString( const char*, const int = -1 );
220 static QString toQString( const short*, const int = -1 );
221 static QString toQString( const unsigned char*, const int = -1 );
222 static QString toQString( const unsigned short*, const int = -1 );
223
224 static void setTabOrder( QWidget*, ... );
225 static void setTabOrder( const QWidgetList& );
226 static void alignWidget( QWidget*, const QWidget*, const int );
227
228 static void simplifySeparators( QWidget*, const bool = true );
229
230 static bool isParent( QObject*, QObject* );
231 static QObject* findParent( QObject*, const char* );
232
233 static QString dir( const QString&, const bool = true );
234 static QString file( const QString&, const bool = true );
235 static QString extension( const QString&, const bool = false );
236
237 static QString libraryName( const QString& );
238 static QString library( const QString& );
239
240 static QString tmpDir();
241 static bool mkDir( const QString& );
242 static bool rmDir( const QString& );
243 static bool dos2unix( const QString& );
244 static QString addSlash( const QString& );
245 static QString joinPath( const QStringList& );
246
247 static QCompleter* pathCompleter( const PathType, const QString& = QString() );
248 static QString findEnvVar( const QString&, int&, int& );
249 static QString makeEnvVarSubst( const QString&, const SubstMode = Auto );
250
251 static int rgbSet( const QColor& );
252 static int rgbSet( const int, const int, const int );
253
254 static QColor rgbSet( const int );
255 static void rgbSet( const int, int&, int&, int& );
256
257 static QColor scaleColor( const int, const int, const int );
258 static void scaleColors( const int, QColorList& );
259
260 static QPixmap scaleIcon( const QPixmap&, const unsigned, const unsigned = 0 );
261 static QImage grayscale( const QImage& );
262 static QPixmap grayscale( const QPixmap& );
263 static QImage transparentImage( const int, const int, const int = -1 );
264 static QPixmap transparentPixmap( const int, const int, const int = -1 );
265 static QPixmap composite( const QPixmap&, const int, const int, const QPixmap& = QPixmap() );
266
267 static QString colorToString( const QColor& );
268 static bool stringToColor( const QString&, QColor& );
269 static QString biColorToString( const QColor&, const int );
270 static bool stringToBiColor( const QString&, QColor&, int& );
271 static QColor mainColorToSecondary( const QColor&, int );
272
273 static QString gradientToString( const QLinearGradient& );
274 static QString gradientToString( const QRadialGradient& );
275 static QString gradientToString( const QConicalGradient& );
276 static bool stringToLinearGradient( const QString&, QLinearGradient& );
277 static bool stringToRadialGradient( const QString&, QRadialGradient& );
278 static bool stringToConicalGradient( const QString&, QConicalGradient& );
279
280 static QString backgroundToString( const BackgroundData& );
281 static BackgroundData stringToBackground( const QString& );
282
283 static long versionToId( const QString& );
284
285 static QString qtDir( const QString& = QString());
286
287 static QFont stringToFont( const QString& fontDescription );
288
289 static QString getenv( const QString& envVar );
290
291#ifndef WIN32
292 static void* getDisplay();
293 static Qt::HANDLE getVisual();
294#endif
295 static void initDefaultSurfaceFormat();
296};
297
298#endif
QList< QColor > QColorList
list of colors
Definition: Qtx.h:60
QList< int > QIntList
list of int values
Definition: Qtx.h:57
QList< double > QDoubleList
list of double values
Definition: Qtx.h:59
#define QTX_EXPORT
Definition: Qtx.h:36
QList< short > QShortList
list of short int values
Definition: Qtx.h:58
bool operator==(const SUIT_DataOwnerPtr &p1, const SUIT_DataOwnerPtr &p2)
Definition: SUIT_DataOwner.cxx:39
bool isValid(const QPolygon *thePoints, const QPoint &theCurrent)
Definition: SVTK_InteractorStyle.cxx:1762
VisibilityState
Definition: SalomePyQt.h:174
For more information see QT documentation.
Stores background data.
Definition: Qtx.h:178
QGradient myGradient
Definition: Qtx.h:215
BackgroundMode myMode
Definition: Qtx.h:210
int myGradientType
Definition: Qtx.h:214
QColorList myColors
Definition: Qtx.h:213
bool myTextureShown
Definition: Qtx.h:216
QString myFileName
Definition: Qtx.h:212
TextureMode myTextureMode
Definition: Qtx.h:211
bool operator!=(const BackgroundData &other) const
Definition: Qtx.h:187
Get access to the command line arguments in the C-like manner.
Definition: Qtx.h:164
int myArgc
Definition: Qtx.h:173
char ** myArgv
Definition: Qtx.h:174
Localization helper.
Definition: Qtx.h:151
QString myOriginalLocale
Definition: Qtx.h:160
int myCategory
Definition: Qtx.h:159
A set of helpful utility functions.
Definition: Qtx.h:63
TextureMode
Texture mode.
Definition: Qtx.h:144
@ CenterTexture
Definition: Qtx.h:145
@ TileTexture
Definition: Qtx.h:146
@ StretchTexture
Definition: Qtx.h:147
PathType
Path type, indicates required directory/file operation.
Definition: Qtx.h:91
@ PT_OpenFile
the file is opened
Definition: Qtx.h:92
@ PT_SaveFile
the file is saved
Definition: Qtx.h:93
SubstMode
Environment variables substitution mode.
Definition: Qtx.h:109
@ Never
keep environment variable as is without any substitution
Definition: Qtx.h:111
@ Always
substitute environment variable by it's value if variable exists, and "" otherwise
Definition: Qtx.h:110
@ Shown
column should be always visible
Definition: Qtx.h:103
@ Hidden
column should be always hidden
Definition: Qtx.h:104
@ UnpresentableState
Unpresentable object.
Definition: Qtx.h:119
@ HiddenState
Object is hidden in viewer.
Definition: Qtx.h:118
@ ShownState
Object is shown in viewer.
Definition: Qtx.h:117
BackgroundMode
Background mode.
Definition: Qtx.h:136
@ ColorBackground
Definition: Qtx.h:138
@ NoBackground
Definition: Qtx.h:137
@ SimpleGradientBackground
Definition: Qtx.h:139
Quantity_Color color(const QColor &)
Convert QColor object to Quantity_Color object.
Definition: OCCViewer.cxx:28