kalarm/lib
label.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "kalarm.h"
00022 #include <tqradiobutton.h>
00023 #include "label.moc"
00024
00025
00026 Label::Label(TQWidget* parent, const char* name, WFlags f)
00027 : TQLabel(parent, name, f),
00028 mRadioButton(0),
00029 mFocusWidget(0)
00030 { }
00031
00032 Label::Label(const TQString& text, TQWidget* parent, const char* name, WFlags f)
00033 : TQLabel(text, parent, name, f),
00034 mRadioButton(0),
00035 mFocusWidget(0)
00036 { }
00037
00038 Label::Label(TQWidget* buddy, const TQString& text, TQWidget* parent, const char* name, WFlags f)
00039 : TQLabel(buddy, text, parent, name, f),
00040 mRadioButton(0),
00041 mFocusWidget(0)
00042 { }
00043
00044
00045
00046
00047
00048
00049
00050 void Label::setBuddy(TQWidget* bud)
00051 {
00052 if (mRadioButton)
00053 disconnect(mRadioButton, TQT_SIGNAL(destroyed()), this, TQT_SLOT(buddyDead()));
00054 TQWidget* w = bud;
00055 if (w)
00056 {
00057 while (w->focusProxy())
00058 w = TQT_TQWIDGET(w->focusProxy());
00059 if (!w->inherits(TQRADIOBUTTON_OBJECT_NAME_STRING))
00060 w = 0;
00061 }
00062 if (!w)
00063 {
00064
00065 TQLabel::setBuddy(bud);
00066 delete mFocusWidget;
00067 mFocusWidget = 0;
00068 mRadioButton = 0;
00069 }
00070 else
00071 {
00072
00073 if (!mFocusWidget)
00074 mFocusWidget = new LabelFocusWidget(this);
00075 TQLabel::setBuddy(mFocusWidget);
00076 mRadioButton = (TQRadioButton*)bud;
00077 connect(mRadioButton, TQT_SIGNAL(destroyed()), this, TQT_SLOT(buddyDead()));
00078 }
00079 }
00080
00081 void Label::buddyDead()
00082 {
00083 delete mFocusWidget;
00084 mFocusWidget = 0;
00085 mRadioButton = 0;
00086 }
00087
00088
00089
00090
00091
00092 void Label::activated()
00093 {
00094 if (mFocusWidget && mRadioButton)
00095 {
00096 mRadioButton->setFocus();
00097 mRadioButton->setChecked(true);
00098 }
00099 }
00100
00101
00102
00103
00104
00105
00106 LabelFocusWidget::LabelFocusWidget(TQWidget* parent, const char* name)
00107 : TQWidget(parent, name)
00108 {
00109 setFocusPolicy(TQ_ClickFocus);
00110 setFixedSize(TQSize(1,1));
00111 }
00112
00113 void LabelFocusWidget::focusInEvent(TQFocusEvent*)
00114 {
00115 Label* parent = (Label*)parentWidget();
00116 parent->activated();
00117
00118 }
|