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