• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeui
 

tdeui

  • tdeui
kstatusbar.cpp
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)
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 <kdebug.h>
22#include <kstatusbar.h>
23#include <tdeconfig.h>
24#include <tdeglobal.h>
25
26
27KStatusBarLabel::KStatusBarLabel( const TQString& text, int _id,
28 KStatusBar *parent, const char *name) :
29 TQLabel( parent, name)
30{
31 id = _id;
32
33 setText( text );
34
35 // umm... Mosfet? Can you help here?
36
37 // Warning: TQStatusBar draws shaded rectangle around every item - which
38 // IMHO is stupid.
39 // So NoFrame|Plain is the best you get. the problem is that only in case of
40 // StyledPanel|Something you get TQFrame to call TQStyle::drawPanel().
41
42 setLineWidth (0);
43 setFrameStyle (TQFrame::NoFrame);
44
45 setAlignment( AlignHCenter | AlignVCenter | SingleLine );
46
47 connect (this, TQ_SIGNAL(itemPressed(int)), parent, TQ_SIGNAL(pressed(int)));
48 connect (this, TQ_SIGNAL(itemReleased(int)), parent, TQ_SIGNAL(released(int)));
49}
50
51void KStatusBarLabel::mousePressEvent (TQMouseEvent *)
52{
53 emit itemPressed (id);
54}
55
56void KStatusBarLabel::mouseReleaseEvent (TQMouseEvent *)
57{
58 emit itemReleased (id);
59}
60
61KStatusBar::KStatusBar( TQWidget *parent, const char *name )
62 : TQStatusBar( parent, name )
63{
64 // make the size grip stuff configurable
65 // ...but off by default (sven)
66 TDEConfig *config = TDEGlobal::config();
67 TQString group(config->group());
68 config->setGroup(TQString::fromLatin1("StatusBar style"));
69 bool grip_enabled = config->readBoolEntry(TQString::fromLatin1("SizeGripEnabled"), false);
70 setSizeGripEnabled(grip_enabled);
71 config->setGroup(group);
72}
73
74KStatusBar::~KStatusBar ()
75{
76}
77
78void KStatusBar::insertItem( const TQString& text, int id, int stretch, bool permanent)
79{
80 if (items[id])
81 kdDebug() << "KStatusBar::insertItem: item id " << id << " already exists." << endl;
82
83 KStatusBarLabel *l = new KStatusBarLabel (text, id, this);
84 l->setFixedHeight(fontMetrics().height()+2);
85 items.insert(id, l);
86 addWidget (l, stretch, permanent);
87 l->show();
88}
89
90void KStatusBar::removeItem (int id)
91{
92 KStatusBarLabel *l = items[id];
93 if (l)
94 {
95 removeWidget (l);
96 items.remove(id);
97 delete l;
98 }
99 else
100 kdDebug() << "KStatusBar::removeItem: bad item id: " << id << endl;
101}
102
103bool KStatusBar::hasItem( int id ) const
104{
105 KStatusBarLabel *l = items[id];
106 if (l)
107 return true;
108 else
109 return false;
110}
111
112void KStatusBar::changeItem( const TQString& text, int id )
113{
114 KStatusBarLabel *l = items[id];
115 if (l)
116 {
117 l->setText(text);
118 if(l->minimumWidth () != l->maximumWidth ())
119 {
120 reformat();
121 }
122 }
123 else
124 kdDebug() << "KStatusBar::changeItem: bad item id: " << id << endl;
125}
126
127void KStatusBar::setItemAlignment (int id, int align)
128{
129 KStatusBarLabel *l = items[id];
130 if (l)
131 {
132 l->setAlignment(align);
133 }
134 else
135 kdDebug() << "KStatusBar::setItemAlignment: bad item id: " << id << endl;
136}
137
138void KStatusBar::setItemFixed(int id, int w)
139{
140 KStatusBarLabel *l = items[id];
141 if (l)
142 {
143 if (w==-1)
144 w=fontMetrics().boundingRect(l->text()).width()+3;
145
146 l->setFixedWidth(w);
147 }
148 else
149 kdDebug() << "KStatusBar::setItemFixed: bad item id: " << id << endl;
150}
151
152#include "kstatusbar.moc"
153
154//Eh!!!
155//Eh what ? :)
156
KStatusBarLabel
Internal label class for use in KStatusBar.
Definition: kstatusbar.h:36
KStatusBar
KDE statusbar widget
Definition: kstatusbar.h:88
KStatusBar::removeItem
void removeItem(int id)
Removes an item.
Definition: kstatusbar.cpp:90
KStatusBar::hasItem
bool hasItem(int id) const
Definition: kstatusbar.cpp:103
KStatusBar::~KStatusBar
~KStatusBar()
Destructor.
Definition: kstatusbar.cpp:74
KStatusBar::KStatusBar
KStatusBar(TQWidget *parent=0L, const char *name=0L)
Constructs a status bar.
Definition: kstatusbar.cpp:61
KStatusBar::changeItem
void changeItem(const TQString &text, int id)
Changes the text in a status bar field.
Definition: kstatusbar.cpp:112
KStatusBar::setItemAlignment
void setItemAlignment(int id, int align)
Sets the alignment of item id.
Definition: kstatusbar.cpp:127
KStatusBar::setItemFixed
void setItemFixed(int id, int width=-1)
Sets item id to have fixed width.
Definition: kstatusbar.cpp:138
KStatusBar::insertItem
void insertItem(const TQString &text, int id, int stretch=0, bool permanent=false)
Inserts a text label into the status bar.
Definition: kstatusbar.cpp:78
TDEConfigBase::readBoolEntry
bool readBoolEntry(const TQString &pKey, bool bDefault=false) const
TDEConfigBase::group
TQString group() const
TDEConfigBase::setGroup
void setGroup(const TQString &group)
TDEConfig
TDEGlobal::config
static TDEConfig * config()
endl
kndbgstream & endl(kndbgstream &s)
kdDebug
kdbgstream kdDebug(int area=0)
TDEStdAccel::name
TQString name(StdAccel id)

tdeui

Skip menu "tdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdeui

Skip menu "tdeui"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeui by doxygen 1.9.4
This website is maintained by Timothy Pearson.