1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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 <tqlabel.h>
class TQRadioButton;
class LabelFocusWidget;
/**
* @short A TQLabel 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 TQLabel.
*
* @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 TQWidget constructor for details.
*/
explicit Label(TQWidget* 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 TQWidget constructor for details.
*/
Label(const TQString& text, TQWidget* 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 TQWidget constructor for details.
*/
Label(TQWidget* buddy, const TQString& text, TQWidget* 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(TQWidget* buddy);
protected:
virtual void drawContents(TQPainter* p) { TQLabel::drawContents(p); }
private slots:
void buddyDead();
private:
void activated();
TQRadioButton* 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(TQWidget* parent, const char* name = 0);
protected:
virtual void focusInEvent(TQFocusEvent*);
};
#endif // LABEL_H
|