/* This file is part of the KDE project Copyright (C) 2004 Cedric Pasteur This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KFORMDESIGNERPIXMAPCOLLECTION_H #define KFORMDESIGNERPIXMAPCOLLECTION_H #include #include #include #include #include #include #include #include #include class TQPixmap; class KIconView; class KIconButton; class KLineEdit; class TQDomNode; typedef TQMap > PixmapMap; //! A class that store pixmaps (by path or by name for KDE icons) class KEXIEXTWIDGETS_EXPORT PixmapCollection : public TQObject { Q_OBJECT TQ_OBJECT public: PixmapCollection(const TQString &collectionName, TQObject *tqparent = 0, const char *name = 0); ~PixmapCollection() {;} TQString addPixmapPath(const KURL &url); TQString addPixmapName(const TQString &name, int size = KIcon::SizeMedium); void removePixmap(const TQString &name); bool tqcontains(const TQString &name); TQPixmap getPixmap(const TQString &name); void save(TQDomNode parentNode); void load(TQDomNode node); TQString collectionName() {return m_name; } signals: void itemRenamed(const TQString &oldName, const TQString &newName); void itemRemoved(const TQString &name); protected: TQString m_name; PixmapMap m_pixmaps; friend class PixmapCollectionEditor; friend class PixmapCollectionChooser; }; //! A dialog to edit the contents of a PixmapCollection class KEXIEXTWIDGETS_EXPORT PixmapCollectionEditor : public KDialogBase { Q_OBJECT TQ_OBJECT public: PixmapCollectionEditor(PixmapCollection *collection, TQWidget *tqparent = 0); ~PixmapCollectionEditor() {;} protected: TQPixmap getPixmap(const TQString &name); void createIconViewItem(const TQString &name); protected slots: void newItemByPath(); void newItemByName(); void removeItem(); void renameItem(); void renameCollectionItem(TQIconViewItem *item, const TQString &name); void displayMenu(TQIconViewItem *item, const TQPoint &p); private: enum { BNewItemPath = 101, BNewItemName, BDelItem}; KIconView *m_iconView; TQIntDict m_buttons; PixmapCollection *m_collection; }; //! A dialog to choose an icon in a PixmapCollection class KEXIEXTWIDGETS_EXPORT PixmapCollectionChooser : public KDialogBase { Q_OBJECT TQ_OBJECT public: PixmapCollectionChooser(PixmapCollection *collection, const TQString &selectedItem, TQWidget *tqparent = 0); ~PixmapCollectionChooser() {;} TQPixmap pixmap(); TQString pixmapName(); protected: TQPixmap getPixmap(const TQString &name); protected slots: virtual void slotUser1(); private: PixmapCollection *m_collection; KIconView *m_iconView; }; //! A simple dialog to choose a KDE icon class KEXIEXTWIDGETS_EXPORT LoadIconDialog : public KDialogBase { Q_OBJECT TQ_OBJECT public: LoadIconDialog(TQWidget *tqparent = 0); ~LoadIconDialog() {;} int iconSize(); TQString iconName(); protected slots: void changeIconSize(int); void updateIconName(TQString); void setIcon(const TQString &); private: KLineEdit *m_nameInput; KIconButton *m_button; }; //! A Special KIconViewItem that holds the name of its associated pixmap (to allow renaming) class KEXIEXTWIDGETS_EXPORT PixmapIconViewItem : public KIconViewItem { public: PixmapIconViewItem(KIconView *tqparent, const TQString &text, const TQPixmap &icon) : KIconViewItem(tqparent, text, icon) { m_name = text; } ~PixmapIconViewItem() {;} void setName(const TQString &name) { m_name = name; } TQString name() { return m_name;} private: TQString m_name; }; #endif