• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kdeprint
 

kdeprint

kiconselectaction.cpp
00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Library General Public
00007  *  License version 2 as published by the Free Software Foundation.
00008  *
00009  *  This library is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *  Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Library General Public License
00015  *  along with this library; see the file COPYING.LIB.  If not, write to
00016  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  *  Boston, MA 02110-1301, USA.
00018  **/
00019 
00020 #include "kiconselectaction.h"
00021 
00022 #include <tqpopupmenu.h>
00023 #include <kiconloader.h>
00024 #include <kdebug.h>
00025 #include <ktoolbar.h>
00026 #include <ktoolbarbutton.h>
00027 
00028 class KIconSelectActionPrivate
00029 {
00030 public:
00031     KIconSelectActionPrivate()
00032     {
00033         m_menu = 0;
00034     }
00035     TQStringList    m_iconlst;
00036     TQPopupMenu*    m_menu;
00037 };
00038 
00039 KIconSelectAction::KIconSelectAction(const TQString& text, int accel, TQObject* parent, const char* name)
00040 : KSelectAction(text, accel, parent, name)
00041 {
00042     d = new KIconSelectActionPrivate;
00043 }
00044 
00045 KIconSelectAction::~KIconSelectAction()
00046 {
00047     delete d;
00048 }
00049 
00050 void KIconSelectAction::updateIcons()
00051 {
00052     if (d->m_menu)
00053     {
00054         TQStringList    lst = items();
00055         for (uint id=0; id<lst.count(); ++id)
00056             d->m_menu->changeItem(id, SmallIconSet(d->m_iconlst[id]), lst[id]);
00057     }
00058 }
00059 
00060 void KIconSelectAction::createPopupMenu()
00061 {
00062     if (!d->m_menu)
00063     {
00064         d->m_menu = popupMenu();
00065         updateIcons();
00066     }
00067 }
00068 
00069 void KIconSelectAction::setItems(const TQStringList& lst, const TQStringList& iconlst)
00070 {
00071     KSelectAction::setItems(lst);
00072     d->m_iconlst = iconlst;
00073     updateIcons();
00074 }
00075 
00076 int KIconSelectAction::plug(TQWidget* widget, int index)
00077 {
00078     int value(-1);
00079     if (widget->inherits(TQPOPUPMENU_OBJECT_NAME_STRING))
00080     {
00081         createPopupMenu();
00082         value = KSelectAction::plug(widget, index);
00083     }
00084     else if (widget->inherits("KToolBar"))
00085     {
00086         KToolBar* bar = static_cast<KToolBar*>(widget);
00087         int id = KAction::getToolButtonID();
00088         // To have a correct layout in the toolbar, a non
00089         // empty icon has to be used. Use "unknown" by default.
00090         TQString    iconName = (currentItem() != -1 ? d->m_iconlst[currentItem()] : "unknown");
00091 
00092         createPopupMenu();
00093         bar->insertButton(iconName, id, true, plainText(), index);
00094         bar->getButton(id)->setPopup(d->m_menu, true);
00095         bar->setItemEnabled(id, isEnabled());
00096         addContainer(bar, id);
00097         connect(bar, TQT_SIGNAL(destroyed()), TQT_SLOT(slotDestroyed()));
00098 
00099         value = containerCount()-1;
00100     }
00101     return value;
00102 }
00103 
00104 void KIconSelectAction::updateCurrentItem(int id)
00105 {
00106     TQWidget*   w = container(id);
00107     if (w->inherits("KToolBar"))
00108         static_cast<KToolBar*>(w)->getButton(itemId(id))->setIcon(d->m_iconlst[currentItem()]);
00109     else
00110         KSelectAction::updateCurrentItem(id);
00111 }
00112 
00113 void KIconSelectAction::setCurrentItem(int index)
00114 {
00115     KSelectAction::setCurrentItem(index);
00116 }
00117 
00118 #include "kiconselectaction.moc"

kdeprint

Skip menu "kdeprint"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kdeprint

Skip menu "kdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdeprint by doxygen 1.7.6.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |