1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
#include "displaychannel.h"
cFlatDisplayChannel::cFlatDisplayChannel(bool WithInfo) {
present = NULL;
channelName = "";
CreateFullOsd();
if ( !osd )
return;
TopBarCreate();
MessageCreate();
// von unten noch oben
// 2 * EPG + 2 * EPGsml
progressBarHeight = 20;
heightBottom = (fontHeight * 2) + (fontSmlHeight * 2) + progressBarHeight; // Top, Buttom, Between
int heightTop = fontHeight;
int height = heightBottom;
chanInfoBottomPixmap = osd->CreatePixmap(1, cRect(0, osdHeight - height, osdWidth, heightBottom));
height += progressBarHeight;
chanInfoProgressPixmap = osd->CreatePixmap(2, cRect(0, osdHeight - height, osdWidth, progressBarHeight));
chanInfoProgressPixmap->Fill( Theme.Color(clrChannelBg) );
height += heightTop;
chanInfoTopPixmap = osd->CreatePixmap(1, cRect(0, osdHeight - height, osdWidth, heightTop));
}
cFlatDisplayChannel::~cFlatDisplayChannel() {
if (osd) {
osd->DestroyPixmap(chanInfoTopPixmap);
osd->DestroyPixmap(chanInfoProgressPixmap);
osd->DestroyPixmap(chanInfoBottomPixmap);
}
}
void cFlatDisplayChannel::SetChannel(const cChannel *Channel, int Number) {
cString channelNumber("");
if (Channel) {
channelName = Channel->Name();
if (!Channel->GroupSep())
channelNumber = cString::sprintf("%d%s", Channel->Number(), Number ? "-" : "");
else if (Number)
channelNumber = cString::sprintf("%d-", Number);
} else
channelName = ChannelString(NULL, 0);
cString channelString = cString::sprintf("%s %s", *channelNumber, *channelName);
chanInfoTopPixmap->Fill(Theme.Color(clrChannelBg));
chanInfoTopPixmap->DrawText(cPoint(50, 0), channelString, Theme.Color(clrChannelFontTitle), Theme.Color(clrChannelBg), font);
}
void cFlatDisplayChannel::SetEvents(const cEvent *Present, const cEvent *Following) {
present = Present;
cString epgShort("");
cString epg("");
chanInfoBottomPixmap->Fill(Theme.Color(clrChannelBg));
int imageHeight = heightBottom - marginItem*2;
if( imgLoader.LoadLogo(*channelName, imageHeight, imageHeight) ) {
int imageLeft = marginItem;
int imageTop = (heightBottom - imgLoader.Height() ) / 2;
chanInfoBottomPixmap->DrawImage( cPoint(imageLeft, imageTop), imgLoader.GetImage() );
}
int left = heightBottom + marginItem;
if( Present ) {
cString startTime = Present->GetTimeString();
cString endTime = Present->GetEndTimeString();
cString timeString = cString::sprintf("%s - %s", *startTime, *endTime);
int timeStringWidth = fontSml->Width(*timeString);
int epgWidth = font->Width(Present->Title());
int epgShortWidth = fontSml->Width(Present->ShortText());
int s = (int)(time(NULL) - Present->StartTime()) / 60;
int sleft = (Present->Duration() / 60) - s;
cString seen = cString::sprintf("%d-/%d+ (%d) min", s, sleft, Present->Duration() / 60);
int seenWidth = fontSml->Width(*seen);
if( epgWidth > osdWidth - left - timeStringWidth ) {
int dotsWidth = font->Width("... ");
cTextWrapper epgInfoWrapper(Present->Title(), font, osdWidth - left - timeStringWidth - dotsWidth);
epg = epgInfoWrapper.GetLine(0);
epg = cString::sprintf("%s...", *epg);
} else {
epg = Present->Title();
}
if( epgShortWidth > osdWidth - left - timeStringWidth ) {
int dotsWidth = fontSml->Width("... ");
cTextWrapper epgInfoWrapper(Present->ShortText(), fontSml, osdWidth - left - timeStringWidth - dotsWidth);
epgShort = epgInfoWrapper.GetLine(0);
epgShort = cString::sprintf("%s...", *epgShort);
} else {
epgShort = Present->ShortText();
}
chanInfoBottomPixmap->DrawText(cPoint(osdWidth - timeStringWidth, 0), *timeString,
Theme.Color(clrChannelFontEpg), Theme.Color(clrChannelBg), fontSml);
chanInfoBottomPixmap->DrawText(cPoint(osdWidth - seenWidth, fontSmlHeight), *seen,
Theme.Color(clrChannelFontEpg), Theme.Color(clrChannelBg), fontSml);
chanInfoBottomPixmap->DrawText(cPoint(left, 0), *epg, Theme.Color(clrChannelFontEpg), Theme.Color(clrChannelBg), font);
chanInfoBottomPixmap->DrawText(cPoint(left, fontHeight), *epgShort, Theme.Color(clrChannelFontEpg), Theme.Color(clrChannelBg), fontSml);
}
if( Following ) {
cString startTime = Following->GetTimeString();
cString endTime = Following->GetEndTimeString();
cString timeString = cString::sprintf("%s - %s", *startTime, *endTime);
int timeStringWidth = fontSml->Width(*timeString);
int epgWidth = fontSml->Width(Following->Title());
int epgShortWidth = fontSml->Width(Following->ShortText());
cString dur = cString::sprintf("%d min", Following->Duration() / 60);
int durWidth = fontSml->Width(*dur);
if( epgWidth > osdWidth - left - timeStringWidth ) {
int dotsWidth = font->Width("... ");
cTextWrapper epgInfoWrapper(Following->Title(), font, osdWidth - left - timeStringWidth - dotsWidth);
epg = epgInfoWrapper.GetLine(0);
epg = cString::sprintf("%s...", *epg);
} else {
epg = Following->Title();
}
if (epgShortWidth > osdWidth - left - timeStringWidth ) {
int dotsWidth = fontSml->Width("... ");
cTextWrapper epgInfoWrapper(Following->ShortText(), fontSml, osdWidth - left - timeStringWidth - dotsWidth);
epgShort = epgInfoWrapper.GetLine(0);
epgShort = cString::sprintf("%s...", *epgShort);
} else {
epgShort = Following->ShortText();
}
chanInfoBottomPixmap->DrawText(cPoint(osdWidth - timeStringWidth, fontHeight + fontSmlHeight), *timeString,
Theme.Color(clrChannelFontEpg), Theme.Color(clrChannelBg), fontSml);
chanInfoBottomPixmap->DrawText(cPoint(osdWidth - durWidth, fontHeight + fontSmlHeight*2), *dur,
Theme.Color(clrChannelFontEpg), Theme.Color(clrChannelBg), fontSml);
chanInfoBottomPixmap->DrawText(cPoint(left, fontHeight + fontSmlHeight), *epg,
Theme.Color(clrChannelFontEpg), Theme.Color(clrChannelBg), font);
chanInfoBottomPixmap->DrawText(cPoint(left, fontHeight*2 + fontSmlHeight), *epgShort,
Theme.Color(clrChannelFontEpg), Theme.Color(clrChannelBg), fontSml);
}
}
void cFlatDisplayChannel::DrawProgressBar(int Current, int Total) {
int top = progressBarHeight / 2 - 3;
int barFullWidth = chanInfoProgressPixmap->ViewPort().Width();
double percentLeft = ((double)Current) / (double)Total;
chanInfoProgressPixmap->Fill( Theme.Color(clrChannelBg) );
if (Current > 0) {
chanInfoProgressPixmap->DrawRectangle(cRect( 0, top + 2, barFullWidth, 2), Theme.Color(clrChannelProgressBg));
chanInfoProgressPixmap->DrawRectangle(cRect( 0, top, (barFullWidth * percentLeft), 6), Theme.Color(clrChannelProgressFg));
}
}
void cFlatDisplayChannel::SetMessage(eMessageType Type, const char *Text) {
// Wenn es einen Text gibt, diesen Anzeigen ansonsten Message ausblenden
if( Text )
MessageSet(Type, Text);
else
MessageClear();
}
void cFlatDisplayChannel::Flush(void) {
int Current = 0;
int Total = 0;
if( present ) {
time_t t = time(NULL);
if (t > present->StartTime())
Current = t - present->StartTime();
Total = present->Duration();
DrawProgressBar(Current, Total);
}
TopBarUpdate();
osd->Flush();
}
|