summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui/ktoolbarbutton.h
Unidiff
Diffstat (limited to 'microkde/kdeui/ktoolbarbutton.h') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/ktoolbarbutton.h313
1 files changed, 313 insertions, 0 deletions
diff --git a/microkde/kdeui/ktoolbarbutton.h b/microkde/kdeui/ktoolbarbutton.h
new file mode 100644
index 0000000..9aaa13c
--- a/dev/null
+++ b/microkde/kdeui/ktoolbarbutton.h
@@ -0,0 +1,313 @@
1/* This file is part of the KDE libraries
2 Copyright (C) 1997, 1998 Stephan Kulow (coolo@kde.org)
3 (C) 1997, 1998 Sven Radej (radej@kde.org)
4 (C) 1997, 1998 Mark Donohoe (donohoe@kde.org)
5 (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org)
6 (C) 2000 Kurt Granroth (granroth@kde.org)
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public
10 License version 2 as published by the Free Software Foundation.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.
21*/
22
23// $Id$
24#ifndef _KTOOLBARBUTTON_H
25#define _KTOOLBARBUTTON_H
26
27#include <qpixmap.h>
28#include <qtoolbutton.h>
29#include <qintdict.h>
30#include <qstring.h>
31#include <kglobal.h>
32
33class KToolBar;
34class KToolBarButtonPrivate;
35//USclass KInstance;
36class QEvent;
37class QPopupMenu;
38class QPainter;
39
40/**
41 * A toolbar button. This is used internally by @ref KToolBar, use the
42 * KToolBar methods instead.
43 * @internal
44 */
45class KToolBarButton : public QToolButton
46{
47 Q_OBJECT
48
49public:
50 /**
51 * Construct a button with an icon loaded by the button itself.
52 * This will trust the button to load the correct icon with the
53 * correct size.
54 *
55 * @param icon Name of icon to load (may be absolute or relative)
56 * @param id Id of this button
57 * @param parent This button's parent
58 * @param name This button's internal name
59 * @param txt This button's text (in a tooltip or otherwise)
60 */
61 KToolBarButton(const QString& icon, int id, QWidget *parent,
62 const char *name=0L, const QString &txt=QString::null/*US,
63 KInstance *_instance = KGlobal::instance()*/);
64
65 /**
66 * Construct a button with an existing pixmap. It is not
67 * recommended that you use this as the internal icon loading code
68 * will almost always get it "right".
69 *
70 * @param icon Name of icon to load (may be absolute or relative)
71 * @param id Id of this button
72 * @param parent This button's parent
73 * @param name This button's internal name
74 * @param txt This button's text (in a tooltip or otherwise)
75 */
76 KToolBarButton(const QPixmap& pixmap, int id, QWidget *parent,
77 const char *name=0L, const QString &txt=QString::null);
78
79 /**
80 * Construct a separator button
81 *
82 * @param parent This button's parent
83 * @param name This button's internal name
84 */
85 KToolBarButton(QWidget *parent=0L, const char *name=0L);
86
87 /**
88 * Standard destructor
89 */
90 ~KToolBarButton();
91 QSize sizeHint() const;
92 QSize minimumSizeHint() const;
93 QSize minimumSize() const;
94
95#ifndef KDE_NO_COMPAT
96 /**
97 * @deprecated
98 * Set the pixmap directly for this button. This pixmap should be
99 * the active one... the dimmed and disabled pixmaps are constructed
100 * based on this one. However, don't use this function unless you
101 * are positive that you don't want to use @ref setIcon.
102 *
103 * @param pixmap The active pixmap
104 */
105 // this one is from QButton, so #ifdef-ing it out doesn't break BC
106 virtual void setPixmap(const QPixmap &pixmap);
107
108 /**
109 * @deprecated
110 * Force the button to use this pixmap as the default one rather
111 * then generating it using effects.
112 *
113 * @param pixmap The pixmap to use as the default (normal) one
114 */
115 void setDefaultPixmap(const QPixmap& pixmap);
116
117 /**
118 * @deprecated
119 * Force the button to use this pixmap when disabled one rather then
120 * generating it using effects.
121 *
122 * @param pixmap The pixmap to use when disabled
123 */
124 void setDisabledPixmap(const QPixmap& pixmap);
125#endif
126
127 /**
128 * Set the text for this button. The text will be either used as a
129 * tooltip (IconOnly) or will be along side the icon
130 *
131 * @param text The button (or tooltip) text
132 */
133 virtual void setText(const QString &text);
134
135 /**
136 * Set the icon for this button. The icon will be loaded internally
137 * with the correct size. This function is preferred over @ref setIconSet
138 *
139 * @param icon The name of the icon
140 */
141 virtual void setIcon(const QString &icon);
142
143 /// @since 3.1
144 virtual void setIcon( const QPixmap &pixmap )
145 { QToolButton::setIcon( pixmap ); }
146
147 /**
148 * Set the pixmaps for this toolbar button from a QIconSet.
149 * If you call this you don't need to call any of the other methods
150 * that set icons or pixmaps.
151 * @param iconset The iconset to use
152 */
153 virtual void setIconSet( const QIconSet &iconset );
154
155#ifndef KDE_NO_COMPAT
156 /**
157 * @deprecated
158 * Set the active icon for this button. The pixmap itself is loaded
159 * internally based on the icon size... .. the disabled and default
160 * pixmaps, however will only be constructed if @ref #generate is
161 * true. This function is preferred over @ref setPixmap
162 *
163 * @param icon The name of the active icon
164 * @param generate If true, then the other icons are automagically
165 * generated from this one
166 */
167 void setIcon(const QString &icon, bool /*generate*/ ) { setIcon( icon ); }
168
169 /**
170 * @deprecated
171 * Force the button to use this icon as the default one rather
172 * then generating it using effects.
173 *
174 * @param icon The icon to use as the default (normal) one
175 */
176 void setDefaultIcon(const QString& icon);
177
178 /**
179 * @deprecated
180 * Force the button to use this icon when disabled one rather then
181 * generating it using effects.
182 *
183 * @param icon The icon to use when disabled
184 */
185 void setDisabledIcon(const QString& icon);
186#endif
187
188 /**
189 * Turn this button on or off
190 *
191 * @param flag true or false
192 */
193 void on(bool flag = true);
194
195 /**
196 * Toggle this button
197 */
198 void toggle();
199
200 /**
201 * Turn this button into a toggle button or disable the toggle
202 * aspects of it. This does not toggle the button itself.
203 * Use @ref toggle() for that.
204 *
205 * @param toggle true or false
206 */
207 void setToggle(bool toggle = true);
208
209 /**
210 * Return a pointer to this button's popup menu (if it exists)
211 */
212 QPopupMenu *popup();
213
214 /**
215 * Returns the button's id.
216 * @since 3.2
217 */
218 int id() const;
219
220 /**
221 * Give this button a popup menu. There will not be a delay when
222 * you press the button. Use @ref setDelayedPopup if you want that
223 * behavior.
224 *
225 * @param p The new popup menu
226 */
227 void setPopup (QPopupMenu *p, bool unused = false);
228
229 /**
230 * Gives this button a delayed popup menu.
231 *
232 * This function allows you to add a delayed popup menu to the button.
233 * The popup menu is then only displayed when the button is pressed and
234 * held down for about half a second.
235 *
236 * @param p the new popup menu
237 */
238 void setDelayedPopup(QPopupMenu *p, bool unused = false);
239
240 /**
241 * Turn this button into a radio button
242 *
243 * @param f true or false
244 */
245 void setRadio(bool f = true);
246
247 /**
248 * Toolbar buttons naturally will assume the global styles
249 * concerning icons, icons sizes, etc. You can use this function to
250 * explicitely turn this off, if you like.
251 *
252 * @param no_style Will disable styles if true
253 */
254 void setNoStyle(bool no_style = true);
255
256signals:
257 void clicked(int);
258 void doubleClicked(int);
259 void pressed(int);
260 void released(int);
261 void toggled(int);
262 void highlighted(int, bool);
263
264public slots:
265 /**
266 * This slot should be called whenever the toolbar mode has
267 * potentially changed. This includes such events as text changing,
268 * orientation changing, etc.
269 */
270 void modeChange();
271 virtual void setTextLabel(const QString&, bool tipToo);
272
273protected:
274 void paletteChange(const QPalette &);
275 void leaveEvent(QEvent *e);
276 void enterEvent(QEvent *e);
277 void drawButton(QPainter *p);
278 bool eventFilter (QObject *o, QEvent *e);
279 void showMenu();
280
281 /// @since 3.1
282 bool isRaised() const;
283 /// @since 3.1
284 bool isActive() const;
285 /// @since 3.1
286 int iconTextMode() const;
287
288protected slots:
289 void slotClicked();
290 void slotPressed();
291 void slotReleased();
292 void slotToggled();
293 void slotDelayTimeout();
294
295protected:
296 virtual void virtual_hook( int id, void* data );
297private:
298 KToolBarButtonPrivate *d;
299};
300
301/**
302* List of @ref KToolBarButton objects.
303* @internal
304* @version $Id$
305*/
306class KToolBarButtonList : public QIntDict<KToolBarButton>
307{
308public:
309 KToolBarButtonList();
310 ~KToolBarButtonList() {}
311};
312
313#endif