#include "displaymenu.h" cFlatDisplayMenu::cFlatDisplayMenu(void) { CreateFullOsd(); TopBarCreate(); ButtonsCreate(); MessageCreate(); itemHeight = fontHeight + 2; scrollBarWidth = 10; scrollBarHeight = osdHeight - (topBarHeight + buttonsHeight + marginItem*2 ); scrollBarTop = topBarHeight + marginItem; menuWidth = osdWidth - scrollBarWidth - marginItem; menuPixmap = osd->CreatePixmap(1, cRect(0, topBarHeight + marginItem, menuWidth, scrollBarHeight )); contentTop = topBarHeight + marginItem + fontHeight + (fontSmlHeight*2) + marginItem; ContentCreate(0, contentTop, menuWidth, scrollBarHeight - fontHeight*2 -3); scrollbarPixmap = osd->CreatePixmap(2, cRect(osdWidth - scrollBarWidth, scrollBarTop, scrollBarWidth, scrollBarHeight)); menuPixmap->Fill(clrTransparent); scrollbarPixmap->Fill(clrTransparent); } cFlatDisplayMenu::~cFlatDisplayMenu() { osd->DestroyPixmap(menuPixmap); osd->DestroyPixmap(scrollbarPixmap); } void cFlatDisplayMenu::DrawScrollbar(int Total, int Offset, int Shown, int Top, int Height, bool CanScrollUp, bool CanScrollDown) { if (Total > 0 && Total > Shown) { int scrollHeight = max(int((Height) * double(Shown) / Total + 0.5), 5); int scrollTop = min(int(Top + (Height) * double(Offset) / Total + 0.5), Top + Height - scrollHeight); scrollbarPixmap->Fill(clrTransparent); scrollbarPixmap->DrawRectangle(cRect(0, Top, 2, Height), Theme.Color(clrScrollbarBg)); scrollbarPixmap->DrawRectangle(cRect(0, scrollTop, 5, scrollHeight), Theme.Color(clrScrollbarFg)); } } void cFlatDisplayMenu::SetScrollbar(int Total, int Offset) { DrawScrollbar(Total, Offset, MaxItems(), 0, ItemsHeight(), Offset > 0, Offset + MaxItems() < Total); } void cFlatDisplayMenu::Scroll(bool Up, bool Page) { // Wird das Menü gescrollt oder Content? if( ContentIsShown() ) { bool scrolled = ContentScroll(Up, Page); if( scrolled ) { DrawScrollbar(ContentScrollTotal(), ContentScrollOffset(), ContentVisibleLines(), contentTop - scrollBarTop, ContentGetHeight(), ContentScrollOffset() > 0, ContentScrollOffset() + ContentVisibleLines() < ContentScrollTotal()); } } else { cSkinDisplayMenu::Scroll(Up, Page); } } int cFlatDisplayMenu::MaxItems(void) { return scrollBarHeight / itemHeight; } int cFlatDisplayMenu::ItemsHeight(void) { return MaxItems() * itemHeight; } void cFlatDisplayMenu::Clear(void) { textScroller.Reset(); menuPixmap->Fill(clrTransparent); scrollbarPixmap->Fill(clrTransparent); ContentClear(); } void cFlatDisplayMenu::SetTitle(const char *Title) { TopBarSetTitle(Title); } void cFlatDisplayMenu::SetButtons(const char *Red, const char *Green, const char *Yellow, const char *Blue) { ButtonsSet(Red, Green, Yellow, Blue); } void cFlatDisplayMenu::SetMessage(eMessageType Type, const char *Text) { if (Text) MessageSet(Type, Text); else MessageClear(); } void cFlatDisplayMenu::SetItem(const char *Text, int Index, bool Current, bool Selectable) { int y = Index * itemHeight; tColor ColorFg, ColorBg; if (Current) { ColorFg = Theme.Color(clrItemCurrentFont); ColorBg = Theme.Color(clrItemCurrentBg); } else { if( Selectable ) { ColorFg = Theme.Color(clrItemSelableFont); ColorBg = Theme.Color(clrItemSelableBg); } else { ColorFg = Theme.Color(clrItemFont); ColorBg = Theme.Color(clrItemBg); } } for (int i = 0; i < MaxTabs; i++) { const char *s = GetTabbedText(Text, i); if (s) { int xt = Tab(i); menuPixmap->DrawText(cPoint(xt, y), s, ColorFg, ColorBg, font, menuWidth); } if (!Tab(i + 1)) break; } } void cFlatDisplayMenu::SetEvent(const cEvent *Event) { if( !Event ) return; menuPixmap->Fill(clrTransparent); cString date = Event->GetDateString(); cString startTime = Event->GetTimeString(); cString endTime = Event->GetEndTimeString(); cString timeString = cString::sprintf("%s %s - %s", *date, *startTime, *endTime); cString title = Event->Title(); cString shortText = Event->ShortText(); menuPixmap->DrawText(cPoint(0, 0), timeString, Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, menuWidth); menuPixmap->DrawText(cPoint(0, fontSmlHeight), title, Theme.Color(clrMenuEventFontTitle), Theme.Color(clrMenuEventBg), font, menuWidth); menuPixmap->DrawText(cPoint(0, fontSmlHeight + fontHeight), shortText, Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg), fontSml, menuWidth); ContentSet( Event->Description(), Theme.Color(clrMenuEventFontInfo), Theme.Color(clrMenuEventBg) ); if( ContentScrollable() ) DrawScrollbar(ContentScrollTotal(), ContentScrollOffset(), ContentVisibleLines(), contentTop - scrollBarTop, ContentGetHeight(), ContentScrollOffset() > 0, ContentScrollOffset() + ContentVisibleLines() < ContentScrollTotal()); } void cFlatDisplayMenu::SetRecording(const cRecording *Recording) { if( !Recording ) return; menuPixmap->Fill(clrTransparent); const cRecordingInfo *recInfo = Recording->Info(); cString timeString = cString::sprintf("%s %s %s", *DateString(Recording->Start()), *TimeString(Recording->Start()), recInfo->ChannelName() ? recInfo->ChannelName() : ""); cString title = recInfo->Title(); if( isempty(title) ) title = Recording->Name(); cString shortText = recInfo->ShortText(); menuPixmap->DrawText(cPoint(0, 0), timeString, Theme.Color(clrMenuRecFontInfo), Theme.Color(clrMenuRecBg), fontSml, menuWidth); menuPixmap->DrawText(cPoint(0, fontSmlHeight), title, Theme.Color(clrMenuRecFontTitle), Theme.Color(clrMenuRecBg), font, menuWidth); menuPixmap->DrawText(cPoint(0, fontSmlHeight + fontHeight), shortText, Theme.Color(clrMenuRecFontTitle), Theme.Color(clrMenuRecBg), fontSml, menuWidth); ContentSet( recInfo->Description(), Theme.Color(clrMenuRecFontInfo), Theme.Color(clrMenuRecBg) ); if( ContentScrollable() ) DrawScrollbar(ContentScrollTotal(), ContentScrollOffset(), ContentVisibleLines(), contentTop - scrollBarTop, ContentGetHeight(), ContentScrollOffset() > 0, ContentScrollOffset() + ContentVisibleLines() < ContentScrollTotal()); } void cFlatDisplayMenu::SetText(const char *Text, bool FixedFont) { if( !Text ) return; menuPixmap->Fill(clrTransparent); ContentSet( Text, Theme.Color(clrMenuTextFont), Theme.Color(clrMenuTextBg) ); if( ContentScrollable() ) SetScrollbar( ContentScrollTotal(), 0 ); } int cFlatDisplayMenu::GetTextAreaWidth(void) const { return menuWidth - (marginItem*2); } const cFont *cFlatDisplayMenu::GetTextAreaFont(bool FixedFont) const { const cFont *rfont = FixedFont ? fontFixed : font; return rfont; } void cFlatDisplayMenu::Flush(void) { TopBarUpdate(); osd->Flush(); }