ttdetoolbarbutton.h
1/*
2 * Kivio - Visual Modelling and Flowcharting
3 * Copyright (C) 2000 theKompany.com
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20#ifndef TTDETOOLBARBUTTON_H
21#define TTDETOOLBARBUTTON_H
22
23#include <ttdeaction.h>
24
25#include <tqpixmap.h>
26#include <tqtoolbutton.h>
27#include <tdeglobal.h>
28
29class TDEToolBar;
30class TDEInstance;
31class TQPopupMenu;
32class TQPainter;
33
34class TTDEToolBarButton : public TQToolButton
35{ TQ_OBJECT
36
37public:
38 TTDEToolBarButton(const TQString& icon, const TQString& txt,
39 TQWidget* parent = 0, const char *name=0L,
40 TDEInstance *_instance = TDEGlobal::instance());
41
42 TTDEToolBarButton(const TQPixmap&, const TQString&, TQWidget* parent=0, const char* name=0);
43 ~TTDEToolBarButton();
44
45 void setIconMode(TK::IconMode);
46 void setRaised(bool);
47 void setAutoRaised(bool);
48
54 void setEnabled(bool enable = true);
55
64 virtual void setPixmap(const TQPixmap &pixmap);
65
77 virtual void setPixmap(const TQPixmap &pixmap, bool generate);
78
85 virtual void setDefaultPixmap(const TQPixmap& pixmap);
86
93 virtual void setDisabledPixmap(const TQPixmap& pixmap);
94
101 virtual void setText(const TQString &text);
102 TQString text();
103
112 virtual void setIcon(const TQString &icon);
113
120 virtual void setDefaultIcon(const TQString& icon);
121
128 virtual void setDisabledIcon(const TQString& icon);
129
135 void on(bool flag = true);
136
140 void toggle();
141
149 void setToggle(bool toggle = true);
150
154 TQPopupMenu *popup();
155
163 void setPopup (TQPopupMenu *p);
164
179 void setDelayedPopup(TQPopupMenu *p, bool toggle = false);
180
181 TQPixmap getActivePixmap() const;
182
183 virtual TQSize sizeHint() const;
184 virtual TQSize minimumSizeHint() const;
185
186signals:
187 void buttonClicked();
188 void buttonPressed();
189 void buttonReleased();
190 void buttonToggled();
191
192public slots:
193 void modeChange();
194
195protected:
196 void paletteChange(const TQPalette &);
197 void leaveEvent(TQEvent *e);
198 void enterEvent(TQEvent *e);
199 void drawButton(TQPainter *p);
200 bool eventFilter (TQObject *o, TQEvent *e);
201 void showMenu();
202
203 void makeDefaultPixmap();
204 void makeDisabledPixmap();
205 bool arrowPressed( const TQPoint& pos ) {
206 int x = pos.x();
207 int y = pos.y();
208 return (x > width() - 12 && x <= width() && y > 0 && y < height());
209 }
210
211private:
212 TQPixmap defaultPixmap;
213 TQPixmap activePixmap;
214 TQPixmap disabledPixmap;
215 virtual void setIcon(const TQPixmap &p) { TQButton::setIcon(p); }
216 class TTDEToolBarButtonPrivate;
217 TTDEToolBarButtonPrivate *d;
218
219
220protected slots:
221 void slotClicked();
222 void slotPressed();
223 void slotReleased();
224 void slotToggled();
225 void slotDelayTimeout();
226};
227
228#endif