2002-05-10 14:55:53 +02:00
|
|
|
/*
|
|
|
|
* osdbase.c: Basic interface to the On Screen Display
|
|
|
|
*
|
|
|
|
* See the main source file 'vdr.c' for copyright information and
|
|
|
|
* how to reach the author.
|
|
|
|
*
|
2010-01-17 12:08:03 +01:00
|
|
|
* $Id: osdbase.c 2.2 2010/01/17 11:36:12 kls Exp $
|
2002-05-10 14:55:53 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "osdbase.h"
|
2004-05-16 10:35:36 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include "device.h"
|
|
|
|
#include "i18n.h"
|
|
|
|
#include "remote.h"
|
|
|
|
#include "status.h"
|
2002-05-10 14:55:53 +02:00
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
// --- cOsdItem --------------------------------------------------------------
|
2002-05-10 14:55:53 +02:00
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
cOsdItem::cOsdItem(eOSState State)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
text = NULL;
|
|
|
|
state = State;
|
|
|
|
selectable = true;
|
|
|
|
fresh = true;
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2005-10-02 09:57:52 +02:00
|
|
|
cOsdItem::cOsdItem(const char *Text, eOSState State, bool Selectable)
|
2002-07-13 14:45:55 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
text = NULL;
|
|
|
|
state = State;
|
2005-10-02 09:57:52 +02:00
|
|
|
selectable = Selectable;
|
2004-05-16 10:35:36 +02:00
|
|
|
fresh = true;
|
|
|
|
SetText(Text);
|
2002-07-13 14:45:55 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
cOsdItem::~cOsdItem()
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
free(text);
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
void cOsdItem::SetText(const char *Text, bool Copy)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
free(text);
|
2010-01-17 12:08:03 +01:00
|
|
|
text = Copy ? strdup(Text ? Text : "") : (char *)Text; // text assumes ownership!
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
void cOsdItem::SetSelectable(bool Selectable)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
selectable = Selectable;
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
void cOsdItem::SetFresh(bool Fresh)
|
2002-08-25 10:05:24 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
fresh = Fresh;
|
2002-08-25 10:05:24 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
eOSState cOsdItem::ProcessKey(eKeys Key)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
return Key == kOk ? state : osUnknown;
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2006-01-05 15:35:06 +01:00
|
|
|
// --- cOsdObject ------------------------------------------------------------
|
|
|
|
|
|
|
|
void cOsdObject::Show(void)
|
|
|
|
{
|
|
|
|
if (isMenu)
|
|
|
|
((cOsdMenu *)this)->Display();
|
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
// --- cOsdMenu --------------------------------------------------------------
|
2002-05-10 14:55:53 +02:00
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
cSkinDisplayMenu *cOsdMenu::displayMenu = NULL;
|
|
|
|
int cOsdMenu::displayMenuCount = 0;
|
|
|
|
int cOsdMenu::displayMenuItems = 0;//XXX dynamic???
|
2002-05-10 14:55:53 +02:00
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
cOsdMenu::cOsdMenu(const char *Title, int c0, int c1, int c2, int c3, int c4)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
isMenu = true;
|
|
|
|
digit = 0;
|
|
|
|
hasHotkeys = false;
|
|
|
|
title = NULL;
|
|
|
|
SetTitle(Title);
|
2005-06-12 10:46:34 +02:00
|
|
|
SetCols(c0, c1, c2, c3, c4);
|
2004-05-16 10:35:36 +02:00
|
|
|
first = 0;
|
|
|
|
current = marked = -1;
|
|
|
|
subMenu = NULL;
|
|
|
|
helpRed = helpGreen = helpYellow = helpBlue = NULL;
|
|
|
|
status = NULL;
|
2007-06-10 13:02:43 +02:00
|
|
|
if (!displayMenuCount++)
|
|
|
|
SetDisplayMenu();
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
cOsdMenu::~cOsdMenu()
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
free(title);
|
|
|
|
delete subMenu;
|
|
|
|
free(status);
|
|
|
|
displayMenu->Clear();
|
|
|
|
cStatus::MsgOsdClear();
|
|
|
|
if (!--displayMenuCount)
|
|
|
|
DELETENULL(displayMenu);
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2007-06-10 13:02:43 +02:00
|
|
|
void cOsdMenu::SetDisplayMenu(void)
|
|
|
|
{
|
|
|
|
if (displayMenu) {
|
|
|
|
displayMenu->Clear();
|
|
|
|
delete displayMenu;
|
|
|
|
}
|
|
|
|
displayMenu = Skins.Current()->DisplayMenu();
|
|
|
|
displayMenuItems = displayMenu->MaxItems();
|
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
const char *cOsdMenu::hk(const char *s)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2007-06-10 13:02:43 +02:00
|
|
|
static cString buffer;
|
2004-05-16 10:35:36 +02:00
|
|
|
if (s && hasHotkeys) {
|
|
|
|
if (digit == 0 && '1' <= *s && *s <= '9' && *(s + 1) == ' ')
|
|
|
|
digit = -1; // prevents automatic hotkeys - input already has them
|
|
|
|
if (digit >= 0) {
|
|
|
|
digit++;
|
2007-06-10 13:02:43 +02:00
|
|
|
buffer = cString::sprintf(" %c %s", (digit < 10) ? '0' + digit : ' ' , s);
|
2004-05-16 10:35:36 +02:00
|
|
|
s = buffer;
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
}
|
2004-05-16 10:35:36 +02:00
|
|
|
return s;
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2005-06-12 10:46:34 +02:00
|
|
|
void cOsdMenu::SetCols(int c0, int c1, int c2, int c3, int c4)
|
|
|
|
{
|
|
|
|
cols[0] = c0;
|
|
|
|
cols[1] = c1;
|
|
|
|
cols[2] = c2;
|
|
|
|
cols[3] = c3;
|
|
|
|
cols[4] = c4;
|
|
|
|
}
|
|
|
|
|
2007-01-07 14:46:14 +01:00
|
|
|
void cOsdMenu::SetHasHotkeys(bool HasHotkeys)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2007-01-07 14:46:14 +01:00
|
|
|
hasHotkeys = HasHotkeys;
|
2004-05-16 10:35:36 +02:00
|
|
|
digit = 0;
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
void cOsdMenu::SetStatus(const char *s)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
free(status);
|
|
|
|
status = s ? strdup(s) : NULL;
|
|
|
|
displayMenu->SetMessage(mtStatus, s);
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
void cOsdMenu::SetTitle(const char *Title)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
free(title);
|
|
|
|
title = strdup(Title);
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
void cOsdMenu::SetHelp(const char *Red, const char *Green, const char *Yellow, const char *Blue)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
// strings are NOT copied - must be constants!!!
|
|
|
|
helpRed = Red;
|
|
|
|
helpGreen = Green;
|
|
|
|
helpYellow = Yellow;
|
|
|
|
helpBlue = Blue;
|
|
|
|
displayMenu->SetButtons(helpRed, helpGreen, helpYellow, helpBlue);
|
|
|
|
cStatus::MsgOsdHelpKeys(helpRed, helpGreen, helpYellow, helpBlue);
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
void cOsdMenu::Del(int Index)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
cList<cOsdItem>::Del(Get(Index));
|
2005-01-07 16:19:29 +01:00
|
|
|
int count = Count();
|
2006-01-08 11:44:37 +01:00
|
|
|
while (current < count && !SelectableItem(current))
|
2005-01-07 16:19:29 +01:00
|
|
|
current++;
|
|
|
|
if (current == count) {
|
2006-01-08 11:44:37 +01:00
|
|
|
while (current > 0 && !SelectableItem(current))
|
2005-01-07 16:19:29 +01:00
|
|
|
current--;
|
|
|
|
}
|
2004-05-16 10:35:36 +02:00
|
|
|
if (Index == first && first > 0)
|
|
|
|
first--;
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
void cOsdMenu::Add(cOsdItem *Item, bool Current, cOsdItem *After)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
cList<cOsdItem>::Add(Item, After);
|
|
|
|
if (Current)
|
|
|
|
current = Item->Index();
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
void cOsdMenu::Ins(cOsdItem *Item, bool Current, cOsdItem *Before)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
cList<cOsdItem>::Ins(Item, Before);
|
|
|
|
if (Current)
|
|
|
|
current = Item->Index();
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
void cOsdMenu::Display(void)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
if (subMenu) {
|
|
|
|
subMenu->Display();
|
|
|
|
return;
|
|
|
|
}
|
2004-07-17 13:29:13 +02:00
|
|
|
displayMenu->SetMessage(mtStatus, NULL);
|
2004-05-16 10:35:36 +02:00
|
|
|
displayMenu->Clear();
|
|
|
|
cStatus::MsgOsdClear();
|
|
|
|
displayMenu->SetTabs(cols[0], cols[1], cols[2], cols[3], cols[4]);//XXX
|
|
|
|
displayMenu->SetTitle(title);
|
|
|
|
cStatus::MsgOsdTitle(title);
|
|
|
|
displayMenu->SetButtons(helpRed, helpGreen, helpYellow, helpBlue);
|
|
|
|
cStatus::MsgOsdHelpKeys(helpRed, helpGreen, helpYellow, helpBlue);
|
|
|
|
int count = Count();
|
|
|
|
if (count > 0) {
|
|
|
|
int ni = 0;
|
2005-10-02 09:57:52 +02:00
|
|
|
for (cOsdItem *item = First(); item; item = Next(item)) {
|
2004-05-16 10:35:36 +02:00
|
|
|
cStatus::MsgOsdItem(item->Text(), ni++);
|
2005-10-02 09:57:52 +02:00
|
|
|
if (current < 0 && item->Selectable())
|
|
|
|
current = item->Index();
|
|
|
|
}
|
2004-05-16 10:35:36 +02:00
|
|
|
if (current < 0)
|
|
|
|
current = 0; // just for safety - there HAS to be a current item!
|
2009-06-01 11:57:46 +02:00
|
|
|
first = min(first, max(0, count - displayMenuItems)); // in case the menu size has changed
|
2004-05-16 10:35:36 +02:00
|
|
|
if (current - first >= displayMenuItems || current < first) {
|
|
|
|
first = current - displayMenuItems / 2;
|
|
|
|
if (first + displayMenuItems > count)
|
|
|
|
first = count - displayMenuItems;
|
|
|
|
if (first < 0)
|
|
|
|
first = 0;
|
|
|
|
}
|
|
|
|
int i = first;
|
|
|
|
int n = 0;
|
|
|
|
for (cOsdItem *item = Get(first); item; item = Next(item)) {
|
2005-10-02 15:04:34 +02:00
|
|
|
bool CurrentSelectable = (i == current) && item->Selectable();
|
|
|
|
displayMenu->SetItem(item->Text(), i - first, CurrentSelectable, item->Selectable());
|
|
|
|
if (CurrentSelectable)
|
2004-05-16 10:35:36 +02:00
|
|
|
cStatus::MsgOsdCurrentItem(item->Text());
|
|
|
|
if (++n == displayMenuItems)
|
|
|
|
break;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
2008-02-17 12:31:16 +01:00
|
|
|
displayMenu->SetScrollbar(count, first);
|
2004-05-16 10:35:36 +02:00
|
|
|
if (!isempty(status))
|
|
|
|
displayMenu->SetMessage(mtStatus, status);
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
void cOsdMenu::SetCurrent(cOsdItem *Item)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
current = Item ? Item->Index() : -1;
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
void cOsdMenu::RefreshCurrent(void)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
cOsdItem *item = Get(current);
|
|
|
|
if (item)
|
|
|
|
item->Set();
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
void cOsdMenu::DisplayCurrent(bool Current)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
cOsdItem *item = Get(current);
|
|
|
|
if (item) {
|
2005-10-09 11:00:50 +02:00
|
|
|
displayMenu->SetItem(item->Text(), current - first, Current && item->Selectable(), item->Selectable());
|
|
|
|
if (Current && item->Selectable())
|
2004-05-16 10:35:36 +02:00
|
|
|
cStatus::MsgOsdCurrentItem(item->Text());
|
|
|
|
if (!Current)
|
|
|
|
item->SetFresh(true); // leaving the current item resets 'fresh'
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-07 14:46:14 +01:00
|
|
|
void cOsdMenu::DisplayItem(cOsdItem *Item)
|
|
|
|
{
|
|
|
|
if (Item) {
|
|
|
|
int Index = Item->Index();
|
|
|
|
int Offset = Index - first;
|
|
|
|
if (Offset >= 0 && Offset < first + displayMenuItems) {
|
|
|
|
bool Current = Index == current;
|
|
|
|
displayMenu->SetItem(Item->Text(), Offset, Current && Item->Selectable(), Item->Selectable());
|
|
|
|
if (Current && Item->Selectable())
|
|
|
|
cStatus::MsgOsdCurrentItem(Item->Text());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
void cOsdMenu::Clear(void)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2006-01-05 13:43:07 +01:00
|
|
|
if (marked >= 0)
|
|
|
|
SetStatus(NULL);
|
2004-05-16 10:35:36 +02:00
|
|
|
first = 0;
|
|
|
|
current = marked = -1;
|
|
|
|
cList<cOsdItem>::Clear();
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
bool cOsdMenu::SelectableItem(int idx)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
cOsdItem *item = Get(idx);
|
|
|
|
return item && item->Selectable();
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
void cOsdMenu::CursorUp(void)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2005-06-18 10:44:30 +02:00
|
|
|
int tmpCurrent = current;
|
|
|
|
int lastOnScreen = first + displayMenuItems - 1;
|
|
|
|
int last = Count() - 1;
|
2005-10-09 10:45:48 +02:00
|
|
|
if (last < 0)
|
|
|
|
return;
|
2005-06-18 10:44:30 +02:00
|
|
|
while (--tmpCurrent != current) {
|
|
|
|
if (tmpCurrent < 0) {
|
2006-02-05 14:38:56 +01:00
|
|
|
if (first > 0) {
|
|
|
|
// make non-selectable items at the beginning visible:
|
|
|
|
first = 0;
|
|
|
|
Display();
|
|
|
|
return;
|
|
|
|
}
|
2005-06-18 10:44:30 +02:00
|
|
|
if (Setup.MenuScrollWrap)
|
2005-10-09 10:45:48 +02:00
|
|
|
tmpCurrent = last + 1;
|
2005-06-18 10:44:30 +02:00
|
|
|
else
|
|
|
|
return;
|
|
|
|
}
|
2005-10-09 10:45:48 +02:00
|
|
|
else if (SelectableItem(tmpCurrent))
|
2005-06-18 10:44:30 +02:00
|
|
|
break;
|
2004-05-16 10:35:36 +02:00
|
|
|
}
|
2005-06-18 10:44:30 +02:00
|
|
|
if (first <= tmpCurrent && tmpCurrent <= lastOnScreen)
|
|
|
|
DisplayCurrent(false);
|
|
|
|
current = tmpCurrent;
|
|
|
|
if (current < first) {
|
|
|
|
first = Setup.MenuScrollPage ? max(0, current - displayMenuItems + 1) : current;
|
|
|
|
Display();
|
|
|
|
}
|
|
|
|
else if (current > lastOnScreen) {
|
|
|
|
first = max(0, current - displayMenuItems + 1);
|
|
|
|
Display();
|
2004-05-16 10:35:36 +02:00
|
|
|
}
|
2005-06-18 10:44:30 +02:00
|
|
|
else
|
|
|
|
DisplayCurrent(true);
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
void cOsdMenu::CursorDown(void)
|
|
|
|
{
|
2005-06-18 10:44:30 +02:00
|
|
|
int tmpCurrent = current;
|
|
|
|
int lastOnScreen = first + displayMenuItems - 1;
|
2004-05-16 10:35:36 +02:00
|
|
|
int last = Count() - 1;
|
2005-10-09 10:45:48 +02:00
|
|
|
if (last < 0)
|
|
|
|
return;
|
2005-06-18 10:44:30 +02:00
|
|
|
while (++tmpCurrent != current) {
|
|
|
|
if (tmpCurrent > last) {
|
2006-02-05 14:38:56 +01:00
|
|
|
if (first < last - displayMenuItems) {
|
|
|
|
// make non-selectable items at the end visible:
|
|
|
|
first = last - displayMenuItems + 1;
|
|
|
|
Display();
|
|
|
|
return;
|
|
|
|
}
|
2005-06-18 10:44:30 +02:00
|
|
|
if (Setup.MenuScrollWrap)
|
2005-10-09 10:45:48 +02:00
|
|
|
tmpCurrent = -1;
|
2005-06-18 10:44:30 +02:00
|
|
|
else
|
|
|
|
return;
|
|
|
|
}
|
2005-10-09 10:45:48 +02:00
|
|
|
else if (SelectableItem(tmpCurrent))
|
2005-06-18 10:44:30 +02:00
|
|
|
break;
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
2005-06-18 10:44:30 +02:00
|
|
|
if (first <= tmpCurrent && tmpCurrent <= lastOnScreen)
|
|
|
|
DisplayCurrent(false);
|
|
|
|
current = tmpCurrent;
|
|
|
|
if (current > lastOnScreen) {
|
|
|
|
first = Setup.MenuScrollPage ? current : max(0, current - displayMenuItems + 1);
|
|
|
|
if (first + displayMenuItems > last)
|
|
|
|
first = max(0, last - displayMenuItems + 1);
|
|
|
|
Display();
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
2005-06-18 10:44:30 +02:00
|
|
|
else if (current < first) {
|
|
|
|
first = current;
|
|
|
|
Display();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DisplayCurrent(true);
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
void cOsdMenu::PageUp(void)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2005-06-12 10:02:59 +02:00
|
|
|
int oldCurrent = current;
|
|
|
|
int oldFirst = first;
|
2004-05-16 10:35:36 +02:00
|
|
|
current -= displayMenuItems;
|
|
|
|
first -= displayMenuItems;
|
2005-06-12 10:02:59 +02:00
|
|
|
int last = Count() - 1;
|
|
|
|
if (current < 0)
|
|
|
|
current = 0;
|
2004-05-16 10:35:36 +02:00
|
|
|
if (first < 0)
|
2005-06-12 10:02:59 +02:00
|
|
|
first = 0;
|
|
|
|
int tmpCurrent = current;
|
|
|
|
while (!SelectableItem(tmpCurrent) && --tmpCurrent >= 0)
|
|
|
|
;
|
|
|
|
if (tmpCurrent < 0) {
|
|
|
|
tmpCurrent = current;
|
|
|
|
while (++tmpCurrent <= last && !SelectableItem(tmpCurrent))
|
|
|
|
;
|
|
|
|
}
|
|
|
|
current = tmpCurrent <= last ? tmpCurrent : -1;
|
|
|
|
if (current >= 0) {
|
|
|
|
if (current < first)
|
|
|
|
first = current;
|
|
|
|
else if (current - first >= displayMenuItems)
|
|
|
|
first = current - displayMenuItems + 1;
|
|
|
|
}
|
|
|
|
if (current != oldCurrent || first != oldFirst) {
|
|
|
|
Display();
|
|
|
|
DisplayCurrent(true);
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
2005-06-18 10:44:30 +02:00
|
|
|
else if (Setup.MenuScrollWrap)
|
|
|
|
CursorUp();
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2006-01-08 11:44:37 +01:00
|
|
|
void cOsdMenu::PageDown(void)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2005-06-12 10:02:59 +02:00
|
|
|
int oldCurrent = current;
|
|
|
|
int oldFirst = first;
|
2004-05-16 10:35:36 +02:00
|
|
|
current += displayMenuItems;
|
|
|
|
first += displayMenuItems;
|
2005-06-12 10:02:59 +02:00
|
|
|
int last = Count() - 1;
|
2005-06-17 14:25:08 +02:00
|
|
|
if (current > last)
|
|
|
|
current = last;
|
|
|
|
if (first + displayMenuItems > last)
|
|
|
|
first = max(0, last - displayMenuItems + 1);
|
2005-06-12 10:02:59 +02:00
|
|
|
int tmpCurrent = current;
|
|
|
|
while (!SelectableItem(tmpCurrent) && ++tmpCurrent <= last)
|
|
|
|
;
|
|
|
|
if (tmpCurrent > last) {
|
|
|
|
tmpCurrent = current;
|
|
|
|
while (--tmpCurrent >= 0 && !SelectableItem(tmpCurrent))
|
|
|
|
;
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
2005-06-12 10:02:59 +02:00
|
|
|
current = tmpCurrent > 0 ? tmpCurrent : -1;
|
|
|
|
if (current >= 0) {
|
|
|
|
if (current < first)
|
|
|
|
first = current;
|
|
|
|
else if (current - first >= displayMenuItems)
|
|
|
|
first = current - displayMenuItems + 1;
|
|
|
|
}
|
|
|
|
if (current != oldCurrent || first != oldFirst) {
|
|
|
|
Display();
|
|
|
|
DisplayCurrent(true);
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
2005-06-18 10:44:30 +02:00
|
|
|
else if (Setup.MenuScrollWrap)
|
|
|
|
CursorDown();
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
void cOsdMenu::Mark(void)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
if (Count() && marked < 0) {
|
|
|
|
marked = current;
|
|
|
|
SetStatus(tr("Up/Dn for new location - OK to move"));
|
|
|
|
}
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
eOSState cOsdMenu::HotKey(eKeys Key)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
for (cOsdItem *item = First(); item; item = Next(item)) {
|
|
|
|
const char *s = item->Text();
|
|
|
|
if (s && (s = skipspace(s)) != NULL) {
|
|
|
|
if (*s == Key - k1 + '1') {
|
|
|
|
current = item->Index();
|
2007-01-07 14:46:14 +01:00
|
|
|
RefreshCurrent();
|
|
|
|
Display();
|
2004-05-16 10:35:36 +02:00
|
|
|
cRemote::Put(kOk, true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return osContinue;
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
eOSState cOsdMenu::AddSubMenu(cOsdMenu *SubMenu)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
delete subMenu;
|
|
|
|
subMenu = SubMenu;
|
|
|
|
subMenu->Display();
|
|
|
|
return osContinue; // convenience return value
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
eOSState cOsdMenu::CloseSubMenu()
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
delete subMenu;
|
|
|
|
subMenu = NULL;
|
|
|
|
RefreshCurrent();
|
|
|
|
Display();
|
|
|
|
return osContinue; // convenience return value
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
eOSState cOsdMenu::ProcessKey(eKeys Key)
|
2002-05-10 14:55:53 +02:00
|
|
|
{
|
2004-05-16 10:35:36 +02:00
|
|
|
if (subMenu) {
|
|
|
|
eOSState state = subMenu->ProcessKey(Key);
|
|
|
|
if (state == osBack)
|
|
|
|
return CloseSubMenu();
|
|
|
|
return state;
|
|
|
|
}
|
2002-05-10 14:55:53 +02:00
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
cOsdItem *item = Get(current);
|
|
|
|
if (marked < 0 && item) {
|
|
|
|
eOSState state = item->ProcessKey(Key);
|
|
|
|
if (state != osUnknown) {
|
|
|
|
DisplayCurrent(true);
|
|
|
|
return state;
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|
|
|
|
}
|
2004-05-16 10:35:36 +02:00
|
|
|
switch (Key) {
|
2006-01-05 13:43:07 +01:00
|
|
|
case k0: return osUnknown;
|
2004-05-16 10:35:36 +02:00
|
|
|
case k1...k9: return hasHotkeys ? HotKey(Key) : osUnknown;
|
|
|
|
case kUp|k_Repeat:
|
|
|
|
case kUp: CursorUp(); break;
|
|
|
|
case kDown|k_Repeat:
|
|
|
|
case kDown: CursorDown(); break;
|
|
|
|
case kLeft|k_Repeat:
|
|
|
|
case kLeft: PageUp(); break;
|
|
|
|
case kRight|k_Repeat:
|
|
|
|
case kRight: PageDown(); break;
|
|
|
|
case kBack: return osBack;
|
|
|
|
case kOk: if (marked >= 0) {
|
|
|
|
SetStatus(NULL);
|
|
|
|
if (marked != current)
|
|
|
|
Move(marked, current);
|
|
|
|
marked = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// else run into default
|
|
|
|
default: if (marked < 0)
|
|
|
|
return osUnknown;
|
|
|
|
}
|
|
|
|
return osContinue;
|
2002-05-10 14:55:53 +02:00
|
|
|
}
|