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

@ -21,3 +21,5 @@ Version 0.0.2
- changed display of menu lists, do flush first after complete rendering
- added support for custom tokens in dislaychannel
- added vps token in menudetailepg
- implemented cSDDisplayMenu::GetTextAreaFont()

View File

@ -2,6 +2,7 @@
#include "libcore/helpers.h"
cSDDisplayMenu::cSDDisplayMenu(cTemplate *menuTemplate) {
textAreaFont = NULL;
doOutput = true;
state = vsInit;
if (!menuTemplate) {
@ -20,6 +21,8 @@ cSDDisplayMenu::~cSDDisplayMenu() {
if (!doOutput)
return;
delete rootView;
if (textAreaFont)
delete textAreaFont;
}
void cSDDisplayMenu::Scroll(bool Up, bool Page) {
@ -180,7 +183,10 @@ int cSDDisplayMenu::GetTextAreaWidth(void) const {
}
const cFont *cSDDisplayMenu::GetTextAreaFont(bool FixedFont) const {
return NULL;
if (textAreaFont)
return textAreaFont;
textAreaFont = rootView->GetTextAreaFont();
return textAreaFont;
}
void cSDDisplayMenu::SetScrollbar(int Total, int Offset) {

View File

@ -18,6 +18,7 @@ private:
cDisplayMenuRootView *rootView;
eViewState state;
bool doOutput;
mutable cFont *textAreaFont;
protected:
int Tab(int n);
public:

View File

@ -108,6 +108,12 @@ cFont *cFontManager::Font(string fontName, int fontSize) {
return font;
}
cFont *cFontManager::FontUncached(string fontName, int fontSize) {
cMutexLock MutexLock(&mutex);
cFont *font = CreateFont(fontName, fontSize);
return font;
}
/********************************************************************************
* Private Functions
********************************************************************************/

View File

@ -28,6 +28,7 @@ class cFontManager {
int Width(string fontName, int fontSize, const char *text);
int Height(string fontName, int fontSize);
cFont *Font(string fontName, int fontSize);
cFont *FontUncached(string fontName, int fontSize);
void Debug(void);
void ListAvailableFonts(void);
};

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

View File

@ -288,15 +288,29 @@ int cDisplayMenuRootView::GetListViewWidth(void) {
int cDisplayMenuRootView::GetTextAreaWidth(void) {
if (!tmplView)
return 1900;
cTemplateView *tempSubView = tmplView->GetSubView(svMenuDefault);
if (!tempSubView)
cTemplateView *tmplSubView = tmplView->GetSubView(svMenuDefault);
if (!tmplSubView)
return 1900;
int areaWidth = tempSubView->GetNumericParameter(ptWidth);
int areaWidth = tmplSubView->GetNumericParameter(ptWidth);
if (areaWidth > 0)
return areaWidth;
return 1900;
}
cFont *cDisplayMenuRootView::GetTextAreaFont(void) {
if (!tmplView)
return NULL;
cTemplateView *tmplSubViewDefault = tmplView->GetSubView(svMenuDefault);
if (!tmplSubViewDefault)
return NULL;
cTemplateViewList *tmplViewList = tmplSubViewDefault->GetViewList(vlMenuItem);
if (!tmplViewList)
return NULL;
return tmplViewList->GetTextAreaFont();
}
void cDisplayMenuRootView::Render(void) {

View File

@ -46,6 +46,7 @@ public:
int GetMaxItems(void);
int GetListViewWidth(void);
int GetTextAreaWidth(void);
cFont *GetTextAreaFont(void);
bool SubViewAvailable(void) { return subViewAvailable; };
cDisplayMenuListView *GetListView(void) { return listView; };
void Render(void);