lib

kogradientmanager.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2005 Tim Beaulen <tbscope@gmail.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef __GRADIENT_LOADER__
00021 #define __GRADIENT_LOADER__
00022 
00023 #include <qptrlist.h>
00024 #include <qstring.h>
00025 #include <qstringlist.h>
00026 #include <qfile.h>
00027 #include <qdom.h>
00028 #include <qcolor.h>
00029 #include <koffice_export.h>
00030 struct KoColorStop
00031 {
00032     double offset;
00033     double midpoint;
00034     double opacity;
00035     double color1;
00036     double color2;
00037     double color3;
00038     double color4;
00039     int colorType;
00040     int interpolation;
00041 };
00042 
00043 struct KoGradient
00044 {
00045     double originX;
00046     double originY;
00047     double vectorX;
00048     double vectorY;
00049     double focalpointX;
00050     double focalpointY;
00051     int gradientType;
00052     int gradientRepeatMethod;
00053 
00054     QPtrList<KoColorStop> colorStops;
00055 };  
00056 
00057 class KOPAINTER_EXPORT KoGradientManager
00058 {
00059 public:
00060 
00061     enum KoGradientType
00062     {
00063         gradient_type_linear = 0,
00064         gradient_type_radial = 1,
00065         gradient_type_conic = 2
00066     };
00067     
00068     enum KoGradientInterpolation
00069     {
00070         interpolation_linear = 0,
00071         interpolation_curved = 1,
00072         interpolation_sine = 2,
00073         interpolation_sphere_increasing = 3,
00074         interpolation_sphere_decreasing = 4
00075     };
00076     
00077     enum KoGradientColorType
00078     {
00079         color_type_rgb = 0,
00080         color_type_hsv_ccw = 1,
00081         color_type_hsv_cw = 2,
00082         color_type_gray = 3,
00083         color_type_cmyk = 4
00084     };
00085     
00086     enum KoGradientRepeatMethod
00087     {
00088         repeat_method_none = 0,
00089         repeat_method_reflect = 1,
00090         repeat_method_repeat = 2
00091     };
00092 
00093     KoGradientManager();
00094     ~KoGradientManager();
00095 
00096     KoGradient* loadGradient(const QString& filename);
00097     static QStringList filters() 
00098     {
00099         QStringList filterList;
00100         filterList << "*.kgr" << "*.svg" << "*.ggr"; 
00101         return filterList; 
00102     }
00103 
00104 private:
00105     KoGradient* loadKarbonGradient(QFile* file);
00106     KoGradient* loadKritaGradient(QFile* file);
00107     KoGradient* loadSvgGradient(QFile* file);
00108     KoGradient* parseKarbonGradient(const QDomElement& element);
00109     KoGradient* parseSvgGradient(const QDomElement& element);
00110     void parseSvgColor(QColor &color, const QString &s);
00111 };
00112 
00113 #endif
00114 
00115 
KDE Home | KDE Accessibility Home | Description of Access Keys