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 : public QObject
00044 {
00045     Q_OBJECT
00046 
00047 public:
00048     KarbonResourceServer();
00049     virtual ~KarbonResourceServer();
00050 
00051     int patternCount()
00052     {
00053         return m_patterns.count();
00054     }
00055 
00056     QPtrList<KoIconItem> patterns()
00057     {
00058         return m_patterns;
00059     }
00060 
00061     VPattern* addPattern( const QString& tilename );
00062     void removePattern( VPattern* pattern );
00063 
00064     int gradientCount()
00065     {
00066         return m_gradients->count();
00067     }
00068 
00069     QPtrList<VGradientListItem>* gradients()
00070     {
00071         return m_gradients;
00072     }
00073 
00074     VGradientListItem* addGradient( VGradient* gradient );
00075     void removeGradient( VGradientListItem* gradient );
00076 
00077     int clipartCount()
00078     {
00079         return m_cliparts->count();
00080     }
00081 
00082     QPtrList<VClipartIconItem>* cliparts()
00083     {
00084         return m_cliparts;
00085     }
00086 
00087     VClipartIconItem* addClipart( VObject* clipart, double width, double height );
00088     void removeClipart( VClipartIconItem* clipartIcon );
00089 
00090     QPixmap *cachePixmap( const QString &key, int group_or_size );
00091 
00092 signals:
00093     void patternAdded( KoIconItem *pattern );
00094     void patternRemoved( KoIconItem *pattern );
00095 
00096 protected:
00097     const VPattern* loadPattern( const QString& filename );
00098 
00099     void loadGradient( const QString& filename );
00100     void saveGradient( VGradient* gradient, const QString& filename );
00101 
00102     void loadClipart( const QString& filename );
00103     void saveClipart( VObject* object, double width, double height, const QString& filename );
00104 
00105 private:
00106     QPtrList<KoIconItem> m_patterns;
00107     QPtrList<VGradientListItem>* m_gradients;
00108     QPtrList<VClipartIconItem>* m_cliparts;
00109     QDict<QPixmap> m_pixmaps;
00110 };
00111 
00112 class VClipartIconItem : public KoIconItem
00113 {
00114 public:
00115     VClipartIconItem( const VObject* clipart, double width, double height, QString filename );
00116     VClipartIconItem( const VClipartIconItem& item );
00117     ~VClipartIconItem();
00118 
00119     virtual QPixmap& thumbPixmap() const
00120     {
00121         return ( QPixmap& ) m_thumbPixmap;
00122     }
00123 
00124     virtual QPixmap& pixmap() const
00125     {
00126         return ( QPixmap& ) m_pixmap;
00127     }
00128 
00129     const VObject* clipart() const
00130     {
00131         return m_clipart;
00132     }
00133 
00134     QString filename() const
00135     {
00136         return m_filename;
00137     }
00138 
00139     bool canDelete() const
00140     {
00141         return m_delete;
00142     }
00143 
00144     double originalWidth() const
00145     {
00146         return m_width;
00147     }
00148 
00149     double originalHeight() const
00150     {
00151         return m_height;
00152     }
00153 
00154     VClipartIconItem* clone();
00155 
00156 private:
00157     QPixmap m_pixmap;
00158     QPixmap m_thumbPixmap;
00159     VObject* m_clipart;
00160     QString m_filename;
00161     bool m_delete;
00162     double m_width;
00163     double m_height;
00164 }
00165 
00166 ; // VClipartIconItem
00167 
00168 #endif
00169 
KDE Home | KDE Accessibility Home | Description of Access Keys