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,69 +1,72 @@ | |||
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 | * |
@@ -121,150 +124,150 @@ public: | |||
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(); |
@@ -274,40 +277,40 @@ 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 |