lib

koFrameButton.cpp
1/* This file is part of the KDE project
2 Copyright (c) 1999 Matthias Elter (me@kde.org)
3 Copyright (c) 2001 Igor Jansen (rm@kde.org)
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#include "koFrameButton.h"
22
23KoFrameButton::KoFrameButton(TQWidget *parent, const char *name):
24TQLabel(parent, name)
25{
26 setAutoResize(true);
27 setFrameStyle(Panel | Raised);
28 setLineWidth(1);
29 setMaximumHeight(8);
30 mActive = false;
31 mToggle = false;
32}
33
34KoFrameButton::KoFrameButton(const TQString &text, TQWidget *parent, const char *name):
35TQLabel(parent, name)
36{
37 setFrameStyle(Panel | Raised);
38 setLineWidth(1);
39 setText(text);
40 setAlignment(AlignHCenter | AlignVCenter);
41 mActive = false;
42 mToggle = false;
43}
44
45KoFrameButton::KoFrameButton(const TQPixmap &pixmap, TQWidget *parent, const char *name):
46TQLabel(parent, name)
47{
48 setFrameStyle(Panel | Raised);
49 setLineWidth(1);
50 setPixmap(pixmap);
51 mActive = false;
52 mToggle = false;
53}
54
55void KoFrameButton::mousePressEvent(TQMouseEvent *)
56{
57 setFrameStyle(Panel | Sunken);
58}
59
60void KoFrameButton::mouseReleaseEvent(TQMouseEvent *)
61{
62 if(mToggle)
63 {
64 mActive = !mActive;
65 if(mActive)
66 setFrameStyle(Panel | Sunken);
67 else
68 setFrameStyle(Panel | Raised);
69 }
70 else
71 setFrameStyle(Panel | Raised);
72
73 emit clicked();
74 emit clicked(mText);
75}
76
77void KoFrameButton::setOn(bool v)
78{
79 if(!mToggle)
80 return;
81
82 mActive = v;
83
84 if(mActive)
85 setFrameStyle(Panel | Sunken);
86 else
87 setFrameStyle(Panel | Raised);
88}
89
90
91void KoFrameButton::setToggleButton(bool v)
92{
93 mToggle = v;
94}
95
96void KoFrameButton::setText(const TQString &t)
97{
98 mText = t;
99 TQLabel::setText(t);
100}
101
102#include "koFrameButton.moc"
const char * name(StdAction id)