implemented cSDDisplayMenu::GetTextAreaFont()

This commit is contained in:
louis
2014-10-15 18:04:12 +02:00
parent 2e4a9b86ed
commit 8b8389d975
9 changed files with 84 additions and 4 deletions

View File

@@ -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);
}

View File

@@ -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);