vclicklabel.h

Go to the documentation of this file.
00001 /*
00002 **  This file is part of Vidalia, and is subject to the license terms in the
00003 **  LICENSE file, found in the top level directory of this distribution. If you
00004 **  did not receive the LICENSE file with this file, you may obtain it from the
00005 **  Vidalia source package distributed by the Vidalia Project at
00006 **  http://www.vidalia-project.net/. No part of Vidalia, including this file,
00007 **  may be copied, modified, propagated, or distributed except according to the
00008 **  terms described in the LICENSE file.
00009 */
00010 
00011 /*
00012 ** \file vclicklabel.h
00013 ** \version $Id: vclicklabel.h 2362 2008-02-29 04:30:11Z edmanm $
00014 ** \brief Custom widget to create a clickable label with both an image and text.
00015 */
00016 
00017 #ifndef _VCLICKLABEL_H
00018 #define _VCLICKLABEL_H
00019 
00020 #include <QWidget>
00021 #include <QPixmap>
00022 #include <QMouseEvent>
00023 #include <QSize>
00024 
00025 #include "animatedpixmap.h"
00026 
00027 
00028 class VClickLabel : public QWidget
00029 {
00030   Q_OBJECT
00031 
00032 public:
00033   /** Default constructor. */
00034   VClickLabel(QWidget *parent = 0);
00035 
00036   /** Returns the current size hint for this widget's current contents. */
00037   virtual QSize sizeHint() const;
00038   /** Returns the minimum size hint for this widget's current contents. */
00039   virtual QSize minimumSizeHint() const;
00040   
00041   /** Sets the label text to <b>text</b>. */
00042   void setText(const QString &text);
00043   /** Sets the widget's image to <b>img</b>. */
00044   void setPixmap(const QPixmap &img);
00045   /** Sets the widget's image to the animated image file <b>animFile</b>. */
00046   void setAnimation(const QPixmap &animPixmap);
00047 
00048 signals:
00049   /** Emitted when the widget is left-clicked. */
00050   void clicked();
00051   
00052 protected:
00053   /** Overloaded paint event to draw a pixmap and a text label. */
00054   virtual void paintEvent(QPaintEvent *e);
00055   /** Overloaded mouse event to catch left mouse button clicks. */
00056   virtual void mouseReleaseEvent(QMouseEvent *e);
00057 
00058 private slots:
00059   /** Responds to a frame change on the animation. */
00060   void animationFrameChanged(int frameNumber);
00061 
00062 private:
00063   QString _text;    /**< Text label to display in the widget. */
00064   QPixmap _pixmap;  /**< Image to display in the widget. */
00065   AnimatedPixmap _anim; /**< Animated pixmap to display. */
00066 };
00067 
00068 #endif
00069 

Generated on Sat Aug 16 17:31:48 2008 for Vidalia by  doxygen 1.5.6