Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

ALabel.h

Go to the documentation of this file.
00001 //==============================================
00002 //  copyright            : (C) 2003-2005 by Will Stokes
00003 //==============================================
00004 //  This program is free software; you can redistribute it
00005 //  and/or modify it under the terms of the GNU General
00006 //  Public License as published by the Free Software
00007 //  Foundation; either version 2 of the License, or
00008 //  (at your option) any later version.
00009 //==============================================
00010 
00011 #ifndef GUI_ALABEL_H
00012 #define GUI_ALABEL_H
00013 
00014 #define APPEAR_IMMEDIATELY 1
00015 #define DISAPPEAR_IMMEDIATELY 2
00016 #define SLIDE_IN_LEFT 3
00017 #define SLIDE_OUT_LEFT 4
00018 #define SLIDE_IN_RIGHT 5
00019 #define SLIDE_OUT_RIGHT 6
00020 #define FADE_TRANSITION 7
00021 
00022 //--------------------
00023 //forward declarations
00024 class QTimer;
00025 class QPixmap;
00026 class QPainter;
00027 class QImage;
00028 class Action;
00029 //--------------------
00030 
00031 #include <qlabel.h>
00032 #include <qpixmap.h>
00033 #include <qdatetime.h>
00034 #include <qmutex.h>
00035 
00036 //=====================================
00037 class ALabel : public QLabel
00038 {
00039 Q_OBJECT
00040 //----------------------
00041 public:
00043   ALabel( QWidget *parent=0, const char* name=0,
00044           QPixmap* hoverOverImage = NULL,
00045           int setMethod = APPEAR_IMMEDIATELY,
00046           int removalMethod = DISAPPEAR_IMMEDIATELY,
00047           int resetMethod = APPEAR_IMMEDIATELY,
00048           int removalBeforeResetMethod = DISAPPEAR_IMMEDIATELY,
00049           int initDelay = 130, int accel = 50);
00050 
00052    void setAnimationMethods(int setMethod = APPEAR_IMMEDIATELY,
00053                                               int removalMethod = DISAPPEAR_IMMEDIATELY,
00054                                               int resetMethod = APPEAR_IMMEDIATELY,
00055                                               int removalBeforeResetMethod = DISAPPEAR_IMMEDIATELY);
00056 
00058   void setPixmap ( const QPixmap &p );
00059 
00061   void removePixmap( bool forceImmediate = false);
00062 protected:
00064   void animatePixmap( );
00065 
00066   void drawContents( QPainter* p);
00067 
00068   void enterEvent( QEvent* e);
00069   void leaveEvent( QEvent* e);
00070 
00071   void mousePressEvent( QMouseEvent* );
00072   void mouseReleaseEvent( QMouseEvent* );
00073   void mouseDoubleClickEvent( QMouseEvent* );
00074   void mouseMoveEvent( QMouseEvent* );
00075 //----------------------
00076 signals:
00077   void dropEventOccured( QDropEvent* e);
00078 
00080   void mousePress();
00081   void mouseRelease();
00082   void mouseDoubleClick();
00083 
00084   void pixmapRemoved();
00085   //----------------------
00086 private slots:
00087   void animate();
00088 //----------------------
00089 private:
00090   void internalRemovePixmap( bool forceImmediate = false );
00091   void internalSetPixmap ( const QPixmap &p );
00092   void appendJob(QPixmap* pix);
00093   void cleanStack();
00094 
00095   //actual and reset images
00096   QImage *pixStore, *resetPixStore;
00097 
00098   //method for removing old images when doing a set
00099   int setMethod;
00100   int removalMethod;
00101   int removalBeforeResetMethod;
00102   int resetMethod;
00103 
00104   //specs for ongoing animation
00105   int initDelay, accel, minDelay, delay, animationType;
00106   int step;
00107 
00108   //timer and time variables for ongoing animation
00109   QTimer* timer;
00110   QTime lastTime, currentTime;
00111 
00112   //should hover-over image be drawn on repaint?
00113   bool drawHoverOverImage;
00114   QRect hoverOverRect;
00115 
00116   //hover-overimage
00117   QPixmap* hoverOverImage;
00118 
00119   //is picture fully shown?
00120   bool imageShown;
00121 
00122   //is hand cursor shown?
00123   bool handCursorShown;
00124 
00125   //are we animating?
00126   bool animating;
00127   QMutex animatingBoolMutex;
00128 
00129   //are we preforming a reset action?
00130   bool resettingImage;
00131 
00132   //queue of actions
00133   Action* delayedActionHead;
00134   Action* delayedActionTail;
00135   QMutex queueMutex;
00136 //----------------------
00137 };
00138 //======================
00139 
00140 
00141 //======================
00142 class Action
00143 {
00144   public:
00145     Action(QPixmap* image);
00146     ~Action();
00147     Action* getNext();
00148     void setNext( Action* next);
00149     QPixmap* getImage();
00150 
00151   private:
00152     QPixmap* image;
00153     Action* next;
00154 };
00155 //======================
00156 
00157 
00158 #endif //GUI_ALABEL_H

Generated on Mon Apr 11 18:27:45 2005 for AlbumShaper by  doxygen 1.3.9.1