1 /* This file is part of the KDE libraries
2 Copyright (C) 1997 Mark Donohoe (donohoe@kde.org)
3 (C) 1997,1998, 2000 Sven Radej (radej@kde.org)
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.
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.
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 Steet, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 #include <kstatusbar.h>
27 KStatusBarLabel::KStatusBarLabel( const QString
& text
, int _id
,
28 KStatusBar
*parent
, const char *name
) :
35 // umm... Mosfet? Can you help here?
37 // Warning: QStatusBar draws shaded rectangle around every item - which
39 // So NoFrame|Plain is the best you get. the problem is that only in case of
40 // StyledPanel|Something you get QFrame to call QStyle::drawPanel().
43 setFrameStyle (QFrame::NoFrame
);
45 setAlignment( AlignHCenter
| AlignVCenter
| SingleLine
);
47 connect (this, SIGNAL(itemPressed(int)), parent
, SIGNAL(pressed(int)));
48 connect (this, SIGNAL(itemReleased(int)), parent
, SIGNAL(released(int)));
51 void KStatusBarLabel::mousePressEvent (QMouseEvent
*)
53 emit
itemPressed (id
);
56 void KStatusBarLabel::mouseReleaseEvent (QMouseEvent
*)
58 emit
itemReleased (id
);
61 KStatusBar::KStatusBar( QWidget
*parent
, const char *name
)
62 : QStatusBar( parent
, name
)
64 // make the size grip stuff configurable
65 // ...but off by default (sven)
66 KConfig
*config
= KGlobal::config();
67 QString
group(config
->group());
68 config
->setGroup(QString::fromLatin1("StatusBar style"));
69 bool grip_enabled
= config
->readBoolEntry(QString::fromLatin1("SizeGripEnabled"), false);
70 setSizeGripEnabled(grip_enabled
);
71 config
->setGroup(group
);
74 KStatusBar::~KStatusBar ()
78 void KStatusBar::insertItem( const QString
& text
, int id
, int stretch
, bool permanent
)
81 kdDebug() << "KStatusBar::insertItem: item id " << id
<< " already exists." << endl
;
83 KStatusBarLabel
*l
= new KStatusBarLabel (text
, id
, this);
84 l
->setFixedHeight(fontMetrics().height()+2);
86 addWidget (l
, stretch
, permanent
);
90 void KStatusBar::removeItem (int id
)
92 KStatusBarLabel
*l
= items
[id
];
100 kdDebug() << "KStatusBar::removeItem: bad item id: " << id
<< endl
;
103 bool KStatusBar::hasItem( int id
) const
105 KStatusBarLabel
*l
= items
[id
];
112 void KStatusBar::changeItem( const QString
& text
, int id
)
114 KStatusBarLabel
*l
= items
[id
];
118 if(l
->minimumWidth () != l
->maximumWidth ())
124 kdDebug() << "KStatusBar::changeItem: bad item id: " << id
<< endl
;
127 void KStatusBar::setItemAlignment (int id
, int align
)
129 KStatusBarLabel
*l
= items
[id
];
132 l
->setAlignment(align
);
135 kdDebug() << "KStatusBar::setItemAlignment: bad item id: " << id
<< endl
;
138 void KStatusBar::setItemFixed(int id
, int w
)
140 KStatusBarLabel
*l
= items
[id
];
144 w
=fontMetrics().boundingRect(l
->text()).width()+3;
149 kdDebug() << "KStatusBar::setItemFixed: bad item id: " << id
<< endl
;
152 #include "kstatusbar.moc"