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 )
41 class QTX_EXPORT QtxColorScale : public QFrame
46 typedef enum { Auto, User } Mode;
47 typedef enum { None, Left, Right, Center } Position;
48 typedef enum { NoDump, TitleDump, ScaleDump, FullDump } DumpMode;
49 typedef enum { AtBorder = 0x001, Reverse = 0x002, Integer = 0x004,
50 WrapTitle = 0x008, PreciseFormat = 0x010, Transparent = 0x020 } Flags;
53 class Dock : public QDockWindow
56 Dock( Place = InDock, QWidget* = 0, const char* = 0, WFlags = 0 );
59 QtxColorScale* colorScale() const;
64 bool isActive() const;
69 virtual void resize( int, int );
70 virtual void setOrientation( Orientation );
73 QtxColorScale* myScale;
79 QtxColorScale( Dock*, const char* = 0, WFlags = 0 );
83 QtxColorScale( QWidget* = 0, const char* = 0, WFlags = 0 );
84 QtxColorScale( const int, QWidget* = 0, const char* = 0, WFlags = 0 );
85 virtual ~QtxColorScale();
87 double minimum() const;
88 double maximum() const;
89 void range( double&, double& ) const;
91 int labelMode() const;
92 int colorMode() const;
93 int intervalsNumber() const;
95 QString title() const;
96 QString format() const;
97 QString label( const int ) const;
98 QColor color( const int ) const;
99 void labels( QStringList& ) const;
100 void colors( QValueList<QColor>& ) const;
102 int labelPosition() const;
103 int titlePosition() const;
105 void setMinimum( const double );
106 void setMaximum( const double );
107 void setRange( const double, const double );
108 void setDumpMode( const int );
109 void setColorMode( const int );
110 void setLabelMode( const int );
111 void setIntervalsNumber( const int );
113 void setTitle( const QString& );
114 void setFormat( const QString& );
115 void setLabel( const QString&, const int = -1 );
116 void setColor( const QColor&, const int = -1 );
117 void setLabels( const QStringList& );
118 void setColors( const QValueList<QColor>& );
120 void setLabelPosition( const int );
121 void setTitlePosition( const int );
123 void setFlags( const int );
124 bool testFlags( const int ) const;
125 void clearFlags( const int );
127 QPixmap dump() const;
128 QPixmap dump( const int = -1, const int = -1 ) const;
129 QPixmap dump( const QColor&, const int = -1, const int = -1 ) const;
131 virtual QSize minimumSizeHint() const;
132 virtual QSize sizeHint() const;
138 virtual void drawContents( QPainter* );
142 QString getFormat() const;
143 QString getLabel( const int ) const;
144 QColor getColor( const int ) const;
145 double getNumber( const int ) const;
146 QSimpleRichText* simpleRichText( const int ) const;
147 void drawScale( QPainter*, const bool, const int, const int,
148 const int, const int, const bool, const bool, const bool ) const;
149 void drawScale( QPainter*, const QColor&, const bool,
150 const int, const int, const int, const int,
151 const bool, const bool, const bool ) const;
152 QSize calculateSize( const bool, const int,
153 const bool, const bool, const bool ) const;
156 friend class QtxColorScale::Dock;
170 QValueList<QColor> myColors;
171 QValueList<QString> myLabels;
177 QStyleSheet* myStyleSheet;
181 #pragma warning( default:4251 )