vdr 2.6.9
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.2 2023/12/29 10:48:40 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
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
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
260
261void cSkinClassicDisplayMenu::Scroll(bool Up, bool Page)
262{
263 cSkinDisplayMenu::Scroll(Up, Page);
265}
266
268{
269 return (y3 - y2) / lineHeight;
270}
271
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 cString d = Info->Description();
425 cString f = Info->FrameParams();
426 if (*f) {
427 d.Append("\n\n");
428 d.Append(f);
429 }
430 textScroller.Set(osd, x1, y, x2 - x1, y3 - y, d, font, Theme.Color(clrMenuEventDescription), Theme.Color(clrBackground));
432 }
433}
434
435void cSkinClassicDisplayMenu::SetText(const char *Text, bool FixedFont)
436{
437 textScroller.Set(osd, x1, y2, GetTextAreaWidth(), y3 - y2, Text, GetTextAreaFont(FixedFont), Theme.Color(clrMenuText), Theme.Color(clrBackground));
439}
440
442{
443return x2 - x1;
444}
445
447{
448 return cFont::GetFont(FixedFont ? fontFix : fontOsd);
449}
450
452{
454 DrawTitle();
455 cString date = DayDateTime();
456 if (!*lastDate || strcmp(date, lastDate)) {
457 const cFont *font = cFont::GetFont(fontOsd);
458 int w = font->Width(date);
459 osd->DrawText(x3 - w - TextFrame, y0, date, Theme.Color(clrMenuDate), Theme.Color(clrMenuTitleBg), font, w);
460 lastDate = date;
462 }
463 osd->Flush();
464}
465
466// --- cSkinClassicDisplayReplay ---------------------------------------------
467
469private:
471 int x0, x1;
472 int y0, y1, y2, y3;
474public:
475 cSkinClassicDisplayReplay(bool ModeOnly);
477 virtual void SetTitle(const char *Title);
478 virtual void SetMode(bool Play, bool Forward, int Speed);
479 virtual void SetProgress(int Current, int Total);
480 virtual void SetCurrent(const char *Current);
481 virtual void SetTotal(const char *Total);
482 virtual void SetJump(const char *Jump);
483 virtual void SetMessage(eMessageType Type, const char *Text);
484 virtual void Flush(void);
485 };
486
488{
489 const cFont *font = cFont::GetFont(fontOsd);
490 int lineHeight = font->Height();
492 x0 = 0;
493 x1 = cOsd::OsdWidth();
494 y0 = 0;
495 y1 = lineHeight;
496 y2 = 2 * lineHeight;
497 y3 = 3 * lineHeight;
499 tArea Areas[] = { { x0, y0, x1 - 1, y3 - 1, 8 } };
500 if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
501 osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
502 else {
503 tArea Areas[] = { { x0, y0, x1 - 1, y3 - 1, 4 } };
504 osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
505 }
506 osd->DrawRectangle(x0, y0, x1 - 1, y3 - 1, ModeOnly ? clrTransparent : Theme.Color(clrBackground));
507}
508
513
515{
516 osd->DrawText(x0, y0, Title, Theme.Color(clrReplayTitle), Theme.Color(clrBackground), cFont::GetFont(fontOsd), x1 - x0);
517}
518
519void cSkinClassicDisplayReplay::SetMode(bool Play, bool Forward, int Speed)
520{
521 if (Setup.ShowReplayMode) {
522 const char *Mode;
523 if (Speed == -1) Mode = Play ? " > " : " || ";
524 else if (Play) Mode = Forward ? " X>> " : " <<X ";
525 else Mode = Forward ? " X|> " : " <|X ";
526 char buf[16];
527 strn0cpy(buf, Mode, sizeof(buf));
528 char *p = strchr(buf, 'X');
529 if (p)
530 *p = Speed > 0 ? '1' + Speed - 1 : ' ';
531 SetJump(buf);
532 }
533}
534
535void cSkinClassicDisplayReplay::SetProgress(int Current, int Total)
536{
537 cProgressBar pb(x1 - x0, y2 - y1, Current, Total, marks, Theme.Color(clrReplayProgressSeen), Theme.Color(clrReplayProgressRest), Theme.Color(clrReplayProgressSelected), Theme.Color(clrReplayProgressMark), Theme.Color(clrReplayProgressCurrent));
538 osd->DrawBitmap(x0, y1, pb);
539}
540
542{
543 const cFont *font = cFont::GetFont(fontOsd);
544 int w = font->Width(Current);
545 osd->DrawText(x0, y2, Current, Theme.Color(clrReplayCurrent), Theme.Color(clrBackground), font, lastCurrentWidth > w ? lastCurrentWidth : w);
547}
548
550{
551 const cFont *font = cFont::GetFont(fontOsd);
552 int w = font->Width(Total);
553 osd->DrawText(x1 - font->Width(Total), y2, Total, Theme.Color(clrReplayTotal), Theme.Color(clrBackground), font, w);
554}
555
557{
558 osd->DrawText(x0 + (x1 - x0) / 4, y2, Jump, Theme.Color(clrReplayModeJump), Theme.Color(clrBackground), cFont::GetFont(fontOsd), (x1 - x0) / 2, 0, taCenter);
559}
560
562{
563 const cFont *font = cFont::GetFont(fontOsd);
564 if (Text) {
565 osd->SaveRegion(x0, y2, x1 - 1, y3 - 1);
566 osd->DrawText(x0, y2, Text, Theme.Color(clrMessageStatusFg + 2 * Type), Theme.Color(clrMessageStatusBg + 2 * Type), font, x1 - x0, y3 - y2, taCenter);
567 }
568 else
570}
571
573{
574 osd->Flush();
575}
576
577// --- cSkinClassicDisplayVolume ---------------------------------------------
578
580private:
582public:
585 virtual void SetVolume(int Current, int Total, bool Mute);
586 virtual void Flush(void);
587 };
588
590{
591 const cFont *font = cFont::GetFont(fontOsd);
592 int lineHeight = font->Height();
594 tArea Areas[] = { { 0, 0, cOsd::OsdWidth() - 1, lineHeight - 1, 8 } };
595 if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
596 osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
597 else {
598 tArea Areas[] = { { 0, 0, cOsd::OsdWidth() - 1, lineHeight - 1, 4 } };
599 osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
600 }
601}
602
607
608void cSkinClassicDisplayVolume::SetVolume(int Current, int Total, bool Mute)
609{
610 const cFont *font = cFont::GetFont(fontOsd);
611 if (Mute) {
612 osd->DrawRectangle(0, 0, osd->Width() - 1, osd->Height() - 1, clrTransparent);
613 osd->DrawText(0, 0, tr("Key$Mute"), Theme.Color(clrVolumePrompt), Theme.Color(clrBackground), font);
614 }
615 else {
616 // TRANSLATORS: note the trailing blank!
617 const char *Prompt = tr("Volume ");
618 int l = font->Width(Prompt);
619 int p = (osd->Width() - l) * Current / Total;
620 osd->DrawText(0, 0, Prompt, Theme.Color(clrVolumePrompt), Theme.Color(clrBackground), font);
621 osd->DrawRectangle(l, 0, l + p - 1, osd->Height() - 1, Theme.Color(clrVolumeBarLower));
622 osd->DrawRectangle(l + p, 0, osd->Width() - 1, osd->Height() - 1, Theme.Color(clrVolumeBarUpper));
623 }
624}
625
627{
628 osd->Flush();
629}
630
631// --- cSkinClassicDisplayTracks ---------------------------------------------
632
634private:
636 int x0, x1;
637 int y0, y1, y2;
640 void SetItem(const char *Text, int Index, bool Current);
641public:
642 cSkinClassicDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks);
644 virtual void SetTrack(int Index, const char * const *Tracks);
645 virtual void SetAudioChannel(int AudioChannel) {}
646 virtual void Flush(void);
647 };
648
649cSkinClassicDisplayTracks::cSkinClassicDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks)
650{
651 const cFont *font = cFont::GetFont(fontOsd);
652 lineHeight = font->Height();
653 currentIndex = -1;
654 int ItemsWidth = font->Width(Title);
655 for (int i = 0; i < NumTracks; i++)
656 ItemsWidth = max(ItemsWidth, font->Width(Tracks[i]));
657 ItemsWidth += 2 * TextSpacing;
658 x0 = 0;
659 x1 = cOsd::OsdWidth();
660 int d = x1 - x0;
661 if (d > ItemsWidth) {
662 d = (d - ItemsWidth) & ~0x07; // must be multiple of 8
663 x1 -= d;
664 }
665 y0 = 0;
666 y1 = lineHeight;
667 y2 = y1 + NumTracks * lineHeight;
669 tArea Areas[] = { { x0, y0, x1 - 1, y2 - 1, 8 } };
670 if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
671 osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
672 else {
673 tArea Areas[] = { { x0, y0, x1 - 1, y2 - 1, 4 } };
674 osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
675 }
676 osd->DrawText(x0, y0, Title, Theme.Color(clrMenuTitleFg), Theme.Color(clrMenuTitleBg), font, x1 - x0);
677 for (int i = 0; i < NumTracks; i++)
678 SetItem(Tracks[i], i, false);
679}
680
685
686void cSkinClassicDisplayTracks::SetItem(const char *Text, int Index, bool Current)
687{
688 int y = y1 + Index * lineHeight;
689 tColor ColorFg, ColorBg;
690 if (Current) {
691 ColorFg = Theme.Color(clrMenuItemCurrentFg);
692 ColorBg = Theme.Color(clrMenuItemCurrentBg);
693 currentIndex = Index;
694 }
695 else {
696 ColorFg = Theme.Color(clrMenuItemSelectable);
697 ColorBg = Theme.Color(clrBackground);
698 }
699 const cFont *font = cFont::GetFont(fontOsd);
700 osd->DrawText(x0, y, Text, ColorFg, ColorBg, font, x1 - x0);
701}
702
703void cSkinClassicDisplayTracks::SetTrack(int Index, const char * const *Tracks)
704{
705 if (currentIndex >= 0)
706 SetItem(Tracks[currentIndex], currentIndex, false);
707 SetItem(Tracks[Index], Index, true);
708}
709
711{
712 osd->Flush();
713}
714
715// --- cSkinClassicDisplayMessage --------------------------------------------
716
718private:
720public:
723 virtual void SetMessage(eMessageType Type, const char *Text);
724 virtual void Flush(void);
725 };
726
728{
729 const cFont *font = cFont::GetFont(fontOsd);
730 int lineHeight = font->Height();
732 tArea Areas[] = { { 0, 0, cOsd::OsdWidth() - 1, lineHeight - 1, 8 } };
733 if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
734 osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
735 else {
736 tArea Areas[] = { { 0, 0, cOsd::OsdWidth() - 1, lineHeight - 1, 2 } };
737 osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
738 }
739}
740
745
747{
748 const cFont *font = cFont::GetFont(fontOsd);
749 osd->DrawText(0, 0, Text, Theme.Color(clrMessageStatusFg + 2 * Type), Theme.Color(clrMessageStatusBg + 2 * Type), font, cOsd::OsdWidth(), 0, taCenter);
750}
751
753{
754 osd->Flush();
755}
756
757// --- cSkinClassic ----------------------------------------------------------
758
760:cSkin("classic", &::Theme)//XXX naming problem???
761{
762}
763
765{
766 return tr("Classic VDR");
767}
768
770{
771 return new cSkinClassicDisplayChannel(WithInfo);
772}
773
778
780{
781 return new cSkinClassicDisplayReplay(ModeOnly);
782}
783
788
789cSkinDisplayTracks *cSkinClassic::DisplayTracks(const char *Title, int NumTracks, const char * const *Tracks)
790{
791 return new cSkinClassicDisplayTracks(Title, NumTracks, Tracks);
792}
793
cString ChannelString(const cChannel *Channel, int Number)
Definition channels.c:1140
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:412
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:2290
The cOsd class is the interface to the "On Screen Display".
Definition osd.h:753
int Width(void)
Definition osd.h:844
static int OsdHeight(void)
Definition osd.h:831
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas)
Sets the sub-areas to the given areas.
Definition osd.c:2092
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:2206
virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas)
Checks whether the OSD can display the given set of sub-areas.
Definition osd.c:2070
static int OsdTop(void)
Definition osd.h:829
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:2127
virtual void Flush(void)
Actually commits all data to the OSD hardware.
Definition osd.c:2266
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:2236
static int OsdLeft(void)
Definition osd.h:828
static int OsdWidth(void)
Definition osd.h:830
virtual void RestoreRegion(void)
Restores the region previously saved by a call to SaveRegion().
Definition osd.c:2143
int Height(void)
Definition osd.h:845
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:2226
const char * ChannelName(void) const
Definition recording.h:87
const cEvent * GetEvent(void) const
Definition recording.h:88
int Errors(void) const
Definition recording.h:105
const char * ShortText(void) const
Definition recording.h:90
const char * Title(void) const
Definition recording.h:89
cString FrameParams(void) const
Definition recording.c:629
const char * Description(void) const
Definition recording.h:91
const char * Name(void) const
Returns the full name of the recording (without the video directory).
Definition recording.h:162
time_t Start(void) const
Definition recording.h:147
cRecordingInfo * Info(void) const
Definition recording.h:169
int ColorKey3
Definition config.h:324
int ColorKey2
Definition config.h:324
int AntiAlias
Definition config.h:336
int ColorKey0
Definition config.h:324
int ShowReplayMode
Definition config.h:352
int ChannelInfoPos
Definition config.h:329
int ColorKey1
Definition config.h:324
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.
virtual void SetChannel(const cChannel *Channel, int Number)
Sets the current channel to Channel.
virtual void Flush(void)
Actually draws the OSD display to the output device.
virtual ~cSkinClassicDisplayChannel()
virtual void SetEvents(const cEvent *Present, const cEvent *Following)
Sets the Present and Following EPG events.
virtual ~cSkinClassicDisplayMenu()
virtual void Clear(void)
Clears the entire central area of the menu.
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...
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...
virtual int MaxItems(void)
Returns the maximum number of items the menu can display.
virtual void SetEvent(const cEvent *Event)
Sets the Event that shall be displayed, using the entire central area of the menu.
virtual const cFont * GetTextAreaFont(bool FixedFont) const
Returns a pointer to the font which is used to display text with SetText().
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.
virtual void SetMessage(eMessageType Type, const char *Text)
Sets a one line message Text, with the given Type.
virtual void SetRecording(const cRecording *Recording)
Sets the Recording that shall be displayed, using the entire central area of the menu.
void DrawScrollbar(int Total, int Offset, int Shown, int Top, int Height, bool CanScrollUp, bool CanScrollDown)
virtual void Flush(void)
Actually draws the OSD display to the output device.
virtual int GetTextAreaWidth(void) const
Returns the width in pixel of the area which is used to display text with SetText().
virtual void SetText(const char *Text, bool FixedFont)
Sets the Text that shall be displayed, using the entire central area of the menu.
virtual void SetTitle(const char *Title)
Sets the title of this menu to Title.
virtual void SetItem(const char *Text, int Index, bool Current, bool Selectable)
Sets the item at the given Index to Text.
virtual ~cSkinClassicDisplayMessage()
virtual void SetMessage(eMessageType Type, const char *Text)
< This class implements a simple message display.
virtual void Flush(void)
Actually draws the OSD display to the output device.
virtual void SetTitle(const char *Title)
Sets the title of the recording.
virtual void SetCurrent(const char *Current)
Sets the current position within the recording, as a user readable string in the form "h:mm:ss....
virtual void SetJump(const char *Jump)
Sets the prompt that allows the user to enter a jump point.
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...
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...
cSkinClassicDisplayReplay(bool ModeOnly)
virtual ~cSkinClassicDisplayReplay()
virtual void Flush(void)
Actually draws the OSD display to the output device.
virtual void SetMessage(eMessageType Type, const char *Text)
Sets a one line message Text, with the given Type.
virtual void SetTotal(const char *Total)
Sets the total length of the recording, as a user readable string in the form "h:mm:ss".
virtual void Flush(void)
Actually draws the OSD display to the output device.
virtual ~cSkinClassicDisplayTracks()
void SetItem(const char *Text, int Index, bool Current)
virtual void SetTrack(int Index, const char *const *Tracks)
< This class implements the track display.
virtual void SetAudioChannel(int AudioChannel)
Sets the audio channel indicator.
cSkinClassicDisplayTracks(const char *Title, int NumTracks, const char *const *Tracks)
virtual void SetVolume(int Current, int Total, bool Mute)
< This class implements the volume/mute display.
virtual ~cSkinClassicDisplayVolume()
virtual void Flush(void)
Actually draws the OSD display to the output device.
cSkinClassic(void)
virtual cSkinDisplayVolume * DisplayVolume(void)
Creates and returns a new object for displaying the current volume.
virtual cSkinDisplayTracks * DisplayTracks(const char *Title, int NumTracks, const char *const *Tracks)
Creates and returns a new object for displaying the available tracks.
virtual const char * Description(void)
Returns a user visible, single line description of this skin, which may consist of arbitrary text and...
virtual cSkinDisplayChannel * DisplayChannel(bool WithInfo)
Creates and returns a new object for displaying the current channel.
virtual cSkinDisplayReplay * DisplayReplay(bool ModeOnly)
Creates and returns a new object for displaying replay progress.
virtual cSkinDisplayMessage * DisplayMessage(void)
Creates and returns a new object for displaying a message.
virtual cSkinDisplayMenu * DisplayMenu(void)
Creates and returns a new object for displaying a menu.
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
Definition skins.h:173
int Tab(int n)
Returns the offset of the given tab from the left border of the item display area.
Definition skins.h:174
eMenuCategory MenuCategory(void) const
Returns the menu category, set by a previous call to SetMenuCategory().
Definition skins.h:183
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.
Definition skins.h:322
static cSkinDisplay * Current(void)
Returns the currently active cSkinDisplay.
Definition skins.h:61
void SetEditableWidth(int Width)
If an item is set through a call to cSkinDisplayMenu::SetItem(), this function shall be called to set...
Definition skins.h:49
Definition skins.h:401
static cString sprintf(const char *fmt,...) __attribute__((format(printf
Definition tools.c:1180
cString & Append(const char *String)
Definition tools.c:1133
int Height(void)
Definition osd.h:1088
bool CanScroll(void)
Definition osd.h:1092
int Total(void)
Definition osd.h:1089
int Top(void)
Definition osd.h:1086
int Offset(void)
Definition osd.h:1090
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:2421
void Reset(void)
Definition osd.c:2438
int Shown(void)
Definition osd.h:1091
bool CanScrollDown(void)
Definition osd.h:1094
bool CanScrollUp(void)
Definition osd.h:1093
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
Definition osd.h:158
@ oeOk
Definition osd.h:44
@ clrGray50
Definition osd.h:33
static cTheme Theme
Definition skinclassic.c:21
#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
@ mcMain
Definition skins.h:107
@ mcRecording
Definition skins.h:115
eMessageType
Definition skins.h:37
Definition osd.h:298
#define THEME_CLR(Theme, Subject, Color)
Definition themes.h:59
cString TimeString(time_t t)
Converts the given time to a string of the form "hh:mm".
Definition tools.c:1286
bool isempty(const char *s)
Definition tools.c:354
cString DateString(time_t t)
Converts the given time to a string of the form "www dd.mm.yyyy".
Definition tools.c:1266
cString DayDateTime(time_t t)
Converts the given time to a string of the form "www dd.mm. hh:mm".
Definition tools.c:1245
char * strn0cpy(char *dest, const char *src, size_t n)
Definition tools.c:131
T min(T a, T b)
Definition tools.h:63
T max(T a, T b)
Definition tools.h:64