Salome HOME
sources v1.2
[modules/kernel.git] / src / SALOMEGUI / QAD_Tools.h
1 //  SALOME SALOMEGUI : implementation of desktop and GUI kernel
2 //
3 //  Copyright (C) 2003  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. 
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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : QAD_Tools.h
25 //  Author : UI team
26 //  Module : SALOME
27 //  $Header$
28
29 #ifndef QAD_TOOLS_H
30 #define QAD_TOOLS_H
31
32 #include "QAD.h"
33 #include <qrect.h>
34 #include <qstring.h>
35 #include <qfont.h>
36 #include <qpopupmenu.h>
37 #include <TCollection_ExtendedString.hxx>
38 #include <TCollection_AsciiString.hxx>
39
40 class QAD_EXPORT QAD_Tools : public Qt
41 {
42 public:
43   /* min/max functions */
44   static int                        getMax(int v1, int v2);
45   static int                        getMin(int v1, int v2);
46
47   /* makes rectangle */
48   static QRect                      makeRect(int x1, int y1, int x2, int y2); 
49
50   /* trace function */
51   static void                       trace (const char* pLog, const char* szFormat, ... );
52   
53   /* path functions */
54   static QString                    getDirFromPath( const QString& path, bool absPath = true );
55   static QString                    getFileNameFromPath( const QString& path, bool withExtension = true );
56   static QString                    getFileExtensionFromPath( const QString& path );
57   static QString                    addSlash( const QString& path ); 
58   static QString                    unix2win( const QString& path ); 
59   
60   /* aligning widget in 'ref' widget */
61   static void                       centerWidget( QWidget* src, const QWidget* ref ); 
62   static void                       alignWidget ( QWidget* src, const QWidget* ref, int alignFlags = AlignCenter );     
63
64   /* converting strings */
65   static QString                    toQString    ( const TCollection_ExtendedString& extString);
66   static TCollection_ExtendedString toExtString  ( const QString& qString);
67   static QString                    toQString    ( const TCollection_AsciiString& asciiString);
68   static TCollection_AsciiString    toAsciiString( const QString& qString);
69
70   static QFont                      stringToFont( const QString& fontDescription );
71   static QString                    fontToString( const QFont& font );
72
73   /* popup menu optimization */
74   static void                       checkPopup( QPopupMenu* popup );
75 };
76
77 #endif
78
79
80