Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ZSkin.h

Go to the documentation of this file.
00001 //-------------------------------------------------------------------------------------------------
00002 //                                                                        
00003 //   Module Name: zskin.h
00004 //
00005 //   General Description: Used to access resources in current skin set
00006 //
00007 //-------------------------------------------------------------------------------------------------
00008 //
00009 //                            Motorola Confidential Proprietary
00010 //                     Template ID and version: TMP_LFC_50068  Version 1.2
00011 //                      (c) Copyright Motorola 200{x}, All Rights Reserved
00012 //
00013 //-------------------------------------------------------------------------------------------------
00014 
00015 #ifndef ZSKIN_H
00016 #define ZSKIN_H
00017 
00018 #ifndef __cplusplus
00019 #error "This is a C++ header file; it requires C++ to compile."
00020 #endif
00021 
00022 
00023 #include <qstring.h>
00024 #include <qpixmap.h>
00025 #include <qimage.h>
00026 #include <qbitmap.h>
00027 #include <qmovie.h>
00028 #include <ZResource.h>
00029 
00030 
00031 /**
00032  * Implements the application skin.
00033  *
00034  * The application skin is a stack of between zero and four resource files,
00035  * the application skin, the applicaiton base, the system skin, and the 
00036  * system base.
00037  *
00038  * @code
00039  * void myClass::myFunc(...)
00040  * {
00041  *     // skin is const (read-only)
00042  *     const ZSkin& skin = ZSkin::skin();   
00043  *     
00044  *     QPixmap pm = skin.getPixmap("CST_Back_O.g");
00045  *     // pm now contains the pixmap for the 'back' button overlay.
00046  *
00047  *     void *data;
00048  *     int length;
00049  *
00050  *     if (skin.get("somedata.dat", &data, &length))
00051  *     {
00052  *          printf("somedata.dat is located at 0x%08x and is of length %d",
00053  *                 data, length);
00054  *     }
00055  *     else
00056  *     {
00057  *          printf("somedata.dat could not be found");
00058  *     }
00059  * }
00060  * @endcode
00061  */
00062 class ZSkin : public ZResReader
00063 {
00064 public:
00065 
00066     /**
00067      * get a reference to the application's skin.
00068      */
00069     static const ZSkin& skin();
00070 
00071     /**
00072      * @return bool indicating whether or not a resource exists
00073      */
00074     virtual bool exists(const QString& ID) const;
00075    
00076     /**
00077      * get a QPixmap associated with a resource ID
00078      *
00079      * @param ID is the resource ID of the pixmap ("name.g")
00080      *
00081      * @note resource IDs for graphics do not maintain the file-extension
00082      * of the file stored on disk (.gif, .jpg, etc.).  When put into
00083      * the resource file, the all are changed to .g
00084      */
00085     virtual QPixmap getQPixmap(const QString& ID) const;
00086   
00087     /**
00088      * get a QImage associated with a resource ID
00089      *
00090      * @param ID is the resource ID of the pixmap ("name.g")
00091      *
00092      * @note resource IDs for graphics do not maintain the file-extension
00093      * of the file stored on disk (.gif, .jpg, etc.).  When put into the
00094      * resource file, the all are changed to .g
00095      */
00096     virtual QImage getQImage(const QString& ID) const;
00097 
00098     /**
00099      * get a QBitmap associated with a resource ID
00100      *
00101      * @param ID is the resource ID of the pixmap ("name.bmp")
00102      */
00103     virtual QBitmap getQBitmap(const QString& ID) const;
00104 
00105     /**
00106      * get a QMovie associated with a resource ID
00107      *
00108      * @param ID is the resource ID of the pixmap ("name.swf")
00109      */
00110     virtual QMovie getQMovie(const QString& ID) const;
00111     
00112     /**
00113      * get the data associated with a resource ID
00114      *
00115      * @note Do not delete/de-allocate the pointer returned from this function.
00116      */
00117     virtual bool get(const QString& ID, 
00118                      unsigned char** ppOutData, 
00119                      int* pOutLength) const;
00120     
00121     /**
00122      * reload the default skin
00123      *
00124      * @internal
00125      */
00126     static void reloadSkin();                
00127 
00128 protected:
00129 
00130     ZSkin();
00131     virtual ~ZSkin();
00132     
00133     ZSkin(const QString& systemBaseName, 
00134           const QString& systemSkinName,
00135           const QString& applicationBaseName,
00136           const QString& applicationSkinName);
00137 
00138     void init(const QString& systemBaseName, 
00139               const QString& systemSkinName,
00140               const QString& applicationBaseName,
00141               const QString& applicationSkinName);
00142 
00143     ZResFileReader *systemBase;
00144     ZResFileReader *systemSkin;
00145     ZResFileReader *appBase;
00146     ZResFileReader *appSkin;
00147    
00148     static ZSkin *defaultSkin; 
00149 };
00150 
00151 #endif // #ifndef ZSKIN_H

Generated at Wed Mar 3 13:22:02 2004 by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001