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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
/* This file is part of the KDE libraries
Copyright (C) 1997 Mark Donohoe ([email protected])
(C) 1997,1998, 2000 Sven Radej ([email protected])
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <kdebug.h>
#include <kstatusbar.h>
#include <tdeconfig.h>
#include <tdeglobal.h>
KStatusBarLabel::KStatusBarLabel( const TQString& text, int _id,
KStatusBar *parent, const char *name) :
TQLabel( parent, name)
{
id = _id;
setText( text );
// umm... Mosfet? Can you help here?
// Warning: TQStatusBar draws shaded rectangle around every item - which
// IMHO is stupid.
// So NoFrame|Plain is the best you get. the problem is that only in case of
// StyledPanel|Something you get TQFrame to call TQStyle::drawPanel().
setLineWidth (0);
setFrameStyle (TQFrame::NoFrame);
setAlignment( AlignHCenter | AlignVCenter | SingleLine );
connect (this, TQ_SIGNAL(itemPressed(int)), parent, TQ_SIGNAL(pressed(int)));
connect (this, TQ_SIGNAL(itemReleased(int)), parent, TQ_SIGNAL(released(int)));
}
void KStatusBarLabel::mousePressEvent (TQMouseEvent *)
{
emit itemPressed (id);
}
void KStatusBarLabel::mouseReleaseEvent (TQMouseEvent *)
{
emit itemReleased (id);
}
KStatusBar::KStatusBar( TQWidget *parent, const char *name )
: TQStatusBar( parent, name )
{
// make the size grip stuff configurable
// ...but off by default (sven)
TDEConfig *config = TDEGlobal::config();
TQString group(config->group());
config->setGroup(TQString::fromLatin1("StatusBar style"));
bool grip_enabled = config->readBoolEntry(TQString::fromLatin1("SizeGripEnabled"), false);
setSizeGripEnabled(grip_enabled);
config->setGroup(group);
}
KStatusBar::~KStatusBar ()
{
}
void KStatusBar::insertItem( const TQString& text, int id, int stretch, bool permanent)
{
if (items[id])
kdDebug() << "KStatusBar::insertItem: item id " << id << " already exists." << endl;
KStatusBarLabel *l = new KStatusBarLabel (text, id, this);
l->setFixedHeight(fontMetrics().height()+2);
items.insert(id, l);
addWidget (l, stretch, permanent);
l->show();
}
void KStatusBar::removeItem (int id)
{
KStatusBarLabel *l = items[id];
if (l)
{
removeWidget (l);
items.remove(id);
delete l;
}
else
kdDebug() << "KStatusBar::removeItem: bad item id: " << id << endl;
}
bool KStatusBar::hasItem( int id ) const
{
KStatusBarLabel *l = items[id];
if (l)
return true;
else
return false;
}
void KStatusBar::changeItem( const TQString& text, int id )
{
KStatusBarLabel *l = items[id];
if (l)
{
l->setText(text);
if(l->minimumWidth () != l->maximumWidth ())
{
reformat();
}
}
else
kdDebug() << "KStatusBar::changeItem: bad item id: " << id << endl;
}
void KStatusBar::setItemAlignment (int id, int align)
{
KStatusBarLabel *l = items[id];
if (l)
{
l->setAlignment(align);
}
else
kdDebug() << "KStatusBar::setItemAlignment: bad item id: " << id << endl;
}
void KStatusBar::setItemFixed(int id, int w)
{
KStatusBarLabel *l = items[id];
if (l)
{
if (w==-1)
w=fontMetrics().boundingRect(l->text()).width()+3;
l->setFixedWidth(w);
}
else
kdDebug() << "KStatusBar::setItemFixed: bad item id: " << id << endl;
}
#include "kstatusbar.moc"
//Eh!!!
//Eh what ? :)
|