vdr  1.7.31
skinsttng.c
Go to the documentation of this file.
1 /*
2  * skinsttng.c: A VDR skin with ST:TNG Panels
3  *
4  * See the main source file 'vdr.c' for copyright information and
5  * how to reach the author.
6  *
7  * $Id: skinsttng.c 2.16 2012/09/09 11:39:06 kls Exp $
8  */
9 
10 // "Star Trek: The Next Generation"(R) is a registered trademark of Paramount Pictures
11 // registered in the United States Patent and Trademark Office.
12 // No infringement intended.
13 
14 #include "skinsttng.h"
15 #include "font.h"
16 #include "osd.h"
17 #include "menu.h"
18 #include "themes.h"
19 #include "videodir.h"
20 
21 #include "symbols/arrowdown.xpm"
22 #include "symbols/arrowup.xpm"
23 #include "symbols/audio.xpm"
24 #include "symbols/audioleft.xpm"
25 #include "symbols/audioright.xpm"
26 #include "symbols/audiostereo.xpm"
27 #include "symbols/dolbydigital.xpm"
28 #include "symbols/encrypted.xpm"
29 #include "symbols/ffwd.xpm"
30 #include "symbols/ffwd1.xpm"
31 #include "symbols/ffwd2.xpm"
32 #include "symbols/ffwd3.xpm"
33 #include "symbols/frew.xpm"
34 #include "symbols/frew1.xpm"
35 #include "symbols/frew2.xpm"
36 #include "symbols/frew3.xpm"
37 #include "symbols/mute.xpm"
38 #include "symbols/pause.xpm"
39 #include "symbols/play.xpm"
40 #include "symbols/radio.xpm"
41 #include "symbols/recording.xpm"
42 #include "symbols/sfwd.xpm"
43 #include "symbols/sfwd1.xpm"
44 #include "symbols/sfwd2.xpm"
45 #include "symbols/sfwd3.xpm"
46 #include "symbols/srew.xpm"
47 #include "symbols/srew1.xpm"
48 #include "symbols/srew2.xpm"
49 #include "symbols/srew3.xpm"
50 #include "symbols/teletext.xpm"
51 #include "symbols/volume.xpm"
52 
53 #define Roundness (Setup.FontOsdSize / 2)
54 #define Gap (Setup.FontOsdSize / 5)
55 #define ScrollWidth (Setup.FontOsdSize / 4)
56 #define TextFrame (Setup.FontOsdSize / 10)
57 #define TextSpacing (Setup.FontOsdSize / 4)
58 #define SymbolSpacing (Setup.FontOsdSize / 4)
59 
60 static cTheme Theme;
61 
63 THEME_CLR(Theme, clrButtonRedFg, clrWhite);
64 THEME_CLR(Theme, clrButtonRedBg, clrRed);
65 THEME_CLR(Theme, clrButtonGreenFg, clrBlack);
66 THEME_CLR(Theme, clrButtonGreenBg, clrGreen);
67 THEME_CLR(Theme, clrButtonYellowFg, clrBlack);
68 THEME_CLR(Theme, clrButtonYellowBg, clrYellow);
69 THEME_CLR(Theme, clrButtonBlueFg, clrWhite);
70 THEME_CLR(Theme, clrButtonBlueBg, clrBlue);
71 THEME_CLR(Theme, clrMessageFrame, clrYellow);
72 THEME_CLR(Theme, clrMessageStatusFg, clrBlack);
73 THEME_CLR(Theme, clrMessageStatusBg, clrCyan);
74 THEME_CLR(Theme, clrMessageInfoFg, clrBlack);
75 THEME_CLR(Theme, clrMessageInfoBg, clrGreen);
76 THEME_CLR(Theme, clrMessageWarningFg, clrBlack);
77 THEME_CLR(Theme, clrMessageWarningBg, clrYellow);
78 THEME_CLR(Theme, clrMessageErrorFg, clrWhite);
79 THEME_CLR(Theme, clrMessageErrorBg, clrRed);
80 THEME_CLR(Theme, clrVolumeFrame, clrYellow);
81 THEME_CLR(Theme, clrVolumeSymbol, clrBlack);
82 THEME_CLR(Theme, clrVolumeBarUpper, 0xFFBC8024);
83 THEME_CLR(Theme, clrVolumeBarLower, 0xFF248024);
84 THEME_CLR(Theme, clrChannelFrame, clrYellow);
85 THEME_CLR(Theme, clrChannelName, clrBlack);
86 THEME_CLR(Theme, clrChannelDate, clrBlack);
87 THEME_CLR(Theme, clrChannelSymbolOn, clrBlack);
88 THEME_CLR(Theme, clrChannelSymbolOff, 0xFFBC8024);
89 THEME_CLR(Theme, clrChannelSymbolRecFg, clrWhite);
90 THEME_CLR(Theme, clrChannelSymbolRecBg, clrRed);
91 THEME_CLR(Theme, clrChannelEpgTime, clrBlack);
92 THEME_CLR(Theme, clrChannelEpgTitle, clrCyan);
93 THEME_CLR(Theme, clrChannelEpgShortText, clrYellow);
94 THEME_CLR(Theme, clrChannelTimebarSeen, clrYellow);
95 THEME_CLR(Theme, clrChannelTimebarRest, clrGray50);
96 THEME_CLR(Theme, clrChannelSignalValue, clrGreen);
97 THEME_CLR(Theme, clrChannelSignalRest, clrRed);
98 THEME_CLR(Theme, clrMenuFrame, clrYellow);
99 THEME_CLR(Theme, clrMenuTitle, clrBlack);
100 THEME_CLR(Theme, clrMenuDate, clrBlack);
101 THEME_CLR(Theme, clrMenuItemCurrentFg, clrBlack);
102 THEME_CLR(Theme, clrMenuItemCurrentBg, clrYellow);
103 THEME_CLR(Theme, clrMenuItemSelectable, clrYellow);
104 THEME_CLR(Theme, clrMenuItemNonSelectable, clrCyan);
105 THEME_CLR(Theme, clrMenuEventTime, clrYellow);
106 THEME_CLR(Theme, clrMenuEventVps, clrBlack);
107 THEME_CLR(Theme, clrMenuEventTitle, clrCyan);
108 THEME_CLR(Theme, clrMenuEventShortText, clrYellow);
109 THEME_CLR(Theme, clrMenuEventDescription, clrCyan);
110 THEME_CLR(Theme, clrMenuScrollbarTotal, clrYellow);
111 THEME_CLR(Theme, clrMenuScrollbarShown, clrCyan);
112 THEME_CLR(Theme, clrMenuScrollbarArrow, clrBlack);
113 THEME_CLR(Theme, clrMenuText, clrCyan);
114 THEME_CLR(Theme, clrReplayFrame, clrYellow);
115 THEME_CLR(Theme, clrReplayTitle, clrBlack);
116 THEME_CLR(Theme, clrReplayMode, clrBlack);
117 THEME_CLR(Theme, clrReplayCurrent, clrBlack);
118 THEME_CLR(Theme, clrReplayTotal, clrBlack);
119 THEME_CLR(Theme, clrReplayJump, clrBlack);
120 THEME_CLR(Theme, clrReplayProgressSeen, clrGreen);
121 THEME_CLR(Theme, clrReplayProgressRest, clrWhite);
122 THEME_CLR(Theme, clrReplayProgressSelected, clrRed);
123 THEME_CLR(Theme, clrReplayProgressMark, clrBlack);
124 THEME_CLR(Theme, clrReplayProgressCurrent, clrRed);
125 
126 // --- cSkinSTTNGDisplayChannel ----------------------------------------------
127 
129 private:
131  int x0, x1, x2, x3, x4, x5, x6, x7;
132  int y0, y1, y2, y3, y4, y5, y6, y7;
133  bool withInfo;
136  bool message;
137  const cEvent *present;
139  int lastSeen;
146 public:
147  cSkinSTTNGDisplayChannel(bool WithInfo);
148  virtual ~cSkinSTTNGDisplayChannel();
149  virtual void SetChannel(const cChannel *Channel, int Number);
150  virtual void SetEvents(const cEvent *Present, const cEvent *Following);
151  virtual void SetMessage(eMessageType Type, const char *Text);
152  virtual void Flush(void);
153  };
154 
161 
163 {
164  present = NULL;
165  lastSeen = -1;
166  lastDeviceNumber = -1;
167  lastSignalStrength = -1;
168  lastSignalQuality = -1;
169  lastSignalDisplay = 0;
170  memset(&lastTrackId, 0, sizeof(lastTrackId));
171  const cFont *font = cFont::GetFont(fontOsd);
172  withInfo = WithInfo;
173  lineHeight = font->Height();
174  frameColor = Theme.Color(clrChannelFrame);
175  message = false;
176  if (withInfo) {
177  x0 = 0;
178  x1 = x0 + font->Width("00:00") + 2 * TextFrame;
179  x2 = x1 + Roundness;
180  x3 = x2 + Gap;
181  x7 = cOsd::OsdWidth();
182  x6 = x7 - lineHeight / 2;
183  x5 = x6 - lineHeight / 2;
184  x4 = x5 - Gap;
185  y0 = 0;
186  y1 = lineHeight;
187  y2 = y1 + Roundness;
188  y3 = y2 + Gap;
189  y4 = y3 + 4 * lineHeight;
190  y5 = y4 + Gap;
191  y6 = y5 + Roundness;
192  y7 = y6 + cFont::GetFont(fontSml)->Height();
193  int yt = (y0 + y1) / 2;
194  int yb = (y6 + y7) / 2;
196  tArea Areas[] = { { 0, 0, x7 - 1, y7 - 1, 32 } }; // TrueColor
197  if (osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
198  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
199  else {
200  tArea Areas[] = { { 0, 0, x7 - 1, y7 - 1, 8 } }; // 256 colors
201  if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
202  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
203  else {
204  tArea Areas[] = { { 0, 0, x7 - 1, y7 - 1, 4 } }; // 16 colors
205  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
206  }
207  }
208  osd->DrawRectangle(x0, y0, x7 - 1, y7 - 1, Theme.Color(clrBackground));
209  osd->DrawRectangle(x0, y0, x1 - 1, y1 - 1, clrTransparent);
210  osd->DrawRectangle(x0, y6, x1 - 1, y7 - 1, clrTransparent);
211  osd->DrawRectangle(x6, y0, x7 - 1, yt - 1, clrTransparent);
212  osd->DrawRectangle(x6, yb, x7 - 1, y7 - 1, clrTransparent);
213  osd->DrawEllipse (x0, y0, x1 - 1, y1 - 1, frameColor, 2);
214  osd->DrawRectangle(x1, y0, x4 - 1, y1 - 1, frameColor);
215  osd->DrawRectangle(x5, y0, x6 - 1, y1 - 1, frameColor);
216  osd->DrawEllipse (x6, y0, x7 - 1, y1 - 1, frameColor, 5);
217  osd->DrawRectangle(x0, y1, x1 - 1, y2 - 1, frameColor);
218  osd->DrawEllipse (x1, y1, x2 - 1, y2 - 1, frameColor, -2);
219  osd->DrawRectangle(x0, y3, x1 - 1, y4 - 1, frameColor);
220  osd->DrawRectangle(x0, y5, x1 - 1, y6 - 1, frameColor);
221  osd->DrawEllipse (x1, y5, x2 - 1, y6 - 1, frameColor, -3);
222  osd->DrawEllipse (x0, y6, x1 - 1, y7 - 1, frameColor, 3);
223  osd->DrawRectangle(x1, y6, x4 - 1, y7 - 1, frameColor);
224  osd->DrawRectangle(x5, y6, x6 - 1, y7 - 1, frameColor);
225  osd->DrawEllipse (x6, y6, x7 - 1, y7 - 1, frameColor, 5);
226  }
227  else {
228  x0 = 0;
229  x1 = lineHeight / 2;
230  x2 = lineHeight;
231  x3 = x2 + Gap;
232  x7 = cOsd::OsdWidth();
233  x6 = x7 - lineHeight / 2;
234  x5 = x6 - lineHeight / 2;
235  x4 = x5 - Gap;
236  y0 = 0;
237  y1 = lineHeight;
239  tArea Areas[] = { { x0, y0, x7 - 1, y1 - 1, 32 } }; // TrueColor
240  if (osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
241  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
242  else {
243  tArea Areas[] = { { x0, y0, x7 - 1, y1 - 1, 8 } }; // 256 colors
244  if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
245  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
246  else {
247  tArea Areas[] = { { x0, y0, x7 - 1, y1 - 1, 4 } }; // 16 colors
248  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
249  }
250  }
251  osd->DrawRectangle(x0, y0, x7 - 1, y1 - 1, clrTransparent);
252  osd->DrawEllipse (x0, y0, x1 - 1, y1 - 1, frameColor, 7);
253  osd->DrawRectangle(x1, y0, x2 - 1, y1 - 1, frameColor);
254  osd->DrawRectangle(x5, y0, x6 - 1, y1 - 1, frameColor);
255  osd->DrawEllipse (x6, y0, x7 - 1, y1 - 1, frameColor, 5);
256  }
257 }
258 
260 {
261  delete osd;
262 }
263 
264 void cSkinSTTNGDisplayChannel::SetChannel(const cChannel *Channel, int Number)
265 {
266  osd->DrawRectangle(x3, y0, x4 - 1, y1 - 1, frameColor);
267  int x = x4 - SymbolSpacing;
268  if (Channel && !Channel->GroupSep()) {
269  bool rec = cRecordControls::Active();
271  osd->DrawBitmap(x, y0 + (y1 - y0 - bmRecording.Height()) / 2, bmRecording, Theme.Color(rec ? clrChannelSymbolRecFg : clrChannelSymbolOff), rec ? Theme.Color(clrChannelSymbolRecBg) : frameColor);
273  osd->DrawBitmap(x, y0 + (y1 - y0 - bmEncrypted.Height()) / 2, bmEncrypted, Theme.Color(Channel->Ca() ? clrChannelSymbolOn : clrChannelSymbolOff), frameColor);
275  osd->DrawBitmap(x, y0 + (y1 - y0 - bmDolbyDigital.Height()) / 2, bmDolbyDigital, Theme.Color(Channel->Dpid(0) ? clrChannelSymbolOn : clrChannelSymbolOff), frameColor);
276  x -= bmAudio.Width() + SymbolSpacing;
277  osd->DrawBitmap(x, y0 + (y1 - y0 - bmAudio.Height()) / 2, bmAudio, Theme.Color(Channel->Apid(1) ? clrChannelSymbolOn : clrChannelSymbolOff), frameColor);
278  if (Channel->Vpid()) {
279  x -= bmTeletext.Width() + SymbolSpacing;
280  osd->DrawBitmap(x, y0 + (y1 - y0 - bmTeletext.Height()) / 2, bmTeletext, Theme.Color(Channel->Tpid() ? clrChannelSymbolOn : clrChannelSymbolOff), frameColor);
281  }
282  else if (Channel->Apid(0)) {
283  x -= bmRadio.Width() + SymbolSpacing;
284  osd->DrawBitmap(x, y0 + (y1 - y0 - bmRadio.Height()) / 2, bmRadio, Theme.Color(clrChannelSymbolOn), frameColor);
285  }
286  }
287  osd->DrawText(x3 + TextFrame, y0, ChannelString(Channel, Number), Theme.Color(clrChannelName), frameColor, cFont::GetFont(fontOsd), x - x3 - TextFrame);
288  lastSignalDisplay = 0;
289 }
290 
291 void cSkinSTTNGDisplayChannel::SetEvents(const cEvent *Present, const cEvent *Following)
292 {
293  if (!withInfo)
294  return;
295  if (present != Present)
296  lastSeen = -1;
297  present = Present;
298  osd->DrawRectangle(x0, y3, x1 - 1, y4 - 1, frameColor);
299  osd->DrawRectangle(x3, y3, x7 - 1, y4 - 1, Theme.Color(clrBackground));
300  for (int i = 0; i < 2; i++) {
301  const cEvent *e = !i ? Present : Following;
302  if (e) {
303  osd->DrawText(x0 + TextFrame, y3 + 2 * i * lineHeight, e->GetTimeString(), Theme.Color(clrChannelEpgTime), frameColor, cFont::GetFont(fontOsd));
304  osd->DrawText(x3 + TextFrame, y3 + 2 * i * lineHeight, e->Title(), Theme.Color(clrChannelEpgTitle), Theme.Color(clrBackground), cFont::GetFont(fontOsd), x4 - x3 - TextFrame);
305  osd->DrawText(x3 + TextFrame, y3 + (2 * i + 1) * lineHeight, e->ShortText(), Theme.Color(clrChannelEpgShortText), Theme.Color(clrBackground), cFont::GetFont(fontSml), x4 - x3 - TextFrame);
306  }
307  }
308 }
309 
311 {
312  const cFont *font = cFont::GetFont(withInfo ? fontSml : fontOsd);
313  if (Text) {
314  int yt = withInfo ? y6 : y0;
315  int yb = withInfo ? y7 : y1;
316  osd->SaveRegion(x2, yt, x4 - 1, yb - 1);
317  if (withInfo)
318  osd->DrawRectangle(x2, yt, x3 - 1, yb - 1, Theme.Color(clrBackground));
319  osd->DrawText(x3, yt, Text, Theme.Color(clrMessageStatusFg + 2 * Type), Theme.Color(clrMessageStatusBg + 2 * Type), font, x4 - x3, 0, taCenter);
320  message = true;
321  }
322  else {
323  osd->RestoreRegion();
324  message = false;
325  }
326 }
327 
329 {
330  if (withInfo) {
331  if (!message) {
332  const cFont *font = cFont::GetFont(fontSml);
333  cString date = DayDateTime();
334  int w = font->Width(date);
335  if (!*lastDate || strcmp(date, lastDate)) {
336  osd->DrawText(x4 - w - TextFrame, y7 - font->Height(), date, Theme.Color(clrChannelDate), frameColor, font, w);
337  lastDate = date;
338  }
339  cDevice *Device = cDevice::PrimaryDevice();
340  const tTrackId *Track = Device->GetTrack(Device->GetCurrentAudioTrack());
341  if (!Track && *lastTrackId.description || Track && strcmp(lastTrackId.description, Track->description)) {
342  osd->DrawText(x3 + TextFrame, y6, Track ? Track->description : "", Theme.Color(clrChannelName), frameColor, font, x4 - x3 - w - 2 * TextFrame);
343  strn0cpy(lastTrackId.description, Track ? Track->description : "", sizeof(lastTrackId.description));
344  }
345  int DeviceNumber = cDevice::ActualDevice()->DeviceNumber() + 1;
346  if (DeviceNumber != lastDeviceNumber || time(NULL) != lastSignalDisplay) {
347  int SignalStrength = cDevice::ActualDevice()->SignalStrength();
348  int SignalQuality = cDevice::ActualDevice()->SignalQuality();
349  if (DeviceNumber != lastDeviceNumber || SignalStrength != lastSignalStrength || SignalQuality != lastSignalQuality) {
350  int d = 3;
351  int h = ((y7 - y6 + 1) - 3 * d) / 2;
352  int w = (x4 - x3) / 5;
353  int x = (x3 + x4) / 2 - w / 2;
354  if (SignalStrength >= 0) {
355  int s = SignalStrength * w / 100;
356  osd->DrawRectangle(x, y6 + d, x + s - 1, y6 + d + h - 1, Theme.Color(clrChannelSignalValue));
357  osd->DrawRectangle(x + s, y6 + d, x + w - 1, y6 + d + h - 1, Theme.Color(clrChannelSignalRest));
358  }
359  else if (DeviceNumber != lastDeviceNumber)
360  osd->DrawRectangle(x, y6 + d, x + w - 1, y6 + d + h - 1, Theme.Color(clrChannelFrame));
361  if (SignalQuality >= 0) {
362  int q = SignalQuality * w / 100;
363  osd->DrawRectangle(x, y7 - d - h + 1, x + q - 1, y7 - d, Theme.Color(clrChannelSignalValue));
364  osd->DrawRectangle(x + q, y7 - d - h + 1, x + w - 1, y7 - d, Theme.Color(clrChannelSignalRest));
365  }
366  else if (DeviceNumber != lastDeviceNumber)
367  osd->DrawRectangle(x, y7 - d - h + 1, x + w - 1, y7 - d, Theme.Color(clrChannelFrame));
368  cString dn = cString::sprintf(" %d ", DeviceNumber);
369  const cFont *font = cFont::GetFont(fontSml);
370  int dw = font->Width(dn);
371  osd->DrawText(x - 2 * d - dw, y6, dn, Theme.Color(clrChannelDate), frameColor, font, dw);
372  lastDeviceNumber = DeviceNumber;
373  lastSignalStrength = SignalStrength;
374  lastSignalQuality = SignalQuality;
375  }
376  lastSignalDisplay = time(NULL);
377  }
378  }
379  int seen = 0;
380  if (present) {
381  time_t t = time(NULL);
382  if (t > present->StartTime())
383  seen = min(y4 - y3 - 1, int((y4 - y3) * double(t - present->StartTime()) / present->Duration()));
384  }
385  if (seen != lastSeen) {
386  osd->DrawRectangle(x1 + Gap, y3, x1 + Gap + ScrollWidth - 1, y4 - 1, Theme.Color(clrChannelTimebarRest));
387  if (seen)
388  osd->DrawRectangle(x1 + Gap, y3, x1 + Gap + ScrollWidth - 1, y3 + seen, Theme.Color(clrChannelTimebarSeen));
389  lastSeen = seen;
390  }
391  }
392  osd->Flush();
393 }
394 
395 // --- cSkinSTTNGDisplayMenu -------------------------------------------------
396 
398 private:
400  int x0, x1, x2, x3, x4, x5, x6, x7;
401  int y0, y1, y2, y3, y4, y5, y6, y7;
406  bool message;
409  void DrawTitle(void);
410  void DrawScrollbar(int Total, int Offset, int Shown, int Top, int Height, bool CanScrollUp, bool CanScrollDown);
411  void SetTextScrollbar(void);
412 public:
413  cSkinSTTNGDisplayMenu(void);
414  virtual ~cSkinSTTNGDisplayMenu();
415  virtual void Scroll(bool Up, bool Page);
416  virtual int MaxItems(void);
417  virtual void Clear(void);
418  virtual void SetTitle(const char *Title);
419  virtual void SetButtons(const char *Red, const char *Green = NULL, const char *Yellow = NULL, const char *Blue = NULL);
420  virtual void SetMessage(eMessageType Type, const char *Text);
421  virtual void SetItem(const char *Text, int Index, bool Current, bool Selectable);
422  virtual void SetScrollbar(int Total, int Offset);
423  virtual void SetEvent(const cEvent *Event);
424  virtual void SetRecording(const cRecording *Recording);
425  virtual void SetText(const char *Text, bool FixedFont);
426  virtual int GetTextAreaWidth(void) const;
427  virtual const cFont *GetTextAreaFont(bool FixedFont) const;
428  virtual void Flush(void);
429  };
430 
432 {
433  const cFont *font = cFont::GetFont(fontOsd);
434  lineHeight = font->Height();
435  frameColor = Theme.Color(clrMenuFrame);
436  lastDiskUsageState = -1;
437  currentIndex = -1;
438  message = false;
439  x0 = 0;
440  x1 = lineHeight / 2;
441  x3 = (x1 + Roundness + Gap + 7) & ~0x07; // must be multiple of 8
442  x2 = x3 - Gap;
443  x7 = cOsd::OsdWidth();
444  x6 = x7 - lineHeight / 2;
445  x4 = (x6 - lineHeight / 2 - Gap) & ~0x07; // must be multiple of 8
446  x5 = x4 + Gap;
447  y0 = 0;
448  y1 = lineHeight;
449  y2 = y1 + Roundness;
450  y3 = y2 + Gap;
451  y7 = cOsd::OsdHeight();
452  y6 = y7 - cFont::GetFont(fontSml)->Height();
453  y5 = y6 - Roundness;
454  y4 = y5 - Gap;
455  int yt = (y0 + y1) / 2;
456  int yb = (y6 + y7) / 2;
458  tArea Areas[] = { { x0, y0, x7 - 1, y7 - 1, 32 } }; // TrueColor
459  if (osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
460  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
461  else {
462  tArea Areas[] = { { x0, y0, x7 - 1, y7 - 1, 8 } }; // 256 colors
463  if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
464  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
465  else {
466  tArea Areas[] = { { x0, y0, x7 - 1, y7 - 1, 4 } }; // 16 colors
467  if (osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
468  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
469  else {
470  tArea Areas[] = { { x0, y0, x7 - 1, y3 - 1, 2 }, // 2..16 colors
471  { x0, y3, x3 - 1, y4 - 1, 1 },
472  { x3, y3, x4 - 1, y4 - 1, 2 },
473  { x4, y3, x7 - 1, y4 - 1, 2 },
474  { x0, y4, x7 - 1, y7 - 1, 4 }
475  };
476  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
477  }
478  }
479  }
480  osd->DrawRectangle(x0, y0, x7 - 1, y7 - 1, Theme.Color(clrBackground));
481  osd->DrawRectangle(x0, y0, x1 - 1, y1 - 1, clrTransparent);
482  osd->DrawRectangle(x0, y6, x1 - 1, y7 - 1, clrTransparent);
483  osd->DrawRectangle(x6, y0, x7 - 1, yt - 1, clrTransparent);
484  osd->DrawRectangle(x6, yb, x7 - 1, y7 - 1, clrTransparent);
485  osd->DrawEllipse (x0, y0, x1 - 1, y1 - 1, frameColor, 2);
486  osd->DrawRectangle(x1, y0, x2 - 1, y1 - 1, frameColor);
487  osd->DrawRectangle(x3, y0, x4 - 1, y1 - 1, frameColor);
488  osd->DrawRectangle(x5, y0, x6 - 1, y1 - 1, frameColor);
489  osd->DrawEllipse (x6, y0, x7 - 1, y1 - 1, frameColor, 5);
490  osd->DrawRectangle(x0, y1, x1 - 1, y6 - 1, frameColor);
491  osd->DrawEllipse (x1, y1, x2 - 1, y2 - 1, frameColor, -2);
492  osd->DrawEllipse (x1, y5, x2 - 1, y6 - 1, frameColor, -3);
493  osd->DrawEllipse (x0, y6, x1 - 1, y7 - 1, frameColor, 3);
494  osd->DrawRectangle(x1, y6, x2 - 1, y7 - 1, frameColor);
495  osd->DrawRectangle(x3, y6, x4 - 1, y7 - 1, frameColor);
496  osd->DrawRectangle(x5, y6, x6 - 1, y7 - 1, frameColor);
497  osd->DrawEllipse (x6, y6, x7 - 1, y7 - 1, frameColor, 5);
498 }
499 
501 {
502  delete osd;
503 }
504 
505 void cSkinSTTNGDisplayMenu::DrawScrollbar(int Total, int Offset, int Shown, int Top, int Height, bool CanScrollUp, bool CanScrollDown)
506 {
507  if (Total > 0 && Total > Shown) {
508  int h = lineHeight;
509  int yt = Top;
510  int yb = yt + Height;
511  int st = yt + h + Gap;
512  int sb = yb - h - Gap;
513  int th = max(int((sb - st) * double(Shown) / Total + 0.5), ScrollWidth);
514  int tt = min(int(st + (sb - st) * double(Offset) / Total + 0.5), sb - th);
515  int tb = min(tt + th, sb);
516  osd->DrawRectangle(x5, st, x5 + ScrollWidth - 1, sb - 1, Theme.Color(clrMenuScrollbarTotal));
517  osd->DrawRectangle(x5, tt, x5 + ScrollWidth - 1, tb - 1, Theme.Color(clrMenuScrollbarShown));
518  osd->DrawRectangle(x5, yt, x6 - 1, yt + h - 1, frameColor);
519  osd->DrawEllipse (x6, yt, x7 - 1, yt + h - 1, frameColor, 5);
520  osd->DrawRectangle(x5, yb - h, x6 - 1, yb - 1, frameColor);
521  osd->DrawEllipse (x6, yb - h, x7 - 1, yb - 1, frameColor, 5);
522  if (CanScrollUp) {
523  cBitmap bm(arrowup_xpm);
524  osd->DrawBitmap(x5 + (x7 - x5 - bm.Width()) / 2 - 2, yt + (h - bm.Height()) / 2, bm, Theme.Color(clrMenuScrollbarArrow), frameColor);
525  }
526  if (CanScrollDown) {
527  cBitmap bm(arrowdown_xpm);
528  osd->DrawBitmap(x5 + (x7 - x5 - bm.Width()) / 2 - 2, yb - h + (h - bm.Height()) / 2, bm, Theme.Color(clrMenuScrollbarArrow), frameColor);
529  }
530  }
531 }
532 
534 {
535  if (textScroller.CanScroll())
537 }
538 
539 void cSkinSTTNGDisplayMenu::Scroll(bool Up, bool Page)
540 {
541  cSkinDisplayMenu::Scroll(Up, Page);
543 }
544 
546 {
547  return (y4 - y3 - 2 * Roundness) / lineHeight;
548 }
549 
551 {
553  osd->DrawRectangle(x1, y3, x7 - 1, y4 - 1, Theme.Color(clrBackground));
554 }
555 
557 {
558  const cFont *font = cFont::GetFont(fontOsd);
559  const char *VDR = " VDR";
560  bool WithDisk = MenuCategory() == mcMain || MenuCategory() == mcRecording;
561  int w = font->Width(VDR);
562  osd->DrawText(x3 + TextSpacing, y0, WithDisk ? cString::sprintf("%s - %s", *title, *cVideoDiskUsage::String()) : title, Theme.Color(clrMenuTitle), frameColor, font, x4 - w - x3 - TextSpacing);
563  osd->DrawText(x4 - w, y0, VDR, frameColor, clrBlack, font, w, lineHeight);
564 }
565 
566 void cSkinSTTNGDisplayMenu::SetTitle(const char *Title)
567 {
568  title = Title;
569  DrawTitle();
570 }
571 
572 void cSkinSTTNGDisplayMenu::SetButtons(const char *Red, const char *Green, const char *Yellow, const char *Blue)
573 {
574  const char *lutText[] = { Red, Green, Yellow, Blue };
575  tColor lutFg[] = { clrButtonRedFg, clrButtonGreenFg, clrButtonYellowFg, clrButtonBlueFg };
576  tColor lutBg[] = { clrButtonRedBg, clrButtonGreenBg, clrButtonYellowBg, clrButtonBlueBg };
577  cString date = DayDateTime();
578  const cFont *font = cFont::GetFont(fontSml);
579  int d = 2 * Gap;
580  int d2 = d / 2;
581  int t4 = x4 - font->Width(date) - TextFrame;
582  int w = t4 - x3;
583  int t0 = x3 + d2;
584  int t1 = x3 + w / 4;
585  int t2 = x3 + w / 2;
586  int t3 = t4 - w / 4;
587  osd->DrawRectangle(t0 + d2, y6, t1 - d2, y7 - 1, clrBlack);
588  osd->DrawRectangle(t1 + d2, y6, t2 - d2, y7 - 1, clrBlack);
589  osd->DrawRectangle(t2 + d2, y6, t3 - d2, y7 - 1, clrBlack);
590  osd->DrawRectangle(t3 + d2, y6, t4 - d2, y7 - 1, clrBlack);
591  osd->DrawText(t0 + d, y6, lutText[Setup.ColorKey0], Theme.Color(lutFg[Setup.ColorKey0]), Theme.Color(lutBg[Setup.ColorKey0]), font, t1 - t0 - 2 * d, 0, taCenter);
592  osd->DrawText(t1 + d, y6, lutText[Setup.ColorKey1], Theme.Color(lutFg[Setup.ColorKey1]), Theme.Color(lutBg[Setup.ColorKey1]), font, t2 - t1 - 2 * d, 0, taCenter);
593  osd->DrawText(t2 + d, y6, lutText[Setup.ColorKey2], Theme.Color(lutFg[Setup.ColorKey2]), Theme.Color(lutBg[Setup.ColorKey2]), font, t3 - t2 - 2 * d, 0, taCenter);
594  osd->DrawText(t3 + d, y6, lutText[Setup.ColorKey3], Theme.Color(lutFg[Setup.ColorKey3]), Theme.Color(lutBg[Setup.ColorKey3]), font, t4 - t3 - 2 * d, 0, taCenter);
595 }
596 
598 {
599  const cFont *font = cFont::GetFont(fontSml);
600  if (Text) {
601  osd->SaveRegion(x3, y6, x4 - 1, y7 - 1);
602  osd->DrawText(x3, y6, Text, Theme.Color(clrMessageStatusFg + 2 * Type), Theme.Color(clrMessageStatusBg + 2 * Type), font, x4 - x3, 0, taCenter);
603  message = true;
604  }
605  else {
606  osd->RestoreRegion();
607  message = false;
608  }
609 }
610 
611 void cSkinSTTNGDisplayMenu::SetItem(const char *Text, int Index, bool Current, bool Selectable)
612 {
613  int y = y3 + Roundness + Index * lineHeight;
614  tColor ColorFg, ColorBg;
615  if (Current) {
616  ColorFg = Theme.Color(clrMenuItemCurrentFg);
617  ColorBg = Theme.Color(clrMenuItemCurrentBg);
618  osd->DrawEllipse (x1, y - Roundness, x2 - 1, y - 1, frameColor, -3);
619  osd->DrawRectangle(x1, y, x2 - 1, y + lineHeight - 1, frameColor);
620  osd->DrawEllipse (x1, y + lineHeight, x2 - 1, y + lineHeight + Roundness - 1, frameColor, -2);
621  osd->DrawRectangle(x3, y, x4 - 1, y + lineHeight - 1, ColorBg);
622  currentIndex = Index;
623  }
624  else {
625  ColorFg = Theme.Color(Selectable ? clrMenuItemSelectable : clrMenuItemNonSelectable);
626  ColorBg = Theme.Color(clrBackground);
627  if (currentIndex == Index) {
628  osd->DrawRectangle(x1, y - Roundness, x2 - 1, y + lineHeight + Roundness - 1, Theme.Color(clrBackground));
629  osd->DrawRectangle(x3, y, x4 - 1, y + lineHeight - 1, Theme.Color(clrBackground));
630  }
631  }
632  const cFont *font = cFont::GetFont(fontOsd);
633  for (int i = 0; i < MaxTabs; i++) {
634  const char *s = GetTabbedText(Text, i);
635  if (s) {
636  int xt = x3 + TextSpacing + Tab(i);
637  osd->DrawText(xt, y, s, ColorFg, ColorBg, font, x4 - xt);
638  }
639  if (!Tab(i + 1))
640  break;
641  }
643 }
644 
645 void cSkinSTTNGDisplayMenu::SetScrollbar(int Total, int Offset)
646 {
647  DrawScrollbar(Total, Offset, MaxItems(), y3 + Roundness, MaxItems() * lineHeight, Offset > 0, Offset + MaxItems() < Total);
648 }
649 
651 {
652  if (!Event)
653  return;
654  const cFont *font = cFont::GetFont(fontOsd);
655  int xl = x3 + TextSpacing;
656  int y = y3;
657  cTextScroller ts;
658  char t[32];
659  snprintf(t, sizeof(t), "%s %s - %s", *Event->GetDateString(), *Event->GetTimeString(), *Event->GetEndTimeString());
660  ts.Set(osd, xl, y, x4 - xl, y4 - y, t, font, Theme.Color(clrMenuEventTime), Theme.Color(clrBackground));
661  if (Event->Vps() && Event->Vps() != Event->StartTime()) {
662  cString buffer = cString::sprintf(" VPS: %s ", *Event->GetVpsString());
663  const cFont *font = cFont::GetFont(fontSml);
664  int w = font->Width(buffer);
665  osd->DrawText(x4 - w, y, buffer, Theme.Color(clrMenuEventVps), frameColor, font, w);
666  int yb = y + font->Height();
667  osd->DrawRectangle(x5, y, x6 - 1, yb - 1, frameColor);
668  osd->DrawEllipse (x6, y, x7 - 1, yb - 1, frameColor, 5);
669  }
670  y += ts.Height();
671  if (Event->ParentalRating()) {
672  cString buffer = cString::sprintf(" %s ", *Event->GetParentalRatingString());
673  const cFont *font = cFont::GetFont(fontSml);
674  int w = font->Width(buffer);
675  osd->DrawText(x4 - w, y, buffer, Theme.Color(clrMenuEventVps), frameColor, font, w);
676  int yb = y + font->Height();
677  osd->DrawRectangle(x5, y, x6 - 1, yb - 1, frameColor);
678  osd->DrawEllipse (x6, y, x7 - 1, yb - 1, frameColor, 5);
679  }
680  y += font->Height();
681  ts.Set(osd, xl, y, x4 - xl, y4 - y, Event->Title(), font, Theme.Color(clrMenuEventTitle), Theme.Color(clrBackground));
682  y += ts.Height();
683  if (!isempty(Event->ShortText())) {
684  const cFont *font = cFont::GetFont(fontSml);
685  ts.Set(osd, xl, y, x4 - xl, y4 - y, Event->ShortText(), font, Theme.Color(clrMenuEventShortText), Theme.Color(clrBackground));
686  y += ts.Height();
687  }
688  y += font->Height();
689  if (!isempty(Event->Description())) {
690  int yt = y;
691  int yb = y4 - Roundness;
692  textScroller.Set(osd, xl, yt, x4 - xl, yb - yt, Event->Description(), font, Theme.Color(clrMenuEventDescription), Theme.Color(clrBackground));
693  yb = yt + textScroller.Height();
694  osd->DrawEllipse (x1, yt - Roundness, x2, yt, frameColor, -3);
695  osd->DrawRectangle(x1, yt, x2, yb, frameColor);
696  osd->DrawEllipse (x1, yb, x2, yb + Roundness, frameColor, -2);
698  }
699 }
700 
702 {
703  if (!Recording)
704  return;
705  const cRecordingInfo *Info = Recording->Info();
706  const cFont *font = cFont::GetFont(fontOsd);
707  int xl = x3 + TextSpacing;
708  int y = y3;
709  cTextScroller ts;
710  char t[32];
711  snprintf(t, sizeof(t), "%s %s", *DateString(Recording->Start()), *TimeString(Recording->Start()));
712  ts.Set(osd, xl, y, x4 - xl, y4 - y, t, font, Theme.Color(clrMenuEventTime), Theme.Color(clrBackground));
713  y += ts.Height();
714  if (Info->GetEvent()->ParentalRating()) {
715  cString buffer = cString::sprintf(" %s ", *Info->GetEvent()->GetParentalRatingString());
716  const cFont *font = cFont::GetFont(fontSml);
717  int w = font->Width(buffer);
718  osd->DrawText(x4 - w, y, buffer, Theme.Color(clrMenuEventVps), frameColor, font, w);
719  int yb = y + font->Height();
720  osd->DrawRectangle(x5, y, x6 - 1, yb - 1, frameColor);
721  osd->DrawEllipse (x6, y, x7 - 1, yb - 1, frameColor, 5);
722  }
723  y += font->Height();
724  const char *Title = Info->Title();
725  if (isempty(Title))
726  Title = Recording->Name();
727  ts.Set(osd, xl, y, x4 - xl, y4 - y, Title, font, Theme.Color(clrMenuEventTitle), Theme.Color(clrBackground));
728  y += ts.Height();
729  if (!isempty(Info->ShortText())) {
730  const cFont *font = cFont::GetFont(fontSml);
731  ts.Set(osd, xl, y, x4 - xl, y4 - y, Info->ShortText(), font, Theme.Color(clrMenuEventShortText), Theme.Color(clrBackground));
732  y += ts.Height();
733  }
734  y += font->Height();
735  if (!isempty(Info->Description())) {
736  int yt = y;
737  int yb = y4 - Roundness;
738  textScroller.Set(osd, xl, yt, x4 - xl, yb - yt, Info->Description(), font, Theme.Color(clrMenuEventDescription), Theme.Color(clrBackground));
739  yb = yt + textScroller.Height();
740  osd->DrawEllipse (x1, yt - Roundness, x2, yt, frameColor, -3);
741  osd->DrawRectangle(x1, yt, x2, yb, frameColor);
742  osd->DrawEllipse (x1, yb, x2, yb + Roundness, frameColor, -2);
744  }
745 }
746 
747 void cSkinSTTNGDisplayMenu::SetText(const char *Text, bool FixedFont)
748 {
749  textScroller.Set(osd, x3, y3, GetTextAreaWidth(), y4 - y3, Text, GetTextAreaFont(FixedFont), Theme.Color(clrMenuText), Theme.Color(clrBackground));
751 }
752 
754 {
755  return x4 - x3;
756 }
757 
758 const cFont *cSkinSTTNGDisplayMenu::GetTextAreaFont(bool FixedFont) const
759 {
760  const cFont *font = cFont::GetFont(FixedFont ? fontFix : fontOsd);
761  //XXX -> make a way to let the text define which font to use
762  return font;
763 }
764 
766 {
768  DrawTitle();
769  if (!message) {
770  cString date = DayDateTime();
771  if (!*lastDate || strcmp(date, lastDate)) {
772  const cFont *font = cFont::GetFont(fontSml);
773  int w = font->Width(date);
774  osd->DrawText(x4 - w - TextFrame, y7 - font->Height(), date, Theme.Color(clrMenuDate), frameColor, font, w);
775  lastDate = date;
776  }
777  }
778  osd->Flush();
779 }
780 
781 // --- cSkinSTTNGDisplayReplay -----------------------------------------------
782 
784 private:
786  int x0, x1, x2, x3, x4, x5, x6, x7;
787  int y0, y1, y2, y3, y4, y5, y6, y7;
790 public:
791  cSkinSTTNGDisplayReplay(bool ModeOnly);
792  virtual ~cSkinSTTNGDisplayReplay();
793  virtual void SetTitle(const char *Title);
794  virtual void SetMode(bool Play, bool Forward, int Speed);
795  virtual void SetProgress(int Current, int Total);
796  virtual void SetCurrent(const char *Current);
797  virtual void SetTotal(const char *Total);
798  virtual void SetJump(const char *Jump);
799  virtual void SetMessage(eMessageType Type, const char *Text);
800  virtual void Flush(void);
801  };
802 
804 {
805  const cFont *font = cFont::GetFont(fontSml);
806  int lineHeight = font->Height();
807  frameColor = Theme.Color(clrReplayFrame);
808  lastCurrentWidth = 0;
809  cBitmap bm(play_xpm);
810  x0 = 0;
811  x1 = max(lineHeight * 2, bm.Width());
812  x2 = x1 + Roundness;
813  x3 = x2 + Gap;
814  x7 = cOsd::OsdWidth();
815  x6 = x7 - lineHeight / 2;
816  x5 = x6 - lineHeight / 2;
817  x4 = x5 - Gap;
818  y0 = 0;
819  y1 = lineHeight;
820  y2 = y1 + Roundness;
821  y3 = y2 + Gap;
822  y4 = y3 + max(lineHeight, bm.Height());
823  y5 = y4 + Gap;
824  y6 = y5 + Roundness;
825  y7 = y6 + font->Height();
826  int yt = (y0 + y1) / 2;
827  int yb = (y6 + y7) / 2;
829  tArea Areas[] = { { 0, 0, x7 - 1, y7 - 1, 32 } }; // TrueColor
830  if (osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
831  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
832  else {
833  tArea Areas[] = { { 0, 0, x7 - 1, y7 - 1, 8 } }; // 256 colors
834  if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
835  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
836  else {
837  tArea Areas[] = { { 0, 0, x7 - 1, y7 - 1, 4 } }; // 16 colors
838  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
839  }
840  }
841  osd->DrawRectangle(x0, y0, x7 - 1, y7 - 1, ModeOnly ? clrTransparent : Theme.Color(clrBackground));
842  if (!ModeOnly) {
843  osd->DrawRectangle(x0, y0, x1 - 1, y1 - 1, clrTransparent);
844  osd->DrawRectangle(x0, y6, x1 - 1, y7 - 1, clrTransparent);
845  osd->DrawRectangle(x6, y0, x7 - 1, yt - 1, clrTransparent);
846  osd->DrawRectangle(x6, yb, x7 - 1, y7 - 1, clrTransparent);
847  osd->DrawEllipse (x0, y0, x1 - 1, y1 - 1, frameColor, 2);
848  osd->DrawRectangle(x1, y0, x4 - 1, y1 - 1, frameColor);
849  osd->DrawRectangle(x5, y0, x6 - 1, y1 - 1, frameColor);
850  osd->DrawEllipse (x6, y0, x7 - 1, y1 - 1, frameColor, 5);
851  osd->DrawRectangle(x0, y1, x1 - 1, y2 - 1, frameColor);
852  osd->DrawEllipse (x1, y1, x2 - 1, y2 - 1, frameColor, -2);
853  }
854  osd->DrawRectangle(x0, y3, x1 - 1, y4 - 1, frameColor);
855  if (!ModeOnly) {
856  osd->DrawRectangle(x0, y5, x1 - 1, y6 - 1, frameColor);
857  osd->DrawEllipse (x1, y5, x2 - 1, y6 - 1, frameColor, -3);
858  osd->DrawEllipse (x0, y6, x1 - 1, y7 - 1, frameColor, 3);
859  osd->DrawRectangle(x1, y6, x4 - 1, y7 - 1, frameColor);
860  osd->DrawRectangle(x5, y6, x6 - 1, y7 - 1, frameColor);
861  osd->DrawEllipse (x6, y6, x7 - 1, y7 - 1, frameColor, 5);
862  }
863 }
864 
866 {
867  delete osd;
868 }
869 
870 void cSkinSTTNGDisplayReplay::SetTitle(const char *Title)
871 {
872  osd->DrawText(x3 + TextSpacing, y0, Title, Theme.Color(clrReplayTitle), frameColor, cFont::GetFont(fontSml), x4 - x3 - TextSpacing);
873 }
874 
875 static const char *const *ReplaySymbols[2][2][5] = {
876  { { pause_xpm, srew_xpm, srew1_xpm, srew2_xpm, srew3_xpm },
877  { pause_xpm, sfwd_xpm, sfwd1_xpm, sfwd2_xpm, sfwd3_xpm }, },
878  { { play_xpm, frew_xpm, frew1_xpm, frew2_xpm, frew3_xpm },
879  { play_xpm, ffwd_xpm, ffwd1_xpm, ffwd2_xpm, ffwd3_xpm } }
880  };
881 
882 void cSkinSTTNGDisplayReplay::SetMode(bool Play, bool Forward, int Speed)
883 {
884  Speed = constrain(Speed, -1, 3);
885  cBitmap bm(ReplaySymbols[Play][Forward][Speed + 1]);
886  osd->DrawBitmap(x0 + (x1 - x0 - bm.Width()) / 2, y3 + (y4 - y3 - bm.Height()) / 2, bm, Theme.Color(clrReplayMode), frameColor);
887 }
888 
889 void cSkinSTTNGDisplayReplay::SetProgress(int Current, int Total)
890 {
891  cProgressBar pb(x4 - x3, y4 - y3, Current, Total, marks, Theme.Color(clrReplayProgressSeen), Theme.Color(clrReplayProgressRest), Theme.Color(clrReplayProgressSelected), Theme.Color(clrReplayProgressMark), Theme.Color(clrReplayProgressCurrent));
892  osd->DrawBitmap(x3, y3, pb);
893 }
894 
895 void cSkinSTTNGDisplayReplay::SetCurrent(const char *Current)
896 {
897  const cFont *font = cFont::GetFont(fontSml);
898  int w = font->Width(Current);
899  osd->DrawText(x3, y6, Current, Theme.Color(clrReplayCurrent), frameColor, font, lastCurrentWidth > w ? lastCurrentWidth : w);
900  lastCurrentWidth = w;
901 }
902 
903 void cSkinSTTNGDisplayReplay::SetTotal(const char *Total)
904 {
905  const cFont *font = cFont::GetFont(fontSml);
906  int w = font->Width(Total);
907  osd->DrawText(x4 - w - TextSpacing, y6, Total, Theme.Color(clrReplayTotal), frameColor, font, w);
908 }
909 
910 void cSkinSTTNGDisplayReplay::SetJump(const char *Jump)
911 {
912  osd->DrawText(x0 + (x4 - x0) / 4, y6, Jump, Theme.Color(clrReplayJump), frameColor, cFont::GetFont(fontSml), (x4 - x3) / 2, 0, taCenter);
913 }
914 
916 {
917  const cFont *font = cFont::GetFont(fontSml);
918  if (Text) {
919  osd->SaveRegion(x2, y6, x4 - 1, y7 - 1);
920  osd->DrawRectangle(x2, y6, x3 - 1, y7 - 1, Theme.Color(clrBackground));
921  osd->DrawText(x3, y6, Text, Theme.Color(clrMessageStatusFg + 2 * Type), Theme.Color(clrMessageStatusBg + 2 * Type), font, x4 - x3, 0, taCenter);
922  }
923  else
924  osd->RestoreRegion();
925 }
926 
928 {
929  osd->Flush();
930 }
931 
932 // --- cSkinSTTNGDisplayVolume -----------------------------------------------
933 
935 private:
937  int x0, x1, x2, x3, x4, x5, x6, x7;
938  int y0, y1;
940  int mute;
941 public:
943  virtual ~cSkinSTTNGDisplayVolume();
944  virtual void SetVolume(int Current, int Total, bool Mute);
945  virtual void Flush(void);
946  };
947 
949 {
950  const cFont *font = cFont::GetFont(fontOsd);
951  int lineHeight = font->Height();
952  frameColor = Theme.Color(clrVolumeFrame);
953  mute = -1;
954  x0 = 0;
955  x1 = lineHeight / 2;
956  x2 = lineHeight;
957  x3 = x2 + Gap;
958  x7 = cOsd::OsdWidth();
959  x6 = x7 - lineHeight / 2;
960  x5 = x6 - lineHeight / 2;
961  x4 = x5 - Gap;
962  y0 = 0;
963  y1 = lineHeight;
965  tArea Areas[] = { { x0, y0, x7 - 1, y1 - 1, 32 } }; // TrueColor
966  if (osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
967  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
968  else {
969  tArea Areas[] = { { x0, y0, x7 - 1, y1 - 1, 8 } }; // 256 colors
970  if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
971  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
972  else {
973  tArea Areas[] = { { x0, y0, x7 - 1, y1 - 1, 4 } }; // 16 colors
974  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
975  }
976  }
977  osd->DrawRectangle(x0, y0, x7 - 1, y1 - 1, clrTransparent);
978  osd->DrawEllipse (x0, y0, x1 - 1, y1 - 1, frameColor, 7);
979  osd->DrawRectangle(x1, y0, x2 - 1, y1 - 1, frameColor);
980  osd->DrawRectangle(x3, y0, x4 - 1, y1 - 1, frameColor);
981  osd->DrawRectangle(x5, y0, x6 - 1, y1 - 1, frameColor);
982  osd->DrawEllipse (x6, y0, x7 - 1, y1 - 1, frameColor, 5);
983 }
984 
986 {
987  delete osd;
988 }
989 
990 void cSkinSTTNGDisplayVolume::SetVolume(int Current, int Total, bool Mute)
991 {
992  int xl = x3 + TextSpacing;
993  int xr = x4 - TextSpacing;
994  int yt = y0 + TextFrame;
995  int yb = y1 - TextFrame;
996  if (mute != Mute) {
997  osd->DrawRectangle(x3, y0, x4 - 1, y1 - 1, frameColor);
998  mute = Mute;
999  }
1000  cBitmap bm(Mute ? mute_xpm : volume_xpm);
1001  osd->DrawBitmap(xl, y0 + (y1 - y0 - bm.Height()) / 2, bm, Theme.Color(clrVolumeSymbol), frameColor);
1002  if (!Mute) {
1003  xl += bm.Width() + TextSpacing;
1004  int w = (y1 - y0) / 3;
1005  int d = TextFrame;
1006  int n = (xr - xl + d) / (w + d);
1007  int x = xr - n * (w + d);
1008  tColor Color = Theme.Color(clrVolumeBarLower);
1009  for (int i = 0; i < n; i++) {
1010  if (Total * i >= Current * n)
1011  Color = Theme.Color(clrVolumeBarUpper);
1012  osd->DrawRectangle(x, yt, x + w - 1, yb - 1, Color);
1013  x += w + d;
1014  }
1015  }
1016 }
1017 
1019 {
1020  osd->Flush();
1021 }
1022 
1023 // --- cSkinSTTNGDisplayTracks -----------------------------------------------
1024 
1026 private:
1028  int x0, x1, x2, x3, x4, x5, x6, x7;
1029  int y0, y1, y2, y3, y4, y5, y6, y7;
1034  void SetItem(const char *Text, int Index, bool Current);
1035 public:
1036  cSkinSTTNGDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks);
1037  virtual ~cSkinSTTNGDisplayTracks();
1038  virtual void SetTrack(int Index, const char * const *Tracks);
1039  virtual void SetAudioChannel(int AudioChannel);
1040  virtual void Flush(void);
1041  };
1042 
1046 
1047 cSkinSTTNGDisplayTracks::cSkinSTTNGDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks)
1048 {
1049  const cFont *font = cFont::GetFont(fontOsd);
1050  lineHeight = font->Height();
1051  frameColor = Theme.Color(clrMenuFrame);
1052  currentIndex = -1;
1053  int ItemsWidth = font->Width(Title);
1054  for (int i = 0; i < NumTracks; i++)
1055  ItemsWidth = max(ItemsWidth, font->Width(Tracks[i]));
1056  ItemsWidth += 2 * TextSpacing;
1057  x0 = 0;
1058  x1 = lineHeight / 2;
1059  x3 = (x1 + Roundness + Gap + 7) & ~0x07; // must be multiple of 8
1060  x2 = x3 - Gap;
1061  x7 = cOsd::OsdWidth();
1062  x6 = x7 - lineHeight / 2;
1063  x4 = (x6 - lineHeight / 2 - Gap) & ~0x07; // must be multiple of 8
1064  x5 = x4 + Gap;
1065  int d = x4 - x3;
1066  if (d > ItemsWidth) {
1067  d = (d - ItemsWidth) & ~0x07; // must be multiple of 8
1068  x4 -= d;
1069  x5 -= d;
1070  x6 -= d;
1071  x7 -= d;
1072  }
1073  y0 = 0;
1074  y1 = lineHeight;
1075  y2 = y1 + Roundness;
1076  y3 = y2 + Gap;
1077  // limit to cOsd::OsdHeight()? - what if height is too big???
1078  y4 = y3 + NumTracks * lineHeight + 2 * Roundness;
1079  y5 = y4 + Gap;
1080  y6 = y5 + Roundness;
1081  y7 = y6 + cFont::GetFont(fontSml)->Height();
1082  int yt = (y0 + y1) / 2;
1083  int yb = (y6 + y7) / 2;
1085  tArea Areas[] = { { x0, y0, x7 - 1, y7 - 1, 32 } }; // TrueColor
1086  if (osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
1087  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
1088  else {
1089  tArea Areas[] = { { x0, y0, x7 - 1, y7 - 1, 8 } }; // 256 colors
1090  if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
1091  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
1092  else {
1093  tArea Areas[] = { { x0, y0, x7 - 1, y7 - 1, 4 } }; // 16 colors
1094  if (osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
1095  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
1096  else {
1097  tArea Areas[] = { { x0, y0, x7 - 1, y3 - 1, 2 }, // 2..16 colors
1098  { x0, y3, x3 - 1, y4 - 1, 1 },
1099  { x3, y3, x4 - 1, y4 - 1, 2 },
1100  { x4, y3, x7 - 1, y4 - 1, 2 },
1101  { x0, y4, x7 - 1, y7 - 1, 4 }
1102  };
1103  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
1104  }
1105  }
1106  }
1107  osd->DrawRectangle(x0, y0, x7 - 1, y7 - 1, Theme.Color(clrBackground));
1108  osd->DrawRectangle(x0, y0, x1 - 1, y1 - 1, clrTransparent);
1109  osd->DrawRectangle(x0, y6, x1 - 1, y7 - 1, clrTransparent);
1110  osd->DrawRectangle(x6, y0, x7 - 1, yt - 1, clrTransparent);
1111  osd->DrawRectangle(x6, yb, x7 - 1, y7 - 1, clrTransparent);
1112  osd->DrawEllipse (x0, y0, x1 - 1, y1 - 1, frameColor, 2);
1113  osd->DrawRectangle(x1, y0, x2 - 1, y1 - 1, frameColor);
1114  osd->DrawRectangle(x3, y0, x4 - 1, y1 - 1, frameColor);
1115  osd->DrawRectangle(x5, y0, x6 - 1, y1 - 1, frameColor);
1116  osd->DrawEllipse (x6, y0, x7 - 1, y1 - 1, frameColor, 5);
1117  osd->DrawRectangle(x0, y1, x1 - 1, y6 - 1, frameColor);
1118  osd->DrawEllipse (x1, y1, x2 - 1, y2 - 1, frameColor, -2);
1119  osd->DrawEllipse (x1, y5, x2 - 1, y6 - 1, frameColor, -3);
1120  osd->DrawEllipse (x0, y6, x1 - 1, y7 - 1, frameColor, 3);
1121  osd->DrawRectangle(x1, y6, x2 - 1, y7 - 1, frameColor);
1122  osd->DrawRectangle(x3, y6, x4 - 1, y7 - 1, frameColor);
1123  osd->DrawRectangle(x5, y6, x6 - 1, y7 - 1, frameColor);
1124  osd->DrawEllipse (x6, y6, x7 - 1, y7 - 1, frameColor, 5);
1125  osd->DrawText(x3 + TextSpacing, y0, Title, Theme.Color(clrMenuTitle), frameColor, font, x4 - x3 - TextSpacing);
1126  for (int i = 0; i < NumTracks; i++)
1127  SetItem(Tracks[i], i, false);
1128 }
1129 
1131 {
1132  delete osd;
1133 }
1134 
1135 void cSkinSTTNGDisplayTracks::SetItem(const char *Text, int Index, bool Current)
1136 {
1137  int y = y3 + Roundness + Index * lineHeight;
1138  tColor ColorFg, ColorBg;
1139  if (Current) {
1140  ColorFg = Theme.Color(clrMenuItemCurrentFg);
1141  ColorBg = Theme.Color(clrMenuItemCurrentBg);
1142  osd->DrawEllipse (x1, y - Roundness, x2 - 1, y - 1, frameColor, -3);
1143  osd->DrawRectangle(x1, y, x2 - 1, y + lineHeight - 1, frameColor);
1144  osd->DrawEllipse (x1, y + lineHeight, x2 - 1, y + lineHeight + Roundness - 1, frameColor, -2);
1145  osd->DrawRectangle(x3, y, x4 - 1, y + lineHeight - 1, ColorBg);
1146  currentIndex = Index;
1147  }
1148  else {
1149  ColorFg = Theme.Color(clrMenuItemSelectable);
1150  ColorBg = Theme.Color(clrBackground);
1151  if (currentIndex == Index) {
1152  osd->DrawRectangle(x1, y - Roundness, x2 - 1, y + lineHeight + Roundness - 1, Theme.Color(clrBackground));
1153  osd->DrawRectangle(x3, y, x4 - 1, y + lineHeight - 1, Theme.Color(clrBackground));
1154  }
1155  }
1156  const cFont *font = cFont::GetFont(fontOsd);
1157  int xt = x3 + TextSpacing;
1158  osd->DrawText(xt, y, Text, ColorFg, ColorBg, font, x4 - xt);
1159 }
1160 
1161 void cSkinSTTNGDisplayTracks::SetTrack(int Index, const char * const *Tracks)
1162 {
1163  if (currentIndex >= 0)
1164  SetItem(Tracks[currentIndex], currentIndex, false);
1165  SetItem(Tracks[Index], Index, true);
1166 }
1167 
1169 {
1170  cBitmap *bm = NULL;
1171  switch (AudioChannel) {
1172  case 0: bm = &bmAudioStereo; break;
1173  case 1: bm = &bmAudioLeft; break;
1174  case 2: bm = &bmAudioRight; break;
1175  default: ;
1176  }
1177  if (bm)
1178  osd->DrawBitmap(x3 + TextSpacing, y6 + (y7 - y6 - bm->Height()) / 2, *bm, Theme.Color(clrChannelSymbolOn), frameColor);
1179  else
1180  osd->DrawRectangle(x3, y6, x4 - 1, y7 - 1, frameColor);
1181 }
1182 
1184 {
1185  osd->Flush();
1186 }
1187 
1188 // --- cSkinSTTNGDisplayMessage ----------------------------------------------
1189 
1191 private:
1193  int x0, x1, x2, x3, x4, x5, x6, x7;
1194  int y0, y1;
1195 public:
1197  virtual ~cSkinSTTNGDisplayMessage();
1198  virtual void SetMessage(eMessageType Type, const char *Text);
1199  virtual void Flush(void);
1200  };
1201 
1203 {
1204  const cFont *font = cFont::GetFont(fontOsd);
1205  int lineHeight = font->Height();
1206  tColor frameColor = Theme.Color(clrMessageFrame);
1207  x0 = 0;
1208  x1 = lineHeight / 2;
1209  x2 = lineHeight;
1210  x3 = x2 + Gap;
1211  x7 = cOsd::OsdWidth();
1212  x6 = x7 - lineHeight / 2;
1213  x5 = x6 - lineHeight / 2;
1214  x4 = x5 - Gap;
1215  y0 = 0;
1216  y1 = lineHeight;
1218  tArea Areas[] = { { x0, y0, x7 - 1, y1 - 1, 32 } }; // TrueColor
1219  if (osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
1220  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
1221  else {
1222  tArea Areas[] = { { x0, y0, x7 - 1, y1 - 1, 8 } }; // 256 colors
1223  if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
1224  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
1225  else {
1226  tArea Areas[] = { { x0, y0, x7 - 1, y1 - 1, 2 } }; // 4 colors
1227  osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
1228  }
1229  }
1230  osd->DrawRectangle(x0, y0, x7 - 1, y1 - 1, clrTransparent);
1231  osd->DrawEllipse (x0, y0, x1 - 1, y1 - 1, frameColor, 7);
1232  osd->DrawRectangle(x1, y0, x2 - 1, y1 - 1, frameColor);
1233  osd->DrawRectangle(x5, y0, x6 - 1, y1 - 1, frameColor);
1234  osd->DrawEllipse (x6, y0, x7 - 1, y1 - 1, frameColor, 5);
1235 }
1236 
1238 {
1239  delete osd;
1240 }
1241 
1243 {
1244  const cFont *font = cFont::GetFont(fontOsd);
1245  osd->DrawText(x3, y0, Text, Theme.Color(clrMessageStatusFg + 2 * Type), Theme.Color(clrMessageStatusBg + 2 * Type), font, x4 - x3, 0, taCenter);
1246 }
1247 
1249 {
1250  osd->Flush();
1251 }
1252 
1253 // --- cSkinSTTNG ------------------------------------------------------------
1254 
1256 :cSkin("sttng", &::Theme)//XXX naming problem???
1257 {
1258 }
1259 
1260 const char *cSkinSTTNG::Description(void)
1261 {
1262  return tr("ST:TNG Panels");
1263 }
1264 
1266 {
1267  return new cSkinSTTNGDisplayChannel(WithInfo);
1268 }
1269 
1271 {
1272  return new cSkinSTTNGDisplayMenu;
1273 }
1274 
1276 {
1277  return new cSkinSTTNGDisplayReplay(ModeOnly);
1278 }
1279 
1281 {
1282  return new cSkinSTTNGDisplayVolume;
1283 }
1284 
1285 cSkinDisplayTracks *cSkinSTTNG::DisplayTracks(const char *Title, int NumTracks, const char * const *Tracks)
1286 {
1287  return new cSkinSTTNGDisplayTracks(Title, NumTracks, Tracks);
1288 }
1289 
1291 {
1292  return new cSkinSTTNGDisplayMessage;
1293 }