45 text = Copy ? strdup(Text ? Text :
"") : (
char *)Text;
60 DisplayMenu->
SetItem(
Text(), Index, Current, Selectable);
92 SetCols(c0, c1, c2, c3, c4);
94 current = marked = -1;
96 helpRed = helpGreen = helpYellow = helpBlue = NULL;
97 helpDisplayed =
false;
99 if (!displayMenuCount++)
108 displayMenu->Clear();
110 if (!--displayMenuCount)
116 menuCategory = MenuCategory;
121 menuSortMode = MenuSortMode;
127 displayMenu->Clear();
136 if (s && hasHotkeys) {
137 if (digit == 0 &&
'1' <= *s && *s <=
'9' && *(s + 1) ==
' ')
159 hasHotkeys = HasHotkeys;
166 status = s ? strdup(s) : NULL;
167 displayMenu->SetMessage(
mtStatus, s);
173 title = strdup(Title);
178 if (!helpDisplayed || Force) {
179 displayMenu->SetButtons(helpRed, helpGreen, helpYellow, helpBlue);
181 helpDisplayed =
true;
185 void cOsdMenu::SetHelp(
const char *Red,
const char *Green,
const char *Yellow,
const char *Blue)
199 while (current < count && !SelectableItem(current))
201 if (current == count) {
202 while (current > 0 && !SelectableItem(current))
205 if (Index == first && first > 0)
213 current = Item->
Index();
220 current = Item->
Index();
229 displayMenu->SetMessage(
mtStatus, NULL);
230 displayMenu->Clear();
232 if (menuCategory != displayMenu->MenuCategory())
233 displayMenu->SetMenuCategory(menuCategory);
234 displayMenu->SetMenuSortMode(menuSortMode);
235 displayMenuItems = displayMenu->MaxItems();
236 displayMenu->SetTabs(cols[0], cols[1], cols[2], cols[3], cols[4]);
237 displayMenu->SetTitle(title);
243 for (
cOsdItem *item = First(); item; item =
Next(item)) {
246 current = item->Index();
250 first =
min(first,
max(0, count - displayMenuItems));
251 if (current - first >= displayMenuItems || current < first) {
252 first = current - displayMenuItems / 2;
253 if (first + displayMenuItems > count)
254 first = count - displayMenuItems;
260 for (
cOsdItem *item = Get(first); item; item =
Next(item)) {
261 bool CurrentSelectable = (i == current) && item->Selectable();
262 item->SetMenuItem(displayMenu, i - first, CurrentSelectable, item->Selectable());
263 if (CurrentSelectable)
265 if (++n == displayMenuItems)
270 displayMenu->SetScrollbar(count, first);
272 displayMenu->SetMessage(
mtStatus, status);
277 current = Item ? Item->
Index() : -1;
296 if (
cMenuEditItem *MenuEditItem = dynamic_cast<cMenuEditItem *>(item)) {
297 if (!MenuEditItem->DisplayHelp(Current))
300 helpDisplayed =
false;
309 int Offset = Index - first;
310 if (Offset >= 0 && Offset < first + displayMenuItems) {
311 bool Current = Index == current;
324 current = marked = -1;
336 int tmpCurrent = current;
337 int lastOnScreen = first + displayMenuItems - 1;
338 int last = Count() - 1;
341 while (--tmpCurrent != current) {
342 if (tmpCurrent < 0) {
350 tmpCurrent = last + 1;
354 else if (SelectableItem(tmpCurrent))
357 if (first <= tmpCurrent && tmpCurrent <= lastOnScreen)
358 DisplayCurrent(
false);
359 current = tmpCurrent;
360 if (current < first) {
364 else if (current > lastOnScreen) {
365 first =
max(0, current - displayMenuItems + 1);
369 DisplayCurrent(
true);
374 int tmpCurrent = current;
375 int lastOnScreen = first + displayMenuItems - 1;
376 int last = Count() - 1;
379 while (++tmpCurrent != current) {
380 if (tmpCurrent > last) {
381 if (first < last - displayMenuItems) {
383 first = last - displayMenuItems + 1;
392 else if (SelectableItem(tmpCurrent))
395 if (first <= tmpCurrent && tmpCurrent <= lastOnScreen)
396 DisplayCurrent(
false);
397 current = tmpCurrent;
398 if (current > lastOnScreen) {
400 if (first + displayMenuItems > last)
401 first =
max(0, last - displayMenuItems + 1);
404 else if (current < first) {
409 DisplayCurrent(
true);
414 int oldCurrent = current;
415 int oldFirst = first;
416 current -= displayMenuItems;
417 first -= displayMenuItems;
418 int last = Count() - 1;
423 int tmpCurrent = current;
424 while (!SelectableItem(tmpCurrent) && --tmpCurrent >= 0)
426 if (tmpCurrent < 0) {
427 tmpCurrent = current;
428 while (++tmpCurrent <= last && !SelectableItem(tmpCurrent))
431 current = tmpCurrent <= last ? tmpCurrent : -1;
435 else if (current - first >= displayMenuItems)
436 first = current - displayMenuItems + 1;
438 if (current != oldCurrent || first != oldFirst) {
440 DisplayCurrent(
true);
448 int oldCurrent = current;
449 int oldFirst = first;
450 current += displayMenuItems;
451 first += displayMenuItems;
452 int last = Count() - 1;
455 if (first + displayMenuItems > last)
456 first =
max(0, last - displayMenuItems + 1);
457 int tmpCurrent = current;
458 while (!SelectableItem(tmpCurrent) && ++tmpCurrent <= last)
460 if (tmpCurrent > last) {
461 tmpCurrent = current;
462 while (--tmpCurrent >= 0 && !SelectableItem(tmpCurrent))
465 current = tmpCurrent > 0 ? tmpCurrent : -1;
469 else if (current - first >= displayMenuItems)
470 first = current - displayMenuItems + 1;
472 if (current != oldCurrent || first != oldFirst) {
474 DisplayCurrent(
true);
482 if (Count() && marked < 0) {
484 SetStatus(
tr(
"Up/Dn for new location - OK to move"));
488 #define MENUKEY_TIMEOUT 1500 493 bool highlight =
false;
498 if (lastActivity.TimedOut())
505 for (
cOsdItem *item = Last(); item; item =
Prev(item)) {
506 const char *s = item->Text();
509 if (s && (s =
skipspace(s))[0] !=
'\0' &&
'0' <= s[i] && s[i] <=
'9') {
511 item_nr = item_nr * 10 + (s[i] -
'0');
513 while ( !((s[++i] ==
'\t')||(s[i] ==
' ')) && (s[i] !=
'\0') && (
'0' <= s[i]) && (s[i] <=
'9'));
514 if ((Key ==
kOk) && (item_nr == key_nr)) {
515 current = item->Index();
522 else if (Key !=
kOk) {
523 if (!highlight && (item_nr == (Key -
k0))) {
525 current = item->Index();
527 if (!match && (key_nr == -1) && ((item_nr / 10) == (Key -
k0))) {
531 else if (((key_nr == -1) && (item_nr == (Key -
k0))) || (!match && (key_nr >= 0) && (item_nr == (10 * key_nr + Key -
k0)))) {
532 current = item->Index();
540 if ((!match) && (Key !=
kNone))
569 return CloseSubMenu();
574 if (marked < 0 && item) {
577 DisplayCurrent(
true);
583 case k0...k9:
return hasHotkeys ? HotKey(Key) :
osUnknown;
585 case kUp: CursorUp();
break;
587 case kDown: CursorDown();
break;
589 case kLeft: PageUp();
break;
591 case kRight: PageDown();
break;
593 case kOk:
if (marked >= 0) {
595 if (marked != current)
596 Move(marked, current);
601 default:
if (marked < 0)
static void MsgOsdCurrentItem(const char *Text)
cOsdItem(eOSState State=osUnknown)
void Add(cListObject *Object, cListObject *After=NULL)
static cString sprintf(const char *fmt,...) __attribute__((format(printf
virtual cSkinDisplayMenu * DisplayMenu(void)=0
Creates and returns a new object for displaying a menu.
void SetFresh(bool Fresh)
static void MsgOsdHelpKeys(const char *Red, const char *Green, const char *Yellow, const char *Blue)
const char * Text(void) const
bool Selectable(void) const
cListObject * Next(void) const
static void MsgOsdTitle(const char *Title)
void SetText(const char *Text, bool Copy=true)
void SetSelectable(bool Selectable)
void Ins(cListObject *Object, cListObject *Before=NULL)
bool Put(uint64_t Code, bool Repeat=false, bool Release=false)
virtual eOSState ProcessKey(eKeys Key)
cListObject * Prev(void) const
void Del(cListObject *Object, bool DeleteObject=true)
static void MsgOsdClear(void)
cSkin * Current(void)
Returns a pointer to the current skin.
static void MsgOsdItem(const char *Text, int Index)
virtual void SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable)