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 displayMenuItems = displayMenu->MaxItems();
337 int tmpCurrent = current;
338 int lastOnScreen = first + displayMenuItems - 1;
339 int last = Count() - 1;
342 while (--tmpCurrent != current) {
343 if (tmpCurrent < 0) {
351 tmpCurrent = last + 1;
355 else if (SelectableItem(tmpCurrent))
358 if (first <= tmpCurrent && tmpCurrent <= lastOnScreen)
359 DisplayCurrent(
false);
360 current = tmpCurrent;
361 if (current < first) {
365 else if (current > lastOnScreen) {
366 first =
max(0, current - displayMenuItems + 1);
370 DisplayCurrent(
true);
375 displayMenuItems = displayMenu->MaxItems();
376 int tmpCurrent = current;
377 int lastOnScreen = first + displayMenuItems - 1;
378 int last = Count() - 1;
381 while (++tmpCurrent != current) {
382 if (tmpCurrent > last) {
383 if (first < last - displayMenuItems) {
385 first = last - displayMenuItems + 1;
394 else if (SelectableItem(tmpCurrent))
397 if (first <= tmpCurrent && tmpCurrent <= lastOnScreen)
398 DisplayCurrent(
false);
399 current = tmpCurrent;
400 if (current > lastOnScreen) {
402 if (first + displayMenuItems > last)
403 first =
max(0, last - displayMenuItems + 1);
406 else if (current < first) {
411 DisplayCurrent(
true);
416 displayMenuItems = displayMenu->MaxItems();
417 int oldCurrent = current;
418 int oldFirst = first;
419 current -= displayMenuItems;
420 first -= displayMenuItems;
421 int last = Count() - 1;
426 int tmpCurrent = current;
427 while (!SelectableItem(tmpCurrent) && --tmpCurrent >= 0)
429 if (tmpCurrent < 0) {
430 tmpCurrent = current;
431 while (++tmpCurrent <= last && !SelectableItem(tmpCurrent))
434 current = tmpCurrent <= last ? tmpCurrent : -1;
438 else if (current - first >= displayMenuItems)
439 first = current - displayMenuItems + 1;
441 if (current != oldCurrent || first != oldFirst) {
443 DisplayCurrent(
true);
451 displayMenuItems = displayMenu->MaxItems();
452 int oldCurrent = current;
453 int oldFirst = first;
454 current += displayMenuItems;
455 first += displayMenuItems;
456 int last = Count() - 1;
459 if (first + displayMenuItems > last)
460 first =
max(0, last - displayMenuItems + 1);
461 int tmpCurrent = current;
462 while (!SelectableItem(tmpCurrent) && ++tmpCurrent <= last)
464 if (tmpCurrent > last) {
465 tmpCurrent = current;
466 while (--tmpCurrent >= 0 && !SelectableItem(tmpCurrent))
469 current = tmpCurrent > 0 ? tmpCurrent : -1;
473 else if (current - first >= displayMenuItems)
474 first = current - displayMenuItems + 1;
476 if (current != oldCurrent || first != oldFirst) {
478 DisplayCurrent(
true);
486 if (Count() && marked < 0) {
488 SetStatus(
tr(
"Up/Dn for new location - OK to move"));
492 #define MENUKEY_TIMEOUT 1500 497 bool highlight =
false;
502 if (lastActivity.TimedOut())
509 for (
cOsdItem *item = Last(); item; item =
Prev(item)) {
510 const char *s = item->Text();
513 if (s && (s =
skipspace(s)) !=
'\0' &&
'0' <= s[i] && s[i] <=
'9') {
515 item_nr = item_nr * 10 + (s[i] -
'0');
517 while ( !((s[++i] ==
'\t')||(s[i] ==
' ')) && (s[i] !=
'\0') && (
'0' <= s[i]) && (s[i] <=
'9'));
518 if ((Key ==
kOk) && (item_nr == key_nr)) {
519 current = item->Index();
526 else if (Key !=
kOk) {
527 if (!highlight && (item_nr == (Key -
k0))) {
529 current = item->Index();
531 if (!match && (key_nr == -1) && ((item_nr / 10) == (Key -
k0))) {
535 else if (((key_nr == -1) && (item_nr == (Key -
k0))) || (!match && (key_nr >= 0) && (item_nr == (10 * key_nr + Key -
k0)))) {
536 current = item->Index();
544 if ((!match) && (Key !=
kNone))
573 return CloseSubMenu();
578 if (marked < 0 && item) {
581 DisplayCurrent(
true);
587 case k0...k9:
return hasHotkeys ? HotKey(Key) :
osUnknown;
589 case kUp: CursorUp();
break;
591 case kDown: CursorDown();
break;
593 case kLeft: PageUp();
break;
595 case kRight: PageDown();
break;
597 case kOk:
if (marked >= 0) {
599 if (marked != current)
600 Move(marked, current);
605 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)