Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

skin.h

Go to the documentation of this file.
00001 /*
00002    Copyright (C) 2002 Simon Hausmann <simon@lst.de>
00003              (C) 2002 Max Reiss <harlekin@handhelds.org>
00004              (C) 2002 L. Potter <ljp@llornkcor.com>
00005              (C) 2002 Holger Freyther <zecke@handhelds.org>
00006 
00007    This program is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program; see the file COPYING.  If not, write to
00019    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00020    Boston, MA 02111-1307, USA.
00021 */
00022 
00023 #ifndef SKIN_H
00024 #define SKIN_H
00025 
00026 #include <qstring.h>
00027 #include <qimage.h>
00028 #include <qobject.h>
00029 
00030 #include "mediawidget.h"
00031 
00032 struct SkinData;
00033 
00034 class Skin
00035 {
00036 public:
00037     Skin( const QString &name, const QString &fileNameInfix );
00038     Skin( const QString &fileNameInfix );
00039     ~Skin();
00040 
00041     bool isCachable() const { return m_isCachable; }
00042     void setCachable( bool cachable ) { m_isCachable = cachable; }
00043 
00044     QPixmap backgroundPixmap() const;
00045     QImage buttonUpImage() const;
00046     QImage buttonDownImage() const;
00047 
00048     QImage buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const;
00049 
00050     QImage buttonMaskImage( const QString &fileName ) const;
00051 
00052     static QString defaultSkinName();
00053 
00054 private:
00055     void init( const QString &name );
00056 
00057     void addButtonToMask( int tag, const QImage &maskImage ) const;
00058 
00059     static QImage loadImage( const QString &fileName );
00060 
00061     QString m_fileNameInfix;
00062     QString m_skinPath;
00063     bool m_isCachable : 1;
00064 
00065     SkinData *d;
00066 
00067     Skin( const Skin & );
00068     Skin &operator=( const Skin & );
00069 };
00070 
00071 class SkinLoader : public QObject
00072 {
00073     Q_OBJECT
00074 public:
00075     SkinLoader();
00076     virtual ~SkinLoader();
00077 
00078     void schedule( const MediaWidget::GUIInfo &guiInfo );
00079     void schedule( const QString &skinName, const MediaWidget::GUIInfo &guiInfo );
00080 
00081     void start();
00082 
00083 protected:
00084     virtual void timerEvent( QTimerEvent *ev );
00085 
00086 private slots:
00087     void deleteMe();
00088 
00089 private:
00090     struct Info : public MediaWidget::GUIInfo
00091     {
00092         Info() {}
00093         Info( const QString &_skinName, const MediaWidget::GUIInfo &guiInfo )
00094             : MediaWidget::GUIInfo( guiInfo ), skinName( _skinName )
00095         {}
00096 
00097         QString skinName;
00098     };
00099     typedef QValueList<Info> InfoList;
00100 
00101     class IncrementalLoader
00102     {
00103     public:
00104         enum LoaderResult { LoadingCompleted, MoreToCome };
00105 
00106         IncrementalLoader( const Info &info );
00107 
00108         LoaderResult loadStep();
00109 
00110     private:
00111         enum State { LoadBackgroundPixmap, LoadButtonUpImage, LoadButtonDownImage, LoadButtonMasks, LoadButtonMask };
00112 
00113         Skin m_skin;
00114         Info m_info;
00115         State m_currentState;
00116         uint m_currentButton;
00117     };
00118 
00119     InfoList pendingSkins;
00120     IncrementalLoader *m_currentLoader;
00121     int m_timerId;
00122 };
00123 
00124 #endif // SKIN_H
00125 /* vim: et sw=4 ts=4
00126  */

Generated on Sat Nov 5 16:17:33 2005 for OPIE by  doxygen 1.4.2