2014-09-27 09:25:14 +02:00
|
|
|
#define __STL_CONFIG_H
|
|
|
|
#include <vdr/menu.h>
|
|
|
|
#include "displaymenurootview.h"
|
2015-03-28 11:57:51 +01:00
|
|
|
#include "displayviewelements.h"
|
2014-09-27 09:25:14 +02:00
|
|
|
#include "../config.h"
|
|
|
|
#include "../libcore/helpers.h"
|
|
|
|
|
|
|
|
cDisplayMenuRootView::cDisplayMenuRootView(cTemplateView *rootView) : cView(rootView) {
|
2015-07-12 09:24:58 +02:00
|
|
|
fadeOut = false;
|
2014-10-26 08:26:44 +01:00
|
|
|
cat = mcUndefined;
|
2015-04-05 16:56:15 +02:00
|
|
|
selectedPluginMainMenu = "";
|
2015-03-31 16:08:42 +02:00
|
|
|
sortMode = msmUnknown;
|
|
|
|
sortModeLast = msmUnknown;
|
2015-03-28 11:57:51 +01:00
|
|
|
menuTitle = "";
|
2015-04-01 10:14:26 +02:00
|
|
|
currentRecording = "";
|
2014-09-27 09:25:14 +02:00
|
|
|
viewType = svUndefined;
|
|
|
|
subView = NULL;
|
|
|
|
subViewAvailable = false;
|
2015-04-07 17:46:39 +02:00
|
|
|
subViewInit = true;
|
2014-11-15 09:47:22 +01:00
|
|
|
pluginName = "";
|
|
|
|
pluginMenu = -1;
|
|
|
|
pluginMenuType = mtUnknown;
|
|
|
|
pluginMenuChanged = false;
|
2014-09-27 09:25:14 +02:00
|
|
|
view = NULL;
|
|
|
|
listView = NULL;
|
|
|
|
detailView = NULL;
|
2014-10-25 17:29:41 +02:00
|
|
|
buttonTexts[0] = "";
|
|
|
|
buttonTexts[1] = "";
|
|
|
|
buttonTexts[2] = "";
|
|
|
|
buttonTexts[3] = "";
|
2014-09-27 09:25:14 +02:00
|
|
|
defaultBackgroundDrawn = false;
|
|
|
|
defaultHeaderDrawn = false;
|
|
|
|
defaultButtonsDrawn = false;
|
|
|
|
defaultDateTimeDrawn = false;
|
2015-04-03 15:42:08 +02:00
|
|
|
defaultTimeDrawn = false;
|
2014-09-27 09:25:14 +02:00
|
|
|
defaultMessageDrawn = false;
|
2015-03-31 16:08:42 +02:00
|
|
|
defaultSortmodeDrawn = false;
|
2014-09-27 09:25:14 +02:00
|
|
|
DeleteOsdOnExit();
|
|
|
|
}
|
|
|
|
|
|
|
|
cDisplayMenuRootView::~cDisplayMenuRootView() {
|
2015-01-26 17:10:17 +01:00
|
|
|
if (view) {
|
2014-09-27 09:25:14 +02:00
|
|
|
delete view;
|
2015-01-26 17:10:17 +01:00
|
|
|
view = NULL;
|
|
|
|
}
|
|
|
|
if (listView) {
|
2014-09-27 09:25:14 +02:00
|
|
|
delete listView;
|
2015-01-26 17:10:17 +01:00
|
|
|
listView = NULL;
|
|
|
|
}
|
|
|
|
if (detailView) {
|
2014-09-27 09:25:14 +02:00
|
|
|
delete detailView;
|
2015-01-26 17:10:17 +01:00
|
|
|
detailView = NULL;
|
|
|
|
}
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* Public Functions
|
|
|
|
*******************************************************************/
|
|
|
|
|
|
|
|
bool cDisplayMenuRootView::createOsd(void) {
|
|
|
|
cRect osdSize = tmplView->GetOsdSize();
|
|
|
|
bool ok = CreateOsd(cOsd::OsdLeft() + osdSize.X(),
|
|
|
|
cOsd::OsdTop() + osdSize.Y(),
|
|
|
|
osdSize.Width(),
|
|
|
|
osdSize.Height());
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Categories:
|
2014-10-25 12:47:00 +02:00
|
|
|
-1 mcUndefined,
|
|
|
|
0 mcUnknown,
|
2014-09-27 09:25:14 +02:00
|
|
|
1 mcMain,
|
|
|
|
2 mcSchedule,
|
|
|
|
3 mcScheduleNow,
|
|
|
|
4 mcScheduleNext,
|
|
|
|
5 mcChannel,
|
|
|
|
6 mcChannelEdit,
|
|
|
|
7 mcTimer,
|
|
|
|
8 mcTimerEdit,
|
|
|
|
9 mcRecording,
|
|
|
|
10 mcRecordingInfo,
|
2014-12-06 11:17:15 +01:00
|
|
|
11 mcRecordingEdit,
|
|
|
|
12 mcPlugin,
|
|
|
|
13 mcPluginSetup,
|
|
|
|
14 mcSetup,
|
|
|
|
15 mcSetupOsd,
|
|
|
|
16 mcSetupEpg,
|
|
|
|
17 mcSetupDvb,
|
|
|
|
18 mcSetupLnb,
|
|
|
|
19 mcSetupCam,
|
|
|
|
20 mcSetupRecord,
|
|
|
|
21 mcSetupReplay,
|
|
|
|
22 mcSetupMisc,
|
|
|
|
23 mcSetupPlugins,
|
|
|
|
24 mcCommand,
|
|
|
|
25 mcEvent,
|
|
|
|
26 mcText,
|
|
|
|
27 mcFolder,
|
|
|
|
28 mcCam
|
2014-09-27 09:25:14 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
void cDisplayMenuRootView::SetMenu(eMenuCategory menuCat, bool menuInit) {
|
|
|
|
eSubView newViewType = svUndefined;
|
2014-10-26 08:26:44 +01:00
|
|
|
cat = menuCat;
|
2015-04-07 17:46:39 +02:00
|
|
|
subViewInit = true;
|
2014-09-27 09:25:14 +02:00
|
|
|
bool isListView = true;
|
2014-11-15 09:47:22 +01:00
|
|
|
if (menuCat != mcPlugin) {
|
|
|
|
pluginName = "";
|
|
|
|
pluginMenu = -1;
|
|
|
|
pluginMenuType = mtUnknown;
|
|
|
|
pluginMenuChanged = false;
|
|
|
|
}
|
2014-09-27 09:25:14 +02:00
|
|
|
switch (menuCat) {
|
|
|
|
case mcMain:
|
|
|
|
newViewType = svMenuMain;
|
|
|
|
break;
|
|
|
|
case mcSetup:
|
|
|
|
newViewType = svMenuSetup;
|
|
|
|
break;
|
|
|
|
case mcSchedule:
|
|
|
|
case mcScheduleNow:
|
|
|
|
case mcScheduleNext:
|
|
|
|
newViewType = svMenuSchedules;
|
|
|
|
if (view)
|
|
|
|
view->SetMenuCat(menuCat);
|
|
|
|
break;
|
|
|
|
case mcChannel:
|
|
|
|
newViewType = svMenuChannels;
|
|
|
|
break;
|
|
|
|
case mcTimer:
|
|
|
|
newViewType = svMenuTimers;
|
|
|
|
break;
|
|
|
|
case mcRecording:
|
|
|
|
newViewType = svMenuRecordings;
|
|
|
|
break;
|
|
|
|
case mcEvent:
|
|
|
|
newViewType = svMenuDetailedEpg;
|
|
|
|
isListView = false;
|
|
|
|
break;
|
|
|
|
case mcRecordingInfo:
|
|
|
|
newViewType = svMenuDetailedRecording;
|
|
|
|
isListView = false;
|
|
|
|
break;
|
|
|
|
case mcText:
|
|
|
|
newViewType = svMenuDetailedText;
|
|
|
|
isListView = false;
|
|
|
|
break;
|
2014-11-15 09:47:22 +01:00
|
|
|
case mcPlugin:
|
|
|
|
newViewType = svMenuPlugin;
|
|
|
|
isListView = ( pluginMenuType == mtList ) ? true : false;
|
|
|
|
break;
|
2014-09-27 09:25:14 +02:00
|
|
|
default:
|
|
|
|
newViewType = svMenuDefault;
|
|
|
|
break;
|
|
|
|
}
|
2014-11-15 09:47:22 +01:00
|
|
|
if (newViewType != viewType || pluginMenuChanged) {
|
|
|
|
if (newViewType == svMenuPlugin) {
|
|
|
|
subView = tmplView->GetPluginView(pluginName, pluginMenu);
|
|
|
|
if (!subView) {
|
|
|
|
subViewAvailable = false;
|
|
|
|
if (isListView)
|
|
|
|
subView = tmplView->GetSubView(svMenuDefault);
|
|
|
|
else
|
|
|
|
subView = tmplView->GetSubView(svMenuDetailedText);
|
|
|
|
} else {
|
|
|
|
subViewAvailable = true;
|
|
|
|
}
|
2014-09-27 09:25:14 +02:00
|
|
|
} else {
|
2014-11-15 09:47:22 +01:00
|
|
|
subView = tmplView->GetSubView(newViewType);
|
|
|
|
if (!subView) {
|
|
|
|
subViewAvailable = false;
|
|
|
|
subView = tmplView->GetSubView(svMenuDefault);
|
|
|
|
} else {
|
|
|
|
subViewAvailable = true;
|
|
|
|
}
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
|
|
|
//Cleanup
|
|
|
|
if (view) {
|
|
|
|
delete view;
|
|
|
|
view = NULL;
|
|
|
|
}
|
|
|
|
if (listView) {
|
|
|
|
delete listView;
|
|
|
|
listView = NULL;
|
|
|
|
}
|
|
|
|
if (detailView) {
|
|
|
|
delete detailView;
|
|
|
|
detailView = NULL;
|
|
|
|
}
|
|
|
|
//Create new View
|
|
|
|
switch (newViewType) {
|
|
|
|
case svMenuMain:
|
2015-04-01 10:14:26 +02:00
|
|
|
view = new cDisplayMenuMainView(subView, menuInit, currentRecording);
|
2014-09-27 09:25:14 +02:00
|
|
|
break;
|
|
|
|
case svMenuSchedules:
|
|
|
|
if (subViewAvailable)
|
|
|
|
view = new cDisplayMenuSchedulesView(subView, menuCat, menuInit);
|
|
|
|
else
|
|
|
|
view = new cDisplayMenuView(subView, menuInit);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
view = new cDisplayMenuView(subView, menuInit);
|
|
|
|
}
|
2014-10-26 08:26:44 +01:00
|
|
|
view->SetMenuCat(cat);
|
2014-12-07 14:28:41 +01:00
|
|
|
view->SetButtonTexts(buttonTexts);
|
2014-09-27 09:25:14 +02:00
|
|
|
//Cleanup root view
|
|
|
|
ClearRootView();
|
|
|
|
if (isListView) {
|
|
|
|
//Create menu item list
|
|
|
|
cTemplateViewList *tmplMenuItems = subView->GetViewList(vlMenuItem);
|
|
|
|
if (!tmplMenuItems)
|
|
|
|
return;
|
2015-04-05 16:56:15 +02:00
|
|
|
listView = new cDisplayMenuListView(tmplMenuItems, -1, menuCat, selectedPluginMainMenu);
|
2014-09-27 09:25:14 +02:00
|
|
|
} else {
|
|
|
|
//Create detailed view
|
|
|
|
detailView = new cDisplayMenuDetailView(subView);
|
|
|
|
}
|
|
|
|
viewType = newViewType;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-31 16:08:42 +02:00
|
|
|
void cDisplayMenuRootView::SetSortMode(eMenuSortMode sortMode) {
|
|
|
|
this->sortMode = sortMode;
|
|
|
|
if (!view)
|
|
|
|
return;
|
|
|
|
view->SetSortMode(sortMode);
|
|
|
|
}
|
|
|
|
|
2014-12-06 11:17:15 +01:00
|
|
|
void cDisplayMenuRootView::CorrectDefaultMenu(void) {
|
2015-01-12 12:34:19 +01:00
|
|
|
if (viewType > svMenuDefault && viewType != svMenuPlugin) {
|
2014-12-06 11:17:15 +01:00
|
|
|
SetMenu(mcUnknown, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-13 14:49:36 +01:00
|
|
|
void cDisplayMenuRootView::SetPluginMenu(string name, int menu, int type) {
|
2014-11-15 09:47:22 +01:00
|
|
|
if (pluginName.compare(name) || menu != pluginMenu || type != pluginMenuType)
|
|
|
|
pluginMenuChanged = true;
|
|
|
|
else
|
|
|
|
pluginMenuChanged = false;
|
|
|
|
pluginName = name;
|
|
|
|
pluginMenu = menu;
|
|
|
|
pluginMenuType = (ePluginMenuType)type;
|
|
|
|
}
|
|
|
|
|
2014-09-27 09:25:14 +02:00
|
|
|
void cDisplayMenuRootView::SetTitle(const char *title) {
|
|
|
|
menuTitle = title;
|
|
|
|
if (view)
|
|
|
|
view->SetTitle(title);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayMenuRootView::SetButtonTexts(const char *Red, const char *Green, const char *Yellow, const char *Blue) {
|
|
|
|
if (Red)
|
|
|
|
buttonTexts[0] = Red;
|
|
|
|
else
|
|
|
|
buttonTexts[0] = "";
|
|
|
|
if (Green)
|
|
|
|
buttonTexts[1] = Green;
|
|
|
|
else
|
|
|
|
buttonTexts[1] = "";
|
|
|
|
if (Yellow)
|
|
|
|
buttonTexts[2] = Yellow;
|
|
|
|
else
|
|
|
|
buttonTexts[2] = "";
|
|
|
|
if (Blue)
|
|
|
|
buttonTexts[3] = Blue;
|
|
|
|
else
|
|
|
|
buttonTexts[3] = "";
|
|
|
|
if (view)
|
|
|
|
view->SetButtonTexts(buttonTexts);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayMenuRootView::SetTabs(int tab1, int tab2, int tab3, int tab4, int tab5) {
|
|
|
|
if (listView) {
|
|
|
|
listView->SetTabs(tab1, tab2, tab3, tab4, tab5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayMenuRootView::SetMessage(eMessageType type, const char *text) {
|
|
|
|
if (!view)
|
|
|
|
return;
|
|
|
|
if (!view->DrawMessage(type, text)) {
|
|
|
|
defaultMessageDrawn = true;
|
|
|
|
DrawMessage(type, text);
|
|
|
|
} else {
|
|
|
|
defaultMessageDrawn = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayMenuRootView::SetDetailedViewEvent(const cEvent *event) {
|
2014-10-25 17:29:41 +02:00
|
|
|
if (!detailView) {
|
|
|
|
if (viewType != svMenuDetailedEpg) {
|
|
|
|
SetMenu(mcEvent, true);
|
|
|
|
} else {
|
|
|
|
detailView = new cDisplayMenuDetailView(subView);
|
|
|
|
}
|
|
|
|
}
|
2014-09-27 09:25:14 +02:00
|
|
|
detailView->SetEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayMenuRootView::SetDetailedViewRecording(const cRecording *recording) {
|
2014-10-25 17:29:41 +02:00
|
|
|
if (!detailView) {
|
|
|
|
if (viewType != svMenuDetailedRecording) {
|
|
|
|
SetMenu(mcRecordingInfo, true);
|
|
|
|
} else {
|
|
|
|
detailView = new cDisplayMenuDetailView(subView);
|
|
|
|
}
|
|
|
|
}
|
2014-09-27 09:25:14 +02:00
|
|
|
detailView->SetRecording(recording);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayMenuRootView::SetDetailedViewText(const char *text) {
|
2014-10-25 15:08:57 +02:00
|
|
|
if (!detailView) {
|
|
|
|
if (viewType != svMenuDetailedText) {
|
|
|
|
SetMenu(mcText, true);
|
|
|
|
} else {
|
|
|
|
detailView = new cDisplayMenuDetailView(subView);
|
|
|
|
}
|
|
|
|
}
|
2014-09-27 09:25:14 +02:00
|
|
|
detailView->SetText(text);
|
|
|
|
}
|
|
|
|
|
2014-11-15 09:47:22 +01:00
|
|
|
bool cDisplayMenuRootView::SetDetailedViewPlugin(map<string,string> *stringTokens, map<string,int> *intTokens, map<string,vector<map<string,string> > > *loopTokens) {
|
|
|
|
if (!detailView) {
|
|
|
|
SetMenu(mcPlugin, true);
|
|
|
|
}
|
2015-05-30 16:43:59 +02:00
|
|
|
if (!subViewAvailable) {
|
2015-01-13 14:49:36 +01:00
|
|
|
return false;
|
2015-05-30 16:43:59 +02:00
|
|
|
}
|
2014-11-15 09:47:22 +01:00
|
|
|
detailView->SetPluginTokens(stringTokens, intTokens, loopTokens);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-09-27 09:25:14 +02:00
|
|
|
void cDisplayMenuRootView::KeyInput(bool up, bool page) {
|
|
|
|
if (!detailView)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (up && page) {
|
|
|
|
detailView->KeyLeft();
|
|
|
|
} else if (!up && page) {
|
|
|
|
detailView->KeyRight();
|
|
|
|
} else if (up && !page) {
|
|
|
|
detailView->KeyUp();
|
|
|
|
} else if (!up && !page) {
|
|
|
|
detailView->KeyDown();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayMenuRootView::Clear(void) {
|
2015-01-11 14:46:33 +01:00
|
|
|
if (view) {
|
2015-07-15 19:08:05 +02:00
|
|
|
view->Lock();
|
2015-01-11 14:46:33 +01:00
|
|
|
view->ClearChannel();
|
|
|
|
view->ClearEpgSearchFavorite();
|
2015-07-15 19:08:05 +02:00
|
|
|
view->Unlock();
|
2015-01-11 14:46:33 +01:00
|
|
|
}
|
2014-09-27 09:25:14 +02:00
|
|
|
if (listView) {
|
2015-07-15 19:08:05 +02:00
|
|
|
listView->Lock();
|
2014-09-27 09:25:14 +02:00
|
|
|
listView->Clear();
|
2015-07-15 19:08:05 +02:00
|
|
|
listView->Unlock();
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
|
|
|
if (detailView) {
|
|
|
|
delete detailView;
|
|
|
|
detailView = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayMenuRootView::ClearRootView(void) {
|
2015-01-26 17:10:17 +01:00
|
|
|
if (defaultBackgroundDrawn && view && view->BackgroundImplemented())
|
2014-09-27 09:25:14 +02:00
|
|
|
ClearViewElement(veBackground);
|
|
|
|
if (defaultHeaderDrawn)
|
|
|
|
ClearViewElement(veHeader);
|
|
|
|
if (defaultButtonsDrawn)
|
|
|
|
ClearViewElement(veButtons);
|
|
|
|
if (defaultDateTimeDrawn)
|
|
|
|
ClearViewElement(veDateTime);
|
2015-04-03 15:42:08 +02:00
|
|
|
if (defaultTimeDrawn)
|
|
|
|
ClearViewElement(veTime);
|
2014-09-27 09:25:14 +02:00
|
|
|
if (defaultMessageDrawn)
|
|
|
|
ClearViewElement(veMessage);
|
2015-03-31 16:08:42 +02:00
|
|
|
if (defaultSortmodeDrawn)
|
|
|
|
ClearViewElement(veSortMode);
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int cDisplayMenuRootView::GetMaxItems(void) {
|
|
|
|
if (listView) {
|
|
|
|
return listView->GetMaxItems();
|
|
|
|
}
|
2014-10-25 17:29:41 +02:00
|
|
|
//wrong menucat
|
|
|
|
SetMenu(mcUnknown, true);
|
|
|
|
return listView->GetMaxItems();
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int cDisplayMenuRootView::GetListViewWidth(void) {
|
|
|
|
if (listView) {
|
|
|
|
return listView->GetListWidth();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int cDisplayMenuRootView::GetTextAreaWidth(void) {
|
|
|
|
if (!tmplView)
|
|
|
|
return 1900;
|
2014-10-15 18:04:12 +02:00
|
|
|
cTemplateView *tmplSubView = tmplView->GetSubView(svMenuDefault);
|
|
|
|
if (!tmplSubView)
|
2014-09-27 09:25:14 +02:00
|
|
|
return 1900;
|
2014-10-15 18:04:12 +02:00
|
|
|
int areaWidth = tmplSubView->GetNumericParameter(ptWidth);
|
2014-09-27 09:25:14 +02:00
|
|
|
if (areaWidth > 0)
|
|
|
|
return areaWidth;
|
|
|
|
return 1900;
|
|
|
|
}
|
|
|
|
|
2014-10-15 18:04:12 +02:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2014-09-27 09:25:14 +02:00
|
|
|
|
|
|
|
void cDisplayMenuRootView::Render(void) {
|
2014-12-10 19:27:20 +01:00
|
|
|
if (!view)
|
|
|
|
return;
|
2015-07-15 19:08:05 +02:00
|
|
|
view->Lock();
|
2015-04-11 16:21:33 +02:00
|
|
|
view->DrawDebugGrid();
|
2014-09-27 09:25:14 +02:00
|
|
|
if (!view->DrawBackground()) {
|
2015-01-06 06:07:48 +01:00
|
|
|
defaultBackgroundDrawn = true;
|
|
|
|
DrawBackground();
|
2014-09-27 09:25:14 +02:00
|
|
|
} else {
|
|
|
|
defaultBackgroundDrawn = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!view->DrawHeader()) {
|
|
|
|
defaultHeaderDrawn = true;
|
|
|
|
DrawHeader();
|
|
|
|
} else {
|
|
|
|
defaultHeaderDrawn = false;
|
|
|
|
}
|
|
|
|
|
2015-03-31 16:08:42 +02:00
|
|
|
if (!view->DrawSortMode()) {
|
|
|
|
defaultSortmodeDrawn = true;
|
|
|
|
DrawSortMode();
|
|
|
|
} else {
|
|
|
|
defaultSortmodeDrawn = false;
|
|
|
|
}
|
|
|
|
|
2014-09-27 09:25:14 +02:00
|
|
|
if (!view->DrawColorButtons()) {
|
|
|
|
defaultButtonsDrawn = true;
|
|
|
|
DrawColorButtons();
|
|
|
|
} else {
|
|
|
|
defaultButtonsDrawn = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
view->DrawStaticViewElements();
|
|
|
|
view->DrawDynamicViewElements();
|
2015-07-15 19:08:05 +02:00
|
|
|
view->Unlock();
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayMenuRootView::RenderMenuItems(void) {
|
|
|
|
if (listView)
|
|
|
|
listView->Render();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayMenuRootView::RenderDetailView(void) {
|
|
|
|
if (detailView)
|
|
|
|
detailView->Render();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayMenuRootView::RenderMenuScrollBar(int Total, int Offset) {
|
|
|
|
if (!listView)
|
|
|
|
return;
|
|
|
|
view->DrawScrollbar(listView->GetMaxItems(), Total, Offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cDisplayMenuRootView::RenderDynamicElements(void) {
|
2015-01-07 17:29:58 +01:00
|
|
|
if (!view)
|
|
|
|
return false;
|
2015-01-06 06:07:48 +01:00
|
|
|
bool updated = false;
|
2015-04-03 15:42:08 +02:00
|
|
|
bool implemented = false;
|
2015-04-07 17:46:39 +02:00
|
|
|
if (view->DrawTime(subViewInit, implemented)) {
|
2015-04-03 15:42:08 +02:00
|
|
|
defaultTimeDrawn = false;
|
2015-01-06 06:07:48 +01:00
|
|
|
updated = true;
|
2015-04-07 17:46:39 +02:00
|
|
|
} else if (!implemented && DrawTime(subViewInit)) {
|
2015-04-03 15:42:08 +02:00
|
|
|
defaultTimeDrawn = true;
|
2015-01-06 06:07:48 +01:00
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
|
2015-04-04 07:09:22 +02:00
|
|
|
implemented = false;
|
2015-04-07 17:46:39 +02:00
|
|
|
if (view->DrawDateTime(subViewInit, implemented)) {
|
2015-01-06 06:07:48 +01:00
|
|
|
defaultDateTimeDrawn = false;
|
2015-04-04 07:09:22 +02:00
|
|
|
} else if (!implemented) {
|
2015-04-07 17:46:39 +02:00
|
|
|
DrawDateTime(subViewInit);
|
2015-04-04 07:09:22 +02:00
|
|
|
defaultDateTimeDrawn = true;
|
|
|
|
}
|
|
|
|
|
2015-04-07 17:46:39 +02:00
|
|
|
if (view->DrawDynamicViewElements()) {
|
2015-04-04 07:09:22 +02:00
|
|
|
updated = true;
|
2015-01-06 06:07:48 +01:00
|
|
|
}
|
|
|
|
|
2015-04-07 17:46:39 +02:00
|
|
|
if (subViewInit) {
|
|
|
|
subViewInit = false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
subViewInit = false;
|
2015-01-06 06:07:48 +01:00
|
|
|
return updated;
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* Private Functions
|
|
|
|
*******************************************************************/
|
|
|
|
|
|
|
|
void cDisplayMenuRootView::DrawBackground(void) {
|
2015-01-06 06:07:48 +01:00
|
|
|
map < string, string > stringTokens;
|
|
|
|
map < string, int > intTokens;
|
|
|
|
DrawViewElement(veBackground, &stringTokens, &intTokens);
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
2015-03-31 16:08:42 +02:00
|
|
|
|
2014-09-27 09:25:14 +02:00
|
|
|
void cDisplayMenuRootView::DrawHeader(void) {
|
2015-03-13 18:00:39 +01:00
|
|
|
if (!ExecuteViewElement(veHeader)) {
|
2014-09-27 09:25:14 +02:00
|
|
|
return;
|
|
|
|
}
|
2015-05-10 12:55:23 +02:00
|
|
|
if (DetachViewElement(veHeader)) {
|
|
|
|
cViewElement *viewElement = GetViewElement(veHeader);
|
|
|
|
if (!viewElement) {
|
|
|
|
viewElement = new cViewElementMenuHeader(tmplView->GetViewElement(veHeader), cat, menuTitle);
|
|
|
|
AddViewElement(veHeader, viewElement);
|
|
|
|
viewElement->Start();
|
|
|
|
} else {
|
|
|
|
if (!viewElement->Starting())
|
|
|
|
viewElement->Render();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
map < string, string > stringTokens;
|
|
|
|
map < string, int > intTokens;
|
|
|
|
SetMenuHeader(cat, menuTitle, stringTokens, intTokens);
|
|
|
|
ClearViewElement(veHeader);
|
|
|
|
DrawViewElement(veHeader, &stringTokens, &intTokens);
|
|
|
|
}
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
|
|
|
|
2015-04-07 17:46:39 +02:00
|
|
|
void cDisplayMenuRootView::DrawDateTime(bool forced) {
|
2015-03-13 18:00:39 +01:00
|
|
|
if (!ExecuteViewElement(veDateTime)) {
|
2014-09-27 09:25:14 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-10 12:55:23 +02:00
|
|
|
if (DetachViewElement(veDateTime)) {
|
|
|
|
cViewElement *viewElement = GetViewElement(veDateTime);
|
|
|
|
if (!viewElement) {
|
|
|
|
viewElement = new cViewElement(tmplView->GetViewElement(veDateTime), this);
|
|
|
|
viewElement->SetCallback(veDateTime, &cDisplayMenuRootView::SetDate);
|
|
|
|
AddViewElement(veDateTime, viewElement);
|
|
|
|
viewElement->Start();
|
|
|
|
} else {
|
|
|
|
if (!viewElement->Starting())
|
|
|
|
viewElement->Render();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
map < string, string > stringTokens;
|
|
|
|
map < string, int > intTokens;
|
|
|
|
|
|
|
|
if (!SetDate(forced, stringTokens, intTokens))
|
|
|
|
return;
|
|
|
|
ClearViewElement(veDateTime);
|
|
|
|
DrawViewElement(veDateTime, &stringTokens, &intTokens);
|
2015-01-06 06:07:48 +01:00
|
|
|
}
|
|
|
|
}
|
2014-09-27 09:25:14 +02:00
|
|
|
|
2015-04-07 17:46:39 +02:00
|
|
|
bool cDisplayMenuRootView::DrawTime(bool forced) {
|
2015-03-13 18:00:39 +01:00
|
|
|
if (!ExecuteViewElement(veTime)) {
|
2015-01-06 06:07:48 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-05-10 12:55:23 +02:00
|
|
|
if (DetachViewElement(veTime)) {
|
|
|
|
cViewElement *viewElement = GetViewElement(veTime);
|
|
|
|
if (!viewElement) {
|
|
|
|
viewElement = new cViewElement(tmplView->GetViewElement(veTime), this);
|
|
|
|
viewElement->SetCallback(veTime, &cDisplayMenuRootView::SetTime);
|
|
|
|
AddViewElement(veTime, viewElement);
|
|
|
|
viewElement->Start();
|
|
|
|
} else {
|
|
|
|
if (!viewElement->Starting())
|
|
|
|
if (!viewElement->Render())
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
2015-01-06 06:07:48 +01:00
|
|
|
|
2015-05-10 12:55:23 +02:00
|
|
|
map < string, string > stringTokens;
|
|
|
|
map < string, int > intTokens;
|
|
|
|
|
|
|
|
if (!SetTime(forced, stringTokens, intTokens)) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-01-06 06:07:48 +01:00
|
|
|
|
2015-05-10 12:55:23 +02:00
|
|
|
ClearViewElement(veTime);
|
|
|
|
DrawViewElement(veTime, &stringTokens, &intTokens);
|
|
|
|
}
|
2015-01-06 06:07:48 +01:00
|
|
|
return true;
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
|
|
|
|
2015-03-31 16:08:42 +02:00
|
|
|
void cDisplayMenuRootView::DrawSortMode(void) {
|
|
|
|
if (!ExecuteViewElement(veSortMode)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (sortMode == msmUnknown) {
|
|
|
|
if (sortModeLast != msmUnknown)
|
|
|
|
ClearViewElement(veSortMode);
|
|
|
|
sortModeLast = msmUnknown;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (sortMode == sortModeLast) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
sortModeLast = sortMode;
|
|
|
|
|
|
|
|
map < string, string > stringTokens;
|
|
|
|
map < string, int > intTokens;
|
|
|
|
|
|
|
|
bool sortNumber = (sortMode == msmNumber) ? true : false;
|
|
|
|
bool sortName = (sortMode == msmName) ? true : false;
|
|
|
|
bool sortTime = (sortMode == msmTime) ? true : false;
|
|
|
|
bool sortProvider = (sortMode == msmProvider) ? true : false;
|
|
|
|
|
|
|
|
intTokens.insert(pair<string, int>("sortnumber", sortNumber));
|
|
|
|
intTokens.insert(pair<string, int>("sortname", sortName));
|
|
|
|
intTokens.insert(pair<string, int>("sorttime", sortTime));
|
|
|
|
intTokens.insert(pair<string, int>("sortprovider", sortProvider));
|
|
|
|
|
|
|
|
ClearViewElement(veSortMode);
|
|
|
|
DrawViewElement(veSortMode, &stringTokens, &intTokens);
|
|
|
|
return;
|
|
|
|
}
|
2014-09-27 09:25:14 +02:00
|
|
|
|
|
|
|
void cDisplayMenuRootView::DrawColorButtons(void) {
|
2015-03-13 18:00:39 +01:00
|
|
|
if (!ExecuteViewElement(veButtons)) {
|
2014-09-27 09:25:14 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
map < string, string > stringTokens;
|
|
|
|
map < string, int > intTokens;
|
|
|
|
|
|
|
|
stringTokens.insert(pair<string,string>("red", buttonTexts[0]));
|
|
|
|
stringTokens.insert(pair<string,string>("green", buttonTexts[1]));
|
|
|
|
stringTokens.insert(pair<string,string>("yellow", buttonTexts[2]));
|
|
|
|
stringTokens.insert(pair<string,string>("blue", buttonTexts[3]));
|
|
|
|
|
|
|
|
int colorKeys[4] = { Setup.ColorKey0, Setup.ColorKey1, Setup.ColorKey2, Setup.ColorKey3 };
|
|
|
|
|
|
|
|
for (int button = 1; button < 5; button++) {
|
|
|
|
string red = *cString::sprintf("red%d", button);
|
|
|
|
string green = *cString::sprintf("green%d", button);
|
|
|
|
string yellow = *cString::sprintf("yellow%d", button);
|
|
|
|
string blue = *cString::sprintf("blue%d", button);
|
|
|
|
bool isRed = false;
|
|
|
|
bool isGreen = false;
|
|
|
|
bool isYellow = false;
|
|
|
|
bool isBlue = false;
|
|
|
|
switch (colorKeys[button-1]) {
|
|
|
|
case 0:
|
|
|
|
isRed = true;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
isGreen = true;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
isYellow = true;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
isBlue = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
intTokens.insert(pair<string, int>(red, isRed));
|
|
|
|
intTokens.insert(pair<string, int>(green, isGreen));
|
|
|
|
intTokens.insert(pair<string, int>(yellow, isYellow));
|
|
|
|
intTokens.insert(pair<string, int>(blue, isBlue));
|
|
|
|
}
|
|
|
|
|
|
|
|
ClearViewElement(veButtons);
|
|
|
|
DrawViewElement(veButtons, &stringTokens, &intTokens);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayMenuRootView::DrawMessage(eMessageType type, const char *text) {
|
|
|
|
if (!text) {
|
2015-05-14 11:26:30 +02:00
|
|
|
if (DetachViewElement(veMessage))
|
|
|
|
DestroyDetachedViewElement(veMessage);
|
|
|
|
else
|
|
|
|
ClearViewElement(veMessage);
|
2014-09-27 09:25:14 +02:00
|
|
|
return;
|
|
|
|
}
|
2015-05-14 11:26:30 +02:00
|
|
|
|
|
|
|
if (DetachViewElement(veMessage)) {
|
|
|
|
cViewElement *viewElement = GetViewElement(veMessage);
|
|
|
|
if (!viewElement) {
|
|
|
|
viewElement = new cViewElementMenuMessage(tmplView->GetViewElement(veMessage), type, text);
|
|
|
|
AddViewElement(veMessage, viewElement);
|
|
|
|
viewElement->Start();
|
|
|
|
} else {
|
|
|
|
if (!viewElement->Starting())
|
|
|
|
viewElement->Render();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
map < string, string > stringTokens;
|
|
|
|
map < string, int > intTokens;
|
|
|
|
SetMenuMessage(type, text, stringTokens, intTokens);
|
|
|
|
ClearViewElement(veMessage);
|
|
|
|
DrawViewElement(veMessage, &stringTokens, &intTokens);
|
|
|
|
}
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cDisplayMenuRootView::Action(void) {
|
2015-01-07 17:29:58 +01:00
|
|
|
if (!view)
|
|
|
|
return;
|
2014-09-27 09:25:14 +02:00
|
|
|
SetInitFinished();
|
|
|
|
Render();
|
|
|
|
view->Start();
|
|
|
|
FadeIn();
|
|
|
|
DoFlush();
|
|
|
|
}
|