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

tdeui

tdetoolbarbutton.cpp
00001 /* This file is part of the KDE libraries
00002     Copyright (C) 1997, 1998 Stephan Kulow (coolo@kde.org)
00003               (C) 1997, 1998 Mark Donohoe (donohoe@kde.org)
00004               (C) 1997, 1998 Sven Radej (radej@kde.org)
00005               (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org)
00006               (C) 1999 Chris Schlaeger (cs@kde.org)
00007               (C) 1999 Kurt Granroth (granroth@kde.org)
00008 
00009     This library is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU Library General Public
00011     License version 2 as published by the Free Software Foundation.
00012 
00013     This library is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016     Library General Public License for more details.
00017 
00018     You should have received a copy of the GNU Library General Public License
00019     along with this library; see the file COPYING.LIB.  If not, write to
00020     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00021     Boston, MA 02110-1301, USA.
00022 */
00023 
00024 #include <config.h>
00025 #include <string.h>
00026 
00027 #include "tdetoolbarbutton.h"
00028 #include "tdetoolbar.h"
00029 
00030 #include <tqstyle.h>
00031 #include <tqimage.h>
00032 #include <tqtimer.h>
00033 #include <tqdrawutil.h>
00034 #include <tqtooltip.h>
00035 #include <tqbitmap.h>
00036 #include <tqpopupmenu.h>
00037 #include <tqcursor.h>
00038 #include <tqpainter.h>
00039 #include <tqlayout.h>
00040 
00041 #include <tdeapplication.h>
00042 #include <kdebug.h>
00043 #include <tdeglobal.h>
00044 #include <tdeglobalsettings.h>
00045 #include <kiconeffect.h>
00046 #include <kiconloader.h>
00047 
00048 // needed to get our instance
00049 #include <tdemainwindow.h>
00050 
00051 template class TQIntDict<TDEToolBarButton>;
00052 
00053 class TDEToolBarButtonPrivate
00054 {
00055 public:
00056   TDEToolBarButtonPrivate();
00057   ~TDEToolBarButtonPrivate();
00058 
00059   int     m_id;
00060   bool    m_buttonDown;
00061   bool    m_noStyle;
00062   bool    m_isSeparator;
00063   bool    m_isRadio;
00064   bool    m_highlight;
00065   bool    m_isRaised;
00066   bool    m_isActive;
00067 
00068   TQString m_iconName;
00069 
00070   TDEToolBar *m_parent;
00071   TDEToolBar::IconText m_iconText;
00072   int m_iconSize;
00073   TQSize size;
00074 
00075   TQPoint m_mousePressPos;
00076 
00077   TDEInstance  *m_instance;
00078 };
00079 
00080 TDEToolBarButtonPrivate::TDEToolBarButtonPrivate()
00081 {
00082     m_buttonDown  = false;
00083 
00084     m_noStyle     = false;
00085     m_isSeparator = false;
00086     m_isRadio     = false;
00087     m_highlight   = false;
00088     m_isRaised    = false;
00089     m_isActive    = false;
00090 
00091     m_iconName    = TQString::null;
00092     m_iconText    = TDEToolBar::IconOnly;
00093     m_iconSize    = 0;
00094 
00095     m_parent   = 0;
00096     m_instance = TDEGlobal::instance();
00097 }
00098 
00099 TDEToolBarButtonPrivate::~TDEToolBarButtonPrivate()
00100 {
00101     //
00102 }
00103 
00104 // This will construct a separator
00105 TDEToolBarButton::TDEToolBarButton( TQWidget *_parent, const char *_name )
00106   : TQToolButton( _parent , _name)
00107 {
00108   d = new TDEToolBarButtonPrivate();
00109 
00110   resize(6,6);
00111   hide();
00112   d->m_isSeparator = true;
00113 }
00114 
00115 TDEToolBarButton::TDEToolBarButton( const TQString& _icon, int _id,
00116                                 TQWidget *_parent, const char *_name,
00117                                 const TQString &_txt, TDEInstance *_instance )
00118     : TQToolButton( _parent, _name ), d( 0 )
00119 {
00120   d = new TDEToolBarButtonPrivate();
00121 
00122   d->m_id     = _id;
00123   TQToolButton::setTextLabel(_txt);
00124   d->m_instance = _instance;
00125 
00126   d->m_parent = tqt_dynamic_cast<TDEToolBar*>(_parent);
00127   if (d->m_parent) {
00128     connect(d->m_parent, TQT_SIGNAL( modechange() ),
00129             this,         TQT_SLOT( modeChange() ));
00130   }
00131 
00132   setFocusPolicy( TQ_NoFocus );
00133 
00134   // connect all of our slots and start trapping events
00135   connect(this, TQT_SIGNAL( clicked() ),
00136           this, TQT_SLOT( slotClicked() ) );
00137   connect(this, TQT_SIGNAL( pressed() ),
00138           this, TQT_SLOT( slotPressed() ) );
00139   connect(this, TQT_SIGNAL( released() ),
00140           this, TQT_SLOT( slotReleased() ) );
00141   installEventFilter(this);
00142 
00143   d->m_iconName = _icon;
00144 
00145   // do our initial setup
00146   modeChange();
00147 }
00148 
00149 TDEToolBarButton::TDEToolBarButton( const TQPixmap& pixmap, int _id,
00150                                 TQWidget *_parent, const char *name,
00151                                 const TQString& txt)
00152     : TQToolButton( _parent, name ), d( 0 )
00153 {
00154   d = new TDEToolBarButtonPrivate();
00155 
00156   d->m_id       = _id;
00157   TQToolButton::setTextLabel(txt);
00158 
00159   d->m_parent = tqt_dynamic_cast<TDEToolBar*>(_parent);
00160   if (d->m_parent) {
00161     connect(d->m_parent, TQT_SIGNAL( modechange() ),
00162             this,         TQT_SLOT( modeChange() ));
00163   }
00164 
00165   setFocusPolicy( TQ_NoFocus );
00166 
00167   // connect all of our slots and start trapping events
00168   connect(this, TQT_SIGNAL( clicked() ),
00169           this, TQT_SLOT( slotClicked() ));
00170   connect(this, TQT_SIGNAL( pressed() ),
00171           this, TQT_SLOT( slotPressed() ));
00172   connect(this, TQT_SIGNAL( released() ),
00173           this, TQT_SLOT( slotReleased() ));
00174   installEventFilter(this);
00175 
00176   // set our pixmap and do our initial setup
00177   setIconSet( TQIconSet( pixmap ));
00178   modeChange();
00179 }
00180 
00181 TDEToolBarButton::~TDEToolBarButton()
00182 {
00183   delete d; d = 0;
00184 }
00185 
00186 void TDEToolBarButton::modeChange()
00187 {
00188   TQSize mysize;
00189 
00190   // grab a few global variables for use in this function and others
00191   if (d->m_parent) {
00192     d->m_highlight = d->m_parent->highlight();
00193     d->m_iconText  = d->m_parent->iconText();
00194 
00195     d->m_iconSize = d->m_parent->iconSize();
00196   }
00197   if (!d->m_iconName.isNull())
00198     setIcon(d->m_iconName);
00199 
00200   // we'll start with the size of our pixmap
00201   int pix_width  = d->m_iconSize;
00202   if ( d->m_iconSize == 0 ) {
00203       if (d->m_parent && !strcmp(d->m_parent->name(), "mainToolBar"))
00204           pix_width = IconSize( TDEIcon::MainToolbar );
00205       else
00206           pix_width = IconSize( TDEIcon::Toolbar );
00207   }
00208   int pix_height = pix_width;
00209 
00210   int text_height = 0;
00211   int text_width = 0;
00212 
00213   TQToolTip::remove(this);
00214   if (d->m_iconText != TDEToolBar::IconOnly)
00215   {
00216     // okay, we have to deal with fonts.  let's get our information now
00217     TQFont tmp_font = TDEGlobalSettings::toolBarFont();
00218 
00219     // now parse out our font sizes from our chosen font
00220     TQFontMetrics fm(tmp_font);
00221 
00222     text_height = fm.lineSpacing();
00223     text_width  = fm.width(textLabel());
00224 
00225     // none of the other modes want tooltips
00226   }
00227   else
00228   {
00229     TQToolTip::add(this, textLabel());
00230   }
00231 
00232   switch (d->m_iconText)
00233   {
00234   case TDEToolBar::IconOnly:
00235     mysize = TQSize(pix_width, pix_height);
00236     break;
00237 
00238   case TDEToolBar::IconTextRight:
00239     mysize = TQSize(pix_width + text_width + 4, pix_height);
00240     break;
00241 
00242   case TDEToolBar::TextOnly:
00243     mysize = TQSize(text_width + 4, text_height);
00244     break;
00245 
00246   case TDEToolBar::IconTextBottom:
00247     mysize = TQSize((text_width + 4 > pix_width) ? text_width + 4 : pix_width, pix_height + text_height);
00248     break;
00249 
00250   default:
00251     break;
00252   }
00253 
00254   mysize = style().tqsizeFromContents(TQStyle::CT_ToolButton, this, mysize).
00255                expandedTo(TQApplication::globalStrut());
00256 
00257   // make sure that this isn't taller then it is wide
00258   if (mysize.height() > mysize.width())
00259     mysize.setWidth(mysize.height());
00260 
00261   d->size = mysize;
00262   updateGeometry();
00263 }
00264 
00265 void TDEToolBarButton::setTextLabel( const TQString& text, bool tipToo)
00266 {
00267   if (text.isNull())
00268     return;
00269 
00270   TQString txt(text);
00271   if (txt.endsWith(TQString::fromLatin1("...")))
00272     txt.truncate(txt.length() - 3);
00273 
00274   TQToolButton::setTextLabel(txt, tipToo);
00275   update();
00276 }
00277 
00278 void TDEToolBarButton::setText( const TQString& text)
00279 {
00280   setTextLabel(text, true);
00281   modeChange();
00282 }
00283 
00284 void TDEToolBarButton::setIcon( const TQString &icon )
00285 {
00286   d->m_iconName = icon;
00287   if (d->m_parent)
00288     d->m_iconSize = d->m_parent->iconSize();
00289   // TQObject::name() return "const char *" instead of TQString.
00290   if (d->m_parent && !strcmp(d->m_parent->name(), "mainToolBar"))
00291     TQToolButton::setIconSet( d->m_instance->iconLoader()->loadIconSet(
00292         d->m_iconName, TDEIcon::MainToolbar, d->m_iconSize ));
00293   else
00294     TQToolButton::setIconSet( d->m_instance->iconLoader()->loadIconSet(
00295         d->m_iconName, TDEIcon::Toolbar, d->m_iconSize ));
00296 }
00297 
00298 void TDEToolBarButton::setIconSet( const TQIconSet &iconset )
00299 {
00300   TQToolButton::setIconSet( iconset );
00301 }
00302 
00303 // remove?
00304 void TDEToolBarButton::setPixmap( const TQPixmap &pixmap )
00305 {
00306   if( pixmap.isNull()) // called by TQToolButton
00307   {
00308     TQToolButton::setPixmap( pixmap );
00309     return;
00310   }
00311   TQIconSet set = iconSet();
00312   set.setPixmap( pixmap, TQIconSet::Automatic, TQIconSet::Active );
00313   TQToolButton::setIconSet( set );
00314 }
00315 
00316 void TDEToolBarButton::setDefaultPixmap( const TQPixmap &pixmap )
00317 {
00318   TQIconSet set = iconSet();
00319   set.setPixmap( pixmap, TQIconSet::Automatic, TQIconSet::Normal );
00320   TQToolButton::setIconSet( set );
00321 }
00322 
00323 void TDEToolBarButton::setDisabledPixmap( const TQPixmap &pixmap )
00324 {
00325   TQIconSet set = iconSet();
00326   set.setPixmap( pixmap, TQIconSet::Automatic, TQIconSet::Disabled );
00327   TQToolButton::setIconSet( set );
00328 }
00329 
00330 void TDEToolBarButton::setDefaultIcon( const TQString& icon )
00331 {
00332   TQIconSet set = iconSet();
00333   TQPixmap pm;
00334   if (d->m_parent && !strcmp(d->m_parent->name(), "mainToolBar"))
00335     pm = d->m_instance->iconLoader()->loadIcon( icon, TDEIcon::MainToolbar,
00336         d->m_iconSize );
00337   else
00338     pm = d->m_instance->iconLoader()->loadIcon( icon, TDEIcon::Toolbar,
00339         d->m_iconSize );
00340   set.setPixmap( pm, TQIconSet::Automatic, TQIconSet::Normal );
00341   TQToolButton::setIconSet( set );
00342 }
00343 
00344 void TDEToolBarButton::setDisabledIcon( const TQString& icon )
00345 {
00346   TQIconSet set = iconSet();
00347   TQPixmap pm;
00348   if (d->m_parent && !strcmp(d->m_parent->name(), "mainToolBar"))
00349     pm = d->m_instance->iconLoader()->loadIcon( icon, TDEIcon::MainToolbar,
00350         d->m_iconSize );
00351   else
00352     pm = d->m_instance->iconLoader()->loadIcon( icon, TDEIcon::Toolbar,
00353         d->m_iconSize );
00354   set.setPixmap( pm, TQIconSet::Automatic, TQIconSet::Disabled );
00355   TQToolButton::setIconSet( set );
00356 }
00357 
00358 TQPopupMenu *TDEToolBarButton::popup()
00359 {
00360   // obsolete
00361   // KDE4: remove me
00362   return TQToolButton::popup();
00363 }
00364 
00365 void TDEToolBarButton::setPopup(TQPopupMenu *p, bool)
00366 {
00367   TQToolButton::setPopup(p);
00368   TQToolButton::setPopupDelay(-1);
00369 }
00370 
00371 
00372 void TDEToolBarButton::setDelayedPopup (TQPopupMenu *p, bool)
00373 {
00374   TQToolButton::setPopup(p);
00375   TQToolButton::setPopupDelay(TQApplication::startDragTime());
00376 }
00377 
00378 void TDEToolBarButton::leaveEvent(TQEvent *)
00379 {
00380   if( d->m_isRaised || d->m_isActive )
00381   {
00382     d->m_isRaised = false;
00383     d->m_isActive = false;
00384     repaint(false);
00385   }
00386 
00387   emit highlighted(d->m_id, false);
00388 }
00389 
00390 void TDEToolBarButton::enterEvent(TQEvent *)
00391 {
00392   if (d->m_highlight)
00393   {
00394     if (isEnabled())
00395     {
00396       d->m_isActive = true;
00397       if (!isToggleButton())
00398         d->m_isRaised = true;
00399     }
00400     else
00401     {
00402       d->m_isRaised = false;
00403       d->m_isActive = false;
00404     }
00405 
00406     repaint(false);
00407   }
00408   emit highlighted(d->m_id, true);
00409 }
00410 
00411 bool TDEToolBarButton::eventFilter(TQObject *o, TQEvent *ev)
00412 {
00413   if (TQT_BASE_OBJECT(o) == TQT_BASE_OBJECT(this))
00414   {
00415 
00416     // Popup the menu when the left mousebutton is pressed and the mouse
00417     // is moved by a small distance.
00418     if (TQToolButton::popup())
00419     {
00420       if (ev->type() == TQEvent::MouseButtonPress)
00421       {
00422         TQMouseEvent* mev = TQT_TQMOUSEEVENT(ev);
00423         d->m_mousePressPos = mev->pos();
00424       }
00425       else if (ev->type() == TQEvent::MouseMove)
00426       {
00427         TQMouseEvent* mev = TQT_TQMOUSEEVENT(ev);
00428         if ((mev->pos() - d->m_mousePressPos).manhattanLength()
00429               > TDEGlobalSettings::dndEventDelay())
00430         {
00431           openPopup();
00432           return true;
00433         }
00434       }
00435     }
00436 
00437     if (d->m_isRadio &&
00438     (ev->type() == TQEvent::MouseButtonPress ||
00439          ev->type() == TQEvent::MouseButtonRelease ||
00440          ev->type() == TQEvent::MouseButtonDblClick) && isOn())
00441       return true;
00442 
00443     // From Kai-Uwe Sattler <kus@iti.CS.Uni-Magdeburg.De>
00444     if (ev->type() == TQEvent::MouseButtonDblClick)
00445     {
00446       emit doubleClicked(d->m_id);
00447       return false;
00448     }
00449   }
00450 
00451   return TQToolButton::eventFilter(o, ev);
00452 }
00453 
00454 void TDEToolBarButton::mousePressEvent( TQMouseEvent * e )
00455 {
00456   d->m_buttonDown = true;
00457 
00458   if ( e->button() == Qt::MidButton )
00459   {
00460     // Get TQToolButton to show the button being down while pressed
00461     TQMouseEvent ev( TQEvent::MouseButtonPress, e->pos(), e->globalPos(), Qt::LeftButton, e->state() );
00462     TQToolButton::mousePressEvent(&ev);
00463     return;
00464   }
00465   TQToolButton::mousePressEvent(e);
00466 }
00467 
00468 void TDEToolBarButton::mouseReleaseEvent( TQMouseEvent * e )
00469 {
00470   TQt::ButtonState state = TQt::ButtonState(e->button() | (e->state() & KeyButtonMask));
00471   if ( e->button() == Qt::MidButton )
00472   {
00473     TQMouseEvent ev( TQEvent::MouseButtonRelease, e->pos(), e->globalPos(), Qt::LeftButton, e->state() );
00474     TQToolButton::mouseReleaseEvent(&ev);
00475   }
00476   else
00477     TQToolButton::mouseReleaseEvent(e);
00478 
00479   if ( !d->m_buttonDown )
00480     return;
00481   d->m_buttonDown = false;
00482 
00483   if ( hitButton( e->pos() ) )
00484     emit buttonClicked( d->m_id, state );
00485 }
00486 
00487 void TDEToolBarButton::drawButton( TQPainter *_painter )
00488 {
00489   TQStyle::SFlags flags   = TQStyle::Style_Default;
00490   TQStyle::SCFlags active = TQStyle::SC_None;
00491 
00492   if (isDown()) {
00493     flags  |= TQStyle::Style_Down;
00494     active |= TQStyle::SC_ToolButton;
00495   }
00496   if (isEnabled())  flags |= TQStyle::Style_Enabled;
00497   if (isOn())       flags |= TQStyle::Style_On;
00498   if (isEnabled() && hasMouse())    flags |= TQStyle::Style_Raised;
00499   if (hasFocus())   flags |= TQStyle::Style_HasFocus;
00500 
00501   // Draw a styled toolbutton
00502   style().drawComplexControl(TQStyle::CC_ToolButton, _painter, this, rect(),
00503     colorGroup(), flags, TQStyle::SC_ToolButton, active, TQStyleOption());
00504 
00505   int dx, dy;
00506   TQFont tmp_font(TDEGlobalSettings::toolBarFont());
00507   TQFontMetrics fm(tmp_font);
00508   TQRect textRect;
00509   int textFlags = 0;
00510 
00511   if (d->m_iconText == TDEToolBar::IconOnly) // icon only
00512   {
00513     TQPixmap pixmap = iconSet().pixmap( TQIconSet::Automatic,
00514         isEnabled() ? (d->m_isActive ? TQIconSet::Active : TQIconSet::Normal) :
00515                TQIconSet::Disabled,
00516         isOn() ? TQIconSet::On : TQIconSet::Off );
00517     if( !pixmap.isNull())
00518     {
00519       dx = ( width() - pixmap.width() ) / 2;
00520       dy = ( height() - pixmap.height() ) / 2;
00521       if ( isDown() && style().styleHint(TQStyle::SH_GUIStyle) == WindowsStyle )
00522       {
00523         ++dx;
00524         ++dy;
00525       }
00526       _painter->drawPixmap( dx, dy, pixmap );
00527     }
00528   }
00529   else if (d->m_iconText == TDEToolBar::IconTextRight) // icon and text (if any)
00530   {
00531     TQPixmap pixmap = iconSet().pixmap( TQIconSet::Automatic,
00532         isEnabled() ? (d->m_isActive ? TQIconSet::Active : TQIconSet::Normal) :
00533                 TQIconSet::Disabled,
00534         isOn() ? TQIconSet::On : TQIconSet::Off );
00535     if( !pixmap.isNull())
00536     {
00537       dx = 4;
00538       dy = ( height() - pixmap.height() ) / 2;
00539       if ( isDown() && style().styleHint(TQStyle::SH_GUIStyle) == WindowsStyle )
00540       {
00541         ++dx;
00542         ++dy;
00543       }
00544       _painter->drawPixmap( dx, dy, pixmap );
00545     }
00546 
00547     if (!textLabel().isNull())
00548     {
00549       textFlags = AlignVCenter|AlignLeft;
00550       if (!pixmap.isNull())
00551         dx = 4 + pixmap.width() + 2;
00552       else
00553         dx = 4;
00554       dy = 0;
00555       if ( isDown() && style().styleHint(TQStyle::SH_GUIStyle) == WindowsStyle )
00556       {
00557         ++dx;
00558         ++dy;
00559       }
00560       textRect = TQRect(dx, dy, width()-dx, height());
00561     }
00562   }
00563   else if (d->m_iconText == TDEToolBar::TextOnly)
00564   {
00565     if (!textLabel().isNull())
00566     {
00567       textFlags = AlignVCenter|AlignLeft;
00568       dx = (width() - fm.width(textLabel())) / 2;
00569       dy = (height() - fm.lineSpacing()) / 2;
00570       if ( isDown() && style().styleHint(TQStyle::SH_GUIStyle) == WindowsStyle )
00571       {
00572         ++dx;
00573         ++dy;
00574       }
00575       textRect = TQRect( dx, dy, fm.width(textLabel()), fm.lineSpacing() );
00576     }
00577   }
00578   else if (d->m_iconText == TDEToolBar::IconTextBottom)
00579   {
00580     TQPixmap pixmap = iconSet().pixmap( TQIconSet::Automatic,
00581         isEnabled() ? (d->m_isActive ? TQIconSet::Active : TQIconSet::Normal) :
00582                 TQIconSet::Disabled,
00583         isOn() ? TQIconSet::On : TQIconSet::Off );
00584     if( !pixmap.isNull())
00585     {
00586       dx = (width() - pixmap.width()) / 2;
00587       dy = (height() - fm.lineSpacing() - pixmap.height()) / 2;
00588       if ( isDown() && style().styleHint(TQStyle::SH_GUIStyle) == WindowsStyle )
00589       {
00590         ++dx;
00591         ++dy;
00592       }
00593       _painter->drawPixmap( dx, dy, pixmap );
00594     }
00595 
00596     if (!textLabel().isNull())
00597     {
00598       textFlags = AlignBottom|AlignHCenter;
00599       dx = (width() - fm.width(textLabel())) / 2;
00600       dy = height() - fm.lineSpacing() - 4;
00601 
00602       if ( isDown() && style().styleHint(TQStyle::SH_GUIStyle) == WindowsStyle )
00603       {
00604         ++dx;
00605         ++dy;
00606       }
00607       textRect = TQRect( dx, dy, fm.width(textLabel()), fm.lineSpacing() );
00608     }
00609   }
00610 
00611   // Draw the text at the position given by textRect, and using textFlags
00612   if (!textLabel().isNull() && !textRect.isNull())
00613   {
00614       _painter->setFont(TDEGlobalSettings::toolBarFont());
00615       if (!isEnabled())
00616         _painter->setPen(palette().disabled().dark());
00617       else if(d->m_isRaised)
00618         _painter->setPen(TDEGlobalSettings::toolBarHighlightColor());
00619       else
00620     _painter->setPen( colorGroup().buttonText() );
00621       _painter->drawText(textRect, textFlags, textLabel());
00622   }
00623 
00624   if (TQToolButton::popup())
00625   {
00626     TQStyle::SFlags arrowFlags = TQStyle::Style_Default;
00627 
00628     if (isDown())   arrowFlags |= TQStyle::Style_Down;
00629     if (isEnabled())    arrowFlags |= TQStyle::Style_Enabled;
00630 
00631       style().tqdrawPrimitive(TQStyle::PE_ArrowDown, _painter,
00632           TQRect(width()-7, height()-7, 7, 7), colorGroup(),
00633       arrowFlags, TQStyleOption() );
00634   }
00635 }
00636 
00637 void TDEToolBarButton::paletteChange(const TQPalette &)
00638 {
00639   if(!d->m_isSeparator)
00640   {
00641     modeChange();
00642     repaint(false); // no need to delete it first therefore only false
00643   }
00644 }
00645 
00646 bool TDEToolBarButton::event(TQEvent *e)
00647 {
00648   if (e->type() == TQEvent::ParentFontChange || e->type() == TQEvent::ApplicationFontChange)
00649   {
00650      //If we use toolbar text, apply the settings again, to relayout...
00651      if (d->m_iconText != TDEToolBar::IconOnly)
00652        modeChange();
00653      return true;
00654   }
00655 
00656   return TQToolButton::event(e);
00657 }
00658 
00659 
00660 void TDEToolBarButton::showMenu()
00661 {
00662   // obsolete
00663   // KDE4: remove me
00664 }
00665 
00666 void TDEToolBarButton::slotDelayTimeout()
00667 {
00668   // obsolete
00669   // KDE4: remove me
00670 }
00671 
00672 void TDEToolBarButton::slotClicked()
00673 {
00674   emit clicked( d->m_id );
00675 
00676   // emit buttonClicked when the button was clicked while being in an extension popupmenu
00677   if ( d->m_parent && !d->m_parent->rect().contains( geometry().center() ) ) {
00678     ButtonState state = TDEApplication::keyboardMouseState();
00679     if ( ( state & Qt::MouseButtonMask ) == Qt::NoButton )
00680       state = ButtonState( Qt::LeftButton | state );
00681     emit buttonClicked( d->m_id, state ); // Doesn't work with MidButton
00682   }
00683 }
00684 
00685 void TDEToolBarButton::slotPressed()
00686 {
00687   emit pressed( d->m_id );
00688 }
00689 
00690 void TDEToolBarButton::slotReleased()
00691 {
00692   emit released( d->m_id );
00693 }
00694 
00695 void TDEToolBarButton::slotToggled()
00696 {
00697   emit toggled( d->m_id );
00698 }
00699 
00700 void TDEToolBarButton::setNoStyle(bool no_style)
00701 {
00702     d->m_noStyle = no_style;
00703 
00704     modeChange();
00705     d->m_iconText = TDEToolBar::IconTextRight;
00706     repaint(false);
00707 }
00708 
00709 void TDEToolBarButton::setRadio (bool f)
00710 {
00711     if ( d )
00712     d->m_isRadio = f;
00713 }
00714 
00715 void TDEToolBarButton::on(bool flag)
00716 {
00717   if(isToggleButton())
00718     setOn(flag);
00719   else
00720   {
00721     setDown(flag);
00722     leaveEvent((TQEvent *) 0);
00723   }
00724   repaint();
00725 }
00726 
00727 void TDEToolBarButton::toggle()
00728 {
00729   setOn(!isOn());
00730   repaint();
00731 }
00732 
00733 void TDEToolBarButton::setToggle(bool flag)
00734 {
00735   setToggleButton(flag);
00736   if (flag)
00737     connect(this, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotToggled()));
00738   else
00739     disconnect(this, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotToggled()));
00740 }
00741 
00742 TQSize TDEToolBarButton::sizeHint() const
00743 {
00744    return d->size;
00745 }
00746 
00747 TQSize TDEToolBarButton::minimumSizeHint() const
00748 {
00749    return d->size;
00750 }
00751 
00752 TQSize TDEToolBarButton::minimumSize() const
00753 {
00754    return d->size;
00755 }
00756 
00757 bool TDEToolBarButton::isRaised() const
00758 {
00759     return d->m_isRaised;
00760 }
00761 
00762 bool TDEToolBarButton::isActive() const
00763 {
00764     return d->m_isActive;
00765 }
00766 
00767 int TDEToolBarButton::iconTextMode() const
00768 {
00769     return static_cast<int>( d->m_iconText );
00770 }
00771 
00772 int TDEToolBarButton::id() const
00773 {
00774     return d->m_id;
00775 }
00776 
00777 // TDEToolBarButtonList
00778 TDEToolBarButtonList::TDEToolBarButtonList()
00779 {
00780    setAutoDelete(false);
00781 }
00782 
00783 void TDEToolBarButton::virtual_hook( int, void* )
00784 { /*BASE::virtual_hook( id, data );*/ }
00785 
00786 #include "tdetoolbarbutton.moc"

tdeui

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

tdeui

Skip menu "tdeui"
  • 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 tdeui by doxygen 1.7.6.1
This website is maintained by Timothy Pearson.