diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch) | |
tree | 67208f7c145782a7e90b123b982ca78d88cc2c87 /kalarm/lib/label.h | |
download | tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kalarm/lib/label.h')
-rw-r--r-- | kalarm/lib/label.h | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/kalarm/lib/label.h b/kalarm/lib/label.h new file mode 100644 index 000000000..c65a7fcd6 --- /dev/null +++ b/kalarm/lib/label.h @@ -0,0 +1,96 @@ +/* + * label.h - label with radiobutton buddy option + * Program: kalarm + * Copyright © 2004-2006 by David Jarvie <software@astrojar.org.uk> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef LABEL_H +#define LABEL_H + +#include <qlabel.h> +class QRadioButton; +class LabelFocusWidget; + +/** + * @short A QLabel with option for a buddy radio button. + * + * The Label class provides a text display, with special behaviour when a radio + * button is set as a buddy. + * + * The Label object in effect acts as if it were part of the buddy radio button, + * in that when the label's accelerator key is pressed, the radio button receives + * focus and is switched on. When a non-radio button is specified as a buddy, the + * behaviour is the same as for QLabel. + * + * @author David Jarvie <software@astrojar.org.uk> + */ +class Label : public QLabel +{ + Q_OBJECT + friend class LabelFocusWidget; + public: + /** Constructs an empty label. + * @param parent The parent object of this widget. + * @param name The name of this widget. + * @param f Flags. See QWidget constructor for details. + */ + explicit Label(QWidget* parent, const char* name = 0, WFlags f = 0); + /** Constructs a label that displays @p text. + * @param text Text string to display. + * @param parent The parent object of this widget. + * @param name The name of this widget. + * @param f Flags. See QWidget constructor for details. + */ + Label(const QString& text, QWidget* parent, const char* name = 0, WFlags f = 0); + /** Constructs a label, with a buddy widget, that displays @p text. + * @param buddy Buddy widget which receives the keyboard focus when the + * label's accelerator key is pressed. If @p buddy is a radio + * button, @p buddy is in addition selected when the + * accelerator key is pressed. + * @param text Text string to display. + * @param parent The parent object of this widget. + * @param name The name of this widget. + * @param f Flags. See QWidget constructor for details. + */ + Label(QWidget* buddy, const QString& text, QWidget* parent, const char* name = 0, WFlags f = 0); + /** Sets the label's buddy widget which receives the keyboard focus when the + * label's accelerator key is pressed. If @p buddy is a radio button, + * @p buddy is in addition selected when the accelerator key is pressed. + */ + virtual void setBuddy(QWidget* buddy); + protected: + virtual void drawContents(QPainter* p) { QLabel::drawContents(p); } + private slots: + void buddyDead(); + private: + void activated(); + QRadioButton* mRadioButton; // buddy widget if it's a radio button, else 0 + LabelFocusWidget* mFocusWidget; +}; + + +// Private class for use by Label +class LabelFocusWidget : public QWidget +{ + Q_OBJECT + public: + LabelFocusWidget(QWidget* parent, const char* name = 0); + protected: + virtual void focusInEvent(QFocusEvent*); +}; + +#endif // LABEL_H |