vdr  2.2.0
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 3.0 2013/03/03 15:26:09 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 
21 static cTheme Theme;
22 
24 THEME_CLR(Theme, clrButtonRedFg, clrWhite);
25 THEME_CLR(Theme, clrButtonRedBg, clrRed);
26 THEME_CLR(Theme, clrButtonGreenFg, clrBlack);
27 THEME_CLR(Theme, clrButtonGreenBg, clrGreen);
28 THEME_CLR(Theme, clrButtonYellowFg, clrBlack);
29 THEME_CLR(Theme, clrButtonYellowBg, clrYellow);
30 THEME_CLR(Theme, clrButtonBlueFg, clrWhite);
31 THEME_CLR(Theme, clrButtonBlueBg, clrBlue);
32 THEME_CLR(Theme, clrMessageStatusFg, clrBlack);
33 THEME_CLR(Theme, clrMessageStatusBg, clrCyan);
34 THEME_CLR(Theme, clrMessageInfoFg, clrBlack);
35 THEME_CLR(Theme, clrMessageInfoBg, clrGreen);
36 THEME_CLR(Theme, clrMessageWarningFg, clrBlack);
37 THEME_CLR(Theme, clrMessageWarningBg, clrYellow);
38 THEME_CLR(Theme, clrMessageErrorFg, clrWhite);
39 THEME_CLR(Theme, clrMessageErrorBg, clrRed);
40 THEME_CLR(Theme, clrVolumePrompt, clrGreen);
41 THEME_CLR(Theme, clrVolumeBarUpper, clrWhite);
42 THEME_CLR(Theme, clrVolumeBarLower, clrGreen);
43 THEME_CLR(Theme, clrChannelName, clrWhite);
44 THEME_CLR(Theme, clrChannelDate, clrWhite);
45 THEME_CLR(Theme, clrChannelEpgTimeFg, clrWhite);
46 THEME_CLR(Theme, clrChannelEpgTimeBg, clrRed);
47 THEME_CLR(Theme, clrChannelEpgTitle, clrCyan);
48 THEME_CLR(Theme, clrChannelEpgShortText, clrYellow);
49 THEME_CLR(Theme, clrMenuTitleFg, clrBlack);
50 THEME_CLR(Theme, clrMenuTitleBg, clrCyan);
51 THEME_CLR(Theme, clrMenuDate, clrBlack);
52 THEME_CLR(Theme, clrMenuItemCurrentFg, clrBlack);
53 THEME_CLR(Theme, clrMenuItemCurrentBg, clrCyan);
54 THEME_CLR(Theme, clrMenuItemSelectable, clrWhite);
55 THEME_CLR(Theme, clrMenuItemNonSelectable, clrCyan);
56 THEME_CLR(Theme, clrMenuEventTime, clrWhite);
57 THEME_CLR(Theme, clrMenuEventVpsFg, clrBlack);
58 THEME_CLR(Theme, clrMenuEventVpsBg, clrWhite);
59 THEME_CLR(Theme, clrMenuEventTitle, clrCyan);
60 THEME_CLR(Theme, clrMenuEventShortText, clrWhite);
61 THEME_CLR(Theme, clrMenuEventDescription, clrCyan);
62 THEME_CLR(Theme, clrMenuScrollbarTotal, clrWhite);
63 THEME_CLR(Theme, clrMenuScrollbarShown, clrCyan);
64 THEME_CLR(Theme, clrMenuText, clrWhite);
65 THEME_CLR(Theme, clrReplayTitle, clrWhite);
66 THEME_CLR(Theme, clrReplayCurrent, clrWhite);
67 THEME_CLR(Theme, clrReplayTotal, clrWhite);
68 THEME_CLR(Theme, clrReplayModeJump, clrWhite);
69 THEME_CLR(Theme, clrReplayProgressSeen, clrGreen);
70 THEME_CLR(Theme, clrReplayProgressRest, clrWhite);
71 THEME_CLR(Theme, clrReplayProgressSelected, clrRed);
72 THEME_CLR(Theme, clrReplayProgressMark, clrBlack);
73 THEME_CLR(Theme, clrReplayProgressCurrent, clrRed);
74 
75 // --- cSkinClassicDisplayChannel --------------------------------------------
76 
78 private:
81  int timeWidth;
82  bool message;
84 public:
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 
116 void cSkinClassicDisplayChannel::SetChannel(const cChannel *Channel, int Number)
117 {
118  osd->DrawRectangle(0, 0, osd->Width() - 1, lineHeight - 1, Theme.Color(clrBackground));
119  osd->DrawText(TextFrame, 0, ChannelString(Channel, Number), Theme.Color(clrChannelName), Theme.Color(clrBackground), cFont::GetFont(fontOsd));
120  lastDate = NULL;
121 }
122 
123 void 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 {
146  osd->RestoreRegion();
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 
168 private:
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);
180 public:
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();
203  lastDiskUsageState = -1;
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;
212  y5 = cOsd::OsdHeight();
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  }
231  osd->DrawRectangle(x0, y0, x3 - 1, y5 - 1, Theme.Color(clrBackground));
232 }
233 
235 {
236  delete osd;
237 }
238 
239 void 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 {
257  if (textScroller.CanScroll())
258  DrawScrollbar(textScroller.Total(), textScroller.Offset(), textScroller.Shown(), textScroller.Top(), textScroller.Height(), textScroller.CanScrollUp(), textScroller.CanScrollDown());
259 }
260 
261 void cSkinClassicDisplayMenu::Scroll(bool Up, bool Page)
262 {
263  cSkinDisplayMenu::Scroll(Up, Page);
264  SetTextScrollbar();
265 }
266 
268 {
269  return (y3 - y2) / lineHeight;
270 }
271 
273 {
274  textScroller.Reset();
275  osd->DrawRectangle(x0, y1, x3 - 1, y4 - 1, Theme.Color(clrBackground));
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 
285 void cSkinClassicDisplayMenu::SetTitle(const char *Title)
286 {
287  title = Title;
288  DrawTitle();
289 }
290 
291 void 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
315  osd->DrawRectangle(x0, y3, x3 - 1, y4 - 1, Theme.Color(clrBackground));
316 }
317 
318 void 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 
343 void 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  char t[32];
356  snprintf(t, sizeof(t), "%s %s - %s", *Event->GetDateString(), *Event->GetTimeString(), *Event->GetEndTimeString());
357  ts.Set(osd, x1, y, x2 - x1, y3 - y, t, font, Theme.Color(clrMenuEventTime), Theme.Color(clrBackground));
358  if (Event->Vps() && Event->Vps() != Event->StartTime()) {
359  cString buffer = cString::sprintf(" VPS: %s ", *Event->GetVpsString());
360  const cFont *font = cFont::GetFont(fontSml);
361  int w = font->Width(buffer);
362  osd->DrawText(x3 - w, y, buffer, Theme.Color(clrMenuEventVpsFg), Theme.Color(clrMenuEventVpsBg), font, w);
363  }
364  y += ts.Height();
365  if (Event->ParentalRating()) {
366  cString buffer = cString::sprintf(" %s ", *Event->GetParentalRatingString());
367  const cFont *font = cFont::GetFont(fontSml);
368  int w = font->Width(buffer);
369  osd->DrawText(x3 - w, y, buffer, Theme.Color(clrMenuEventVpsFg), Theme.Color(clrMenuEventVpsBg), font, w);
370  }
371  y += font->Height();
372  ts.Set(osd, x1, y, x2 - x1, y3 - y, Event->Title(), font, Theme.Color(clrMenuEventTitle), Theme.Color(clrBackground));
373  y += ts.Height();
374  if (!isempty(Event->ShortText())) {
375  const cFont *font = cFont::GetFont(fontSml);
376  ts.Set(osd, x1, y, x2 - x1, y3 - y, Event->ShortText(), font, Theme.Color(clrMenuEventShortText), Theme.Color(clrBackground));
377  y += ts.Height();
378  }
379  y += font->Height();
380  if (!isempty(Event->Description())) {
381  textScroller.Set(osd, x1, y, x2 - x1, y3 - y, Event->Description(), font, Theme.Color(clrMenuEventDescription), Theme.Color(clrBackground));
382  SetTextScrollbar();
383  }
384 }
385 
387 {
388  if (!Recording)
389  return;
390  const cRecordingInfo *Info = Recording->Info();
391  const cFont *font = cFont::GetFont(fontOsd);
392  int y = y2;
393  cTextScroller ts;
394  cString t = cString::sprintf("%s %s %s", *DateString(Recording->Start()), *TimeString(Recording->Start()), Info->ChannelName() ? Info->ChannelName() : "");
395  ts.Set(osd, x1, y, x2 - x1, y3 - y, t, font, Theme.Color(clrMenuEventTime), Theme.Color(clrBackground));
396  y += ts.Height();
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(x3 - w, y, buffer, Theme.Color(clrMenuEventVpsFg), Theme.Color(clrMenuEventVpsBg), font, w);
402  }
403  y += font->Height();
404  const char *Title = Info->Title();
405  if (isempty(Title))
406  Title = Recording->Name();
407  ts.Set(osd, x1, y, x2 - x1, y3 - y, Title, font, Theme.Color(clrMenuEventTitle), Theme.Color(clrBackground));
408  y += ts.Height();
409  if (!isempty(Info->ShortText())) {
410  const cFont *font = cFont::GetFont(fontSml);
411  ts.Set(osd, x1, y, x2 - x1, y3 - y, Info->ShortText(), font, Theme.Color(clrMenuEventShortText), Theme.Color(clrBackground));
412  y += ts.Height();
413  }
414  y += font->Height();
415  if (!isempty(Info->Description())) {
416  textScroller.Set(osd, x1, y, x2 - x1, y3 - y, Info->Description(), font, Theme.Color(clrMenuEventDescription), Theme.Color(clrBackground));
417  SetTextScrollbar();
418  }
419 }
420 
421 void cSkinClassicDisplayMenu::SetText(const char *Text, bool FixedFont)
422 {
423  textScroller.Set(osd, x1, y2, GetTextAreaWidth(), y3 - y2, Text, GetTextAreaFont(FixedFont), Theme.Color(clrMenuText), Theme.Color(clrBackground));
424  SetTextScrollbar();
425 }
426 
428 {
429 return x2 - x1;
430 }
431 
433 {
434  return cFont::GetFont(FixedFont ? fontFix : fontOsd);
435 }
436 
438 {
439  if (cVideoDiskUsage::HasChanged(lastDiskUsageState))
440  DrawTitle();
441  cString date = DayDateTime();
442  if (!*lastDate || strcmp(date, lastDate)) {
443  const cFont *font = cFont::GetFont(fontOsd);
444  int w = font->Width(date);
445  osd->DrawText(x3 - w - TextFrame, y0, date, Theme.Color(clrMenuDate), Theme.Color(clrMenuTitleBg), font, w);
446  lastDate = date;
447  dateWidth = max(w + TextFrame, dateWidth);
448  }
449  osd->Flush();
450 }
451 
452 // --- cSkinClassicDisplayReplay ---------------------------------------------
453 
455 private:
457  int x0, x1;
458  int y0, y1, y2, y3;
460 public:
461  cSkinClassicDisplayReplay(bool ModeOnly);
462  virtual ~cSkinClassicDisplayReplay();
463  virtual void SetTitle(const char *Title);
464  virtual void SetMode(bool Play, bool Forward, int Speed);
465  virtual void SetProgress(int Current, int Total);
466  virtual void SetCurrent(const char *Current);
467  virtual void SetTotal(const char *Total);
468  virtual void SetJump(const char *Jump);
469  virtual void SetMessage(eMessageType Type, const char *Text);
470  virtual void Flush(void);
471  };
472 
474 {
475  const cFont *font = cFont::GetFont(fontOsd);
476  int lineHeight = font->Height();
477  lastCurrentWidth = 0;
478  x0 = 0;
479  x1 = cOsd::OsdWidth();
480  y0 = 0;
481  y1 = lineHeight;
482  y2 = 2 * lineHeight;
483  y3 = 3 * lineHeight;
485  tArea Areas[] = { { x0, y0, x1 - 1, y3 - 1, 8 } };
486  if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
487  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
488  else {
489  tArea Areas[] = { { x0, y0, x1 - 1, y3 - 1, 4 } };
490  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
491  }
492  osd->DrawRectangle(x0, y0, x1 - 1, y3 - 1, ModeOnly ? clrTransparent : Theme.Color(clrBackground));
493 }
494 
496 {
497  delete osd;
498 }
499 
500 void cSkinClassicDisplayReplay::SetTitle(const char *Title)
501 {
502  osd->DrawText(x0, y0, Title, Theme.Color(clrReplayTitle), Theme.Color(clrBackground), cFont::GetFont(fontOsd), x1 - x0);
503 }
504 
505 void cSkinClassicDisplayReplay::SetMode(bool Play, bool Forward, int Speed)
506 {
507  if (Setup.ShowReplayMode) {
508  const char *Mode;
509  if (Speed == -1) Mode = Play ? " > " : " || ";
510  else if (Play) Mode = Forward ? " X>> " : " <<X ";
511  else Mode = Forward ? " X|> " : " <|X ";
512  char buf[16];
513  strn0cpy(buf, Mode, sizeof(buf));
514  char *p = strchr(buf, 'X');
515  if (p)
516  *p = Speed > 0 ? '1' + Speed - 1 : ' ';
517  SetJump(buf);
518  }
519 }
520 
522 {
523  cProgressBar pb(x1 - x0, y2 - y1, Current, Total, marks, Theme.Color(clrReplayProgressSeen), Theme.Color(clrReplayProgressRest), Theme.Color(clrReplayProgressSelected), Theme.Color(clrReplayProgressMark), Theme.Color(clrReplayProgressCurrent));
524  osd->DrawBitmap(x0, y1, pb);
525 }
526 
528 {
529  const cFont *font = cFont::GetFont(fontOsd);
530  int w = font->Width(Current);
531  osd->DrawText(x0, y2, Current, Theme.Color(clrReplayCurrent), Theme.Color(clrBackground), font, lastCurrentWidth > w ? lastCurrentWidth : w);
532  lastCurrentWidth = w;
533 }
534 
535 void cSkinClassicDisplayReplay::SetTotal(const char *Total)
536 {
537  const cFont *font = cFont::GetFont(fontOsd);
538  int w = font->Width(Total);
539  osd->DrawText(x1 - font->Width(Total), y2, Total, Theme.Color(clrReplayTotal), Theme.Color(clrBackground), font, w);
540 }
541 
543 {
544  osd->DrawText(x0 + (x1 - x0) / 4, y2, Jump, Theme.Color(clrReplayModeJump), Theme.Color(clrBackground), cFont::GetFont(fontOsd), (x1 - x0) / 2, 0, taCenter);
545 }
546 
548 {
549  const cFont *font = cFont::GetFont(fontOsd);
550  if (Text) {
551  osd->SaveRegion(x0, y2, x1 - 1, y3 - 1);
552  osd->DrawText(x0, y2, Text, Theme.Color(clrMessageStatusFg + 2 * Type), Theme.Color(clrMessageStatusBg + 2 * Type), font, x1 - x0, y3 - y2, taCenter);
553  }
554  else
555  osd->RestoreRegion();
556 }
557 
559 {
560  osd->Flush();
561 }
562 
563 // --- cSkinClassicDisplayVolume ---------------------------------------------
564 
566 private:
568 public:
570  virtual ~cSkinClassicDisplayVolume();
571  virtual void SetVolume(int Current, int Total, bool Mute);
572  virtual void Flush(void);
573  };
574 
576 {
577  const cFont *font = cFont::GetFont(fontOsd);
578  int lineHeight = font->Height();
580  tArea Areas[] = { { 0, 0, cOsd::OsdWidth() - 1, lineHeight - 1, 8 } };
581  if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
582  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
583  else {
584  tArea Areas[] = { { 0, 0, cOsd::OsdWidth() - 1, lineHeight - 1, 4 } };
585  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
586  }
587 }
588 
590 {
591  delete osd;
592 }
593 
594 void cSkinClassicDisplayVolume::SetVolume(int Current, int Total, bool Mute)
595 {
596  const cFont *font = cFont::GetFont(fontOsd);
597  if (Mute) {
598  osd->DrawRectangle(0, 0, osd->Width() - 1, osd->Height() - 1, clrTransparent);
599  osd->DrawText(0, 0, tr("Key$Mute"), Theme.Color(clrVolumePrompt), Theme.Color(clrBackground), font);
600  }
601  else {
602  // TRANSLATORS: note the trailing blank!
603  const char *Prompt = tr("Volume ");
604  int l = font->Width(Prompt);
605  int p = (osd->Width() - l) * Current / Total;
606  osd->DrawText(0, 0, Prompt, Theme.Color(clrVolumePrompt), Theme.Color(clrBackground), font);
607  osd->DrawRectangle(l, 0, l + p - 1, osd->Height() - 1, Theme.Color(clrVolumeBarLower));
608  osd->DrawRectangle(l + p, 0, osd->Width() - 1, osd->Height() - 1, Theme.Color(clrVolumeBarUpper));
609  }
610 }
611 
613 {
614  osd->Flush();
615 }
616 
617 // --- cSkinClassicDisplayTracks ---------------------------------------------
618 
620 private:
622  int x0, x1;
623  int y0, y1, y2;
626  void SetItem(const char *Text, int Index, bool Current);
627 public:
628  cSkinClassicDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks);
629  virtual ~cSkinClassicDisplayTracks();
630  virtual void SetTrack(int Index, const char * const *Tracks);
631  virtual void SetAudioChannel(int AudioChannel) {}
632  virtual void Flush(void);
633  };
634 
635 cSkinClassicDisplayTracks::cSkinClassicDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks)
636 {
637  const cFont *font = cFont::GetFont(fontOsd);
638  lineHeight = font->Height();
639  currentIndex = -1;
640  int ItemsWidth = font->Width(Title);
641  for (int i = 0; i < NumTracks; i++)
642  ItemsWidth = max(ItemsWidth, font->Width(Tracks[i]));
643  ItemsWidth += 2 * TextSpacing;
644  x0 = 0;
645  x1 = cOsd::OsdWidth();
646  int d = x1 - x0;
647  if (d > ItemsWidth) {
648  d = (d - ItemsWidth) & ~0x07; // must be multiple of 8
649  x1 -= d;
650  }
651  y0 = 0;
652  y1 = lineHeight;
653  y2 = y1 + NumTracks * lineHeight;
655  tArea Areas[] = { { x0, y0, x1 - 1, y2 - 1, 8 } };
656  if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
657  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
658  else {
659  tArea Areas[] = { { x0, y0, x1 - 1, y2 - 1, 4 } };
660  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
661  }
662  osd->DrawText(x0, y0, Title, Theme.Color(clrMenuTitleFg), Theme.Color(clrMenuTitleBg), font, x1 - x0);
663  for (int i = 0; i < NumTracks; i++)
664  SetItem(Tracks[i], i, false);
665 }
666 
668 {
669  delete osd;
670 }
671 
672 void cSkinClassicDisplayTracks::SetItem(const char *Text, int Index, bool Current)
673 {
674  int y = y1 + Index * lineHeight;
675  tColor ColorFg, ColorBg;
676  if (Current) {
677  ColorFg = Theme.Color(clrMenuItemCurrentFg);
678  ColorBg = Theme.Color(clrMenuItemCurrentBg);
679  currentIndex = Index;
680  }
681  else {
682  ColorFg = Theme.Color(clrMenuItemSelectable);
683  ColorBg = Theme.Color(clrBackground);
684  }
685  const cFont *font = cFont::GetFont(fontOsd);
686  osd->DrawText(x0, y, Text, ColorFg, ColorBg, font, x1 - x0);
687 }
688 
689 void cSkinClassicDisplayTracks::SetTrack(int Index, const char * const *Tracks)
690 {
691  if (currentIndex >= 0)
692  SetItem(Tracks[currentIndex], currentIndex, false);
693  SetItem(Tracks[Index], Index, true);
694 }
695 
697 {
698  osd->Flush();
699 }
700 
701 // --- cSkinClassicDisplayMessage --------------------------------------------
702 
704 private:
706 public:
708  virtual ~cSkinClassicDisplayMessage();
709  virtual void SetMessage(eMessageType Type, const char *Text);
710  virtual void Flush(void);
711  };
712 
714 {
715  const cFont *font = cFont::GetFont(fontOsd);
716  int lineHeight = font->Height();
718  tArea Areas[] = { { 0, 0, cOsd::OsdWidth() - 1, lineHeight - 1, 8 } };
719  if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
720  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
721  else {
722  tArea Areas[] = { { 0, 0, cOsd::OsdWidth() - 1, lineHeight - 1, 2 } };
723  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
724  }
725 }
726 
728 {
729  delete osd;
730 }
731 
733 {
734  const cFont *font = cFont::GetFont(fontOsd);
735  osd->DrawText(0, 0, Text, Theme.Color(clrMessageStatusFg + 2 * Type), Theme.Color(clrMessageStatusBg + 2 * Type), font, cOsd::OsdWidth(), 0, taCenter);
736 }
737 
739 {
740  osd->Flush();
741 }
742 
743 // --- cSkinClassic ----------------------------------------------------------
744 
746 :cSkin("classic", &::Theme)//XXX naming problem???
747 {
748 }
749 
750 const char *cSkinClassic::Description(void)
751 {
752  return tr("Classic VDR");
753 }
754 
756 {
757  return new cSkinClassicDisplayChannel(WithInfo);
758 }
759 
761 {
762  return new cSkinClassicDisplayMenu;
763 }
764 
766 {
767  return new cSkinClassicDisplayReplay(ModeOnly);
768 }
769 
771 {
772  return new cSkinClassicDisplayVolume;
773 }
774 
775 cSkinDisplayTracks *cSkinClassic::DisplayTracks(const char *Title, int NumTracks, const char * const *Tracks)
776 {
777  return new cSkinClassicDisplayTracks(Title, NumTracks, Tracks);
778 }
779 
781 {
782  return new cSkinClassicDisplayMessage;
783 }
void SetItem(const char *Text, int Index, bool Current)
Definition: skinclassic.c:672
virtual void SetMessage(eMessageType Type, const char *Text)
< This class implements a simple message display.
Definition: skinclassic.c:732
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
int AntiAlias
Definition: config.h:323
static int OsdHeight(void)
Definition: osd.h:789
Definition: epg.h:71
virtual void Flush(void)
Actually draws the OSD display to the output device.
Definition: skinclassic.c:558
virtual cSkinDisplayReplay * DisplayReplay(bool ModeOnly)
Creates and returns a new object for displaying replay progress.
Definition: skinclassic.c:765
Definition: osd.h:36
virtual void SetJump(const char *Jump)
Sets the prompt that allows the user to enter a jump point.
Definition: skinclassic.c:542
eMessageType
Definition: skins.h:24
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
bool isempty(const char *s)
Definition: tools.c:297
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:775
Definition: font.h:23
time_t Start(void) const
Definition: recording.h:128
virtual void SetAudioChannel(int AudioChannel)
Sets the audio channel indicator.
Definition: skinclassic.c:631
static cString String(void)
Returns a localized string of the form "Disk nn% - hh:mm free".
Definition: videodir.c:220
const cRecordingInfo * Info(void) const
Definition: recording.h:149
time_t Vps(void) const
Definition: epg.h:109
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas)
Sets the sub-areas to the given areas.
Definition: osd.c:1823
const char * ShortText(void) const
Definition: recording.h:86
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 void Clear(void)
Clears the entire central area of the menu.
Definition: skinclassic.c:272
virtual void SetEvents(const cEvent *Present, const cEvent *Following)
Sets the Present and Following EPG events.
Definition: skinclassic.c:123
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 cSkinDisplayMessage * DisplayMessage(void)
Creates and returns a new object for displaying a message.
Definition: skinclassic.c:780
virtual const cFont * GetTextAreaFont(bool FixedFont) const
Returns a pointer to the font which is used to display text with SetText().
Definition: skinclassic.c:432
cString GetParentalRatingString(void) const
Definition: epg.c:402
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:1922
virtual void Flush(void)
Actually draws the OSD display to the output device.
Definition: skinclassic.c:151
virtual void SetMessage(eMessageType Type, const char *Text)
Sets a one line message Text, with the given Type.
Definition: skinclassic.c:309
static cString sprintf(const char *fmt,...) __attribute__((format(printf
Definition: tools.c:1080
virtual ~cSkinClassicDisplayMessage()
Definition: skinclassic.c:727
cSkinClassicDisplayReplay(bool ModeOnly)
Definition: skinclassic.c:473
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:2137
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:421
virtual cSkinDisplayMenu * DisplayMenu(void)
Creates and returns a new object for displaying a menu.
Definition: skinclassic.c:760
char * strn0cpy(char *dest, const char *src, size_t n)
Definition: tools.c:131
T max(T a, T b)
Definition: tools.h:55
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:1952
virtual void SetMessage(eMessageType Type, const char *Text)
Sets a one line message Text, with the given Type.
Definition: skinclassic.c:137
virtual void Flush(void)
Actually draws the OSD display to the output device.
Definition: skinclassic.c:696
static cSkinDisplay * Current(void)
Returns the currently active cSkinDisplay.
Definition: skins.h:48
time_t StartTime(void) const
Definition: epg.h:106
int ShowReplayMode
Definition: config.h:340
int ColorKey2
Definition: config.h:311
T min(T a, T b)
Definition: tools.h:54
cString ChannelString(const cChannel *Channel, int Number)
Definition: channels.c:1147
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, provided this cSkinDisplay actually has a color button d...
Definition: skins.h:40
virtual void Flush(void)
Actually commits all data to the OSD hardware.
Definition: osd.c:1982
Definition: osd.h:158
Definition: osd.h:34
int Height(void)
Definition: osd.h:1035
#define clrBackground
Definition: skincurses.c:34
cString GetVpsString(void) const
Definition: epg.c:424
virtual void SetRecording(const cRecording *Recording)
Sets the Recording that shall be displayed, using the entire central area of the menu.
Definition: skinclassic.c:386
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:505
Definition: osd.h:33
virtual ~cSkinClassicDisplayVolume()
Definition: skinclassic.c:589
virtual int GetTextAreaWidth(void) const
Returns the width in pixel of the area which is used to display text with SetText().
Definition: skinclassic.c:427
int ParentalRating(void) const
Definition: epg.h:105
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 void SetTitle(const char *Title)
Sets the title of the recording.
Definition: skinclassic.c:500
Definition: themes.h:17
Definition: font.h:22
static int OsdWidth(void)
Definition: osd.h:788
int ChannelInfoPos
Definition: config.h:316
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
Definition: osd.h:37
Definition: osd.h:39
virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas)
Checks whether the OSD can display the given set of sub-areas.
Definition: osd.c:1801
#define TextSpacing
Definition: skinclassic.c:19
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:197
The cOsd class is the interface to the "On Screen Display".
Definition: osd.h:720
Definition: osd.h:40
Definition: skins.h:94
cSetup Setup
Definition: config.c:373
virtual void SetChannel(const cChannel *Channel, int Number)
Sets the current channel to Channel.
Definition: skinclassic.c:116
cString DayDateTime(time_t t)
Converts the given time to a string of the form "www dd.mm. hh:mm".
Definition: tools.c:1145
virtual ~cSkinClassicDisplayChannel()
Definition: skinclassic.c:111
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:1942
static cTheme Theme
Definition: skinclassic.c:21
int ColorKey3
Definition: config.h:311
Definition: skins.h:370
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:535
static int OsdTop(void)
Definition: osd.h:787
cSkinClassic(void)
Definition: skinclassic.c:745
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:36
int Height(void)
Definition: osd.h:803
const char * Title(void) const
Definition: epg.h:100
static int OsdLeft(void)
Definition: osd.h:786
Definition: osd.h:41
virtual ~cSkinClassicDisplayTracks()
Definition: skinclassic.c:667
virtual void SetMessage(eMessageType Type, const char *Text)
Sets a one line message Text, with the given Type.
Definition: skinclassic.c:547
virtual cSkinDisplayVolume * DisplayVolume(void)
Creates and returns a new object for displaying the current volume.
Definition: skinclassic.c:770
cString GetEndTimeString(void) const
Definition: epg.c:419
#define TextFrame
Definition: skinclassic.c:18
cSkinClassicDisplayChannel(bool WithInfo)
Definition: skinclassic.c:93
Definition: osd.h:298
virtual ~cSkinClassicDisplayReplay()
Definition: skinclassic.c:495
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:527
int ColorKey1
Definition: config.h:311
virtual int Width(uint c) const =0
Returns the width of the given character in pixel.
int Width(void)
Definition: osd.h:802
#define tr(s)
Definition: i18n.h:85
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:750
virtual ~cSkinClassicDisplayMenu()
Definition: skinclassic.c:234
virtual void SetVolume(int Current, int Total, bool Mute)
< This class implements the volume/mute display.
Definition: skinclassic.c:594
cString GetTimeString(void) const
Definition: epg.c:414
const cEvent * GetEvent(void) const
Definition: recording.h:84
const char * Description(void) const
Definition: recording.h:87
const char * Name(void) const
Returns the full name of the recording (without the video directory.
Definition: recording.h:142
cString TimeString(time_t t)
Converts the given time to a string of the form "hh:mm".
Definition: tools.c:1186
void SetTextScrollbar(void)
Definition: skinclassic.c:255
cSkinClassicDisplayTracks(const char *Title, int NumTracks, const char *const *Tracks)
Definition: skinclassic.c:635
const char * Title(void) const
Definition: recording.h:85
const char * Description(void) const
Definition: epg.h:102
virtual void Flush(void)
Actually draws the OSD display to the output device.
Definition: skinclassic.c:437
int ColorKey0
Definition: config.h:311
Definition: osd.h:44
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:521
#define ScrollWidth
Definition: skinclassic.c:17
virtual int Height(void) const =0
Returns the height of this font in pixel (all characters have the same height).
virtual void RestoreRegion(void)
Restores the region previously saved by a call to SaveRegion().
Definition: osd.c:1871
const char * ChannelName(void) const
Definition: recording.h:83
cString GetDateString(void) const
Definition: epg.c:409
virtual int MaxItems(void)
Returns the maximum number of items the menu can display.
Definition: skinclassic.c:267
const char * ShortText(void) const
Definition: epg.h:101
virtual cSkinDisplayChannel * DisplayChannel(bool WithInfo)
Creates and returns a new object for displaying the current channel.
Definition: skinclassic.c:755
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:1855
void DrawScrollbar(int Total, int Offset, int Shown, int Top, int Height, bool CanScrollUp, bool CanScrollDown)
Definition: skinclassic.c:239
Definition: osd.h:35
tColor Color(int Subject)
Returns the color for the given Subject.
Definition: themes.c:201
Definition: font.h:37
virtual void Flush(void)
Actually draws the OSD display to the output device.
Definition: skinclassic.c:738
virtual void Flush(void)
Actually draws the OSD display to the output device.
Definition: skinclassic.c:612
virtual void SetTrack(int Index, const char *const *Tracks)
< This class implements the track display.
Definition: skinclassic.c:689
virtual void SetTitle(const char *Title)
Sets the title of this menu to Title.
Definition: skinclassic.c:285
Definition: tools.h:168
static const cFont * GetFont(eDvbFont Font)
Gets the given Font, which was previously set by a call to SetFont().
Definition: font.c:406
cString DateString(time_t t)
Converts the given time to a string of the form "www dd.mm.yyyy".
Definition: tools.c:1166
THEME_CLR(Theme, clrBackground, clrGray50)
uint32_t tColor
Definition: font.h:29
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:2006