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 MMSSWITCHER_H_ 00034 #define MMSSWITCHER_H_ 00035 00036 #include "mmsbase/interfaces/immsswitcher.h" 00037 #include "mmscore/mmspluginmanager.h" 00038 #include "mmscore/mmsswitcherthread.h" 00039 #include "mmsinput/mmsinput.h" 00040 #include "mmsgui/mmsdialogmanager.h" 00041 #include "mmsgui/mmsmainwindow.h" 00042 00043 typedef struct { 00044 MMSPluginData plugindata; 00045 vector<MMSChildWindow *> previewWins; 00046 MMSSwitcher *switcher; 00047 } plugin_data_t; 00048 00049 00050 class MMSSwitcher : public IMMSSwitcher { 00051 private: 00052 const void addPluginsToMenu(const vector<MMSPluginData *> &plugins); 00053 00054 protected: 00055 MMSConfigData config; 00056 00057 static IMMSWindowManager *windowmanager; 00058 static MMSPluginManager *pluginmanager; 00059 static MMSInputManager *inputmanager; 00060 static vector<MMSInputSubscription*> subscriptions; 00061 00062 static MMSDialogManager dm; /**< dialog manager for whole switcher window */ 00063 static MMSMainWindow *window; /**< whole switcher window */ 00064 00065 static map<int, plugin_data_t *> plugins; /**< loaded plugins */ 00066 static int curr_plugin; /**< index to pluginSwitchers which points to the current plugin */ 00067 00068 MMSOSDPluginHandler *osdhandler; 00069 MMSCentralPluginHandler *centralhandler; 00070 MMSSwitcherThread *showPreviewThread; /**< a separate thread for each plugin */ 00071 static MMSSwitcherThread *switcherThread; /**< my update thread */ 00072 00073 bool switchToPluginEx(int toplugin); 00074 00075 protected: 00076 MMSPluginData *plugindata; /**< for plugin owned switcher instances */ 00077 00078 MMSChildWindow *menuBar; /**< shows the plugin menu */ 00079 MMSMenuWidget *menu; /**< plugin menu */ 00080 MMSChildWindow *menuBar_static; /**< shows the static plugin menu */ 00081 MMSMenuWidget *menu_static; /**< plugin static menu, switcher does not control it */ 00082 00083 int searchingForImage(string pluginpath, string imagename, string *path); 00084 00085 virtual void setMenuItemValues(MMSWidget *item); 00086 virtual void onBeforeScroll(MMSWidget *widget); 00087 virtual void onSelectItem(MMSWidget *widget); 00088 virtual void onReturn(MMSWidget *widget); 00089 virtual bool onBeforeShowPreview(MMSWindow *win); 00090 00091 public: 00092 /* initialization */ 00093 MMSSwitcher(MMSPluginData *plugindata = NULL); 00094 ~MMSSwitcher(); 00095 void setWindowManager(IMMSWindowManager *wm); 00096 void setPluginManager(MMSPluginManager *pm); 00097 void setInputManager(MMSInputManager *im); 00098 void onSubscription(MMSInputSubscription *subscription); 00099 void subscribeKey(MMSKeySymbol key); 00100 00101 /* methods for IMMSSwitcher */ 00102 virtual void show(); 00103 virtual void hide(); 00104 virtual MMSChildWindow* loadPreviewDialog(string filename, MMSTheme *theme = NULL, int id=-1); 00105 virtual MMSChildWindow* loadInfoBarDialog(string filename, MMSTheme *theme = NULL); 00106 virtual void setVolume(unsigned int volume, bool init = false); 00107 virtual IMMSSwitcher *newSwitcher(MMSPluginData *plugindata); 00108 virtual bool switchToPlugin(); 00109 virtual bool revertToLastPlugin(); 00110 virtual bool leavePlugin(bool show_switcher); 00111 virtual void* callback(void *data); 00112 virtual MMSChildWindow* loadChildWindow(string filename, MMSTheme *theme = NULL); 00113 virtual void refresh(); 00114 virtual MMSWidget *getMyButton(); 00115 friend class MMSSwitcherThread; 00116 }; 00117 00118 #endif /*MMSSWITCHER_H_*/