diff options
author | louis <louis.braun@gmx.de> | 2016-01-26 18:32:38 +0100 |
---|---|---|
committer | louis <louis.braun@gmx.de> | 2016-01-26 18:32:38 +0100 |
commit | 809fbda03c5014ba9cd361f5113d1d717cd41ea6 (patch) | |
tree | 264bbc5640375f1bcb165fc7f4a3e595adcc26ca /libtemplate | |
parent | 196dd7eb9965a405bb16b51dc870fbbb31aeef87 (diff) | |
download | vdr-plugin-skindesigner-809fbda03c5014ba9cd361f5113d1d717cd41ea6.tar.gz vdr-plugin-skindesigner-809fbda03c5014ba9cd361f5113d1d717cd41ea6.tar.bz2 |
Version 0.8.0 beta
Diffstat (limited to 'libtemplate')
-rw-r--r-- | libtemplate/globals.c | 283 | ||||
-rw-r--r-- | libtemplate/globals.h | 63 | ||||
-rw-r--r-- | libtemplate/parameter.c | 493 | ||||
-rw-r--r-- | libtemplate/parameter.h | 147 | ||||
-rw-r--r-- | libtemplate/template.c | 322 | ||||
-rw-r--r-- | libtemplate/template.h | 61 | ||||
-rw-r--r-- | libtemplate/templatefunction.c | 1856 | ||||
-rw-r--r-- | libtemplate/templatefunction.h | 270 | ||||
-rw-r--r-- | libtemplate/templateloopfunction.c | 248 | ||||
-rw-r--r-- | libtemplate/templateloopfunction.h | 34 | ||||
-rw-r--r-- | libtemplate/templatepixmap.c | 739 | ||||
-rw-r--r-- | libtemplate/templatepixmap.h | 132 | ||||
-rw-r--r-- | libtemplate/templateview.c | 2148 | ||||
-rw-r--r-- | libtemplate/templateview.h | 243 | ||||
-rw-r--r-- | libtemplate/templateviewelement.c | 236 | ||||
-rw-r--r-- | libtemplate/templateviewelement.h | 127 | ||||
-rw-r--r-- | libtemplate/templateviewgrid.c | 29 | ||||
-rw-r--r-- | libtemplate/templateviewgrid.h | 25 | ||||
-rw-r--r-- | libtemplate/templateviewlist.c | 181 | ||||
-rw-r--r-- | libtemplate/templateviewlist.h | 47 | ||||
-rw-r--r-- | libtemplate/templateviewtab.c | 38 | ||||
-rw-r--r-- | libtemplate/templateviewtab.h | 31 | ||||
-rw-r--r-- | libtemplate/xmlparser.c | 643 | ||||
-rw-r--r-- | libtemplate/xmlparser.h | 68 |
24 files changed, 0 insertions, 8464 deletions
diff --git a/libtemplate/globals.c b/libtemplate/globals.c deleted file mode 100644 index 3fd0705..0000000 --- a/libtemplate/globals.c +++ /dev/null @@ -1,283 +0,0 @@ -#include "globals.h" -#include "xmlparser.h" -#include "../config.h" -#include <locale.h> - -cGlobals::cGlobals(void) { - customTokenChange = 0; - lastCustomTokenQuery = 0; - - fonts.insert(pair<string, string>("vdrOsd", Setup.FontOsd)); - fonts.insert(pair<string, string>("vdrFix", Setup.FontFix)); - fonts.insert(pair<string, string>("vdrSml", Setup.FontSml)); - language = Setup.OSDLanguage; - dsyslog("skindesigner: using language %s", language.c_str()); -} - -bool cGlobals::ReadFromXML(void) { - //globals.xml is mandatory - string xmlFile = "globals.xml"; - cXmlParser parser; - if (!parser.ReadGlobals(this, xmlFile)) - return false; - if (!parser.ParseGlobals()) - return false; - //theme.xml is optional - xmlFile = "theme.xml"; - if (parser.ReadGlobals(this, xmlFile)) { - parser.ParseGlobals(); - } - return true; -} - -void cGlobals::AddColor(string &name, tColor &col) { - colors.erase(name); - colors.insert(pair<string, tColor>(name, col)); -} - -bool cGlobals::GetColor(string &name, tColor &col) { - int size = name.size(); - if (size < 2) - return false; - string nameCutted = name.substr(1, size-2); - map <string, tColor>::iterator hit = colors.find(nameCutted); - if (hit != colors.end()) { - col = hit->second; - return true; - } - return false; -} - -void cGlobals::AddFont(string &name, string &font) { - fonts.erase(name); - fonts.insert(pair<string, string>(name, font)); -} - -bool cGlobals::GetFont(string name, string &font) { - int size = name.size(); - if (size < 2) - return false; - string nameCutted = name.substr(1, size-2); - map<string,string>::iterator hit = fonts.find(nameCutted); - if (hit != fonts.end()) { - font = hit->second; - return true; - } - return false; -} - -void cGlobals::AddInt(string &name, int value) { - intVars.erase(name); - intVars.insert(pair<string, int>(name, value)); -} - -void cGlobals::ReplaceIntVars(string &value) { - for (map<string, int>::iterator it = intVars.begin(); it != intVars.end(); it++) { - stringstream sToken; - sToken << "{" << it->first << "}"; - string token = sToken.str(); - size_t foundToken = string::npos; - do { - foundToken = value.find(token); - if (foundToken != string::npos) { - stringstream st; - st << it->second; - value = value.replace(foundToken, token.size(), st.str()); - } - } while (foundToken != string::npos); - } -} - -bool cGlobals::GetInt(string name, int &val) { - map < string, int >::iterator hit = intVars.find(name); - if (hit != intVars.end()) { - val = hit->second; - return true; - } - return false; -} - -void cGlobals::AddDouble(string &name, string &value) { - doubleVars.erase(name); - if (config.replaceDecPoint) { - if (value.find_first_of('.') != string::npos) { - std::replace( value.begin(), value.end(), '.', config.decPoint); - } - } - double val = atof(value.c_str()); - doubleVars.insert(pair<string, double>(name, val)); -} - -void cGlobals::ReplaceDoubleVars(string &value) { - for (map<string, double>::iterator it = doubleVars.begin(); it != doubleVars.end(); it++) { - stringstream sToken; - sToken << "{" << it->first << "}"; - string token = sToken.str(); - size_t foundToken = string::npos; - do { - foundToken = value.find(token); - if (foundToken != string::npos) { - stringstream st; - st << it->second; - string doubleVal = st.str(); - if (config.replaceDecPoint) { - if (doubleVal.find_first_of('.') != string::npos) { - std::replace( doubleVal.begin(), doubleVal.end(), '.', config.decPoint); - } - } - value = value.replace(foundToken, token.size(), doubleVal); - } - } while (foundToken != string::npos); - } -} - -void cGlobals::AddString(string &name, string &value) { - stringVars.erase(name); - stringVars.insert(pair<string, string>(name, value)); -} - -void cGlobals::ReplaceStringVars(string &value) { - for (map<string,string>::iterator it = stringVars.begin(); it != stringVars.end(); it++) { - stringstream sToken; - sToken << "{" << it->first << "}"; - string token = sToken.str(); - size_t foundToken = value.find(token); - if (foundToken != string::npos) { - value = value.replace(foundToken, token.size(), it->second); - } - } - -} - -bool cGlobals::GetString(string &name, string &value) { - map<string,string>::iterator hit = stringVars.find(name); - if (hit == stringVars.end()) - return false; - value = hit->second; - return true; -} - - -bool cGlobals::AddTranslation(string name, map < string, string > transl) { - translations.erase(name); - translations.insert(pair<string, map < string, string > >(name, transl)); - return true; -} - -bool cGlobals::Translate(string text, string &translation) { - string transStart = "{tr("; - string transEnd = ")}"; - size_t foundStart = text.find(transStart); - size_t foundEnd = text.find(transEnd); - bool translated = false; - - while (foundStart != string::npos && foundEnd != string::npos) { - string token = text.substr(foundStart + 1, foundEnd - foundStart); - string transToken = DoTranslate(token); - if (transToken.size() > 0) - translated = true; - else - return false; - text.replace(foundStart, foundEnd - foundStart + 2, transToken); - foundStart = text.find(transStart); - foundEnd = text.find(transEnd); - } - if (translated) - translation = text; - return translated; -} - -string cGlobals::DoTranslate(string token) { - string translation = ""; - map <string, map< string, string > >::iterator hit = translations.find(token); - if (hit == translations.end()) { - esyslog("skindesigner: invalid translation token %s", token.c_str()); - return translation; - } - map< string, string > translats = hit->second; - map< string, string >::iterator trans = translats.find(language); - if (trans != translats.end()) { - translation = trans->second; - } else { - map< string, string >::iterator transDefault = translats.find("en_EN"); - if (transDefault != translats.end()) { - translation = transDefault->second; - } - } - return translation; -} - -void cGlobals::AddCustomInt(string &name, int value) { - customIntTokens.erase(name); - customIntTokens.insert(pair<string,int>(name, value)); - customTokenChange = time(0); -} - -void cGlobals::AddCustomString(string &name, string &value) { - customStringTokens.erase(name); - customStringTokens.insert(pair<string,string>(name, value)); - customTokenChange = time(0); -} - -bool cGlobals::GetCustomInt(string name, int &val) { - map < string, int >::iterator hit = customIntTokens.find(name); - if (hit != customIntTokens.end()) { - val = hit->second; - return true; - } - return false; -} - -map <string, string> cGlobals::GetCustomStringTokens(void) { - lastCustomTokenQuery = time(0); - return customStringTokens; -} - -map <string, int> cGlobals::GetCustomIntTokens(void) { - lastCustomTokenQuery = time(0); - return customIntTokens; -} - -bool cGlobals::CustomTokenChange(void) { - if (!lastCustomTokenQuery) - return true; - if (lastCustomTokenQuery < customTokenChange) - return true; - return false; -} - -void cGlobals::ListCustomTokens(void) { - for (map<string, string>::iterator it = customStringTokens.begin(); it != customStringTokens.end(); it++) { - dsyslog("skindesigner: custom string token \"%s\" = \"%s\"", (it->first).c_str(), (it->second).c_str()); - } - for (map<string, int>::iterator it = customIntTokens.begin(); it != customIntTokens.end(); it++) { - dsyslog("skindesigner: custom int token \"%s\" = \"%d\"", (it->first).c_str(), it->second); - } -} - -void cGlobals::Debug(void) { - dsyslog("skindesigner: GLOBAL VARIABLES"); - for (map <string, tColor>::iterator col = colors.begin(); col != colors.end(); col++) { - dsyslog("skindesigner: Color \"%s\": %x", (col->first).c_str(), col->second); - } - for (map <string, int>::iterator myInt = intVars.begin(); myInt != intVars.end(); myInt++) { - dsyslog("skindesigner: Integer Variable \"%s\": %d", (myInt->first).c_str(), myInt->second); - } - for (map <string, double>::iterator myDouble = doubleVars.begin(); myDouble != doubleVars.end(); myDouble++) { - dsyslog("skindesigner: Double Variable \"%s\": %f", (myDouble->first).c_str(), myDouble->second); - } - for (map <string, string>::iterator myStr = stringVars.begin(); myStr != stringVars.end(); myStr++) { - dsyslog("skindesigner: String Variable \"%s\": \"%s\"", (myStr->first).c_str(), (myStr->second).c_str()); - } - for (map <string, string>::iterator font = fonts.begin(); font != fonts.end(); font++) { - dsyslog("skindesigner: Font \"%s\": \"%s\"", (font->first).c_str(), (font->second).c_str()); - } - - for (map <string, map< string, string > >::iterator trans = translations.begin(); trans != translations.end(); trans++) { - dsyslog("skindesigner: Translation Token %s", (trans->first).c_str()); - map< string, string > tokenTrans = trans->second; - for (map< string, string >::iterator transTok = tokenTrans.begin(); transTok != tokenTrans.end(); transTok++) { - dsyslog("skindesigner: language %s, translation %s", (transTok->first).c_str(), (transTok->second).c_str()); - } - } -} diff --git a/libtemplate/globals.h b/libtemplate/globals.h deleted file mode 100644 index 12ee917..0000000 --- a/libtemplate/globals.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef __XMLGLOBALS_H -#define __XMLGLOBALS_H - -#include <iostream> -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <string> -#include <vector> -#include <map> -#include <set> -#include <sstream> -#include <vdr/plugin.h> - -using namespace std; - -typedef uint32_t tColor; - -// --- cGlobals ------------------------------------------------------------- - -class cGlobals { -private: - time_t customTokenChange; - time_t lastCustomTokenQuery; - string language; - string DoTranslate(string token); - map <string, tColor> colors; - map <string, string> fonts; - map <string, int> intVars; - map <string, double> doubleVars; - map <string, string> stringVars; - map <string, map< string, string > > translations; - map <string, string> customStringTokens; - map <string, int> customIntTokens; -public: - cGlobals(void); - virtual ~cGlobals(void) {}; - bool ReadFromXML(void); - void AddColor(string &name, tColor &col); - bool GetColor(string &name, tColor &col); - void AddFont(string &name, string &font); - bool GetFont(string name, string &font); - void AddInt(string &name, int value); - void ReplaceIntVars(string &value); - bool GetInt(string name, int &val); - void AddDouble(string &name, string &value); - void ReplaceDoubleVars(string &value); - void AddString(string &name, string &value); - void ReplaceStringVars(string &value); - bool GetString(string &name, string &value); - bool AddTranslation(string name, map < string, string > transl); - bool Translate(string text, string &translation); - void AddCustomInt(string &name, int value); - void AddCustomString(string &name, string &value); - bool GetCustomInt(string name, int &val); - map <string, string> GetCustomStringTokens(void); - map <string, int> GetCustomIntTokens(void); - bool CustomTokenChange(void); - void ListCustomTokens(void); - void Debug(void); -}; - -#endif //__XMLGLOBALS_H
\ No newline at end of file diff --git a/libtemplate/parameter.c b/libtemplate/parameter.c deleted file mode 100644 index d76cb35..0000000 --- a/libtemplate/parameter.c +++ /dev/null @@ -1,493 +0,0 @@ -#include "../config.h" -#include "parameter.h" - -using namespace std; - -// --- cNumericParameter ------------------------------------------------------------- - -cNumericParameter::cNumericParameter(string value) { - this->value = value; - globals = NULL; - isValid = false; - width = 0; - height = 0; - columnWidth = -1; - rowHeight = -1; - hor = true; - defaultValue = 0; -} - -cNumericParameter::~cNumericParameter(void) { -} - -void cNumericParameter::SetAreaSize(int w, int h) { - width = w; - height = h; -} - -int cNumericParameter::Parse(string &parsedValue) { - int retVal = defaultValue; - - if (IsNumber(value)) { - isValid = true; - retVal = atoi(value.c_str()); - return retVal; - } - - //checking for percent value - bool isPercentValue = CheckPercentValue(retVal); - if (isPercentValue) { - isValid = true; - return retVal; - } - - //checking for expression - bool isValidExpression = CheckExpression(retVal, parsedValue); - if (isValidExpression) { - isValid = true; - return retVal; - } - - return retVal; -} - -bool cNumericParameter::IsNumber(const string& s) { - string::const_iterator it = s.begin(); - while (it != s.end() && isdigit(*it)) ++it; - return !s.empty() && it == s.end(); -} - -bool cNumericParameter::CheckPercentValue(int &val) { - bool ok = false; - size_t posPercent = value.find('%'); - if (posPercent != string::npos) { - string strPerc = value.substr(0, posPercent); - if (!IsNumber(strPerc)) { - return ok; - } - int perc = atoi(strPerc.c_str()); - if (hor) { - val = width * perc / 100; - } else { - val = height * perc / 100; - } - ok = true; - } - return ok; -} - -bool cNumericParameter::CheckExpression(int &val, string &parsedVal) { - bool ok = false; - string parsedValue = value; - //remove white spaces - parsedValue.erase( std::remove_if( parsedValue.begin(), parsedValue.end(), ::isspace ), parsedValue.end() ); - - //check and replace {areawidth} and {areaheight} tokens - string tokenWidth = "{areawidth}"; - string tokenHeight = "{areaheight}"; - - stringstream sw; - sw << width; - string strWidth = sw.str(); - stringstream sh; - sh << height; - string strHeight = sh.str(); - - bool foundToken = true; - while(foundToken) { - size_t foundTokenWidth = parsedValue.find(tokenWidth); - if (foundTokenWidth != string::npos) { - parsedValue = parsedValue.replace(foundTokenWidth, tokenWidth.size(), strWidth); - } else { - foundToken = false; - } - } - - foundToken = true; - while(foundToken) { - size_t foundTokenHeight = parsedValue.find(tokenHeight); - if (foundTokenHeight != string::npos) { - parsedValue = parsedValue.replace(foundTokenHeight, tokenHeight.size(), strHeight); - } else { - foundToken = false; - } - } - - //check and replace {columnwidth} and {rowheight} tokens for loop functions - if (columnWidth > 0 || rowHeight > 0) { - tokenWidth = "{columnwidth}"; - tokenHeight = "{rowheight}"; - stringstream cw; - cw << columnWidth; - strWidth = cw.str(); - stringstream rh; - rh << rowHeight; - strHeight = rh.str(); - - foundToken = true; - while(foundToken) { - size_t foundTokenWidth = parsedValue.find(tokenWidth); - if (foundTokenWidth != string::npos) { - parsedValue = parsedValue.replace(foundTokenWidth, tokenWidth.size(), strWidth); - } else { - foundToken = false; - } - } - - foundToken = true; - while(foundToken) { - size_t foundTokenHeight = parsedValue.find(tokenHeight); - if (foundTokenHeight != string::npos) { - parsedValue = parsedValue.replace(foundTokenHeight, tokenHeight.size(), strHeight); - } else { - foundToken = false; - } - } - } - - if (globals) { - globals->ReplaceIntVars(parsedValue); - globals->ReplaceDoubleVars(parsedValue); - } - - if (IsNumber(parsedValue)) { - ok = true; - val = atoi(parsedValue.c_str()); - return ok; - } - - if (!ValidNumericExpression(parsedValue)) { - parsedVal = parsedValue; - return ok; - } - ok = true; - char * expression = new char[parsedValue.size() + 1]; - std::copy(parsedValue.begin(), parsedValue.end(), expression); - expression[parsedValue.size()] = '\0'; - int expRes = EvaluateTheExpression(expression); - val = expRes; - delete[] expression; - return ok; -} - -bool cNumericParameter::ValidNumericExpression(string &parsedValue) { - string::const_iterator it = parsedValue.begin(); - while (it != parsedValue.end() && (isdigit(*it) || *it == '.' || *it == ',' || *it == '+' || *it == '-' || *it == '*' || *it == '/')) ++it; - return !parsedValue.empty() && it == parsedValue.end(); -} - -int cNumericParameter::EvaluateTheExpression(char* expr) { - return round(ParseSummands(expr)); -} - -double cNumericParameter::ParseAtom(char*& expr) { - // Read the number from string - char* end_ptr; - double res = strtod(expr, &end_ptr); - // Advance the pointer and return the result - expr = end_ptr; - return res; -} - -// Parse multiplication and division -double cNumericParameter::ParseFactors(char*& expr) { - double num1 = ParseAtom(expr); - for(;;) { - // Save the operation - char op = *expr; - if(op != '/' && op != '*') - return num1; - expr++; - double num2 = ParseAtom(expr); - // Perform the saved operation - if(op == '/') { - if (num2 != 0) { - num1 /= num2; - } - } else - num1 *= num2; - } -} - -// Parse addition and subtraction -double cNumericParameter::ParseSummands(char*& expr) { - double num1 = ParseFactors(expr); - for(;;) { - char op = *expr; - if(op != '-' && op != '+') - return num1; - expr++; - double num2 = ParseFactors(expr); - if(op == '-') - num1 -= num2; - else - num1 += num2; - } -} - -// --- cConditionalParameter ------------------------------------------------------------- - -cConditionalParameter::cConditionalParameter(cGlobals *globals, string value) { - this->globals = globals; - isTrue = false; - this->value = value; - type = cpNone; -} - -cConditionalParameter::~cConditionalParameter(void) { -} - -void cConditionalParameter::Tokenize(void) { - size_t posAnd = value.find("++"); - if (posAnd != string::npos) { - type = cpAnd; - TokenizeValue("++"); - } else { - size_t posOr = value.find("||"); - if (posOr != string::npos) { - type = cpOr; - TokenizeValue("||"); - } - } - if (type == cpNone) { - InsertCondition(value); - } -} - -void cConditionalParameter::Evaluate(map < string, int > *intTokens, map < string, string > *stringTokens) { - isTrue = false; - bool first = true; - for (vector<sCondition>::iterator cond = conditions.begin(); cond != conditions.end(); cond++) { - bool tokenTrue = false; - - if (cond->type == ctStringSet) { - if (stringTokens) { - map < string, string >::iterator hit = stringTokens->find(cond->tokenName); - if (hit != stringTokens->end()) { - string value = hit->second; - if (value.size() > 0) - tokenTrue = true; - } - } - } else if (cond->type == ctStringEmpty) { - if (stringTokens) { - map < string, string >::iterator hit = stringTokens->find(cond->tokenName); - if (hit != stringTokens->end()) { - string value = hit->second; - if (value.size() == 0) - tokenTrue = true; - } else { - tokenTrue = true; - } - } else { - tokenTrue = true; - } - } else if (cond->type == ctStringEquals) { - if (stringTokens) { - map < string, string >::iterator hit = stringTokens->find(cond->tokenName); - if (hit != stringTokens->end()) { - string value = hit->second; - if (!value.compare(cond->strCompareValue)) - tokenTrue = true; - } - } - if (!tokenTrue) { - string value = ""; - if (globals->GetString(cond->tokenName, value)) { - if (!value.compare(cond->strCompareValue)) { - tokenTrue = true; - } - } - } - } else if (cond->type == ctStringNotEquals) { - if (stringTokens) { - map < string, string >::iterator hit = stringTokens->find(cond->tokenName); - if (hit != stringTokens->end()) { - string value = hit->second; - if (value.compare(cond->strCompareValue)) - tokenTrue = true; - } else { - tokenTrue = true; - } - } else { - tokenTrue = true; - } - } else if (cond->type == ctStringContains) { - if (stringTokens) { - map < string, string >::iterator hit = stringTokens->find(cond->tokenName); - if (hit != stringTokens->end()) { - string value = hit->second; - if (value.find(cond->strCompareValue) != string::npos) - tokenTrue = true; - } - } - if (!tokenTrue) { - string value = ""; - if (globals->GetString(cond->tokenName, value)) { - if (value.find(cond->strCompareValue) != string::npos) { - tokenTrue = true; - } - } - } - } else if (cond->type == ctStringNotContains) { - if (stringTokens) { - map < string, string >::iterator hit = stringTokens->find(cond->tokenName); - if (hit != stringTokens->end()) { - string value = hit->second; - if (value.find(cond->strCompareValue) == string::npos) - tokenTrue = true; - } else { - tokenTrue = true; - } - } else { - tokenTrue = true; - } - } else { - int tokenValue = EvaluateParameter(cond->tokenName, intTokens, stringTokens); - if (cond->type == ctBool) { - tokenTrue = tokenValue; - } else if (cond->type == ctGreater) { - tokenTrue = (tokenValue > cond->compareValue) ? true : false; - } else if (cond->type == ctLower) { - tokenTrue = (tokenValue < cond->compareValue) ? true : false; - } else if (cond->type == ctEquals) { - tokenTrue = (tokenValue == cond->compareValue) ? true : false; - } - } - - if (cond->isNegated) - tokenTrue = !tokenTrue; - if (type == cpAnd) { - if (first) - isTrue = tokenTrue; - else - isTrue = isTrue && tokenTrue; - } else if (type == cpOr) { - isTrue = isTrue || tokenTrue; - } else { - isTrue = tokenTrue; - } - first = false; - } -} - -int cConditionalParameter::EvaluateParameter(string token, map < string, int > *intTokens, map < string, string > *stringTokens) { - //first check globals - int result = 0; - if (globals->GetInt(token, result)) - return result; - //then check custom tokens - if (globals->GetCustomInt(token, result)) - return result; - //then check tokens - if (intTokens) { - map < string, int >::iterator hit = intTokens->find(token); - if (hit != intTokens->end()) { - return hit->second; - } - } - if (stringTokens) { - map < string, string >::iterator hit = stringTokens->find(token); - if (hit != stringTokens->end()) { - string value = hit->second; - return atoi(value.c_str()); - } - } - return 0; -} - -void cConditionalParameter::TokenizeValue(string sep) { - string buffer = value; - bool sepFound = true; - while (sepFound) { - size_t posSep = buffer.find(sep); - if (posSep == string::npos) { - InsertCondition(buffer); - sepFound = false; - } - string token = buffer.substr(0, posSep); - buffer = buffer.replace(0, posSep + sep.size(), ""); - InsertCondition(token); - } -} - -void cConditionalParameter::InsertCondition(string cond) { - cond = StripWhitespaces(cond); - if (cond.size() < 1) - return; - - size_t tokenStart = cond.find('{'); - size_t tokenEnd = cond.find('}'); - - if (tokenStart == string::npos || tokenEnd == string::npos || tokenStart > tokenEnd) - return; - - string tokenName = cond.substr(tokenStart + 1, tokenEnd - tokenStart - 1); - string rest = cond.replace(tokenStart, tokenEnd - tokenStart + 1, ""); - - sCondition sCond; - sCond.tokenName = tokenName; - sCond.type = ctBool; - sCond.compareValue = 0; - sCond.strCompareValue = ""; - sCond.isNegated = false; - if (!rest.compare("not")) { - sCond.isNegated = true; - } else if (!rest.compare("isset")) { - sCond.type = ctStringSet; - } else if (!rest.compare("empty")) { - sCond.type = ctStringEmpty; - } else if (startswith(rest.c_str(), "strequal(")) { - sCond.strCompareValue = rest.substr(10, rest.size() - 11); - sCond.type = ctStringEquals; - } else if (startswith(rest.c_str(), "strnotequal(")) { - sCond.strCompareValue = rest.substr(13, rest.size() - 14); - sCond.type = ctStringNotEquals; - } else if (startswith(rest.c_str(), "strcontains(")) { - sCond.strCompareValue = rest.substr(13, rest.size() - 14); - sCond.type = ctStringContains; - } else if (startswith(rest.c_str(), "strnotcontains(")) { - sCond.strCompareValue = rest.substr(16, rest.size() - 17); - sCond.type = ctStringNotContains; - } else if (startswith(rest.c_str(), "gt(")) { - string compVal = rest.substr(4, rest.size() - 5); - sCond.compareValue = atoi(compVal.c_str()); - sCond.type = ctGreater; - } else if (startswith(rest.c_str(), "lt(")) { - string compVal = rest.substr(4, rest.size() - 5); - sCond.compareValue = atoi(compVal.c_str()); - sCond.type = ctLower; - } else if (startswith(rest.c_str(), "eq(")) { - string compVal = rest.substr(4, rest.size() - 5); - sCond.compareValue = atoi(compVal.c_str()); - sCond.type = ctEquals; - } - - conditions.push_back(sCond); -} - -string cConditionalParameter::StripWhitespaces(string value) { - size_t startEqual = value.find("strequal("); - size_t startNotEqual = value.find("strnotequal("); - size_t startContains = value.find("strcontains("); - size_t startNotContains = value.find("strnotcontains("); - if (startEqual != string::npos || startContains != string::npos || startNotEqual != string::npos || startNotContains != string::npos) { - size_t startString = value.find_first_of('\''); - size_t stopString = value.find_last_of('\''); - string text = value.substr(startString + 1, stopString - startString - 1); - value.replace(startString, stopString - startString + 1, "xxxxxx"); - value.erase( std::remove_if( value.begin(), value.end(), ::isspace ), value.end() ); - size_t startPlaceholder = value.find("xxxxxx"); - value.replace(startPlaceholder, 6, text); - } else { - value.erase( std::remove_if( value.begin(), value.end(), ::isspace ), value.end() ); - } - return value; -} - -void cConditionalParameter::Debug(void) { - dsyslog("skindesigner: Condition %s, Type: %s, cond is %s", value.c_str(), (type == cpAnd)?"and combination":((type == cpOr)?"or combination":"single param") , isTrue?"true":"false"); - for (vector<sCondition>::iterator it = conditions.begin(); it != conditions.end(); it++) { - dsyslog("skindesigner: cond token %s, type: %d, compareValue %d, negated: %d, strCompareValue %s", it->tokenName.c_str(), it->type, it->compareValue, it->isNegated, it->strCompareValue.c_str()); - } -}
\ No newline at end of file diff --git a/libtemplate/parameter.h b/libtemplate/parameter.h deleted file mode 100644 index 0a4ca23..0000000 --- a/libtemplate/parameter.h +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef __TEMPLATEPARAMETER_H -#define __TEMPLATEPARAMETER_H - -#include <iostream> -#include <stdio.h> -#include <stdlib.h> -#include <algorithm> -#include <math.h> -#include <string> -#include <vector> -#include <map> -#include <set> -#include <sstream> - -#include "globals.h" - -using namespace std; - -enum eAlign { - alLeft, - alCenter, - alRight, - alTop, - alBottom -}; - -enum eScrollMode { - smNone, - smCarriageReturn, - smForthAndBack -}; - -enum eScrollSpeed { - ssNone, - ssSlow, - ssMedium, - ssFast -}; - -enum eOrientation { - orNone, - orHorizontal, - orVertical, - orAbsolute -}; - -// --- cNumericParameter ------------------------------------------------------------- - -class cNumericParameter { -private: - cGlobals *globals; - string value; - bool isValid; - int width; - int height; - int columnWidth; - int rowHeight; - bool hor; - int defaultValue; - bool IsNumber(const string& s); - bool CheckPercentValue(int &val); - bool CheckExpression(int &val, string &parsedVal); - bool ValidNumericExpression(string &parsedValue); - int EvaluateTheExpression(char* expr); - double ParseAtom(char*& expr); - double ParseFactors(char*& expr); - double ParseSummands(char*& expr); -public: - cNumericParameter(string value); - virtual ~cNumericParameter(void); - void SetGlobals(cGlobals *globals) { this->globals = globals; }; - void SetAreaSize(int w, int h); - void SetLoopContainer(int columnWidth, int rowHeight) { this->columnWidth = columnWidth; this->rowHeight = rowHeight; }; - void SetDefault(int def) { defaultValue = def; }; - void SetHorizontal(void) { hor = true; }; - void SetVertical(void) { hor = false; }; - int Parse(string &parsedValue); - bool Valid(void) { return isValid; }; -}; - -// --- cTextToken ------------------------------------------------------------- - -enum eTextTokenType { - ttConstString, - ttToken, - ttConditionalToken, - ttPrintfToken -}; - -class cTextToken { -public: - eTextTokenType type; - string value; - vector<string> parameters; - vector<cTextToken> subTokens; -}; - -// --- cConditionalParameter ------------------------------------------------------------- - -enum eCondParameterType { - cpAnd, - cpOr, - cpNone -}; - -enum eCondType { - ctLower, - ctGreater, - ctEquals, - ctBool, - ctStringSet, - ctStringEmpty, - ctStringEquals, - ctStringNotEquals, - ctStringContains, - ctStringNotContains, - ctNone -}; - -struct sCondition { - string tokenName; - bool isNegated; - eCondType type; - int compareValue; - string strCompareValue; -}; - -class cConditionalParameter { -private: - cGlobals *globals; - bool isTrue; - string value; - eCondParameterType type; - vector<sCondition> conditions; - void TokenizeValue(string sep); - void InsertCondition(string cond); - string StripWhitespaces(string value); - int EvaluateParameter(string token, map < string, int > *intTokens, map < string, string > *stringTokens); -public: - cConditionalParameter(cGlobals *globals, string value); - virtual ~cConditionalParameter(void); - void Tokenize(void); - void Evaluate(map < string, int > *intTokens, map < string, string > *stringTokens); - bool IsTrue(void) { return isTrue; }; - void Debug(void); -}; -#endif //__TEMPLATEPARAMETER_H
\ No newline at end of file diff --git a/libtemplate/template.c b/libtemplate/template.c deleted file mode 100644 index 43fd3da..0000000 --- a/libtemplate/template.c +++ /dev/null @@ -1,322 +0,0 @@ - #include "template.h" -#include "xmlparser.h" -#include "../config.h" - -// --- cTemplate ------------------------------------------------------------- - -cTemplate::cTemplate(eViewType viewType, string pluginName, int viewID) { - globals = NULL; - rootView = NULL; - this->viewType = viewType; - CreateView(pluginName, viewID); -} - -cTemplate::~cTemplate() { - if (rootView) - delete rootView; - -} - -/******************************************************************* -* Public Functions -*******************************************************************/ -bool cTemplate::ReadFromXML(string xmlfile) { - string xmlFile; - switch (viewType) { - case vtDisplayChannel: - xmlFile = "displaychannel.xml"; - break; - case vtDisplayMenu: - xmlFile = "displaymenu.xml"; - break; - case vtDisplayMessage: - xmlFile = "displaymessage.xml"; - break; - case vtDisplayReplay: - xmlFile = "displayreplay.xml"; - break; - case vtDisplayVolume: - xmlFile = "displayvolume.xml"; - break; - case vtDisplayAudioTracks: - xmlFile = "displayaudiotracks.xml"; - break; - case vtDisplayPlugin: - xmlFile = xmlfile; - break; - default: - return false; - } - - cXmlParser parser; - if (!parser.ReadView(rootView, xmlFile)) { - return false; - } - if (!parser.ParseView()) { - return false; - } - - //read additional plugin menu templates - bool ok = true; - if (viewType == vtDisplayMenu) { - config.InitPluginMenuIterator(); - map <int,string> *plugTemplates = NULL; - string plugName; - while ( plugTemplates = config.GetPluginTemplates(plugName) ) { - for (map <int,string>::iterator it = plugTemplates->begin(); it != plugTemplates->end(); it++) { - int templateNumber = it->first; - stringstream templateName; - templateName << "plug-" << plugName << "-" << it->second.c_str(); - if (parser.ReadPluginView(plugName, templateNumber, templateName.str())) { - ok = parser.ParsePluginView(plugName, templateNumber); - } else { - dsyslog("skindesigner: template %s for plugin %s not available", templateName.str().c_str(), plugName.c_str()); - } - } - } - } - return ok; -} - -void cTemplate::SetGlobals(cGlobals *globals) { - this->globals = globals; - rootView->SetGlobals(globals); -} - -void cTemplate::Translate(void) { - rootView->Translate(); -} - - -void cTemplate::PreCache(void) { - rootView->PreCache(false); -} - -vector< pair<string, int> > cTemplate::GetUsedFonts(void) { - vector< pair<string, int> > usedFonts; - - GetUsedFonts(rootView, usedFonts); - - rootView->InitSubViewIterator(); - cTemplateView *subView = NULL; - while(subView = rootView->GetNextSubView()) { - GetUsedFonts(subView, usedFonts); - } - - return usedFonts; -} - - -void cTemplate::CacheImages(void) { - CacheImages(rootView); - rootView->InitSubViewIterator(); - cTemplateView *subView = NULL; - while(subView = rootView->GetNextSubView()) { - CacheImages(subView); - } -} - -bool cTemplate::SetSubViews(string plugName, int viewID) { - map <int,string> subViews = config.GetPluginSubViews(plugName, viewID); - - if (subViews.size() == 0) { - return true; - } - - for (map<int,string>::iterator it = subViews.begin(); it != subViews.end(); it ++) { - int subViewID = it->first; - stringstream templateName; - templateName << "plug-" << plugName << "-" << it->second; - string subViewTemplate = templateName.str(); - cTemplateView *plgTemplateView = new cTemplateViewPlugin(plugName, subViewID); - plgTemplateView->SetGlobals(globals); - cXmlParser parser; - if (!parser.ReadView(plgTemplateView, subViewTemplate)) { - esyslog("skindesigner: error reading plugin %s template", plugName.c_str()); - delete plgTemplateView; - return false; - } - if (!parser.ParseView()) { - esyslog("skindesigner: error reading plugin %s template", plugName.c_str()); - delete plgTemplateView; - return false; - } - stringstream svid; - svid << subViewID; - rootView->AddSubView(svid.str(), plgTemplateView); - } - return true; -} - - -void cTemplate::Debug(void) { - rootView->Debug(); -} - -/******************************************************************* -* Private Functions -*******************************************************************/ - -void cTemplate::CreateView(string pluginName, int viewID) { - switch (viewType) { - case vtDisplayChannel: - rootView = new cTemplateViewChannel(); - break; - case vtDisplayMenu: - rootView = new cTemplateViewMenu(); - break; - case vtDisplayReplay: - rootView = new cTemplateViewReplay(); - break; - case vtDisplayVolume: - rootView = new cTemplateViewVolume(); - break; - case vtDisplayAudioTracks: - rootView = new cTemplateViewAudioTracks(); - break; - case vtDisplayMessage: - rootView = new cTemplateViewMessage(); - break; - case vtDisplayPlugin: - rootView = new cTemplateViewPlugin(pluginName, viewID); - break; - default: - esyslog("skindesigner: unknown view %d", viewType); - } -} - -void cTemplate::GetUsedFonts(cTemplateView *view, vector< pair<string, int> > &usedFonts) { - //used fonts in viewElements - view->InitViewElementIterator(); - cTemplateViewElement *viewElement = NULL; - while(viewElement = view->GetNextViewElement()) { - viewElement->InitPixmapIterator(); - cTemplatePixmap *pix = NULL; - while(pix = viewElement->GetNextPixmap()) { - pix->InitFunctionIterator(); - cTemplateFunction *func = NULL; - while(func = pix->GetNextFunction()) { - if (func->GetType() == ftDrawText) { - usedFonts.push_back(pair<string,int>(func->GetFontName(), func->GetNumericParameter(ptFontSize))); - } - } - } - } - //used fonts in viewLists pixmaps - view->InitViewListIterator(); - cTemplateViewList *viewList = NULL; - while(viewList = view->GetNextViewList()) { - viewList->InitPixmapIterator(); - cTemplatePixmap *pix = NULL; - while(pix = viewList->GetNextPixmap()) { - pix->InitFunctionIterator(); - cTemplateFunction *func = NULL; - while(func = pix->GetNextFunction()) { - if (func->GetType() == ftDrawText) { - usedFonts.push_back(pair<string,int>(func->GetFontName(), func->GetNumericParameter(ptFontSize))); - } - } - } - cTemplateViewElement *listElement = viewList->GetListElement(); - listElement->InitPixmapIterator(); - while(pix = listElement->GetNextPixmap()) { - pix->InitFunctionIterator(); - cTemplateFunction *func = NULL; - while(func = pix->GetNextFunction()) { - if (func->GetType() == ftDrawText) { - usedFonts.push_back(pair<string,int>(func->GetFontName(), func->GetNumericParameter(ptFontSize))); - } - } - } - } - //used fonts in viewTabs - view->InitViewTabIterator(); - cTemplateViewTab *viewTab = NULL; - while(viewTab = view->GetNextViewTab()) { - viewTab->InitFunctionIterator(); - cTemplateFunction *func = NULL; - while(func = viewTab->GetNextFunction()) { - if (func->GetType() == ftDrawText) { - usedFonts.push_back(pair<string,int>(func->GetFontName(), func->GetNumericParameter(ptFontSize))); - } - } - } -} - -void cTemplate::CacheImages(cTemplateView *view) { - //used images in viewElements - view->InitViewElementIterator(); - cTemplateViewElement *viewElement = NULL; - while(viewElement = view->GetNextViewElement()) { - viewElement->InitPixmapIterator(); - cTemplatePixmap *pix = NULL; - while(pix = viewElement->GetNextPixmap()) { - CachePixmapImages(pix); - } - } - //used images in viewLists pixmaps - view->InitViewListIterator(); - cTemplateViewList *viewList = NULL; - while(viewList = view->GetNextViewList()) { - viewList->InitPixmapIterator(); - cTemplatePixmap *pix = NULL; - while(pix = viewList->GetNextPixmap()) { - CachePixmapImages(pix); - } - cTemplateViewElement *listElement = viewList->GetListElement(); - listElement->InitPixmapIterator(); - while(pix = listElement->GetNextPixmap()) { - CachePixmapImages(pix); - } - cTemplateViewElement *currentElement = viewList->GetListElementCurrent(); - if (!currentElement) { - continue; - } - currentElement->InitPixmapIterator(); - while(pix = currentElement->GetNextPixmap()) { - CachePixmapImages(pix); - } - } - //used images in viewTabs - view->InitViewTabIterator(); - cTemplateViewTab *viewTab = NULL; - while(viewTab = view->GetNextViewTab()) { - CachePixmapImages(viewTab); - } -} - -void cTemplate::CachePixmapImages(cTemplatePixmap *pix) { - pix->InitFunctionIterator(); - cTemplateFunction *func = NULL; - while(func = pix->GetNextFunction()) { - if (func->GetType() == ftDrawImage) { - CacheImage(func); - } - } -} - -void cTemplate::CacheImage(cTemplateFunction *func) { - eImageType imgType = (eImageType)func->GetNumericParameter(ptImageType); - int width = func->GetNumericParameter(ptWidth); - int height = func->GetNumericParameter(ptHeight); - - switch (imgType) { - case itIcon: - case itMenuIcon: { - string path = func->GetParameter(ptPath); - imgCache->CacheIcon(imgType, path, width, height); - break; } - case itChannelLogo: { - string doCache = func->GetParameter(ptCache); - if (!doCache.compare("true")) { - imgCache->CacheLogo(width, height); - } - break; } - case itSkinPart: { - string path = func->GetParameter(ptPath); - imgCache->CacheSkinpart(path, width, height); - break; } - default: - break; - } -} diff --git a/libtemplate/template.h b/libtemplate/template.h deleted file mode 100644 index 75dce5c..0000000 --- a/libtemplate/template.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef __TEMPLATE_H -#define __TEMPLATE_H - -#include <iostream> -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <string> -#include <vector> -#include <map> -#include <set> -#include <sstream> - -#include "globals.h" -#include "templateview.h" -#include "templateviewelement.h" -#include "templatepixmap.h" -#include "templatefunction.h" - -using namespace std; - -// --- cTemplate ------------------------------------------------------------- -enum eViewType { - vtDisplayChannel, - vtDisplayMenu, - vtDisplayReplay, - vtDisplayVolume, - vtDisplayAudioTracks, - vtDisplayMessage, - vtDisplayPlugin -}; - -class cTemplate { -private: - eViewType viewType; - void CachePixmapImages(cTemplatePixmap *pix); - void CacheImage(cTemplateFunction *func); -protected: - cGlobals *globals; - cTemplateView *rootView; - void CreateView(string pluginName, int viewID); - void GetUsedFonts(cTemplateView *view, vector< pair<string, int> > &usedFonts); - void CacheImages(cTemplateView *view); -public: - cTemplate(eViewType viewType, string pluginName = "", int viewID = -1); - virtual ~cTemplate(void); - bool ReadFromXML(string xmlfile = ""); - void SetGlobals(cGlobals *globals); - cTemplateView *GetRootView(void) { return rootView; }; - void Translate(void); - void PreCache(void); - //get fonts for pre caching - vector< pair<string, int> > GetUsedFonts(void); - void CacheImages(void); - //Set Plugin Subviews - bool SetSubViews(string plugName, int viewID); - //Debug - void Debug(void); -}; - -#endif //__TEMPLATE_H
\ No newline at end of file diff --git a/libtemplate/templatefunction.c b/libtemplate/templatefunction.c deleted file mode 100644 index 0adc754..0000000 --- a/libtemplate/templatefunction.c +++ /dev/null @@ -1,1856 +0,0 @@ -#include "templatefunction.h"
-#include "../config.h"
-#include "../libcore/helpers.h"
-
-using namespace std;
-
-// --- cTemplateFunction -------------------------------------------------------------
-
-cTemplateFunction::cTemplateFunction(eFuncType type) {
- this->type = type;
- debug = false;
- containerX = 0;
- containerY = 0;
- containerWidth = 0;
- containerHeight = 0;
- columnWidth = -1;
- rowHeight = -1;
- globals = NULL;
- condParam = NULL;
- parsedCompletely = false;
- updated = false;
- alreadyCutted = false;
- parsedTextWidth = 0;
- fontName = "";
- imgPath = "";
- textboxHeight = 0;
- stringTokens = NULL;
- intTokens = NULL;
- parsedText = "";
- cuttedText = "";
-}
-
-cTemplateFunction::~cTemplateFunction(void) {
- if (condParam)
- delete condParam;
-}
-
-/*******************************************************************
-* Public Functions
-*******************************************************************/
-
-void cTemplateFunction::SetParameters(vector<pair<string, string> > params) {
- for (vector<pair<string, string> >::iterator it = params.begin(); it != params.end(); it++) {
- string name = it->first;
- pair< eParamType, string > p;
- if (!name.compare("debug")) {
- string value = it->second;
- if (!value.compare("true")) {
- debug = true;
- }
- continue;
- } else if (!name.compare("debuggrid")) {
- string value = it->second;
- SetDebugGrid(value);
- continue;
- } else if (!name.compare("condition")) {
- p.first = ptCond;
- } else if (!name.compare("name")) {
- p.first = ptName;
- } else if (!name.compare("mode")) {
- p.first = ptMode;
- } else if (!name.compare("x")) {
- p.first = ptX;
- } else if (!name.compare("y")) {
- p.first = ptY;
- } else if (!name.compare("width")) {
- p.first = ptWidth;
- } else if (!name.compare("height")) {
- p.first = ptHeight;
- } else if (!name.compare("menuitemwidth")) {
- p.first = ptMenuItemWidth;
- } else if (!name.compare("detached")) {
- p.first = ptDetached;
- } else if (!name.compare("fadetime")) {
- p.first = ptFadeTime;
- } else if (!name.compare("shifttime")) {
- p.first = ptShiftTime;
- } else if (!name.compare("shifttype")) {
- p.first = ptShiftType;
- } else if (!name.compare("shiftmode")) {
- p.first = ptShiftMode;
- } else if (!name.compare("startx")) {
- p.first = ptStartX;
- } else if (!name.compare("starty")) {
- p.first = ptStartY;
- } else if (!name.compare("imagetype")) {
- p.first = ptImageType;
- } else if (!name.compare("path")) {
- p.first = ptPath;
- } else if (!name.compare("color")) {
- p.first = ptColor;
- } else if (!name.compare("font")) {
- p.first = ptFont;
- } else if (!name.compare("fontsize")) {
- p.first = ptFontSize;
- } else if (!name.compare("text")) {
- p.first = ptText;
- } else if (!name.compare("layer")) {
- p.first = ptLayer;
- } else if (!name.compare("transparency")) {
- p.first = ptTransparency;
- } else if (!name.compare("background")) {
- p.first = ptBackground;
- } else if (!name.compare("quadrant")) {
- p.first = ptQuadrant;
- } else if (!name.compare("type")) {
- p.first = ptType;
- } else if (!name.compare("align")) {
- p.first = ptAlign;
- } else if (!name.compare("valign")) {
- p.first = ptValign;
- } else if (!name.compare("delay")) {
- p.first = ptDelay;
- } else if (!name.compare("mode")) {
- p.first = ptScrollMode;
- } else if (!name.compare("scrollspeed")) {
- p.first = ptScrollSpeed;
- } else if (!name.compare("orientation")) {
- p.first = ptOrientation;
- } else if (!name.compare("numlistelements")) {
- p.first = ptNumElements;
- } else if (!name.compare("scrollelement")) {
- p.first = ptScrollElement;
- } else if (!name.compare("scrollheight")) {
- p.first = ptScrollHeight;
- } else if (!name.compare("float")) {
- p.first = ptFloat;
- } else if (!name.compare("floatwidth")) {
- p.first = ptFloatWidth;
- } else if (!name.compare("floatheight")) {
- p.first = ptFloatHeight;
- } else if (!name.compare("maxlines")) {
- p.first = ptMaxLines;
- } else if (!name.compare("columnwidth")) {
- p.first = ptColumnWidth;
- } else if (!name.compare("rowheight")) {
- p.first = ptRowHeight;
- } else if (!name.compare("overflow")) {
- p.first = ptOverflow;
- } else if (!name.compare("scaletvx")) {
- p.first = ptScaleTvX;
- } else if (!name.compare("scaletvy")) {
- p.first = ptScaleTvY;
- } else if (!name.compare("scaletvwidth")) {
- p.first = ptScaleTvWidth;
- } else if (!name.compare("scaletvheight")) {
- p.first = ptScaleTvHeight;
- } else if (!name.compare("hideroot")) {
- p.first = ptHideRoot;
- } else if (!name.compare("cache")) {
- p.first = ptCache;
- } else if (!name.compare("determinatefont")) {
- p.first = ptDeterminateFont;
- } else if (!name.compare("direction")) {
- p.first = ptDirection;
- } else if (!name.compare("animtype")) {
- p.first = ptAnimType;
- } else if (!name.compare("animfreq")) {
- p.first = ptAnimFreq;
- } else {
- p.first = ptNone;
- }
- p.second = it->second;
- nativeParameters.insert(p);
- }
-}
-
-void cTemplateFunction::SetParameter(eParamType type, string value) {
- nativeParameters.erase(type);
- nativeParameters.insert(pair<eParamType, string>(type, value));
-}
-
-void cTemplateFunction::SetContainer(int x, int y, int w, int h) {
- containerX = x;
- containerY = y;
- containerWidth = w;
- containerHeight = h;
-}
-
-void cTemplateFunction::SetLoopContainer(int columnWidth, int rowHeight) {
- this->columnWidth = columnWidth;
- this->rowHeight = rowHeight;
-}
-
-void cTemplateFunction::SetWidthManually(string width) {
- nativeParameters.erase(ptWidth);
- nativeParameters.insert(pair<eParamType, string>(ptWidth, width));
-}
-
-void cTemplateFunction::SetHeightManually(string height) {
- nativeParameters.erase(ptHeight);
- nativeParameters.insert(pair<eParamType, string>(ptHeight, height));
-}
-
-void cTemplateFunction::SetXManually(int newX) {
- numericParameters.erase(ptX);
- numericParameters.insert(pair<eParamType, int>(ptX, newX));
-}
-
-void cTemplateFunction::SetYManually(int newY) {
- numericParameters.erase(ptY);
- numericParameters.insert(pair<eParamType, int>(ptY, newY));
-}
-
-void cTemplateFunction::SetTextboxHeight(int boxHeight) {
- numericParameters.erase(ptHeight);
- numericParameters.insert(pair<eParamType, int>(ptHeight, boxHeight));
-}
-
-void cTemplateFunction::SetTranslatedText(string translation) {
- if (type != ftDrawText && type != ftDrawTextBox && type != ftDrawTextVertical)
- return;
- if (translation.size() == 0)
- return;
- nativeParameters.erase(ptText);
- nativeParameters.insert(pair<eParamType, string>(ptText, translation));
-}
-
-void cTemplateFunction::SetMaxTextWidth(int maxWidth) {
- if (type != ftDrawText)
- return;
- numericParameters.erase(ptWidth);
- numericParameters.insert(pair<eParamType, int>(ptWidth, maxWidth));
-}
-
-bool cTemplateFunction::CalculateParameters(void) {
- bool paramValid = true;
- bool paramsValid = true;
- for (map< eParamType, string >::iterator param = nativeParameters.begin(); param != nativeParameters.end(); param++) {
- paramValid = true;
- eParamType type = param->first;
- string value = param->second;
- switch (type) {
- case ptCond:
- paramValid = SetCondition(value);
- break;
- case ptX:
- case ptY:
- case ptWidth:
- case ptHeight:
- case ptMenuItemWidth:
- case ptFadeTime:
- case ptShiftTime:
- case ptDelay:
- case ptStartX:
- case ptStartY:
- case ptFontSize:
- case ptLayer:
- case ptTransparency:
- case ptQuadrant:
- case ptType:
- case ptNumElements:
- case ptFloatWidth:
- case ptFloatHeight:
- case ptMaxLines:
- case ptColumnWidth:
- case ptRowHeight:
- case ptScaleTvX:
- case ptScaleTvY:
- case ptScaleTvWidth:
- case ptScaleTvHeight:
- case ptAnimFreq:
- SetNumericParameter(type, value);
- break;
- case ptAlign:
- case ptValign:
- paramValid = SetAlign(type, value);
- break;
- case ptImageType:
- paramValid = SetImageType(type, value);
- break;
- case ptColor:
- paramValid = SetColor(type, value);
- break;
- case ptFont:
- paramValid = SetFont(type, value);
- break;
- case ptText:
- paramValid = SetTextTokens(value);
- break;
- case ptScrollMode:
- paramValid = SetScrollMode(value);
- break;
- case ptScrollSpeed:
- paramValid = SetScrollSpeed(value);
- break;
- case ptOrientation:
- paramValid = SetOrientation(value);
- break;
- case ptFloat:
- paramValid = SetFloating(value);
- break;
- case ptOverflow:
- paramValid = SetOverflow(value);
- break;
- case ptHideRoot:
- paramValid = SetHideRoot(value);
- break;
- case ptDetached:
- paramValid = SetDetached(value);
- break;
- case ptBackground:
- paramValid = SetBackground(value);
- break;
- case ptDirection:
- paramValid = SetDirection(value);
- break;
- case ptAnimType:
- paramValid = SetAnimType(value);
- break;
- case ptShiftType:
- paramValid = SetShiftType(value);
- break;
- case ptShiftMode:
- paramValid = SetShiftMode(value);
- break;
- default:
- paramValid = true;
- break;
- }
- if (!paramValid) {
- paramsValid = false;
- esyslog("skindesigner: %s: invalid parameter %d, value %s", GetFuncName().c_str(), type, value.c_str());
- }
- }
- return paramsValid;
-}
-
-bool cTemplateFunction::ReCalculateParameters(void) {
- bool paramValid = true;
- bool paramsValid = true;
- for (map< eParamType, string >::iterator param = nativeParameters.begin(); param != nativeParameters.end(); param++) {
- paramValid = true;
- eParamType type = param->first;
- string value = param->second;
- switch (type) {
- case ptX:
- case ptY:
- case ptWidth:
- case ptHeight:
- case ptMenuItemWidth:
- case ptFontSize:
- case ptFloatWidth:
- case ptFloatHeight:
- case ptMaxLines:
- case ptColumnWidth:
- case ptRowHeight:
- SetNumericParameter(type, value);
- break;
- default:
- break;
- }
- if (!paramValid) {
- paramsValid = false;
- esyslog("skindesigner: %s: invalid parameter %d, value %s", GetFuncName().c_str(), type, value.c_str());
- }
- }
- return paramsValid;
-}
-
-void cTemplateFunction::CompleteParameters(void) {
- switch (type) {
- case ftDrawImage: {
- CalculateAlign(GetNumericParameter(ptWidth), GetNumericParameter(ptHeight));
- if (imgPath.size() == 0) {
- imgPath = GetParameter(ptPath);
- }
- break; }
- case ftDrawRectangle:
- CalculateAlign(GetNumericParameter(ptWidth), GetNumericParameter(ptHeight));
- break;
- case ftDrawEllipse:
- CalculateAlign(GetNumericParameter(ptWidth), GetNumericParameter(ptHeight));
- break;
- case ftDrawSlope:
- CalculateAlign(GetNumericParameter(ptWidth), GetNumericParameter(ptHeight));
- break;
- case ftDrawText:
- CalculateAlign(GetWidth(), GetHeight());
- break;
- default:
- break;
- }
-}
-
-void cTemplateFunction::ClearDynamicParameters(void) {
- parsedText = "";
- cuttedText = "";
- alreadyCutted = false;
- parsedTextWidth = 0;
- textboxHeight = 0;
-
- //clear dynamically parsed int parameters
- for (map<eParamType,string>::iterator it = numericDynamicParameters.begin(); it != numericDynamicParameters.end(); it++) {
- numericParameters.erase(it->first);
- }
- //restoring dynamic numeric parameters only if x, y, width or height of other elements is needed dynamically
- for (map<eParamType,string>::iterator it = nativeParameters.begin(); it != nativeParameters.end(); it++) {
- eParamType paramType = it->first;
- if (paramType == ptX ||
- paramType == ptY ||
- paramType == ptWidth ||
- paramType == ptHeight ||
- paramType == ptFloatWidth ||
- paramType == ptFloatHeight)
- {
- string value = it->second;
- if (value.find("{width(") != string::npos || value.find("{height(") != string::npos || value.find("{posx(") != string::npos || value.find("{posy(") != string::npos) {
- numericDynamicParameters.erase(paramType);
- SetNumericParameter(paramType, value);
- }
- }
- }
-
-}
-
-bool cTemplateFunction::ParseParameters(void) {
- updated = false;
- parsedCompletely = true;
-
- if (stringTokens) {
- ParseStringParameters();
- }
-
- if (intTokens && numericDynamicParameters.size() > 0) {
- ParseNumericalParameters();
- }
-
- if (condParam) {
- condParam->Evaluate(intTokens, stringTokens);
- }
-
- return parsedCompletely;
-}
-
-string cTemplateFunction::GetParameter(eParamType type) {
- map<eParamType,string>::iterator hit = nativeParameters.find(type);
- if (hit == nativeParameters.end())
- return "";
- return hit->second;
-}
-
-int cTemplateFunction::GetNumericParameter(eParamType type) {
- map<eParamType,int>::iterator hit = numericParameters.find(type);
- if (hit == numericParameters.end()) {
- //Set Default Value for Integer Parameters
- if (type == ptLayer)
- return 1;
- else if (type == ptTransparency)
- return 0;
- else if (type == ptDelay)
- return 0;
- else if (type == ptFadeTime)
- return 0;
- else if (type == ptShiftTime)
- return 0;
- else if (type == ptMenuItemWidth)
- return 0;
- else if (type == ptHideRoot)
- return 0;
- else if (type == ptDetached)
- return 0;
- else if (type == ptBackground)
- return 0;
- else if (type == ptDrawDebugGrid)
- return 0;
- else if (type == ptDirection)
- return diBottomUp;
- else if (type == ptStartX)
- return 0;
- else if (type == ptStartY)
- return 0;
- else if (type == ptShiftType)
- return stNone;
- else if (type == ptShiftMode)
- return smLinear;
- //default default ;)
- return -1;
- }
- return hit->second;
-}
-
-string cTemplateFunction::GetText(bool cut) {
- if (!cut) {
- return parsedText;
- }
- if (alreadyCutted && cuttedText.size() > 0) {
- return cuttedText;
- }
- alreadyCutted = true;
- int maxWidth = GetNumericParameter(ptWidth);
- if (maxWidth > 0) {
- parsedTextWidth = fontManager->Width(fontName, GetNumericParameter(ptFontSize), parsedText.c_str());
- if (parsedTextWidth > maxWidth) {
- cuttedText = CutText(parsedText, maxWidth, fontName, GetNumericParameter(ptFontSize));
- return cuttedText;
- }
- }
- return parsedText;
-}
-
-
-tColor cTemplateFunction::GetColorParameter(eParamType type) {
- map<eParamType,tColor>::iterator hit = colorParameters.find(type);
- if (hit == colorParameters.end())
- return 0x00000000;
- return hit->second;
-}
-
-int cTemplateFunction::GetWidth(bool cutted) {
- int funcWidth = 0;
- switch (type) {
- case ftDrawText: {
- if (cutted) {
- if (!alreadyCutted) {
- alreadyCutted = true;
- int maxWidth = GetNumericParameter(ptWidth);
- if (maxWidth > 0) {
- parsedTextWidth = fontManager->Width(fontName, GetNumericParameter(ptFontSize), parsedText.c_str());
- if (parsedTextWidth > maxWidth) {
- cuttedText = CutText(parsedText, maxWidth, fontName, GetNumericParameter(ptFontSize));
- }
- }
- }
- if (cuttedText.size() > 0)
- return fontManager->Width(fontName, GetNumericParameter(ptFontSize), cuttedText.c_str());
- }
- if (parsedTextWidth > 0)
- funcWidth = parsedTextWidth;
- else
- funcWidth = fontManager->Width(fontName, GetNumericParameter(ptFontSize), parsedText.c_str());
- break; }
- case ftDrawTextVertical:
- funcWidth = GetNumericParameter(ptFontSize)*1.2;
- break;
- case ftFill:
- case ftDrawImage:
- case ftDrawRectangle:
- case ftDrawEllipse:
- case ftDrawSlope:
- case ftDrawTextBox:
- funcWidth = GetNumericParameter(ptWidth);
- break;
- default:
- esyslog("skindesigner: GetWidth not implemented for funcType %d", type);
- break;
- }
- return funcWidth;
-}
-
-int cTemplateFunction::GetHeight(map < string, vector< map< string, string > > > *loopTokens) {
- int funcHeight = 0;
- switch (type) {
- case ftDrawText:
- funcHeight = fontManager->Height(fontName, GetNumericParameter(ptFontSize));
- break;
- case ftDrawTextVertical:
- funcHeight = fontManager->Width(fontName, GetNumericParameter(ptFontSize), parsedText.c_str());
- break;
- case ftFill:
- case ftDrawImage:
- case ftDrawRectangle:
- case ftDrawEllipse:
- case ftDrawSlope:
- funcHeight = GetNumericParameter(ptHeight);
- break;
- case ftDrawTextBox: {
- int maxLines = GetNumericParameter(ptMaxLines);
- int fixedBoxHeight = GetNumericParameter(ptHeight);
- if (maxLines > 0) {
- funcHeight = maxLines * fontManager->Height(fontName, GetNumericParameter(ptFontSize));
- } else if (fixedBoxHeight > 0) {
- funcHeight = fixedBoxHeight;
- } else if (textboxHeight > 0) {
- funcHeight = textboxHeight;
- } else {
- funcHeight = CalculateTextBoxHeight();
- textboxHeight = funcHeight;
- }
- break; }
- case ftLoop: {
- cTemplateLoopFunction *loopFunc = dynamic_cast<cTemplateLoopFunction*>(this);
- if (loopFunc) {
- funcHeight = loopFunc->CalculateHeight(loopTokens);
- }
- break; }
- default:
- esyslog("skindesigner: GetHeight not implemented for funcType %d", type);
- break;
- }
- return funcHeight;
-}
-
-void cTemplateFunction::GetNeededWidths(multimap<eParamType,string> *widths) {
- for (map<eParamType, string>::iterator param = numericDynamicParameters.begin(); param !=numericDynamicParameters.end(); param++) {
- string val = param->second;
- size_t posStart = val.find("{width(");
- while (posStart != string::npos) {
- size_t posEnd = val.find(")", posStart+1);
- if (posEnd != string::npos) {
- string label = val.substr(posStart+7, posEnd - posStart - 7);
- widths->insert(pair<eParamType,string>(param->first, label));
- val = val.replace(posStart, posEnd - posStart, "");
- } else {
- break;
- }
- posStart = val.find("{width(");
- }
- }
-}
-
-void cTemplateFunction::GetNeededHeights(multimap<eParamType,string> *heights) {
- for (map<eParamType, string>::iterator param = numericDynamicParameters.begin(); param !=numericDynamicParameters.end(); param++) {
- string val = param->second;
- size_t posStart = val.find("{height(");
- while (posStart != string::npos) {
- size_t posEnd = val.find(")", posStart + 1);
- if (posEnd != string::npos) {
- string label = val.substr(posStart + 8, posEnd - posStart - 8);
- heights->insert(pair<eParamType,string>(param->first, label));
- val = val.replace(posStart, posEnd - posStart, "");
- } else {
- break;
- }
- posStart = val.find("{height(");
- }
- }
-}
-
-void cTemplateFunction::GetNeededPosX(multimap<eParamType,string> *posXs) {
- for (map<eParamType, string>::iterator param = numericDynamicParameters.begin(); param !=numericDynamicParameters.end(); param++) {
- string val = param->second;
- size_t posStart = val.find("{posx(");
- while (posStart != string::npos) {
- size_t posEnd = val.find(")", posStart+1);
- if (posEnd != string::npos) {
- string label = val.substr(posStart+6, posEnd - posStart - 6);
- posXs->insert(pair<eParamType,string>(param->first, label));
- val = val.replace(posStart, posEnd - posStart, "");
- } else {
- break;
- }
- posStart = val.find("{posx(");
- }
- }
-}
-
-void cTemplateFunction::GetNeededPosY(multimap<eParamType,string> *posYs) {
- for (map<eParamType, string>::iterator param = numericDynamicParameters.begin(); param !=numericDynamicParameters.end(); param++) {
- string val = param->second;
- size_t posStart = val.find("{posy(");
- while (posStart != string::npos) {
- size_t posEnd = val.find(")", posStart+1);
- if (posEnd != string::npos) {
- string label = val.substr(posStart+6, posEnd - posStart - 6);
- posYs->insert(pair<eParamType,string>(param->first, label));
- val = val.replace(posStart, posEnd - posStart, "");
- } else {
- break;
- }
- posStart = val.find("{posy(");
- }
- }
-}
-
-void cTemplateFunction::SetWidth(eParamType type, string label, int funcWidth) {
- updated = false;
- map< eParamType, string >::iterator hit = numericDynamicParameters.find(type);
- if (hit == numericDynamicParameters.end())
- return;
- stringstream needle;
- needle << "{width(" << label << ")}";
- size_t posFound = (hit->second).find(needle.str());
- if (posFound == string::npos)
- return;
- stringstream repl;
- repl << funcWidth;
- string parsedVal = (hit->second).replace(posFound, needle.str().size(), repl.str());
-
- cNumericParameter param(parsedVal);
- param.SetAreaSize(containerWidth, containerHeight);
- param.SetGlobals(globals);
- int val = param.Parse(parsedVal);
- if (param.Valid()) {
- updated = true;
- numericParameters.insert(pair<eParamType, int>(type, val));
- } else {
- numericDynamicParameters.erase(type);
- numericDynamicParameters.insert(pair<eParamType, string>(type, parsedVal));
- }
-}
-
-void cTemplateFunction::SetHeight(eParamType type, string label, int funcHeight) {
- updated = false;
- map< eParamType, string >::iterator hit = numericDynamicParameters.find(type);
- if (hit == numericDynamicParameters.end())
- return;
- stringstream needle;
- needle << "{height(" << label << ")}";
- size_t posFound = (hit->second).find(needle.str());
- if (posFound == string::npos)
- return;
- stringstream repl;
- repl << funcHeight;
- string parsedVal = (hit->second).replace(posFound, needle.str().size(), repl.str());
-
- cNumericParameter param(parsedVal);
- param.SetAreaSize(containerWidth, containerHeight);
- param.SetGlobals(globals);
- int val = param.Parse(parsedVal);
- if (param.Valid()) {
- updated = true;
- numericParameters.insert(pair<eParamType, int>(type, val));
- } else {
- numericDynamicParameters.erase(type);
- numericDynamicParameters.insert(pair<eParamType, string>(type, parsedVal));
- }
-}
-
-void cTemplateFunction::SetX(eParamType type, string label, int funcX) {
- updated = false;
- map< eParamType, string >::iterator hit = numericDynamicParameters.find(type);
- if (hit == numericDynamicParameters.end())
- return;
- stringstream needle;
- needle << "{posx(" << label << ")}";
- size_t posFound = (hit->second).find(needle.str());
- if (posFound == string::npos)
- return;
- stringstream repl;
- repl << funcX;
- string parsedVal = (hit->second).replace(posFound, needle.str().size(), repl.str());
-
- cNumericParameter param(parsedVal);
- param.SetAreaSize(containerWidth, containerHeight);
- param.SetGlobals(globals);
- int val = param.Parse(parsedVal);
- if (param.Valid()) {
- updated = true;
- numericParameters.insert(pair<eParamType, int>(type, val));
- } else {
- numericDynamicParameters.erase(type);
- numericDynamicParameters.insert(pair<eParamType, string>(type, parsedVal));
- }
-}
-
-void cTemplateFunction::SetY(eParamType type, string label, int funcY) {
- updated = false;
- map< eParamType, string >::iterator hit = numericDynamicParameters.find(type);
- if (hit == numericDynamicParameters.end())
- return;
- stringstream needle;
- needle << "{posy(" << label << ")}";
- size_t posFound = (hit->second).find(needle.str());
- if (posFound == string::npos)
- return;
- stringstream repl;
- repl << funcY;
- string parsedVal = (hit->second).replace(posFound, needle.str().size(), repl.str());
-
- cNumericParameter param(parsedVal);
- param.SetAreaSize(containerWidth, containerHeight);
- param.SetGlobals(globals);
- int val = param.Parse(parsedVal);
- if (param.Valid()) {
- updated = true;
- numericParameters.insert(pair<eParamType, int>(type, val));
- } else {
- numericDynamicParameters.erase(type);
- numericDynamicParameters.insert(pair<eParamType, string>(type, parsedVal));
- }
-}
-
-bool cTemplateFunction::DoExecute(void) {
- if (!condParam)
- return true;
- return condParam->IsTrue();
-}
-
-bool cTemplateFunction::IsAnimated(void) {
- map< eParamType, int >::iterator hit = numericParameters.find(ptAnimType);
- if (hit == numericParameters.end())
- return false;
- eAnimType type = (eAnimType)hit->second;
- if (type > atNone)
- return true;
- return false;
-}
-
-/*******************************************************************
-* Private Functions
-*******************************************************************/
-
-bool cTemplateFunction::SetCondition(string cond) {
- if (condParam)
- delete condParam;
- condParam = new cConditionalParameter(globals, cond);
- condParam->Tokenize();
- return true;
-}
-
-
-bool cTemplateFunction::SetNumericParameter(eParamType type, string value) {
- if (config.replaceDecPoint) {
- if (value.find_first_of('.') != string::npos) {
- std::replace( value.begin(), value.end(), '.', config.decPoint);
- }
- }
-
- cNumericParameter param(value);
- param.SetAreaSize(containerWidth, containerHeight);
- param.SetLoopContainer(columnWidth, rowHeight);
- param.SetGlobals(globals);
- switch (type) {
- case ptX:
- case ptStartX:
- case ptWidth:
- case ptMenuItemWidth:
- case ptScaleTvX:
- case ptScaleTvWidth:
- param.SetHorizontal();
- break;
- case ptY:
- case ptStartY:
- case ptHeight:
- case ptScaleTvY:
- case ptScaleTvHeight:
- param.SetVertical();
- break;
- case ptFontSize: {
- if (this->type == ftDrawTextVertical)
- param.SetHorizontal();
- else
- param.SetVertical();
- break; }
- case ptLayer:
- param.SetDefault(1);
- break;
- default:
- break;
- }
- string parsedValue = "";
- int val = param.Parse(parsedValue);
- if (param.Valid()) {
- if (this->type < ftLoop && type == ptX) {
- val += containerX;
- }
- if (this->type < ftLoop && type == ptY) {
- val += containerY;
- }
- numericParameters.erase(type);
- numericDynamicParameters.erase(type);
- numericParameters.insert(pair<eParamType, int>(type, val));
- } else {
- numericDynamicParameters.erase(type);
- numericDynamicParameters.insert(pair<eParamType, string>(type, parsedValue));
- }
- return param.Valid();
-}
-
-bool cTemplateFunction::SetAlign(eParamType type, string value) {
- eAlign align = alLeft;
- bool ok = true;
- if (!value.compare("center")) {
- align = alCenter;
- } else if (!value.compare("right")) {
- align = alRight;
- } else if (!value.compare("top")) {
- align = alTop;
- } else if (!value.compare("bottom")) {
- align = alBottom;
- } else if (!value.compare("left")) {
- align = alLeft;
- } else {
- ok = false;
- }
- numericParameters.insert(pair<eParamType, int>(type, align));
- return ok;
-}
-
-bool cTemplateFunction::SetFont(eParamType type, string value) {
- //check if token
- if (IsToken(value)) {
- if (!globals->GetFont(value, fontName)) {
- if (!globals->GetFont("{vdrOsd}", fontName)) {
- return false;
- }
- }
- } else {
- //if no token, directly use input
- fontName = value;
- }
- return true;
-}
-
-bool cTemplateFunction::SetImageType(eParamType type, string value) {
- eImageType imgType = itImage;
- bool ok = true;
- if (!value.compare("channellogo")) {
- imgType = itChannelLogo;
- } else if (!value.compare("seplogo")) {
- imgType = itSepLogo;
- } else if (!value.compare("skinpart")) {
- imgType = itSkinPart;
- } else if (!value.compare("menuicon")) {
- imgType = itMenuIcon;
- } else if (!value.compare("icon")) {
- imgType = itIcon;
- } else if (!value.compare("image")) {
- imgType = itImage;
- } else {
- ok = false;
- }
- numericParameters.insert(pair<eParamType, int>(ptImageType, imgType));
- return ok;
-}
-
-
-bool cTemplateFunction::SetColor(eParamType type, string value) {
- if (globals) {
- tColor colVal = 0x00000000;
- if (globals->GetColor(value, colVal)) {
- colorParameters.insert(pair<eParamType, tColor>(type, colVal));
- return true;
- }
- }
- if (value.size() != 8)
- return false;
- std::stringstream str;
- str << value;
- tColor colVal;
- str >> std::hex >> colVal;
- colorParameters.insert(pair<eParamType, tColor>(type, colVal));
- return true;
-}
-
-bool cTemplateFunction::SetTextTokens(string value) {
- textTokens.clear();
- //first replace globals
- globals->ReplaceStringVars(value);
- //now tokenize
- bool tokenFound = true;
- while (tokenFound) {
- //search for conditional token or normal token
- size_t tokenStart = value.find_first_of('{');
- size_t conditionStart = value.find_first_of('|');
- size_t printfStart = value.find("{printf(");
- if (tokenStart == string::npos && conditionStart == string::npos) {
- //find constant strings
- if (value.size() > 0) {
- cTextToken token;
- token.type = ttConstString;
- token.value = value;
- textTokens.push_back(token);
- }
- tokenFound = false;
- continue;
- } else if (tokenStart != string::npos && conditionStart == string::npos) {
- size_t tokenEnd = value.find_first_of('}');
- if (printfStart != string::npos && printfStart <= tokenStart) {
- //replace printf text token
- ParsePrintfTextToken(value, printfStart, tokenEnd);
- } else {
- //replace normal text token
- ParseTextToken(value, tokenStart, tokenEnd);
- }
- } else if (tokenStart != string::npos && conditionStart != string::npos) {
- if (tokenStart < conditionStart) {
- size_t tokenEnd = value.find_first_of('}');
- if (printfStart != string::npos && printfStart <= tokenStart) {
- //replace printf text token
- ParsePrintfTextToken(value, printfStart, tokenEnd);
- } else {
- //replace normal text token
- ParseTextToken(value, tokenStart, tokenEnd);
- }
- } else {
- //replace conditional text token
- size_t conditionEnd = value.find_first_of('|', conditionStart+1);
- ParseConditionalTextToken(value, conditionStart, conditionEnd);
- }
- }
- }
- return true;
-}
-
-void cTemplateFunction::ParseTextToken(string &value, size_t start, size_t end) {
- cTextToken token;
- if (start > 0) {
- string constString = value.substr(0, start);
- value = value.replace(0, start, "");
- token.type = ttConstString;
- token.value = constString;
- } else {
- string tokenName = value.substr(1, end - start - 1);
- value = value.replace(0, end - start + 1, "");
- token.type = ttToken;
- token.value = tokenName;
- }
- textTokens.push_back(token);
-}
-
-void cTemplateFunction::ParseConditionalTextToken(string &value, size_t start, size_t end) {
- cTextToken token;
- if (start > 0) {
- string constString = value.substr(0, start);
- value = value.replace(0, start, "");
- token.type = ttConstString;
- token.value = constString;
- } else {
- string condToken = value.substr(start + 1, end - start - 1);
- value = value.replace(0, end - start + 1, "");
- size_t tokenStart = condToken.find_first_of('{');
- size_t tokenEnd = condToken.find_first_of('}');
- vector<cTextToken> subTokens;
- if (tokenStart > 0) {
- cTextToken subToken;
- string constString = condToken.substr(0, tokenStart);
- condToken = condToken.replace(0, tokenStart, "");
- subToken.type = ttConstString;
- subToken.value = constString;
- subTokens.push_back(subToken);
- }
- string tokenName = condToken.substr(1, tokenEnd - tokenStart - 1);
- condToken = condToken.replace(0, tokenEnd - tokenStart + 1, "");
-
- cTextToken subToken2;
- subToken2.type = ttToken;
- subToken2.value = tokenName;
- subTokens.push_back(subToken2);
-
- if (condToken.size() > 0) {
- cTextToken subToken3;
- subToken3.type = ttConstString;
- subToken3.value = condToken;
- subTokens.push_back(subToken3);
- }
-
- token.type = ttConditionalToken;
- token.value = tokenName;
- token.subTokens = subTokens;
- }
- textTokens.push_back(token);
-}
-
-void cTemplateFunction::ParsePrintfTextToken(string &value, size_t start, size_t end) {
- cTextToken token;
- if (start > 0) {
- string constString = value.substr(0, start);
- value = value.replace(0, start, "");
- token.type = ttConstString;
- token.value = constString;
- } else {
- token.type = ttPrintfToken;
- //fetch parameter list from printf
- string printfParams = value.substr(start + 8, end - start - 9);
- value = value.replace(0, end - start + 1, "");
- splitstring s(printfParams.c_str());
- vector<string> flds = s.split(',', 1);
-
- int numParams = flds.size();
- if (numParams < 1)
- return;
- string formatString = trim(flds[0]);
- token.value = formatString.substr(1, formatString.size() - 2);
- for (int i=1; i < numParams; i++) {
- token.parameters.push_back(trim(flds[i]));
- }
- }
- textTokens.push_back(token);
-}
-
-bool cTemplateFunction::SetScrollMode(string value) {
- eScrollMode mode = smNone;
- bool ok = true;
- if (!value.compare("forthandback"))
- mode = smForthAndBack;
- else if (!value.compare("carriagereturn"))
- mode = smCarriageReturn;
- else
- ok = false;
- numericParameters.insert(pair<eParamType, int>(ptScrollMode, mode));
- return ok;
-}
-
-bool cTemplateFunction::SetScrollSpeed(string value) {
- eScrollSpeed speed = ssMedium;
- bool ok = true;
- if (!value.compare("slow"))
- speed = ssSlow;
- else if (!value.compare("fast"))
- speed = ssFast;
- else if (!value.compare("medium"))
- speed = ssMedium;
- else
- ok = false;
- numericParameters.insert(pair<eParamType, int>(ptScrollSpeed, speed));
- return ok;
-
-}
-
-bool cTemplateFunction::SetOrientation(string value) {
- eOrientation orientation = orNone;
- bool ok = true;
- if (!value.compare("horizontal"))
- orientation = orHorizontal;
- else if (!value.compare("vertical"))
- orientation = orVertical;
- else if (!value.compare("absolute"))
- orientation = orAbsolute;
- else
- ok = false;
- numericParameters.insert(pair<eParamType, int>(ptOrientation, orientation));
- return ok;
-}
-
-bool cTemplateFunction::SetFloating(string value) {
- eFloatType floatType = flNone;
- bool ok = true;
- if (!value.compare("topleft"))
- floatType = flTopLeft;
- else if (!value.compare("topright"))
- floatType = flTopRight;
- else
- ok = false;
- numericParameters.insert(pair<eParamType, int>(ptFloat, floatType));
- return ok;
-}
-
-bool cTemplateFunction::SetOverflow(string value) {
- eOverflowType overflowType = otNone;
- bool ok = true;
- if (!value.compare("linewrap"))
- overflowType = otWrap;
- else if (!value.compare("cut"))
- overflowType = otCut;
- else
- ok = false;
- numericParameters.insert(pair<eParamType, int>(ptOverflow, overflowType));
- return ok;
-}
-
-bool cTemplateFunction::SetHideRoot(string value) {
- int hideRoot = 0;
- if (!value.compare("true"))
- hideRoot = 1;
- numericParameters.insert(pair<eParamType, int>(ptHideRoot, hideRoot));
- return true;
-}
-
-bool cTemplateFunction::SetDetached(string value) {
- int detached = 0;
- if (!value.compare("true"))
- detached = 1;
- numericParameters.insert(pair<eParamType, int>(ptDetached, detached));
- return true;
-}
-
-bool cTemplateFunction::SetBackground(string value) {
- int back = 0;
- if (!value.compare("true"))
- back = 1;
- numericParameters.insert(pair<eParamType, int>(ptBackground, back));
- return true;
-}
-
-bool cTemplateFunction::SetDirection(string value) {
- int direction = diNone;
- if (!value.compare("bottomup"))
- direction = diBottomUp;
- else if (!value.compare("topdown"))
- direction = diTopDown;
- numericParameters.insert(pair<eParamType, int>(ptDirection, direction));
- return true;
-}
-
-bool cTemplateFunction::SetAnimType(string value) {
- int animType = atNone;
- if (!value.compare("blink"))
- animType = atBlink;
- else if (!value.compare("animated"))
- animType = atAnimated;
- numericParameters.insert(pair<eParamType, int>(ptAnimType, animType));
- return true;
-}
-
-bool cTemplateFunction::SetShiftType(string value) {
- int shiftType = stNone;
- if (!value.compare("left"))
- shiftType = stLeft;
- else if (!value.compare("right"))
- shiftType = stRight;
- else if (!value.compare("top"))
- shiftType = stTop;
- else if (!value.compare("bottom"))
- shiftType = stBottom;
- numericParameters.insert(pair<eParamType, int>(ptShiftType, shiftType));
- return true;
-}
-
-bool cTemplateFunction::SetShiftMode(string value) {
- int shiftMode = smLinear;
- if (!value.compare("slowed"))
- shiftMode = smSlowedDown;
- numericParameters.insert(pair<eParamType, int>(ptShiftMode, shiftMode));
- return true;
-}
-
-void cTemplateFunction::SetDebugGrid(string value) {
- int numGridsX = 0;
- int numGridsY = 0;
- size_t posSep = value.find("x");
- if (posSep != string::npos) {
- string x = value.substr(0, posSep);
- string y = value.substr(posSep+1);
- numGridsX = atoi(x.c_str());
- numGridsY = atoi(y.c_str());
- }
- if (numGridsX < 1)
- numGridsX = 10;
- if (numGridsY < 1)
- numGridsY = 10;
- numericParameters.insert(pair<eParamType, int>(ptDebugGridX, numGridsX));
- numericParameters.insert(pair<eParamType, int>(ptDebugGridY, numGridsY));
- numericParameters.insert(pair<eParamType, int>(ptDrawDebugGrid, 1));
-}
-
-void cTemplateFunction::ParseStringParameters(void) {
- //first replace stringtokens in Text (drawText)
- stringstream text;
- for (vector<cTextToken>::iterator it = textTokens.begin(); it !=textTokens.end(); it++) {
- updated = true;
- if ((*it).type == ttConstString) {
- text << (*it).value;
- } else if ((*it).type == ttToken) {
- bool found = false;
- string tokenName = (*it).value;
- if (stringTokens) {
- map < string, string >::iterator hit = stringTokens->find(tokenName);
- if (hit != stringTokens->end()) {
- text << hit->second;
- found = true;
- }
- }
- if (!found && intTokens) {
- map < string, int >::iterator hitInt = intTokens->find(tokenName);
- if (hitInt != intTokens->end()) {
- text << hitInt->second;
- found = true;
- }
- }
- if (!found) {
- text << "{" << tokenName << "}";
- }
- } else if ((*it).type == ttConditionalToken) {
- bool found = false;
- string tokenName = (*it).value;
- if (stringTokens) {
- map < string, string >::iterator hit = stringTokens->find(tokenName);
- if (hit != stringTokens->end()) {
- string replaceText = hit->second;
- if (replaceText.size() > 0) {
- for (vector<cTextToken>::iterator it2 = (*it).subTokens.begin(); it2 != (*it).subTokens.end(); it2++) {
- if ((*it2).type == ttConstString) {
- text << (*it2).value;
- } else {
- text << replaceText;
- }
- }
- }
- found = true;
- }
- }
- if (!found && intTokens) {
- map < string, int >::iterator hitInt = intTokens->find(tokenName);
- if (hitInt != intTokens->end()) {
- int intVal = hitInt->second;
- if (intVal > 0) {
- for (vector<cTextToken>::iterator it2 = (*it).subTokens.begin(); it2 != (*it).subTokens.end(); it2++) {
- if ((*it2).type == ttConstString) {
- text << (*it2).value;
- } else {
- text << intVal;
- }
- }
- }
- found = true;
- }
- }
- } else if ((*it).type == ttPrintfToken) {
- cTextToken token = *it;
- int paramCount = token.parameters.size();
- string printfResult = "";
- switch (paramCount) {
- case 1: {
- int param1 = ReplaceIntToken(token.parameters[0]);
- printfResult = *cString::sprintf(token.value.c_str(), param1);
- break; }
- case 2: {
- int param1 = ReplaceIntToken(token.parameters[0]);
- int param2 = ReplaceIntToken(token.parameters[1]);
- printfResult = *cString::sprintf(token.value.c_str(), param1, param2);
- break; }
- case 3: {
- int param1 = ReplaceIntToken(token.parameters[0]);
- int param2 = ReplaceIntToken(token.parameters[1]);
- int param3 = ReplaceIntToken(token.parameters[2]);
- printfResult = *cString::sprintf(token.value.c_str(), param1, param2, param3);
- break; }
- case 4: {
- int param1 = ReplaceIntToken(token.parameters[0]);
- int param2 = ReplaceIntToken(token.parameters[1]);
- int param3 = ReplaceIntToken(token.parameters[2]);
- int param4 = ReplaceIntToken(token.parameters[3]);
- printfResult = *cString::sprintf(token.value.c_str(), param1, param2, param3, param4);
- break; }
- case 5: {
- int param1 = ReplaceIntToken(token.parameters[0]);
- int param2 = ReplaceIntToken(token.parameters[1]);
- int param3 = ReplaceIntToken(token.parameters[2]);
- int param4 = ReplaceIntToken(token.parameters[3]);
- int param5 = ReplaceIntToken(token.parameters[4]);
- printfResult = *cString::sprintf(token.value.c_str(), param1, param2, param3, param4, param5);
- break; }
- default:
- break;
- }
- text << printfResult;
- }
- }
- parsedText = text.str();
-
- string path = GetParameter(ptPath);
- if (GetNumericParameter(ptImageType) == itImage && path.size() > 0) {
- //no absolute pathes allowed
- if (!startswith(path.c_str(), "{")) {
- esyslog("skindesigner: no absolute pathes allowed for images - %s", path.c_str());
- }
- if (startswith(path.c_str(), "{ressourcedir}")) {
- imgPath = path.replace(0, 14, *config.GetSkinRessourcePath());
- }
- }
- //now check further possible string variables
- if (stringTokens && path.size() > 0 && path.find("{") != string::npos) {
- for (map < string, string >::iterator it = stringTokens->begin(); it != stringTokens->end(); it++) {
- size_t found = path.find(it->first);
- if (found != string::npos) {
- size_t posEndBracket = found + (it->first).size();
- if (posEndBracket < path.size()) {
- string endChar = path.substr(posEndBracket, 1);
- if (endChar.compare("}"))
- continue;
- }
- updated = true;
- imgPath = path;
- if (found > 0 && ((it->first).size() + 2 <= imgPath.size()))
- imgPath.replace(found-1, (it->first).size() + 2, it->second);
- break;
- }
- }
- for (map < string, int >::iterator it = intTokens->begin(); it != intTokens->end(); it++) {
- size_t found = path.find(it->first);
- if (found != string::npos) {
- size_t posEndBracket = found + (it->first).size();
- if (posEndBracket < path.size()) {
- string endChar = path.substr(posEndBracket, 1);
- if (endChar.compare("}"))
- continue;
- }
- updated = true;
- imgPath = path;
- if (found > 0 && ((it->first).size() + 2 <= imgPath.size())) {
- stringstream intVal;
- intVal << it->second;
- imgPath.replace(found-1, (it->first).size() + 2, intVal.str());
- }
- break;
- }
- }
- }
-}
-
-void cTemplateFunction::ParseNumericalParameters(void) {
- parsedCompletely = true;
- for (map<eParamType, string>::iterator param = numericDynamicParameters.begin(); param !=numericDynamicParameters.end(); param++) {
- string val = param->second;
- for (map<string,int >::iterator tok = intTokens->begin(); tok != intTokens->end(); tok++) {
- stringstream sToken;
- sToken << "{" << tok->first << "}";
- string token = sToken.str();
- size_t foundToken = val.find(token);
- //replace token as often as it appears
- while (foundToken != string::npos) {
- stringstream sVal;
- sVal << tok->second;
- val = val.replace(foundToken, token.size(), sVal.str());
- foundToken = val.find(token);
- }
- }
- cNumericParameter p(val);
- string parsedVal = "";
- int newVal = p.Parse(parsedVal);
- if (p.Valid()) {
- updated = true;
- numericParameters.insert(pair<eParamType, int>(param->first, newVal));
- } else {
- parsedCompletely = false;
- }
- }
-}
-
-void cTemplateFunction::CalculateAlign(int elementWidth, int elementHeight) {
- int align = GetNumericParameter(ptAlign);
- //if element is used in a loop, use loop box width
- int boxWidth = (columnWidth > 0) ? columnWidth : containerWidth;
- int boxHeight = (rowHeight > 0) ? rowHeight : containerHeight;
- if (align == alCenter) {
- int xNew = (boxWidth - elementWidth) / 2;
- numericParameters.erase(ptX);
- numericParameters.insert(pair<eParamType,int>(ptX, xNew));
- } else if (align == alRight) {
- int xNew = boxWidth - elementWidth;
- numericParameters.erase(ptX);
- numericParameters.insert(pair<eParamType,int>(ptX, xNew));
- }
-
- int vAlign = GetNumericParameter(ptValign);
- if (vAlign == alCenter) {
- int yNew = (boxHeight - elementHeight) / 2;
- numericParameters.erase(ptY);
- numericParameters.insert(pair<eParamType,int>(ptY, yNew));
- } else if (vAlign == alBottom) {
- int yNew = boxHeight - elementHeight;
- numericParameters.erase(ptY);
- numericParameters.insert(pair<eParamType,int>(ptY, yNew));
- }
-}
-
-int cTemplateFunction::CalculateTextBoxHeight(void) {
- int width = GetNumericParameter(ptWidth);
- string fontName = GetFontName();
- int fontSize = GetNumericParameter(ptFontSize);
- string text = GetText(false);
- const cFont *font = fontManager->Font(fontName, fontSize);
- if (!font)
- return 0;
-
- int fontHeight = fontManager->Height(fontName, fontSize);
- int floatType = GetNumericParameter(ptFloat);
-
- if (floatType == flNone) {
- fontManager->Lock();
- cTextWrapper wrapper;
- wrapper.Set(text.c_str(), font, width);
- fontManager->Unlock();
- int lines = wrapper.Lines();
- return (lines * fontHeight);
- }
-
- int floatWidth = GetNumericParameter(ptFloatWidth);
- int floatHeight = GetNumericParameter(ptFloatHeight);
-
- cTextWrapper wTextTall;
- cTextWrapper wTextFull;
-
- int linesNarrow = floatHeight / fontHeight;
- int widthNarrow = width - floatWidth;
- int linesDrawn = 0;
- int curY = 0;
- bool drawNarrow = true;
-
- splitstring s(text.c_str());
- vector<string> flds = s.split('\n', 1);
-
- if (flds.size() < 1)
- return 0;
-
- stringstream sstrTextTall;
- stringstream sstrTextFull;
-
- for (int i=0; i < (int)flds.size(); i++) {
- if (!flds[i].size()) {
- //empty line
- linesDrawn++;
- curY += fontHeight;
- if (drawNarrow)
- sstrTextTall << "\n";
- else
- sstrTextFull << "\n";
- } else {
- cTextWrapper wrapper;
- if (drawNarrow) {
- fontManager->Lock();
- wrapper.Set((flds[i].c_str()), font, widthNarrow);
- fontManager->Unlock();
- int newLines = wrapper.Lines();
- //check if wrapper fits completely into narrow area
- if (linesDrawn + newLines < linesNarrow) {
- for (int line = 0; line < wrapper.Lines(); line++) {
- sstrTextTall << wrapper.GetLine(line) << " ";
- }
- sstrTextTall << "\n";
- linesDrawn += newLines;
- } else {
- //this wrapper has to be splitted
- for (int line = 0; line < wrapper.Lines(); line++) {
- if (line + linesDrawn < linesNarrow) {
- sstrTextTall << wrapper.GetLine(line) << " ";
- } else {
- sstrTextFull << wrapper.GetLine(line) << " ";
- }
- }
- sstrTextFull << "\n";
- drawNarrow = false;
- }
- } else {
- fontManager->Lock();
- wrapper.Set((flds[i].c_str()), font, width);
- fontManager->Unlock();
- for (int line = 0; line < wrapper.Lines(); line++) {
- sstrTextFull << wrapper.GetLine(line) << " ";
- }
- sstrTextFull << "\n";
- }
- }
- }
- fontManager->Lock();
- wTextTall.Set(sstrTextTall.str().c_str(), font, widthNarrow);
- fontManager->Unlock();
- fontManager->Lock();
- wTextFull.Set(sstrTextFull.str().c_str(), font, width);
- fontManager->Unlock();
-
- int textLinesTall = wTextTall.Lines();
- int textLinesFull = wTextFull.Lines();
-
- return ((textLinesTall+textLinesFull) * fontHeight);
-}
-
-int cTemplateFunction::ReplaceIntToken(string intTok) {
- if (intTokens) {
- map<string,int>::iterator hit = intTokens->find(intTok);
- if (hit != intTokens->end())
- return hit->second;
- }
- if (stringTokens) {
- map<string,string>::iterator hit = stringTokens->find(intTok);
- if (hit != stringTokens->end()) {
- return atoi(hit->second.c_str());
- }
- }
- return 0;
-}
-
-/*******************************************************************
-* Helper Functions
-*******************************************************************/
-
-string cTemplateFunction::GetFuncName(void) {
- string name;
- switch (type) {
- case ftOsd:
- name = "OSD Parameters";
- break;
- case ftView:
- name = "View Parameters";
- break;
- case ftViewElement:
- name = "View Element Parameters";
- break;
- case ftPixmapContainer:
- name = "Pixmap Container Parameters";
- break;
- case ftPixmap:
- name = "Pixmap Parameters";
- break;
- case ftPixmapScroll:
- name = "ScrollPixmap Parameters";
- break;
- case ftLoop:
- name = "Looping Function";
- break;
- case ftFill:
- name = "Function Fill";
- break;
- case ftDrawText:
- name = "Function DrawText";
- break;
- case ftDrawTextBox:
- name = "Function DrawTextBox";
- break;
- case ftDrawTextVertical:
- name = "Function DrawTextVertical";
- break;
- case ftDrawImage:
- name = "Function DrawImage";
- break;
- case ftDrawRectangle:
- name = "Function DrawRectangle";
- break;
- case ftDrawEllipse:
- name = "Function DrawEllipse";
- break;
- case ftDrawSlope:
- name = "Function DrawSlope";
- break;
- case ftNone:
- name = "Undefined";
- break;
- default:
- name = "Unknown";
- break;
- };
- return name;
-}
-
-string cTemplateFunction::GetParamName(eParamType pt) {
- string name;
- switch (pt) {
- case ptCond:
- name = "Condition";
- break;
- case ptName:
- name = "Name";
- break;
- case ptMode:
- name = "Mode";
- break;
- case ptX:
- name = "X";
- break;
- case ptY:
- name = "Y";
- break;
- case ptWidth:
- name = "Width";
- break;
- case ptHeight:
- name = "Height";
- break;
- case ptMenuItemWidth:
- name = "Menu Item Width";
- break;
- case ptDetached:
- name = "Detached";
- break;
- case ptFadeTime:
- name = "Fade Time";
- break;
- case ptShiftTime:
- name = "Shift Time";
- break;
- case ptShiftType:
- name = "Shift Type";
- break;
- case ptShiftMode:
- name = "Shift Mode";
- break;
- case ptStartX:
- name = "Startpos X";
- break;
- case ptStartY:
- name = "Startpos Y";
- break;
- case ptDelay:
- name = "Delay";
- break;
- case ptImageType:
- name = "Image Type";
- break;
- case ptPath:
- name = "Image Path";
- break;
- case ptColor:
- name = "Color";
- break;
- case ptFont:
- name = "Font";
- break;
- case ptFontSize:
- name = "FontSize";
- break;
- case ptText:
- name = "Text";
- break;
- case ptLayer:
- name = "Layer";
- break;
- case ptTransparency:
- name = "Transparency";
- break;
- case ptQuadrant:
- name = "Quadrant";
- break;
- case ptType:
- name = "Type";
- break;
- case ptAlign:
- name = "Align";
- break;
- case ptValign:
- name = "Vertical Align";
- break;
- case ptScrollMode:
- name = "Scroll Mode";
- break;
- case ptScrollSpeed:
- name = "Scroll Speed";
- break;
- case ptOrientation:
- name = "Orientation";
- break;
- case ptNumElements:
- name = "NumElements";
- break;
- case ptScrollElement:
- name = "Scroll Element";
- break;
- case ptScrollHeight:
- name = "Scroll Height";
- break;
- case ptFloat:
- name = "Floating Type";
- break;
- case ptFloatWidth:
- name = "Floating Width";
- break;
- case ptFloatHeight:
- name = "Floating Height";
- break;
- case ptMaxLines:
- name = "Max num of lines";
- break;
- case ptColumnWidth:
- name = "Column Width";
- break;
- case ptRowHeight:
- name = "Row Height";
- break;
- case ptOverflow:
- name = "Overflow Mode";
- break;
- case ptScaleTvX:
- name = "Scale TV Picture X";
- break;
- case ptScaleTvY:
- name = "Scale TV Picture Y";
- break;
- case ptScaleTvWidth:
- name = "Scale TV Picture Width";
- break;
- case ptScaleTvHeight:
- name = "Scale TV Picture Height";
- break;
- case ptHideRoot:
- name = "Hide Root View";
- break;
- case ptCache:
- name = "Cache Image";
- break;
- case ptDeterminateFont:
- name = "Determinate Font";
- break;
- case ptDirection:
- name = "Text Direction";
- break;
- case ptAnimType:
- name = "Animation Type";
- break;
- case ptAnimFreq:
- name = "Animation Frequency";
- break;
- default:
- name = "Unknown";
- break;
- };
- return name;
-}
-
-void cTemplateFunction::Debug(void) {
- esyslog("skindesigner: Debugging %s, Container: x = %d, y = %d, Size: %dx%d", GetFuncName().c_str(), containerX, containerY, containerWidth, containerHeight);
- esyslog("skindesigner: --- Native Parameters:");
-
- if (condParam) {
- condParam->Debug();
- }
- esyslog("skindesigner: --- Native Parameters:");
- for (map<eParamType,string>::iterator it = nativeParameters.begin(); it != nativeParameters.end(); it++) {
- esyslog("skindesigner: \"%s\" = \"%s\"", GetParamName(it->first).c_str(), (it->second).c_str());
- }
- if (numericParameters.size() > 0) {
- esyslog("skindesigner: --- Integer Parameters: ");
- for (map<eParamType,int>::iterator it = numericParameters.begin(); it != numericParameters.end(); it++) {
- esyslog("skindesigner: %s = %d", GetParamName(it->first).c_str(), it->second);
- }
- }
- if (numericDynamicParameters.size() > 0) {
- esyslog("skindesigner: --- Dynamic Integer Parameters: ");
- for (map<eParamType,string>::iterator it = numericDynamicParameters.begin(); it != numericDynamicParameters.end(); it++) {
- esyslog("skindesigner: %s = %s", GetParamName(it->first).c_str(), (it->second).c_str());
- }
- }
- if (colorParameters.size() > 0) {
- esyslog("skindesigner: --- Color Parameters:");
- for (map<eParamType,tColor>::iterator it = colorParameters.begin(); it != colorParameters.end(); it++) {
- esyslog("skindesigner: %s = %x", GetParamName(it->first).c_str(), it->second);
- }
- }
- if (textTokens.size() > 0) {
- esyslog("skindesigner: --- Text Tokens:");
- int i=0;
- for (vector<cTextToken>::iterator it = textTokens.begin(); it != textTokens.end(); it++) {
- eTextTokenType tokenType = (*it).type;
- string tokType = "";
- if (tokenType == ttConstString)
- tokType = "Const";
- else if (tokenType == ttToken)
- tokType = "Token";
- else if (tokenType == ttConditionalToken)
- tokType = "Conditional Token";
- else if (tokenType == ttPrintfToken)
- tokType = "PrintF Token";
- esyslog("skindesigner: Token %d Type %s : \"%s\"", i++, tokType.c_str(), (*it).value.c_str());
- if (tokenType == ttConditionalToken) {
- for (vector<cTextToken>::iterator it2 = (*it).subTokens.begin(); it2 != (*it).subTokens.end(); it2++) {
- eTextTokenType tokenTypeCond = (*it2).type;
- string tokTypeCond = "";
- if (tokenTypeCond == ttConstString)
- tokTypeCond = "Const: ";
- else if (tokenTypeCond == ttToken)
- tokTypeCond = "Token: ";
- esyslog("skindesigner: %s \"%s\"", tokTypeCond.c_str(), (*it2).value.c_str());
- }
- }
- if (tokenType == ttPrintfToken) {
- for (vector<string>::iterator it2 = (*it).parameters.begin(); it2 != (*it).parameters.end(); it2++) {
- esyslog("skindesigner: PrintF parameter: %s", (*it2).c_str());
- }
- }
- }
- }
- if (fontName.size() > 0) {
- esyslog("skindesigner: --- Font Name: \"%s\"", fontName.c_str());
- }
- if (parsedText.size() > 0) {
- esyslog("skindesigner: --- Parsed Text: \"%s\"", parsedText.c_str());
- }
- if (type == ftDrawText) {
- esyslog("skindesigner: --- Cutted Text: \"%s\"", cuttedText.c_str());
- esyslog("skindesigner: --- Parsed Text Width: %d", parsedTextWidth);
- esyslog("skindesigner: --- Already Cutted: %s", alreadyCutted ? "true" : "false");
- }
- if (imgPath.size() > 0) {
- esyslog("skindesigner: --- Image Path: \"%s\"", imgPath.c_str());
- }
-}
diff --git a/libtemplate/templatefunction.h b/libtemplate/templatefunction.h deleted file mode 100644 index d800c5f..0000000 --- a/libtemplate/templatefunction.h +++ /dev/null @@ -1,270 +0,0 @@ -#ifndef __TEMPLATEFUNCTION_H -#define __TEMPLATEFUNCTION_H - -#include <iostream> -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <string> -#include <vector> -#include <map> -#include <set> -#include <sstream> - -#include "globals.h" -#include "parameter.h" - -using namespace std; - -// --- cTemplateFunction ------------------------------------------------------------- - -enum eFuncType { - ftOsd, - ftView, - ftViewElement, - ftViewList, - ftPixmapContainer, - ftPixmap, - ftPixmapScroll, - ftLoop, - ftFill, - ftDrawText, - ftDrawTextBox, - ftDrawTextVertical, - ftDrawImage, - ftDrawRectangle, - ftDrawEllipse, - ftDrawSlope, - ftNone -}; - -enum eParamType { - ptCond, - ptName, - ptMode, - ptDrawDebugGrid, - ptDebugGridX, - ptDebugGridY, - ptX, - ptY, - ptWidth, - ptHeight, - ptMenuItemWidth, - ptDetached, - ptFadeTime, - ptShiftTime, - ptShiftType, - ptShiftMode, - ptStartX, - ptStartY, - ptDelay, - ptImageType, - ptPath, - ptColor, - ptFont, - ptFontSize, - ptText, - ptLayer, - ptTransparency, - ptBackground, - ptQuadrant, - ptType, - ptAlign, - ptValign, - ptScrollMode, - ptScrollSpeed, - ptOrientation, - ptNumElements, - ptScrollElement, - ptScrollHeight, - ptFloat, - ptFloatWidth, - ptFloatHeight, - ptMaxLines, - ptColumnWidth, - ptRowHeight, - ptOverflow, - ptScaleTvX, - ptScaleTvY, - ptScaleTvWidth, - ptScaleTvHeight, - ptHideRoot, - ptCache, - ptDeterminateFont, - ptDirection, - ptAnimType, - ptAnimFreq, - ptNone -}; - -enum eImageType { - itChannelLogo, - itSepLogo, - itSkinPart, - itMenuIcon, - itIcon, - itImage -}; - -enum eShiftType { - stNone, - stLeft, - stRight, - stTop, - stBottom -}; - -enum eShiftMode { - smLinear, - smSlowedDown -}; - -enum eAnimType { - atNone, - atBlink, - atAnimated -}; - -enum eFloatType { - flNone, - flTopLeft, - flTopRight -}; - -enum eOverflowType { - otNone, - otWrap, - otCut -}; - -enum eDirection { - diNone, - diBottomUp, - diTopDown -}; - -class cTemplateFunction { -protected: - eFuncType type; - bool debug; - int containerX; //X of parent container - int containerY; //Y of parent container - int containerWidth; //width of parent container - int containerHeight; //height of parent container - int columnWidth; //if func is executed in a loop, width of loop column - int rowHeight; //if func is executed in a loop, height of loop row - cGlobals *globals; //globals - map< eParamType, string > nativeParameters; //native parameters directly from xml - map< eParamType, int > numericParameters; //sucessfully parsed numeric parameters - map< eParamType, string > numericDynamicParameters; //numeric parameters with dynamic tokens - bool parsedCompletely; - bool updated; - map< eParamType, tColor > colorParameters; - cConditionalParameter *condParam; - //drawimage parameters - string imgPath; - //drawtext parameters - string fontName; - vector<cTextToken> textTokens; - string parsedText; - int parsedTextWidth; - string cuttedText; - bool alreadyCutted; - //drawtextbox parameters - int textboxHeight; - //dynamic tokens - map < string, string > *stringTokens; - map < string, int > *intTokens; - //private functions - bool SetCondition(string cond); - bool SetNumericParameter(eParamType type, string value); - bool SetAlign(eParamType type, string value); - bool SetFont(eParamType type, string value); - bool SetImageType(eParamType type, string value); - bool SetColor(eParamType type, string value); - bool SetTextTokens(string value); - void ParseTextToken(string &value, size_t start, size_t end); - void ParseConditionalTextToken(string &value, size_t start, size_t end); - void ParsePrintfTextToken(string &value, size_t start, size_t end); - bool SetScrollMode(string value); - bool SetScrollSpeed(string value); - bool SetOrientation(string value); - bool SetFloating(string value); - bool SetOverflow(string value); - bool SetHideRoot(string value); - bool SetDetached(string value); - bool SetBackground(string value); - bool SetDirection(string value); - bool SetAnimType(string value); - bool SetShiftType(string value); - bool SetShiftMode(string value); - void SetDebugGrid(string value); - void ParseStringParameters(void); - void ParseNumericalParameters(void); - void CalculateAlign(int elementWidth, int elementHeight); - int CalculateTextBoxHeight(void); - int ReplaceIntToken(string intTok); -public: - cTemplateFunction(eFuncType type); - virtual ~cTemplateFunction(void); - //Setter Functions - void SetParameters(vector<pair<string, string> > params); - void SetParameter(eParamType type, string value); - void SetContainer(int x, int y, int w, int h); - void SetLoopContainer(int columnWidth, int rowHeight); - void SetWidthManually(string width); - void SetHeightManually(string height); - void SetXManually(int newX); - void SetYManually(int newY); - void SetMaxTextWidth(int maxWidth); - void SetTextboxHeight(int boxHeight); - void SetGlobals(cGlobals *globals) { this->globals = globals; }; - void SetTranslatedText(string translation); - //PreCache Parameters - bool CalculateParameters(void); - //Complete Parameters - bool ReCalculateParameters(void); - void CompleteParameters(void); - //Set and Unset Dynamic Tokens from view - void SetStringTokens(map < string, string > *tok) { stringTokens = tok; }; - void SetIntTokens(map < string, int > *tok) { intTokens = tok; }; - void UnsetIntTokens(void) { intTokens = NULL; }; - void UnsetStringTokens(void) { stringTokens = NULL; }; - //Clear dynamically parameters - void ClearDynamicParameters(void); - //Parse parameters with dynamically set Tokens - bool ParseParameters(void); - //Getter Functions - eFuncType GetType(void) { return type; }; - bool DoDebug(void) { return debug; }; - string GetParameter(eParamType type); - int GetNumericParameter(eParamType type); - string GetText(bool cut = true); - string GetImagePath(void) { return imgPath; }; - tColor GetColorParameter(eParamType type); - string GetFontName(void) { return fontName; }; - string GetFuncName(void); - string GetParamName(eParamType pt); - //Dynamic width or height parameter - int GetWidth(bool cutted = true); - int GetHeight(map < string, vector< map< string, string > > > *loopTokens = NULL); - int GetContainerWidth(void) { return containerWidth; }; - int GetContainerHeight(void) { return containerHeight; }; - void GetNeededWidths(multimap<eParamType,string> *widths); - void GetNeededHeights(multimap<eParamType,string> *heights); - void GetNeededPosX(multimap<eParamType,string> *posXs); - void GetNeededPosY(multimap<eParamType,string> *posYs); - void SetWidth(eParamType type, string label, int funcWidth); - void SetHeight(eParamType type, string label, int funcHeight); - void SetX(eParamType type, string label, int funcX); - void SetY(eParamType type, string label, int funcY); - //Status Functions - bool ParsedCompletely(void) { return parsedCompletely; }; - bool DoExecute(void); - bool Updated(void) { return updated; }; - bool IsAnimated(void); - //Debug - void Debug(void); -}; - -#endif //__TEMPLATEFUNCTION_H
\ No newline at end of file diff --git a/libtemplate/templateloopfunction.c b/libtemplate/templateloopfunction.c deleted file mode 100644 index 07219ac..0000000 --- a/libtemplate/templateloopfunction.c +++ /dev/null @@ -1,248 +0,0 @@ -#include "templateloopfunction.h" -#include "../libcore/helpers.h" - -using namespace std; - -// --- cTemplateFunction ------------------------------------------------------------- - -cTemplateLoopFunction::cTemplateLoopFunction(void) : cTemplateFunction(ftLoop) { -} - -cTemplateLoopFunction::~cTemplateLoopFunction(void) { -} - -void cTemplateLoopFunction::InitIterator(void) { - funcIt = functions.begin(); -} - -void cTemplateLoopFunction::AddFunction(string name, vector<pair<string, string> > ¶ms) { - eFuncType type = ftNone; - - if (!name.compare("drawtext")) { - type = ftDrawText; - } else if (!name.compare("drawtextbox")) { - type = ftDrawTextBox; - } else if (!name.compare("drawimage")) { - type = ftDrawImage; - } else if (!name.compare("drawrectangle")) { - type = ftDrawRectangle; - } else if (!name.compare("drawellipse")) { - type = ftDrawEllipse; - } - - if (type == ftNone) { - return; - } - - cTemplateFunction *f = new cTemplateFunction(type); - f->SetParameters(params); - functions.push_back(f); -} - -void cTemplateLoopFunction::CalculateLoopFuncParameters(void) { - int columnWidth = GetNumericParameter(ptColumnWidth); - int rowHeight = GetNumericParameter(ptRowHeight); - for (vector<cTemplateFunction*>::iterator func = functions.begin(); func != functions.end(); func++) { - (*func)->SetGlobals(globals); - (*func)->SetContainer(0, 0, containerWidth, containerHeight); - (*func)->SetLoopContainer(columnWidth, rowHeight); - (*func)->CalculateParameters(); - (*func)->CompleteParameters(); - } -} - -cTemplateFunction *cTemplateLoopFunction::GetNextFunction(void) { - if (funcIt == functions.end()) - return NULL; - cTemplateFunction *func = *funcIt; - funcIt++; - return func; -} - -void cTemplateLoopFunction::ClearDynamicParameters(void) { - InitIterator(); - cTemplateFunction *func = NULL; - while(func = GetNextFunction()) { - func->ClearDynamicParameters(); - } -} - -void cTemplateLoopFunction::ParseDynamicParameters(map <string,string> *tokens) { - if (!tokens) - return; - InitIterator(); - cTemplateFunction *func = NULL; - - map <string,int> intTokens; - for (map <string,string>::iterator it = tokens->begin(); it != tokens->end(); it++) { - if (isNumber(it->second)) - intTokens.insert(pair<string, int>(it->first, atoi((it->second).c_str()))); - } - - bool completelyParsed = true; - while(func = GetNextFunction()) { - func->SetStringTokens(tokens); - func->SetIntTokens(&intTokens); - bool funcCompletelyParsed = func->ParseParameters(); - if (!funcCompletelyParsed) - completelyParsed = false; - if (func->Updated()) - func->CompleteParameters(); - func->UnsetStringTokens(); - func->UnsetIntTokens(); - } - if (completelyParsed) { - return; - } - - bool replacedWidth = ReplaceWidthFunctions(); - bool replacedHeight = ReplaceHeightFunctions(); - - if (!replacedWidth && !replacedHeight) - return; - - InitIterator(); - func = NULL; - while(func = GetNextFunction()) { - if (func->ParsedCompletely()) - continue; - func->SetStringTokens(tokens); - func->SetIntTokens(&intTokens); - func->ParseParameters(); - if (func->Updated()) - func->CompleteParameters(); - func->UnsetIntTokens(); - func->UnsetStringTokens(); - } -} - -int cTemplateLoopFunction::GetLoopElementsWidth(void) { - int cW = GetNumericParameter(ptColumnWidth); - if (cW > 0) { - return cW; - } - InitIterator(); - cTemplateFunction *func = NULL; - int maxWidth = 1; - while(func = GetNextFunction()) { - int funcWidth = func->GetWidth(true); - if (funcWidth > maxWidth) - maxWidth = funcWidth; - } - return maxWidth; -} - -int cTemplateLoopFunction::GetLoopElementsHeight(void) { - int rH = GetNumericParameter(ptRowHeight); - if (rH > 0) - return rH; - InitIterator(); - cTemplateFunction *func = NULL; - int maxHeight = 1; - while(func = GetNextFunction()) { - int funcY = func->GetNumericParameter(ptY); - int funcHeight = func->GetHeight(); - int totalHeight = funcY + funcHeight; - if (totalHeight > maxHeight) - maxHeight = totalHeight; - } - return maxHeight; -} - -int cTemplateLoopFunction::CalculateHeight(map < string, vector< map< string, string > > > *loopTokens) { - if (!loopTokens) { - return 0; - } - int rowHeight = GetLoopElementsHeight(); - string loopName = GetParameter(ptName); - map < string, vector< map< string, string > > >::iterator hit = loopTokens->find(loopName); - if (hit == loopTokens->end()) - return 0; - vector< map< string, string > > toks = hit->second; - int numElements = toks.size(); - - return numElements * rowHeight; -} - -bool cTemplateLoopFunction::ReplaceWidthFunctions(void) { - bool replaced = false; - InitIterator(); - cTemplateFunction *func = NULL; - while(func = GetNextFunction()) { - if (func->ParsedCompletely()) { - continue; - } - multimap<eParamType,string> widths; - func->GetNeededWidths(&widths); - for (map<eParamType, string>::iterator names = widths.begin(); names !=widths.end(); names++) { - eParamType type = names->first; - string label = names->second; - int funcWidth = 0; - for (vector<cTemplateFunction*>::iterator it = functions.begin(); it != functions.end(); it++) { - cTemplateFunction *myFunc = *it; - string myFuncName = myFunc->GetParameter(ptName); - if (!myFuncName.compare(label)) { - funcWidth = myFunc->GetWidth(); - func->SetWidth(type, label, funcWidth); - if (func->Updated()) { - func->CompleteParameters(); - } else { - replaced = true; - } - } - } - } - } - return replaced; -} - -bool cTemplateLoopFunction::ReplaceHeightFunctions(void) { - bool replaced = false; - InitIterator(); - cTemplateFunction *func = NULL; - while(func = GetNextFunction()) { - if (func->ParsedCompletely()) { - continue; - } - multimap<eParamType,string> heights; - func->GetNeededHeights(&heights); - for (map<eParamType, string>::iterator names = heights.begin(); names !=heights.end(); names++) { - eParamType type = names->first; - string label = names->second; - int funcHeight = 0; - for (vector<cTemplateFunction*>::iterator it = functions.begin(); it != functions.end(); it++) { - cTemplateFunction *myFunc = *it; - string myFuncName = myFunc->GetParameter(ptName); - if (!myFuncName.compare(label)) { - funcHeight = myFunc->GetHeight(); - func->SetHeight(type, label, funcHeight); - if (func->Updated()) { - func->CompleteParameters(); - } else { - replaced = true; - } - } - } - } - } - return replaced; -} - -bool cTemplateLoopFunction::Ready(void) { - bool isReady = true; - map< eParamType, string >::iterator hit = numericDynamicParameters.find(ptColumnWidth); - if (hit != numericDynamicParameters.end()) - isReady = false; - hit = numericDynamicParameters.find(ptRowHeight); - if (hit != numericDynamicParameters.end()) - isReady = false; - return isReady; -} - -void cTemplateLoopFunction::Debug(void) { - cTemplateFunction::Debug(); - esyslog("skindesigner: functions to be looped:"); - for (vector<cTemplateFunction*>::iterator func = functions.begin(); func != functions.end(); func++) { - (*func)->Debug(); - } -}
\ No newline at end of file diff --git a/libtemplate/templateloopfunction.h b/libtemplate/templateloopfunction.h deleted file mode 100644 index 1a28c65..0000000 --- a/libtemplate/templateloopfunction.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef __TEMPLATELOOPFUNCTION_H -#define __TEMPLATELOOPFUNCTION_H - -#include "templatefunction.h" - -using namespace std; - -// --- cTemplateLoopFunction ------------------------------------------------------------- - -class cTemplateLoopFunction : public cTemplateFunction { -private: - vector<cTemplateFunction*> functions; - vector<cTemplateFunction*>::iterator funcIt; - bool ReplaceWidthFunctions(void); - bool ReplaceHeightFunctions(void); -public: - cTemplateLoopFunction(void); - virtual ~cTemplateLoopFunction(void); - void AddFunction(string name, vector<pair<string, string> > ¶ms); - void CalculateLoopFuncParameters(void); - void InitIterator(void); - cTemplateFunction *GetNextFunction(void); - void ClearDynamicParameters(void); - void ParseDynamicParameters(map <string,string> *tokens); - int GetLoopElementsWidth(void); - int GetLoopElementsHeight(void); - int GetContainerWidth(void) { return containerWidth; }; - int GetContainerHeight(void) { return containerHeight; }; - int CalculateHeight(map < string, vector< map< string, string > > > *loopTokens); - bool Ready(void); - void Debug(void); -}; - -#endif //__TEMPLATELOOPFUNCTION_H diff --git a/libtemplate/templatepixmap.c b/libtemplate/templatepixmap.c deleted file mode 100644 index 117ab25..0000000 --- a/libtemplate/templatepixmap.c +++ /dev/null @@ -1,739 +0,0 @@ -#include "templatepixmap.h"
-
-using namespace std;
-// --- cTemplatePixmapNode -------------------------------------------------------------
-
-cTemplatePixmapNode::cTemplatePixmapNode(void) {
- parameters = NULL;
- globals = NULL;
- containerX = 0;
- containerY = 0;
- containerWidth = 0;
- containerHeight = 0;
-}
-
-cTemplatePixmapNode::~cTemplatePixmapNode() {
- if (parameters)
- delete parameters;
-}
-
-void cTemplatePixmapNode::SetParameters(vector<stringpair> ¶ms) {
- parameters = new cTemplateFunction(isContainer?ftPixmapContainer:ftPixmap);
- parameters->SetGlobals(globals);
- parameters->SetParameters(params);
-}
-
-void cTemplatePixmapNode::SetContainer(int x, int y, int w, int h) {
- containerX = x;
- containerY = y;
- containerWidth = w;
- containerHeight = h;
-}
-
-// --- cTemplatePixmap -------------------------------------------------------------
-
-cTemplatePixmap::cTemplatePixmap(void) {
- pixContainer = NULL;
- isContainer = false;
- scrolling = false;
- background = false;
-}
-
-cTemplatePixmap::~cTemplatePixmap() {
- for (vector<cTemplateFunction*>::iterator it = functions.begin(); it != functions.end(); it++) {
- delete (*it);
- }
-}
-
-void cTemplatePixmap::SetWidth(int width) {
- cString pWidth = cString::sprintf("%d", width);
- parameters->SetWidthManually(*pWidth);
-}
-
-void cTemplatePixmap::SetHeight(int height) {
- cString pHeight = cString::sprintf("%d", height);
- parameters->SetHeightManually(*pHeight);
-}
-
-void cTemplatePixmap::SetX(int x) {
- parameters->SetXManually(x);
-}
-
-void cTemplatePixmap::SetY(int y) {
- parameters->SetYManually(y);
-}
-
-void cTemplatePixmap::SetWidthPercent(double width) {
- int absWidth = containerWidth * width;
- cString pWidth = cString::sprintf("%d", absWidth);
- parameters->SetWidthManually(*pWidth);
-}
-
-void cTemplatePixmap::SetHeightPercent(double height) {
- int absHeight = containerHeight * height;
- cString pHeight = cString::sprintf("%d", absHeight);
- parameters->SetHeightManually(*pHeight);
-}
-
-void cTemplatePixmap::SetXPercent(double x) {
- int absX = containerX + containerWidth * x;
- parameters->SetXManually(absX);
-}
-
-void cTemplatePixmap::SetYPercent(double y) {
- int absY = containerY + containerHeight * y;
- parameters->SetYManually(absY);
-}
-
-void cTemplatePixmap::SetParameter(eParamType type, string value) {
- parameters->SetParameter(type, value);
-}
-
-
-void cTemplatePixmap::ClearDynamicParameters(void) {
- parameters->ClearDynamicParameters();
-}
-
-void cTemplatePixmap::ParseDynamicParameters(map <string,string> *stringTokens, map <string,int> *intTokens, bool initFuncs) {
- parameters->ClearDynamicParameters();
- parameters->SetIntTokens(intTokens);
- parameters->SetStringTokens(stringTokens);
- parameters->ParseParameters();
- parameters->UnsetIntTokens();
- parameters->UnsetStringTokens();
-
- if (!DoExecute()) {
- parameters->ClearDynamicParameters();
- return;
- }
-
- if (!initFuncs || !Ready())
- return;
-
- int x = parameters->GetNumericParameter(ptX);
- int y = parameters->GetNumericParameter(ptY);
- int width = parameters->GetNumericParameter(ptWidth);
- int height = parameters->GetNumericParameter(ptHeight);
-
- for (vector<cTemplateFunction*>::iterator func = functions.begin(); func != functions.end(); func++) {
- (*func)->SetContainer(x, y, width, height);
- (*func)->ReCalculateParameters();
- (*func)->CompleteParameters();
- if ((*func)->GetType() == ftLoop) {
- cTemplateLoopFunction *loopFunc = dynamic_cast<cTemplateLoopFunction*>(*func);
- if (!loopFunc->Ready()) {
- loopFunc->CalculateParameters();
- loopFunc->SetIntTokens(intTokens);
- loopFunc->ParseParameters();
- loopFunc->UnsetIntTokens();
- }
- loopFunc->CalculateLoopFuncParameters();
- }
- }
-}
-
-void cTemplatePixmap::AddFunction(string name, vector<pair<string, string> > ¶ms) {
- eFuncType type = ftNone;
-
- if (!name.compare("fill")) {
- type = ftFill;
- } else if (!name.compare("drawtext")) {
- type = ftDrawText;
- } else if (!name.compare("drawtextbox")) {
- type = ftDrawTextBox;
- } else if (!name.compare("drawtextvertical")) {
- type = ftDrawTextVertical;
- } else if (!name.compare("drawimage")) {
- type = ftDrawImage;
- } else if (!name.compare("drawrectangle")) {
- type = ftDrawRectangle;
- } else if (!name.compare("drawellipse")) {
- type = ftDrawEllipse;
- } else if (!name.compare("drawslope")) {
- type = ftDrawSlope;
- }
-
- if (type == ftNone) {
- return;
- }
-
- cTemplateFunction *f = new cTemplateFunction(type);
- f->SetParameters(params);
- functions.push_back(f);
-}
-
-void cTemplatePixmap::AddLoopFunction(cTemplateLoopFunction *lf) {
- functions.push_back(lf);
-}
-
-
-bool cTemplatePixmap::CalculateParameters(void) {
- bool paramsValid = true;
- //Calculate Pixmap Size
- parameters->SetContainer(containerX, containerY, containerWidth, containerHeight);
- parameters->SetGlobals(globals);
- paramsValid = parameters->CalculateParameters();
-
- int pixWidth = parameters->GetNumericParameter(ptWidth);
- int pixHeight = parameters->GetNumericParameter(ptHeight);
-
- for (vector<cTemplateFunction*>::iterator func = functions.begin(); func != functions.end(); func++) {
- (*func)->SetGlobals(globals);
- (*func)->SetContainer(0, 0, pixWidth, pixHeight);
- paramsValid = (*func)->CalculateParameters();
- (*func)->CompleteParameters();
- if ((*func)->GetType() == ftLoop) {
- cTemplateLoopFunction *loopFunc = dynamic_cast<cTemplateLoopFunction*>(*func);
- loopFunc->CalculateLoopFuncParameters();
- }
- }
-
- background = parameters->GetNumericParameter(ptBackground);
-
- return paramsValid;
-}
-
-void cTemplatePixmap::ClearDynamicFunctionParameters(void) {
- InitFunctionIterator();
- cTemplateFunction *func = NULL;
- while(func = GetNextFunction()) {
- func->ClearDynamicParameters();
- }
-}
-
-void cTemplatePixmap::ParseDynamicFunctionParameters(map <string,string> *stringTokens, map <string,int> *intTokens, map < string, vector< map< string, string > > > *loopTokens) {
- InitFunctionIterator();
- cTemplateFunction *func = NULL;
- bool completelyParsed = true;
- while(func = GetNextFunction()) {
- func->SetStringTokens(stringTokens);
- func->SetIntTokens(intTokens);
- bool funcCompletelyParsed = func->ParseParameters();
- if (!funcCompletelyParsed)
- completelyParsed = false;
- if (func->Updated())
- func->CompleteParameters();
- func->UnsetIntTokens();
- func->UnsetStringTokens();
- }
-
- if (completelyParsed) {
- return;
- }
-
- bool replacedWidth = ReplaceWidthFunctions();
- bool replacedHeight = ReplaceHeightFunctions(loopTokens);
- bool replacedPosX = ReplacePosXFunctions();
- bool replacedPosY = ReplacePosYFunctions();
-
- if (!replacedWidth && !replacedHeight && !replacedPosX && !replacedPosY)
- return;
-
- InitFunctionIterator();
- func = NULL;
- while(func = GetNextFunction()) {
- if (func->ParsedCompletely())
- continue;
- func->SetStringTokens(stringTokens);
- func->SetIntTokens(intTokens);
- func->ParseParameters();
- if (func->Updated())
- func->CompleteParameters();
- func->UnsetIntTokens();
- func->UnsetStringTokens();
- }
-}
-
-bool cTemplatePixmap::CalculateDrawPortSize(cSize &size, map < string, vector< map< string, string > > > *loopTokens) {
- int pixWidth = parameters->GetNumericParameter(ptWidth);
- int pixHeight = parameters->GetNumericParameter(ptHeight);
- int orientation = parameters->GetNumericParameter(ptOrientation);
- if (orientation < 0)
- orientation = orVertical;
- if (orientation == orHorizontal) {
- //get function which determinates drawport width
- cTemplateFunction *scrollFunc = GetScrollFunction();
- if (!scrollFunc)
- return false;
- int drawportWidth = scrollFunc->GetWidth(false) + scrollFunc->GetNumericParameter(ptX) + 10;
- if (drawportWidth > pixWidth) {
- size.SetWidth(drawportWidth);
- size.SetHeight(pixHeight);
- return true;
- }
- } else if (orientation == orVertical) {
- //check "last" element height
- InitFunctionIterator();
- cTemplateFunction *f = NULL;
- int drawportHeight = 1;
- while (f = GetNextFunction()) {
- if (f->GetType() == ftLoop) {
- cTemplateLoopFunction *loopFunc = dynamic_cast<cTemplateLoopFunction*>(f);
- //get number of loop tokens
- string loopTokenName = loopFunc->GetParameter(ptName);
- int numLoopTokens = 0;
- map < string, vector< map< string, string > > >::iterator hit = loopTokens->find(loopTokenName);
- if (hit != loopTokens->end()) {
- vector< map<string,string> > loopToken = hit->second;
- numLoopTokens = loopToken.size();
- //parse first loop token element to get correct height
- vector< map<string,string> >::iterator firstLoopToken = loopToken.begin();
- loopFunc->ClearDynamicParameters();
- loopFunc->ParseDynamicParameters(&(*firstLoopToken));
- }
- int orientation = loopFunc->GetNumericParameter(ptOrientation);
- int yFunc = loopFunc->GetNumericParameter(ptY);
- int heightFunc = loopFunc->GetLoopElementsHeight();
- if (loopTokens && orientation == orVertical) {
- //height is height of loop elements times num loop elements
- heightFunc = heightFunc * numLoopTokens;
- } else if (loopTokens && orientation == orHorizontal) {
- int overflow = loopFunc->GetNumericParameter(ptOverflow);
- if (overflow == otCut) {
- //do nothing, height is only height of one line
- } else if (overflow == otWrap) {
- int widthFunc = loopFunc->GetLoopElementsWidth();
- if (widthFunc <= 0)
- continue;
- int loopWidth = loopFunc->GetNumericParameter(ptWidth);
- if (loopWidth <= 0)
- loopWidth = loopFunc->GetContainerWidth();
- int elementsPerRow = loopWidth / widthFunc;
- int rest = loopWidth % widthFunc;
- if (rest > 0)
- elementsPerRow++;
- if (elementsPerRow <= 0)
- continue;
- int lines = numLoopTokens / elementsPerRow;
- rest = numLoopTokens % elementsPerRow;
- if (rest > 0)
- lines++;
- heightFunc = heightFunc * lines;
- }
- }
- int neededHeight = heightFunc + yFunc;
- if (neededHeight > drawportHeight)
- drawportHeight = neededHeight;
- } else {
- int yFunc = f->GetNumericParameter(ptY);
- int heightFunc = f->GetHeight();
- int neededHeight = heightFunc + yFunc;
- if (neededHeight > drawportHeight)
- drawportHeight = neededHeight;
- }
- }
- if (drawportHeight > pixHeight) {
- size.SetWidth(pixWidth);
- size.SetHeight(drawportHeight);
- return true;
- }
- }
- size.SetWidth(0);
- size.SetHeight(0);
- return false;
-}
-
-void cTemplatePixmap::SetScrollingTextWidth(void) {
- int orientation = parameters->GetNumericParameter(ptOrientation);
- if (orientation != orHorizontal)
- return;
- int pixWidth = parameters->GetNumericParameter(ptWidth);
- InitFunctionIterator();
- cTemplateFunction *func = NULL;
- while(func = GetNextFunction()) {
- if (func->GetType() == ftDrawText) {
- int offset = func->GetNumericParameter(ptX);
- func->SetMaxTextWidth(pixWidth - offset);
- }
- }
-}
-
-
-cTemplateFunction *cTemplatePixmap::GetScrollFunction(void) {
- string scrollElement = parameters->GetParameter(ptScrollElement);
- if (scrollElement.size() == 0)
- return NULL;
- InitFunctionIterator();
- cTemplateFunction *f = NULL;
- while (f = GetNextFunction()) {
- string funcName = f->GetParameter(ptName);
- if (!funcName.compare(scrollElement)) {
- return f;
- }
- }
- return NULL;
-}
-
-cRect cTemplatePixmap::GetPixmapSize(void) {
- cRect size;
- size.SetX(GetNumericParameter(ptX));
- size.SetY(GetNumericParameter(ptY));
- size.SetWidth(GetNumericParameter(ptWidth));
- size.SetHeight(GetNumericParameter(ptHeight));
- return size;
-}
-
-int cTemplatePixmap::GetNumericParameter(eParamType type) {
- if (!parameters)
- return -1;
- return parameters->GetNumericParameter(type);
-}
-
-void cTemplatePixmap::InitFunctionIterator(void) {
- funcIt = functions.begin();
-}
-
-cTemplateFunction *cTemplatePixmap::GetNextFunction(void) {
- if (funcIt == functions.end())
- return NULL;
- cTemplateFunction *func = *funcIt;
- funcIt++;
- return func;
-}
-
-bool cTemplatePixmap::Ready(void) {
- int myX = parameters->GetNumericParameter(ptX);
- if (myX < 0)
- return false;
- int myY = parameters->GetNumericParameter(ptY);
- if (myY < 0)
- return false;
- int myWidth = parameters->GetNumericParameter(ptWidth);
- if (myWidth < 1)
- return false;
- int myHeight = parameters->GetNumericParameter(ptHeight);
- if (myHeight < 1)
- return false;
- return true;
-}
-
-bool cTemplatePixmap::ParameterSet(eParamType type) {
- string value = parameters->GetParameter(type);
- if (value.size() > 0)
- return true;
- return false;
-}
-
-cTemplateFunction *cTemplatePixmap::GetFunction(string name) {
- for (vector<cTemplateFunction*>::iterator it = functions.begin(); it != functions.end(); it++) {
- string funcName = (*it)->GetParameter(ptName);
- if (!name.compare(funcName))
- return *it;
- }
- return NULL;
-}
-
-bool cTemplatePixmap::ReplaceWidthFunctions(void) {
- bool replaced = false;
- bool found = false;
- InitFunctionIterator();
- cTemplateFunction *func = NULL;
- while(func = GetNextFunction()) {
- if (func->ParsedCompletely()) {
- continue;
- }
- multimap<eParamType,string> widths;
- func->GetNeededWidths(&widths);
- for (map<eParamType, string>::iterator names = widths.begin(); names !=widths.end(); names++) {
- eParamType type = names->first;
- string label = names->second;
- int funcWidth = 0;
- for (vector<cTemplateFunction*>::iterator it = functions.begin(); it != functions.end(); it++) {
- cTemplateFunction *myFunc = *it;
- string myFuncName = myFunc->GetParameter(ptName);
- if (!myFuncName.compare(label)) {
- found = true;
- funcWidth = myFunc->GetWidth();
- func->SetWidth(type, label, funcWidth);
- if (func->Updated()) {
- func->CompleteParameters();
- } else {
- replaced = true;
- }
- break;
- }
- }
- if (!found && pixContainer) {
- cTemplateFunction *myFunc = pixContainer->GetFunction(label);
- if (myFunc) {
- funcWidth = myFunc->GetWidth();
- func->SetWidth(type, label, funcWidth);
- if (func->Updated()) {
- func->CompleteParameters();
- } else {
- replaced = true;
- }
- break;
- }
- }
- }
- }
- return replaced;
-}
-
-bool cTemplatePixmap::ReplaceHeightFunctions(map < string, vector< map< string, string > > > *loopTokens) {
- bool replaced = false;
- bool found = false;
- InitFunctionIterator();
- cTemplateFunction *func = NULL;
- while(func = GetNextFunction()) {
- if (func->ParsedCompletely()) {
- continue;
- }
- multimap<eParamType,string> heights;
- func->GetNeededHeights(&heights);
- for (map<eParamType, string>::iterator names = heights.begin(); names !=heights.end(); names++) {
- eParamType type = names->first;
- string label = names->second;
- int funcHeight = 0;
- for (vector<cTemplateFunction*>::iterator it = functions.begin(); it != functions.end(); it++) {
- cTemplateFunction *myFunc = *it;
- string myFuncName = myFunc->GetParameter(ptName);
- if (!myFuncName.compare(label)) {
- found = true;
- funcHeight = myFunc->GetHeight(loopTokens);
- func->SetHeight(type, label, funcHeight);
- if (func->Updated()) {
- func->CompleteParameters();
- } else {
- replaced = true;
- }
- break;
- }
- }
- if (!found && pixContainer) {
- cTemplateFunction *myFunc = pixContainer->GetFunction(label);
- if (myFunc) {
- funcHeight = myFunc->GetHeight(loopTokens);
- func->SetHeight(type, label, funcHeight);
- if (func->Updated()) {
- func->CompleteParameters();
- } else {
- replaced = true;
- }
- break;
- }
- }
- }
- }
- return replaced;
-}
-
-bool cTemplatePixmap::ReplacePosXFunctions(void) {
- bool replaced = false;
- bool found = false;
- InitFunctionIterator();
- cTemplateFunction *func = NULL;
- while(func = GetNextFunction()) {
- if (func->ParsedCompletely()) {
- continue;
- }
- multimap<eParamType,string> posXs;
- func->GetNeededPosX(&posXs);
- for (map<eParamType, string>::iterator names = posXs.begin(); names !=posXs.end(); names++) {
- eParamType type = names->first;
- string label = names->second;
- int funcX = 0;
- for (vector<cTemplateFunction*>::iterator it = functions.begin(); it != functions.end(); it++) {
- cTemplateFunction *myFunc = *it;
- string myFuncName = myFunc->GetParameter(ptName);
- if (!myFuncName.compare(label)) {
- found = true;
- funcX = myFunc->GetNumericParameter(ptX);
- if (funcX > -1) {
- func->SetX(type, label, funcX);
- if (func->Updated()) {
- func->CompleteParameters();
- } else {
- replaced = true;
- }
- }
- break;
- }
- }
- if (!found && pixContainer) {
- cTemplateFunction *myFunc = pixContainer->GetFunction(label);
- if (myFunc) {
- funcX = myFunc->GetNumericParameter(ptX);
- if (funcX > -1) {
- func->SetX(type, label, funcX);
- if (func->Updated()) {
- func->CompleteParameters();
- } else {
- replaced = true;
- }
- }
- break;
- }
- }
- }
- }
- return replaced;
-}
-
-bool cTemplatePixmap::ReplacePosYFunctions(void) {
- bool replaced = false;
- bool found = false;
- InitFunctionIterator();
- cTemplateFunction *func = NULL;
- while(func = GetNextFunction()) {
- if (func->ParsedCompletely()) {
- continue;
- }
- multimap<eParamType,string> posYs;
- func->GetNeededPosY(&posYs);
- for (map<eParamType, string>::iterator names = posYs.begin(); names !=posYs.end(); names++) {
- eParamType type = names->first;
- string label = names->second;
- int funcY = 0;
- for (vector<cTemplateFunction*>::iterator it = functions.begin(); it != functions.end(); it++) {
- cTemplateFunction *myFunc = *it;
- string myFuncName = myFunc->GetParameter(ptName);
- if (!myFuncName.compare(label)) {
- found = true;
- funcY = myFunc->GetNumericParameter(ptY);
- if (funcY > -1) {
- func->SetY(type, label, funcY);
- if (func->Updated()) {
- func->CompleteParameters();
- } else {
- replaced = true;
- }
- }
- break;
- }
- }
- if (!found && pixContainer) {
- cTemplateFunction *myFunc = pixContainer->GetFunction(label);
- if (myFunc) {
- funcY = myFunc->GetNumericParameter(ptY);
- if (funcY > -1) {
- func->SetY(type, label, funcY);
- if (func->Updated()) {
- func->CompleteParameters();
- } else {
- replaced = true;
- }
- }
- break;
- }
- }
- }
- }
- return replaced;
-}
-
-void cTemplatePixmap::Debug(void) {
- esyslog("skindesigner: pixmap container size x: %d, y: %d, width: %d, height %d", containerX, containerY, containerWidth, containerHeight);
- parameters->Debug();
- for (vector<cTemplateFunction*>::iterator it = functions.begin(); it != functions.end(); it++) {
- (*it)->Debug();
- }
-}
-
-// --- cTemplatePixmapContainer -------------------------------------------------------------
-
-cTemplatePixmapContainer::cTemplatePixmapContainer(void) {
- isContainer = true;
-}
-
-cTemplatePixmapContainer::~cTemplatePixmapContainer() {
- for (vector<cTemplatePixmap*>::iterator it = pixmaps.begin(); it != pixmaps.end(); it++) {
- delete (*it);
- }
-}
-
-void cTemplatePixmapContainer::SetGlobals(cGlobals *globals) {
- this->globals = globals;
- for (vector<cTemplatePixmap*>::iterator it = pixmaps.begin(); it != pixmaps.end(); it++) {
- (*it)->SetGlobals(globals);
- }
-}
-
-void cTemplatePixmapContainer::SetWidth(int width) {
- for (vector<cTemplatePixmap*>::iterator it = pixmaps.begin(); it != pixmaps.end(); it++) {
- (*it)->SetWidth(width);
- }
-}
-
-void cTemplatePixmapContainer::SetHeight(int height) {
- for (vector<cTemplatePixmap*>::iterator it = pixmaps.begin(); it != pixmaps.end(); it++) {
- (*it)->SetHeight(height);
- }
-}
-
-void cTemplatePixmapContainer::AddPixmap(cTemplatePixmap *pix) {
- //setting default parameters of container if parameter is not set in area
- string containerDefaultX = parameters->GetParameter(ptX);
- string containerDefaultY = parameters->GetParameter(ptY);
- string containerDefaultWidth = parameters->GetParameter(ptWidth);
- string containerDefaultHeight = parameters->GetParameter(ptHeight);
- if (containerDefaultX.size() > 0 && !pix->ParameterSet(ptX))
- pix->SetParameter(ptX, containerDefaultX);
- if (containerDefaultY.size() > 0 && !pix->ParameterSet(ptY))
- pix->SetParameter(ptY, containerDefaultY);
- if (containerDefaultWidth.size() > 0 && !pix->ParameterSet(ptWidth))
- pix->SetParameter(ptWidth, containerDefaultWidth);
- if (containerDefaultHeight.size() > 0 && !pix->ParameterSet(ptHeight))
- pix->SetParameter(ptHeight, containerDefaultHeight);
-
- pix->SetPixmapContainer(this);
- pixmaps.push_back(pix);
-}
-
-bool cTemplatePixmapContainer::CalculateParameters(void) {
- bool paramsValid = true;
- //Calculate Pixmap Size
- parameters->SetContainer(containerX, containerY, containerWidth, containerHeight);
- parameters->SetGlobals(globals);
- paramsValid = parameters->CalculateParameters();
-
- for (vector<cTemplatePixmap*>::iterator it = pixmaps.begin(); it != pixmaps.end(); it++) {
- (*it)->SetContainer(containerX, containerY, containerWidth, containerHeight);
- (*it)->SetGlobals(globals);
- paramsValid = (*it)->CalculateParameters() && paramsValid;
- }
-
- return paramsValid;
-}
-
-void cTemplatePixmapContainer::ParseDynamicParameters(map <string,string> *stringTokens, map <string,int> *intTokens) {
- parameters->ClearDynamicParameters();
- parameters->SetIntTokens(intTokens);
- parameters->SetStringTokens(stringTokens);
- parameters->ParseParameters();
- parameters->UnsetIntTokens();
- parameters->UnsetStringTokens();
-}
-
-void cTemplatePixmapContainer::InitIterator(void) {
- pixmapIterator = pixmaps.begin();
-}
-
-cTemplatePixmap *cTemplatePixmapContainer::GetNextPixmap(void) {
- if (pixmapIterator == pixmaps.end())
- return NULL;
- cTemplatePixmap *pix = *pixmapIterator;
- pixmapIterator++;
- return pix;
-}
-
-cTemplateFunction *cTemplatePixmapContainer::GetFunction(string name) {
- cTemplateFunction *hit = NULL;
- for (vector<cTemplatePixmap*>::iterator it = pixmaps.begin(); it != pixmaps.end(); it++) {
- hit = (*it)->GetFunction(name);
- if (hit)
- return hit;
- }
- return NULL;
-}
-
-
-void cTemplatePixmapContainer::Debug(void) {
- esyslog("skindesigner: pixmapcontainer");
- parameters->Debug();
- for (vector<cTemplatePixmap*>::iterator it = pixmaps.begin(); it != pixmaps.end(); it++) {
- (*it)->Debug();
- }
-}
-
diff --git a/libtemplate/templatepixmap.h b/libtemplate/templatepixmap.h deleted file mode 100644 index f9c2f6f..0000000 --- a/libtemplate/templatepixmap.h +++ /dev/null @@ -1,132 +0,0 @@ -#ifndef __TEMPLATEPIXMAP_H -#define __TEMPLATEPIXMAP_H - -#include <iostream> -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <string> -#include <vector> -#include <map> -#include <set> -#include <sstream> - -#include "globals.h" -#include "templateloopfunction.h" -#include "../views/viewhelpers.h" - -using namespace std; - -// --- cTemplatePixmapNode ------------------------------------------------------------- -class cTemplatePixmapNode { -protected: - bool isContainer; - cGlobals *globals; - cTemplateFunction *parameters; - int containerX; - int containerY; - int containerWidth; - int containerHeight; -public: - cTemplatePixmapNode(void); - virtual ~cTemplatePixmapNode(void); - void SetParameters(vector<stringpair> ¶ms); - void SetContainer(int x, int y, int w, int h); - bool IsContainer(void) { return isContainer; }; - bool DoExecute(void) { return parameters->DoExecute(); }; - bool DoDebug(void) { return parameters->DoDebug(); }; - virtual void SetGlobals(cGlobals *globals) { this->globals = globals; }; - virtual bool CalculateParameters(void) { return false; }; - virtual void SetWidth(int width) {}; - virtual void SetHeight(int height) {}; - virtual int NumPixmaps(void) { return 0; }; - virtual void Debug(void) {}; -}; - -// --- cTemplatePixmap ------------------------------------------------------------- -class cTemplatePixmapContainer; - -class cTemplatePixmap : public cTemplatePixmapNode { -protected: - cTemplatePixmapContainer *pixContainer; - bool scrolling; - bool background; - vector<cTemplateFunction*> functions; - vector<cTemplateFunction*>::iterator funcIt; - //functions replacing {width(label)} and {height(label)} tokens - bool ReplaceWidthFunctions(void); - bool ReplaceHeightFunctions(map < string, vector< map< string, string > > > *loopTokens); - //functions replacing {posx(label)} and {posy(label)} tokens - bool ReplacePosXFunctions(void); - bool ReplacePosYFunctions(void); - //Get Scrolling Function - cTemplateFunction *GetScrollFunction(void); -public: - cTemplatePixmap(void); - virtual ~cTemplatePixmap(void); - //Setter Functions - void SetPixmapContainer(cTemplatePixmapContainer *pixContainer) { this->pixContainer = pixContainer; }; - void SetScrolling(void) { scrolling = true; }; - void SetWidth(int width); - void SetHeight(int height); - void SetX(int x); - void SetY(int y); - void SetWidthPercent(double width); - void SetHeightPercent(double height); - void SetXPercent(double x); - void SetYPercent(double y); - void SetParameter(eParamType type, string value); - void AddFunction(string name, vector<pair<string, string> > ¶ms); - void AddLoopFunction(cTemplateLoopFunction *lf); - //PreCache Parameters - bool CalculateParameters(void); - //clear dynamically set function parameters - void ClearDynamicFunctionParameters(void); - //Clear dynamically set pixmap parameters - void ClearDynamicParameters(void); - //Parse pixmap parameters with dynamically set Tokens - void ParseDynamicParameters(map <string,string> *stringTokens, map <string,int> *intTokens, bool initFuncs); - //Parse all function parameters with dynamically set Tokens - void ParseDynamicFunctionParameters(map <string,string> *stringTokens, map <string,int> *intTokens, map < string, vector< map< string, string > > > *loopTokens); - //Calculate size of drawport in case area scrolls - bool CalculateDrawPortSize(cSize &size, map < string, vector< map< string, string > > > *loopTokens = NULL); - //Set max width for text in scrollarea - void SetScrollingTextWidth(void); - //Getter Functions - int NumPixmaps(void) { return 1; }; - cRect GetPixmapSize(void); - int GetNumericParameter(eParamType type); - bool Scrolling(void) { return scrolling; }; - bool Ready(void); - bool BackgroundArea(void) { return background; }; - bool ParameterSet(eParamType type); - cTemplateFunction *GetFunction(string name); - //Traverse Functions - void InitFunctionIterator(void); - cTemplateFunction *GetNextFunction(void); - //Debug - void Debug(void); -}; - -class cTemplatePixmapContainer : public cTemplatePixmapNode { -private: - vector<cTemplatePixmap*> pixmaps; - vector<cTemplatePixmap*>::iterator pixmapIterator; -public: - cTemplatePixmapContainer(void); - virtual ~cTemplatePixmapContainer(void); - void SetGlobals(cGlobals *globals); - void SetWidth(int width); - void SetHeight(int height); - void AddPixmap(cTemplatePixmap *pix); - //PreCache Parameters - bool CalculateParameters(void); - void ParseDynamicParameters(map <string,string> *stringTokens, map <string,int> *intTokens); - int NumPixmaps(void) { return pixmaps.size(); }; - void InitIterator(void); - cTemplatePixmap *GetNextPixmap(void); - cTemplateFunction *GetFunction(string name); - void Debug(void); -}; - -#endif //__TEMPLATEPIXMAP_H
\ No newline at end of file diff --git a/libtemplate/templateview.c b/libtemplate/templateview.c deleted file mode 100644 index 78d6fdf..0000000 --- a/libtemplate/templateview.c +++ /dev/null @@ -1,2148 +0,0 @@ -#include "../config.h" -#include "templateview.h" - -// --- cTemplateView ------------------------------------------------------------- - -cTemplateView::cTemplateView(void) { - globals = NULL; - parameters = NULL; - containerX = 0; - containerY = 0; - containerWidth = 0; - containerHeight = 0; - SetFunctionDefinitions(); -} - -cTemplateView::~cTemplateView() { - for (multimap < eViewElement, cTemplateViewElement* >::iterator it = viewElements.begin(); it != viewElements.end(); it++) { - delete it->second; - } - - for (multimap < eViewList, cTemplateViewList* >::iterator it = viewLists.begin(); it != viewLists.end(); it++) { - delete it->second; - } - - for (map < int, cTemplateViewGrid* >::iterator it = viewGrids.begin(); it != viewGrids.end(); it++) { - delete it->second; - } - - for (vector < cTemplateViewTab* >::iterator it = viewTabs.begin(); it != viewTabs.end(); it++) { - delete *it; - } - - for (map < eSubView, cTemplateView* >::iterator it = subViews.begin(); it != subViews.end(); it++) { - delete it->second; - } - - for (map < string, map< int, cTemplateView*> >::iterator it = pluginViews.begin(); it != pluginViews.end(); it++) { - map< int, cTemplateView*> plugViews = it->second; - for (map< int, cTemplateView*>::iterator it2 = plugViews.begin(); it2 != plugViews.end(); it2++) { - delete it2->second; - } - } - - if (parameters) - delete parameters; - -} - -/******************************************************************* -* Public Functions -*******************************************************************/ - -void cTemplateView::SetParameters(vector<pair<string, string> > ¶ms) { - parameters = new cTemplateFunction(ftView); - parameters->SetGlobals(globals); - parameters->SetParameters(params); -} - -void cTemplateView::SetContainer(int x, int y, int width, int height) { - containerX = x; - containerY = y; - containerWidth = width; - containerHeight = height; -} - -cTemplateViewElement *cTemplateView::GetViewElement(eViewElement ve) { - pair<multimap< eViewElement, cTemplateViewElement* >::iterator, multimap< eViewElement, cTemplateViewElement* >::iterator> rangeViewElements; - rangeViewElements = viewElements.equal_range(ve); - for (multimap<eViewElement, cTemplateViewElement*>::iterator it = rangeViewElements.first; it!=rangeViewElements.second; ++it) { - cTemplateViewElement *viewElement = it->second; - if (viewElement->Execute()) { - return viewElement; - } - } - return NULL; -} - -void cTemplateView::InitViewElementIterator(void) { - veIt = viewElements.begin(); -} - -cTemplateViewElement *cTemplateView::GetNextViewElement(void) { - if (veIt == viewElements.end()) - return NULL; - cTemplateViewElement *viewElement = veIt->second; - veIt++; - return viewElement; -} - -cTemplateViewGrid *cTemplateView::GetViewGrid(int gridID) { - map < int, cTemplateViewGrid* >::iterator hit = viewGrids.find(gridID); - if (hit == viewGrids.end()) { - return NULL; - } - return hit->second; -} - -void cTemplateView::InitViewGridIterator(void) { - geIt = viewGrids.begin(); -} - -cTemplateViewGrid *cTemplateView::GetNextViewGrid(void) { - if (geIt == viewGrids.end()) - return NULL; - cTemplateViewGrid *viewGrid = geIt->second; - geIt++; - return viewGrid; -} - -cTemplateViewList *cTemplateView::GetViewList(eViewList vl) { - if (viewLists.size() == 1) { - multimap < eViewList, cTemplateViewList* >::iterator hit = viewLists.find(vl); - if (hit == viewLists.end()) - return NULL; - return hit->second; - } - pair<multimap< eViewList, cTemplateViewList* >::iterator, multimap< eViewList, cTemplateViewList* >::iterator> rangeViewLists; - rangeViewLists = viewLists.equal_range(vl); - for (multimap<eViewList, cTemplateViewList*>::iterator it = rangeViewLists.first; it!=rangeViewLists.second; ++it) { - cTemplateViewList *viewList = it->second; - if (viewList->Execute()) { - return viewList; - } - } - return NULL; -} - -void cTemplateView::InitViewListIterator(void) { - vlIt = viewLists.begin(); -} - -cTemplateViewList *cTemplateView::GetNextViewList(void) { - if (vlIt == viewLists.end()) - return NULL; - cTemplateViewList *viewList = vlIt->second; - vlIt++; - return viewList; -} - -cTemplateView *cTemplateView::GetSubView(eSubView sv) { - map < eSubView, cTemplateView* >::iterator hit = subViews.find(sv); - if (hit == subViews.end()) - return NULL; - return hit->second; -} - -cTemplateView *cTemplateView::GetPluginView(string pluginName, int pluginMenu) { - map < string, map< int, cTemplateView*> >::iterator hit = pluginViews.find(pluginName); - - if (hit == pluginViews.end()) - return NULL; - - map< int, cTemplateView*> plugViews = hit->second; - map< int, cTemplateView*>::iterator hit2 = plugViews.find(pluginMenu); - - if (hit2 == plugViews.end()) - return NULL; - - return hit2->second; -} - - -void cTemplateView::InitViewTabIterator(void) { - vtIt = viewTabs.begin(); -} - -cTemplateViewTab *cTemplateView::GetNextViewTab(void) { - if (vtIt == viewTabs.end()) { - return NULL; - } - cTemplateViewTab *tab = *vtIt; - vtIt++; - return tab; -} - -void cTemplateView::InitSubViewIterator(void) { - svIt = subViews.begin(); -} - -cTemplateView *cTemplateView::GetNextSubView(void) { - if (svIt == subViews.end()) - return NULL; - cTemplateView *subView = svIt->second; - svIt++; - return subView; -} - -int cTemplateView::GetNumericParameter(eParamType type) { - if (!parameters) - return 0; - return parameters->GetNumericParameter(type); -} - -cRect cTemplateView::GetOsdSize(void) { - cRect osdSize; - if (!parameters) { - return osdSize; - } - osdSize.SetX(parameters->GetNumericParameter(ptX)); - osdSize.SetY(parameters->GetNumericParameter(ptY)); - osdSize.SetWidth(parameters->GetNumericParameter(ptWidth)); - osdSize.SetHeight(parameters->GetNumericParameter(ptHeight)); - return osdSize; -} - -int cTemplateView::GetNumPixmaps(void) { - int numPixmaps = 0; - for (multimap < eViewElement, cTemplateViewElement* >::iterator it = viewElements.begin(); it != viewElements.end(); it++) { - cTemplateViewElement *viewElement = it->second; - numPixmaps += viewElement->GetNumPixmaps(); - } - return numPixmaps; -} - -int cTemplateView::GetNumPixmapsViewElement(eViewElement ve) { - cTemplateViewElement *viewElement = GetViewElement(ve); - if (!viewElement) - return 0; - return viewElement->GetNumPixmaps(); -} - -bool cTemplateView::HideView(void) { - if (!parameters) - return false; - return parameters->GetNumericParameter(ptHideRoot); -} - -bool cTemplateView::DrawGebugGrid(void) { - if (!parameters) - return false; - return parameters->GetNumericParameter(ptDrawDebugGrid); -} - -int cTemplateView::DebugGridX(void) { - if (!parameters) - return 0; - return parameters->GetNumericParameter(ptDebugGridX); -} - -int cTemplateView::DebugGridY(void) { - if (!parameters) - return 0; - return parameters->GetNumericParameter(ptDebugGridY); -} - -tColor cTemplateView::DebugGridColor(void) { - tColor col = 0xFFFF0000; - if (!globals) - return col; - string colName = "{clrDebugGrid}"; - globals->GetColor(colName, col); - return col; -} - -tColor cTemplateView::DebugGridFontColor(void) { - tColor col = 0xFFFF0000; - if (!globals) - return col; - string colName = "{clrFontDebugGrid}"; - globals->GetColor(colName, col); - return col; -} - -bool cTemplateView::ExecuteView(eViewElement ve) { - cTemplateViewElement *viewElement = GetViewElement(ve); - if (!viewElement) - return false; - return true; -} - -bool cTemplateView::DetachViewElement(eViewElement ve) { - multimap < eViewElement, cTemplateViewElement* >::iterator hit = viewElements.find(ve); - if (hit == viewElements.end()) - return false; - cTemplateViewElement *viewElement = hit->second; - return viewElement->Detach(); -} - -string cTemplateView::GetViewElementMode(eViewElement ve) { - cTemplateViewElement *viewElement = GetViewElement(ve); - if (!viewElement) - return ""; - return viewElement->GetMode(); -} - -int cTemplateView::GetNumListViewMenuItems(void) { - int numElements = 0; - cTemplateViewList *menuList = GetViewList(vlMenuItem); - if (!menuList) - return numElements; - return menuList->GetNumericParameter(ptNumElements); -} - -bool cTemplateView::GetScalingWindow(cRect &scalingWindow) { - if (!parameters) - return false; - bool doScale = false; - int scaleX = parameters->GetNumericParameter(ptScaleTvX) + cOsd::OsdLeft(); - int scaleY = parameters->GetNumericParameter(ptScaleTvY) + cOsd::OsdTop(); - int scaleWidth = parameters->GetNumericParameter(ptScaleTvWidth); - int scaleHeight = parameters->GetNumericParameter(ptScaleTvHeight); - if (scaleX > -1 && scaleY > -1 && scaleWidth > -1 && scaleHeight > -1) { - cRect suggestedScaleWindow(scaleX, scaleY, scaleWidth, scaleHeight); - scalingWindow = cDevice::PrimaryDevice()->CanScaleVideo(suggestedScaleWindow); - doScale = true; - } else { - scalingWindow = cDevice::PrimaryDevice()->CanScaleVideo(cRect::Null); - } - return doScale; -} - -bool cTemplateView::ValidViewElement(const char *viewElement) { - set<string>::iterator hit = viewElementsAllowed.find(viewElement); - if (hit == viewElementsAllowed.end()) - return false; - return true; -} - -bool cTemplateView::ValidSubView(const char *subView) { - set<string>::iterator hit = subViewsAllowed.find(subView); - if (hit == subViewsAllowed.end()) - return false; - return true; -} - -bool cTemplateView::ValidViewList(const char *viewList) { - set<string>::iterator hit = viewListsAllowed.find(viewList); - if (hit == viewListsAllowed.end()) - return false; - return true; -} - -bool cTemplateView::ValidViewGrid(const char *viewGrid) { - set<string>::iterator hit = viewGridsAllowed.find(viewGrid); - if (hit == viewGridsAllowed.end()) - return false; - return true; -} - -bool cTemplateView::ValidFunction(const char *func) { - map < string, set < string > >::iterator hit = funcsAllowed.find(func); - if (hit == funcsAllowed.end()) - return false; - return true; -} - -bool cTemplateView::ValidAttribute(const char *func, const char *att) { - map < string, set < string > >::iterator hit = funcsAllowed.find(func); - if (hit == funcsAllowed.end()) - return false; - - set<string>::iterator hitAtt = (hit->second).find(att); - if (hitAtt == (hit->second).end()) - return false; - - return true; -} - -void cTemplateView::Translate(void) { - //Translate ViewElements - InitViewElementIterator(); - cTemplateViewElement *viewElement = NULL; - while(viewElement = GetNextViewElement()) { - viewElement->InitPixmapIterator(); - cTemplatePixmap *pix = NULL; - while(pix = viewElement->GetNextPixmap()) { - pix->InitFunctionIterator(); - cTemplateFunction *func = NULL; - while(func = pix->GetNextFunction()) { - if (func->GetType() == ftDrawText || func->GetType() == ftDrawTextBox || func->GetType() == ftDrawTextVertical) { - string text = func->GetParameter(ptText); - string translation; - bool translated = globals->Translate(text, translation); - if (translated) { - func->SetTranslatedText(translation); - } - } - if (func->GetType() == ftLoop) { - cTemplateLoopFunction *funcsLoop = dynamic_cast<cTemplateLoopFunction*>(func); - funcsLoop->InitIterator(); - cTemplateFunction *loopFunc = NULL; - while(loopFunc = funcsLoop->GetNextFunction()) { - if (loopFunc->GetType() == ftDrawText || loopFunc->GetType() == ftDrawTextBox || func->GetType() == ftDrawTextVertical) { - string text = loopFunc->GetParameter(ptText); - string translation; - bool translated = globals->Translate(text, translation); - if (translated) { - loopFunc->SetTranslatedText(translation); - } - } - } - } - } - } - } - //Translate viewLists - InitViewListIterator(); - cTemplateViewList *viewList = NULL; - while(viewList = GetNextViewList()) { - viewList->InitPixmapIterator(); - cTemplatePixmap *pix = NULL; - while(pix = viewList->GetNextPixmap()) { - pix->InitFunctionIterator(); - cTemplateFunction *func = NULL; - while(func = pix->GetNextFunction()) { - if (func->GetType() == ftDrawText || func->GetType() == ftDrawTextBox || func->GetType() == ftDrawTextVertical) { - string text = func->GetParameter(ptText); - string translation; - bool translated = globals->Translate(text, translation); - if (translated) { - func->SetTranslatedText(translation); - } - } - } - } - cTemplateViewElement *listElement = viewList->GetListElement(); - listElement->InitPixmapIterator(); - while(pix = listElement->GetNextPixmap()) { - pix->InitFunctionIterator(); - cTemplateFunction *func = NULL; - while(func = pix->GetNextFunction()) { - if (func->GetType() == ftDrawText || func->GetType() == ftDrawTextBox || func->GetType() == ftDrawTextVertical) { - string text = func->GetParameter(ptText); - string translation; - bool translated = globals->Translate(text, translation); - if (translated) { - func->SetTranslatedText(translation); - } - } - } - } - - cTemplateViewElement *listElementCurrent = viewList->GetListElementCurrent(); - if (listElementCurrent) { - listElementCurrent->InitPixmapIterator(); - while(pix = listElementCurrent->GetNextPixmap()) { - pix->InitFunctionIterator(); - cTemplateFunction *func = NULL; - while(func = pix->GetNextFunction()) { - if (func->GetType() == ftDrawText || func->GetType() == ftDrawTextBox || func->GetType() == ftDrawTextVertical) { - string text = func->GetParameter(ptText); - string translation; - bool translated = globals->Translate(text, translation); - if (translated) { - func->SetTranslatedText(translation); - } - } - if (func->GetType() == ftLoop) { - cTemplateLoopFunction *funcsLoop = dynamic_cast<cTemplateLoopFunction*>(func); - funcsLoop->InitIterator(); - cTemplateFunction *loopFunc = NULL; - while(loopFunc = funcsLoop->GetNextFunction()) { - if (loopFunc->GetType() == ftDrawText || loopFunc->GetType() == ftDrawTextBox || func->GetType() == ftDrawTextVertical) { - string text = loopFunc->GetParameter(ptText); - string translation; - bool translated = globals->Translate(text, translation); - if (translated) { - loopFunc->SetTranslatedText(translation); - } - } - } - } - } - } - } - } - - //Translate viewTabs - InitViewTabIterator(); - cTemplateViewTab *viewTab = NULL; - while(viewTab = GetNextViewTab()) { - string tabName = viewTab->GetName(); - string tabTrans; - bool translated = globals->Translate(tabName, tabTrans); - if (translated) { - viewTab->SetName(tabTrans); - } - viewTab->InitFunctionIterator(); - cTemplateFunction *func = NULL; - while(func = viewTab->GetNextFunction()) { - if (func->GetType() == ftDrawText || func->GetType() == ftDrawTextBox || func->GetType() == ftDrawTextVertical) { - string text = func->GetParameter(ptText); - string translation; - translated = globals->Translate(text, translation); - if (translated) { - func->SetTranslatedText(translation); - } - } - if (func->GetType() == ftLoop) { - cTemplateLoopFunction *funcsLoop = dynamic_cast<cTemplateLoopFunction*>(func); - funcsLoop->InitIterator(); - cTemplateFunction *loopFunc = NULL; - while(loopFunc = funcsLoop->GetNextFunction()) { - if (loopFunc->GetType() == ftDrawText || loopFunc->GetType() == ftDrawTextBox || func->GetType() == ftDrawTextVertical) { - string text = loopFunc->GetParameter(ptText); - string translation; - bool translated = globals->Translate(text, translation); - if (translated) { - loopFunc->SetTranslatedText(translation); - } - } - } - } - } - } - - //Translate ViewGrids - InitViewGridIterator(); - cTemplateViewGrid *viewGrid = NULL; - while(viewGrid = GetNextViewGrid()) { - viewGrid->InitPixmapIterator(); - cTemplatePixmap *pix = NULL; - while(pix = viewGrid->GetNextPixmap()) { - pix->InitFunctionIterator(); - cTemplateFunction *func = NULL; - while(func = pix->GetNextFunction()) { - if (func->GetType() == ftDrawText || func->GetType() == ftDrawTextBox || func->GetType() == ftDrawTextVertical) { - string text = func->GetParameter(ptText); - string translation; - bool translated = globals->Translate(text, translation); - if (translated) { - func->SetTranslatedText(translation); - } - } - if (func->GetType() == ftLoop) { - cTemplateLoopFunction *funcsLoop = dynamic_cast<cTemplateLoopFunction*>(func); - funcsLoop->InitIterator(); - cTemplateFunction *loopFunc = NULL; - while(loopFunc = funcsLoop->GetNextFunction()) { - if (loopFunc->GetType() == ftDrawText || loopFunc->GetType() == ftDrawTextBox || func->GetType() == ftDrawTextVertical) { - string text = loopFunc->GetParameter(ptText); - string translation; - bool translated = globals->Translate(text, translation); - if (translated) { - loopFunc->SetTranslatedText(translation); - } - } - } - } - } - } - } - - //Translate Plugin Views - for (map < string, map< int, cTemplateView*> >::iterator it = pluginViews.begin(); it != pluginViews.end(); it++) { - map< int, cTemplateView*> plugViews = it->second; - for (map< int, cTemplateView*>::iterator it2 = plugViews.begin(); it2 != plugViews.end(); it2++) { - cTemplateView *pluginView = it2->second; - pluginView->Translate(); - } - } - - //Translate Subviews - InitSubViewIterator(); - cTemplateView *subView = NULL; - while(subView = GetNextSubView()) { - subView->Translate(); - } -} - -void cTemplateView::PreCache(bool isSubview) { - - if (!isSubview) { - int osdW = cOsd::OsdWidth(); - int osdH = cOsd::OsdHeight(); - parameters->SetContainer(0, 0, osdW, osdH); - } else { - parameters->SetContainer(containerX, containerY, containerWidth, containerHeight); - } - //Calculate OSD Size - parameters->CalculateParameters(); - - int osdX = parameters->GetNumericParameter(ptX); - int osdY = parameters->GetNumericParameter(ptY); - int osdWidth = parameters->GetNumericParameter(ptWidth); - int osdHeight = parameters->GetNumericParameter(ptHeight); - int pixOffset = 0; - //Cache ViewElements - for (multimap < eViewElement, cTemplateViewElement* >::iterator it = viewElements.begin(); it != viewElements.end(); it++) { - cTemplateViewElement *viewElement = it->second; - viewElement->SetGlobals(globals); - if (!isSubview) - viewElement->SetContainer(0, 0, osdWidth, osdHeight); - else - viewElement->SetContainer(osdX, osdY, osdWidth, osdHeight); - viewElement->CalculateParameters(); - viewElement->CalculatePixmapParameters(); - viewElement->SetPixOffset(pixOffset); - pixOffset += viewElement->GetNumPixmaps(); - } - - //Cache ViewGrids - for (map < int, cTemplateViewGrid* >::iterator it = viewGrids.begin(); it != viewGrids.end(); it++) { - cTemplateViewGrid *viewGrid = it->second; - viewGrid->SetGlobals(globals); - viewGrid->SetContainer(0, 0, osdWidth, osdHeight); - viewGrid->CalculateParameters(); - viewGrid->CalculatePixmapParameters(); - } - - //Cache ViewLists - for (multimap < eViewList, cTemplateViewList* >::iterator it = viewLists.begin(); it != viewLists.end(); it++) { - cTemplateViewList *viewList = it->second; - viewList->SetGlobals(globals); - //viewlists in subviews need complete container information - if (isSubview) - viewList->SetContainer(osdX, osdY, osdWidth, osdHeight); - else - viewList->SetContainer(0, 0, osdWidth, osdHeight); - viewList->CalculateParameters(); - viewList->CalculateListParameters(); - } - - //Cache ViewTabs - for (vector<cTemplateViewTab*>::iterator tab = viewTabs.begin(); tab != viewTabs.end(); tab++) { - //viewtabs are only in subviews - (*tab)->SetContainer(osdX, osdY, osdWidth, osdHeight); - (*tab)->SetGlobals(globals); - (*tab)->CalculateParameters(); - } - - //Cache Subviews - for (map < eSubView, cTemplateView* >::iterator it = subViews.begin(); it != subViews.end(); it++) { - cTemplateView *subView = it->second; - subView->SetContainer(0, 0, osdWidth, osdHeight); - subView->PreCache(true); - } - - //Cache Plugin Subviews - for (map < string, map< int, cTemplateView*> >::iterator it = pluginViews.begin(); it != pluginViews.end(); it++) { - map< int, cTemplateView*> plugViews = it->second; - for (map< int, cTemplateView*>::iterator it2 = plugViews.begin(); it2 != plugViews.end(); it2++) { - cTemplateView *plugView = it2->second; - plugView->SetContainer(0, 0, osdWidth, osdHeight); - plugView->PreCache(true); - } - } -} - -void cTemplateView::Debug(void) { - - esyslog("skindesigner: TemplateView %s", viewName.c_str());; - - parameters->Debug(); - - for (multimap < eViewElement, cTemplateViewElement* >::iterator it = viewElements.begin(); it != viewElements.end(); it++) { - esyslog("skindesigner: ++++++++ ViewElement: %s", GetViewElementName(it->first).c_str()); - cTemplateViewElement *viewElement = it->second; - viewElement->Debug(); - } - - for (multimap < eViewList, cTemplateViewList* >::iterator it = viewLists.begin(); it != viewLists.end(); it++) { - esyslog("skindesigner: ++++++++ ViewList: %s", GetViewListName(it->first).c_str()); - cTemplateViewList *viewList = it->second; - viewList->Debug(); - } - - for (map < int, cTemplateViewGrid* >::iterator it = viewGrids.begin(); it != viewGrids.end(); it++) { - esyslog("skindesigner: ++++++++ ViewGrid %d:", it->first); - cTemplateViewGrid *viewGrid = it->second; - viewGrid->Debug(); - } - - for (vector<cTemplateViewTab*>::iterator tab = viewTabs.begin(); tab != viewTabs.end(); tab++) { - esyslog("skindesigner: ++++++++ ViewTab"); - (*tab)->Debug(); - } - - for (map < eSubView, cTemplateView* >::iterator it = subViews.begin(); it!= subViews.end(); it++) { - esyslog("skindesigner: ++++++++ SubView: %s", GetSubViewName(it->first).c_str()); - cTemplateView *subView = it->second; - subView->Debug(); - } - - for (map < string, map< int, cTemplateView*> >::iterator it = pluginViews.begin(); it!= pluginViews.end(); it++) { - esyslog("skindesigner: ++++++++ Plugin: %s", it->first.c_str()); - map< int, cTemplateView*> plugViews = it->second; - for (map< int, cTemplateView*>::iterator it2 = plugViews.begin(); it2 != plugViews.end(); it2++) { - esyslog("skindesigner: Tmpl %d", it2->first); - ((cTemplateView*)it2->second)->Debug(); - } - } - -} - - -void cTemplateView::SetFunctionDefinitions(void) { - - string name = "viewelement"; - set<string> attributes; - attributes.insert("debug"); - attributes.insert("detached"); - attributes.insert("delay"); - attributes.insert("fadetime"); - attributes.insert("shifttime"); - attributes.insert("shifttype"); - attributes.insert("shiftmode"); - attributes.insert("startx"); - attributes.insert("starty"); - attributes.insert("name"); - attributes.insert("condition"); - attributes.insert("mode"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "listelement"; - attributes.clear(); - attributes.insert("debug"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "areacontainer"; - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("debug"); - attributes.insert("condition"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "area"; - attributes.clear(); - attributes.insert("debug"); - attributes.insert("condition"); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("layer"); - attributes.insert("transparency"); - attributes.insert("background"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "areascroll"; - attributes.clear(); - attributes.insert("debug"); - attributes.insert("orientation"); - attributes.insert("delay"); - attributes.insert("mode"); - attributes.insert("scrollspeed"); - attributes.insert("condition"); - attributes.insert("scrollelement"); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("layer"); - attributes.insert("transparency"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "loop"; - attributes.clear(); - attributes.insert("debug"); - attributes.insert("name"); - attributes.insert("orientation"); - attributes.insert("condition"); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("columnwidth"); - attributes.insert("rowheight"); - attributes.insert("overflow"); - attributes.insert("maxitems"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "fill"; - attributes.clear(); - attributes.insert("debug"); - attributes.insert("condition"); - attributes.insert("color"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "drawtext"; - attributes.clear(); - attributes.insert("debug"); - attributes.insert("condition"); - attributes.insert("name"); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("align"); - attributes.insert("valign"); - attributes.insert("font"); - attributes.insert("fontsize"); - attributes.insert("color"); - attributes.insert("text"); - attributes.insert("animtype"); - attributes.insert("animfreq"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "drawtextbox"; - attributes.clear(); - attributes.insert("debug"); - attributes.insert("condition"); - attributes.insert("name"); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("align"); - attributes.insert("valign"); - attributes.insert("maxlines"); - attributes.insert("font"); - attributes.insert("fontsize"); - attributes.insert("color"); - attributes.insert("text"); - attributes.insert("float"); - attributes.insert("floatwidth"); - attributes.insert("floatheight"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "drawtextvertical"; - attributes.clear(); - attributes.insert("debug"); - attributes.insert("condition"); - attributes.insert("name"); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("height"); - attributes.insert("align"); - attributes.insert("valign"); - attributes.insert("direction"); - attributes.insert("font"); - attributes.insert("fontsize"); - attributes.insert("color"); - attributes.insert("text"); - attributes.insert("animtype"); - attributes.insert("animfreq"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "drawimage"; - attributes.clear(); - attributes.insert("debug"); - attributes.insert("condition"); - attributes.insert("name"); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("align"); - attributes.insert("valign"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("imagetype"); - attributes.insert("path"); - attributes.insert("align"); - attributes.insert("valign"); - attributes.insert("cache"); - attributes.insert("animtype"); - attributes.insert("animfreq"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "drawrectangle"; - attributes.clear(); - attributes.insert("debug"); - attributes.insert("condition"); - attributes.insert("name"); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("align"); - attributes.insert("valign"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("color"); - attributes.insert("animtype"); - attributes.insert("animfreq"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "drawellipse"; - attributes.clear(); - attributes.insert("debug"); - attributes.insert("condition"); - attributes.insert("name"); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("align"); - attributes.insert("valign"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("color"); - attributes.insert("quadrant"); - attributes.insert("animtype"); - attributes.insert("animfreq"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "drawslope"; - attributes.clear(); - attributes.insert("debug"); - attributes.insert("condition"); - attributes.insert("name"); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("align"); - attributes.insert("valign"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("color"); - attributes.insert("type"); - attributes.insert("animtype"); - attributes.insert("animfreq"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); -} - -/************************************************************************************ -* cTemplateViewChannel -************************************************************************************/ - -cTemplateViewChannel::cTemplateViewChannel(void) { - - viewName = "displaychannel"; - //definition of allowed parameters for class itself - set<string> attributes; - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("shifttime"); - attributes.insert("shifttype"); - attributes.insert("shiftmode"); - attributes.insert("startx"); - attributes.insert("starty"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(viewName, attributes)); - - SetViewElements(); -} - -cTemplateViewChannel::~cTemplateViewChannel() { -} - -void cTemplateViewChannel::SetViewElements(void) { - viewElementsAllowed.insert("background"); - viewElementsAllowed.insert("channelinfo"); - viewElementsAllowed.insert("channelgroup"); - viewElementsAllowed.insert("epginfo"); - viewElementsAllowed.insert("progressbar"); - viewElementsAllowed.insert("progressbarback"); - viewElementsAllowed.insert("statusinfo"); - viewElementsAllowed.insert("audioinfo"); - viewElementsAllowed.insert("ecminfo"); - viewElementsAllowed.insert("screenresolution"); - viewElementsAllowed.insert("signalquality"); - viewElementsAllowed.insert("signalqualityback"); - viewElementsAllowed.insert("devices"); - viewElementsAllowed.insert("currentweather"); - viewElementsAllowed.insert("scrapercontent"); - viewElementsAllowed.insert("datetime"); - viewElementsAllowed.insert("time"); - viewElementsAllowed.insert("message"); - viewElementsAllowed.insert("customtokens"); -} - -string cTemplateViewChannel::GetViewElementName(eViewElement ve) { - string name; - switch (ve) { - case veBackground: - name = "Background"; - break; - case veChannelInfo: - name = "ChannelInfo"; - break; - case veChannelGroup: - name = "ChannelGroup"; - break; - case veEpgInfo: - name = "EpgInfo"; - break; - case veProgressBar: - name = "ProgressBar"; - break; - case veProgressBarBack: - name = "ProgressBar Background"; - break; - case veStatusInfo: - name = "StatusInfo"; - break; - case veAudioInfo: - name = "AudioInfo"; - break; - case veScreenResolution: - name = "Screen Resolution"; - break; - case veEcmInfo: - name = "ECM Info"; - break; - case veSignalQuality: - name = "Signal Quality"; - break; - case veSignalQualityBack: - name = "Signal Quality Background"; - break; - case veDevices: - name = "Devices"; - break; - case veCurrentWeather: - name = "Current Weather"; - break; - case veScraperContent: - name = "Scraper Content"; - break; - case veDateTime: - name = "DateTime"; - break; - case veTime: - name = "Time"; - break; - case veMessage: - name = "Message"; - break; - case veCustomTokens: - name = "Custom Tokens"; - break; - default: - name = "Unknown"; - break; - }; - return name; -} - -void cTemplateViewChannel::AddViewElement(string sViewElement, cTemplateViewElement *viewElement) { - eViewElement ve = veUndefined; - - if (!sViewElement.compare("background")) { - ve = veBackground; - } else if (!sViewElement.compare("channelinfo")) { - ve = veChannelInfo; - } else if (!sViewElement.compare("channelgroup")) { - ve = veChannelGroup; - } else if (!sViewElement.compare("epginfo")) { - ve = veEpgInfo; - } else if (!sViewElement.compare("progressbar")) { - ve = veProgressBar; - } else if (!sViewElement.compare("progressbarback")) { - ve = veProgressBarBack; - } else if (!sViewElement.compare("statusinfo")) { - ve = veStatusInfo; - } else if (!sViewElement.compare("audioinfo")) { - ve = veAudioInfo; - } else if (!sViewElement.compare("ecminfo")) { - ve = veEcmInfo; - } else if (!sViewElement.compare("screenresolution")) { - ve = veScreenResolution; - } else if (!sViewElement.compare("signalquality")) { - ve = veSignalQuality; - } else if (!sViewElement.compare("signalqualityback")) { - ve = veSignalQualityBack; - } else if (!sViewElement.compare("devices")) { - ve = veDevices; - } else if (!sViewElement.compare("currentweather")) { - ve = veCurrentWeather; - } else if (!sViewElement.compare("scrapercontent")) { - ve = veScraperContent; - } else if (!sViewElement.compare("datetime")) { - ve = veDateTime; - } else if (!sViewElement.compare("time")) { - ve = veTime; - } else if (!sViewElement.compare("message")) { - ve = veMessage; - } else if (!sViewElement.compare("customtokens")) { - ve = veCustomTokens; - } - if (ve == veUndefined) { - esyslog("skindesigner: unknown ViewElement in displaychannel: %s", sViewElement.c_str()); - return; - } - - viewElements.insert(pair< eViewElement, cTemplateViewElement*>(ve, viewElement)); -} - -/************************************************************************************ -* cTemplateViewMenu -************************************************************************************/ - -cTemplateViewMenu::cTemplateViewMenu(void) { - - viewName = "displaymenu"; - //definition of allowed parameters for class itself - set<string> attributes; - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(viewName, attributes)); - - string subViewName = "menudefault"; - //definition of allowed parameters for subtemplate menumain - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(subViewName, attributes)); - - subViewName = "menumain"; - //definition of allowed parameters for subtemplate menumain - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(subViewName, attributes)); - - subViewName = "menusetup"; - //definition of allowed parameters for subtemplate menumain - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(subViewName, attributes)); - - subViewName = "menuschedules"; - //definition of allowed parameters for subtemplate menumain - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(subViewName, attributes)); - - subViewName = "menuchannels"; - //definition of allowed parameters for subtemplate menumain - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(subViewName, attributes)); - - subViewName = "menutimers"; - //definition of allowed parameters for subtemplate menumain - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(subViewName, attributes)); - - subViewName = "menurecordings"; - //definition of allowed parameters for subtemplate menumain - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(subViewName, attributes)); - - subViewName = "menudetailedepg"; - //definition of allowed parameters for subtemplate menumain - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(subViewName, attributes)); - - subViewName = "menudetailedrecording"; - //definition of allowed parameters for subtemplate menumain - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(subViewName, attributes)); - - subViewName = "menudetailedtext"; - //definition of allowed parameters for subtemplate menumain - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(subViewName, attributes)); - - //definition of allowed parameters for menuitems viewlist - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("orientation"); - attributes.insert("align"); - attributes.insert("menuitemwidth"); - attributes.insert("determinatefont"); - attributes.insert("numlistelements"); - attributes.insert("condition"); - funcsAllowed.insert(pair< string, set<string> >("menuitems", attributes)); - - //definition of allowed parameters for currentitems viewlist - attributes.clear(); - attributes.insert("debug"); - attributes.insert("delay"); - attributes.insert("fadetime"); - attributes.insert("condition"); - funcsAllowed.insert(pair< string, set<string> >("currentelement", attributes)); - - //definition of allowed parameters for viewtab - attributes.clear(); - attributes.insert("debug"); - attributes.insert("name"); - attributes.insert("condition"); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("layer"); - attributes.insert("transparency"); - attributes.insert("scrollheight"); - funcsAllowed.insert(pair< string, set<string> >("tab", attributes)); - - //definition of allowed parameters for plugin menus - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >("menuplugin", attributes)); - - SetSubViews(); - SetViewElements(); - SetViewLists(); - -} - -cTemplateViewMenu::~cTemplateViewMenu() { -} - -void cTemplateViewMenu::SetSubViews(void) { - subViewsAllowed.insert("menudefault"); - subViewsAllowed.insert("menumain"); - subViewsAllowed.insert("menusetup"); - subViewsAllowed.insert("menuschedules"); - subViewsAllowed.insert("menutimers"); - subViewsAllowed.insert("menurecordings"); - subViewsAllowed.insert("menuchannels"); - subViewsAllowed.insert("menudetailedepg"); - subViewsAllowed.insert("menudetailedrecording"); - subViewsAllowed.insert("menudetailedtext"); -} - -void cTemplateViewMenu::SetViewElements(void) { - viewElementsAllowed.insert("background"); - viewElementsAllowed.insert("datetime"); - viewElementsAllowed.insert("time"); - viewElementsAllowed.insert("header"); - viewElementsAllowed.insert("colorbuttons"); - viewElementsAllowed.insert("message"); - viewElementsAllowed.insert("sortmode"); - viewElementsAllowed.insert("discusage"); - viewElementsAllowed.insert("systemload"); - viewElementsAllowed.insert("systemmemory"); - viewElementsAllowed.insert("vdrstatistics"); - viewElementsAllowed.insert("temperatures"); - viewElementsAllowed.insert("timers"); - viewElementsAllowed.insert("lastrecordings"); - viewElementsAllowed.insert("devices"); - viewElementsAllowed.insert("currentweather"); - viewElementsAllowed.insert("currentschedule"); - viewElementsAllowed.insert("customtokens"); - viewElementsAllowed.insert("scrollbar"); - viewElementsAllowed.insert("detailheader"); - viewElementsAllowed.insert("tablabels"); -} - -void cTemplateViewMenu::SetViewLists(void) { - viewListsAllowed.insert("menuitems"); -} - -string cTemplateViewMenu::GetSubViewName(eSubView sv) { - string name; - switch (sv) { - case svMenuDefault: - name = "Default Menu"; - break; - case svMenuMain: - name = "Main Menu"; - break; - case svMenuSetup: - name = "Setup Menu"; - break; - case svMenuSchedules: - name = "Schedules Menu"; - break; - case svMenuTimers: - name = "Timers Menu"; - break; - case svMenuRecordings: - name = "Recordings Menu"; - break; - case svMenuChannels: - name = "Channels Menu"; - break; - case svMenuDetailedEpg: - name = "Detailed EPG"; - break; - case svMenuDetailedRecording: - name = "Detailed Recording"; - break; - case svMenuDetailedText: - name = "Detailed Text"; - break; - default: - name = "Unknown"; - break; - }; - return name; -} - - -string cTemplateViewMenu::GetViewElementName(eViewElement ve) { - string name; - switch (ve) { - case veBackground: - name = "Background"; - break; - case veDateTime: - name = "DateTime"; - break; - case veTime: - name = "Time"; - break; - case veHeader: - name = "Header"; - break; - case veButtons: - name = "Color Buttons"; - break; - case veMessage: - name = "Message"; - break; - case veSortMode: - name = "Sort Mode"; - break; - case veDiscUsage: - name = "Disc Usage"; - break; - case veSystemLoad: - name = "System Load"; - break; - case veSystemMemory: - name = "System Memory"; - break; - case veVDRStats: - name = "VDR Statistics"; - break; - case veTemperatures: - name = "Temperatures"; - break; - case veTimers: - name = "Timers"; - break; - case veLastRecordings: - name = "Last Recordings"; - break; - case veCurrentSchedule: - name = "Current Schedule"; - break; - case veCurrentWeather: - name = "Current Weather"; - break; - case veCustomTokens: - name = "Custom Tokens"; - break; - case veDevices: - name = "Devices"; - break; - case veMenuItem: - name = "Menu Item"; - break; - case veMenuCurrentItemDetail: - name = "Menu Current Item Detail"; - break; - case veScrollbar: - name = "Scrollbar"; - break; - case veDetailHeader: - name = "Detail header"; - break; - case veTabLabels: - name = "tab labels"; - break; - default: - name = "Unknown"; - break; - }; - return name; -} - -string cTemplateViewMenu::GetViewListName(eViewList vl) { - string name; - switch (vl) { - case vlMenuItem: - name = "Menu Item"; - break; - default: - name = "Unknown"; - break; - }; - return name; -} - -void cTemplateViewMenu::AddSubView(string sSubView, cTemplateView *subView) { - eSubView sv = svUndefined; - - if (!sSubView.compare("menumain")) { - sv = svMenuMain; - } else if (!sSubView.compare("menudefault")) { - sv = svMenuDefault; - } else if (!sSubView.compare("menuschedules")) { - sv = svMenuSchedules; - } else if (!sSubView.compare("menusetup")) { - sv = svMenuSetup; - } else if (!sSubView.compare("menuschedules")) { - sv = svMenuSchedules; - } else if (!sSubView.compare("menutimers")) { - sv = svMenuTimers; - } else if (!sSubView.compare("menurecordings")) { - sv = svMenuRecordings; - } else if (!sSubView.compare("menuchannels")) { - sv = svMenuChannels; - } else if (!sSubView.compare("menudetailedepg")) { - sv = svMenuDetailedEpg; - } else if (!sSubView.compare("menudetailedrecording")) { - sv = svMenuDetailedRecording; - } else if (!sSubView.compare("menudetailedtext")) { - sv = svMenuDetailedText; - } - - if (sv == svUndefined) { - esyslog("skindesigner: unknown SubView in displayMenu: %s", sSubView.c_str()); - return; - } - subView->SetGlobals(globals); - subViews.insert(pair<eSubView, cTemplateView*>(sv, subView)); -} - -void cTemplateViewMenu::AddPluginView(string plugName, int templNo, cTemplateView *plugView) { - plugView->SetGlobals(globals); - - map < string, map< int, cTemplateView*> >::iterator hit = pluginViews.find(plugName); - - if (hit == pluginViews.end()) { - map< int, cTemplateView*> plugTemplates; - plugTemplates.insert(pair<int, cTemplateView*>(templNo, plugView)); - pluginViews.insert(pair< string, map< int, cTemplateView*> >(plugName, plugTemplates)); - } else { - hit->second.insert(pair<int, cTemplateView*>(templNo, plugView)); - } -} - -void cTemplateViewMenu::AddViewElement(string sViewElement, cTemplateViewElement *viewElement) { - eViewElement ve = veUndefined; - - if (!sViewElement.compare("background")) { - ve = veBackground; - } else if (!sViewElement.compare("datetime")) { - ve = veDateTime; - } else if (!sViewElement.compare("time")) { - ve = veTime; - } else if (!sViewElement.compare("header")) { - ve = veHeader; - } else if (!sViewElement.compare("colorbuttons")) { - ve = veButtons; - } else if (!sViewElement.compare("message")) { - ve = veMessage; - } else if (!sViewElement.compare("sortmode")) { - ve = veSortMode; - } else if (!sViewElement.compare("discusage")) { - ve = veDiscUsage; - } else if (!sViewElement.compare("systemload")) { - ve = veSystemLoad; - } else if (!sViewElement.compare("systemmemory")) { - ve = veSystemMemory; - } else if (!sViewElement.compare("vdrstatistics")) { - ve = veVDRStats; - } else if (!sViewElement.compare("temperatures")) { - ve = veTemperatures; - } else if (!sViewElement.compare("timers")) { - ve = veTimers; - } else if (!sViewElement.compare("lastrecordings")) { - ve = veLastRecordings; - } else if (!sViewElement.compare("currentschedule")) { - ve = veCurrentSchedule; - } else if (!sViewElement.compare("customtokens")) { - ve = veCustomTokens; - } else if (!sViewElement.compare("devices")) { - ve = veDevices; - } else if (!sViewElement.compare("currentweather")) { - ve = veCurrentWeather; - } else if (!sViewElement.compare("scrollbar")) { - ve = veScrollbar; - } else if (!sViewElement.compare("detailheader")) { - ve = veDetailHeader; - } else if (!sViewElement.compare("tablabels")) { - ve = veTabLabels; - } - - if (ve == veUndefined) { - esyslog("skindesigner: unknown ViewElement in displayMenu: %s", sViewElement.c_str()); - return; - } - - viewElements.insert(pair< eViewElement, cTemplateViewElement*>(ve, viewElement)); -} - -void cTemplateViewMenu::AddViewList(string sViewList, cTemplateViewList *viewList) { - - eViewList vl = vlUndefined; - if (!sViewList.compare("menuitems")) { - vl = vlMenuItem; - } - - if (vl == vlUndefined) { - esyslog("skindesigner: unknown ViewList in displaymenu: %s", sViewList.c_str()); - return; - } - - viewList->SetGlobals(globals); - viewLists.insert(pair< eViewList, cTemplateViewList*>(vl, viewList)); -} - -void cTemplateViewMenu::AddViewTab(cTemplateViewTab *viewTab) { - viewTabs.push_back(viewTab); -} - -/************************************************************************************ -* cTemplateViewMessage -************************************************************************************/ - -cTemplateViewMessage::cTemplateViewMessage(void) { - - viewName = "displaymessage"; - //definition of allowed parameters for class itself - set<string> attributes; - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("shifttime"); - attributes.insert("shifttype"); - attributes.insert("shiftmode"); - attributes.insert("startx"); - attributes.insert("starty"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(viewName, attributes)); - - SetViewElements(); -} - -cTemplateViewMessage::~cTemplateViewMessage() { -} - -void cTemplateViewMessage::SetViewElements(void) { - viewElementsAllowed.insert("background"); - viewElementsAllowed.insert("message"); -} - -string cTemplateViewMessage::GetViewElementName(eViewElement ve) { - string name; - switch (ve) { - case veBackground: - name = "Background"; - break; - case veMessage: - name = "Message"; - break; - default: - name = "Unknown"; - break; - }; - return name; -} - -void cTemplateViewMessage::AddViewElement(string sViewElement, cTemplateViewElement *viewElement) { - eViewElement ve = veUndefined; - - if (!sViewElement.compare("background")) { - ve = veBackground; - } else if (!sViewElement.compare("message")) { - ve = veMessage; - } - - if (ve == veUndefined) { - esyslog("skindesigner: unknown ViewElement in displaymessage: %s", sViewElement.c_str()); - return; - } - - viewElements.insert(pair< eViewElement, cTemplateViewElement*>(ve, viewElement)); -} - -/************************************************************************************ -* cTemplateViewReplay -************************************************************************************/ - -cTemplateViewReplay::cTemplateViewReplay(void) { - - viewName = "displayreplay"; - //definition of allowed parameters for class itself - set<string> attributes; - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("shifttime"); - attributes.insert("shifttype"); - attributes.insert("shiftmode"); - attributes.insert("startx"); - attributes.insert("starty"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(viewName, attributes)); - - //definition of allowed parameters for onpause and onpausemodeonly viewelement - attributes.clear(); - attributes.insert("debug"); - attributes.insert("delay"); - attributes.insert("fadetime"); - funcsAllowed.insert(pair< string, set<string> >("onpause", attributes)); - funcsAllowed.insert(pair< string, set<string> >("onpausemodeonly", attributes)); - - SetViewElements(); -} - -cTemplateViewReplay::~cTemplateViewReplay() { -} - -void cTemplateViewReplay::SetViewElements(void) { - viewElementsAllowed.insert("background"); - viewElementsAllowed.insert("backgroundmodeonly"); - viewElementsAllowed.insert("datetime"); - viewElementsAllowed.insert("time"); - viewElementsAllowed.insert("rectitle"); - viewElementsAllowed.insert("recinfo"); - viewElementsAllowed.insert("scrapercontent"); - viewElementsAllowed.insert("currenttime"); - viewElementsAllowed.insert("totaltime"); - viewElementsAllowed.insert("endtime"); - viewElementsAllowed.insert("progressbar"); - viewElementsAllowed.insert("cutmarks"); - viewElementsAllowed.insert("controlicons"); - viewElementsAllowed.insert("controliconsmodeonly"); - viewElementsAllowed.insert("progressmodeonly"); - viewElementsAllowed.insert("jump"); - viewElementsAllowed.insert("message"); - viewElementsAllowed.insert("onpause"); - viewElementsAllowed.insert("onpausemodeonly"); - viewElementsAllowed.insert("customtokens"); -} - -string cTemplateViewReplay::GetViewElementName(eViewElement ve) { - string name; - switch (ve) { - case veBackground: - name = "Background"; - break; - case veDateTime: - name = "DateTime"; - break; - case veTime: - name = "DateTime"; - break; - case veRecTitle: - name = "Recording Title"; - break; - case veRecInfo: - name = "Recording Information"; - break; - case veRecCurrent: - name = "Recording current Time"; - break; - case veRecTotal: - name = "Recording total Time"; - break; - case veRecEnd: - name = "Recording end Time"; - break; - case veRecProgressBar: - name = "Rec Progress Bar"; - break; - case veCuttingMarks: - name = "Cutting Marks"; - break; - case veControlIcons: - name = "Control Icons"; - break; - case veControlIconsModeOnly: - name = "Control Icons Mode only"; - break; - case veProgressModeOnly: - name = "Progress Mode only"; - break; - case veBackgroundModeOnly: - name = "Background Mode only"; - break; - case veRecJump: - name = "Recording Jump"; - break; - case veScraperContent: - name = "Scraper Content"; - break; - case veOnPause: - name = "On Pause"; - break; - case veOnPauseModeOnly: - name = "On Pause Mode Only"; - break; - case veCustomTokens: - name = "Custom Tokens"; - break; - default: - name = "Unknown"; - break; - }; - return name; -} - -void cTemplateViewReplay::AddViewElement(string sViewElement, cTemplateViewElement *viewElement) { - eViewElement ve = veUndefined; - - if (!sViewElement.compare("background")) { - ve = veBackground; - } else if (!sViewElement.compare("datetime")) { - ve = veDateTime; - } else if (!sViewElement.compare("time")) { - ve = veTime; - } else if (!sViewElement.compare("rectitle")) { - ve = veRecTitle; - } else if (!sViewElement.compare("recinfo")) { - ve = veRecInfo; - } else if (!sViewElement.compare("scrapercontent")) { - ve = veScraperContent; - } else if (!sViewElement.compare("currenttime")) { - ve = veRecCurrent; - } else if (!sViewElement.compare("totaltime")) { - ve = veRecTotal; - } else if (!sViewElement.compare("endtime")) { - ve = veRecEnd; - } else if (!sViewElement.compare("progressbar")) { - ve = veRecProgressBar; - } else if (!sViewElement.compare("cutmarks")) { - ve = veCuttingMarks; - } else if (!sViewElement.compare("controlicons")) { - ve = veControlIcons; - } else if (!sViewElement.compare("controliconsmodeonly")) { - ve = veControlIconsModeOnly; - } else if (!sViewElement.compare("progressmodeonly")) { - ve = veProgressModeOnly; - } else if (!sViewElement.compare("backgroundmodeonly")) { - ve = veBackgroundModeOnly; - } else if (!sViewElement.compare("jump")) { - ve = veRecJump; - } else if (!sViewElement.compare("message")) { - ve = veMessage; - } else if (!sViewElement.compare("onpause")) { - ve = veOnPause; - } else if (!sViewElement.compare("onpausemodeonly")) { - ve = veOnPauseModeOnly; - } else if (!sViewElement.compare("customtokens")) { - ve = veCustomTokens; - } - - if (ve == veUndefined) { - esyslog("skindesigner: unknown ViewElement in displayreplay: %s", sViewElement.c_str()); - return; - } - - viewElements.insert(pair< eViewElement, cTemplateViewElement*>(ve, viewElement)); -} - - -/************************************************************************************ -* cTemplateViewVolume -************************************************************************************/ - -cTemplateViewVolume::cTemplateViewVolume(void) { - - viewName = "displayvolume"; - //definition of allowed parameters for class itself - set<string> attributes; - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("shifttime"); - attributes.insert("shifttype"); - attributes.insert("shiftmode"); - attributes.insert("startx"); - attributes.insert("starty"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(viewName, attributes)); - - SetViewElements(); -} - -cTemplateViewVolume::~cTemplateViewVolume() { -} - -void cTemplateViewVolume::SetViewElements(void) { - viewElementsAllowed.insert("background"); - viewElementsAllowed.insert("volume"); -} - -string cTemplateViewVolume::GetViewElementName(eViewElement ve) { - string name; - switch (ve) { - case veBackground: - name = "Background"; - break; - case veVolume: - name = "Volume"; - break; - default: - name = "Unknown"; - break; - }; - return name; -} - -void cTemplateViewVolume::AddViewElement(string sViewElement, cTemplateViewElement *viewElement) { - eViewElement ve = veUndefined; - - if (!sViewElement.compare("background")) { - ve = veBackground; - } else if (!sViewElement.compare("volume")) { - ve = veVolume; - } - - if (ve == veUndefined) { - esyslog("skindesigner: unknown ViewElement in displayvolume: %s", sViewElement.c_str()); - return; - } - - viewElements.insert(pair< eViewElement, cTemplateViewElement*>(ve, viewElement)); -} - -/************************************************************************************ -* cTemplateViewAudioTracks -************************************************************************************/ - -cTemplateViewAudioTracks::cTemplateViewAudioTracks(void) { - - viewName = "displayaudiotracks"; - //definition of allowed parameters for class itself - set<string> attributes; - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("shifttime"); - attributes.insert("shifttype"); - attributes.insert("shiftmode"); - attributes.insert("startx"); - attributes.insert("starty"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(viewName, attributes)); - - //definition of allowed parameters for menuitems viewlist - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("orientation"); - attributes.insert("align"); - attributes.insert("menuitemwidth"); - attributes.insert("numlistelements"); - funcsAllowed.insert(pair< string, set<string> >("menuitems", attributes)); - - SetViewElements(); - SetViewLists(); -} - -cTemplateViewAudioTracks::~cTemplateViewAudioTracks() { -} - -void cTemplateViewAudioTracks::SetViewElements(void) { - viewElementsAllowed.insert("background"); - viewElementsAllowed.insert("header"); -} - -void cTemplateViewAudioTracks::SetViewLists(void) { - viewListsAllowed.insert("menuitems"); -} - -string cTemplateViewAudioTracks::GetViewElementName(eViewElement ve) { - string name; - switch (ve) { - case veBackground: - name = "Background"; - break; - case veHeader: - name = "Header"; - break; - default: - name = "Unknown"; - break; - }; - return name; -} - -string cTemplateViewAudioTracks::GetViewListName(eViewList vl) { - string name; - switch (vl) { - case vlMenuItem: - name = "Menu Item"; - break; - default: - name = "Unknown"; - break; - }; - return name; -} - -void cTemplateViewAudioTracks::AddViewElement(string sViewElement, cTemplateViewElement *viewElement) { - eViewElement ve = veUndefined; - - if (!sViewElement.compare("background")) { - ve = veBackground; - } else if(!sViewElement.compare("header")) { - ve = veHeader; - } - - if (ve == veUndefined) { - esyslog("skindesigner: unknown ViewElement in displayaudiotracks: %s", sViewElement.c_str()); - return; - } - - viewElements.insert(pair< eViewElement, cTemplateViewElement*>(ve, viewElement)); -} - -void cTemplateViewAudioTracks::AddViewList(string sViewList, cTemplateViewList *viewList) { - - eViewList vl = vlUndefined; - if (!sViewList.compare("menuitems")) { - vl = vlMenuItem; - } - - if (vl == vlUndefined) { - esyslog("skindesigner: unknown ViewList in displaymenu: %s", sViewList.c_str()); - return; - } - - viewList->SetGlobals(globals); - viewLists.insert(pair< eViewList, cTemplateViewList*>(vl, viewList)); -} - -/************************************************************************************ -* cTemplateViewPlugin -************************************************************************************/ - -cTemplateViewPlugin::cTemplateViewPlugin(string pluginName, int viewID) { - this->pluginName = pluginName; - this->viewID = viewID; - viewName = "displayplugin"; - //definition of allowed parameters for class itself - set<string> attributes; - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("shifttime"); - attributes.insert("shifttype"); - attributes.insert("shiftmode"); - attributes.insert("startx"); - attributes.insert("starty"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("hideroot"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(viewName, attributes)); - - //definition of allowed parameters for viewtab - attributes.clear(); - attributes.insert("debug"); - attributes.insert("name"); - attributes.insert("condition"); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("layer"); - attributes.insert("transparency"); - attributes.insert("scrollheight"); - funcsAllowed.insert(pair< string, set<string> >("tab", attributes)); - - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("name"); - funcsAllowed.insert(pair< string, set<string> >("grid", attributes)); - - viewElementsAllowed.insert("viewelement"); - viewElementsAllowed.insert("scrollbar"); - viewElementsAllowed.insert("tablabels"); - viewGridsAllowed.insert("grid"); -} - -cTemplateViewPlugin::~cTemplateViewPlugin() { -} - -void cTemplateViewPlugin::AddSubView(string sSubView, cTemplateView *subView) { - int subViewId = atoi(sSubView.c_str()); - subViews.insert(pair< eSubView, cTemplateView* >((eSubView)subViewId, subView)); -} - -void cTemplateViewPlugin::AddViewElement(string sViewElement, cTemplateViewElement *viewElement) { - eViewElement ve = veUndefined; - string viewElementName = ""; - int viewElementID = -1; - - bool found = viewElement->GetName(viewElementName); - - if (found) { - viewElementID = config.GetPluginViewElementID(pluginName, viewElementName, viewID); - } else { - //check for internal view elements - ePluginInteralViewElements pve = pveUndefined; - if (!sViewElement.compare("scrollbar")) { - pve = pveScrollbar; - } else if (!sViewElement.compare("tablabels")) { - pve = pveTablabels; - } - if (pve == pveUndefined) { - esyslog("skindesigner: %s: unknown ViewElement in displayplugin: %s", pluginName.c_str(), viewElementName.c_str()); - return; - } - viewElementID = pve; - } - - ve = (eViewElement)viewElementID; - viewElements.insert(pair< eViewElement, cTemplateViewElement*>(ve, viewElement)); -} - -void cTemplateViewPlugin::AddGrid(cTemplateViewGrid *viewGrid) { - string gridName = ""; - bool found = viewGrid->GetName(gridName); - - if (!found) { - esyslog("skindesigner: no name defined for plugin %s grid", pluginName.c_str()); - } - int gridID = config.GetPluginViewGridID(pluginName, gridName, viewID); - - if (gridID == -1) { - esyslog("skindesigner: %s: unknown Grid in displayplugin: %s", pluginName.c_str(), gridName.c_str()); - return; - } - - viewGrids.insert(pair< int, cTemplateViewGrid*>(gridID, viewGrid)); -} - -void cTemplateViewPlugin::AddViewTab(cTemplateViewTab *viewTab) { - viewTabs.push_back(viewTab); -} diff --git a/libtemplate/templateview.h b/libtemplate/templateview.h deleted file mode 100644 index 1713cdc..0000000 --- a/libtemplate/templateview.h +++ /dev/null @@ -1,243 +0,0 @@ -#ifndef __TEMPLATEVIEW_H -#define __TEMPLATEVIEW_H - -#include <iostream> -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <string> -#include <vector> -#include <map> -#include <set> -#include <sstream> - -#include "templateviewelement.h" -#include "templateviewlist.h" -#include "templateviewgrid.h" -#include "templatepixmap.h" -#include "templateviewtab.h" -#include "templatefunction.h" - -using namespace std; - -// --- cTemplateView ------------------------------------------------------------- - -enum eSubView { - svUndefined, - svMenuDefault, - svMenuMain, - svMenuSetup, - svMenuSchedules, - svMenuTimers, - svMenuRecordings, - svMenuChannels, - svMenuDetailedEpg, - svMenuDetailedRecording, - svMenuDetailedText, - svMenuPlugin, -}; - -class cTemplateView { -private: -protected: - cGlobals *globals; - //view parameters - string viewName; - cTemplateFunction *parameters; - int containerX; - int containerY; - int containerWidth; - int containerHeight; - //basic view data structures - multimap < eViewElement, cTemplateViewElement* > viewElements; - multimap < eViewList, cTemplateViewList* > viewLists; - map < int, cTemplateViewGrid* > viewGrids; - map < eSubView, cTemplateView* > subViews; - vector< cTemplateViewTab* > viewTabs; - map < string, map< int, cTemplateView*> > pluginViews; - //helpers to iterate data structures - map < eViewElement, cTemplateViewElement* >::iterator veIt; - map < eViewList, cTemplateViewList* >::iterator vlIt; - map < int, cTemplateViewGrid* >::iterator geIt; - map < eSubView, cTemplateView* >::iterator svIt; - vector< cTemplateViewTab* >::iterator vtIt; - //helpers to check valid xml templates - set<string> subViewsAllowed; - set<string> viewElementsAllowed; - set<string> viewListsAllowed; - set<string> viewGridsAllowed; - map < string, set < string > > funcsAllowed; - void SetFunctionDefinitions(void); -public: - cTemplateView(void); - virtual ~cTemplateView(void); - virtual string GetSubViewName(eSubView sv) { return ""; }; - virtual string GetViewElementName(eViewElement ve) { return ""; }; - virtual string GetViewListName(eViewList vl) { return ""; }; - virtual void AddSubView(string sSubView, cTemplateView *subView) {}; - virtual void AddPluginView(string plugName, int templNo, cTemplateView *plugView) {}; - virtual void AddViewElement(string sViewElement, cTemplateViewElement *viewElement) {}; - virtual void AddGrid(cTemplateViewGrid *viewGrid) {}; - virtual void AddViewList(string sViewList, cTemplateViewList *viewList) {}; - virtual void AddViewTab(cTemplateViewTab *viewTab) {}; - //Setter Functions - void SetGlobals(cGlobals *globals) { this->globals = globals; }; - void SetParameters(vector<pair<string, string> > ¶ms); - void SetContainer(int x, int y, int width, int height); - //access view elements - cTemplateViewElement *GetViewElement(eViewElement ve); - void InitViewElementIterator(void); - cTemplateViewElement *GetNextViewElement(void); - //access view grids - cTemplateViewGrid *GetViewGrid(int gridID); - void InitViewGridIterator(void); - cTemplateViewGrid *GetNextViewGrid(void); - //access list elements - cTemplateViewList *GetViewList(eViewList vl); - void InitViewListIterator(void); - cTemplateViewList *GetNextViewList(void); - bool IsListView(void) { return viewLists.size() > 0 ? true : false; }; - //access tabs - void InitViewTabIterator(void); - cTemplateViewTab *GetNextViewTab(void); - //access sub views - cTemplateView *GetSubView(eSubView sv); - void InitSubViewIterator(void); - cTemplateView *GetNextSubView(void); - //access plugin views - cTemplateView *GetPluginView(string pluginName, int pluginMenu); - //Getter Functions - const char *GetViewName(void) { return viewName.c_str(); }; - int GetNumericParameter(eParamType type); - cRect GetOsdSize(void); - int GetNumPixmaps(void); - int GetNumPixmapsViewElement(eViewElement ve); - bool DrawGebugGrid(void); - int DebugGridX(void); - int DebugGridY(void); - tColor DebugGridColor(void); - tColor DebugGridFontColor(void); - bool HideView(void); - bool ExecuteView(eViewElement ve); - bool DetachViewElement(eViewElement ve); - string GetViewElementMode(eViewElement ve); - int GetNumListViewMenuItems(void); - bool GetScalingWindow(cRect &scalingWindow); - map<string,string> GetCustomStringTokens(void) { return globals->GetCustomStringTokens(); }; - map<string,int> GetCustomIntTokens(void) { return globals->GetCustomIntTokens(); }; - bool CustomTokenChange(void) { return globals->CustomTokenChange(); }; - //Checks for parsing template XML files - bool ValidSubView(const char *subView); - bool ValidViewElement(const char *viewElement); - bool ValidViewList(const char *viewList); - bool ValidViewGrid(const char *viewGrid); - bool ValidFunction(const char *func); - bool ValidAttribute(const char *func, const char *att); - //Caching - void Translate(void); - void PreCache(bool isSubview); - //Debug - void Debug(void); -}; - -// --- cTemplateViewChannel ------------------------------------------------------------- - -class cTemplateViewChannel : public cTemplateView { -private: - void SetViewElements(void); - void SetViewLists(void); - eViewElement GetViewElementID(string sViewElement); -public: - cTemplateViewChannel(void); - virtual ~cTemplateViewChannel(void); - string GetViewElementName(eViewElement ve); - void AddViewElement(string sViewElement, cTemplateViewElement *viewElement); -}; - -// --- cTemplateViewMenu ------------------------------------------------------------- - -class cTemplateViewMenu : public cTemplateView { -private: - void SetSubViews(void); - void SetViewElements(void); - void SetViewLists(void); -public: - cTemplateViewMenu(void); - virtual ~cTemplateViewMenu(void); - string GetSubViewName(eSubView sv); - string GetViewElementName(eViewElement ve); - string GetViewListName(eViewList vl); - void AddSubView(string sSubView, cTemplateView *subView); - void AddPluginView(string plugName, int templNo, cTemplateView *plugView); - void AddViewElement(string sViewElement, cTemplateViewElement *viewElement); - void AddViewList(string sViewList, cTemplateViewList *viewList); - void AddViewTab(cTemplateViewTab *viewTab); -}; - -// --- cTemplateViewMessage ------------------------------------------------------------- - -class cTemplateViewMessage : public cTemplateView { -private: - void SetViewElements(void); -public: - cTemplateViewMessage(void); - virtual ~cTemplateViewMessage(void); - string GetViewElementName(eViewElement ve); - void AddViewElement(string sViewElement, cTemplateViewElement *viewElement); -}; - -// --- cTemplateViewReplay ------------------------------------------------------------- - -class cTemplateViewReplay : public cTemplateView { -private: - void SetViewElements(void); -public: - cTemplateViewReplay(void); - virtual ~cTemplateViewReplay(void); - string GetViewElementName(eViewElement ve); - void AddViewElement(string sViewElement, cTemplateViewElement *viewElement); -}; - -// --- cTemplateViewVolume ------------------------------------------------------------- - -class cTemplateViewVolume : public cTemplateView { -private: - void SetViewElements(void); -public: - cTemplateViewVolume(void); - virtual ~cTemplateViewVolume(void); - string GetViewElementName(eViewElement ve); - void AddViewElement(string sViewElement, cTemplateViewElement *viewElement); -}; - -// --- cTemplateViewAudioTracks ------------------------------------------------------------- - -class cTemplateViewAudioTracks : public cTemplateView { -private: - void SetViewElements(void); - void SetViewLists(void); -public: - cTemplateViewAudioTracks(void); - virtual ~cTemplateViewAudioTracks(void); - string GetViewElementName(eViewElement ve); - string GetViewListName(eViewList vl); - void AddViewElement(string sViewElement, cTemplateViewElement *viewElement); - void AddViewList(string sViewList, cTemplateViewList *viewList); -}; - -// --- cTemplateViewPlugin ------------------------------------------------------------- - -class cTemplateViewPlugin : public cTemplateView { -private: - string pluginName; - int viewID; -public: - cTemplateViewPlugin(string pluginName, int viewID); - virtual ~cTemplateViewPlugin(void); - void AddSubView(string sSubView, cTemplateView *subView); - void AddViewElement(string sViewElement, cTemplateViewElement *viewElement); - void AddGrid(cTemplateViewGrid *viewGrid); - void AddViewTab(cTemplateViewTab *viewTab); -}; - -#endif //__TEMPLATEVIEW_H diff --git a/libtemplate/templateviewelement.c b/libtemplate/templateviewelement.c deleted file mode 100644 index 56672b8..0000000 --- a/libtemplate/templateviewelement.c +++ /dev/null @@ -1,236 +0,0 @@ -#include "templateviewelement.h"
-#include "../config.h"
-
-cTemplateViewElement::cTemplateViewElement(void) {
- debugTokens = false;
- parameters = NULL;
- containerX = 0;
- containerY = 0;
- containerWidth = 0;
- containerHeight = 0;
- pixOffset = -1;
- pixmapIterator = NULL;
- currentNode = NULL;
-}
-
-cTemplateViewElement::~cTemplateViewElement(void) {
- if (parameters)
- delete parameters;
- for (vector<cTemplatePixmapNode*>::iterator it = viewPixmapNodes.begin(); it != viewPixmapNodes.end(); it++) {
- delete (*it);
- }
-}
-
-void cTemplateViewElement::SetContainer(int x, int y, int width, int height) {
- containerX = x;
- containerY = y;
- containerWidth = width;
- containerHeight = height;
-}
-
-void cTemplateViewElement::SetGlobals(cGlobals *globals) {
- this->globals = globals;
- for (vector<cTemplatePixmapNode*>::iterator pix = viewPixmapNodes.begin(); pix != viewPixmapNodes.end(); pix++) {
- (*pix)->SetGlobals(globals);
- }
-}
-
-void cTemplateViewElement::SetParameters(vector<pair<string, string> > ¶ms) {
- parameters = new cTemplateFunction(ftViewElement);
- parameters->SetGlobals(globals);
- parameters->SetParameters(params);
-}
-
-bool cTemplateViewElement::CalculateParameters(void) {
- if (!parameters)
- return true;
- bool paramsValid = true;
- parameters->SetContainer(containerX, containerY, containerWidth, containerHeight);
- parameters->SetGlobals(globals);
- paramsValid = parameters->CalculateParameters();
- parameters->ParseParameters();
- return paramsValid;
-}
-
-bool cTemplateViewElement::CalculatePixmapParameters(void) {
- bool paramsValid = true;
- for (vector<cTemplatePixmapNode*>::iterator pix = viewPixmapNodes.begin(); pix != viewPixmapNodes.end(); pix++) {
- (*pix)->SetContainer(containerX, containerY, containerWidth, containerHeight);
- (*pix)->SetGlobals(globals);
- paramsValid = paramsValid && (*pix)->CalculateParameters();
- }
- return paramsValid;
-}
-
-bool cTemplateViewElement::CalculatePixmapParametersList(int orientation, int numElements) {
- bool paramsValid = true;
- for (vector<cTemplatePixmapNode*>::iterator pix = viewPixmapNodes.begin(); pix != viewPixmapNodes.end(); pix++) {
- (*pix)->SetContainer(containerX, containerY, containerWidth, containerHeight);
- (*pix)->SetGlobals(globals);
- if (orientation == orHorizontal) {
- if (numElements > 0) {
- int width = containerWidth / numElements;
- (*pix)->SetWidth(width);
- }
- } else if (orientation == orVertical) {
- if (numElements > 0) {
- int height = containerHeight / numElements;
- (*pix)->SetHeight(height);
- }
- }
- paramsValid = paramsValid && (*pix)->CalculateParameters();
- }
- return paramsValid;
-}
-
-int cTemplateViewElement::GetNumericParameter(eParamType type) {
- if (!parameters)
- return -1;
- return parameters->GetNumericParameter(type);
-}
-
-int cTemplateViewElement::GetNumPixmaps(void) {
- int numPixmaps = 0;
- for (vector<cTemplatePixmapNode*>::iterator pix = viewPixmapNodes.begin(); pix != viewPixmapNodes.end(); pix++) {
- numPixmaps += (*pix)->NumPixmaps();
- }
- return numPixmaps;
-};
-
-bool cTemplateViewElement::GetName(string &name) {
- if (!parameters)
- return false;
- name = parameters->GetParameter(ptName);
- if (name.size() > 0)
- return true;
- return false;
-}
-
-void cTemplateViewElement::InitPixmapNodeIterator(void) {
- pixmapNodeIterator = viewPixmapNodes.begin();
-}
-
-cTemplatePixmapNode *cTemplateViewElement::GetNextPixmapNode(void) {
- if (pixmapNodeIterator == viewPixmapNodes.end())
- return NULL;
- cTemplatePixmapNode *pix = *pixmapNodeIterator;
- pixmapNodeIterator++;
- return pix;
-}
-
-void cTemplateViewElement::InitPixmapIterator(void) {
- pixmapNodeIterator = viewPixmapNodes.begin();
- if (pixmapNodeIterator == viewPixmapNodes.end())
- return;
- if (!(*pixmapNodeIterator)->IsContainer()) {
- //first node is a pixmap, use this
- pixmapIterator = dynamic_cast<cTemplatePixmap*>(*pixmapNodeIterator);
- return;
- }
- //first node is a container, so fetch first pixmap of this container
- currentNode = dynamic_cast<cTemplatePixmapContainer*>(*pixmapNodeIterator);
- currentNode->InitIterator();
- pixmapIterator = currentNode->GetNextPixmap();
-}
-
-cTemplatePixmap *cTemplateViewElement::GetNextPixmap(void) {
- if (!pixmapIterator)
- return NULL;
- cTemplatePixmap *current = pixmapIterator;
- //set next pixmap
- if (!currentNode) {
- //last node was a pixmap
- pixmapNodeIterator++;
- if (pixmapNodeIterator == viewPixmapNodes.end()) {
- pixmapIterator = NULL;
- return current;
- }
- if (!(*pixmapNodeIterator)->IsContainer()) {
- //node is a pixmap, use this
- pixmapIterator = dynamic_cast<cTemplatePixmap*>(*pixmapNodeIterator);
- return current;
- }
- //node is a container, so fetch first pixmap of this container
- currentNode = dynamic_cast<cTemplatePixmapContainer*>(*pixmapNodeIterator);
- currentNode->InitIterator();
- pixmapIterator = currentNode->GetNextPixmap();
- } else {
- pixmapIterator = currentNode->GetNextPixmap();
- if (pixmapIterator) {
- return current;
- }
- currentNode = NULL;
- pixmapNodeIterator++;
- if (pixmapNodeIterator == viewPixmapNodes.end()) {
- pixmapIterator = NULL;
- return current;
- }
- if (!(*pixmapNodeIterator)->IsContainer()) {
- //node is a pixmap, use this
- pixmapIterator = dynamic_cast<cTemplatePixmap*>(*pixmapNodeIterator);
- return current;
- }
- //node is a container, so fetch first pixmap of this container
- currentNode = dynamic_cast<cTemplatePixmapContainer*>(*pixmapNodeIterator);
- currentNode->InitIterator();
- pixmapIterator = currentNode->GetNextPixmap();
- }
- return current;
-}
-
-cTemplateFunction *cTemplateViewElement::GetFunction(string name) {
- InitPixmapIterator();
- cTemplatePixmap *pix = NULL;
- while (pix = GetNextPixmap()) {
- pix->InitFunctionIterator();
- cTemplateFunction *func = NULL;
- while(func = pix->GetNextFunction()) {
- if (func->GetType() == ftDrawText) {
- string funcName = func->GetParameter(ptName);
- if (!funcName.compare(name))
- return func;
- } else {
- continue;
- }
- }
- }
- return NULL;
-}
-
-bool cTemplateViewElement::Execute(void) {
- if (!parameters)
- return true;
- return parameters->DoExecute();
-}
-
-bool cTemplateViewElement::Detach(void) {
- if (!parameters)
- return false;
- int detached = parameters->GetNumericParameter(ptDetached);
- if (detached == 1)
- return true;
- return false;
-}
-
-string cTemplateViewElement::GetMode(void) {
- if (!parameters)
- return "";
- return parameters->GetParameter(ptMode);
-}
-
-bool cTemplateViewElement::DebugTokens(void) {
- if (!parameters)
- return false;
- return parameters->DoDebug();
-}
-
-
-void cTemplateViewElement::Debug(void) {
- esyslog("skindesigner: viewelement container size x: %d, y: %d, width: %d, height %d", containerX, containerY, containerWidth, containerHeight);
- if (parameters)
- parameters->Debug();
- return;
- for (vector<cTemplatePixmapNode*>::iterator it = viewPixmapNodes.begin(); it != viewPixmapNodes.end(); it++) {
- (*it)->Debug();
- }
-}
\ No newline at end of file diff --git a/libtemplate/templateviewelement.h b/libtemplate/templateviewelement.h deleted file mode 100644 index 189e9e5..0000000 --- a/libtemplate/templateviewelement.h +++ /dev/null @@ -1,127 +0,0 @@ -#ifndef __TEMPLATEVIEWELEMENT_H
-#define __TEMPLATEVIEWELEMENT_H
-
-#include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <string>
-#include <vector>
-#include <map>
-#include <set>
-#include <sstream>
-
-#include "templatepixmap.h"
-#include "templatefunction.h"
-
-using namespace std;
-
-// --- cTemplateViewElement -------------------------------------------------------------
-
-enum eViewElement {
- //Common ViewElements
- veUndefined,
- veBackground,
- veDateTime,
- veTime,
- veMessage,
- veSortMode,
- veDevices,
- veCurrentWeather,
- veCustomTokens,
- //DisplayChannel ViewElements
- veChannelInfo,
- veChannelGroup,
- veEpgInfo,
- veProgressBar,
- veProgressBarBack,
- veStatusInfo,
- veAudioInfo,
- veScreenResolution,
- veSignalQuality,
- veSignalQualityBack,
- veScraperContent,
- veEcmInfo,
- //DisplayMenu ViewElements
- veHeader,
- veButtons,
- veDiscUsage,
- veSystemLoad,
- veSystemMemory,
- veVDRStats,
- veTemperatures,
- veTimers,
- veLastRecordings,
- veCurrentSchedule,
- veMenuItem,
- veMenuCurrentItemDetail,
- veScrollbar,
- veDetailHeader,
- veTabLabels,
- //DisplayReplay ViewElements
- veRecTitle,
- veRecInfo,
- veRecCurrent,
- veRecTotal,
- veRecEnd,
- veRecProgressBar,
- veCuttingMarks,
- veControlIcons,
- veControlIconsModeOnly,
- veProgressModeOnly,
- veBackgroundModeOnly,
- veRecJump,
- veOnPause,
- veOnPauseModeOnly,
- //DisplayVolume ViewElements
- veVolume
-};
-
-enum ePluginInteralViewElements {
- pveScrollbar = -1,
- pveTablabels = -2,
- pveUndefined = 0
-};
-
-class cTemplateViewElement {
-protected:
- bool debugTokens;
- cGlobals *globals;
- cTemplateFunction *parameters;
- int containerX;
- int containerY;
- int containerWidth;
- int containerHeight;
- vector<cTemplatePixmapNode*> viewPixmapNodes;
- vector<cTemplatePixmapNode*>::iterator pixmapNodeIterator;
- cTemplatePixmap *pixmapIterator;
- cTemplatePixmapContainer *currentNode;
- int pixOffset;
-public:
- cTemplateViewElement(void);
- virtual ~cTemplateViewElement(void);
- void SetContainer(int x, int y, int width, int height);
- virtual void SetGlobals(cGlobals *globals);
- void SetParameters(vector<pair<string, string> > ¶ms);
- bool CalculateParameters(void);
- virtual bool CalculatePixmapParameters(void);
- bool CalculatePixmapParametersList(int orientation, int numElements);
- void AddPixmap(cTemplatePixmapNode *pix) { viewPixmapNodes.push_back(pix); };
- int GetNumericParameter(eParamType type);
- void SetPixOffset(int offset) { pixOffset = offset; };
- int GetPixOffset(void) { return pixOffset; };
- virtual int GetNumPixmaps(void);
- bool GetName(string &name);
- void InitPixmapNodeIterator(void);
- cTemplatePixmapNode *GetNextPixmapNode(void);
- void InitPixmapIterator(void);
- cTemplatePixmap *GetNextPixmap(void);
- cTemplateFunction *GetFunction(string name);
- bool Execute(void);
- bool Detach(void);
- string GetMode(void);
- bool DebugTokens(void);
- virtual void Debug(void);
-};
-
-#endif //__TEMPLATEVIEWELEMENT_H
\ No newline at end of file diff --git a/libtemplate/templateviewgrid.c b/libtemplate/templateviewgrid.c deleted file mode 100644 index bd73d84..0000000 --- a/libtemplate/templateviewgrid.c +++ /dev/null @@ -1,29 +0,0 @@ -#include "templateviewgrid.h"
-#include "../config.h"
-#include "../libcore/helpers.h"
-
-cTemplateViewGrid::cTemplateViewGrid(void) : cTemplateViewElement() {
-}
-
-cTemplateViewGrid::~cTemplateViewGrid(void) {
-}
-
-bool cTemplateViewGrid::CalculatePixmapParameters(void) {
- bool paramsValid = true;
- int gridX = parameters->GetNumericParameter(ptX);
- int gridY = parameters->GetNumericParameter(ptY);
- int gridWidth = parameters->GetNumericParameter(ptWidth);
- int gridHeight = parameters->GetNumericParameter(ptHeight);
-
- for (vector<cTemplatePixmapNode*>::iterator pix = viewPixmapNodes.begin(); pix != viewPixmapNodes.end(); pix++) {
- (*pix)->SetContainer(gridX, gridY, gridWidth, gridHeight);
- (*pix)->SetGlobals(globals);
- paramsValid = paramsValid && (*pix)->CalculateParameters();
- }
- return paramsValid;
-}
-
-void cTemplateViewGrid::Debug(void) {
- esyslog("skindesigner: --- Grid: ");
- cTemplateViewElement::Debug();
-}
\ No newline at end of file diff --git a/libtemplate/templateviewgrid.h b/libtemplate/templateviewgrid.h deleted file mode 100644 index 6b5c34a..0000000 --- a/libtemplate/templateviewgrid.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __TEMPLATEVIEWGRID_H -#define __TEMPLATEVIEWGRID_H - -#include <string> -#include <vector> -#include <map> -#include <set> -#include <sstream> - -#include "templateviewelement.h" - -using namespace std; - -// --- cTemplateViewGrid ------------------------------------------------------------- - -class cTemplateViewGrid : public cTemplateViewElement { -private: -public: - cTemplateViewGrid(void); - ~cTemplateViewGrid(void); - bool CalculatePixmapParameters(void); - void Debug(void); -}; - -#endif //__TEMPLATEVIEWGRID_H
\ No newline at end of file diff --git a/libtemplate/templateviewlist.c b/libtemplate/templateviewlist.c deleted file mode 100644 index a831d2d..0000000 --- a/libtemplate/templateviewlist.c +++ /dev/null @@ -1,181 +0,0 @@ -#include "templateviewlist.h"
-#include "../config.h"
-#include "../libcore/helpers.h"
-
-cTemplateViewList::cTemplateViewList(void) : cTemplateViewElement() {
- listElement = NULL;
- currentElement = NULL;
-}
-
-cTemplateViewList::~cTemplateViewList(void) {
- if (listElement)
- delete listElement;
- if (currentElement)
- delete currentElement;
-}
-
-void cTemplateViewList::SetGlobals(cGlobals *globals) {
- cTemplateViewElement::SetGlobals(globals);
- if (listElement)
- listElement->SetGlobals(globals);
- if (currentElement)
- currentElement->SetGlobals(globals);
-}
-
-bool cTemplateViewList::CalculateListParameters(void) {
- if (!parameters)
- return false;
- bool paramsValid = false;
- if (!listElement)
- return false;
- listElement->SetContainer(parameters->GetNumericParameter(ptX),
- parameters->GetNumericParameter(ptY),
- parameters->GetNumericParameter(ptWidth),
- parameters->GetNumericParameter(ptHeight));
- paramsValid = listElement->CalculateParameters();
- paramsValid = listElement->CalculatePixmapParametersList(parameters->GetNumericParameter(ptOrientation),
- parameters->GetNumericParameter(ptNumElements));
- if (!currentElement)
- return paramsValid;
- currentElement->SetContainer(parameters->GetNumericParameter(ptX),
- parameters->GetNumericParameter(ptY),
- parameters->GetNumericParameter(ptWidth),
- parameters->GetNumericParameter(ptHeight));
- paramsValid = currentElement->CalculateParameters();
- paramsValid = currentElement->CalculatePixmapParameters();
- currentElement->SetPixOffset(0);
- return paramsValid;
-}
-
-bool cTemplateViewList::CalculateListParameters(map < string, int > *intTokens) {
- if (!parameters)
- return false;
- parameters->ClearDynamicParameters();
- parameters->SetIntTokens(intTokens);
- parameters->ParseParameters();
- parameters->UnsetIntTokens();
-
- listElement->SetContainer(parameters->GetNumericParameter(ptX),
- parameters->GetNumericParameter(ptY),
- parameters->GetNumericParameter(ptWidth),
- parameters->GetNumericParameter(ptHeight));
- bool paramsValid = listElement->CalculateParameters();
- paramsValid = listElement->CalculatePixmapParametersList(parameters->GetNumericParameter(ptOrientation),
- parameters->GetNumericParameter(ptNumElements));
- return paramsValid;
-}
-
-eOrientation cTemplateViewList::GetOrientation(void) {
- if (!parameters)
- return orNone;
- int orientation = parameters->GetNumericParameter(ptOrientation);
- return (eOrientation)orientation;
-}
-
-int cTemplateViewList::GetAverageFontWidth(void) {
- int defaultAverageFontWidth = 20;
-
- if (!listElement)
- return defaultAverageFontWidth;
-
- int numItems = GetNumericParameter(ptNumElements);
- int listHeight = GetNumericParameter(ptHeight);
- if (listHeight <= 0)
- return defaultAverageFontWidth;
- int itemHeight = (double)listHeight / (double)numItems;
- string fontFuncName = parameters->GetParameter(ptDeterminateFont);
-
- cTemplateFunction *fontFunc = listElement->GetFunction(fontFuncName);
- if (!fontFunc)
- return defaultAverageFontWidth;
-
- string fontNameToken = fontFunc->GetParameter(ptFont);
- string paramFontSize = fontFunc->GetParameter(ptFontSize);
-
- string fontName = "";
- if (IsToken(fontNameToken)) {
- if (!globals->GetFont(fontNameToken, fontName)) {
- if (!globals->GetFont("{vdrOsd}", fontName)) {
- return defaultAverageFontWidth;
- }
- }
- } else {
- //if no token, directly use input
- fontName = fontNameToken;
- }
-
- cNumericParameter pFontSize(paramFontSize);
- pFontSize.SetGlobals(globals);
- pFontSize.SetAreaSize(1000, itemHeight);
- pFontSize.SetVertical();
- int fontSize = pFontSize.Parse(paramFontSize);
- if (!pFontSize.Valid())
- return defaultAverageFontWidth;
-
- int averageFontWidth = fontManager->Width(fontName, fontSize, "x") + 3;
- return averageFontWidth;
-}
-
-cFont *cTemplateViewList::GetTextAreaFont(void) {
- if (!listElement)
- return NULL;
-
- int numItems = GetNumericParameter(ptNumElements);
- int listHeight = GetNumericParameter(ptHeight);
- if (listHeight <= 0)
- return NULL;
- int itemHeight = (double)listHeight / (double)numItems;
- string fontFuncName = parameters->GetParameter(ptDeterminateFont);
-
- cTemplateFunction *fontFunc = listElement->GetFunction(fontFuncName);
- if (!fontFunc)
- return NULL;
-
- string fontNameToken = fontFunc->GetParameter(ptFont);
- string paramFontSize = fontFunc->GetParameter(ptFontSize);
-
- string fontName = "";
- if (IsToken(fontNameToken)) {
- if (!globals->GetFont(fontNameToken, fontName)) {
- if (!globals->GetFont("{vdrOsd}", fontName)) {
- return NULL;
- }
- }
- } else {
- //if no token, directly use input
- fontName = fontNameToken;
- }
-
- cNumericParameter pFontSize(paramFontSize);
- pFontSize.SetGlobals(globals);
- pFontSize.SetAreaSize(1000, itemHeight);
- pFontSize.SetVertical();
- int fontSize = pFontSize.Parse(paramFontSize);
- if (!pFontSize.Valid())
- return NULL;
-
- return fontManager->FontUncached(fontName, fontSize);
-}
-
-
-int cTemplateViewList::GetMenuItemWidth(void) {
- return GetNumericParameter(ptMenuItemWidth);
-}
-
-
-int cTemplateViewList::GetNumPixmaps(void) {
- if (!listElement)
- return 0;
- return listElement->GetNumPixmaps();
-}
-
-void cTemplateViewList::Debug(void) {
- if (parameters)
- parameters->Debug();
- esyslog("skindesigner: --- listelement: ");
- if (listElement)
- listElement->Debug();
- esyslog("skindesigner: --- currentelement: ");
- if (currentElement)
- currentElement->Debug();
-}
\ No newline at end of file diff --git a/libtemplate/templateviewlist.h b/libtemplate/templateviewlist.h deleted file mode 100644 index 4cc4ccb..0000000 --- a/libtemplate/templateviewlist.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef __TEMPLATEVIEWLIST_H -#define __TEMPLATEVIEWLIST_H - -#include <iostream> -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <string> -#include <vector> -#include <map> -#include <set> -#include <sstream> - -#include "templateviewelement.h" - -using namespace std; - -// --- cTemplateViewList ------------------------------------------------------------- - -enum eViewList { - vlUndefined, - vlMenuItem -}; - -class cTemplateViewList : public cTemplateViewElement { -private: - cTemplateViewElement *listElement; - cTemplateViewElement *currentElement; -public: - cTemplateViewList(void); - ~cTemplateViewList(void); - void SetGlobals(cGlobals *globals); - void AddListElement(cTemplateViewElement *listElement) { this->listElement = listElement; }; - void AddCurrentElement(cTemplateViewElement *currentElement) { this->currentElement = currentElement; }; - bool CalculateListParameters(void); - bool CalculateListParameters(map < string, int > *intTokens); - cTemplateViewElement *GetListElement(void) { return listElement; }; - cTemplateViewElement *GetListElementCurrent(void) { return currentElement; }; - eOrientation GetOrientation(void); - int GetAverageFontWidth(void); - cFont *GetTextAreaFont(void); - int GetMenuItemWidth(void); - int GetNumPixmaps(void); - void Debug(void); -}; - -#endif //__TEMPLATEVIEWLIST_H
\ No newline at end of file diff --git a/libtemplate/templateviewtab.c b/libtemplate/templateviewtab.c deleted file mode 100644 index 1e9f463..0000000 --- a/libtemplate/templateviewtab.c +++ /dev/null @@ -1,38 +0,0 @@ -#include "templateviewtab.h" - -cTemplateViewTab::cTemplateViewTab(void) : cTemplatePixmap() { - scrollStep = -1; -} - -cTemplateViewTab::~cTemplateViewTab(void) { -} - -int cTemplateViewTab::GetScrollStep(void) { - if (scrollStep > 0) - return scrollStep; - int pixWidth = GetNumericParameter(ptWidth); - int pixHeight = GetNumericParameter(ptHeight); - string scrollHeight = parameters->GetParameter(ptScrollHeight); - - cNumericParameter p(scrollHeight); - p.SetAreaSize(pixWidth, pixHeight); - string parsedValue = ""; - scrollStep = p.Parse(parsedValue); - if (scrollStep < 1) - scrollStep = 50; - return scrollStep; -} - -string cTemplateViewTab::GetName(void) { - return parameters->GetParameter(ptName); -} - -void cTemplateViewTab::SetName(string trans) { - parameters->SetParameter(ptName, trans); -} - -void cTemplateViewTab::Debug(void) { - esyslog("skindesigner: cTemplateViewTab Debug %s", GetName().c_str()); - cTemplatePixmap::Debug(); - esyslog("skindesigner: -------------------------------------------------------"); -} diff --git a/libtemplate/templateviewtab.h b/libtemplate/templateviewtab.h deleted file mode 100644 index 8514cad..0000000 --- a/libtemplate/templateviewtab.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef __TEMPLATEVIEWTAB_H -#define __TEMPLATEVIEWTAB_H - -#include <iostream> -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <string> -#include <vector> -#include <map> -#include <set> - -#include "templatepixmap.h" - -using namespace std; - -// --- cTemplateViewTab ------------------------------------------------------------- - -class cTemplateViewTab : public cTemplatePixmap { -private: - int scrollStep; -public: - cTemplateViewTab(void); - ~cTemplateViewTab(void); - int GetScrollStep(void); - string GetName(void); - void SetName(string trans); - void Debug(void); -}; - -#endif //__TEMPLATEVIEWTAB_H
\ No newline at end of file diff --git a/libtemplate/xmlparser.c b/libtemplate/xmlparser.c deleted file mode 100644 index 8db3d3d..0000000 --- a/libtemplate/xmlparser.c +++ /dev/null @@ -1,643 +0,0 @@ -#include "xmlparser.h" -#include "../config.h" -#include "../libcore/helpers.h" - -using namespace std; - -cXmlParser::cXmlParser(void) { - view = NULL; - globals = NULL; - skinSetup = NULL; -} - -cXmlParser::~cXmlParser() { -} - -/********************************************************************* -* PUBLIC Functions -*********************************************************************/ -bool cXmlParser::ReadView(cTemplateView *view, string xmlFile) { - if (!view) - return false; - this->view = view; - string xmlPath = GetPath(xmlFile); - if (! ReadXMLFile(xmlPath.c_str()) ) - return false; - if (! Validate() ) - return false; - if (! SetDocument() ) - return false; - if (! CheckNodeName(view->GetViewName()) ) - return false; - return true; -} - -bool cXmlParser::ParseView(void) { - if (!view) - return false; - - vector<stringpair> rootAttribs = ParseAttributes(); - ValidateAttributes(NodeName(), rootAttribs); - view->SetParameters(rootAttribs); - - if (!LevelDown()) - return false; - - do { - - if (view->ValidSubView(NodeName())) { - ParseSubView(); - } else if (view->ValidViewElement(NodeName())) { - ParseViewElement(); - } else if (view->ValidViewList(NodeName())) { - ParseViewList(); - } else if (view->ValidViewGrid(NodeName())) { - ParseGrid(); - } else if (CheckNodeName("tab")) { - ParseViewTab(view); - } else { - return false; - } - - } while (NextNode()); - - return true; - -} - -bool cXmlParser::ReadPluginView(string plugName, int templateNumber, string templateName) { - string xmlPath = GetPath(templateName); - DeleteDocument(); - if (! ReadXMLFile(xmlPath.c_str()) ) - return false; - if (! Validate() ) - return false; - if (! SetDocument() ) - return false; - return true; -} - -bool cXmlParser::ParsePluginView(string plugName, int templateNumber) { - cTemplateView *plugView = new cTemplateViewMenu(); - view->AddPluginView(plugName, templateNumber, plugView); - - vector<stringpair> attribs = ParseAttributes(); - ValidateAttributes(NodeName(), attribs); - plugView->SetParameters(attribs); - - if (!LevelDown()) - return false; - do { - - if (plugView->ValidViewElement(NodeName())) { - ParseViewElement(plugView); - } else if (plugView->ValidViewList(NodeName())) { - ParseViewList(plugView); - } else if (CheckNodeName("tab")) { - ParseViewTab(plugView); - } else { - return false; - } - - } while (NextNode()); - - return true; -} - -bool cXmlParser::ReadGlobals(cGlobals *globals, string xmlFile) { - this->globals = globals; - string xmlPath = GetPath(xmlFile); - DeleteDocument(); - if (! ReadXMLFile(xmlPath.c_str()) ) - return false; - if (! Validate() ) - return false; - if (! SetDocument() ) - return false; - if (! CheckNodeName("globals") ) - return false; - return true; -} - -bool cXmlParser::ParseGlobals(void) { - if (!LevelDown()) - return false; - do { - if (CheckNodeName("colors")) { - ParseGlobalColors(); - } else if (CheckNodeName("variables")) { - ParseGlobalVariables(); - } else if (CheckNodeName("fonts")) { - ParseGlobalFonts(); - } else if (CheckNodeName("translations")) { - ParseTranslations(); - } - } while (NextNode()); - return true; -} - -bool cXmlParser::ReadSkinSetup(cSkinSetup *skinSetup, string xmlFile) { - this->skinSetup = skinSetup; - if (! ReadXMLFile(xmlFile.c_str()) ) - return false; - if (! Validate() ) - return false; - if (! SetDocument() ) - return false; - if (! CheckNodeName("setup") ) - return false; - return true; -} - -bool cXmlParser::ParseSkinSetup(string skin) { - if (!LevelDown()) - return false; - do { - if (CheckNodeName("menu")) { - ParseSetupMenu(); - } else if (CheckNodeName("translations")) { - ParseTranslations(); - } - } while (NextNode()); - return true; -} -/********************************************************************* -* PRIVATE Functions -*********************************************************************/ - -bool cXmlParser::ParseSubView(void) { - if (!view) - return false; - - cTemplateView *subView = new cTemplateViewMenu(); - view->AddSubView(NodeName(), subView); - - vector<pair<string, string> > subViewAttribs = ParseAttributes(); - ValidateAttributes(NodeName(), subViewAttribs); - subView->SetParameters(subViewAttribs); - - if (!LevelDown()) - return false; - do { - - if (subView->ValidViewElement(NodeName())) { - ParseViewElement(subView); - } else if (subView->ValidViewList(NodeName())) { - ParseViewList(subView); - } else if (CheckNodeName("tab")) { - ParseViewTab(subView); - } else { - return false; - } - - } while (NextNode()); - LevelUp(); - return true; - -} -void cXmlParser::ParseViewElement(cTemplateView *subView) { - if (!view) - return; - - const char *viewElementName = NodeName(); - vector<stringpair> attributes = ParseAttributes(); - ValidateAttributes("viewelement", attributes); - - if (!LevelDown()) - return; - - cTemplateViewElement *viewElement = new cTemplateViewElement(); - viewElement->SetParameters(attributes); - - do { - if (!CheckNodeName("areacontainer") && !CheckNodeName("area") && !CheckNodeName("areascroll")) { - esyslog("skindesigner: invalid tag \"%s\" in viewelement", NodeName()); - continue; - } - cTemplatePixmapNode *pix = NULL; - if (CheckNodeName("area") || CheckNodeName("areascroll")) { - pix = ParseArea(); - } else { - pix = ParseAreaContainer(); - } - pix->SetGlobals(globals); - viewElement->AddPixmap(pix); - } while (NextNode()); - LevelUp(); - - if (subView) - subView->AddViewElement(viewElementName, viewElement); - else - view->AddViewElement(viewElementName, viewElement); -} - -void cXmlParser::ParseViewList(cTemplateView *subView) { - if (!view) - return; - - vector<stringpair> attribs = ParseAttributes(); - ValidateAttributes(NodeName(), attribs); - - cTemplateViewList *viewList = new cTemplateViewList(); - viewList->SetGlobals(globals); - viewList->SetParameters(attribs); - - if (!LevelDown()) - return; - - do { - if (CheckNodeName("currentelement")) { - - cTemplateViewElement *currentElement = new cTemplateViewElement(); - vector<stringpair> attribsCur = ParseAttributes(); - ValidateAttributes(NodeName(), attribsCur); - currentElement->SetGlobals(globals); - currentElement->SetParameters(attribsCur); - if (!LevelDown()) - continue; - do { - if (!CheckNodeName("areacontainer") && !CheckNodeName("area") && !CheckNodeName("areascroll")) { - esyslog("skindesigner: invalid tag \"%s\" in viewelement", NodeName()); - continue; - } - cTemplatePixmapNode *pix = NULL; - if (CheckNodeName("area") || CheckNodeName("areascroll")) { - pix = ParseArea(); - } else { - pix = ParseAreaContainer(); - } - currentElement->AddPixmap(pix); - } while (NextNode()); - LevelUp(); - viewList->AddCurrentElement(currentElement); - - } else if (CheckNodeName("listelement")) { - - cTemplateViewElement *listElement = new cTemplateViewElement(); - vector<stringpair> attribsList = ParseAttributes(); - ValidateAttributes(NodeName(), attribsList); - listElement->SetGlobals(globals); - listElement->SetParameters(attribsList); - if (!LevelDown()) - return; - do { - if (!CheckNodeName("areacontainer") && !CheckNodeName("area") && !CheckNodeName("areascroll")) { - esyslog("skindesigner: invalid tag \"%s\" in viewelement", NodeName()); - continue; - } - cTemplatePixmapNode *pix = NULL; - if (CheckNodeName("area") || CheckNodeName("areascroll")) { - pix = ParseArea(); - } else { - pix = ParseAreaContainer(); - } - listElement->AddPixmap(pix); - } while (NextNode()); - LevelUp(); - viewList->AddListElement(listElement); - } - - } while (NextNode()); - LevelUp(); - - if (subView) - subView->AddViewList(NodeName(), viewList); - else - view->AddViewList(NodeName(), viewList); -} - -void cXmlParser::ParseViewTab(cTemplateView *subView) { - if (!view || !subView) - return; - - vector<stringpair> attribs = ParseAttributes(); - ValidateAttributes(NodeName(), attribs); - - cTemplateViewTab *viewTab = new cTemplateViewTab(); - viewTab->SetGlobals(globals); - viewTab->SetParameters(attribs); - viewTab->SetScrolling(); - ParseFunctionCalls(viewTab); - subView->AddViewTab(viewTab); -} - -void cXmlParser::ParseGrid(void) { - if (!view) - return; - - vector<stringpair> attributes = ParseAttributes(); - ValidateAttributes(NodeName(), attributes); - - if (!LevelDown()) - return; - - cTemplateViewGrid *viewGrid = new cTemplateViewGrid(); - viewGrid->SetParameters(attributes); - - do { - - if (!CheckNodeName("areacontainer") && !CheckNodeName("area") && !CheckNodeName("areascroll")) { - esyslog("skindesigner: invalid tag \"%s\" in grid", NodeName()); - continue; - } - cTemplatePixmapNode *pix = NULL; - if (CheckNodeName("area") || CheckNodeName("areascroll")) { - pix = ParseArea(); - } else { - pix = ParseAreaContainer(); - } - pix->SetGlobals(globals); - viewGrid->AddPixmap(pix); - } while (NextNode()); - LevelUp(); - - view->AddGrid(viewGrid); -} - -cTemplatePixmap *cXmlParser::ParseArea(void) { - vector<stringpair> attribs = ParseAttributes(); - ValidateAttributes(NodeName(), attribs); - - cTemplatePixmap *pix = new cTemplatePixmap(); - if (CheckNodeName("areascroll")) { - pix->SetScrolling(); - } - pix->SetParameters(attribs); - ParseFunctionCalls(pix); - return pix; -} - -cTemplatePixmapContainer *cXmlParser::ParseAreaContainer(void) { - vector<stringpair> attribs = ParseAttributes(); - ValidateAttributes(NodeName(), attribs); - - cTemplatePixmapContainer *pixContainer = new cTemplatePixmapContainer(); - pixContainer->SetParameters(attribs); - - if (!LevelDown()) - return pixContainer; - do { - if (!CheckNodeName("area") && !CheckNodeName("areascroll")) { - esyslog("skindesigner: invalid tag \"%s\" in areacontainer", NodeName()); - continue; - } - cTemplatePixmap *pix = ParseArea(); - pixContainer->AddPixmap(pix); - } while (NextNode()); - LevelUp(); - return pixContainer; -} - -void cXmlParser::ParseFunctionCalls(cTemplatePixmap *pix) { - if (!view) - return; - if (!LevelDown()) - return; - do { - if (CheckNodeName("loop")) { - vector<stringpair> attribs = ParseAttributes(); - ValidateAttributes(NodeName(), attribs); - cTemplateLoopFunction *loopFunc = new cTemplateLoopFunction(); - loopFunc->SetParameters(attribs); - ParseLoopFunctionCalls(loopFunc); - pix->AddLoopFunction(loopFunc); - } else if (view->ValidFunction(NodeName())) { - vector<stringpair> attribs = ParseAttributes(); - ValidateAttributes(NodeName(), attribs); - pix->AddFunction(NodeName(), attribs); - } - - } while (NextNode()); - LevelUp(); -} - -void cXmlParser::ParseLoopFunctionCalls(cTemplateLoopFunction *loopFunc) { - if (!view) - return; - if (!LevelDown()) - return; - do { - if (view->ValidFunction(NodeName())) { - vector<stringpair> attribs = ParseAttributes(); - ValidateAttributes(NodeName(), attribs); - loopFunc->AddFunction(NodeName(), attribs); - } - } while (NextNode()); - LevelUp(); -} - -void cXmlParser::ParseGlobalColors(void) { - if (!LevelDown()) - return; - do { - if (!CheckNodeName("color")) { - continue; - } - string attributeName = "name"; - string colorName = ""; - string colorValue = ""; - bool ok = GetAttribute(attributeName, colorName); - if (ok) { - ok = GetNodeValue(colorValue); - if (ok) - InsertColor(colorName, colorValue); - } - } while (NextNode()); - LevelUp(); -} - -void cXmlParser::InsertColor(string name, string value) { - if (value.size() != 8) - return; - std::stringstream str; - str << value; - tColor colVal; - str >> std::hex >> colVal; - globals->AddColor(name, colVal); -} - -void cXmlParser::ParseGlobalVariables(void) { - if (!LevelDown()) - return; - do { - if (!CheckNodeName("var")) { - continue; - } - string attributeName = "name"; - string attributeType = "type"; - string varName = ""; - string varType = ""; - string varValue = ""; - - bool ok1 = GetAttribute(attributeName, varName); - bool ok2 = GetAttribute(attributeType, varType); - - if (ok1 && ok2) { - bool ok = GetNodeValue(varValue); - if (ok) - InsertVariable(varName, varType, varValue); - } - } while (NextNode()); - LevelUp(); -} - -void cXmlParser::InsertVariable(string name, string type, string value) { - if (!type.compare("int")) { - int val = atoi(value.c_str()); - globals->AddInt(name, val); - } else if (!type.compare("double")) { - globals->AddDouble(name, value); - } else if (!type.compare("string")) { - globals->AddString(name, value); - } -} - -void cXmlParser::ParseGlobalFonts(void) { - if (!LevelDown()) - return; - do { - if (!CheckNodeName("font")) { - continue; - } - string attributeName = "name"; - string fontName = ""; - string fontValue = ""; - - bool ok = GetAttribute(attributeName, fontName); - if (ok) { - ok = GetNodeValue(fontValue); - if (ok) { - globals->AddFont(fontName, fontValue); - } - } - } while (NextNode()); - LevelUp(); -} - -void cXmlParser::ParseTranslations(void) { - if (!LevelDown()) - return; - do { - if (!CheckNodeName("token")) { - continue; - } - string attributeName = "name"; - string tokenName = ""; - - if (!GetAttribute(attributeName, tokenName)) - continue; - - if (!LevelDown()) - continue; - - stringmap tokenTranslations; - do { - if (!CheckNodeName("trans")) { - continue; - } - string attributeName = "lang"; - string language = ""; - if (!GetAttribute(attributeName, language)) - continue; - string translation = ""; - if (!GetNodeValue(translation)) - continue; - tokenTranslations.insert(stringpair(language, translation)); - } while (NextNode()); - LevelUp(); - - if (globals) { - globals->AddTranslation(tokenName, tokenTranslations); - } else if (skinSetup) { - skinSetup->SetTranslation(tokenName, tokenTranslations); - } - - } while (NextNode()); - LevelUp(); -} - -void cXmlParser::ParseSetupMenu(void) { - if (!skinSetup) - return; - if (!LevelDown()) - return; - do { - if (CheckNodeName("parameter")) { - ParseSetupParameter(); - } else if (CheckNodeName("submenu")) { - string attributeName = "name"; - string subMenuName = ""; - string attributeDisplayText = "displaytext"; - string subDisplayText = ""; - GetAttribute(attributeName, subMenuName); - GetAttribute(attributeDisplayText, subDisplayText); - skinSetup->SetSubMenu(subMenuName, subDisplayText); - ParseSetupMenu(); - } - } while (NextNode()); - skinSetup->SubMenuDone(); - LevelUp(); -} - -void cXmlParser::ParseSetupParameter(void) { - if (!skinSetup) - return; - string attributeType = "type"; - string paramType = ""; - string attributeName = "name"; - string paramName = ""; - string attributeDisplayText = "displaytext"; - string paramDisplayText = ""; - string attributeHelpText = "helptext"; - string paramHelpText = ""; - string attributeMin = "min"; - string paramMin = ""; - string attributeMax = "max"; - string paramMax = ""; - string paramValue = ""; - string attributeOptions = "options"; - string paramOptions=""; - - GetAttribute(attributeType, paramType); - GetAttribute(attributeName, paramName); - GetAttribute(attributeDisplayText, paramDisplayText); - GetAttribute(attributeHelpText, paramHelpText); - GetAttribute(attributeMin, paramMin); - GetAttribute(attributeMax, paramMax); - GetAttribute(attributeOptions, paramOptions); - GetNodeValue(paramValue); - - skinSetup->SetParameter(paramType, paramName, paramDisplayText, paramHelpText, paramMin, paramMax, paramValue, paramOptions); -} - -void cXmlParser::ValidateAttributes(const char *nodeName, vector<stringpair> &attributes) { - bool repeat = true; - while (repeat) { - repeat = false; - for (vector<stringpair>::iterator it = attributes.begin(); it != attributes.end(); it++) { - string attributeName = (*it).first; - if (!view->ValidAttribute(nodeName, attributeName.c_str())) { - attributes.erase(it); - repeat = true; - break; - } - } - } -} - -string cXmlParser::GetPath(string xmlFile) { - string activeSkin = Setup.OSDSkin; - string activeTheme = Setup.OSDTheme; - string path = ""; - if (!xmlFile.compare("globals.xml")) { - path = *cString::sprintf("%s%s/%s", *config.GetSkinPath(activeSkin), activeSkin.c_str(), xmlFile.c_str()); - } else if (!xmlFile.compare("theme.xml")) { - path = *cString::sprintf("%s%s/themes/%s/%s", *config.GetSkinPath(activeSkin), activeSkin.c_str(), activeTheme.c_str(), xmlFile.c_str()); - } else if (!xmlFile.compare("setup.xml")) { - path = *cString::sprintf("%s%s/%s", *config.GetSkinPath(activeSkin), activeSkin.c_str(), xmlFile.c_str()); - } else { - path = *cString::sprintf("%s%s/xmlfiles/%s", *config.GetSkinPath(activeSkin), activeSkin.c_str(), xmlFile.c_str()); - } - return path; -} - diff --git a/libtemplate/xmlparser.h b/libtemplate/xmlparser.h deleted file mode 100644 index 3dd0705..0000000 --- a/libtemplate/xmlparser.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef __XMLPARSER_H -#define __XMLPARSER_H - -#include <iostream> -#include <stdio.h> -#include <stdlib.h> -#include <string> -#include <vector> -#include <map> -#include <set> -#include <vdr/plugin.h> -#include "../libcore/libxmlwrapper.h" -#include "templateview.h" -#include "templateviewlist.h" -#include "templateviewgrid.h" -#include "templateviewtab.h" -#include "../libcore/skinsetup.h" - -using namespace std; - -// --- cXmlParser ------------------------------------------------------------- - -class cXmlParser : public cLibXMLWrapper { -private: - cTemplateView *view; - cGlobals *globals; - cSkinSetup *skinSetup; - //parsing views - bool ParseSubView(void); - void ParseViewElement(cTemplateView *subView = NULL); - void ParseViewList(cTemplateView *subView = NULL); - void ParseViewTab(cTemplateView *subView); - void ParseGrid(void); - cTemplatePixmap *ParseArea(void); - cTemplatePixmapContainer *ParseAreaContainer(void); - void ParseFunctionCalls(cTemplatePixmap *pix); - void ParseLoopFunctionCalls(cTemplateLoopFunction *loopFunc); - //parsing globals - void ParseGlobalColors(void); - void InsertColor(string name, string value); - void ParseGlobalVariables(void); - void InsertVariable(string name, string type, string value); - void ParseGlobalFonts(void); - void ParseTranslations(void); - //parsing skin setup - void ParseSetupMenu(void); - void ParseSetupParameter(void); - //helpers - void ValidateAttributes(const char *nodeName, vector<stringpair> &attributes); - string GetPath(string xmlFile); -public: - cXmlParser(void); - virtual ~cXmlParser(void); - //reading views - bool ReadView(cTemplateView *view, string xmlFile); - bool ParseView(void); - //reading plugin views - bool ReadPluginView(string plugName, int templateNumber, string templateName); - bool ParsePluginView(string plugName, int templateNumber); - //reading globals - bool ReadGlobals(cGlobals *globals, string xmlFile); - bool ParseGlobals(void); - //reading skin setups - bool ReadSkinSetup(cSkinSetup *skinSetup, string xmlFile); - bool ParseSkinSetup(string skin); -}; - -#endif //__XMLPARSER_H |