00001 /**************************************************************** 00002 * Vidalia is distributed under the following license: 00003 * 00004 * Copyright (C) 2006, Matt Edman, Justin Hipple 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 ****************************************************************/ 00021 00022 /** 00023 * \file vclicklabel.h 00024 * \version $Id: vclicklabel.h 1700 2007-04-09 01:51:15Z edmanm $ 00025 * \brief Custom widget to create a clickable label with both an image and text. 00026 */ 00027 00028 #ifndef _VCLICKLABEL_H 00029 #define _VCLICKLABEL_H 00030 00031 #include <QWidget> 00032 #include <QPixmap> 00033 #include <QMouseEvent> 00034 #include <QSize> 00035 00036 #include "animatedpixmap.h" 00037 00038 00039 class VClickLabel : public QWidget 00040 { 00041 Q_OBJECT 00042 00043 public: 00044 /** Default constructor. */ 00045 VClickLabel(QWidget *parent = 0); 00046 00047 /** Returns the current size hint for this widget's current contents. */ 00048 virtual QSize sizeHint() const; 00049 /** Returns the minimum size hint for this widget's current contents. */ 00050 virtual QSize minimumSizeHint() const; 00051 00052 /** Sets the label text to <b>text</b>. */ 00053 void setText(const QString &text); 00054 /** Sets the widget's image to <b>img</b>. */ 00055 void setPixmap(const QPixmap &img); 00056 /** Sets the widget's image to the animated image file <b>animFile</b>. */ 00057 void setAnimation(const QPixmap &animPixmap); 00058 00059 signals: 00060 /** Emitted when the widget is left-clicked. */ 00061 void clicked(); 00062 00063 protected: 00064 /** Overloaded paint event to draw a pixmap and a text label. */ 00065 virtual void paintEvent(QPaintEvent *e); 00066 /** Overloaded mouse event to catch left mouse button clicks. */ 00067 virtual void mouseReleaseEvent(QMouseEvent *e); 00068 00069 private slots: 00070 /** Responds to a frame change on the animation. */ 00071 void animationFrameChanged(int frameNumber); 00072 00073 private: 00074 QString _text; /**< Text label to display in the widget. */ 00075 QPixmap _pixmap; /**< Image to display in the widget. */ 00076 AnimatedPixmap _anim; /**< Animated pixmap to display. */ 00077 }; 00078 00079 #endif 00080