1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
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.
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.
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
17 // See http://www.salome-platform.org/
19 // File: QtxColorScale.h
20 // Author: Sergey TELKOV
22 #ifndef QTXCOLORSCALE_H
23 #define QTXCOLORSCALE_H
28 #include <qvaluelist.h>
31 #include <qdockwindow.h>
35 class QSimpleRichText;
38 #pragma warning( disable:4251 )
45 class QTX_EXPORT QtxColorScale : public QFrame
50 typedef enum { Auto, User } Mode;
51 typedef enum { None, Left, Right, Center } Position;
52 typedef enum { NoDump, TitleDump, ScaleDump, FullDump } DumpMode;
53 typedef enum { AtBorder = 0x001, Reverse = 0x002, Integer = 0x004,
54 WrapTitle = 0x008, PreciseFormat = 0x010, Transparent = 0x020 } Flags;
57 class Dock : public QDockWindow
60 Dock( Place = InDock, QWidget* = 0, const char* = 0, WFlags = 0 );
63 QtxColorScale* colorScale() const;
68 bool isActive() const;
73 virtual void resize( int, int );
74 virtual void setOrientation( Orientation );
77 QtxColorScale* myScale;
83 QtxColorScale( Dock*, const char* = 0, WFlags = 0 );
87 QtxColorScale( QWidget* = 0, const char* = 0, WFlags = 0 );
88 QtxColorScale( const int, QWidget* = 0, const char* = 0, WFlags = 0 );
89 virtual ~QtxColorScale();
91 double minimum() const;
92 double maximum() const;
93 void range( double&, double& ) const;
95 int labelMode() const;
96 int colorMode() const;
97 int intervalsNumber() const;
99 QString title() const;
100 QString format() const;
101 QString label( const int ) const;
102 QColor color( const int ) const;
103 void labels( QStringList& ) const;
104 void colors( QValueList<QColor>& ) const;
106 int labelPosition() const;
107 int titlePosition() const;
109 void setMinimum( const double );
110 void setMaximum( const double );
111 void setRange( const double, const double );
112 void setDumpMode( const int );
113 void setColorMode( const int );
114 void setLabelMode( const int );
115 void setIntervalsNumber( const int );
117 void setTitle( const QString& );
118 void setFormat( const QString& );
119 void setLabel( const QString&, const int = -1 );
120 void setColor( const QColor&, const int = -1 );
121 void setLabels( const QStringList& );
122 void setColors( const QValueList<QColor>& );
124 void setLabelPosition( const int );
125 void setTitlePosition( const int );
127 void setFlags( const int );
128 bool testFlags( const int ) const;
129 void clearFlags( const int );
131 QPixmap dump() const;
132 QPixmap dump( const int = -1, const int = -1 ) const;
133 QPixmap dump( const QColor&, const int = -1, const int = -1 ) const;
135 virtual QSize minimumSizeHint() const;
136 virtual QSize sizeHint() const;
142 virtual void drawContents( QPainter* );
146 QString getFormat() const;
147 QString getLabel( const int ) const;
148 QColor getColor( const int ) const;
149 double getNumber( const int ) const;
150 QSimpleRichText* simpleRichText( const int ) const;
151 void drawScale( QPainter*, const bool, const int, const int,
152 const int, const int, const bool, const bool, const bool ) const;
153 void drawScale( QPainter*, const QColor&, const bool,
154 const int, const int, const int, const int,
155 const bool, const bool, const bool ) const;
156 QSize calculateSize( const bool, const int,
157 const bool, const bool, const bool ) const;
160 friend class QtxColorScale::Dock;
174 QValueList<QColor> myColors;
175 QValueList<QString> myLabels;
181 QStyleSheet* myStyleSheet;
185 #pragma warning( default:4251 )