vdr-plugin-tvguide/config.c

296 lines
13 KiB
C
Raw Normal View History

2013-01-17 13:16:44 +01:00
#include "config.h"
enum {
2013-05-26 11:38:05 +02:00
e12Hours,
e24Hours
2013-01-17 13:16:44 +01:00
};
2013-05-24 16:23:23 +02:00
enum {
2013-05-26 11:38:05 +02:00
eVertical,
eHorizontal
2013-05-24 16:23:23 +02:00
};
2013-05-31 13:58:22 +02:00
enum {
eNumJump,
eGroupJump
};
2013-05-24 16:23:23 +02:00
2013-01-17 13:16:44 +01:00
cTvguideConfig::cTvguideConfig() {
showMainMenuEntry = 1;
2013-05-26 11:38:05 +02:00
osdWidth = 0;
osdHeight = 0;
2013-05-24 16:23:23 +02:00
displayMode = eHorizontal;
2013-05-26 11:38:05 +02:00
colWidth = 0;
rowHeight = 0;
channelCols = 5;
2013-05-24 16:23:23 +02:00
channelRows = 10;
2013-05-26 11:38:05 +02:00
displayTime = 160;
minutePixel = 0;
displayStatusHeader = 1;
2013-05-31 13:58:22 +02:00
displayChannelGroups = 1;
statusHeaderPercent = 20;
statusHeaderHeight = 0;
2013-05-31 13:58:22 +02:00
channelGroupsPercent = 5;
channelGroupsWidth = 0;
channelGroupsHeight = 0;
scaleVideo = 1;
2013-05-24 16:23:23 +02:00
decorateVideo = 1;
2013-05-26 11:38:05 +02:00
timeLineWidthPercent = 8;
timeLineHeightPercent = 4;
2013-05-24 16:23:23 +02:00
displayChannelName = 1;
channelHeaderWidthPercent = 20;
2013-05-26 11:38:05 +02:00
channelHeaderHeightPercent = 15;
2013-05-24 16:23:23 +02:00
footerHeight = 80;
2013-05-26 11:38:05 +02:00
stepMinutes = 30;
2013-05-24 16:23:23 +02:00
bigStepHours = 3;
2013-05-26 11:38:05 +02:00
hugeStepHours = 24;
2013-05-31 13:58:22 +02:00
channelJumpMode = eNumJump;
jumpChannels = 0;
blueKeyMode = 0;
2013-05-31 13:58:22 +02:00
hideLastGroup = 0;
2013-05-26 11:38:05 +02:00
hideChannelLogos = 0;
logoWidthRatio = 13;
logoHeightRatio = 10;
logoExtension = 0;
hideEpgImages = 0;
epgImageWidth = 315;
epgImageHeight = 240;
fontIndex = 0;
fontNameDefault = "VDRSymbols Sans:Book";
2013-05-24 16:23:23 +02:00
FontButtonDelta = 0;
FontDetailViewDelta = 0;
FontDetailHeaderDelta = 0;
FontMessageBoxDelta = 0;
FontMessageBoxLargeDelta = 0;
FontStatusHeaderDelta = 0;
FontStatusHeaderLargeDelta = 0;
FontChannelHeaderDelta = 0;
2013-05-31 13:58:22 +02:00
FontChannelGroupsDelta = 0;
2013-05-24 16:23:23 +02:00
FontGridDelta = 0;
FontGridSmallDelta = 0;
FontTimeLineWeekdayDelta = 0;
FontTimeLineDateDelta = 0;
FontTimeLineTimeDelta = 0;
FontChannelHeaderHorizontalDelta = 0;
2013-05-31 13:58:22 +02:00
FontChannelGroupsHorizontalDelta = 0;
2013-05-24 16:23:23 +02:00
FontGridHorizontalDelta = 0;
FontGridHorizontalSmallDelta = 0;
FontTimeLineDateHorizontalDelta = 0;
FontTimeLineTimeHorizontalDelta = 0;
//Common Fonts
2013-05-26 11:38:05 +02:00
FontButton = NULL;
FontDetailView = NULL;
FontDetailHeader = NULL;
FontMessageBox = NULL;
FontMessageBoxLarge = NULL;
2013-05-24 16:23:23 +02:00
FontStatusHeader = NULL;
FontStatusHeaderLarge = NULL;
//Fonts for vertical Display
2013-05-26 11:38:05 +02:00
FontChannelHeader = NULL;
FontGrid = NULL;
FontGridSmall = NULL;
FontTimeLineWeekday = NULL;
FontTimeLineDate = NULL;
2013-05-24 16:23:23 +02:00
FontTimeLineTime = NULL;
//Fonts for horizontal Display
2013-05-26 11:38:05 +02:00
FontChannelHeaderHorizontal = NULL;
2013-05-24 16:23:23 +02:00
FontGridHorizontal = NULL;
2013-05-26 11:38:05 +02:00
FontGridHorizontalSmall = NULL;
2013-05-24 16:23:23 +02:00
FontTimeLineDateHorizontal = NULL;
2013-05-26 11:38:05 +02:00
FontTimeLineTimeHorizontal = NULL;
2013-05-24 16:23:23 +02:00
2013-05-26 11:38:05 +02:00
timeFormat = 1;
themeIndex = 4;
useBlending = 2;
roundedCorners = 0;
2013-05-26 17:44:04 +02:00
displayRerunsDetailEPGView = 1;
numReruns = 5;
useSubtitleRerun = 1;
2013-01-17 13:16:44 +01:00
}
cTvguideConfig::~cTvguideConfig() {
2013-05-26 11:38:05 +02:00
delete FontButton;
2013-05-24 16:23:23 +02:00
delete FontDetailView;
2013-05-26 11:38:05 +02:00
delete FontDetailHeader;
delete FontMessageBox;
delete FontMessageBoxLarge;
delete FontStatusHeader;
delete FontStatusHeaderLarge;
2013-05-24 16:23:23 +02:00
delete FontChannelHeader;
2013-05-31 13:58:22 +02:00
delete FontChannelGroups;
2013-05-24 16:23:23 +02:00
delete FontGrid;
2013-05-26 11:38:05 +02:00
delete FontGridSmall;
2013-05-24 16:23:23 +02:00
delete FontTimeLineWeekday;
2013-05-26 11:38:05 +02:00
delete FontTimeLineDate;
delete FontTimeLineTime;
delete FontChannelHeaderHorizontal;
2013-05-31 13:58:22 +02:00
delete FontChannelGroupsHorizontal;
2013-05-26 11:38:05 +02:00
delete FontGridHorizontal;
delete FontGridHorizontalSmall;
delete FontTimeLineDateHorizontal;
2013-05-24 16:23:23 +02:00
delete FontTimeLineTimeHorizontal;
2013-01-17 13:16:44 +01:00
}
void cTvguideConfig::setDynamicValues(int width, int height) {
2013-05-24 16:23:23 +02:00
SetGeometry(width, height);
SetFonts();
}
void cTvguideConfig::SetGeometry(int width, int height) {
2013-05-26 11:38:05 +02:00
osdWidth = width;
osdHeight = height;
2013-05-24 16:23:23 +02:00
statusHeaderHeight = (displayStatusHeader)?(statusHeaderPercent * osdHeight / 100):0;
2013-05-31 13:58:22 +02:00
channelGroupsWidth = (displayChannelGroups)?(channelGroupsPercent * osdWidth / 100):0;
channelGroupsHeight = (displayChannelGroups)?(channelGroupsPercent * osdHeight / 100):0;
2013-05-26 11:38:05 +02:00
channelHeaderWidth = channelHeaderWidthPercent * osdWidth / 100;
channelHeaderHeight = channelHeaderHeightPercent * osdHeight / 100;
2013-05-24 16:23:23 +02:00
timeLineWidth = timeLineWidthPercent * osdWidth / 100;
2013-05-26 11:38:05 +02:00
timeLineHeight = timeLineHeightPercent * osdHeight / 100;
2013-05-24 16:23:23 +02:00
if (displayMode == eVertical) {
colWidth = (osdWidth - timeLineWidth) / channelCols;
rowHeight = 0;
2013-05-31 13:58:22 +02:00
minutePixel = (osdHeight - statusHeaderHeight - channelGroupsHeight - channelHeaderHeight - footerHeight) / displayTime;
2013-05-24 16:23:23 +02:00
} else if (displayMode == eHorizontal) {
colWidth = 0;
rowHeight = (osdHeight - statusHeaderHeight - timeLineHeight - footerHeight) / channelRows;
2013-05-31 13:58:22 +02:00
minutePixel = (osdWidth - channelHeaderWidth - channelGroupsWidth) / displayTime;
2013-05-24 16:23:23 +02:00
}
numGrids = (displayMode == eVertical)?channelCols:channelRows;
jumpChannels = numGrids;
2013-05-24 16:23:23 +02:00
}
void cTvguideConfig::SetFonts(void){
2013-05-26 11:38:05 +02:00
cString fontname;
if (fontIndex == 0) {
fontname = fontNameDefault;
} else {
cStringList availableFonts;
cFont::GetAvailableFontNames(&availableFonts);
if (availableFonts[fontIndex-1]) {
fontname = availableFonts[fontIndex-1];
} else
fontname = fontNameDefault;
}
cFont *test = NULL;
test = cFont::CreateFont(*fontname, 30);
if (!test) {
fontname = DefaultFontSml;
}
delete test;
2013-05-24 16:23:23 +02:00
//Common Fonts
2013-05-26 11:38:05 +02:00
FontButton = cFont::CreateFont(*fontname, footerHeight/3 + 4 + FontButtonDelta);
FontDetailView = cFont::CreateFont(*fontname, osdHeight/30 + FontDetailViewDelta);
FontDetailHeader = cFont::CreateFont(*fontname, osdHeight/25 + FontDetailHeaderDelta);
FontMessageBox = cFont::CreateFont(*fontname, osdHeight/33 + FontMessageBoxDelta);
FontMessageBoxLarge = cFont::CreateFont(*fontname, osdHeight/30 + FontMessageBoxLargeDelta);
FontStatusHeader = cFont::CreateFont(*fontname, statusHeaderHeight/6 - 4 + FontStatusHeaderDelta);
2013-05-24 16:23:23 +02:00
FontStatusHeaderLarge = cFont::CreateFont(*fontname, statusHeaderHeight/5 + FontStatusHeaderLargeDelta);
//Fonts for vertical Display
2013-05-26 11:38:05 +02:00
FontChannelHeader = cFont::CreateFont(*fontname, colWidth/10 + FontChannelHeaderDelta);
2013-05-31 13:58:22 +02:00
FontChannelGroups = cFont::CreateFont(*fontname, colWidth/8 + FontChannelGroupsDelta);
2013-05-24 16:23:23 +02:00
FontGrid = cFont::CreateFont(*fontname, colWidth/12 + FontGridDelta);
2013-05-26 11:38:05 +02:00
FontGridSmall = cFont::CreateFont(*fontname, colWidth/12 + FontGridSmallDelta);
FontTimeLineWeekday = cFont::CreateFont(*fontname, timeLineWidth/3 + FontTimeLineWeekdayDelta);
2013-05-24 16:23:23 +02:00
FontTimeLineDate = cFont::CreateFont(*fontname, timeLineWidth/4 + FontTimeLineDateDelta);
2013-05-26 11:38:05 +02:00
FontTimeLineTime = cFont::CreateFont(*fontname, timeLineWidth/4 + FontTimeLineTimeDelta);
2013-05-24 16:23:23 +02:00
//Fonts for horizontal Display
2013-05-26 11:38:05 +02:00
FontChannelHeaderHorizontal = cFont::CreateFont(*fontname, rowHeight/3 + FontChannelHeaderHorizontalDelta);
2013-05-31 13:58:22 +02:00
FontChannelGroupsHorizontal = cFont::CreateFont(*fontname, rowHeight/3 + 5 + FontChannelGroupsHorizontalDelta);
2013-05-24 16:23:23 +02:00
FontGridHorizontal = cFont::CreateFont(*fontname, rowHeight/3 + 5 + FontGridHorizontalDelta);
2013-05-26 11:38:05 +02:00
FontGridHorizontalSmall = cFont::CreateFont(*fontname, rowHeight/4 + FontGridHorizontalSmallDelta);
FontTimeLineDateHorizontal = cFont::CreateFont(*fontname, timeLineHeight/2 + 5 + FontTimeLineDateHorizontalDelta);
2013-05-24 16:23:23 +02:00
FontTimeLineTimeHorizontal = cFont::CreateFont(*fontname, timeLineHeight/2 + FontTimeLineTimeHorizontalDelta);
2013-01-17 13:16:44 +01:00
}
void cTvguideConfig::SetBlending(void) {
if (theme.Color(clrDoBlending) == CLR_BLENDING_OFF) {
useBlending = 0;
} else if (theme.Color(clrDoBlending) == CLR_BLENDING_DEFAULT)
useBlending = 1;
else {
useBlending = 2;
}
}
2013-01-17 13:16:44 +01:00
void cTvguideConfig::SetLogoPath(cString path) {
2013-05-26 11:38:05 +02:00
logoPath = path;
2013-01-17 13:16:44 +01:00
}
void cTvguideConfig::SetImagesPath(cString path) {
2013-05-26 11:38:05 +02:00
epgImagePath = path;
2013-01-17 13:16:44 +01:00
}
void cTvguideConfig::loadTheme() {
2013-05-26 11:38:05 +02:00
cThemes themes;
themes.Load(*cString("tvguide"));
const char *FileName = themes.FileName(themeIndex);
if (access(FileName, F_OK) == 0) {
::theme.Load(FileName);
}
2013-01-17 13:16:44 +01:00
}
bool cTvguideConfig::SetupParse(const char *Name, const char *Value) {
2013-05-26 11:38:05 +02:00
if (strcmp(Name, "timeFormat") == 0) timeFormat = atoi(Value);
else if (strcmp(Name, "showMainMenuEntry") == 0) showMainMenuEntry = atoi(Value);
2013-05-26 11:38:05 +02:00
else if (strcmp(Name, "themeIndex") == 0) themeIndex = atoi(Value);
else if (strcmp(Name, "displayMode") == 0) displayMode = atoi(Value);
else if (strcmp(Name, "displayStatusHeader") == 0) displayStatusHeader = atoi(Value);
2013-05-31 13:58:22 +02:00
else if (strcmp(Name, "displayChannelGroups") == 0) displayChannelGroups = atoi(Value);
else if (strcmp(Name, "statusHeaderPercent") == 0) statusHeaderPercent = atoi(Value);
2013-05-31 13:58:22 +02:00
else if (strcmp(Name, "channelGroupsPercent") == 0) channelGroupsPercent = atoi(Value);
2013-05-26 11:38:05 +02:00
else if (strcmp(Name, "scaleVideo") == 0) scaleVideo = atoi(Value);
else if (strcmp(Name, "decorateVideo") == 0) decorateVideo = atoi(Value);
else if (strcmp(Name, "roundedCorners") == 0) roundedCorners = atoi(Value);
else if (strcmp(Name, "channelCols") == 0) channelCols = atoi(Value);
else if (strcmp(Name, "channelRows") == 0) channelRows = atoi(Value);
else if (strcmp(Name, "displayTime") == 0) displayTime = atoi(Value);
else if (strcmp(Name, "hideChannelLogos") == 0) hideChannelLogos = atoi(Value);
else if (strcmp(Name, "logoExtension") == 0) logoExtension = atoi(Value);
else if (strcmp(Name, "logoWidthRatio") == 0) logoWidthRatio = atoi(Value);
else if (strcmp(Name, "logoHeightRatio") == 0) logoHeightRatio = atoi(Value);
else if (strcmp(Name, "bigStepHours") == 0) bigStepHours = atoi(Value);
else if (strcmp(Name, "hugeStepHours") == 0) hugeStepHours = atoi(Value);
2013-05-31 13:58:22 +02:00
else if (strcmp(Name, "channelJumpMode") == 0) channelJumpMode = atoi(Value);
else if (strcmp(Name, "blueKeyMode") == 0) blueKeyMode = atoi(Value);
2013-05-31 13:58:22 +02:00
else if (strcmp(Name, "hideLastGroup") == 0) hideLastGroup = atoi(Value);
2013-05-26 11:38:05 +02:00
else if (strcmp(Name, "hideEpgImages") == 0) hideEpgImages = atoi(Value);
else if (strcmp(Name, "epgImageWidth") == 0) epgImageWidth = atoi(Value);
else if (strcmp(Name, "epgImageHeight") == 0) epgImageHeight = atoi(Value);
else if (strcmp(Name, "timeLineWidthPercent") == 0) timeLineWidthPercent = atoi(Value);
2013-05-24 16:23:23 +02:00
else if (strcmp(Name, "timeLineHeightPercent") == 0) timeLineHeightPercent = atoi(Value);
else if (strcmp(Name, "displayChannelName") == 0) displayChannelName = atoi(Value);
else if (strcmp(Name, "channelHeaderWidthPercent") == 0) channelHeaderWidthPercent = atoi(Value);
else if (strcmp(Name, "channelHeaderHeightPercent") == 0) channelHeaderHeightPercent = atoi(Value);
2013-05-26 11:38:05 +02:00
else if (strcmp(Name, "footerHeight") == 0) footerHeight = atoi(Value);
else if (strcmp(Name, "fontIndex") == 0) fontIndex = atoi(Value);
else if (strcmp(Name, "FontButtonDelta") == 0) FontButtonDelta = atoi(Value);
else if (strcmp(Name, "FontDetailViewDelta") == 0) FontDetailViewDelta = atoi(Value);
else if (strcmp(Name, "FontDetailHeaderDelta") == 0) FontDetailHeaderDelta = atoi(Value);
else if (strcmp(Name, "FontMessageBoxDelta") == 0) FontMessageBoxDelta = atoi(Value);
else if (strcmp(Name, "FontMessageBoxLargeDelta") == 0) FontMessageBoxLargeDelta = atoi(Value);
else if (strcmp(Name, "FontStatusHeaderDelta") == 0) FontStatusHeaderDelta = atoi(Value);
else if (strcmp(Name, "FontStatusHeaderLargeDelta") == 0) FontStatusHeaderLargeDelta = atoi(Value);
2013-05-31 13:58:22 +02:00
else if (strcmp(Name, "FontChannelHeaderDelta") == 0) FontChannelHeaderDelta = atoi(Value);
else if (strcmp(Name, "FontChannelGroupsDelta") == 0) FontChannelGroupsDelta = atoi(Value);
2013-05-26 11:38:05 +02:00
else if (strcmp(Name, "FontGridDelta") == 0) FontGridDelta = atoi(Value);
else if (strcmp(Name, "FontGridSmallDelta") == 0) FontGridSmallDelta = atoi(Value);
else if (strcmp(Name, "FontTimeLineWeekdayDelta") == 0) FontTimeLineWeekdayDelta = atoi(Value);
else if (strcmp(Name, "FontTimeLineDateDelta") == 0) FontTimeLineDateDelta = atoi(Value);
else if (strcmp(Name, "FontTimeLineTimeDelta") == 0) FontTimeLineTimeDelta = atoi(Value);
else if (strcmp(Name, "FontChannelHeaderHorizontalDelta") == 0) FontChannelHeaderHorizontalDelta = atoi(Value);
2013-05-31 13:58:22 +02:00
else if (strcmp(Name, "FontChannelGroupsHorizontalDelta") == 0) FontChannelGroupsHorizontalDelta = atoi(Value);
2013-05-26 11:38:05 +02:00
else if (strcmp(Name, "FontGridHorizontalDelta") == 0) FontGridHorizontalDelta = atoi(Value);
else if (strcmp(Name, "FontGridHorizontalSmallDelta") == 0) FontGridHorizontalSmallDelta = atoi(Value);
else if (strcmp(Name, "FontTimeLineDateHorizontalDelta") == 0) FontTimeLineDateHorizontalDelta = atoi(Value);
else if (strcmp(Name, "FontTimeLineTimeHorizontalDelta") == 0) FontTimeLineTimeHorizontalDelta = atoi(Value);
2013-05-26 17:44:04 +02:00
else if (strcmp(Name, "displayRerunsDetailEPGView") == 0) displayRerunsDetailEPGView = atoi(Value);
else if (strcmp(Name, "numReruns") == 0) numReruns = atoi(Value);
else if (strcmp(Name, "useSubtitleRerun") == 0) useSubtitleRerun = atoi(Value);
2013-05-24 16:23:23 +02:00
else return false;
2013-05-26 11:38:05 +02:00
return true;
2013-01-17 17:54:27 +01:00
}