Logo
  • Main Page
  • Related Pages
  • Modules
  • Classes
  • Files

mmsthememanager.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2007 Stefan Schwarzer, Jens Schneider,             *
00003  *                           Matthias Hardt, Guido Madaus                  *
00004  *                                                                         *
00005  *   Copyright (C) 2007-2008 BerLinux Solutions GbR                        *
00006  *                           Stefan Schwarzer & Guido Madaus               *
00007  *                                                                         *
00008  *   Copyright (C) 2009-2013 BerLinux Solutions GmbH                       *
00009  *                                                                         *
00010  *   Authors:                                                              *
00011  *      Stefan Schwarzer   <stefan.schwarzer@diskohq.org>,                 *
00012  *      Matthias Hardt     <matthias.hardt@diskohq.org>,                   *
00013  *      Jens Schneider     <jens.schneider@diskohq.org>,                   *
00014  *      Guido Madaus       <guido.madaus@diskohq.org>,                     *
00015  *      Patrick Helterhoff <patrick.helterhoff@diskohq.org>,               *
00016  *      René Bählkow       <rene.baehlkow@diskohq.org>                     *
00017  *                                                                         *
00018  *   This library is free software; you can redistribute it and/or         *
00019  *   modify it under the terms of the GNU Lesser General Public            *
00020  *   License version 2.1 as published by the Free Software Foundation.     *
00021  *                                                                         *
00022  *   This library is distributed in the hope that it will be useful,       *
00023  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00024  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00025  *   Lesser General Public License for more details.                       *
00026  *                                                                         *
00027  *   You should have received a copy of the GNU Lesser General Public      *
00028  *   License along with this library; if not, write to the                 *
00029  *   Free Software Foundation, Inc.,                                       *
00030  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
00031  **************************************************************************/
00032 
00033 #ifndef MMSTHEMEMANAGER_H_
00034 #define MMSTHEMEMANAGER_H_
00035 
00036 #include "mmsgui/theme/mmstheme.h"
00037 
00038 #define DEFAULT_THEME   "default"
00039 
00040 
00041 //! The MMSThemeManager will be used to load theme definitions from the theme file.
00042 /*!
00043 During mmsInit() the first instance will be created which loads the global theme.
00044 You can instantiate a separate object to interact with the theme manager.
00045 \author Jens Schneider
00046 */
00047 class MMSThemeManager {
00048     private:
00049         //! first static object initialized?
00050         static bool                 initialized;
00051 
00052         //! path to the theme
00053         static string               themepath;
00054 
00055         //! additional application (e.g. plugin) specific themes
00056         static vector<MMSTheme*>    localThemes;
00057 
00058         void throughFile(MMSTaffFile *tafff, MMSTheme *theme);
00059 
00060         void getThemeValues(MMSTaffFile *tafff, MMSTheme *theme);
00061         void getDescriptionValues(MMSTaffFile *tafff, MMSTheme *theme);
00062 
00063         void getTemplateValues(MMSTaffFile *tafff, MMSTemplateClass *themeClass);
00064         void getMainWindowValues(MMSTaffFile *tafff, MMSMainWindowClass *themeClass, MMSTheme *theme);
00065         void getPopupWindowValues(MMSTaffFile *tafff, MMSPopupWindowClass *themeClass, MMSTheme *theme);
00066         void getRootWindowValues(MMSTaffFile *tafff, MMSRootWindowClass *themeClass, MMSTheme *theme);
00067         void getChildWindowValues(MMSTaffFile *tafff, MMSChildWindowClass *themeClass, MMSTheme *theme);
00068         void getLabelWidgetValues(MMSTaffFile *tafff, MMSLabelWidgetClass *themeClass, MMSTheme *theme);
00069         void getImageWidgetValues(MMSTaffFile *tafff, MMSImageWidgetClass *themeClass, MMSTheme *theme);
00070         void getCanvasWidgetValues(MMSTaffFile *tafff, MMSCanvasWidgetClass *themeClass, MMSTheme *theme);
00071         void getButtonWidgetValues(MMSTaffFile *tafff, MMSButtonWidgetClass *themeClass, MMSTheme *theme);
00072         void getProgressBarWidgetValues(MMSTaffFile *tafff, MMSProgressBarWidgetClass *themeClass, MMSTheme *theme);
00073         void getSliderWidgetValues(MMSTaffFile *tafff, MMSSliderWidgetClass *themeClass, MMSTheme *theme);
00074         void getMenuWidgetValues(MMSTaffFile *tafff, MMSMenuWidgetClass *themeClass, MMSTheme *theme);
00075         void getTextBoxWidgetValues(MMSTaffFile *tafff, MMSTextBoxWidgetClass *themeClass, MMSTheme *theme);
00076         void getArrowWidgetValues(MMSTaffFile *tafff, MMSArrowWidgetClass *themeClass, MMSTheme *theme);
00077         void getInputWidgetValues(MMSTaffFile *tafff, MMSInputWidgetClass *themeClass, MMSTheme *theme);
00078         void getCheckBoxWidgetValues(MMSTaffFile *tafff, MMSCheckBoxWidgetClass *themeClass, MMSTheme *theme);
00079 
00080         void getTemplateClassValues(MMSTaffFile *tafff, MMSTheme *theme, string className);
00081         void getMainWindowClassValues(MMSTaffFile *tafff, MMSTheme *theme, string className);
00082         void getPopupWindowClassValues(MMSTaffFile *tafff, MMSTheme *theme, string className);
00083         void getRootWindowClassValues(MMSTaffFile *tafff, MMSTheme *theme, string className);
00084         void getChildWindowClassValues(MMSTaffFile *tafff, MMSTheme *theme, string className);
00085         void getLabelWidgetClassValues(MMSTaffFile *tafff, MMSTheme *theme, string className);
00086         void getImageWidgetClassValues(MMSTaffFile *tafff, MMSTheme *theme, string className);
00087         void getCanvasWidgetClassValues(MMSTaffFile *tafff, MMSTheme *theme, string className);
00088         void getButtonWidgetClassValues(MMSTaffFile *tafff, MMSTheme *theme, string className);
00089         void getProgressBarWidgetClassValues(MMSTaffFile *tafff, MMSTheme *theme, string className);
00090         void getSliderWidgetClassValues(MMSTaffFile *tafff, MMSTheme *theme, string className);
00091         void getMenuWidgetClassValues(MMSTaffFile *tafff, MMSTheme *theme, string className);
00092         void getTextBoxWidgetClassValues(MMSTaffFile *tafff, MMSTheme *theme, string className);
00093         void getArrowWidgetClassValues(MMSTaffFile *tafff, MMSTheme *theme, string className);
00094         void getInputWidgetClassValues(MMSTaffFile *tafff, MMSTheme *theme, string className);
00095         void getCheckBoxWidgetClassValues(MMSTaffFile *tafff, MMSTheme *theme, string className);
00096 
00097 
00098         void loadTheme(string path, string themeName, MMSTheme *theme);
00099         void loadGlobalTheme(string themeName);
00100         void loadLocalTheme(MMSTheme *theme, string path, string themeName = "");
00101 
00102     public:
00103         MMSThemeManager(string themepath, string globalThemeName = DEFAULT_THEME);
00104         MMSThemeManager();
00105         ~MMSThemeManager();
00106 
00107         MMSTheme *loadLocalTheme(string path, string themeName = "");
00108         void deleteLocalTheme(string path, string themeName);
00109         void deleteLocalTheme(MMSTheme **theme);
00110 
00111         //! Change the theme.
00112         /*!
00113         The fadein effect switcher will be used from the theme.xml definition.
00114         For that, you can set the attribute "fadein" for the tag <mmstheme/> to "true" or "false".
00115         The default is "false".
00116         \param themeName    name of the new theme to be activated
00117         \note The attribute "fadein" have to set for the new theme which is to be activated.
00118         \note If fails, an MMSError exception will be throw.
00119         */
00120         void setTheme(string themeName);
00121 
00122         //! Change the theme.
00123         /*!
00124         You can switch on/off the fading animation during the theme switch.
00125         \param themeName    name of the new theme to be activated
00126         \param fadein       the new theme should fade in?
00127         \note If fails, an MMSError exception will be throw.
00128         */
00129         void setTheme(string themeName, bool fadein);
00130 
00131 
00132         //! Set one or more callbacks for the onThemeChanged event.
00133         /*!
00134         The connected callbacks will be called during setTheme().
00135 
00136         A callback method must be defined like this:
00137 
00138             void myclass::mycallbackmethod(string themeName, bool fadein);
00139 
00140             \param themeName    name of the new theme
00141             \param fadein       the new theme should fade in?
00142 
00143         To connect your callback to onThemeChanged do this:
00144 
00145             sigc::connection connection;
00146             connection = mywindow->onThemeChanged->connect(sigc::mem_fun(myobject,&myclass::mycallbackmethod));
00147 
00148         To disconnect your callback do this:
00149 
00150             connection.disconnect();
00151 
00152         Please note:
00153 
00154             You HAVE TO disconnect myobject from onThemeChanged BEFORE myobject will be deleted!!!
00155             Else an abnormal program termination can occur.
00156             You HAVE TO call the disconnect() method of sigc::connection explicitly. The destructor will NOT do this!!!
00157         */
00158         static sigc::signal<void, string, bool> onThemeChanged;
00159 };
00160 
00161 MMS_CREATEERROR(MMSThemeManagerError);
00162 
00163 #endif /*MMSTHEMEMANAGER_H_*/

Generated by doxygen