kexi

pixmapcollection.h
1/* This file is part of the KDE project
2 Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KFORMDESIGNERPIXMAPCOLLECTION_H
21#define KFORMDESIGNERPIXMAPCOLLECTION_H
22
23#include <tqobject.h>
24#include <tqmap.h>
25#include <tqpair.h>
26#include <tqintdict.h>
27#include <tqtoolbutton.h>
28
29#include <kicontheme.h>
30#include <kdialogbase.h>
31#include <kiconview.h>
32#include <kurl.h>
33
34class TQPixmap;
35class TDEIconView;
36class TDEIconButton;
37class KLineEdit;
38class TQDomNode;
39
40typedef TQMap<TQString, TQPair<TQString, int> > PixmapMap;
41
43class KEXIEXTWIDGETS_EXPORT PixmapCollection : public TQObject
44{
45 TQ_OBJECT
46
47
48 public:
49 PixmapCollection(const TQString &collectionName, TQObject *parent = 0, const char *name = 0);
51
52 TQString addPixmapPath(const KURL &url);
53 TQString addPixmapName(const TQString &name, int size = TDEIcon::SizeMedium);
54 void removePixmap(const TQString &name);
55
56 bool contains(const TQString &name);
57 TQPixmap getPixmap(const TQString &name);
58
59 void save(TQDomNode parentNode);
60 void load(TQDomNode node);
61
62 TQString collectionName() {return m_name; }
63
64 signals:
65 void itemRenamed(const TQString &oldName, const TQString &newName);
66 void itemRemoved(const TQString &name);
67
68 protected:
69 TQString m_name;
70 PixmapMap m_pixmaps;
71
72 friend class PixmapCollectionEditor;
73 friend class PixmapCollectionChooser;
74};
75
77class KEXIEXTWIDGETS_EXPORT PixmapCollectionEditor : public KDialogBase
78{
79 TQ_OBJECT
80
81
82 public:
83 PixmapCollectionEditor(PixmapCollection *collection, TQWidget *parent = 0);
85
86 protected:
87 TQPixmap getPixmap(const TQString &name);
88 void createIconViewItem(const TQString &name);
89
90 protected slots:
91 void newItemByPath();
92 void newItemByName();
93 void removeItem();
94 void renameItem();
95 void renameCollectionItem(TQIconViewItem *item, const TQString &name);
96 void displayMenu(TQIconViewItem *item, const TQPoint &p);
97
98 private:
99 enum { BNewItemPath = 101, BNewItemName, BDelItem};
100 TDEIconView *m_iconView;
101 TQIntDict<TQToolButton> m_buttons;
102 PixmapCollection *m_collection;
103};
104
106class KEXIEXTWIDGETS_EXPORT PixmapCollectionChooser : public KDialogBase
107{
108 TQ_OBJECT
109
110
111 public:
112 PixmapCollectionChooser(PixmapCollection *collection, const TQString &selectedItem, TQWidget *parent = 0);
113 ~PixmapCollectionChooser() {;}
114
115 TQPixmap pixmap();
116 TQString pixmapName();
117
118 protected:
119 TQPixmap getPixmap(const TQString &name);
120 protected slots:
121 virtual void slotUser1();
122
123 private:
124 PixmapCollection *m_collection;
125 TDEIconView *m_iconView;
126};
127
129class KEXIEXTWIDGETS_EXPORT LoadIconDialog : public KDialogBase
130{
131 TQ_OBJECT
132
133
134 public:
135 LoadIconDialog(TQWidget *parent = 0);
136 ~LoadIconDialog() {;}
137
138 int iconSize();
139 TQString iconName();
140
141 protected slots:
142 void changeIconSize(int);
143 void updateIconName(TQString);
144 void setIcon(const TQString &);
145
146 private:
147 KLineEdit *m_nameInput;
148 TDEIconButton *m_button;
149};
150
152class KEXIEXTWIDGETS_EXPORT PixmapIconViewItem : public TDEIconViewItem
153{
154 public:
155 PixmapIconViewItem(TDEIconView *parent, const TQString &text, const TQPixmap &icon)
156 : TDEIconViewItem(parent, text, icon) { m_name = text; }
157 ~PixmapIconViewItem() {;}
158
159 void setName(const TQString &name) { m_name = name; }
160 TQString name() { return m_name;}
161
162 private:
163 TQString m_name;
164};
165
166#endif
PixmapCollectionEditor(PixmapCollection *collection, TQWidget *parent=0)
Pixmap Collection Editor Dialog.
A class that store pixmaps (by path or by name for KDE icons).
PixmapCollection(const TQString &collectionName, TQObject *parent=0, const char *name=0)
Pixmap Collection.