lib Library API Documentation

tktoolbarbutton.h

00001 /*
00002  * Kivio - Visual Modelling and Flowcharting
00003  * Copyright (C) 2000 theKompany.com
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018  */
00019 #ifndef TKTOOLBARBUTTON_H
00020 #define TKTOOLBARBUTTON_H
00021 
00022 #include <tkaction.h>
00023 
00024 #include <qpixmap.h>
00025 #include <qtoolbutton.h>
00026 #include <kglobal.h>
00027 
00028 class KToolBar;
00029 class KInstance;
00030 class QPopupMenu;
00031 class QPainter;
00032 
00033 class TKToolBarButton : public QToolButton
00034 { Q_OBJECT
00035 public:
00036   TKToolBarButton(const QString& icon, const QString& txt,
00037                      QWidget* parent = 0, const char *name=0L,
00038                      KInstance *_instance = KGlobal::instance());
00039 
00040   TKToolBarButton(const QPixmap&, const QString&, QWidget* parent=0, const char* name=0);
00041   ~TKToolBarButton();
00042 
00043   void setIconMode(TK::IconMode);
00044   void setRaised(bool);
00045   void setAutoRaised(bool);
00046 
00052   void setEnabled(bool enable = true);
00053 
00062   virtual void setPixmap(const QPixmap &pixmap);
00063 
00075   virtual void setPixmap(const QPixmap &pixmap, bool generate);
00076 
00083   virtual void setDefaultPixmap(const QPixmap& pixmap);
00084 
00091   virtual void setDisabledPixmap(const QPixmap& pixmap);
00092 
00099   virtual void setText(const QString &text);
00100   QString text();
00101 
00110   virtual void setIcon(const QString &icon);
00111 
00118   virtual void setDefaultIcon(const QString& icon);
00119 
00126   virtual void setDisabledIcon(const QString& icon);
00127 
00133   void on(bool flag = true);
00134 
00138   void toggle();
00139 
00147   void setToggle(bool toggle = true);
00148 
00152   QPopupMenu *popup();
00153 
00161   void setPopup (QPopupMenu *p);
00162 
00177   void setDelayedPopup(QPopupMenu *p, bool toggle = false);
00178 
00179   QPixmap getActivePixmap() const;
00180 
00181   virtual QSize sizeHint() const;
00182   virtual QSize minimumSizeHint() const;
00183 
00184 signals:
00185   void buttonClicked();
00186   void buttonPressed();
00187   void buttonReleased();
00188   void buttonToggled();
00189 
00190 public slots:
00191   void modeChange();
00192 
00193 protected:
00194   void paletteChange(const QPalette &);
00195   void leaveEvent(QEvent *e);
00196   void enterEvent(QEvent *e);
00197   void drawButton(QPainter *p);
00198   bool eventFilter (QObject *o, QEvent *e);
00199   void showMenu();
00200 
00201   void makeDefaultPixmap();
00202   void makeDisabledPixmap();
00203   bool arrowPressed( const QPoint& pos ) {
00204     int x = pos.x();
00205     int y = pos.y();
00206     return (x > width() - 12 && x <= width() && y > 0 && y < height());
00207   }
00208 
00209 private:
00210   QPixmap defaultPixmap;
00211   QPixmap activePixmap;
00212   QPixmap disabledPixmap;
00213   virtual void setIcon(const QPixmap &p) { QButton::setIcon(p); }
00214   class TKToolBarButtonPrivate;
00215   TKToolBarButtonPrivate *d;
00216 
00217 
00218 protected slots:
00219   void slotClicked();
00220   void slotPressed();
00221   void slotReleased();
00222   void slotToggled();
00223   void slotDelayTimeout();
00224 };
00225 
00226 #endif
KDE Logo
This file is part of the documentation for lib Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:40:16 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003