home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kstatusbar.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-10-08  |  5.6 KB  |  209 lines

  1. /* This file is part of the KDE libraries
  2.    Copyright (C) 1997 Mark Donohoe (donohoe@kde.org)
  3.    Copyright (C) 1997, 1998 1998 Sven Radej (sven@lisa.exp.univie.ac.at)
  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. #ifndef __KSTATUSBAR_H__
  22. #define __KSTATUSBAR_H__
  23.  
  24. #include <qstatusbar.h>
  25. #include <qintdict.h>
  26. #include <qlabel.h>
  27. #include <kdelibs_export.h>
  28.  
  29. class KStatusBar;
  30.  
  31. /**
  32.  *  Internal label class for use in KStatusBar
  33.  *  @internal
  34.  */
  35. class KDEUI_EXPORT KStatusBarLabel : public QLabel
  36. {
  37.   Q_OBJECT
  38.  
  39. public:
  40.  
  41.  
  42.   KStatusBarLabel( const QString& text, int _id, KStatusBar* parent = 0L, const char *name=0L );
  43.   ~KStatusBarLabel () {}
  44.  
  45. protected:
  46.  
  47.   void mousePressEvent (QMouseEvent* _event);
  48.   void mouseReleaseEvent (QMouseEvent* _event);
  49.  
  50. private:
  51.  
  52.   int id;
  53.  
  54. signals:
  55.  
  56.   void itemPressed (int id);
  57.   void itemReleased (int id);
  58. };
  59.  
  60. /**
  61.  *  @short %KDE statusbar widget
  62.  *
  63.  *  Display status messages.
  64.  *
  65.  *  You can insert text labels or custom widgets. Their geometry is managed
  66.  *  internally. KStatusBar resizes itself, but positioning is left to
  67.  *  KMainWindow (or to you, if you don't use KMainWindow ).
  68.  *
  69.  *  A special type of item is a message which is a temporary text-message
  70.  *  displayed on top of other items in full-width. Messages are visible for
  71.  *  specified time, or until you call the slot QStatusBar::clear(). See
  72.  *  QStatusBar::message for details.
  73.  *
  74.  *  It is useful to connect the KActionCollection signals to the
  75.  *  QStatusBar::message slots.
  76.  *
  77.  *  KStatusBar inherits QStatusBar, you can freely use all QStatusBar
  78.  *  methods.
  79.  *
  80.  *  Empty text items are not visible. They will become visible when you change
  81.  *  (add) text.
  82.  *
  83.  *  @author Mark Donohoe (donohoe@kde.org) Maintained by Sven Radej <radej@kde.org>
  84.  
  85.  *  @see KActionCollection
  86.  */
  87. class KDEUI_EXPORT KStatusBar : public QStatusBar
  88. {
  89.   Q_OBJECT
  90.  
  91. public:
  92.   /**
  93.    * @deprecated
  94.    * WARNING: This enum is only for backward compatibility and it may be removed.
  95.    * No method here uses it.
  96.    */
  97.   enum BarStatus{ Toggle, Show, Hide };
  98.  
  99.   /**
  100.    *  Constructs a status bar. @p parent is usually KMainWindow.
  101.    */
  102.   KStatusBar( QWidget* parent = 0L, const char* name = 0L );
  103.  
  104.   /**
  105.    *  Destructor.
  106.    *
  107.    *  Deletes all internal objects.
  108.    */
  109.   ~KStatusBar();
  110.  
  111.   /**
  112.    *  Inserts a text label into the status bar.
  113.    *  Parameters @p stretch and  @p permanent are passed to
  114.    * QStatusBar::addWidget .
  115.    *
  116.    *  If @p permanent is true, then item will be placed on the far right of
  117.    *  the statusbar and will never be hidden by QStatusBar::message.
  118.    *
  119.    *  @param text The label's text string.
  120.    *  @param id id of item
  121.    *  @param stretch stretch passed to QStatusBar::addWidget
  122.    *  @param permanent is item permanent or not (passed to QStatusBar::addWidget )
  123.    *
  124.    *  @see QStatusbar::addWidget
  125.    *
  126.    */
  127.   void insertItem(const QString& text, int id, int stretch=0, bool permanent=false );
  128.  
  129.   /**
  130.    *  Inserts a fixed width text label into status bar. The width will be set
  131.    *  according to @p text, but will remain fixed even if you change text.
  132.    *  You can change fixed width by calling setItemFixed.
  133.    *
  134.    *  @param text The label's text string
  135.    *  @param id id of item
  136.    *  @param permanent permanent flag passed to QStatusBar::addWidget
  137.    */
  138.   inline void insertFixedItem(const QString& text, int id, bool permanent=false)
  139.                { insertItem(text, id, 0, permanent); setItemFixed(id); }
  140.  
  141.   /**
  142.    *  Removes an item.
  143.    *
  144.    * @param id The item to remove.
  145.    */
  146.   void removeItem( int id );
  147.  
  148.   /**
  149.    *  @since 3.2
  150.    *
  151.    *  Returns true if an item with @p id exists already in KStatusBar,
  152.    *  otherwise returns false.
  153.    *
  154.    *  @param id id of the item
  155.    */
  156.   bool hasItem( int id ) const;
  157.  
  158.   /**
  159.    * Changes the text in a status bar field.
  160.    *
  161.    * The item will be resized to fit the text. If you change text to be empty,
  162.    * item will not be visible (untill you add some text).
  163.    *
  164.    * @param text The label's text string
  165.    * @param id The id of item.
  166.    */
  167.   void changeItem( const QString& text, int id );
  168.  
  169.   /**
  170.    * Sets the alignment of item @p id. By default all fields are aligned
  171.    * @p AlignHCenter | @p AlignVCenter. See QLabel::setAlignment for details.
  172.    *
  173.   */
  174.   void setItemAlignment(int id, int align);
  175.  
  176.   /**
  177.    * Sets item @p id to have fixed width. This cannot be undone, but you can
  178.    * always set new fixed width.
  179.    *
  180.    * @param id id of item
  181.    * @param width fixed width in pixels. Default -1 is to adapt to text width.
  182.    */
  183.   void setItemFixed(int id, int width=-1);
  184.  
  185. signals:
  186.  
  187.   /**
  188.    *  Emitted when mouse is pressed over item @p id.
  189.    *
  190.    *  Connect to this signal if you want to respond to mouse press events.
  191.    *
  192.    */
  193.   void pressed( int );
  194.  
  195.   /**
  196.    *  Emitted when mouse is released over item @p id.
  197.    *
  198.    *  Connect to this signal if you want to respond to mouse release events (clicks).
  199.    */
  200.   void released( int );
  201.  
  202. private:
  203.   QIntDict<KStatusBarLabel> items;
  204.   class KStatusBarPrivate* d;
  205. };
  206.  
  207. #endif // __KSTATUSBAR_H__
  208.  
  209.