karbon

karbon_resourceserver.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2001, 2002, 2003 The Karbon Developers
00003 
00004    Original work :
00005    kis_resourceserver.h - part of KImageShop
00006 
00007    Copyright (c) 1999 Matthias Elter <elter@kde.org>
00008 
00009    This library is free software; you can redistribute it and/or
00010    modify it under the terms of the GNU Library General Public
00011    License as published by the Free Software Foundation; either
00012    version 2 of the License, or (at your option) any later version.
00013 
00014    This library is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017    Library General Public License for more details.
00018 
00019    You should have received a copy of the GNU Library General Public License
00020    along with this library; see the file COPYING.LIB.  If not, write to
00021    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00022  * Boston, MA 02110-1301, USA.
00023 */
00024 
00025 #ifndef __KARBONRESOURCESERVER_H__
00026 #define __KARBONRESOURCESERVER_H__
00027 
00028 
00029 #include <qptrlist.h>
00030 #include <qdict.h>
00031 #include <qstring.h>
00032 
00033 //#include "vgradient.h"
00034 #include "vpattern.h"
00035 #include <koffice_export.h>
00036 
00037 class VGradient;
00038 class VGradientListItem;
00039 class VClipartIconItem;
00040 class VObject;
00041 
00042 
00043 class KARBONCOMMON_EXPORT KarbonResourceServer
00044 {
00045 
00046 public:
00047     KarbonResourceServer();
00048     virtual ~KarbonResourceServer();
00049 
00050     int patternCount()
00051     {
00052         return m_patterns.count();
00053     }
00054 
00055     QPtrList<KoIconItem> patterns()
00056     {
00057         return m_patterns;
00058     }
00059 
00060     VPattern* addPattern( const QString& tilename );
00061     void removePattern( VPattern* pattern );
00062 
00063     int gradientCount()
00064     {
00065         return m_gradients->count();
00066     }
00067 
00068     QPtrList<VGradientListItem>* gradients()
00069     {
00070         return m_gradients;
00071     }
00072 
00073     VGradientListItem* addGradient( VGradient* gradient );
00074     void removeGradient( VGradientListItem* gradient );
00075 
00076     int clipartCount()
00077     {
00078         return m_cliparts->count();
00079     }
00080 
00081     QPtrList<VClipartIconItem>* cliparts()
00082     {
00083         return m_cliparts;
00084     }
00085 
00086     VClipartIconItem* addClipart( VObject* clipart, double width, double height );
00087     void removeClipart( VClipartIconItem* clipartIcon );
00088 
00089     QPixmap *cachePixmap( const QString &key, int group_or_size );
00090 
00091 protected:
00092     const VPattern* loadPattern( const QString& filename );
00093 
00094     void loadGradient( const QString& filename );
00095     void saveGradient( VGradient* gradient, const QString& filename );
00096 
00097     void loadClipart( const QString& filename );
00098     void saveClipart( VObject* object, double width, double height, const QString& filename );
00099 
00100 private:
00101     QPtrList<KoIconItem> m_patterns;
00102     QPtrList<VGradientListItem>* m_gradients;
00103     QPtrList<VClipartIconItem>* m_cliparts;
00104     QDict<QPixmap> m_pixmaps;
00105 };
00106 
00107 class VClipartIconItem : public KoIconItem
00108 {
00109 public:
00110     VClipartIconItem( const VObject* clipart, double width, double height, QString filename );
00111     VClipartIconItem( const VClipartIconItem& item );
00112     ~VClipartIconItem();
00113 
00114     virtual QPixmap& thumbPixmap() const
00115     {
00116         return ( QPixmap& ) m_thumbPixmap;
00117     }
00118 
00119     virtual QPixmap& pixmap() const
00120     {
00121         return ( QPixmap& ) m_pixmap;
00122     }
00123 
00124     const VObject* clipart() const
00125     {
00126         return m_clipart;
00127     }
00128 
00129     QString filename() const
00130     {
00131         return m_filename;
00132     }
00133 
00134     bool canDelete() const
00135     {
00136         return m_delete;
00137     }
00138 
00139     double originalWidth() const
00140     {
00141         return m_width;
00142     }
00143 
00144     double originalHeight() const
00145     {
00146         return m_height;
00147     }
00148 
00149     VClipartIconItem* clone();
00150 
00151 private:
00152     QPixmap m_pixmap;
00153     QPixmap m_thumbPixmap;
00154     VObject* m_clipart;
00155     QString m_filename;
00156     bool m_delete;
00157     double m_width;
00158     double m_height;
00159 }
00160 
00161 ; // VClipartIconItem
00162 
00163 #endif
00164 
KDE Home | KDE Accessibility Home | Description of Access Keys