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 / kanimwidget.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  3.9 KB  |  145 lines

  1. /* This file is part of the KDE libraries
  2.    Copyright (C) 2000 Kurt Granroth <granroth@kde.org>
  3.  
  4.    This library is free software; you can redistribute it and/or
  5.    modify it under the terms of the GNU Library General Public
  6.    License version 2 as published by the Free Software Foundation.
  7.  
  8.    This library is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11.    Library General Public License for more details.
  12.  
  13.    You should have received a copy of the GNU Library General Public License
  14.    along with this library; see the file COPYING.LIB.  If not, write to
  15.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16.    Boston, MA 02110-1301, USA.
  17. */
  18. #ifndef _KANIMWIDGET_H
  19. #define _KANIMWIDGET_H
  20.  
  21. #include <qframe.h>
  22.  
  23. #include <kdelibs_export.h>
  24.  
  25. class QStringList;
  26. class QPainter;
  27. class QMouseEvent;
  28.  
  29. class KAnimWidgetPrivate;
  30. /**
  31.  * @short Standard "About KDE" dialog box
  32.  *
  33.  * This is a widget used to display animation using multiple
  34.  * individual pixmaps.  This widget allows you to deal with variable
  35.  * size icons (e.g., ones that will change based on a global setting)
  36.  * as it loads the icons internally.  All you need to do is pass along
  37.  * a list of icon names and their size and everything else is taken
  38.  * care of.
  39.  *
  40.  * This widget also emits a 'clicked()' signal when it received a
  41.  * mouse press event.
  42.  *
  43.  * A quick example:
  44.  * \code
  45.  * KAnimWidget *anim = new KAnimWidget("kde", 0, this);
  46.  * anim->start();
  47.  * \endcode
  48.  *
  49.  * That example will search for the pixmaps "one.png", "two.png", and
  50.  * "three.png" in the share/icons/small/ directories as well as the
  51.  * app's pics directory.
  52.  *
  53.  * @author Kurt Granroth <granroth@kde.org>
  54.  */
  55. class KDEUI_EXPORT KAnimWidget : public QFrame
  56. {
  57.   Q_OBJECT
  58.   Q_PROPERTY( int size READ size WRITE setSize )
  59.   Q_PROPERTY( QString icons READ icons WRITE setIcons )
  60.  
  61. public:
  62.   /**
  63.    * This is the most common constructor.  Pass along the name of the
  64.    * animated icons to use (e.g., "kde") for the animation and an
  65.    * optional size to load and you're set.  If you omit the size, the
  66.    * default size will be used.
  67.    *
  68.    * @param icons  The icons name (e.g., "kde") to use for the animation
  69.    * @param size   The size to load
  70.    *               You don't have to set it if the parent is a
  71.    *               KToolBar; in this case it will use the toolbar's
  72.    *               size.
  73.    * @param parent The standard parent
  74.    * @param name   The standard internal name
  75.    */
  76.   KAnimWidget( const QString& icons, int size = 0,
  77.                QWidget *parent = 0L, const char *name = 0L );
  78.  
  79.   /**
  80.    * Destructor
  81.    */
  82.   virtual ~KAnimWidget();
  83.  
  84.   /**
  85.    * Sets the size of the icons.
  86.    *
  87.    * @param size The size of the icons
  88.    */
  89.   void setSize( int size );
  90.  
  91.   /**
  92.   * Returns the current size.
  93.   * @since 3.4
  94.   */
  95.   int size() const;
  96.  
  97.   /**
  98.   * Returns the current icons
  99.   * since 3.4
  100.   */
  101.   QString icons() const;
  102.  
  103.   /**
  104.    * Sets the name of the animated icons to load.  This will use the
  105.    * KIconLoader::loadAnimated method for the actual loading.
  106.    *
  107.    * @param icons The name of the icons to use for the animation
  108.    */
  109.   void setIcons( const QString& icons );
  110.  
  111. public slots:
  112.   /**
  113.    * Starts the animation from frame 1
  114.    */
  115.   void start();
  116.  
  117.   /**
  118.    * Stops the animation.  This will also reset the widget to frame 1.
  119.    */
  120.   void stop();
  121.  
  122. signals:
  123.   void clicked();
  124.  
  125. protected:
  126.   virtual void drawContents( QPainter *p );
  127.   virtual void leaveEvent( QEvent *e );
  128.   virtual void enterEvent( QEvent *e );
  129.   virtual void hideEvent( QHideEvent *e);
  130.   virtual void showEvent( QShowEvent *e);
  131.   virtual void mousePressEvent( QMouseEvent *e );
  132.   virtual void mouseReleaseEvent( QMouseEvent *e );
  133.  
  134. protected slots:
  135.   void slotTimerUpdate();
  136.   void updateIcons();
  137.  
  138. protected:
  139.   virtual void virtual_hook( int id, void* data );
  140. private:
  141.   KAnimWidgetPrivate *d;
  142. };
  143.  
  144. #endif // _KANIMWIDGET_H
  145.