karbon

karbon_resourceserver.h
1/* This file is part of the KDE project
2 Copyright (C) 2001, 2002, 2003 The Karbon Developers
3
4 Original work :
5 kis_resourceserver.h - part of KImageShop
6
7 Copyright (c) 1999 Matthias Elter <elter@kde.org>
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public
11 License as published by the Free Software Foundation; either
12 version 2 of the License, or (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details.
18
19 You should have received a copy of the GNU Library General Public License
20 along with this library; see the file COPYING.LIB. If not, write to
21 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
23*/
24
25#ifndef __KARBONRESOURCESERVER_H__
26#define __KARBONRESOURCESERVER_H__
27
28
29#include <tqptrlist.h>
30#include <tqdict.h>
31#include <tqstring.h>
32
33//#include "vgradient.h"
34#include "vpattern.h"
35#include <koffice_export.h>
36
37class VGradient;
38class VGradientListItem;
39class VClipartIconItem;
40class VObject;
41
42
43class KARBONCOMMON_EXPORT KarbonResourceServer : public TQObject
44{
45 TQ_OBJECT
46
47
48public:
49 KarbonResourceServer();
50 virtual ~KarbonResourceServer();
51
52 int patternCount()
53 {
54 return m_patterns.count();
55 }
56
57 TQPtrList<KoIconItem> patterns()
58 {
59 return m_patterns;
60 }
61
62 VPattern* addPattern( const TQString& tilename );
63 void removePattern( VPattern* pattern );
64
65 int gradientCount()
66 {
67 return m_gradients->count();
68 }
69
70 TQPtrList<VGradientListItem>* gradients()
71 {
72 return m_gradients;
73 }
74
75 VGradientListItem* addGradient( VGradient* gradient );
76 void removeGradient( VGradientListItem* gradient );
77
78 int clipartCount()
79 {
80 return m_cliparts->count();
81 }
82
83 TQPtrList<VClipartIconItem>* cliparts()
84 {
85 return m_cliparts;
86 }
87
88 VClipartIconItem* addClipart( VObject* clipart, double width, double height );
89 void removeClipart( VClipartIconItem* clipartIcon );
90
91 TQPixmap *cachePixmap( const TQString &key, int group_or_size );
92
93signals:
94 void patternAdded( KoIconItem *pattern );
95 void patternRemoved( KoIconItem *pattern );
96
97protected:
98 const VPattern* loadPattern( const TQString& filename );
99
100 void loadGradient( const TQString& filename );
101 void saveGradient( VGradient* gradient, const TQString& filename );
102
103 void loadClipart( const TQString& filename );
104 void saveClipart( VObject* object, double width, double height, const TQString& filename );
105
106private:
107 TQPtrList<KoIconItem> m_patterns;
108 TQPtrList<VGradientListItem>* m_gradients;
109 TQPtrList<VClipartIconItem>* m_cliparts;
110 TQDict<TQPixmap> m_pixmaps;
111};
112
113class VClipartIconItem : public KoIconItem
114{
115public:
116 VClipartIconItem( const VObject* clipart, double width, double height, TQString filename );
117 VClipartIconItem( const VClipartIconItem& item );
118 ~VClipartIconItem();
119
120 virtual TQPixmap& thumbPixmap() const
121 {
122 return ( TQPixmap& ) m_thumbPixmap;
123 }
124
125 virtual TQPixmap& pixmap() const
126 {
127 return ( TQPixmap& ) m_pixmap;
128 }
129
130 const VObject* clipart() const
131 {
132 return m_clipart;
133 }
134
135 TQString filename() const
136 {
137 return m_filename;
138 }
139
140 bool canDelete() const
141 {
142 return m_delete;
143 }
144
145 double originalWidth() const
146 {
147 return m_width;
148 }
149
150 double originalHeight() const
151 {
152 return m_height;
153 }
154
155 VClipartIconItem* clone();
156
157private:
158 TQPixmap m_pixmap;
159 TQPixmap m_thumbPixmap;
160 VObject* m_clipart;
161 TQString m_filename;
162 bool m_delete;
163 double m_width;
164 double m_height;
165}
166
167; // VClipartIconItem
168
169#endif
170
The base class for all karbon objects.
Definition vobject.h:50