diff options
author | louis <louis.braun@gmx.de> | 2014-10-15 18:04:12 +0200 |
---|---|---|
committer | louis <louis.braun@gmx.de> | 2014-10-15 18:04:12 +0200 |
commit | 8b8389d975f1867d5e6a8be678678fa3206f4fda (patch) | |
tree | 75c62b726167c2d8659bf67203f4099ca100c99d /libtemplate | |
parent | 2e4a9b86ed6491e85d7e032790172fe2433cc19c (diff) | |
download | vdr-plugin-skindesigner-8b8389d975f1867d5e6a8be678678fa3206f4fda.tar.gz vdr-plugin-skindesigner-8b8389d975f1867d5e6a8be678678fa3206f4fda.tar.bz2 |
implemented cSDDisplayMenu::GetTextAreaFont()
Diffstat (limited to 'libtemplate')
-rw-r--r-- | libtemplate/templateviewlist.c | 48 | ||||
-rw-r--r-- | libtemplate/templateviewlist.h | 1 |
2 files changed, 49 insertions, 0 deletions
diff --git a/libtemplate/templateviewlist.c b/libtemplate/templateviewlist.c index 808a89f..e75c528 100644 --- a/libtemplate/templateviewlist.c +++ b/libtemplate/templateviewlist.c @@ -115,6 +115,54 @@ int cTemplateViewList::GetAverageFontWidth(void) { return averageFontWidth;
}
+cFont *cTemplateViewList::GetTextAreaFont(void) {
+ if (!listElement)
+ return NULL;
+
+ int fontWidth = 0;
+ 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 ((fontNameToken.find("{") == 0) && (fontNameToken.find("}") == (fontNameToken.size()-1))) {
+ fontNameToken = fontNameToken.substr(1, fontNameToken.size()-2);
+ map<string,string>::iterator hit = globals->fonts.find(fontNameToken);
+ if (hit != globals->fonts.end()) {
+ fontName = hit->second;
+ } else {
+ map<string,string>::iterator def = globals->fonts.find("vdrOsd");
+ if (def == globals->fonts.end())
+ return NULL;
+ fontName = def->second;
+ }
+ } 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);
}
diff --git a/libtemplate/templateviewlist.h b/libtemplate/templateviewlist.h index 8998384..b124a7c 100644 --- a/libtemplate/templateviewlist.h +++ b/libtemplate/templateviewlist.h @@ -41,6 +41,7 @@ public: cTemplateViewElement *GetListElement(void) { return listElement; }; cTemplateViewElement *GetListElementCurrent(void) { return currentElement; }; int GetAverageFontWidth(void); + cFont *GetTextAreaFont(void); int GetMenuItemWidth(void); int GetNumPixmaps(void); void Debug(void); |