thememanager.h

Go to the documentation of this file.
00001 #ifndef THEME_MANAGER_H
00002 #define THEME_MANAGER_H
00003 /*
00004    This file is part of the KDE games kwin4 program
00005    Copyright (c) 2006 Martin Heni <kde@heni-online.de>
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library 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 library 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    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public License
00018    along with this library; see the file COPYING.LIB.  If not, write to
00019    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020    Boston, MA 02110-1301, USA.
00021 */
00022 
00023 // Qt includes
00024 #include <QObject>
00025 #include <QSvgRenderer>
00026 #include <QHash>
00027 
00028 // KDE includes
00029 #include <kconfig.h>
00030 
00031 
00032 class ThemeManager;
00033 
00039 class Themable 
00040 {
00041    public:
00044      Themable();
00045      
00052      Themable(QString id, ThemeManager* thememanager);
00053      
00056      virtual ~Themable();
00057      
00061      QString id() {return mId;}
00062      
00066      ThemeManager* thememanager() {return mThemeManager;}
00067      
00071      double getScale() {return mScale;}
00072      
00076      void setScale(double scale)  {mScale = scale;}
00077 
00082      virtual void changeTheme() = 0;
00083 
00084    private:
00085      // The theme ID
00086      QString mId;
00087      
00088      // The theme manager
00089      ThemeManager* mThemeManager;
00090      
00091      // The current scale for the object (maximum extension)
00092      double mScale;
00093 };
00094 
00095 
00096 
00105 class ThemeManager : public QObject
00106 {
00107 
00108   public:
00114     ThemeManager(QString themefile, QObject* parent, int initialSize = 1);
00115 
00123     const QPixmap getPixmap(QString svgid, QSize size);
00124     
00133     const QPixmap getPixmap(QString svgid, double width);
00134     
00144     const QPixmap getPixmap(QString svgid, QString svgref, double refwidth);
00145     
00149     double getScale();
00150     
00154     KConfigGroup config(QString id);
00155 
00159     void registerTheme(Themable* ob);
00160     
00164     void unregisterTheme(Themable* ob);
00165     
00170     void updateTheme(Themable* ob);
00171     
00178     void updateTheme(QString themefile);
00179     
00185     void rescale(int scale);
00186     
00187 
00188    private:
00189      // The used SVG rendered
00190      QSvgRenderer* mRenderer;
00191      
00192      // Storage of all theme objects [object,1] [TODO: Alist might suffice]
00193      QHash<Themable*,int> mObjects;
00194 
00195      // The cache of all pixmap objects [id,pixmap]
00196      QHash<QString,QPixmap> mPixmapCache;
00197      
00198      // The theme configration file
00199      KConfig* mConfig;
00200      
00201      // The current theme scale
00202      int mScale;
00203      
00204 };
00205 
00206 
00207 #endif

Generated on Sun Mar 4 10:56:43 2007 for KWin4 by  doxygen 1.4.6