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

tdeprint

kiconselectaction.cpp

00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001 Michael Goffioul <tdeprint@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 <tdetoolbar.h>
00026 #include <tdetoolbarbutton.h>
00027 
00028 class TDEIconSelectActionPrivate
00029 {
00030 public:
00031     TDEIconSelectActionPrivate()
00032     {
00033         m_menu = 0;
00034     }
00035     TQStringList    m_iconlst;
00036     TQPopupMenu*    m_menu;
00037 };
00038 
00039 TDEIconSelectAction::TDEIconSelectAction(const TQString& text, int accel, TQObject* parent, const char* name)
00040 : TDESelectAction(text, accel, parent, name)
00041 {
00042     d = new TDEIconSelectActionPrivate;
00043 }
00044 
00045 TDEIconSelectAction::~TDEIconSelectAction()
00046 {
00047     delete d;
00048 }
00049 
00050 void TDEIconSelectAction::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 TDEIconSelectAction::createPopupMenu()
00061 {
00062     if (!d->m_menu)
00063     {
00064         d->m_menu = popupMenu();
00065         updateIcons();
00066     }
00067 }
00068 
00069 void TDEIconSelectAction::setItems(const TQStringList& lst, const TQStringList& iconlst)
00070 {
00071     TDESelectAction::setItems(lst);
00072     d->m_iconlst = iconlst;
00073     updateIcons();
00074 }
00075 
00076 int TDEIconSelectAction::plug(TQWidget* widget, int index)
00077 {
00078     int value(-1);
00079     if (widget->inherits(TQPOPUPMENU_OBJECT_NAME_STRING))
00080     {
00081         createPopupMenu();
00082         value = TDESelectAction::plug(widget, index);
00083     }
00084     else if (widget->inherits("TDEToolBar"))
00085     {
00086         TDEToolBar* bar = static_cast<TDEToolBar*>(widget);
00087         int id = TDEAction::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 TDEIconSelectAction::updateCurrentItem(int id)
00105 {
00106     TQWidget*   w = container(id);
00107     if (w->inherits("TDEToolBar"))
00108         static_cast<TDEToolBar*>(w)->getButton(itemId(id))->setIcon(d->m_iconlst[currentItem()]);
00109     else
00110         TDESelectAction::updateCurrentItem(id);
00111 }
00112 
00113 void TDEIconSelectAction::setCurrentItem(int index)
00114 {
00115     TDESelectAction::setCurrentItem(index);
00116 }
00117 
00118 #include "kiconselectaction.moc"

tdeprint

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

tdeprint

Skip menu "tdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeprint by doxygen 1.7.1
This website is maintained by Timothy Pearson.