summaryrefslogtreecommitdiff
path: root/libopie/oclickablelabel.cpp
authormickeyl <mickeyl>2004-11-16 19:14:18 (UTC)
committer mickeyl <mickeyl>2004-11-16 19:14:18 (UTC)
commitea3945a9bd8f9830f70b1efa133f9df13b19362f (patch) (unidiff)
treef2ea22cc50e9aa8aa73ee7dea148f41c563c9666 /libopie/oclickablelabel.cpp
parent1c6f490e8541626f68422e0a3a7c7281d7f5b7d3 (diff)
downloadopie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.zip
opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.tar.gz
opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.tar.bz2
libopie1 goes into unsupported
Diffstat (limited to 'libopie/oclickablelabel.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/oclickablelabel.cpp117
1 files changed, 0 insertions, 117 deletions
diff --git a/libopie/oclickablelabel.cpp b/libopie/oclickablelabel.cpp
deleted file mode 100644
index bc7037b..0000000
--- a/libopie/oclickablelabel.cpp
+++ b/dev/null
@@ -1,117 +0,0 @@
1#include "oclickablelabel.h"
2#include <stdio.h>
3
4/**
5 * This constructs the clickable ButtonLabel
6 *
7 * @param parent The parent of this label
8 * @param name A name of this label @see QObject
9 * @param fl The windowing flags
10 */
11OClickableLabel::OClickableLabel(QWidget* parent,
12 const char* name,
13 WFlags fl) :
14 QLabel(parent,name,fl)
15{
16 textInverted=false;
17 isToggle=false;
18 isDown=false;
19 showState(false);
20 setFrameShadow(Sunken);
21}
22
23/**
24 * This method makes the label behave as a toggle button
25 *
26 * @param t Whether or not to behave like a toggle button
27 */
28void OClickableLabel::setToggleButton(bool t) {
29 isToggle=t;
30}
31
32/**
33 * @internal
34 */
35void OClickableLabel::mousePressEvent( QMouseEvent * /*e*/ ) {
36 if (isToggle && isDown) {
37 showState(false);
38 } else {
39 showState(true);
40 }
41}
42
43/**
44 * @internal
45 */
46void OClickableLabel::mouseReleaseEvent( QMouseEvent *e ) {
47 if (rect().contains(e->pos()) && isToggle) isDown=!isDown;
48
49 if (isToggle && isDown) {
50 showState(true);
51 } else {
52 showState(false);
53 }
54
55 if (rect().contains(e->pos())) {
56 if (isToggle) {
57 emit toggled(isDown);
58 }
59 emit clicked();
60 }
61}
62
63/**
64 * @internal
65 */
66void OClickableLabel::mouseMoveEvent( QMouseEvent *e ) {
67 if (rect().contains(e->pos())) {
68 if (isToggle && isDown) {
69 showState(false);
70 } else {
71 showState(true);
72 }
73 } else {
74 if (isToggle && isDown) {
75 showState(true);
76 } else {
77 showState(false);
78 }
79 }
80}
81
82/**
83 * this toggles the label and inverts the color of
84 * the label
85 * @param on
86 */
87void OClickableLabel::showState(bool on) {
88 if (on) {
89 //setFrameShape(Panel);
90 setInverted(true);
91 setBackgroundMode(PaletteHighlight);
92 } else {
93 //setFrameShape(NoFrame);
94 setInverted(false);
95 setBackgroundMode(PaletteBackground);
96 }
97 repaint();
98}
99
100void OClickableLabel::setInverted(bool on) {
101 if ( (!textInverted && on) || (textInverted && !on) ) {
102 QPalette pal=palette();
103 QColor col=pal.color(QPalette::Normal, QColorGroup::Foreground);
104 col.setRgb(255-col.red(),255-col.green(),255-col.blue());
105 pal.setColor(QPalette::Normal, QColorGroup::Foreground, col);
106 setPalette(pal);
107 textInverted=!textInverted;
108 }
109}
110
111/**
112 * @param on if the Label is down or up
113 */
114void OClickableLabel::setOn(bool on) {
115 isDown=on;
116 showState(isDown);
117}