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

kdeui

  • kdeui
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 <kconfig.h>
24 #include <kglobal.h>
25 
26 
27 KStatusBarLabel::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, TQT_SIGNAL(itemPressed(int)), parent, TQT_SIGNAL(pressed(int)));
48  connect (this, TQT_SIGNAL(itemReleased(int)), parent, TQT_SIGNAL(released(int)));
49 }
50 
51 void KStatusBarLabel::mousePressEvent (TQMouseEvent *)
52 {
53  emit itemPressed (id);
54 }
55 
56 void KStatusBarLabel::mouseReleaseEvent (TQMouseEvent *)
57 {
58  emit itemReleased (id);
59 }
60 
61 KStatusBar::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  KConfig *config = KGlobal::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 
74 KStatusBar::~KStatusBar ()
75 {
76 }
77 
78 void 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 
90 void 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 
103 bool KStatusBar::hasItem( int id ) const
104 {
105  KStatusBarLabel *l = items[id];
106  if (l)
107  return true;
108  else
109  return false;
110 }
111 
112 void 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 
127 void 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 
138 void 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 

kdeui

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

kdeui

Skip menu "kdeui"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdeui by doxygen 1.8.1.2
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |