vdr 2.6.1
skinclassic.c
Go to the documentation of this file.
1/*
2 * skinclassic.c: The 'classic' VDR skin
3 *
4 * See the main source file 'vdr.c' for copyright information and
5 * how to reach the author.
6 *
7 * $Id: skinclassic.c 5.1 2021/07/01 15:40:46 kls Exp $
8 */
9
10#include "skinclassic.h"
11#include "font.h"
12#include "i18n.h"
13#include "osd.h"
14#include "themes.h"
15#include "videodir.h"
16
17#define ScrollWidth (Setup.FontOsdSize / 4)
18#define TextFrame (Setup.FontOsdSize / 10)
19#define TextSpacing (Setup.FontOsdSize / 4)
20
22
24THEME_CLR(Theme, clrButtonRedFg, clrWhite);
25THEME_CLR(Theme, clrButtonRedBg, clrRed);
26THEME_CLR(Theme, clrButtonGreenFg, clrBlack);
27THEME_CLR(Theme, clrButtonGreenBg, clrGreen);
28THEME_CLR(Theme, clrButtonYellowFg, clrBlack);
29THEME_CLR(Theme, clrButtonYellowBg, clrYellow);
30THEME_CLR(Theme, clrButtonBlueFg, clrWhite);
31THEME_CLR(Theme, clrButtonBlueBg, clrBlue);
32THEME_CLR(Theme, clrMessageStatusFg, clrBlack);
33THEME_CLR(Theme, clrMessageStatusBg, clrCyan);
34THEME_CLR(Theme, clrMessageInfoFg, clrBlack);
35THEME_CLR(Theme, clrMessageInfoBg, clrGreen);
36THEME_CLR(Theme, clrMessageWarningFg, clrBlack);
37THEME_CLR(Theme, clrMessageWarningBg, clrYellow);
38THEME_CLR(Theme, clrMessageErrorFg, clrWhite);
39THEME_CLR(Theme, clrMessageErrorBg, clrRed);
40THEME_CLR(Theme, clrVolumePrompt, clrGreen);
41THEME_CLR(Theme, clrVolumeBarUpper, clrWhite);
42THEME_CLR(Theme, clrVolumeBarLower, clrGreen);
43THEME_CLR(Theme, clrChannelName, clrWhite);
44THEME_CLR(Theme, clrChannelDate, clrWhite);
45THEME_CLR(Theme, clrChannelEpgTimeFg, clrWhite);
46THEME_CLR(Theme, clrChannelEpgTimeBg, clrRed);
47THEME_CLR(Theme, clrChannelEpgTitle, clrCyan);
48THEME_CLR(Theme, clrChannelEpgShortText, clrYellow);
49THEME_CLR(Theme, clrMenuTitleFg, clrBlack);
50THEME_CLR(Theme, clrMenuTitleBg, clrCyan);
51THEME_CLR(Theme, clrMenuDate, clrBlack);
52THEME_CLR(Theme, clrMenuItemCurrentFg, clrBlack);
53THEME_CLR(Theme, clrMenuItemCurrentBg, clrCyan);
54THEME_CLR(Theme, clrMenuItemSelectable, clrWhite);
55THEME_CLR(Theme, clrMenuItemNonSelectable, clrCyan);
56THEME_CLR(Theme, clrMenuEventTime, clrWhite);
57THEME_CLR(Theme, clrMenuEventVpsFg, clrBlack);
58THEME_CLR(Theme, clrMenuEventVpsBg, clrWhite);
59THEME_CLR(Theme, clrMenuEventTitle, clrCyan);
60THEME_CLR(Theme, clrMenuEventShortText, clrWhite);
61THEME_CLR(Theme, clrMenuEventDescription, clrCyan);
62THEME_CLR(Theme, clrMenuScrollbarTotal, clrWhite);
63THEME_CLR(Theme, clrMenuScrollbarShown, clrCyan);
64THEME_CLR(Theme, clrMenuText, clrWhite);
65THEME_CLR(Theme, clrReplayTitle, clrWhite);
66THEME_CLR(Theme, clrReplayCurrent, clrWhite);
67THEME_CLR(Theme, clrReplayTotal, clrWhite);
68THEME_CLR(Theme, clrReplayModeJump, clrWhite);
69THEME_CLR(Theme, clrReplayProgressSeen, clrGreen);
70THEME_CLR(Theme, clrReplayProgressRest, clrWhite);
71THEME_CLR(Theme, clrReplayProgressSelected, clrRed);
72THEME_CLR(Theme, clrReplayProgressMark, clrBlack);
73THEME_CLR(Theme, clrReplayProgressCurrent, clrRed);
74
75// --- cSkinClassicDisplayChannel --------------------------------------------
76
78private:
82 bool message;
84public:
85 cSkinClassicDisplayChannel(bool WithInfo);
87 virtual void SetChannel(const cChannel *Channel, int Number);
88 virtual void SetEvents(const cEvent *Present, const cEvent *Following);
89 virtual void SetMessage(eMessageType Type, const char *Text);
90 virtual void Flush(void);
91 };
92
94{
95 int Lines = WithInfo ? 5 : 1;
96 const cFont *font = cFont::GetFont(fontOsd);
97 lineHeight = font->Height();
98 message = false;
100 timeWidth = font->Width("00:00") + 2 * TextFrame;
101 tArea Areas[] = { { 0, 0, cOsd::OsdWidth() - 1, Lines * lineHeight - 1, 8 } };
102 if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
103 osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
104 else {
105 tArea Areas[] = { { 0, 0, cOsd::OsdWidth() - 1, Lines * lineHeight - 1, 4 } };
106 osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
107 }
108 osd->DrawRectangle(0, 0, osd->Width() - 1, osd->Height() - 1, Theme.Color(clrBackground));
109}
110
112{
113 delete osd;
114}
115
116void cSkinClassicDisplayChannel::SetChannel(const cChannel *Channel, int Number)
117{
119 osd->DrawText(TextFrame, 0, ChannelString(Channel, Number), Theme.Color(clrChannelName), Theme.Color(clrBackground), cFont::GetFont(fontOsd));
120 lastDate = NULL;
121}
122
123void cSkinClassicDisplayChannel::SetEvents(const cEvent *Present, const cEvent *Following)
124{
125 osd->DrawRectangle(0, lineHeight, timeWidth - 1, osd->Height(), Theme.Color(clrChannelEpgTimeBg));
127 for (int i = 0; i < 2; i++) {
128 const cEvent *e = !i ? Present : Following;
129 if (e) {
130 osd->DrawText( TextFrame, (2 * i + 1) * lineHeight, e->GetTimeString(), Theme.Color(clrChannelEpgTimeFg), Theme.Color(clrChannelEpgTimeBg), cFont::GetFont(fontOsd));
131 osd->DrawText(timeWidth + 2 * TextSpacing, (2 * i + 1) * lineHeight, e->Title(), Theme.Color(clrChannelEpgTitle), Theme.Color(clrBackground), cFont::GetFont(fontOsd));
132 osd->DrawText(timeWidth + 2 * TextSpacing, (2 * i + 2) * lineHeight, e->ShortText(), Theme.Color(clrChannelEpgShortText), Theme.Color(clrBackground), cFont::GetFont(fontSml));
133 }
134 }
135}
136
138{
139 const cFont *font = cFont::GetFont(fontOsd);
140 if (Text) {
141 osd->SaveRegion(0, 0, osd->Width() - 1, lineHeight - 1);
142 osd->DrawText(0, 0, Text, Theme.Color(clrMessageStatusFg + 2 * Type), Theme.Color(clrMessageStatusBg + 2 * Type), font, osd->Width(), 0, taCenter);
143 message = true;
144 }
145 else {
147 message = false;
148 }
149}
150
152{
153 if (!message) {
154 cString date = DayDateTime();
155 if (!*lastDate || strcmp(date, lastDate)) {
156 const cFont *font = cFont::GetFont(fontSml);
157 int w = font->Width(date);
158 osd->DrawText(osd->Width() - w - TextFrame, 0, date, Theme.Color(clrChannelDate), Theme.Color(clrBackground), cFont::GetFont(fontSml), w);
159 lastDate = date;
160 }
161 }
162 osd->Flush();
163}
164
165// --- cSkinClassicDisplayMenu -----------------------------------------------
166
168private:
170 int x0, x1, x2, x3;
171 int y0, y1, y2, y3, y4, y5;
177 void DrawTitle(void);
178 void DrawScrollbar(int Total, int Offset, int Shown, int Top, int Height, bool CanScrollUp, bool CanScrollDown);
179 void SetTextScrollbar(void);
180public:
182 virtual ~cSkinClassicDisplayMenu();
183 virtual void Scroll(bool Up, bool Page);
184 virtual int MaxItems(void);
185 virtual void Clear(void);
186 virtual void SetTitle(const char *Title);
187 virtual void SetButtons(const char *Red, const char *Green = NULL, const char *Yellow = NULL, const char *Blue = NULL);
188 virtual void SetMessage(eMessageType Type, const char *Text);
189 virtual void SetItem(const char *Text, int Index, bool Current, bool Selectable);
190 virtual void SetScrollbar(int Total, int Offset);
191 virtual void SetEvent(const cEvent *Event);
192 virtual void SetRecording(const cRecording *Recording);
193 virtual void SetText(const char *Text, bool FixedFont);
194 virtual int GetTextAreaWidth(void) const;
195 virtual const cFont *GetTextAreaFont(bool FixedFont) const;
196 virtual void Flush(void);
197 };
198
200{
201 const cFont *font = cFont::GetFont(fontOsd);
202 lineHeight = font->Height();
204 dateWidth = 0;
205 x0 = 0;
206 x1 = x0 + 2 * TextSpacing;
207 x3 = cOsd::OsdWidth();
208 x2 = x3 - 2 * ScrollWidth;
209 y0 = 0;
210 y1 = lineHeight;
211 y2 = y1 + lineHeight;
213 y4 = y5 - lineHeight;
214 y3 = y4 - lineHeight;
216 tArea Areas[] = { { x0, y0, x3 - 1, y5 - 1, 8 } };
217 if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
218 osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
219 else {
220 tArea Areas[] = { { x0, y0, x3 - 1, y5 - 1, 4 } };
221 if (osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
222 osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
223 else {
224 tArea Areas[] = { { x0, y0, x3 - 1, y1 - 1, 2 },
225 { x0, y1, x3 - 1, y3 - 1, 2 },
226 { x0, y3, x3 - 1, y5 - 1, 4 }
227 };
228 osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
229 }
230 }
232}
233
235{
236 delete osd;
237}
238
239void cSkinClassicDisplayMenu::DrawScrollbar(int Total, int Offset, int Shown, int Top, int Height, bool CanScrollUp, bool CanScrollDown)
240{
241 if (Total > 0 && Total > Shown) {
242 int yt = Top;
243 int yb = yt + Height;
244 int st = yt;
245 int sb = yb;
246 int th = max(int((sb - st) * double(Shown) / Total + 0.5), ScrollWidth);
247 int tt = min(int(st + (sb - st) * double(Offset) / Total + 0.5), sb - th);
248 int tb = min(tt + th, sb);
249 int xl = x3 - ScrollWidth;
250 osd->DrawRectangle(xl, st, x3 - 1, sb - 1, Theme.Color(clrMenuScrollbarTotal));
251 osd->DrawRectangle(xl, tt, x3 - 1, tb - 1, Theme.Color(clrMenuScrollbarShown));
252 }
253}
254
256{
259}
260
261void cSkinClassicDisplayMenu::Scroll(bool Up, bool Page)
262{
263 cSkinDisplayMenu::Scroll(Up, Page);
265}
266
268{
269 return (y3 - y2) / lineHeight;
270}
271
273{
276}
277
279{
280 const cFont *font = cFont::GetFont(fontOsd);
281 bool WithDisk = MenuCategory() == mcMain || MenuCategory() == mcRecording;
282 osd->DrawText(x0, y0, WithDisk ? cString::sprintf("%s - %s", *title, *cVideoDiskUsage::String()) : title, Theme.Color(clrMenuTitleFg), Theme.Color(clrMenuTitleBg), font, x3 - x0 - dateWidth);
283}
284
286{
287 title = Title;
288 DrawTitle();
289}
290
291void cSkinClassicDisplayMenu::SetButtons(const char *Red, const char *Green, const char *Yellow, const char *Blue)
292{
293 const cFont *font = cFont::GetFont(fontOsd);
294 const char *lutText[] = { Red, Green, Yellow, Blue };
295 tColor lutFg[] = { clrButtonRedFg, clrButtonGreenFg, clrButtonYellowFg, clrButtonBlueFg };
296 tColor lutBg[] = { clrButtonRedBg, clrButtonGreenBg, clrButtonYellowBg, clrButtonBlueBg };
297 int w = x3 - x0;
298 int t0 = x0;
299 int t1 = x0 + w / 4;
300 int t2 = x0 + w / 2;
301 int t3 = x3 - w / 4;
302 int t4 = x3;
303 osd->DrawText(t0, y4, lutText[Setup.ColorKey0], Theme.Color(lutFg[Setup.ColorKey0]), lutText[Setup.ColorKey0] ? Theme.Color(lutBg[Setup.ColorKey0]) : Theme.Color(clrBackground), font, t1 - t0, 0, taCenter);
304 osd->DrawText(t1, y4, lutText[Setup.ColorKey1], Theme.Color(lutFg[Setup.ColorKey1]), lutText[Setup.ColorKey1] ? Theme.Color(lutBg[Setup.ColorKey1]) : Theme.Color(clrBackground), font, t2 - t1, 0, taCenter);
305 osd->DrawText(t2, y4, lutText[Setup.ColorKey2], Theme.Color(lutFg[Setup.ColorKey2]), lutText[Setup.ColorKey2] ? Theme.Color(lutBg[Setup.ColorKey2]) : Theme.Color(clrBackground), font, t3 - t2, 0, taCenter);
306 osd->DrawText(t3, y4, lutText[Setup.ColorKey3], Theme.Color(lutFg[Setup.ColorKey3]), lutText[Setup.ColorKey3] ? Theme.Color(lutBg[Setup.ColorKey3]) : Theme.Color(clrBackground), font, t4 - t3, 0, taCenter);
307}
308
310{
311 const cFont *font = cFont::GetFont(fontOsd);
312 if (Text)
313 osd->DrawText(x0, y3, Text, Theme.Color(clrMessageStatusFg + 2 * Type), Theme.Color(clrMessageStatusBg + 2 * Type), font, x3 - x0, 0, taCenter);
314 else
316}
317
318void cSkinClassicDisplayMenu::SetItem(const char *Text, int Index, bool Current, bool Selectable)
319{
320 int y = y2 + Index * lineHeight;
321 tColor ColorFg, ColorBg;
322 if (Current) {
323 ColorFg = Theme.Color(clrMenuItemCurrentFg);
324 ColorBg = Theme.Color(clrMenuItemCurrentBg);
325 }
326 else {
327 ColorFg = Theme.Color(Selectable ? clrMenuItemSelectable : clrMenuItemNonSelectable);
328 ColorBg = Theme.Color(clrBackground);
329 }
330 const cFont *font = cFont::GetFont(fontOsd);
331 for (int i = 0; i < MaxTabs; i++) {
332 const char *s = GetTabbedText(Text, i);
333 if (s) {
334 int xt = x0 + Tab(i);
335 osd->DrawText(xt, y, s, ColorFg, ColorBg, font, x2 - xt);
336 }
337 if (!Tab(i + 1))
338 break;
339 }
340 SetEditableWidth(x2 - x0 - Tab(1));
341}
342
343void cSkinClassicDisplayMenu::SetScrollbar(int Total, int Offset)
344{
345 DrawScrollbar(Total, Offset, MaxItems(), y2, MaxItems() * lineHeight, Offset > 0, Offset + MaxItems() < Total);
346}
347
349{
350 if (!Event)
351 return;
352 const cFont *font = cFont::GetFont(fontOsd);
353 int y = y2;
354 cTextScroller ts;
355 cString t = cString::sprintf("%s %s - %s", *Event->GetDateString(), *Event->GetTimeString(), *Event->GetEndTimeString());
356 ts.Set(osd, x1, y, x2 - x1, y3 - y, t, font, Theme.Color(clrMenuEventTime), Theme.Color(clrBackground));
357 if (Event->Vps() && Event->Vps() != Event->StartTime()) {
358 cString buffer = cString::sprintf(" VPS: %s ", *Event->GetVpsString());
359 const cFont *font = cFont::GetFont(fontSml);
360 int w = font->Width(buffer);
361 osd->DrawText(x3 - w, y, buffer, Theme.Color(clrMenuEventVpsFg), Theme.Color(clrMenuEventVpsBg), font, w);
362 }
363 y += ts.Height();
364 if (Event->ParentalRating()) {
365 cString buffer = cString::sprintf(" %s ", *Event->GetParentalRatingString());
366 const cFont *font = cFont::GetFont(fontSml);
367 int w = font->Width(buffer);
368 osd->DrawText(x3 - w, y, buffer, Theme.Color(clrMenuEventVpsFg), Theme.Color(clrMenuEventVpsBg), font, w);
369 }
370 y += font->Height();
371 ts.Set(osd, x1, y, x2 - x1, y3 - y, Event->Title(), font, Theme.Color(clrMenuEventTitle), Theme.Color(clrBackground));
372 y += ts.Height();
373 if (!isempty(Event->ShortText())) {
374 const cFont *font = cFont::GetFont(fontSml);
375 ts.Set(osd, x1, y, x2 - x1, y3 - y, Event->ShortText(), font, Theme.Color(clrMenuEventShortText), Theme.Color(clrBackground));
376 y += ts.Height();
377 }
378 y += font->Height();
379 if (!isempty(Event->Description())) {
380 textScroller.Set(osd, x1, y, x2 - x1, y3 - y, Event->Description(), font, Theme.Color(clrMenuEventDescription), Theme.Color(clrBackground));
382 }
383}
384
386{
387 if (!Recording)
388 return;
389 const cRecordingInfo *Info = Recording->Info();
390 const cFont *font = cFont::GetFont(fontOsd);
391 int y = y2;
392 cTextScroller ts;
393 cString t = cString::sprintf("%s %s %s", *DateString(Recording->Start()), *TimeString(Recording->Start()), Info->ChannelName() ? Info->ChannelName() : "");
394 ts.Set(osd, x1, y, x2 - x1, y3 - y, t, font, Theme.Color(clrMenuEventTime), Theme.Color(clrBackground));
395 y += ts.Height();
396 int xt = x3;
397 if (Info->GetEvent()->ParentalRating()) {
398 cString buffer = cString::sprintf(" %s ", *Info->GetEvent()->GetParentalRatingString());
399 const cFont *font = cFont::GetFont(fontSml);
400 int w = font->Width(buffer);
401 osd->DrawText(xt - w, y, buffer, Theme.Color(clrMenuEventVpsFg), Theme.Color(clrMenuEventVpsBg), font, w);
402 xt -= w + 5;
403 }
404 if (Info->Errors() > 0) {
405 cString buffer = cString::sprintf(" %d %s ", Info->Errors(), tr("errors"));
406 const cFont *font = cFont::GetFont(fontSml);
407 int w = font->Width(buffer);
408 osd->DrawText(xt - w, y, buffer, Theme.Color(clrMenuEventVpsFg), Theme.Color(clrMenuEventVpsBg), font, w);
409 xt -= w + 5;
410 }
411 y += font->Height();
412 const char *Title = Info->Title();
413 if (isempty(Title))
414 Title = Recording->Name();
415 ts.Set(osd, x1, y, x2 - x1, y3 - y, Title, font, Theme.Color(clrMenuEventTitle), Theme.Color(clrBackground));
416 y += ts.Height();
417 if (!isempty(Info->ShortText())) {
418 const cFont *font = cFont::GetFont(fontSml);
419 ts.Set(osd, x1, y, x2 - x1, y3 - y, Info->ShortText(), font, Theme.Color(clrMenuEventShortText), Theme.Color(clrBackground));
420 y += ts.Height();
421 }
422 y += font->Height();
423 if (!isempty(Info->Description())) {
424 textScroller.Set(osd, x1, y, x2 - x1, y3 - y, Info->Description(), font, Theme.Color(clrMenuEventDescription), Theme.Color(clrBackground));
426 }
427}
428
429void cSkinClassicDisplayMenu::SetText(const char *Text, bool FixedFont)
430{
431 textScroller.Set(osd, x1, y2, GetTextAreaWidth(), y3 - y2, Text, GetTextAreaFont(FixedFont), Theme.Color(clrMenuText), Theme.Color(clrBackground));
433}
434
436{
437return x2 - x1;
438}
439
441{
442 return cFont::GetFont(FixedFont ? fontFix : fontOsd);
443}
444
446{
448 DrawTitle();
449 cString date = DayDateTime();
450 if (!*lastDate || strcmp(date, lastDate)) {
451 const cFont *font = cFont::GetFont(fontOsd);
452 int w = font->Width(date);
453 osd->DrawText(x3 - w - TextFrame, y0, date, Theme.Color(clrMenuDate), Theme.Color(clrMenuTitleBg), font, w);
454 lastDate = date;
456 }
457 osd->Flush();
458}
459
460// --- cSkinClassicDisplayReplay ---------------------------------------------
461
463private:
465 int x0, x1;
466 int y0, y1, y2, y3;
468public:
469 cSkinClassicDisplayReplay(bool ModeOnly);
471 virtual void SetTitle(const char *Title);
472 virtual void SetMode(bool Play, bool Forward, int Speed);
473 virtual void SetProgress(int Current, int Total);
474 virtual void SetCurrent(const char *Current);
475 virtual void SetTotal(const char *Total);
476 virtual void SetJump(const char *Jump);
477 virtual void SetMessage(eMessageType Type, const char *Text);
478 virtual void Flush(void);
479 };
480
482{
483 const cFont *font = cFont::GetFont(fontOsd);
484 int lineHeight = font->Height();
486 x0 = 0;
487 x1 = cOsd::OsdWidth();
488 y0 = 0;
489 y1 = lineHeight;
490 y2 = 2 * lineHeight;
491 y3 = 3 * lineHeight;
493 tArea Areas[] = { { x0, y0, x1 - 1, y3 - 1, 8 } };
494 if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
495 osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
496 else {
497 tArea Areas[] = { { x0, y0, x1 - 1, y3 - 1, 4 } };
498 osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
499 }
500 osd->DrawRectangle(x0, y0, x1 - 1, y3 - 1, ModeOnly ? clrTransparent : Theme.Color(clrBackground));
501}
502
504{
505 delete osd;
506}
507
509{
510 osd->DrawText(x0, y0, Title, Theme.Color(clrReplayTitle), Theme.Color(clrBackground), cFont::GetFont(fontOsd), x1 - x0);
511}
512
513void cSkinClassicDisplayReplay::SetMode(bool Play, bool Forward, int Speed)
514{
515 if (Setup.ShowReplayMode) {
516 const char *Mode;
517 if (Speed == -1) Mode = Play ? " > " : " || ";
518 else if (Play) Mode = Forward ? " X>> " : " <<X ";
519 else Mode = Forward ? " X|> " : " <|X ";
520 char buf[16];
521 strn0cpy(buf, Mode, sizeof(buf));
522 char *p = strchr(buf, 'X');
523 if (p)
524 *p = Speed > 0 ? '1' + Speed - 1 : ' ';
525 SetJump(buf);
526 }
527}
528
529void cSkinClassicDisplayReplay::SetProgress(int Current, int Total)
530{
531 cProgressBar pb(x1 - x0, y2 - y1, Current, Total, marks, Theme.Color(clrReplayProgressSeen), Theme.Color(clrReplayProgressRest), Theme.Color(clrReplayProgressSelected), Theme.Color(clrReplayProgressMark), Theme.Color(clrReplayProgressCurrent));
532 osd->DrawBitmap(x0, y1, pb);
533}
534
536{
537 const cFont *font = cFont::GetFont(fontOsd);
538 int w = font->Width(Current);
539 osd->DrawText(x0, y2, Current, Theme.Color(clrReplayCurrent), Theme.Color(clrBackground), font, lastCurrentWidth > w ? lastCurrentWidth : w);
541}
542
544{
545 const cFont *font = cFont::GetFont(fontOsd);
546 int w = font->Width(Total);
547 osd->DrawText(x1 - font->Width(Total), y2, Total, Theme.Color(clrReplayTotal), Theme.Color(clrBackground), font, w);
548}
549
551{
552 osd->DrawText(x0 + (x1 - x0) / 4, y2, Jump, Theme.Color(clrReplayModeJump), Theme.Color(clrBackground), cFont::GetFont(fontOsd), (x1 - x0) / 2, 0, taCenter);
553}
554
556{
557 const cFont *font = cFont::GetFont(fontOsd);
558 if (Text) {
559 osd->SaveRegion(x0, y2, x1 - 1, y3 - 1);
560 osd->DrawText(x0, y2, Text, Theme.Color(clrMessageStatusFg + 2 * Type), Theme.Color(clrMessageStatusBg + 2 * Type), font, x1 - x0, y3 - y2, taCenter);
561 }
562 else
564}
565
567{
568 osd->Flush();
569}
570
571// --- cSkinClassicDisplayVolume ---------------------------------------------
572
574private:
576public:
579 virtual void SetVolume(int Current, int Total, bool Mute);
580 virtual void Flush(void);
581 };
582
584{
585 const cFont *font = cFont::GetFont(fontOsd);
586 int lineHeight = font->Height();
588 tArea Areas[] = { { 0, 0, cOsd::OsdWidth() - 1, lineHeight - 1, 8 } };
589 if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
590 osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
591 else {
592 tArea Areas[] = { { 0, 0, cOsd::OsdWidth() - 1, lineHeight - 1, 4 } };
593 osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
594 }
595}
596
598{
599 delete osd;
600}
601
602void cSkinClassicDisplayVolume::SetVolume(int Current, int Total, bool Mute)
603{
604 const cFont *font = cFont::GetFont(fontOsd);
605 if (Mute) {
606 osd->DrawRectangle(0, 0, osd->Width() - 1, osd->Height() - 1, clrTransparent);
607 osd->DrawText(0, 0, tr("Key$Mute"), Theme.Color(clrVolumePrompt), Theme.Color(clrBackground), font);
608 }
609 else {
610 // TRANSLATORS: note the trailing blank!
611 const char *Prompt = tr("Volume ");
612 int l = font->Width(Prompt);
613 int p = (osd->Width() - l) * Current / Total;
614 osd->DrawText(0, 0, Prompt, Theme.Color(clrVolumePrompt), Theme.Color(clrBackground), font);
615 osd->DrawRectangle(l, 0, l + p - 1, osd->Height() - 1, Theme.Color(clrVolumeBarLower));
616 osd->DrawRectangle(l + p, 0, osd->Width() - 1, osd->Height() - 1, Theme.Color(clrVolumeBarUpper));
617 }
618}
619
621{
622 osd->Flush();
623}
624
625// --- cSkinClassicDisplayTracks ---------------------------------------------
626
628private:
630 int x0, x1;
631 int y0, y1, y2;
634 void SetItem(const char *Text, int Index, bool Current);
635public:
636 cSkinClassicDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks);
638 virtual void SetTrack(int Index, const char * const *Tracks);
639 virtual void SetAudioChannel(int AudioChannel) {}
640 virtual void Flush(void);
641 };
642
643cSkinClassicDisplayTracks::cSkinClassicDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks)
644{
645 const cFont *font = cFont::GetFont(fontOsd);
646 lineHeight = font->Height();
647 currentIndex = -1;
648 int ItemsWidth = font->Width(Title);
649 for (int i = 0; i < NumTracks; i++)
650 ItemsWidth = max(ItemsWidth, font->Width(Tracks[i]));
651 ItemsWidth += 2 * TextSpacing;
652 x0 = 0;
653 x1 = cOsd::OsdWidth();
654 int d = x1 - x0;
655 if (d > ItemsWidth) {
656 d = (d - ItemsWidth) & ~0x07; // must be multiple of 8
657 x1 -= d;
658 }
659 y0 = 0;
660 y1 = lineHeight;
661 y2 = y1 + NumTracks * lineHeight;
663 tArea Areas[] = { { x0, y0, x1 - 1, y2 - 1, 8 } };
664 if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
665 osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
666 else {
667 tArea Areas[] = { { x0, y0, x1 - 1, y2 - 1, 4 } };
668 osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
669 }
670 osd->DrawText(x0, y0, Title, Theme.Color(clrMenuTitleFg), Theme.Color(clrMenuTitleBg), font, x1 - x0);
671 for (int i = 0; i < NumTracks; i++)
672 SetItem(Tracks[i], i, false);
673}
674
676{
677 delete osd;
678}
679
680void cSkinClassicDisplayTracks::SetItem(const char *Text, int Index, bool Current)
681{
682 int y = y1 + Index * lineHeight;
683 tColor ColorFg, ColorBg;
684 if (Current) {
685 ColorFg = Theme.Color(clrMenuItemCurrentFg);
686 ColorBg = Theme.Color(clrMenuItemCurrentBg);
687 currentIndex = Index;
688 }
689 else {
690 ColorFg = Theme.Color(clrMenuItemSelectable);
691 ColorBg = Theme.Color(clrBackground);
692 }
693 const cFont *font = cFont::GetFont(fontOsd);
694 osd->DrawText(x0, y, Text, ColorFg, ColorBg, font, x1 - x0);
695}
696
697void cSkinClassicDisplayTracks::SetTrack(int Index, const char * const *Tracks)
698{
699 if (currentIndex >= 0)
700 SetItem(Tracks[currentIndex], currentIndex, false);
701 SetItem(Tracks[Index], Index, true);
702}
703
705{
706 osd->Flush();
707}
708
709// --- cSkinClassicDisplayMessage --------------------------------------------
710
712private:
714public:
717 virtual void SetMessage(eMessageType Type, const char *Text);
718 virtual void Flush(void);
719 };
720
722{
723 const cFont *font = cFont::GetFont(fontOsd);
724 int lineHeight = font->Height();
726 tArea Areas[] = { { 0, 0, cOsd::OsdWidth() - 1, lineHeight - 1, 8 } };
727 if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
728 osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
729 else {
730 tArea Areas[] = { { 0, 0, cOsd::OsdWidth() - 1, lineHeight - 1, 2 } };
731 osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
732 }
733}
734
736{
737 delete osd;
738}
739
741{
742 const cFont *font = cFont::GetFont(fontOsd);
743 osd->DrawText(0, 0, Text, Theme.Color(clrMessageStatusFg + 2 * Type), Theme.Color(clrMessageStatusBg + 2 * Type), font, cOsd::OsdWidth(), 0, taCenter);
744}
745
747{
748 osd->Flush();
749}
750
751// --- cSkinClassic ----------------------------------------------------------
752
754:cSkin("classic", &::Theme)//XXX naming problem???
755{
756}
757
759{
760 return tr("Classic VDR");
761}
762
764{
765 return new cSkinClassicDisplayChannel(WithInfo);
766}
767
769{
770 return new cSkinClassicDisplayMenu;
771}
772
774{
775 return new cSkinClassicDisplayReplay(ModeOnly);
776}
777
779{
780 return new cSkinClassicDisplayVolume;
781}
782
783cSkinDisplayTracks *cSkinClassic::DisplayTracks(const char *Title, int NumTracks, const char * const *Tracks)
784{
785 return new cSkinClassicDisplayTracks(Title, NumTracks, Tracks);
786}
787
789{
791}
cString ChannelString(const cChannel *Channel, int Number)
Definition: channels.c:1139
Definition: epg.h:73
const char * ShortText(void) const
Definition: epg.h:106
time_t Vps(void) const
Definition: epg.h:114
cString GetDateString(void) const
Definition: epg.c:428
const char * Description(void) const
Definition: epg.h:107
int ParentalRating(void) const
Definition: epg.h:110
time_t StartTime(void) const
Definition: epg.h:111
cString GetTimeString(void) const
Definition: epg.c:433
const char * Title(void) const
Definition: epg.h:105
cString GetEndTimeString(void) const
Definition: epg.c:438
cString GetVpsString(void) const
Definition: epg.c:443
cString GetParentalRatingString(void) const
Definition: epg.c:421
Definition: font.h:37
virtual int Width(void) const =0
Returns the original character width as requested when the font was created, or 0 if the default widt...
virtual int Height(void) const =0
Returns the height of this font in pixel (all characters have the same height).
static const cFont * GetFont(eDvbFont Font)
Gets the given Font, which was previously set by a call to SetFont().
Definition: font.c:411
static cOsd * NewOsd(int Left, int Top, uint Level=OSD_LEVEL_DEFAULT)
Returns a pointer to a newly created cOsd object, which will be located at the given coordinates.
Definition: osd.c:2215
The cOsd class is the interface to the "On Screen Display".
int Width(void)
static int OsdHeight(void)
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas)
Sets the sub-areas to the given areas.
Definition: osd.c:2029
virtual void DrawBitmap(int x, int y, const cBitmap &Bitmap, tColor ColorFg=0, tColor ColorBg=0, bool ReplacePalette=false, bool Overlay=false)
Sets the pixels in the OSD with the data from the given Bitmap, putting the upper left corner of the ...
Definition: osd.c:2131
virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas)
Checks whether the OSD can display the given set of sub-areas.
Definition: osd.c:2007
static int OsdTop(void)
virtual void SaveRegion(int x1, int y1, int x2, int y2)
Saves the region defined by the given coordinates for later restoration through RestoreRegion().
Definition: osd.c:2064
virtual void Flush(void)
Actually commits all data to the OSD hardware.
Definition: osd.c:2191
virtual void DrawRectangle(int x1, int y1, int x2, int y2, tColor Color)
Draws a filled rectangle defined by the upper left (x1, y1) and lower right (x2, y2) corners with the...
Definition: osd.c:2161
static int OsdLeft(void)
static int OsdWidth(void)
virtual void RestoreRegion(void)
Restores the region previously saved by a call to SaveRegion().
Definition: osd.c:2080
int Height(void)
virtual void DrawText(int x, int y, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width=0, int Height=0, int Alignment=taDefault)
Draws the given string at coordinates (x, y) with the given foreground and background color and font.
Definition: osd.c:2151
const char * ChannelName(void) const
const cEvent * GetEvent(void) const
int Errors(void) const
const char * ShortText(void) const
const char * Title(void) const
const char * Description(void) const
const char * Name(void) const
Returns the full name of the recording (without the video directory).
time_t Start(void) const
cRecordingInfo * Info(void) const
int ColorKey3
Definition: config.h:322
int ColorKey2
Definition: config.h:322
int AntiAlias
Definition: config.h:334
int ColorKey0
Definition: config.h:322
int ShowReplayMode
Definition: config.h:350
int ChannelInfoPos
Definition: config.h:327
int ColorKey1
Definition: config.h:322
cSkinClassicDisplayChannel(bool WithInfo)
Definition: skinclassic.c:93
virtual void SetMessage(eMessageType Type, const char *Text)
Sets a one line message Text, with the given Type.
Definition: skinclassic.c:137
virtual void SetChannel(const cChannel *Channel, int Number)
Sets the current channel to Channel.
Definition: skinclassic.c:116
virtual void Flush(void)
Actually draws the OSD display to the output device.
Definition: skinclassic.c:151
virtual ~cSkinClassicDisplayChannel()
Definition: skinclassic.c:111
virtual void SetEvents(const cEvent *Present, const cEvent *Following)
Sets the Present and Following EPG events.
Definition: skinclassic.c:123
virtual ~cSkinClassicDisplayMenu()
Definition: skinclassic.c:234
virtual void Clear(void)
Clears the entire central area of the menu.
Definition: skinclassic.c:272
virtual void Scroll(bool Up, bool Page)
If this menu contains a text area that can be scrolled, this function will be called to actually scro...
Definition: skinclassic.c:261
virtual void SetScrollbar(int Total, int Offset)
Sets the Total number of items in the currently displayed list, and the Offset of the first item that...
Definition: skinclassic.c:343
virtual int MaxItems(void)
Returns the maximum number of items the menu can display.
Definition: skinclassic.c:267
virtual void SetEvent(const cEvent *Event)
Sets the Event that shall be displayed, using the entire central area of the menu.
Definition: skinclassic.c:348
virtual const cFont * GetTextAreaFont(bool FixedFont) const
Returns a pointer to the font which is used to display text with SetText().
Definition: skinclassic.c:440
virtual void SetButtons(const char *Red, const char *Green=NULL, const char *Yellow=NULL, const char *Blue=NULL)
Sets the color buttons to the given strings.
Definition: skinclassic.c:291
virtual void SetMessage(eMessageType Type, const char *Text)
Sets a one line message Text, with the given Type.
Definition: skinclassic.c:309
virtual void SetRecording(const cRecording *Recording)
Sets the Recording that shall be displayed, using the entire central area of the menu.
Definition: skinclassic.c:385
void DrawScrollbar(int Total, int Offset, int Shown, int Top, int Height, bool CanScrollUp, bool CanScrollDown)
Definition: skinclassic.c:239
virtual void Flush(void)
Actually draws the OSD display to the output device.
Definition: skinclassic.c:445
virtual int GetTextAreaWidth(void) const
Returns the width in pixel of the area which is used to display text with SetText().
Definition: skinclassic.c:435
virtual void SetText(const char *Text, bool FixedFont)
Sets the Text that shall be displayed, using the entire central area of the menu.
Definition: skinclassic.c:429
virtual void SetTitle(const char *Title)
Sets the title of this menu to Title.
Definition: skinclassic.c:285
void SetTextScrollbar(void)
Definition: skinclassic.c:255
virtual void SetItem(const char *Text, int Index, bool Current, bool Selectable)
Sets the item at the given Index to Text.
Definition: skinclassic.c:318
virtual ~cSkinClassicDisplayMessage()
Definition: skinclassic.c:735
virtual void SetMessage(eMessageType Type, const char *Text)
< This class implements a simple message display.
Definition: skinclassic.c:740
virtual void Flush(void)
Actually draws the OSD display to the output device.
Definition: skinclassic.c:746
virtual void SetTitle(const char *Title)
Sets the title of the recording.
Definition: skinclassic.c:508
virtual void SetCurrent(const char *Current)
Sets the current position within the recording, as a user readable string if the form "h:mm:ss....
Definition: skinclassic.c:535
virtual void SetJump(const char *Jump)
Sets the prompt that allows the user to enter a jump point.
Definition: skinclassic.c:550
virtual void SetProgress(int Current, int Total)
This function will be called whenever the position in or the total length of the recording has change...
Definition: skinclassic.c:529
virtual void SetMode(bool Play, bool Forward, int Speed)
Sets the current replay mode, which can be used to display some indicator, showing the user whether w...
Definition: skinclassic.c:513
cSkinClassicDisplayReplay(bool ModeOnly)
Definition: skinclassic.c:481
virtual ~cSkinClassicDisplayReplay()
Definition: skinclassic.c:503
virtual void Flush(void)
Actually draws the OSD display to the output device.
Definition: skinclassic.c:566
virtual void SetMessage(eMessageType Type, const char *Text)
Sets a one line message Text, with the given Type.
Definition: skinclassic.c:555
virtual void SetTotal(const char *Total)
Sets the total length of the recording, as a user readable string if the form "h:mm:ss".
Definition: skinclassic.c:543
virtual void Flush(void)
Actually draws the OSD display to the output device.
Definition: skinclassic.c:704
virtual ~cSkinClassicDisplayTracks()
Definition: skinclassic.c:675
void SetItem(const char *Text, int Index, bool Current)
Definition: skinclassic.c:680
virtual void SetTrack(int Index, const char *const *Tracks)
< This class implements the track display.
Definition: skinclassic.c:697
virtual void SetAudioChannel(int AudioChannel)
Sets the audio channel indicator.
Definition: skinclassic.c:639
cSkinClassicDisplayTracks(const char *Title, int NumTracks, const char *const *Tracks)
Definition: skinclassic.c:643
virtual void SetVolume(int Current, int Total, bool Mute)
< This class implements the volume/mute display.
Definition: skinclassic.c:602
virtual ~cSkinClassicDisplayVolume()
Definition: skinclassic.c:597
virtual void Flush(void)
Actually draws the OSD display to the output device.
Definition: skinclassic.c:620
cSkinClassic(void)
Definition: skinclassic.c:753
virtual cSkinDisplayVolume * DisplayVolume(void)
Creates and returns a new object for displaying the current volume.
Definition: skinclassic.c:778
virtual cSkinDisplayTracks * DisplayTracks(const char *Title, int NumTracks, const char *const *Tracks)
Creates and returns a new object for displaying the available tracks.
Definition: skinclassic.c:783
virtual const char * Description(void)
Returns a user visible, single line description of this skin, which may consist of arbitrary text and...
Definition: skinclassic.c:758
virtual cSkinDisplayChannel * DisplayChannel(bool WithInfo)
Creates and returns a new object for displaying the current channel.
Definition: skinclassic.c:763
virtual cSkinDisplayReplay * DisplayReplay(bool ModeOnly)
Creates and returns a new object for displaying replay progress.
Definition: skinclassic.c:773
virtual cSkinDisplayMessage * DisplayMessage(void)
Creates and returns a new object for displaying a message.
Definition: skinclassic.c:788
virtual cSkinDisplayMenu * DisplayMenu(void)
Creates and returns a new object for displaying a menu.
Definition: skinclassic.c:768
virtual void Scroll(bool Up, bool Page)
If this menu contains a text area that can be scrolled, this function will be called to actually scro...
Definition: skins.c:107
cTextScroller textScroller
int Tab(int n)
Returns the offset of the given tab from the left border of the item display area.
eMenuCategory MenuCategory(void) const
Returns the menu category, set by a previous call to SetMenuCategory().
const char * GetTabbedText(const char *s, int Tab)
Returns the part of the given string that follows the given Tab (where 0 indicates the beginning of t...
Definition: skins.c:112
const cMarks * marks
< This class implements the progress display used during replay of a recording.
static cSkinDisplay * Current(void)
Returns the currently active cSkinDisplay.
void SetEditableWidth(int Width)
If an item is set through a call to cSkinDisplayMenu::SetItem(), this function shall be called to set...
static cString sprintf(const char *fmt,...) __attribute__((format(printf
Definition: tools.c:1149
bool CanScroll(void)
void Set(cOsd *Osd, int Left, int Top, int Width, int Height, const char *Text, const cFont *Font, tColor ColorFg, tColor ColorBg)
Definition: osd.c:2346
void Reset(void)
Definition: osd.c:2363
bool CanScrollDown(void)
bool CanScrollUp(void)
tColor Color(int Subject)
Returns the color for the given Subject.
Definition: themes.c:201
static bool HasChanged(int &State)
Returns true if the usage of the video disk space has changed since the last call to this function wi...
Definition: videodir.c:210
static cString String(void)
Returns a localized string of the form "Disk nn% - hh:mm free".
Definition: videodir.c:234
cSetup Setup
Definition: config.c:372
@ fontOsd
Definition: font.h:22
@ fontFix
Definition: font.h:23
uint32_t tColor
Definition: font.h:30
#define tr(s)
Definition: i18n.h:85
@ taCenter
@ oeOk
@ clrGray50
@ mcMain
@ mcRecording
eMessageType
cString TimeString(time_t t)
Converts the given time to a string of the form "hh:mm".
Definition: tools.c:1255
bool isempty(const char *s)
Definition: tools.c:349
cString DayDateTime(time_t t=0)
Converts the given time to a string of the form "www dd.mm. hh:mm".
Definition: tools.c:1214
cString DateString(time_t t)
Converts the given time to a string of the form "www dd.mm.yyyy".
Definition: tools.c:1235
T min(T a, T b)
T max(T a, T b)
char * strn0cpy(char *dest, const char *src, size_t n)
Definition: tools.c:131
static cTheme Theme
Definition: skinclassic.c:21
THEME_CLR(Theme, clrBackground, clrGray50)
#define TextFrame
Definition: skinclassic.c:18
#define ScrollWidth
Definition: skinclassic.c:17
#define TextSpacing
Definition: skinclassic.c:19
#define clrBlue
Definition: skincurses.c:41
#define clrTransparent
Definition: skincurses.c:36
#define clrBlack
Definition: skincurses.c:37
#define clrWhite
Definition: skincurses.c:44
#define clrGreen
Definition: skincurses.c:39
#define clrRed
Definition: skincurses.c:38
#define clrYellow
Definition: skincurses.c:40
#define clrBackground
Definition: skincurses.c:35
#define clrCyan
Definition: skincurses.c:43