diff options
author | louis <louis.braun@gmx.de> | 2015-01-15 13:12:47 +0100 |
---|---|---|
committer | louis <louis.braun@gmx.de> | 2015-01-15 13:12:47 +0100 |
commit | c7f71f3f2b580714bd9e5a5c773bc2179c0e8567 (patch) | |
tree | a39d3efd5494b60964152e559eaead76c7897af5 /libskindesigner | |
download | vdr-plugin-weatherforecast-0.0.1.tar.gz vdr-plugin-weatherforecast-0.0.1.tar.bz2 |
Initial commit0.0.1
Diffstat (limited to 'libskindesigner')
-rw-r--r-- | libskindesigner/services.h | 52 | ||||
-rw-r--r-- | libskindesigner/skindesignerosdbase.c | 172 | ||||
-rw-r--r-- | libskindesigner/skindesignerosdbase.h | 62 |
3 files changed, 286 insertions, 0 deletions
diff --git a/libskindesigner/services.h b/libskindesigner/services.h new file mode 100644 index 0000000..0a016fa --- /dev/null +++ b/libskindesigner/services.h @@ -0,0 +1,52 @@ +#ifndef __SKINDESIGNERSERVICES_H +#define __SKINDESIGNERSERVICES_H + +using namespace std; + +#include <string> +#include <vector> +#include <map> + +enum eMenuType { + mtList, + mtText +}; + +class cSDDisplayMenu : public cSkinDisplayMenu { +public: + virtual void SetTitle(const char *Title); + virtual void SetPluginMenu(string name, int menu, int type, bool init); + virtual bool SetItemPlugin(map<string,string> *stringTokens, map<string,int> *intTokens, map<string,vector<map<string,string> > > *loopTokens, int Index, bool Current, bool Selectable); + virtual bool SetPluginText(map<string,string> *stringTokens, map<string,int> *intTokens, map<string,vector<map<string,string> > > *loopTokens); +}; + +/********************************************************************* +* Data Structures for Service Calls +*********************************************************************/ + +// Data structure for service "RegisterPlugin" +class RegisterPlugin { +public: + RegisterPlugin(void) { + name = ""; + }; + void SetMenu(int key, string templateName) { + menus.insert(pair<int, string>(key, templateName)); + } +// in + string name; //name of plugin + map< int, string > menus; //menus as key -> templatename hashmap +//out +}; + +// Data structure for service "GetDisplayMenu" +class GetDisplayMenu { +public: + GetDisplayMenu(void) { + displayMenu = NULL; + }; +// in +//out + cSDDisplayMenu *displayMenu; +}; +#endif //__SKINDESIGNERSERVICES_H
\ No newline at end of file diff --git a/libskindesigner/skindesignerosdbase.c b/libskindesigner/skindesignerosdbase.c new file mode 100644 index 0000000..821efdc --- /dev/null +++ b/libskindesigner/skindesignerosdbase.c @@ -0,0 +1,172 @@ +#include "skindesignerosdbase.h" + +/********************************************************************** +* cSkindesignerOsdItem +**********************************************************************/ +cSkindesignerOsdItem::cSkindesignerOsdItem(eOSState State) : cOsdItem(State) { + sdDisplayMenu = NULL; +} + +cSkindesignerOsdItem::cSkindesignerOsdItem(const char *Text, eOSState State, bool Selectable) : cOsdItem(Text, State, Selectable) { + sdDisplayMenu = NULL; +} + +cSkindesignerOsdItem::~cSkindesignerOsdItem() { + +} + +void cSkindesignerOsdItem::SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable) { + if (sdDisplayMenu) { + if (!sdDisplayMenu->SetItemPlugin(&stringTokens, &intTokens, &loopTokens, Index, Current, Selectable)) { + DisplayMenu->SetItem(Text(), Index, Current, Selectable); + } + } else { + DisplayMenu->SetItem(Text(), Index, Current, Selectable); + } +} + +void cSkindesignerOsdItem::AddStringToken(string key, string value) { + stringTokens.insert(pair<string,string>(key, value)); +} + +void cSkindesignerOsdItem::AddIntToken(string key, int value) { + intTokens.insert(pair<string,int>(key, value)); +} + +void cSkindesignerOsdItem::AddLoopToken(string loopName, map<string, string> &tokens) { + map<string, vector<map<string, string> > >::iterator hitLoop = loopTokens.find(loopName); + if (hitLoop == loopTokens.end()) { + vector<map<string, string> > tokenVector; + tokenVector.push_back(tokens); + loopTokens.insert(pair<string, vector<map<string, string> > >(loopName, tokenVector)); + } else { + vector<map<string, string> > *tokenVector = &hitLoop->second; + tokenVector->push_back(tokens); + } +} + + +/********************************************************************** +* cSkindesignerOsdMenu +**********************************************************************/ +cSkindesignerOsdMenu::cSkindesignerOsdMenu(const char *Title, int c0, int c1, int c2, int c3, int c4) : cOsdMenu(Title, c0, c1, c2, c3, c4) { + init = true; + displayText = false; + sdDisplayMenu = NULL; + pluginName = ""; + SetMenuCategory(mcPlugin); + SetSkinDesignerDisplayMenu(); +} + +cSkindesignerOsdMenu::~cSkindesignerOsdMenu() { + +} + +void cSkindesignerOsdMenu::SetPluginMenu(int menu, eMenuType type) { + if (type == mtList) + displayText = false; + else if (type == mtText) + displayText = true; + + if (sdDisplayMenu) { + sdDisplayMenu->SetPluginMenu(pluginName, menu, type, init); + } + init = false; +} + +bool cSkindesignerOsdMenu::SetSkinDesignerDisplayMenu(void) { + static cPlugin *pSkinDesigner = cPluginManager::GetPlugin("skindesigner"); + if (!pSkinDesigner) { + return false; + } + GetDisplayMenu call; + bool ok = pSkinDesigner->Service("GetDisplayMenu", &call); + if (ok && call.displayMenu) { + sdDisplayMenu = call.displayMenu; + return true; + } + return false; +} + +void cSkindesignerOsdMenu::ClearTokens(void) { + text = ""; + stringTokens.clear(); + intTokens.clear(); + loopTokens.clear(); +} + +void cSkindesignerOsdMenu::AddStringToken(string key, string value) { + stringTokens.insert(pair<string,string>(key, value)); +} + +void cSkindesignerOsdMenu::AddIntToken(string key, int value) { + intTokens.insert(pair<string,int>(key, value)); +} + +void cSkindesignerOsdMenu::AddLoopToken(string loopName, map<string, string> &tokens) { + map<string, vector<map<string, string> > >::iterator hitLoop = loopTokens.find(loopName); + if (hitLoop == loopTokens.end()) { + vector<map<string, string> > tokenVector; + tokenVector.push_back(tokens); + loopTokens.insert(pair<string, vector<map<string, string> > >(loopName, tokenVector)); + } else { + vector<map<string, string> > *tokenVector = &hitLoop->second; + tokenVector->push_back(tokens); + } +} + +void cSkindesignerOsdMenu::TextKeyLeft(void) { + if (!displayText) + return; + DisplayMenu()->Scroll(true, true); +} + +void cSkindesignerOsdMenu::TextKeyRight(void) { + if (!displayText) + return; + DisplayMenu()->Scroll(false, true); +} + +void cSkindesignerOsdMenu::TextKeyUp(void) { + if (!displayText) + return; + DisplayMenu()->Scroll(true, false); +} + +void cSkindesignerOsdMenu::TextKeyDown(void) { + if (!displayText) + return; + DisplayMenu()->Scroll(false, false); +} + +void cSkindesignerOsdMenu::Display(void) { + if (displayText) { + if (sdDisplayMenu) { + sdDisplayMenu->SetTitle(Title()); + if (sdDisplayMenu->SetPluginText(&stringTokens, &intTokens, &loopTokens)) { + sdDisplayMenu->Flush(); + } else { + DisplayMenu()->Clear(); + DisplayMenu()->SetTitle(Title()); + DisplayMenu()->SetText(text.c_str(), false); + DisplayMenu()->Flush(); + } + } else { + DisplayMenu()->Clear(); + DisplayMenu()->SetTitle(Title()); + DisplayMenu()->SetText(text.c_str(), false); + DisplayMenu()->Flush(); + } + return; + } + if (sdDisplayMenu) { + sdDisplayMenu->SetTitle(Title()); + for (cOsdItem *item = First(); item; item = Next(item)) { + cSkindesignerOsdItem *sdItem = dynamic_cast<cSkindesignerOsdItem*>(item); + if (sdItem) { + sdItem->SetDisplayMenu(sdDisplayMenu); + } + } + } + cOsdMenu::Display(); +} diff --git a/libskindesigner/skindesignerosdbase.h b/libskindesigner/skindesignerosdbase.h new file mode 100644 index 0000000..88068af --- /dev/null +++ b/libskindesigner/skindesignerosdbase.h @@ -0,0 +1,62 @@ +#ifndef __SKINDESIGNEROSDBASE_H +#define __SKINDESIGNEROSDBASE_H + +#include <string> +#include <vector> +#include <map> +#include <set> +#include <sstream> +#include <vdr/osdbase.h> +#include <vdr/plugin.h> +#include "services.h" + +class cSkindesignerOsdItem : public cOsdItem { +private: + cSDDisplayMenu *sdDisplayMenu; + map < string, string > stringTokens; + map < string, int > intTokens; + map < string, vector< map< string, string > > > loopTokens; +protected: +public: + cSkindesignerOsdItem(eOSState State = osUnknown); + cSkindesignerOsdItem(const char *Text, eOSState State = osUnknown, bool Selectable = true); + virtual ~cSkindesignerOsdItem(); + virtual void SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable); + void SetDisplayMenu(cSDDisplayMenu *sdDisplayMenu) { this->sdDisplayMenu = sdDisplayMenu; }; + void AddStringToken(string key, string value); + void AddIntToken(string key, int value); + void AddLoopToken(string loopName, map<string, string> &tokens); +}; + + +class cSkindesignerOsdMenu : public cOsdMenu { +private: + bool init; + bool displayText; + string pluginName; + cSDDisplayMenu *sdDisplayMenu; + string text; + map < string, string > stringTokens; + map < string, int > intTokens; + map < string, vector< map< string, string > > > loopTokens; + bool SetSkinDesignerDisplayMenu(void); +protected: + void ClearTokens(void); + void SetPluginName(string name) {pluginName = name; }; + void SetPluginMenu(int menu, eMenuType type); + void SetText(string text) { this->text = text; }; + void AddStringToken(string key, string value); + void AddIntToken(string key, int value); + void AddLoopToken(string loopName, map<string, string> &tokens); + void TextKeyLeft(void); + void TextKeyRight(void); + void TextKeyUp(void); + void TextKeyDown(void); +public: + cSkindesignerOsdMenu(const char *Title, int c0 = 0, int c1 = 0, int c2 = 0, int c3 = 0, int c4 = 0); + virtual ~cSkindesignerOsdMenu(); + virtual void Display(void); +}; + +#endif // __SKINDESIGNEROSDBASE_H + |