summaryrefslogtreecommitdiff
path: root/osd.c
diff options
context:
space:
mode:
Diffstat (limited to 'osd.c')
-rw-r--r--osd.c243
1 files changed, 240 insertions, 3 deletions
diff --git a/osd.c b/osd.c
index 6feeaa8..1092187 100644
--- a/osd.c
+++ b/osd.c
@@ -4,12 +4,243 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: osd.c 1.25 2002/05/12 11:38:39 kls Exp $
+ * $Id: osd.c 1.29 2002/06/16 13:24:00 kls Exp $
*/
#include "osd.h"
#include <string.h>
+#include "device.h"
#include "i18n.h"
+#include "status.h"
+
+// --- cOsd ------------------------------------------------------------------
+
+#ifdef DEBUG_OSD
+ WINDOW *cOsd::window = NULL;
+ int cOsd::colorPairs[MaxColorPairs] = { 0 };
+#else
+ cDvbOsd *cOsd::osd = NULL;
+#endif
+ int cOsd::cols = 0;
+ int cOsd::rows = 0;
+
+void cOsd::Initialize(void)
+{
+#if defined(DEBUG_OSD) || defined(REMOTE_KBD)
+ initscr();
+ keypad(stdscr, true);
+ nonl();
+ cbreak();
+ noecho();
+ timeout(10);
+#endif
+#if defined(DEBUG_OSD)
+ start_color();
+ leaveok(stdscr, true);
+#endif
+}
+
+void cOsd::Shutdown(void)
+{
+ Close();
+#if defined(DEBUG_OSD) || defined(REMOTE_KBD)
+ endwin();
+#endif
+}
+
+#ifdef DEBUG_OSD
+void cOsd::SetColor(eDvbColor colorFg, eDvbColor colorBg)
+{
+ int color = (colorBg << 16) | colorFg | 0x80000000;
+ for (int i = 0; i < MaxColorPairs; i++) {
+ if (!colorPairs[i]) {
+ colorPairs[i] = color;
+ init_pair(i + 1, colorFg, colorBg);
+ wattrset(window, COLOR_PAIR(i + 1));
+ break;
+ }
+ else if (color == colorPairs[i]) {
+ wattrset(window, COLOR_PAIR(i + 1));
+ break;
+ }
+ }
+}
+#endif
+
+void cOsd::Open(int w, int h)
+{
+ int d = (h < 0) ? Setup.OSDheight + h : 0;
+ h = abs(h);
+ cols = w;
+ rows = h;
+#ifdef DEBUG_OSD
+ window = subwin(stdscr, h, w, d, (Setup.OSDwidth - w) / 2);
+ syncok(window, true);
+ #define B2C(b) (((b) * 1000) / 255)
+ #define SETCOLOR(n, r, g, b, o) init_color(n, B2C(r), B2C(g), B2C(b))
+ //XXX
+ SETCOLOR(clrBackground, 0x00, 0x00, 0x00, 127); // background 50% gray
+ SETCOLOR(clrBlack, 0x00, 0x00, 0x00, 255);
+ SETCOLOR(clrRed, 0xFC, 0x14, 0x14, 255);
+ SETCOLOR(clrGreen, 0x24, 0xFC, 0x24, 255);
+ SETCOLOR(clrYellow, 0xFC, 0xC0, 0x24, 255);
+ SETCOLOR(clrBlue, 0x00, 0x00, 0xFC, 255);
+ SETCOLOR(clrCyan, 0x00, 0xFC, 0xFC, 255);
+ SETCOLOR(clrMagenta, 0xB0, 0x00, 0xFC, 255);
+ SETCOLOR(clrWhite, 0xFC, 0xFC, 0xFC, 255);
+#else
+ w *= charWidth;
+ h *= lineHeight;
+ d *= lineHeight;
+ int x = (720 - w + charWidth) / 2; //TODO PAL vs. NTSC???
+ int y = (576 - Setup.OSDheight * lineHeight) / 2 + d;
+ //XXX
+ osd = new cDvbOsd(cDevice::PrimaryDevice()->OsdDeviceHandle(), x, y);
+ //XXX TODO this should be transferred to the places where the individual windows are requested (there's too much detailed knowledge here!)
+ if (h / lineHeight == 5) { //XXX channel display
+ osd->Create(0, 0, w, h, 4);
+ }
+ else if (h / lineHeight == 1) { //XXX info display
+ osd->Create(0, 0, w, h, 4);
+ }
+ else if (d == 0) { //XXX full menu
+ osd->Create(0, 0, w, lineHeight, 2);
+ osd->Create(0, lineHeight, w, (Setup.OSDheight - 3) * lineHeight, 2);
+ osd->AddColor(clrBackground);
+ osd->AddColor(clrCyan);
+ osd->AddColor(clrWhite);
+ osd->AddColor(clrBlack);
+ osd->Create(0, (Setup.OSDheight - 2) * lineHeight, w, 2 * lineHeight, 4);
+ }
+ else { //XXX progress display
+ /*XXX
+ osd->Create(0, 0, w, lineHeight, 1);
+ osd->Create(0, lineHeight, w, lineHeight, 2, false);
+ osd->Create(0, 2 * lineHeight, w, lineHeight, 1);
+ XXX*///XXX some pixels are not drawn correctly with lower bpp values
+ osd->Create(0, 0, w, 3*lineHeight, 4);
+ }
+#endif
+}
+
+void cOsd::Close(void)
+{
+#ifdef DEBUG_OSD
+ if (window) {
+ delwin(window);
+ window = 0;
+ }
+#else
+ delete osd;
+ osd = NULL;
+#endif
+}
+
+void cOsd::Clear(void)
+{
+#ifdef DEBUG_OSD
+ SetColor(clrBackground, clrBackground);
+ Fill(0, 0, cols, rows, clrBackground);
+#else
+ osd->Clear();
+#endif
+}
+
+void cOsd::Fill(int x, int y, int w, int h, eDvbColor color)
+{
+ if (x < 0) x = cols + x;
+ if (y < 0) y = rows + y;
+#ifdef DEBUG_OSD
+ SetColor(color, color);
+ for (int r = 0; r < h; r++) {
+ wmove(window, y + r, x); // ncurses wants 'y' before 'x'!
+ whline(window, ' ', w);
+ }
+ wsyncup(window); // shouldn't be necessary because of 'syncok()', but w/o it doesn't work
+#else
+ osd->Fill(x * charWidth, y * lineHeight, (x + w) * charWidth - 1, (y + h) * lineHeight - 1, color);
+#endif
+}
+
+void cOsd::SetBitmap(int x, int y, const cBitmap &Bitmap)
+{
+#ifndef DEBUG_OSD
+ osd->SetBitmap(x, y, Bitmap);
+#endif
+}
+
+void cOsd::ClrEol(int x, int y, eDvbColor color)
+{
+ Fill(x, y, cols - x, 1, color);
+}
+
+int cOsd::CellWidth(void)
+{
+#ifdef DEBUG_OSD
+ return 1;
+#else
+ return charWidth;
+#endif
+}
+
+int cOsd::LineHeight(void)
+{
+#ifdef DEBUG_OSD
+ return 1;
+#else
+ return lineHeight;
+#endif
+}
+
+int cOsd::Width(unsigned char c)
+{
+#ifdef DEBUG_OSD
+ return 1;
+#else
+ return osd->Width(c);
+#endif
+}
+
+int cOsd::WidthInCells(const char *s)
+{
+#ifdef DEBUG_OSD
+ return strlen(s);
+#else
+ return (osd->Width(s) + charWidth - 1) / charWidth;
+#endif
+}
+
+eDvbFont cOsd::SetFont(eDvbFont Font)
+{
+#ifdef DEBUG_OSD
+ return Font;
+#else
+ return osd->SetFont(Font);
+#endif
+}
+
+void cOsd::Text(int x, int y, const char *s, eDvbColor colorFg, eDvbColor colorBg)
+{
+ if (x < 0) x = cols + x;
+ if (y < 0) y = rows + y;
+#ifdef DEBUG_OSD
+ SetColor(colorFg, colorBg);
+ wmove(window, y, x); // ncurses wants 'y' before 'x'!
+ waddnstr(window, s, cols - x);
+#else
+ osd->Text(x * charWidth, y * lineHeight, s, colorFg, colorBg);
+#endif
+}
+
+void cOsd::Flush(void)
+{
+#ifdef DEBUG_OSD
+ refresh();
+#else
+ if (osd)
+ osd->Flush();
+#endif
+}
// --- cOsdItem --------------------------------------------------------------
@@ -200,8 +431,11 @@ void cOsdMenu::Display(void)
}
for (int i = first; i < count; i++) {
cOsdItem *item = Get(i);
- if (item)
+ if (item) {
item->Display(i - first, i == current ? clrBlack : clrWhite, i == current ? clrCyan : clrBackground);
+ if (i == current)
+ cStatus::MsgOsdCurrentItem(item->Text());
+ }
if (++n == MAXOSDITEMS) //TODO get this from Interface!!!
break;
}
@@ -225,8 +459,11 @@ void cOsdMenu::RefreshCurrent(void)
void cOsdMenu::DisplayCurrent(bool Current)
{
cOsdItem *item = Get(current);
- if (item)
+ if (item) {
item->Display(current - first, Current ? clrBlack : clrWhite, Current ? clrCyan : clrBackground);
+ if (Current)
+ cStatus::MsgOsdCurrentItem(item->Text());
+ }
}
void cOsdMenu::Clear(void)