karbon

vcolor.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2001, The Karbon Developers
00003    Copyright (C) 2002, The Karbon Developers
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef __VCOLOR_H__
00022 #define __VCOLOR_H__
00023 
00024 
00025 #include <qcolor.h>
00026 #include <qstring.h>
00027 #include <koffice_export.h>
00028 class QDomElement;
00029 
00030 
00040 class KARBONBASE_EXPORT VColor
00041 {
00042 public:
00043     enum VColorSpace
00044     {
00045         rgb  = 0,   
00046         cmyk = 1,   
00047         hsb  = 2,   
00048         gray = 3    
00049     };
00050 
00056     VColor( VColorSpace colorSpace = rgb );
00057 
00063     VColor( const VColor& color );
00064 
00070     VColor( const QColor& color );
00071 
00075     operator QColor() const;
00076 
00083     float operator[]( unsigned i ) const
00084         { return m_value[i]; }
00085 
00091     void set( float v1 )
00092         { m_value[0] = v1; }
00093 
00100     void set( float v1, float v2 )
00101         { m_value[0] = v1; m_value[1] = v2; }
00102 
00110     void set( float v1, float v2, float v3 )
00111         { m_value[0] = v1; m_value[1] = v2; m_value[2] = v3; }
00112 
00121     void set( float v1, float v2, float v3, float v4 )
00122         { m_value[0] = v1; m_value[1] = v2; m_value[2] = v3; m_value[3] = v4; }
00123 
00131     float opacity() const { return m_opacity; }
00132 
00138     void setOpacity( float opacity ) { m_opacity = opacity; }
00139 
00145     VColorSpace colorSpace() const { return m_colorSpace; }
00146 
00155     void setColorSpace( const VColorSpace colorSpace, bool convert = true );
00156 
00162     void save( QDomElement& element ) const;
00163 
00169     void load( const QDomElement& element );
00170 
00171 private:
00172     void convertToColorSpace( const VColorSpace colorSpace );
00173 
00174     VColorSpace m_colorSpace;
00175 
00176     float m_value[4];
00177     float m_opacity;
00178 
00179     QString m_name;
00180 };
00181 
00182 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys