45 text = Copy ? strdup(Text ? Text :
"") : (
char *)Text;
60 DisplayMenu->
SetItem(
Text(), Index, Current, Selectable);
94 SetCols(c0, c1, c2, c3, c4);
97 current = marked = -1;
99 helpRed = helpGreen = helpYellow = helpBlue = NULL;
100 helpDisplayed =
false;
102 if (!displayMenuCount++) {
113 displayMenu->Clear();
115 if (!--displayMenuCount)
121 menuCategory = MenuCategory;
126 menuSortMode = MenuSortMode;
132 displayMenu->Clear();
141 if (s && hasHotkeys) {
142 if (digit == 0 &&
'1' <= *s && *s <=
'9' && *(s + 1) ==
' ')
164 hasHotkeys = HasHotkeys;
171 status = s ? strdup(s) : NULL;
172 displayMenu->SetMessage(
mtStatus, s);
178 title = strdup(Title);
183 if (!helpDisplayed || Force) {
184 displayMenu->SetButtons(helpRed, helpGreen, helpYellow, helpBlue);
186 helpDisplayed =
true;
190 void cOsdMenu::SetHelp(
const char *Red,
const char *Green,
const char *Yellow,
const char *Blue)
204 while (current < count && !SelectableItem(current))
206 if (current == count) {
207 while (current > 0 && !SelectableItem(current))
210 if (Index == first && first > 0)
218 current = Item->
Index();
225 current = Item->
Index();
236 displayMenu->SetMessage(
mtStatus, NULL);
237 displayMenu->Clear();
239 if (menuCategory != displayMenu->MenuCategory())
240 displayMenu->SetMenuCategory(menuCategory);
241 displayMenu->SetMenuSortMode(menuSortMode);
242 menuOrientation = displayMenu->MenuOrientation();
243 displayMenuItems = displayMenu->MaxItems();
244 displayMenu->SetTabs(cols[0], cols[1], cols[2], cols[3], cols[4]);
245 displayMenu->SetTitle(title);
251 for (
cOsdItem *item = First(); item; item =
Next(item)) {
254 current = item->Index();
258 first =
max(0,
min(first,
max(0, count - displayMenuItems)));
259 if (current - first >= displayMenuItems || current < first) {
260 first = current - displayMenuItems / 2;
261 if (first + displayMenuItems > count)
262 first = count - displayMenuItems;
268 for (
cOsdItem *item = Get(first); item; item =
Next(item)) {
269 bool CurrentSelectable = (i == current) && item->Selectable();
270 item->SetMenuItem(displayMenu, i - first, CurrentSelectable, item->Selectable());
271 if (CurrentSelectable)
273 if (++n == displayMenuItems)
278 displayMenu->SetScrollbar(count, first);
280 displayMenu->SetMessage(
mtStatus, status);
285 current = Item ? Item->
Index() : -1;
286 if (current >= 0 && lastOffset >= 0)
287 first =
max(0, current - lastOffset);
307 if (
cMenuEditItem *MenuEditItem = dynamic_cast<cMenuEditItem *>(item)) {
308 if (!MenuEditItem->DisplayHelp(Current))
311 helpDisplayed =
false;
320 int Offset = Index - first;
321 if (Offset >= 0 && Offset < first + displayMenuItems) {
322 bool Current = Index == current;
335 lastOffset = (current > first) ? current - first : 0;
337 current = marked = -1;
349 int tmpCurrent = current;
350 int lastOnScreen = first + displayMenuItems - 1;
351 int last = Count() - 1;
354 while (--tmpCurrent != current) {
355 if (tmpCurrent < 0) {
363 tmpCurrent = last + 1;
367 else if (SelectableItem(tmpCurrent))
370 if (first <= tmpCurrent && tmpCurrent <= lastOnScreen)
371 DisplayCurrent(
false);
372 current = tmpCurrent;
373 if (current < first) {
377 else if (current > lastOnScreen) {
378 first =
max(0, current - displayMenuItems + 1);
382 DisplayCurrent(
true);
387 int tmpCurrent = current;
388 int lastOnScreen = first + displayMenuItems - 1;
389 int last = Count() - 1;
392 while (++tmpCurrent != current) {
393 if (tmpCurrent > last) {
394 if (first < last - displayMenuItems) {
396 first = last - displayMenuItems + 1;
405 else if (SelectableItem(tmpCurrent))
408 if (first <= tmpCurrent && tmpCurrent <= lastOnScreen)
409 DisplayCurrent(
false);
410 current = tmpCurrent;
411 if (current > lastOnScreen) {
413 if (first + displayMenuItems > last)
414 first =
max(0, last - displayMenuItems + 1);
417 else if (current < first) {
422 DisplayCurrent(
true);
427 int oldCurrent = current;
428 int oldFirst = first;
429 current -= displayMenuItems;
430 first -= displayMenuItems;
431 int last = Count() - 1;
436 int tmpCurrent = current;
437 while (!SelectableItem(tmpCurrent) && --tmpCurrent >= 0)
439 if (tmpCurrent < 0) {
440 tmpCurrent = current;
441 while (++tmpCurrent <= last && !SelectableItem(tmpCurrent))
444 current = tmpCurrent <= last ? tmpCurrent : -1;
448 else if (current - first >= displayMenuItems)
449 first = current - displayMenuItems + 1;
451 if (current != oldCurrent || first != oldFirst) {
453 DisplayCurrent(
true);
461 int oldCurrent = current;
462 int oldFirst = first;
463 current += displayMenuItems;
464 first += displayMenuItems;
465 int last = Count() - 1;
468 if (first + displayMenuItems > last)
469 first =
max(0, last - displayMenuItems + 1);
470 int tmpCurrent = current;
471 while (!SelectableItem(tmpCurrent) && ++tmpCurrent <= last)
473 if (tmpCurrent > last) {
474 tmpCurrent = current;
475 while (--tmpCurrent >= 0 && !SelectableItem(tmpCurrent))
478 current = tmpCurrent > 0 ? tmpCurrent : -1;
482 else if (current - first >= displayMenuItems)
483 first = current - displayMenuItems + 1;
485 if (current != oldCurrent || first != oldFirst) {
487 DisplayCurrent(
true);
495 if (Count() && marked < 0) {
497 SetStatus(
tr(
"Up/Dn for new location - OK to move"));
501 #define MENUKEY_TIMEOUT 1500 506 bool highlight =
false;
511 if (lastActivity.TimedOut())
518 for (
cOsdItem *item = Last(); item; item =
Prev(item)) {
519 const char *s = item->Text();
522 if (s && (s =
skipspace(s))[0] !=
'\0' &&
'0' <= s[i] && s[i] <=
'9') {
524 item_nr = item_nr * 10 + (s[i] -
'0');
526 while ( !((s[++i] ==
'\t')||(s[i] ==
' ')) && (s[i] !=
'\0') && (
'0' <= s[i]) && (s[i] <=
'9'));
527 if ((Key ==
kOk) && (item_nr == key_nr)) {
528 current = item->Index();
535 else if (Key !=
kOk) {
536 if (!highlight && (item_nr == (Key -
k0))) {
538 current = item->Index();
540 if (!match && (key_nr == -1) && ((item_nr / 10) == (Key -
k0))) {
544 else if (((key_nr == -1) && (item_nr == (Key -
k0))) || (!match && (key_nr >= 0) && (item_nr == (10 * key_nr + Key -
k0)))) {
545 current = item->Index();
553 if ((!match) && (Key !=
kNone))
582 return CloseSubMenu();
587 if (marked < 0 && item) {
590 DisplayCurrent(
true);
596 case k0...k9:
return hasHotkeys ? HotKey(Key) :
osUnknown;
598 case kUp:
if (menuOrientation ==
moHorizontal) PageUp();
else CursorUp();
break;
600 case kDown:
if (menuOrientation ==
moHorizontal) PageDown();
else CursorDown();
break;
602 case kLeft:
if (menuOrientation ==
moHorizontal) CursorUp();
else PageUp();
break;
604 case kRight:
if (menuOrientation ==
moHorizontal) CursorDown();
else PageDown();
break;
606 case kOk:
if (marked >= 0) {
608 if (marked != current)
609 Move(marked, current);
614 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 bool OsdSizeChanged(int &State)
Checks if the OSD size has changed and a currently displayed OSD needs to be redrawn.
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)