diff --git a/data/icons/0-green.png b/data/icons/0-green.png new file mode 100644 index 000000000..716637c7a Binary files /dev/null and b/data/icons/0-green.png differ diff --git a/data/icons/0-red.png b/data/icons/0-red.png new file mode 100644 index 000000000..a99393a3f Binary files /dev/null and b/data/icons/0-red.png differ diff --git a/data/icons/1-green.png b/data/icons/1-green.png new file mode 100644 index 000000000..1ad8fee1b Binary files /dev/null and b/data/icons/1-green.png differ diff --git a/data/icons/1-red.png b/data/icons/1-red.png new file mode 100644 index 000000000..690a5154c Binary files /dev/null and b/data/icons/1-red.png differ diff --git a/data/icons/2-green.png b/data/icons/2-green.png new file mode 100644 index 000000000..3679e7511 Binary files /dev/null and b/data/icons/2-green.png differ diff --git a/data/icons/2-red.png b/data/icons/2-red.png new file mode 100644 index 000000000..05845207e Binary files /dev/null and b/data/icons/2-red.png differ diff --git a/data/icons/3-green.png b/data/icons/3-green.png new file mode 100644 index 000000000..3cb2d23fa Binary files /dev/null and b/data/icons/3-green.png differ diff --git a/data/icons/3-red.png b/data/icons/3-red.png new file mode 100644 index 000000000..06644bb00 Binary files /dev/null and b/data/icons/3-red.png differ diff --git a/data/icons/4-green.png b/data/icons/4-green.png new file mode 100644 index 000000000..4b690273d Binary files /dev/null and b/data/icons/4-green.png differ diff --git a/data/icons/4-red.png b/data/icons/4-red.png new file mode 100644 index 000000000..c2508e59e Binary files /dev/null and b/data/icons/4-red.png differ diff --git a/data/icons/5-green.png b/data/icons/5-green.png new file mode 100644 index 000000000..bf74eeed9 Binary files /dev/null and b/data/icons/5-green.png differ diff --git a/data/icons/5-red.png b/data/icons/5-red.png new file mode 100644 index 000000000..cc9963238 Binary files /dev/null and b/data/icons/5-red.png differ diff --git a/data/icons/6-green.png b/data/icons/6-green.png new file mode 100644 index 000000000..b8376864a Binary files /dev/null and b/data/icons/6-green.png differ diff --git a/data/icons/6-red.png b/data/icons/6-red.png new file mode 100644 index 000000000..e34639e11 Binary files /dev/null and b/data/icons/6-red.png differ diff --git a/data/icons/7-green.png b/data/icons/7-green.png new file mode 100644 index 000000000..a02844aa2 Binary files /dev/null and b/data/icons/7-green.png differ diff --git a/data/icons/7-red.png b/data/icons/7-red.png new file mode 100644 index 000000000..b33f57e85 Binary files /dev/null and b/data/icons/7-red.png differ diff --git a/data/icons/8-green.png b/data/icons/8-green.png new file mode 100644 index 000000000..a87ae15c0 Binary files /dev/null and b/data/icons/8-green.png differ diff --git a/data/icons/8-red.png b/data/icons/8-red.png new file mode 100644 index 000000000..000fc524b Binary files /dev/null and b/data/icons/8-red.png differ diff --git a/data/icons/9-green.png b/data/icons/9-green.png new file mode 100644 index 000000000..8959902e8 Binary files /dev/null and b/data/icons/9-green.png differ diff --git a/data/icons/9-red.png b/data/icons/9-red.png new file mode 100644 index 000000000..01e66e508 Binary files /dev/null and b/data/icons/9-red.png differ diff --git a/data/icons/hint_nkplay.png b/data/icons/hint_nkplay.png new file mode 100644 index 000000000..4ea007091 Binary files /dev/null and b/data/icons/hint_nkplay.png differ diff --git a/data/icons/hint_rass.png b/data/icons/hint_rass.png new file mode 100644 index 000000000..e9f5462da Binary files /dev/null and b/data/icons/hint_rass.png differ diff --git a/data/icons/hint_spark.png b/data/icons/hint_spark.png new file mode 100644 index 000000000..f10fca62e Binary files /dev/null and b/data/icons/hint_spark.png differ diff --git a/data/icons/icon_nkplay.png b/data/icons/icon_nkplay.png new file mode 100644 index 000000000..ce3b052f2 Binary files /dev/null and b/data/icons/icon_nkplay.png differ diff --git a/data/icons/icon_ytplay.png b/data/icons/icon_ytplay.png new file mode 100644 index 000000000..858f4ffd4 Binary files /dev/null and b/data/icons/icon_ytplay.png differ diff --git a/data/icons/longpress.png b/data/icons/longpress.png new file mode 100644 index 000000000..6b0c3db18 Binary files /dev/null and b/data/icons/longpress.png differ diff --git a/data/icons/mp_play_repeat_all.png b/data/icons/mp_play_repeat_all.png new file mode 100644 index 000000000..415c530b9 Binary files /dev/null and b/data/icons/mp_play_repeat_all.png differ diff --git a/data/icons/mp_play_repeat_track.png b/data/icons/mp_play_repeat_track.png new file mode 100644 index 000000000..04a8f71bd Binary files /dev/null and b/data/icons/mp_play_repeat_track.png differ diff --git a/data/icons/rass.png b/data/icons/rass.png new file mode 100644 index 000000000..ce6a80a78 Binary files /dev/null and b/data/icons/rass.png differ diff --git a/data/icons/warning.png b/data/icons/warning.png new file mode 100644 index 000000000..374193eec Binary files /dev/null and b/data/icons/warning.png differ diff --git a/src/driver/display.h b/src/driver/display.h new file mode 100644 index 000000000..e80049a46 --- /dev/null +++ b/src/driver/display.h @@ -0,0 +1,7 @@ +/* helper for different display CVFD implementations */ +#if HAVE_COOL_HARDWARE +#include +#endif +#if HAVE_TRIPLEDRAGON || HAVE_SPARK_HARDWARE || HAVE_AZBOX_HARDWARE || HAVE_GENERIC_HARDWARE +#include +#endif diff --git a/src/driver/record.cpp b/src/driver/record.cpp index 5c2eae786..836632b71 100644 --- a/src/driver/record.cpp +++ b/src/driver/record.cpp @@ -1414,7 +1414,7 @@ bool CRecordManager::ShowMenu(void) sprintf(cnt, "%d", i); //define stop key if only one record is running, otherwise define shortcuts neutrino_msg_t rc_key = CRCInput::convertDigitToKey(shortcut++); - std::string btn_icon = NEUTRINO_ICON_BUTTON_OKAY; + const char * btn_icon = NEUTRINO_ICON_BUTTON_OKAY; if (rec_count == 1){ rc_key = CRCInput::RC_stop; btn_icon = NEUTRINO_ICON_BUTTON_STOP; diff --git a/src/gui/audio_setup.cpp b/src/gui/audio_setup.cpp index 5b854d798..22290473a 100644 --- a/src/gui/audio_setup.cpp +++ b/src/gui/audio_setup.cpp @@ -160,7 +160,7 @@ int CAudioSetup::showAudioSetup() as_oj_vsteps = new CMenuOptionNumberChooser(LOCALE_AUDIOMENU_VOLUME_STEP, (int *)&g_settings.current_volume_step, true, 1, 25, NULL); as_oj_vsteps->setHint("", LOCALE_MENU_HINT_AUDIO_VOLSTEP); - st = new CMenuOptionNumberChooser(LOCALE_AUDIOMENU_VOLUME_START, &g_settings.start_volume, true, -1, 100, NULL, 0, -1, LOCALE_OPTIONS_OFF); + st = new CMenuOptionNumberChooser(LOCALE_AUDIOMENU_VOLUME_START, &g_settings.start_volume, true, -1, 100, NULL, CRCInput::RC_nokey, NULL, 0, -1, LOCALE_OPTIONS_OFF); st->setHint("", LOCALE_MENU_HINT_AUDIO_VOLSTART); //clock rec //CMenuOptionChooser * as_oj_clockrec new CMenuOptionChooser(LOCALE_AUDIOMENU_CLOCKREC, &g_settings.clockrec, AUDIOMENU_CLOCKREC_OPTIONS, AUDIOMENU_CLOCKREC_OPTION_COUNT, true, audioSetupNotifier); diff --git a/src/gui/audioplayer_setup.cpp b/src/gui/audioplayer_setup.cpp index 74dbcc725..b95433215 100644 --- a/src/gui/audioplayer_setup.cpp +++ b/src/gui/audioplayer_setup.cpp @@ -125,7 +125,7 @@ int CAudioPlayerSetup::showAudioPlayerSetup() mc->setHint("", LOCALE_MENU_HINT_AUDIOPLAYER_PLAYLIST); audioplayerSetup->addItem(mc); - CMenuOptionNumberChooser *cc = new CMenuOptionNumberChooser(LOCALE_AUDIOPLAYER_SCREENSAVER_TIMEOUT, &g_settings.audioplayer_screensaver, true, 0, 999, NULL, 0, 0, LOCALE_OPTIONS_OFF); + CMenuOptionNumberChooser *cc = new CMenuOptionNumberChooser(LOCALE_AUDIOPLAYER_SCREENSAVER_TIMEOUT, &g_settings.audioplayer_screensaver, true, 0, 999, NULL, CRCInput::RC_nokey, NULL, 0, 0, LOCALE_OPTIONS_OFF); cc->setNumberFormat(std::string("%d ") + g_Locale->getText(LOCALE_UNIT_SHORT_MINUTE)); cc->setHint("", LOCALE_MENU_HINT_AUDIOPLAYER_SCREENSAVER); audioplayerSetup->addItem(cc); diff --git a/src/gui/keybind_setup.cpp b/src/gui/keybind_setup.cpp index 94598bdfa..fcb675f72 100644 --- a/src/gui/keybind_setup.cpp +++ b/src/gui/keybind_setup.cpp @@ -261,7 +261,7 @@ int CKeybindSetup::showKeySetup() CMenuOptionNumberChooser *cc; cc = new CMenuOptionNumberChooser(LOCALE_KEYBINDINGMENU_LONGKEYPRESS_DURATION, - &g_settings.longkeypress_duration, true, LONGKEYPRESS_OFF, 9999, NULL, 0, LONGKEYPRESS_OFF, LOCALE_OPTIONS_OFF); + &g_settings.longkeypress_duration, true, LONGKEYPRESS_OFF, 9999, NULL, CRCInput::convertDigitToKey(shortcut++), NULL, 0, LONGKEYPRESS_OFF, LOCALE_OPTIONS_OFF); cc->setNumberFormat(ms_number_format); cc->setNumericInput(true); cc->setHint("", LOCALE_MENU_HINT_LONGKEYPRESS_DURATION); diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 70b549038..5946f78d3 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -1086,13 +1086,24 @@ int CLuaInstance::MenuAddItem(lua_State *L) } else m->m->addItem(GenericMenuSeparatorLine); } else { - std::string right_icon; tableLookup(L, "right_icon", right_icon); + std::string right_icon_str; tableLookup(L, "right_icon", right_icon_str); std::string action; tableLookup(L, "action", action); std::string value; tableLookup(L, "value", value); std::string hint; tableLookup(L, "hint", hint); - std::string hint_icon; tableLookup(L, "hint_icon", hint_icon); + std::string hint_icon_str; tableLookup(L, "hint_icon", hint_icon_str); std::string id; tableLookup(L, "id", id); std::string tmp; + char *right_icon = NULL; + if (!right_icon_str.empty()) { + right_icon = strdup(right_icon_str.c_str()); + m->tofree.push_back(right_icon); + } + char *hint_icon = NULL; + if (!hint_icon_str.empty()) { + hint_icon = strdup(hint_icon_str.c_str()); + m->tofree.push_back(hint_icon); + } + int directkey = CRCInput::RC_nokey; tableLookup(L, "directkey", directkey); int pulldown = false; tableLookup(L, "pulldown", pulldown); tmp = "true"; @@ -1107,8 +1118,8 @@ int CLuaInstance::MenuAddItem(lua_State *L) if (type == "forwarder") { b->str_val = value; CLuaMenuForwarder *forwarder = new CLuaMenuForwarder(L, action, id); - mi = new CMenuForwarder(b->name, enabled, b->str_val, forwarder, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); - if (!hint.empty() || !hint_icon.empty()) + mi = new CMenuForwarder(b->name, enabled, b->str_val, forwarder, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon); + if (!hint.empty() || hint_icon) mi->setHint(hint_icon, hint); m->targets.push_back(forwarder); } else if (type == "chooser") { @@ -1161,7 +1172,7 @@ int CLuaInstance::MenuAddItem(lua_State *L) int sms = 0; tableLookup(L, "sms", sms); int size = 30; tableLookup(L, "size", size); CLuaMenuStringinput *stringinput = new CLuaMenuStringinput(L, action, id, b->name.c_str(), &b->str_val, size, valid_chars, m->observ, icon.c_str(), sms); - mi = new CMenuForwarder(b->name, enabled, b->str_val, stringinput, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); + mi = new CMenuForwarder(b->name, enabled, b->str_val, stringinput, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon); m->targets.push_back(stringinput); } else if (type == "filebrowser") { b->str_val = value; @@ -1177,12 +1188,12 @@ int CLuaInstance::MenuAddItem(lua_State *L) } lua_pop(L, 1); - mi = new CMenuForwarder(b->name, enabled, b->str_val, filebrowser, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); + mi = new CMenuForwarder(b->name, enabled, b->str_val, filebrowser, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon); m->targets.push_back(filebrowser); } if (mi) { mi->setLua(L, action, id); - if (!hint.empty() || !hint_icon.empty()) + if (!hint.empty() || hint_icon) mi->setHint(hint_icon, hint); m->m->addItem(mi); } diff --git a/src/gui/miscsettings_menu.cpp b/src/gui/miscsettings_menu.cpp index 3c23a55e5..0271ada8c 100644 --- a/src/gui/miscsettings_menu.cpp +++ b/src/gui/miscsettings_menu.cpp @@ -337,7 +337,7 @@ void CMiscMenue::showMiscSettingsMenuGeneral(CMenuWidget *ms_general) //fan speed if (g_info.has_fan) { - CMenuOptionNumberChooser * mn = new CMenuOptionNumberChooser(LOCALE_FAN_SPEED, &g_settings.fan_speed, true, 1, 14, fanNotifier, 0, 0, LOCALE_OPTIONS_OFF); + CMenuOptionNumberChooser * mn = new CMenuOptionNumberChooser(LOCALE_FAN_SPEED, &g_settings.fan_speed, true, 1, 14, fanNotifier, CRCInput::RC_nokey, NULL, 0, 0, LOCALE_OPTIONS_OFF); mn->setHint("", LOCALE_MENU_HINT_FAN_SPEED); ms_general->addItem(mn); } diff --git a/src/gui/network_service.cpp b/src/gui/network_service.cpp index 15ff33e8b..7decd099f 100644 --- a/src/gui/network_service.cpp +++ b/src/gui/network_service.cpp @@ -46,18 +46,18 @@ struct network_service std::string cmd; std::string options; neutrino_locale_t hint; - std::string icon; + const char * icon; int enabled; }; static struct network_service services[] = { - { "FTP", "vsftpd", "", LOCALE_MENU_HINT_NET_FTPD, "", 0 }, - { "Telnet", "telnetd", "-l/bin/login", LOCALE_MENU_HINT_NET_TELNET, "", 0 }, + { "FTP", "vsftpd", "", LOCALE_MENU_HINT_NET_FTPD, NULL, 0 }, + { "Telnet", "telnetd", "-l/bin/login", LOCALE_MENU_HINT_NET_TELNET, NULL, 0 }, { "DjMount", "djmount", "-o iocharset=UTF-8 /media/00upnp/", LOCALE_MENU_HINT_NET_DJMOUNT, "", 0 }, - { "uShare", "ushare", "-D -n `cat /etc/hostname`", LOCALE_MENU_HINT_NET_USHARE, "", 0 }, - { "xupnpd", "xupnpd", "", LOCALE_MENU_HINT_NET_XUPNPD, "", 0 }, - { "Dropbear", "dropbear", "-B", LOCALE_MENU_HINT_NET_DROPBEAR, "", 0 }, + { "uShare", "ushare", "-D -n `cat /etc/hostname`", LOCALE_MENU_HINT_NET_USHARE, NULL, 0 }, + { "xupnpd", "xupnpd", "", LOCALE_MENU_HINT_NET_XUPNPD, NULL, 0 }, + { "Dropbear", "dropbear", "-B", LOCALE_MENU_HINT_NET_DROPBEAR, NULL, 0 }, }; #define SERVICE_COUNT (sizeof(services)/sizeof(struct network_service)) diff --git a/src/gui/personalize.cpp b/src/gui/personalize.cpp index e9b1e6050..1f1eea012 100644 --- a/src/gui/personalize.cpp +++ b/src/gui/personalize.cpp @@ -295,7 +295,7 @@ int CPersonalizeGui::ShowPersonalizationMenu() if (g_settings.easymenu) { int count = 0; for (uint j = 0; jgetName().c_str()); + printf("v_item[i].widget [%s]\n", v_item[j].widget->getName()); //pin protected items only if (v_item[j].item_mode == PERSONALIZE_SHOW_AS_ACCESS_OPTION) { @@ -853,7 +853,7 @@ void CPersonalizeGui::addPersonalizedItems() bool add_shortcut = false; //get shortcut - if (fw->iconName.empty() && fw->active ) //if no icon is defined and item is active, allow to generate a shortcut, + if (d_key == CRCInput::RC_nokey && fw->active ) //if no icon is defined and item is active, allow to generate a shortcut, { add_shortcut = true; d_key = getShortcut(short_cut); @@ -875,7 +875,7 @@ void CPersonalizeGui::addPersonalizedItems() //convert item to locked forwarder and use generated pin mode for usage as ask parameter v_item[i].menuItem = new CLockedMenuForwarder(fw->getTextLocale(), g_settings.easymenu ? g_settings.parentallock_pincode : g_settings.personalize_pincode, - use_pin, fw->active, NULL, fw->getTarget(), fw->getActionKey(), d_key, fw->iconName.c_str(), lock_icon); + use_pin, fw->active, NULL, fw->getTarget(), fw->getActionKey(), d_key, NULL, lock_icon); v_item[i].menuItem->hintIcon = fw->hintIcon; v_item[i].menuItem->hint = fw->hint; //add item if it's set to visible or pin protected and allow to add an forwarder as next diff --git a/src/gui/scan_setup.cpp b/src/gui/scan_setup.cpp index 7728fbf56..03ba13859 100644 --- a/src/gui/scan_setup.cpp +++ b/src/gui/scan_setup.cpp @@ -659,7 +659,7 @@ int CScanSetup::showScanMenuFrontendSetup() mf->setHint("", LOCALE_MENU_HINT_SCAN_LONGITUDE); rotorMenu->addItem(mf); - nc = new CMenuOptionNumberChooser(LOCALE_SATSETUP_USALS_REPEAT, (int *)&zapitCfg.repeatUsals, true, 0, 10, NULL, 0, 0, LOCALE_OPTIONS_OFF); + nc = new CMenuOptionNumberChooser(LOCALE_SATSETUP_USALS_REPEAT, (int *)&zapitCfg.repeatUsals, true, 0, 10, NULL, CRCInput::convertDigitToKey(shortcut++), NULL, 0, 0, LOCALE_OPTIONS_OFF); nc->setHint("", LOCALE_MENU_HINT_SCAN_USALS_REPEAT); rotorMenu->addItem(nc); @@ -1142,13 +1142,13 @@ void CScanSetup::addScanMenuTempSat(CMenuWidget *temp_sat, sat_config_t & satcon bool unicable = (dmode == DISEQC_UNICABLE); if (!unicable) { - diseqc = new CMenuOptionNumberChooser(LOCALE_SATSETUP_DISEQC_INPUT, &satconfig.diseqc, ((dmode != NO_DISEQC) && (dmode != DISEQC_ADVANCED)), -1, 15, this, 1, -1, LOCALE_OPTIONS_OFF); + diseqc = new CMenuOptionNumberChooser(LOCALE_SATSETUP_DISEQC_INPUT, &satconfig.diseqc, ((dmode != NO_DISEQC) && (dmode != DISEQC_ADVANCED)), -1, 15, this, CRCInput::RC_nokey, NULL, 1, -1, LOCALE_OPTIONS_OFF); diseqc->setHint("", LOCALE_MENU_HINT_SCAN_DISEQC); - comm = new CMenuOptionNumberChooser(LOCALE_SATSETUP_COMM_INPUT, &satconfig.commited, dmode == DISEQC_ADVANCED, -1, 15, NULL, 1, -1, LOCALE_OPTIONS_OFF); + comm = new CMenuOptionNumberChooser(LOCALE_SATSETUP_COMM_INPUT, &satconfig.commited, dmode == DISEQC_ADVANCED, -1, 15, NULL, CRCInput::RC_nokey, NULL, 1, -1, LOCALE_OPTIONS_OFF); comm->setHint("", LOCALE_MENU_HINT_SCAN_COMMITED); - uncomm = new CMenuOptionNumberChooser(LOCALE_SATSETUP_UNCOMM_INPUT, &satconfig.uncommited, dmode == DISEQC_ADVANCED, -1, 15, NULL, 1, -1, LOCALE_OPTIONS_OFF); + uncomm = new CMenuOptionNumberChooser(LOCALE_SATSETUP_UNCOMM_INPUT, &satconfig.uncommited, dmode == DISEQC_ADVANCED, -1, 15, NULL, CRCInput::RC_nokey, NULL, 1, -1, LOCALE_OPTIONS_OFF); uncomm->setHint("", LOCALE_MENU_HINT_SCAN_UNCOMMITED); - motor = new CMenuOptionNumberChooser(LOCALE_SATSETUP_MOTOR_POS, &satconfig.motor_position, true /*dmode == DISEQC_ADVANCED*/, 0, 64, this, 0, 0, LOCALE_OPTIONS_OFF); + motor = new CMenuOptionNumberChooser(LOCALE_SATSETUP_MOTOR_POS, &satconfig.motor_position, true /*dmode == DISEQC_ADVANCED*/, 0, 64, this, CRCInput::RC_nokey, NULL, 0, 0, LOCALE_OPTIONS_OFF); motor->setHint("", LOCALE_MENU_HINT_SCAN_MOTORPOS); usals = new CMenuOptionChooser(LOCALE_EXTRA_USE_GOTOXX, &satconfig.use_usals, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true /*dmode == DISEQC_ADVANCED*/); usals->setHint("", LOCALE_MENU_HINT_SCAN_USEUSALS); @@ -1336,7 +1336,7 @@ int CScanSetup::showFastscanDiseqcSetup() continue; std::string satname = CServiceManager::getInstance()->GetSatelliteName(sit->first); - CMenuOptionNumberChooser *diseqc = new CMenuOptionNumberChooser(satname, &sit->second.diseqc, true, -1, 15, this, 1, -1, LOCALE_OPTIONS_OFF); + CMenuOptionNumberChooser *diseqc = new CMenuOptionNumberChooser(satname, &sit->second.diseqc, true, -1, 15, this, CRCInput::RC_nokey, NULL, 1, -1, LOCALE_OPTIONS_OFF); sat_setup->addItem(diseqc); } sat_setup->addItem(GenericMenuSeparatorLine); diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index dbbe7eff6..8209599d2 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -448,7 +448,7 @@ void CTimerList::updateEvents(void) theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); fheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); //get footerHeight from paintButtons - footerHeight = ::paintButtons(0, 0, 0, TimerListButtonsCount, TimerListButtons, 0, 0, "", false, COL_INFOBAR_SHADOW_TEXT, NULL, 0, false); + footerHeight = ::paintButtons(TimerListButtons, TimerListButtonsCount, 0, 0, 0, 0, 0, false); width = w_max(g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getWidth()*56, 20); height = frameBuffer->getScreenHeight() - (2*theight); // max height diff --git a/src/gui/vfd_setup.cpp b/src/gui/vfd_setup.cpp index c170778eb..09d1259b0 100644 --- a/src/gui/vfd_setup.cpp +++ b/src/gui/vfd_setup.cpp @@ -169,20 +169,20 @@ void CVfdSetup::showBrightnessSetup(CMenuWidget *mn_widget) brightnessstandby = CVFD::getInstance()->getBrightnessStandby(); brightnessdeepstandby = CVFD::getInstance()->getBrightnessDeepStandby(); - nc = new CMenuOptionNumberChooser(LOCALE_LCDCONTROLER_BRIGHTNESS, &brightness, true, 0, 15, this, 0, 0, NONEXISTANT_LOCALE, true); + nc = new CMenuOptionNumberChooser(LOCALE_LCDCONTROLER_BRIGHTNESS, &brightness, true, 0, 15, this, CRCInput::RC_nokey, NULL, 0, 0, NONEXISTANT_LOCALE, true); nc->setHint("", LOCALE_MENU_HINT_VFD_BRIGHTNESS); mn_widget->addItem(nc); - nc = new CMenuOptionNumberChooser(LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY, &brightnessstandby, true, 0, 15, this, 0, 0, NONEXISTANT_LOCALE, true); + nc = new CMenuOptionNumberChooser(LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY, &brightnessstandby, true, 0, 15, this, CRCInput::RC_nokey, NULL, 0, 0, NONEXISTANT_LOCALE, true); nc->setHint("", LOCALE_MENU_HINT_VFD_BRIGHTNESSSTANDBY); mn_widget->addItem(nc); if(cs_get_revision() > 7) { - nc = new CMenuOptionNumberChooser(LOCALE_LCDCONTROLER_BRIGHTNESSDEEPSTANDBY, &brightnessdeepstandby, true, 0, 15, this, 0, 0, NONEXISTANT_LOCALE, true); + nc = new CMenuOptionNumberChooser(LOCALE_LCDCONTROLER_BRIGHTNESSDEEPSTANDBY, &brightnessdeepstandby, true, 0, 15, this, CRCInput::RC_nokey, NULL, 0, 0, NONEXISTANT_LOCALE, true); nc->setHint("", LOCALE_MENU_HINT_VFD_BRIGHTNESSDEEPSTANDBY); mn_widget->addItem(nc); } - nc = new CMenuOptionNumberChooser(LOCALE_LCDMENU_DIM_BRIGHTNESS, &g_settings.lcd_setting_dim_brightness, vfd_enabled, -1, 15, NULL, 0, -1, LOCALE_OPTIONS_OFF, true); + nc = new CMenuOptionNumberChooser(LOCALE_LCDMENU_DIM_BRIGHTNESS, &g_settings.lcd_setting_dim_brightness, vfd_enabled, -1, 15, NULL, CRCInput::RC_nokey, NULL, 0, -1, LOCALE_OPTIONS_OFF, true); nc->setHint("", LOCALE_MENU_HINT_VFD_BRIGHTNESSDIM); mn_widget->addItem(nc); diff --git a/src/gui/widget/buttons.cpp b/src/gui/widget/buttons.cpp index 9843b48f5..4134eb0a8 100644 --- a/src/gui/widget/buttons.cpp +++ b/src/gui/widget/buttons.cpp @@ -30,7 +30,7 @@ #include #include #include -//#include +// #include @@ -50,33 +50,55 @@ * maxwidth maximum horizontal space for the buttons * footerheight set height of buttonbar as similar to footer, value 0 (default) means: value calculates automaticly depends of maximal height of icon and caption - - * stuff below here was obviously not tested recently - * vertical_paint optional, default value is false (horizontal) sets direction of painted buttons - * fcolor optional, default value is COL_INFOBAR_SHADOW_TEXT, use it to render font with other color - * alt_buttontext optional, default NULL, overwrites button caption at definied buttonlabel id (see parameter alt_buttontext_id) with this text - * alt_buttontext_id optional, default 0, means id from buttonlable struct which text you will change - * show optional, default value is true (show button), if false, then no show and return the height of the button. + * show optional, default value is true (show button), if false, then no show and return the height of the button. */ -int paintButtons( const int &x, +int paintButtons( const int &x, + const int &y, + const int &footerwidth, + const int &count, + const button_label * const content, + const int &maxwidth, + const int &footerheight) { + return paintButtons(content, count, x, y, footerwidth, footerheight, maxwidth, true, NULL, NULL); +}; + +int paintButtons( const button_label * const content, + const int &count, + const int &x, const int &y, const int &footerwidth, - const uint &count, - const struct button_label * const content, - const int &maxwidth, const int &footerheight, - std::string /* just to make sure nobody uses anything below */, - bool vertical_paint, - const uint32_t fcolor, - const char * alt_buttontext, - const uint &buttontext_id, + const int &maxwidth, bool show, - const std::vector& /*all_buttontext_id*/) + int *wantedwidth, + int *wantedheight) +{ + button_label_ext content_ext[count]; + for (int i = 0; i < count; i++) { + content_ext[i].button = content[i].button; + content_ext[i].locale = content[i].locale; + content_ext[i].text = NULL; + content_ext[i].width = 0; + content_ext[i].maximize = false; + } + return paintButtons(content_ext, count, x, y, footerwidth, footerheight, maxwidth, show, wantedwidth, wantedheight); +} + +int paintButtons( const button_label_ext * const content, + const int &count, + const int &x, + const int &y, + const int &footerwidth, + const int &footerheight, + const int &maxwidth, + bool show, + int *wantedwidth, + int *wantedheight) { CFrameBuffer *frameBuffer = CFrameBuffer::getInstance(); Font * font = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]; - uint cnt = count; + int cnt = count; int x_footer = x; int y_footer = y; int w_footer = footerwidth; @@ -107,6 +129,211 @@ int paintButtons( const int &x, int fwidth[16]; const char *buttontext[16]; + /* sanity check... */ + if (count > 16 || count == 0) + { + fprintf(stderr, "paintButtons does only support max 16 buttons yet (%d)\n", count); +// print_stacktrace(); + return 0; + } + if (maxwidth < 200 && show) + { + fprintf(stderr, "paintButtons: maxwidth very small\n"); + fprintf(stderr, " x: %d y: %d footw: %d count: %d maxw: %d footh: %d\n ", + x, y, footerwidth, count, maxwidth, footerheight); +// print_stacktrace(); + } + + bool maximize = false; + for (int i = 0; i < cnt; i++) + maximize |= content[i].maximize; + + for (int i = 0; i < cnt; i++) + { + //icon + int w = 0; + int h = 0; + frameBuffer->getIconSize(content[i].button, &w, &h); + iconw[i] = w; + iconh[i] = h; + h_max_icon = std::max(h_max_icon, h); + w_icons += w; + if (w) + count_icons++; + + if (content[i].text) { + buttontext[i] = content[i].text; + fwidth[i] = std::max(content[i].width, font->getRenderWidth(buttontext[i])); + w_text += fwidth[i]; + count_labels++; + } else if (content[i].locale) { + buttontext[i] = g_Locale->getText(content[i].locale); + fwidth[i] = std::max(content[i].width, font->getRenderWidth(buttontext[i])); + w_text += fwidth[i]; + count_labels++; + } else { + buttontext[i] = ""; + fwidth[i] = 0; + } + if (maximize && i < cnt - 1) + fwidth[i] += w, w_text += w; + } + + //calculate button heigth + h_button = std::max(h_max_icon, h_max_text); //calculate optimal button height + + //calculate footer heigth + h_footer = footerheight == 0 ? (h_button + 2*h_space) : footerheight; + + if (!show) { + if (wantedheight) + *wantedheight = h_button + 2*h_space; + if (wantedwidth) + *wantedwidth = w_space * 2 + w_text + w_icons + (count_icons + count_labels - 1) * h_space; + return h_footer; + } + + //paint footer + if (w_footer > 0) + frameBuffer->paintBoxRel(x_footer, y_footer, w_footer, h_footer, COL_INFOBAR_SHADOW_PLUS_1, RADIUS_LARGE, CORNER_BOTTOM); //round + + + //baseline + int y_base = y_footer + h_footer/2; + int spacing = maxwidth - w_space * 2 - w_text - w_icons - (count_icons + count_labels - 1) * h_space; +#if 0 + /* debug */ + fprintf(stderr, "PB: sp %d mw %d w_t %d w_i %d w_s %d c_i %d\n", + spacing, maxwidth, w_text, w_icons, w_space, count_items); +#endif + if (fwidth[cnt - 1] == 0) /* divisor needs to be labels+1 unless rightmost icon has a label */ + count_labels++; /* side effect: we don't try to divide by 0 :-) */ + + if (maximize) { + while (spacing > 0) { + for (int i = 0; i < cnt && spacing > 0; i++) { + if (content[i].maximize) { + fwidth[i]++; + spacing--; + } + } + } + } + + if (spacing >= 0) + { /* add half of the inter-object space to the */ + spacing /= count_labels; /* left and right (this might break vertical */ + x_button += spacing / 2; /* alignment, but nobody is using this (yet) */ + } /* and I'm don't know how it should work. */ + else + { + /* shorten captions relative to their length */ + for (int i = 0; i < cnt; i++) + fwidth[i] = (fwidth[i] * (w_text + spacing)) / w_text; /* spacing is negative...*/ + spacing = 0; + } + + for (int j = 0; j < cnt; j++) + { + const char * caption = NULL; + //set caption... + caption = buttontext[j]; + + const char * icon = content[j].button ? content[j].button : ""; + + // calculate baseline startposition of icon and text in y + int y_caption = y_base + h_max_text/2+1; + + // paint icon and text + frameBuffer->paintIcon(icon, x_button , y_base - iconh[j]/2); + x_caption = x_button + iconw[j] + h_space; + font->RenderString(x_caption, y_caption, fwidth[j], caption, COL_INFOBAR_SHADOW_TEXT); + + /* set next startposition x, if text is length=0 then offset is =renderwidth of icon, + * for generating buttons without captions, + */ + + /* increase x position */ + x_button = x_caption; + if (fwidth[j]) + x_button += fwidth[j] + spacing + h_space; + } + + return h_footer; +} + +/* paintButtons usage, + use this function for painting icons with captions in horizontal or vertical direction. + Icons automatically use the available maxwidth. + If not enough space is available, captions are shortened. + If there is extra space, space between icons is increased. + + * x set horizontal startposition + * y set vertical startposition + * footerwidth set width of buttonbar as similar to footer, value 0 (default) means: do nothing, + then paint it extra + * count set count of buttons + * content set struct buttonlabel with iconfile and locales, for an empty text let locale + constant empty, so you can paint icons without captions, + * maxwidth maximum horizontal space for the buttons + * footerheight set height of buttonbar as similar to footer, value 0 (default) means: + value calculates automaticly depends of maximal height of icon and caption + + * stuff below here was obviously not tested recently + * vertical_paint optional, default value is false (horizontal) sets direction of painted buttons + * fcolor optional, default value is COL_INFOBAR_SHADOW_TEXT, use it to render font with other color + * alt_buttontext optional, default NULL, overwrites button caption at definied buttonlabel id (see parameter alt_buttontext_id) with this text + * alt_buttontext_id optional, default 0, means id from buttonlable struct which text you will change + * show optional, default value is true (show button), if false, then no show and return the height of the button. + */ + +int paintButtons( const int &x, + const int &y, + const int &footerwidth, + const uint &count, + const struct button_label * const content, + const int &maxwidth, + const int &footerheight, + std::string /* just to make sure nobody uses anything below */, + bool vertical_paint, + const uint32_t fcolor, + const char * alt_buttontext, + const uint &buttontext_id, + bool show, + const std::vector& /*all_buttontext_id*/) +{ + CFrameBuffer *frameBuffer = CFrameBuffer::getInstance(); + Font * font = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]; + uint cnt = count; + int x_footer = x; + int y_footer = y; + int w_footer = footerwidth; + int h_footer = 0; + + int w_space = 10; //minimal space between buttons + int h_space = 4; //minimal space between caption and/or icon and border + int x_icon = x_footer + w_space; + int x_caption = 0; + + int x_button = x_icon; + int h_button = 0; + + //calculate max of h + w + //icon + int h_max_icon = 0; + int w_icons = 0; + + //text + int w_text = 0; + int h_max_text = font->getHeight(); + int count_icons = 0; + int count_labels = 0; + /* more than 16 buttons? noooooo*/ + int iconw[16]; + int iconh[16]; + int fwidth[16]; + const char *buttontext[16]; + /* sanity check... */ if (count > 16 || count == 0) { @@ -139,7 +366,7 @@ int paintButtons( const int &x, if (content[i].locale) { buttontext[i] = g_Locale->getText(content[i].locale); //text width - if (alt_buttontext != NULL && i == buttontext_id) + if (alt_buttontext != NULL && i == buttontext_id) fwidth[i] = font->getRenderWidth(alt_buttontext); //...with an alternate buttontext else fwidth[i] = font->getRenderWidth(buttontext[i]); @@ -153,7 +380,7 @@ int paintButtons( const int &x, //calculate button heigth h_button = std::max(h_max_icon, h_max_text); //calculate optimal button height - + //calculate footer heigth h_footer = footerheight == 0 ? (h_button + 2*h_space) : footerheight; @@ -164,22 +391,22 @@ int paintButtons( const int &x, if (w_footer > 0) frameBuffer->paintBoxRel(x_footer, y_footer, w_footer, h_footer, COL_INFOBAR_SHADOW_PLUS_1, RADIUS_LARGE, CORNER_BOTTOM); //round - + //baseline int y_base = y_footer + h_footer/2; int spacing = maxwidth - w_space * 2 - w_text - w_icons - (count_icons + count_labels - 1) * h_space; #if 0 /* debug */ fprintf(stderr, "PB: sp %d mw %d w_t %d w_i %d w_s %d c_i %d\n", - spacing, maxwidth, w_text, w_icons, w_space, count_items); + spacing, maxwidth, w_text, w_icons, w_space, count_items); #endif if (fwidth[cnt - 1] == 0) /* divisor needs to be labels+1 unless rightmost icon has a label */ count_labels++; /* side effect: we don't try to divide by 0 :-) */ if (spacing >= 0) - { /* add half of the inter-object space to the */ + { /* add half of the inter-object space to the */ spacing /= count_labels; /* left and right (this might break vertical */ x_button += spacing / 2; /* alignment, but nobody is using this (yet) */ - } /* and I'm don't know how it should work. */ + } /* and I'm don't know how it should work. */ else { /* shorten captions relative to their length */ @@ -192,7 +419,7 @@ int paintButtons( const int &x, { const char * caption = NULL; //set caption... - if (alt_buttontext != NULL && j == buttontext_id) + if (alt_buttontext != NULL && j == buttontext_id) caption = alt_buttontext; //...with an alternate buttontext else caption = buttontext[j]; @@ -200,30 +427,30 @@ int paintButtons( const int &x, const char * icon = content[j].button ? content[j].button : ""; // calculate baseline startposition of icon and text in y - int y_caption = y_base + h_max_text/2+1; - + int y_caption = y_base + h_max_text/2+1; + // paint icon and text frameBuffer->paintIcon(icon, x_button , y_base - iconh[j]/2); x_caption = x_button + iconw[j] + h_space; font->RenderString(x_caption, y_caption, fwidth[j], caption, fcolor); - - /* set next startposition x, if text is length=0 then offset is =renderwidth of icon, - * for generating buttons without captions, - */ - - int lentext = strlen(caption); - if (vertical_paint) - // set x_icon for painting buttons with vertical arrangement + + /* set next startposition x, if text is length=0 then offset is =renderwidth of icon, + * for generating buttons without captions, + */ + + int lentext = strlen(caption); + if (vertical_paint) + // set x_icon for painting buttons with vertical arrangement { - if (lentext !=0) - { - x_button = x; - y_base += h_footer; - } - else - { - x_button = x_caption; - } + if (lentext !=0) + { + x_button = x; + y_base += h_footer; + } + else + { + x_button = x_caption; + } } else { @@ -231,7 +458,7 @@ int paintButtons( const int &x, x_button = x_caption; if (fwidth[j]) x_button += fwidth[j] + spacing + h_space; - } + } } return h_footer; diff --git a/src/gui/widget/buttons.h b/src/gui/widget/buttons.h index f988dcfae..ad52669b2 100644 --- a/src/gui/widget/buttons.h +++ b/src/gui/widget/buttons.h @@ -29,25 +29,64 @@ #include -typedef struct button_label +struct button_label { const char * button; neutrino_locale_t locale; -} button_label_struct; +}; + +struct button_label_ext +{ + const char * button; + neutrino_locale_t locale; + const char * text; + int width; + bool maximize; +}; + +int paintButtons( const button_label * const content, + const int &count, + const int &x, + const int &y, + const int &footerheight, + const int &footerwidth, + const int &maxwidth, + bool show = true, + int *wantedwidth = NULL, + int *wantedheight = NULL); + +int paintButtons( const button_label_ext * const content, + const int &count, + const int &x, + const int &y, + const int &footerheight, + const int &footerwidth, + const int &maxwidth, + bool show = true, + int *wantedwidth = NULL, + int *wantedheight = NULL); int paintButtons( const int &x, const int &y, const int &footerwidth, - const uint &count, - const struct button_label * const content, + const int &count, + const button_label * const content, const int &maxwidth, - const int &footerheight = 0, - std::string tmp = "", /* just to make sure compilation breaks */ - bool vertical_paint = false, - const uint32_t fcolor = COL_INFOBAR_SHADOW_TEXT, - const char * alt_buttontext = NULL, - const uint &buttontext_id = 0, - bool show = true, - const std::vector& all_buttontext_id = std::vector()); + const int &footerheight = 0); + +int paintButtons( const int &x, + const int &y, + const int &footerwidth, + const uint &count, + const struct button_label * const content, + const int &maxwidth, + const int &footerheight = 0, + std::string tmp = "", /* just to make sure compilation breaks */ + bool vertical_paint = false, + const uint32_t fcolor = COL_INFOBAR_SHADOW_TEXT, + const char * alt_buttontext = NULL, + const uint &buttontext_id = 0, + bool show = true, + const std::vector& all_buttontext_id = std::vector()); #endif /* __gui_widget_buttons_h__ */ diff --git a/src/gui/widget/icons.h b/src/gui/widget/icons.h index 1f7115bf6..6a9be6880 100644 --- a/src/gui/widget/icons.h +++ b/src/gui/widget/icons.h @@ -104,9 +104,13 @@ #define NEUTRINO_ICON_MP3 "mp3" #define NEUTRINO_ICON_MULTIMEDIA "multimedia" #define NEUTRINO_ICON_MOVIEPLAYER "icon_movieplayer" +#define NEUTRINO_ICON_NKPLAY "icon_nkplay" +#define NEUTRINO_ICON_YTPLAY "icon_ytplay" #define NEUTRINO_ICON_NOT_MOUNTED "not_mounted" #define NEUTRINO_ICON_PAUSE "mp_pause" #define NEUTRINO_ICON_PLAY "mp_play" +#define NEUTRINO_ICON_PLAY_REPEAT_ALL "mp_play_repeat_all" +#define NEUTRINO_ICON_PLAY_REPEAT_TRACK "mp_play_repeat_track" #define NEUTRINO_ICON_REW "mp_b-skip" #define NEUTRINO_ICON_FF "mp_f-skip" #define NEUTRINO_ICON_PROTECTING "protecting" @@ -223,6 +227,7 @@ #define NEUTRINO_ICON_HINT_HDD "hint_hdd" #define NEUTRINO_ICON_HINT_KEYS "hint_keys" #define NEUTRINO_ICON_HINT_A_PIC "hint_a_pic" +#define NEUTRINO_ICON_HINT_RASS "hint_rass" #define NEUTRINO_ICON_HINT_COLORS "hint_colors" #define NEUTRINO_ICON_HINT_FONTS "hint_fonts" @@ -249,14 +254,41 @@ #define NEUTRINO_ICON_HINT_FACTORY "hint_factory" /* opkg manager */ -#define NEUTRINO_ICON_CHECKMARK "checkmark" -#define NEUTRINO_ICON_WARNING "warning" +#define NEUTRINO_ICON_CHECKMARK "checkmark" +#define NEUTRINO_ICON_WARNING "warning" + +/* RASS */ +#define NEUTRINO_ICON_RED_0 "0-red" +#define NEUTRINO_ICON_RED_1 "1-red" +#define NEUTRINO_ICON_RED_2 "2-red" +#define NEUTRINO_ICON_RED_3 "3-red" +#define NEUTRINO_ICON_RED_4 "4-red" +#define NEUTRINO_ICON_RED_5 "5-red" +#define NEUTRINO_ICON_RED_6 "6-red" +#define NEUTRINO_ICON_RED_7 "7-red" +#define NEUTRINO_ICON_RED_8 "8-red" +#define NEUTRINO_ICON_RED_9 "9-red" + +#define NEUTRINO_ICON_GREEN_0 "0-green" +#define NEUTRINO_ICON_GREEN_1 "1-green" +#define NEUTRINO_ICON_GREEN_2 "2-green" +#define NEUTRINO_ICON_GREEN_3 "3-green" +#define NEUTRINO_ICON_GREEN_4 "4-green" +#define NEUTRINO_ICON_GREEN_5 "5-green" +#define NEUTRINO_ICON_GREEN_6 "6-green" +#define NEUTRINO_ICON_GREEN_7 "7-green" +#define NEUTRINO_ICON_GREEN_8 "8-green" +#define NEUTRINO_ICON_GREEN_9 "9-green" /* misc */ +#define NEUTRINO_ICON_HINT_NKPLAY "hint_nkplay" #define NEUTRINO_ICON_HINT_YTPLAY "hint_ytplay" +#define NEUTRINO_ICON_HINT_SPARK "hint_spark" #define NEUTRINO_ICON_EPG "epg" +#define NEUTRINO_ICON_BUTTON_LONGPRESS "longpress" + #define NEUTRINO_ICON_VARPATH "/var/share/tuxbox/neutrino/icons/" //alternatively path for user-defined icons #endif /* __gui_widget_icons_h__ */ diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index c0a1c6599..a890e7129 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -39,6 +39,7 @@ #include #include +#include #include #include @@ -55,20 +56,37 @@ CMenuForwarder * const GenericMenuBack = &CGenericMenuBack; CMenuForwarder * const GenericMenuCancel = &CGenericMenuCancel; CMenuForwarder * const GenericMenuNext = &CGenericMenuNext; -CMenuItem::CMenuItem() +CMenuItem::CMenuItem(bool Active, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) { + active = Active; + directKey = DirectKey; + isStatic = IsStatic; + + if (IconName && *IconName) + iconName = IconName; + else + setIconName(); + + if (IconName_Info_right && *IconName_Info_right) + iconName_Info_right = IconName_Info_right; + else + iconName_Info_right = NULL; + + hintIcon = NULL; + x = -1; - directKey = CRCInput::RC_nokey; - iconName = ""; - iconName_Info_right = ""; used = false; icon_frame_w = 10; hint = NONEXISTANT_LOCALE; name = NONEXISTANT_LOCALE; nameString = ""; - isStatic = false; + desc = NONEXISTANT_LOCALE; + descString = ""; marked = false; inert = false; + directKeyOK = true; + selected_iconName = NULL; + height = 0; } void CMenuItem::init(const int X, const int Y, const int DX, const int OFFX) @@ -106,7 +124,7 @@ void CMenuItem::setInert(const bool Inert) paint(); } -void CMenuItem::setItemButton(const std::string& icon_Name, const bool is_select_button) +void CMenuItem::setItemButton(const char * const icon_Name, const bool is_select_button) { if (is_select_button) selected_iconName = icon_Name; @@ -138,14 +156,19 @@ void CMenuItem::initItemColors(const bool select_mode) } } -void CMenuItem::paintItemCaption(const bool select_mode, const int &item_height, const char * left_text, const char * right_text, const fb_pixel_t right_bgcol) +void CMenuItem::paintItemCaption(const bool select_mode, const char * right_text, const fb_pixel_t right_bgcol) { + int item_height = height; + const char *left_text = getName(); + const char *desc_text = getDescription(); + if (select_mode) { - if (right_text != NULL) + if (right_text && *right_text) { - char str[256]; - snprintf(str, 255, "%s %s", left_text, right_text); + ssize_t len = strlen(left_text) + strlen(right_text) + 2; + char str[len]; + snprintf(str, len, "%s %s", left_text, right_text); CVFD::getInstance()->showMenuText(0, str, -1, true); } else @@ -156,18 +179,28 @@ void CMenuItem::paintItemCaption(const bool select_mode, const int &item_height, int _dx = dx; int icon_w = 0; int icon_h = 0; - if (!iconName_Info_right.empty()) { - CFrameBuffer::getInstance()->getIconSize(iconName_Info_right.c_str(), &icon_w, &icon_h); + if (iconName_Info_right) { + CFrameBuffer::getInstance()->getIconSize(iconName_Info_right, &icon_w, &icon_h); if (icon_w) _dx -= icon_frame_w + icon_w; } - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(name_start_x, y+ item_height, _dx- (name_start_x - x), left_text, item_color); + + int desc_height = 0; + if (desc_text && *desc_text) + desc_height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]->getHeight(); + + if (*left_text) + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(name_start_x, y+ item_height - desc_height, _dx- (name_start_x - x), left_text, item_color); //right text if (right_text && (*right_text || right_bgcol)) { int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(right_text); - int stringstartposOption = std::max(name_start_x + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(left_text) + icon_frame_w, x + dx - stringwidth - icon_frame_w); //+ offx + int stringstartposOption; + if (*left_text) + stringstartposOption = std::max(name_start_x + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(left_text) + icon_frame_w, x + dx - stringwidth - icon_frame_w); //+ offx + else + stringstartposOption = name_start_x; if (right_bgcol) { if (!*right_text) stringstartposOption -= 60; @@ -187,9 +220,11 @@ void CMenuItem::paintItemCaption(const bool select_mode, const int &item_height, } if (*right_text) { stringstartposOption -= (icon_w == 0 ? 0 : icon_w + icon_frame_w); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposOption, y+item_height,dx- (stringstartposOption- x), right_text, item_color); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposOption, y+item_height - desc_height, dx- (stringstartposOption- x), right_text, item_color); } } + if (desc_text && *desc_text) + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]->RenderString(name_start_x + 10, y+ item_height, _dx- 10 - (name_start_x - x), desc_text, item_color); } void CMenuItem::prepareItem(const bool select_mode, const int &item_height) @@ -198,7 +233,8 @@ void CMenuItem::prepareItem(const bool select_mode, const int &item_height) initItemColors(select_mode); //paint item background - CFrameBuffer::getInstance()->paintBoxRel(x, y, dx, item_height, item_bgcolor, RADIUS_LARGE); + CFrameBuffer *frameBuffer = CFrameBuffer::getInstance(); + frameBuffer->paintBoxRel(x, y, dx, item_height, item_bgcolor, RADIUS_LARGE); } void CMenuItem::paintItemSlider( const bool select_mode, const int &item_height, const int &optionvalue, const int &factor, const char * left_text, const char * right_text) @@ -210,14 +246,13 @@ void CMenuItem::paintItemSlider( const bool select_mode, const int &item_height, return; int stringwidth = 0; if (right_text != NULL) { - stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("U999") ; + stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("U999"); } int stringwidth2 = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(left_text); int maxspace = dx - stringwidth - icon_frame_w - stringwidth2 - 10; - if(maxspace < slider_lenght){ + if(maxspace < slider_lenght) return ; - } int stringstartposOption = x + dx - stringwidth - slider_lenght; int optionV = (optionvalue < 0) ? 0 : optionvalue; @@ -226,54 +261,60 @@ void CMenuItem::paintItemSlider( const bool select_mode, const int &item_height, frameBuffer->paintIcon(select_mode ? NEUTRINO_ICON_VOLUMESLIDER2BLUE : NEUTRINO_ICON_VOLUMESLIDER2, (stringstartposOption + (optionV * 100 / factor)), y+item_height/4); } -void CMenuItem::paintItemButton(const bool select_mode, const int &item_height, const std::string &icon_Name) +void CMenuItem::paintItemButton(const bool select_mode, int item_height, const char * const icon_Name) { + item_height -= getDescriptionHeight(); + CFrameBuffer *frameBuffer = CFrameBuffer::getInstance(); bool selected = select_mode; bool icon_painted = false; - std::string icon_name = iconName; + const char *icon_name = iconName; int icon_w = 0; int icon_h = 0; //define icon name depends of numeric value - if (icon_name.empty() && CRCInput::isNumeric(directKey)) - { - char i_name[6]; /* X +'\0' */ - snprintf(i_name, 6, "%d", CRCInput::getNumericValue(directKey)); - i_name[5] = '\0'; /* even if snprintf truncated the string, ensure termination */ - icon_name = i_name; - } - + bool isNumeric = CRCInput::isNumeric(directKey); +#if 0 + if (isNumeric && !g_settings.menu_numbers_as_icons) + icon_name = NULL; +#endif //define select icon - if (selected && offx > 0) + if (selected && offx > 0) { - if (!selected_iconName.empty()) + if (selected_iconName) icon_name = selected_iconName; - else if (icon_name.empty() && !CRCInput::isNumeric(directKey)) + else if (!(icon_name && *icon_name) && !isNumeric) icon_name = icon_Name; } - int icon_x = 0; int icon_start_x = x+icon_frame_w; //start of icon space int icon_space_x = name_start_x - icon_frame_w - icon_start_x; //size of space where to paint icon int icon_space_mid = icon_start_x + icon_space_x/2; //get data of number icon and paint - if (!icon_name.empty()) + if (icon_name && *icon_name) { - frameBuffer->getIconSize(icon_name.c_str(), &icon_w, &icon_h); + frameBuffer->getIconSize(icon_name, &icon_w, &icon_h); - if (active && icon_w>0 && icon_h>0 && icon_space_x >= icon_w) + if (/*active &&*/ icon_w>0 && icon_h>0 && icon_space_x >= icon_w) { - icon_x = icon_space_mid - (icon_w/2); - - icon_painted = frameBuffer->paintIcon(icon_name, icon_x, y+ ((item_height/2- icon_h/2)) ); + int icon_x = icon_space_mid - icon_w/2; + int icon_y = y + item_height/2 - icon_h/2; + icon_painted = frameBuffer->paintIcon(icon_name, icon_x, icon_y); + if (icon_painted && (directKey != CRCInput::RC_nokey) && (directKey & CRCInput::RC_Repeat)) { + static int longpress_icon_w = 0, longpress_icon_h = 0; + if (!longpress_icon_w) + frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_LONGPRESS, &longpress_icon_w, &longpress_icon_h); + frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_LONGPRESS, + std::min(icon_x + icon_w - longpress_icon_w/2, name_start_x - longpress_icon_w), + std::min(icon_y + icon_h - longpress_icon_h/2, y + item_height - longpress_icon_h)); + } } } //paint only number if no icon was painted and keyval is numeric - if (active && CRCInput::isNumeric(directKey) && !icon_painted) + if (active && isNumeric && !icon_painted) { int number_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(CRCInput::getKeyName(directKey)); @@ -283,15 +324,94 @@ void CMenuItem::paintItemButton(const bool select_mode, const int &item_height, } //get data of number right info icon and paint - if (!iconName_Info_right.empty()) + if (iconName_Info_right) { - frameBuffer->getIconSize(iconName_Info_right.c_str(), &icon_w, &icon_h); + frameBuffer->getIconSize(iconName_Info_right, &icon_w, &icon_h); - if (/* active && */ icon_w>0 && icon_h>0) + if (icon_w>0 && icon_h>0) + { icon_painted = frameBuffer->paintIcon(iconName_Info_right, dx + icon_start_x - (icon_w + 20), y+ ((item_height/2- icon_h/2)) ); + } } } +void CMenuItem::setIconName() +{ + iconName = NULL; + + switch (directKey & ~CRCInput::RC_Repeat) { + case CRCInput::RC_red: + iconName = NEUTRINO_ICON_BUTTON_RED; + break; + case CRCInput::RC_green: + iconName = NEUTRINO_ICON_BUTTON_GREEN; + break; + case CRCInput::RC_yellow: + iconName = NEUTRINO_ICON_BUTTON_YELLOW; + break; + case CRCInput::RC_blue: + iconName = NEUTRINO_ICON_BUTTON_BLUE; + break; + case CRCInput::RC_standby: + iconName = NEUTRINO_ICON_BUTTON_POWER; + break; + case CRCInput::RC_setup: + iconName = NEUTRINO_ICON_BUTTON_MENU_SMALL; + break; + case CRCInput::RC_help: + iconName = NEUTRINO_ICON_BUTTON_HELP_SMALL; + break; + case CRCInput::RC_info: + iconName = NEUTRINO_ICON_BUTTON_INFO_SMALL; + break; + case CRCInput::RC_stop: + iconName = NEUTRINO_ICON_BUTTON_STOP; + break; + case CRCInput::RC_0: + iconName = NEUTRINO_ICON_BUTTON_0; + break; + case CRCInput::RC_1: + iconName = NEUTRINO_ICON_BUTTON_1; + break; + case CRCInput::RC_2: + iconName = NEUTRINO_ICON_BUTTON_2; + break; + case CRCInput::RC_3: + iconName = NEUTRINO_ICON_BUTTON_3; + break; + case CRCInput::RC_4: + iconName = NEUTRINO_ICON_BUTTON_4; + break; + case CRCInput::RC_5: + iconName = NEUTRINO_ICON_BUTTON_5; + break; + case CRCInput::RC_6: + iconName = NEUTRINO_ICON_BUTTON_6; + break; + case CRCInput::RC_7: + iconName = NEUTRINO_ICON_BUTTON_7; + break; + case CRCInput::RC_8: + iconName = NEUTRINO_ICON_BUTTON_8; + break; + case CRCInput::RC_9: + iconName = NEUTRINO_ICON_BUTTON_9; + break; + } +} + +void CMenuItem::setName(const std::string& t) +{ + name = NONEXISTANT_LOCALE; + nameString = t; +} + +void CMenuItem::setName(const neutrino_locale_t t) +{ + name = t; + nameString = ""; +} + const char *CMenuItem::getName(void) { if (name != NONEXISTANT_LOCALE) @@ -299,6 +419,40 @@ const char *CMenuItem::getName(void) return nameString.c_str(); } +void CMenuItem::setDescription(const std::string& t) +{ + desc = NONEXISTANT_LOCALE; + descString = t; + getHeight(); +} + +void CMenuItem::setDescription(const neutrino_locale_t t) +{ + desc = t; + descString = ""; + getHeight(); +} + +const char *CMenuItem::getDescription(void) +{ + if (desc != NONEXISTANT_LOCALE) + return g_Locale->getText(desc); + return descString.c_str(); +} + +int CMenuItem::getDescriptionHeight(void) +{ + if (*getDescription()) + return g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]->getHeight(); + return 0; +} + +int CMenuItem::getHeight(void) +{ + height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight() + getDescriptionHeight(); + return height; +} + //small helper class to manage values e.g.: handling needed but deallocated widget objects CMenuGlobal::CMenuGlobal() { @@ -325,45 +479,44 @@ CMenuGlobal* CMenuGlobal::getInstance() CMenuWidget::CMenuWidget() { - nameString = g_Locale->getText(NONEXISTANT_LOCALE); + nameString = g_Locale->getText(NONEXISTANT_LOCALE); name = NONEXISTANT_LOCALE; - iconfile = ""; - selected = -1; - iconOffset = 0; + iconfile = ""; + selected = -1; + iconOffset = 0; offx = offy = 0; from_wizard = false; fade = true; sb_width = 0; - sb_height = 0; savescreen = false; background = NULL; preselected = -1; - details_line = NULL; - info_box = NULL; + details_line = NULL; + info_box = NULL; show_details_line = true; } CMenuWidget::CMenuWidget(const neutrino_locale_t Name, const std::string & Icon, const int mwidth, const mn_widget_id_t &w_index) { name = Name; - nameString = g_Locale->getText(Name); + nameString = g_Locale->getText(Name); preselected = -1; Init(Icon, mwidth, w_index); } -CMenuWidget::CMenuWidget(const char* Name, const std::string & Icon, const int mwidth, const mn_widget_id_t &w_index) +CMenuWidget::CMenuWidget(const std::string &Name, const std::string & Icon, const int mwidth, const mn_widget_id_t &w_index) { name = NONEXISTANT_LOCALE; - nameString = Name; + nameString = Name; preselected = -1; Init(Icon, mwidth, w_index); } -void CMenuWidget::Init(const std::string & Icon, const int mwidth, const mn_widget_id_t &w_index) +void CMenuWidget::Init(const std::string &Icon, const int mwidth, const mn_widget_id_t &w_index) { mglobal = CMenuGlobal::getInstance(); //create CMenuGlobal instance only here - frameBuffer = CFrameBuffer::getInstance(); - iconfile = Icon; + frameBuffer = CFrameBuffer::getInstance(); + iconfile = Icon; details_line = new CComponentsDetailLine(); show_details_line = true; info_box = new CComponentsInfoBox(); @@ -379,9 +532,6 @@ void CMenuWidget::Init(const std::string & Icon, const int mwidth, const mn_widg widget_index = w_index; } - //set default preselected if value = -1 (no selected). If value has changed, e.g. with setSelected(), then use current value - preselected = preselected != -1 ? preselected : -1; - //overwrite preselected value with global select value selected = (widget_index == NO_WIDGET_ID ? preselected : mglobal->v_selected[widget_index]); @@ -401,7 +551,7 @@ void CMenuWidget::Init(const std::string & Icon, const int mwidth, const mn_widg min_width = frameBuffer->getScreenWidth(); } - current_page = 0; + current_page = 0; offx = offy = 0; from_wizard = false; fade = true; @@ -410,9 +560,9 @@ void CMenuWidget::Init(const std::string & Icon, const int mwidth, const mn_widg has_hints = false; hint_painted = false; hint_height = 0; - hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); fbutton_count = 0; fbutton_labels = NULL; + fbutton_width = 0; fbutton_height = 0; } @@ -450,10 +600,8 @@ void CMenuWidget::resetWidget(bool delete_items) { for(unsigned int count=0;countisStatic && delete_items) { + if (delete_items && !item->isStatic) delete item; - item = NULL; - } } items.clear(); @@ -469,6 +617,10 @@ void CMenuWidget::insertItem(const uint& item_id, CMenuItem* menuItem) void CMenuWidget::removeItem(const uint& item_id) { items.erase(items.begin()+item_id); + if ((unsigned int) selected >= items.size()) + selected = items.size() - 1; + while (selected > 0 && !items[selected]->active) + selected--; } bool CMenuWidget::hasItem() @@ -479,35 +631,29 @@ bool CMenuWidget::hasItem() int CMenuWidget::getItemId(CMenuItem* menuItem) { for (uint i= 0; i< items.size(); i++) - { if (items[i] == menuItem) return i; - } - return -1; } CMenuItem* CMenuWidget::getItem(const uint& item_id) { for (uint i= 0; i< items.size(); i++) - { if (i == item_id) return items[i]; - } - return NULL; } -std::string CMenuWidget::getName() +const char *CMenuWidget::getName() { if (name != NONEXISTANT_LOCALE) - nameString = g_Locale->getText(name); - return nameString; + return g_Locale->getText(name); + return nameString.c_str(); } int CMenuWidget::exec(CMenuTarget* parent, const std::string &) { - neutrino_msg_t msg; + neutrino_msg_t msg; neutrino_msg_data_t data; bool bAllowRepeatLR = false; CVFD::MODES oldLcdMode = CVFD::getInstance()->getMode(); @@ -515,9 +661,8 @@ int CMenuWidget::exec(CMenuTarget* parent, const std::string &) int pos = 0; if (selected > 0 && selected < (int)items.size()) pos = selected; - else if (selected >= (int)items.size()) + else selected = -1; - exit_pressed = false; frameBuffer->Lock(); @@ -550,12 +695,16 @@ int CMenuWidget::exec(CMenuTarget* parent, const std::string &) saveScreen(); } paint(); + frameBuffer->blit(); + int retval = menu_return::RETURN_REPAINT; uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]); + bool bAllowRepeatLR_override = keyActionMap.find(CRCInput::RC_left) != keyActionMap.end() || keyActionMap.find(CRCInput::RC_right) != keyActionMap.end(); do { if(hasItem() && selected >= 0 && (int)items.size() > selected ) bAllowRepeatLR = items[selected]->isMenueOptionChooser(); + bAllowRepeatLR |= bAllowRepeatLR_override; g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd, bAllowRepeatLR); @@ -592,7 +741,10 @@ int CMenuWidget::exec(CMenuTarget* parent, const std::string &) selected= i; paintHint(selected); pos = selected; - msg= CRCInput::RC_ok; + if (titem->directKeyOK) + msg = CRCInput::RC_ok; + else + msg = CRCInput::RC_nokey; } else { // swallow-key... handled= true; @@ -601,9 +753,9 @@ int CMenuWidget::exec(CMenuTarget* parent, const std::string &) } } #if 0 - if (msg == (uint32_t) g_settings.key_channelList_pageup) + if (msg == (uint32_t) g_settings.key_pageup) msg = CRCInput::RC_page_up; - else if (msg == (uint32_t) g_settings.key_channelList_pagedown) + else if (msg == (uint32_t) g_settings.key_pagedown) msg = CRCInput::RC_page_down; #endif } @@ -627,6 +779,7 @@ int CMenuWidget::exec(CMenuTarget* parent, const std::string &) case CRCInput::RC_page_down: case CRCInput::RC_up: case CRCInput::RC_down: + case CRCInput::RC_nokey: { /* dir and wrap are used when searching for a selectable item: * if the item is not selectable, try the previous (dir = -1) or @@ -635,6 +788,8 @@ int CMenuWidget::exec(CMenuTarget* parent, const std::string &) int dir = 1; bool wrap = false; switch (msg) { + case CRCInput::RC_nokey: + break; case CRCInput::RC_page_up: if (current_page) { pos = page_start[current_page] - 1; @@ -657,6 +812,8 @@ int CMenuWidget::exec(CMenuTarget* parent, const std::string &) pos -= dir * items.size(); wrap = true; } + if (pos >= (int)items.size()) + pos = (int)items.size() - 1; do { CMenuItem* item = items[pos]; if (item->isSelectable()) { @@ -769,11 +926,14 @@ int CMenuWidget::exec(CMenuTarget* parent, const std::string &) // recalculate timeout for RC-keys timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]); } + frameBuffer->blit(); } while ( msg!=CRCInput::RC_timeout ); hide(); - delete[] background; - background = NULL; + if (background) { + delete[] background; + background = NULL; + } fader.StopFade(); @@ -801,10 +961,11 @@ void CMenuWidget::hide() if(savescreen && background) restoreScreen();//FIXME else { - frameBuffer->paintBackgroundBoxRel(x, y, full_width, full_height); + frameBuffer->paintBackgroundBoxRel(x, y, full_width, full_height + fbutton_height); //paintHint(-1); } paintHint(-1); + frameBuffer->blit(); /* setActive() paints item for hidden parent menu, if called from child menu */ for (unsigned int count = 0; count < items.size(); count++) @@ -817,7 +978,7 @@ void CMenuWidget::checkHints() { GenericMenuBack->setHint("", NONEXISTANT_LOCALE); for (unsigned int i= 0; i< items.size(); i++) { - if(!items[i]->hintIcon.empty() || items[i]->hint != NONEXISTANT_LOCALE || !items[i]->hintText.empty()) { + if(items[i]->hintIcon || items[i]->hint != NONEXISTANT_LOCALE || !items[i]->hintText.empty()) { has_hints = true; break; } @@ -828,16 +989,13 @@ void CMenuWidget::checkHints() void CMenuWidget::calcSize() { - if (name != NONEXISTANT_LOCALE) - nameString = g_Locale->getText(name); - width = min_width; int wi, hi; for (unsigned int i= 0; i< items.size(); i++) { wi = 0; - if (!items[i]->iconName_Info_right.empty()) { - frameBuffer->getIconSize(items[i]->iconName_Info_right.c_str(), &wi, &hi); + if (items[i]->iconName_Info_right) { + frameBuffer->getIconSize(items[i]->iconName_Info_right, &wi, &hi); if ((wi > 0) && (hi > 0)) wi += 10; else @@ -860,16 +1018,15 @@ void CMenuWidget::calcSize() } /* set the max height to 9/10 of usable screen height debatable, if the callers need a possibility to set this */ - height = (frameBuffer->getScreenHeight() - hint_height) / 20 * 18; /* make sure its a multiple of 2 */ + height = (frameBuffer->getScreenHeight() - fbutton_height - hint_height) / 20 * 18; /* make sure its a multiple of 2 */ if(height > ((int)frameBuffer->getScreenHeight() - 10)) height = frameBuffer->getScreenHeight() - 10; - int neededWidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(nameString); + int neededWidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(getName()); if (neededWidth > width-48) { width= neededWidth+ 49; } - //reinit header height, 1st init happens in Init() hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); int itemHeightTotal=0; @@ -877,49 +1034,53 @@ void CMenuWidget::calcSize() page_start.clear(); page_start.push_back(0); total_pages=1; + for (unsigned int i= 0; i< items.size(); i++) { int item_height=items[i]->getHeight(); heightCurrPage+=item_height; - if(heightCurrPage > (height-hheight-fbutton_height)) { + if(heightCurrPage > (height-hheight)) { page_start.push_back(i); total_pages++; heightCurrPage=item_height; } - if (heightCurrPage > itemHeightTotal) - itemHeightTotal = heightCurrPage; + if(total_pages == 1) + itemHeightTotal+=item_height; } page_start.push_back(items.size()); iconOffset= 0; - for (unsigned int i= 0; i< items.size(); i++) { - if ((!(items[i]->iconName.empty())) || CRCInput::isNumeric(items[i]->directKey)) + for (unsigned int i= 0; i< items.size(); i++) + if (items[i]->iconName && (/*!g_settings.menu_numbers_as_icons ||*/ !CRCInput::isNumeric(items[i]->directKey))) { - const char *tmp; - if (items[i]->iconName.empty()) - tmp = CRCInput::getKeyName(items[i]->directKey).c_str(); - else - tmp = items[i]->iconName.c_str(); int w, h; - frameBuffer->getIconSize(tmp, &w, &h); + frameBuffer->getIconSize(items[i]->iconName, &w, &h); if (w > iconOffset) iconOffset = w; } - } iconOffset += 10; width += iconOffset; + + int maxItemHeight = 0; + if (total_pages > 1) { + for (unsigned int i= 0; i< items.size(); i++) + maxItemHeight = std::max(maxItemHeight, items[i]->getHeight()); + itemHeightTotal = items.size() * maxItemHeight; + } + if (fbutton_count) + width = std::max(width, fbutton_width); + if (width > (int)frameBuffer->getScreenWidth()) width = frameBuffer->getScreenWidth(); // shrink menu if less items - if (hheight + itemHeightTotal + fbutton_height < height) - height = hheight + itemHeightTotal + fbutton_height; + if(hheight+itemHeightTotal < height) + height=hheight+itemHeightTotal; - //scrollbar + //scrollbar width sb_width=0; if(total_pages > 1) sb_width=15; - sb_height=itemHeightTotal; full_width = /*ConnectLineBox_Width+*/width+sb_width+SHADOW_OFFSET; full_height = height+RADIUS_LARGE+SHADOW_OFFSET*2 /*+hint_height+INFO_BOX_Y_OFFSET*/; @@ -934,7 +1095,7 @@ void CMenuWidget::calcSize() full_width = max_possible + center_offset; /* symmetry in MENU_POS_CENTER case */ } - setMenuPos(width + sb_width); + setMenuPos(full_width); } void CMenuWidget::paint() @@ -943,26 +1104,21 @@ void CMenuWidget::paint() CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8 /*, nameString.c_str()*/); // paint head - CComponentsHeader header(x, y, width + sb_width, hheight, nameString, iconfile); + CComponentsHeader header(x, y, width + sb_width, hheight, getName(), iconfile); header.setShadowOnOff(CC_SHADOW_ON); header.setOffset(10); header.paint(CC_SAVE_SCREEN_NO); // paint body shadow - frameBuffer->paintBoxRel(x+SHADOW_OFFSET, y + hheight + SHADOW_OFFSET, width + sb_width, height - hheight + RADIUS_LARGE, COL_MENUCONTENTDARK_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); + frameBuffer->paintBoxRel(x+SHADOW_OFFSET, y + hheight + SHADOW_OFFSET, width + sb_width, height - hheight + (fbutton_count ? fbutton_height : RADIUS_LARGE), COL_MENUCONTENTDARK_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); // paint body background - frameBuffer->paintBoxRel(x, y + hheight, width + sb_width, height - hheight + RADIUS_LARGE - fbutton_height, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, (fbutton_count ? 0 /*CORNER_NONE*/ : CORNER_BOTTOM)); + frameBuffer->paintBoxRel(x, y+hheight, width + sb_width, height-hheight + RADIUS_LARGE, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); item_start_y = y+hheight; paintItems(); washidden = false; - if (fbutton_count){ - int y_footer = y + height + RADIUS_LARGE - fbutton_height; - int w_footer = width + sb_width; - CComponentsFooter footer(x, y_footer, w_footer, fbutton_height); - footer.setButtonLabels(fbutton_labels, fbutton_count, 0, (w_footer/max(fbutton_count, 4)+2)-20); - footer.paint(CC_SAVE_SCREEN_NO); - } + if (fbutton_count) + ::paintButtons(x, y + height, width + sb_width, fbutton_count, fbutton_labels, width, fbutton_height); } void CMenuWidget::setMenuPos(const int& menu_width) @@ -972,7 +1128,7 @@ void CMenuWidget::setMenuPos(const int& menu_width) int scr_w = frameBuffer->getScreenWidth(); int scr_h = frameBuffer->getScreenHeight(); - int real_h = full_height + hint_height; + int real_h = full_height + fbutton_height + hint_height; //configured positions switch(g_settings.menu_pos) @@ -980,26 +1136,29 @@ void CMenuWidget::setMenuPos(const int& menu_width) case MENU_POS_CENTER: x = offx + scr_x + ((scr_w - menu_width ) >> 1 ); y = offy + scr_y + ((scr_h - real_h) >> 1 ); + x += ConnectLineBox_Width; break; case MENU_POS_TOP_LEFT: y = offy + scr_y + 10; x = offx + scr_x + 10; + x += ConnectLineBox_Width; break; case MENU_POS_TOP_RIGHT: y = offy + scr_y + 10; - x = offx + scr_x + scr_w - menu_width - 10; + x = /*offx +*/ scr_x + scr_w - menu_width - 10; break; case MENU_POS_BOTTOM_LEFT: - y = offy + scr_y + scr_h - real_h - 10; + y = /*offy +*/ scr_y + scr_h - real_h - 10; x = offx + scr_x + 10; + x += ConnectLineBox_Width; break; case MENU_POS_BOTTOM_RIGHT: - y = offy + scr_y + scr_h - real_h - 10; - x = offx + scr_x + scr_w - menu_width - 10; + y = /*offy +*/ scr_y + scr_h - real_h - 10; + x = /*offx +*/ scr_x + scr_w - menu_width - 10; break; } } @@ -1018,11 +1177,12 @@ void CMenuWidget::paintItems() // Scrollbar if(total_pages>1) { - frameBuffer->paintBoxRel(x+ width,item_start_y, sb_width, sb_height, COL_MENUCONTENT_PLUS_1, RADIUS_MIN); - frameBuffer->paintBoxRel(x+ width +2, item_start_y+ 2+ current_page*(sb_height-4)/total_pages, sb_width-4, (sb_height-4)/total_pages, COL_MENUCONTENT_PLUS_3, RADIUS_MIN); + int item_height=height-(item_start_y-y); + frameBuffer->paintBoxRel(x+ width,item_start_y, 15, item_height, COL_MENUCONTENT_PLUS_1, RADIUS_MIN); + frameBuffer->paintBoxRel(x+ width +2, item_start_y+ 2+ current_page*(item_height-4)/total_pages, 11, (item_height-4)/total_pages, COL_MENUCONTENT_PLUS_3, RADIUS_MIN); /* background of menu items, paint every time because different items can have * different height and this might leave artifacts otherwise after changing pages */ - frameBuffer->paintBoxRel(x,item_start_y, width, sb_height, COL_MENUCONTENT_PLUS_0); + frameBuffer->paintBoxRel(x,item_start_y, width,item_height, COL_MENUCONTENT_PLUS_0); } int ypos=item_start_y; for (int count = 0; count < (int)items.size(); count++) @@ -1063,21 +1223,17 @@ void CMenuWidget::addIntroItems(neutrino_locale_t subhead_text, neutrino_locale_ addItem(GenericMenuSeparator); - if (buttontype != BTN_TYPE_NO) - { - switch (buttontype) - { - case BTN_TYPE_BACK: - GenericMenuBack->setItemButton(!g_settings.menu_left_exit ? NEUTRINO_ICON_BUTTON_HOME : NEUTRINO_ICON_BUTTON_LEFT); - addItem(GenericMenuBack); - break; - case BTN_TYPE_CANCEL: - addItem(GenericMenuCancel); - break; - case BTN_TYPE_NEXT: - addItem(GenericMenuNext); - break; - } + switch (buttontype) { + case BTN_TYPE_BACK: + GenericMenuBack->setItemButton(!g_settings.menu_left_exit ? NEUTRINO_ICON_BUTTON_HOME : NEUTRINO_ICON_BUTTON_LEFT); + addItem(GenericMenuBack); + break; + case BTN_TYPE_CANCEL: + addItem(GenericMenuCancel); + break; + case BTN_TYPE_NEXT: + addItem(GenericMenuNext); + break; } if (section_text != NONEXISTANT_LOCALE) @@ -1095,14 +1251,14 @@ void CMenuWidget::saveScreen() background = new fb_pixel_t [full_width * full_height]; if(background) - frameBuffer->SaveScreen(x /*-ConnectLineBox_Width*/, y, full_width, full_height, background); + frameBuffer->SaveScreen(x /*-ConnectLineBox_Width*/, y, full_width, full_height + fbutton_height, background); } void CMenuWidget::restoreScreen() { if(background) { if(savescreen) - frameBuffer->RestoreScreen(x /*-ConnectLineBox_Width*/, y, full_width, full_height, background); + frameBuffer->RestoreScreen(x /*-ConnectLineBox_Width*/, y, full_width, full_height + fbutton_height, background); } } @@ -1137,7 +1293,7 @@ void CMenuWidget::paintHint(int pos) CMenuItem* item = items[pos]; - if (item->hintIcon.empty() && item->hint == NONEXISTANT_LOCALE && item->hintText.empty()) { + if (!item->hintIcon && item->hint == NONEXISTANT_LOCALE && item->hintText.empty()) { if (info_box) { savescreen ? info_box->hide(false) : info_box->kill(); hint_painted = false; @@ -1151,7 +1307,7 @@ void CMenuWidget::paintHint(int pos) int iheight = item->getHeight(); int rad = RADIUS_LARGE; int xpos = x - ConnectLineBox_Width; - int ypos2 = y + height + rad + SHADOW_OFFSET + INFO_BOX_Y_OFFSET; + int ypos2 = y + height + fbutton_height + rad + SHADOW_OFFSET + INFO_BOX_Y_OFFSET; int iwidth = width+sb_width; //init details line and infobox dimensions @@ -1182,7 +1338,7 @@ void CMenuWidget::paintHint(int pos) info_box->syncSysColors(); info_box->setColorBody(COL_MENUCONTENTDARK_PLUS_0); info_box->setShadowOnOff(CC_SHADOW_ON); - info_box->setPicture(item->hintIcon); + info_box->setPicture(item->hintIcon ? item->hintIcon : ""); } //paint result @@ -1203,70 +1359,72 @@ void CMenuWidget::setFooter(const struct button_label *_fbutton_labels, const in { fbutton_count = _fbutton_count; fbutton_labels = _fbutton_labels; - fbutton_height = hheight;//g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight() + 6; // init min buttonbar height + fbutton_width = 0; + fbutton_height = 0; + if (fbutton_count) + paintButtons(fbutton_labels, fbutton_count, 0, 0, 0, 0, 0, false, &fbutton_width, &fbutton_height); if (repaint) paint(); } //------------------------------------------------------------------------------------------------------------------------------- -CMenuOptionNumberChooser::CMenuOptionNumberChooser( const neutrino_locale_t Name, - int * const OptionValue, - const bool Active, - const int min_value, - const int max_value, - CChangeObserver * const Observ, - const int print_offset, - const int special_value, - const neutrino_locale_t special_value_name, - bool sliderOn) +CMenuOptionNumberChooser::CMenuOptionNumberChooser(const neutrino_locale_t Name, int * const OptionValue, const bool Active, + const int min_value, const int max_value, + CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const char * const IconName, + const int print_offset, const int special_value, const neutrino_locale_t special_value_name, bool sliderOn) + : CAbstractMenuOptionChooser(Active, DirectKey, IconName) { - initMenuOptionNumberChooser("", Name, OptionValue, Active, min_value, max_value, Observ, print_offset, special_value, special_value_name, sliderOn); + name = Name; + optionValue = OptionValue; + + lower_bound = min_value; + upper_bound = max_value; + + display_offset = print_offset; + + localized_value = special_value; + localized_value_name = special_value_name; + + display_offset = print_offset; + nameString = ""; + numberFormat = "%d"; + numberFormatFunction = NULL; + observ = Observ; + slider_on = sliderOn; + + numeric_input = false; + + directKeyOK = false; } -CMenuOptionNumberChooser::CMenuOptionNumberChooser( const std::string &Name, - int * const OptionValue, - const bool Active, - const int min_value, - const int max_value, - CChangeObserver * const Observ, - const int print_offset, - const int special_value, - const neutrino_locale_t special_value_name, - bool sliderOn) +CMenuOptionNumberChooser::CMenuOptionNumberChooser(const std::string &Name, int * const OptionValue, const bool Active, + const int min_value, const int max_value, + CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const char * const IconName, + const int print_offset, const int special_value, const neutrino_locale_t special_value_name, bool sliderOn) + : CAbstractMenuOptionChooser(Active, DirectKey, IconName) { - initMenuOptionNumberChooser(Name, NONEXISTANT_LOCALE, OptionValue, Active, min_value, max_value, Observ, print_offset, special_value, special_value_name, sliderOn); -} + name = NONEXISTANT_LOCALE; + optionValue = OptionValue; -void CMenuOptionNumberChooser::initMenuOptionNumberChooser( const std::string &s_name, - const neutrino_locale_t l_name, - int * const OptionValue, - const bool Active, - const int min_value, - const int max_value, - CChangeObserver * const Observ, - const int print_offset, - const int special_value, - const neutrino_locale_t special_value_name, - bool sliderOn) -{ - height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - nameString = s_name; - name = l_name; - optionValue = OptionValue; - active = Active; - lower_bound = min_value; - upper_bound = max_value; - observ = Observ; - display_offset = print_offset; - localized_value = special_value; - localized_value_name = special_value_name; - slider_on = sliderOn; + lower_bound = min_value; + upper_bound = max_value; - numberFormat = "%d"; - numberFormatFunction = NULL; - numeric_input = false; + display_offset = print_offset; + + localized_value = special_value; + localized_value_name = special_value_name; + + nameString = Name; + numberFormat = "%d"; + numberFormatFunction = NULL; + observ = Observ; + slider_on = sliderOn; + + numeric_input = false; + + directKeyOK = false; } int CMenuOptionNumberChooser::exec(CMenuTarget*) @@ -1301,18 +1459,20 @@ int CMenuOptionNumberChooser::exec(CMenuTarget*) else (*optionValue)++; } -#if ENABLE_LUA + + bool wantsRepaint = false; if(observ && !luaAction.empty()) { // optionValue is int* - observ->changeNotify(luaState, luaAction, luaId, (void *) to_string(*optionValue).c_str()); - } else -#endif - if(observ) - observ->changeNotify(name, optionValue); + wantsRepaint = observ->changeNotify(luaState, luaAction, luaId, (void *) to_string(*optionValue).c_str()); + } else if(observ) + wantsRepaint = observ->changeNotify(name, optionValue); // give the observer a chance to modify the value paint(true); + if (wantsRepaint) + res = menu_return::RETURN_REPAINT; + return res; } @@ -1325,7 +1485,7 @@ int CMenuOptionNumberChooser::paint(bool selected) { if (numberFormatFunction) { std::string s = numberFormatFunction(*optionValue + display_offset); - strncpy(option_value, s.c_str(), s.length()); + strncpy(option_value, s.c_str(), sizeof(option_value)); } else sprintf(option_value, numberFormat.c_str(), *optionValue + display_offset); l_option = option_value; @@ -1339,9 +1499,9 @@ int CMenuOptionNumberChooser::paint(bool selected) //paint item icon paintItemButton(selected, height, NEUTRINO_ICON_BUTTON_OKAY); if(slider_on) - paintItemSlider( selected, height, *optionValue, (upper_bound - lower_bound) , getName(), l_option); + paintItemSlider(selected, height, *optionValue, (upper_bound - lower_bound), getName(), l_option); //paint text - paintItemCaption(selected, height , getName(), l_option); + paintItemCaption(selected, l_option); return y+height; } @@ -1380,26 +1540,25 @@ int CMenuOptionNumberChooser::getWidth(void) width += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(format) - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("0"); } - return width + 10; /* min 10 pixels between option name and value. enough? */ + width += 10; /* min 10 pixels between option name and value. enough? */ + + const char *desc_text = getDescription(); + if (*desc_text) + width = std::max(width, 10 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(desc_text)); + return width; } -//------------------------------------------------------------------------------------------------------------------------------- - -CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, - int * const OptionValue, - const struct keyval * const Options, - const unsigned Number_Of_Options, - const bool Active, - CChangeObserver * const Observ, - const neutrino_msg_t DirectKey, - const std::string & IconName, - bool Pulldown, - bool OptionsSort) +CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, + const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) + : CAbstractMenuOptionChooser(Active, DirectKey, IconName) { - initVarOptionChooser("", OptionName, OptionValue, Active, Observ, DirectKey, IconName, Pulldown, OptionsSort); - + nameString = ""; + name = OptionName; + optionValue = OptionValue; number_of_options = Number_Of_Options; - + observ = Observ; + pulldown = Pulldown; + optionsSort = OptionsSort; for (unsigned int i = 0; i < number_of_options; i++) { struct keyval_ext opt; @@ -1408,21 +1567,17 @@ CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, } } -CMenuOptionChooser::CMenuOptionChooser(const std::string &OptionName, - int * const OptionValue, - const struct keyval * const Options, - const unsigned Number_Of_Options, - const bool Active, - CChangeObserver * const Observ, - neutrino_msg_t DirectKey, - const std::string & IconName, - bool Pulldown, - bool OptionsSort) +CMenuOptionChooser::CMenuOptionChooser(const std::string &OptionName, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, + const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) + : CAbstractMenuOptionChooser(Active, DirectKey, IconName) { - initVarOptionChooser(OptionName, NONEXISTANT_LOCALE, OptionValue, Active, Observ, DirectKey, IconName, Pulldown, OptionsSort); - + nameString = OptionName; + name = NONEXISTANT_LOCALE; + optionValue = OptionValue; number_of_options = Number_Of_Options; - + observ = Observ; + pulldown = Pulldown; + optionsSort = OptionsSort; for (unsigned int i = 0; i < number_of_options; i++) { struct keyval_ext opt; @@ -1431,94 +1586,66 @@ CMenuOptionChooser::CMenuOptionChooser(const std::string &OptionName, } } -CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, - int * const OptionValue, - const struct keyval_ext * const Options, - const unsigned Number_Of_Options, - const bool Active, - CChangeObserver * const Observ, - const neutrino_msg_t DirectKey, - const std::string & IconName, - bool Pulldown, - bool OptionsSort) +CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval_ext * const Options, + const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ, + const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) + : CAbstractMenuOptionChooser(Active, DirectKey, IconName) { - initVarOptionChooser("", OptionName, OptionValue, Active, Observ, DirectKey, IconName, Pulldown, OptionsSort); - + nameString = ""; + name = OptionName; + optionValue = OptionValue; number_of_options = Number_Of_Options; - + observ = Observ; + pulldown = Pulldown; + optionsSort = OptionsSort; for (unsigned int i = 0; i < number_of_options; i++) options.push_back(Options[i]); } -CMenuOptionChooser::CMenuOptionChooser(const std::string &OptionName, - int * const OptionValue, - const struct keyval_ext * const Options, - const unsigned Number_Of_Options, - const bool Active, - CChangeObserver * const Observ, - const neutrino_msg_t DirectKey, - const std::string & IconName, - bool Pulldown, - bool OptionsSort) +CMenuOptionChooser::CMenuOptionChooser(const std::string &OptionName, int * const OptionValue, const struct keyval_ext * const Options, + const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ, + const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) + : CAbstractMenuOptionChooser(Active, DirectKey, IconName) { - initVarOptionChooser(OptionName, NONEXISTANT_LOCALE, OptionValue, Active, Observ, DirectKey, IconName, Pulldown, OptionsSort); - + nameString = OptionName; + name = NONEXISTANT_LOCALE; + optionValue = OptionValue; number_of_options = Number_Of_Options; - + observ = Observ; + pulldown = Pulldown; + optionsSort = OptionsSort; for (unsigned int i = 0; i < number_of_options; i++) options.push_back(Options[i]); } -CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, - int * const OptionValue, - std::vector &Options, - const bool Active, - CChangeObserver * const Observ, - const neutrino_msg_t DirectKey, - const std::string & IconName, - bool Pulldown, - bool OptionsSort) +CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, std::vector &Options, + const bool Active, CChangeObserver * const Observ, + const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) + : CAbstractMenuOptionChooser(Active, DirectKey, IconName) { - initVarOptionChooser("", OptionName, OptionValue, Active, Observ, DirectKey, IconName, Pulldown, OptionsSort); - - options = Options; + nameString = ""; + name = OptionName; + optionValue = OptionValue; + options = Options; + number_of_options = options.size(); + observ = Observ; + pulldown = Pulldown; + optionsSort = OptionsSort; } -CMenuOptionChooser::CMenuOptionChooser(const std::string &OptionName, - int * const OptionValue, - std::vector &Options, - const bool Active, - CChangeObserver * const Observ, - const neutrino_msg_t DirectKey, - const std::string & IconName, - bool Pulldown, - bool OptionsSort) +CMenuOptionChooser::CMenuOptionChooser(const std::string &OptionName, int * const OptionValue, std::vector &Options, + const bool Active, CChangeObserver * const Observ, + const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) + : CAbstractMenuOptionChooser(Active, DirectKey, IconName) { - initVarOptionChooser(OptionName, NONEXISTANT_LOCALE, OptionValue, Active, Observ, DirectKey, IconName, Pulldown, OptionsSort); - - options = Options; -} - -void CMenuOptionChooser::initVarOptionChooser( const std::string &OptionName, - const neutrino_locale_t Name, - int * const OptionValue, - const bool Active, - CChangeObserver * const Observ, - neutrino_msg_t DirectKey, - const std::string & IconName, - bool Pulldown, - bool OptionsSort) -{ - height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - nameString = OptionName; - name = Name; - optionValue = OptionValue; - active = Active; - observ = Observ; - directKey = DirectKey; - iconName = IconName; - pulldown = Pulldown; - optionsSort = OptionsSort; + nameString = OptionName; + name = NONEXISTANT_LOCALE; + optionValue = OptionValue; + options = Options; + number_of_options = options.size(); + observ = Observ; + pulldown = Pulldown; + optionsSort = OptionsSort; } CMenuOptionChooser::~CMenuOptionChooser() @@ -1526,6 +1653,36 @@ CMenuOptionChooser::~CMenuOptionChooser() clearChooserOptions(); } +void CMenuOptionChooser::initVarOptionChooser( const std::string &OptionName, + const neutrino_locale_t Name, + int * const OptionValue, + const bool Active, + CChangeObserver * const Observ, + neutrino_msg_t DirectKey, + const char * IconName, + bool Pulldown, + bool OptionsSort) +{ + height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); + nameString = OptionName; + name = Name; + optionValue = OptionValue; + active = Active; + observ = Observ; + directKey = DirectKey; + iconName = IconName; + pulldown = Pulldown; + optionsSort = OptionsSort; +} + +void CMenuOptionChooser::clearChooserOptions() +{ + for (std::vector::iterator it = option_chooser_options_v.begin(); it != option_chooser_options_v.end(); ++it) + delete *it; + + option_chooser_options_v.clear(); +} + void CMenuOptionChooser::setOptions(const struct keyval * const Options, const unsigned Number_Of_Options) { options.clear(); @@ -1560,26 +1717,18 @@ int CMenuOptionChooser::getOption(void) const return *optionValue; } -void CMenuOptionChooser::clearChooserOptions() -{ - for (std::vector::iterator it = option_chooser_options_v.begin(); it != option_chooser_options_v.end(); ++it) - delete *it; - - option_chooser_options_v.clear(); -} int CMenuOptionChooser::exec(CMenuTarget*) { bool wantsRepaint = false; int ret = menu_return::RETURN_NONE; -#if ENABLE_LUA char *optionValname = NULL; -#endif + if (optionsSort) { optionsSort = false; clearChooserOptions(); unsigned int i1; - for (i1 = 0; i1 < number_of_options; i1++) + for (i1 = 0; i1 < number_of_options; i1++) { CMenuOptionChooserOptions* co = new CMenuOptionChooserOptions(); co->key = options[i1].key; @@ -1602,10 +1751,11 @@ int CMenuOptionChooser::exec(CMenuTarget*) if((msg == CRCInput::RC_ok) && pulldown) { int select = -1; CMenuWidget* menu = new CMenuWidget(getName(), NEUTRINO_ICON_SETTINGS); + menu->enableFade(false); /* FIXME: BACK button with hints enabled - parent menu getting holes, possible solution * to hide parent, or add hints ? */ menu->addIntroItems(NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, CMenuWidget::BTN_TYPE_CANCEL); -// menu->move(20, 0); + // menu->move(20, 0); CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select); for(unsigned int count = 0; count < number_of_options; count++) { @@ -1627,9 +1777,7 @@ int CMenuOptionChooser::exec(CMenuTarget*) if(select >= 0) { *optionValue = options[select].key; -#if ENABLE_LUA optionValname = (char *) options[select].valname; -#endif } delete menu; delete selector; @@ -1638,35 +1786,26 @@ int CMenuOptionChooser::exec(CMenuTarget*) if (options[count].key == (*optionValue)) { if(msg == CRCInput::RC_left) { if(count > 0) -#if ENABLE_LUA optionValname = (char *) options[(count-1) % number_of_options].valname, -#endif - *optionValue = options[(count-1) % number_of_options].key; + *optionValue = options[(count-1) % number_of_options].key; else -#if ENABLE_LUA optionValname = (char *) options[number_of_options-1].valname, -#endif - *optionValue = options[number_of_options-1].key; + *optionValue = options[number_of_options-1].key; } else -#if ENABLE_LUA optionValname = (char *) options[(count+1) % number_of_options].valname, -#endif - *optionValue = options[(count+1) % number_of_options].key; + *optionValue = options[(count+1) % number_of_options].key; break; } } } paint(true); -#if ENABLE_LUA if(observ && !luaAction.empty()) { if (optionValname) wantsRepaint = observ->changeNotify(luaState, luaAction, luaId, optionValname); - } else -#endif - if(observ) - wantsRepaint = observ->changeNotify(name, optionValue); + } else if(observ) + wantsRepaint = observ->changeNotify(name, optionValue); - if ( wantsRepaint ) + if (wantsRepaint) ret = menu_return::RETURN_REPAINT; return ret; @@ -1705,7 +1844,7 @@ int CMenuOptionChooser::paint( bool selected) paintItemButton(selected, height, NEUTRINO_ICON_BUTTON_OKAY); //paint text - paintItemCaption(selected, height , getName(), l_option); + paintItemCaption(selected, l_option); return y+height; } @@ -1719,59 +1858,43 @@ int CMenuOptionChooser::getWidth(void) for(unsigned int count = 0; count < options.size(); count++) { ow = 0; if (options[count].valname) - ow = g_Font[SNeutrinoSettings::FONT_TYPE_MENU] - ->getRenderWidth(options[count].valname); + ow = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(options[count].valname); else - ow = g_Font[SNeutrinoSettings::FONT_TYPE_MENU] - ->getRenderWidth(g_Locale->getText(options[count].value)); + ow = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(g_Locale->getText(options[count].value)); if (tw + ow > width) width = tw + ow; } - return width + 10; /* min 10 pixels between option name and value. enough? */ + width += 10; /* min 10 pixels between option name and value. enough? */ + const char *desc_text = getDescription(); + if (*desc_text) + width = std::max(width, 10 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(desc_text)); + return width; } //------------------------------------------------------------------------------------------------------------------------------- -CMenuOptionStringChooser::CMenuOptionStringChooser(const neutrino_locale_t OptionName, - std::string* OptionValue, - bool Active, CChangeObserver* Observ, - const neutrino_msg_t DirectKey, - const std::string & IconName, - bool Pulldown) +CMenuOptionStringChooser::CMenuOptionStringChooser(const neutrino_locale_t OptionName, std::string* OptionValue, bool Active, CChangeObserver* Observ, + const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown) + : CMenuItem(Active, DirectKey, IconName) { - initVarMenuOptionStringChooser("", OptionName, OptionValue, Active, Observ, DirectKey, IconName, Pulldown); + nameString = ""; + name = OptionName; + optionValuePtr = OptionValue ? OptionValue : &optionValue; + observ = Observ; + pulldown = Pulldown; } -CMenuOptionStringChooser::CMenuOptionStringChooser(const std::string &OptionName, - std::string* OptionValue, - bool Active, CChangeObserver* Observ, - const neutrino_msg_t DirectKey, - const std::string & IconName, - bool Pulldown) +CMenuOptionStringChooser::CMenuOptionStringChooser(const std::string &OptionName, std::string* OptionValue, bool Active, CChangeObserver* Observ, + const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown) + : CMenuItem(Active, DirectKey, IconName) { - initVarMenuOptionStringChooser(OptionName, NONEXISTANT_LOCALE, OptionValue, Active, Observ, DirectKey, IconName, Pulldown); -} - -void CMenuOptionStringChooser::initVarMenuOptionStringChooser( const std::string &string_Name, - const neutrino_locale_t locale_Name, - std::string* OptionValue, - bool Active, - CChangeObserver* Observ, - const neutrino_msg_t DirectKey, - const std::string & IconName, - bool Pulldown) -{ - height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - nameString = string_Name; - name = locale_Name; - active = Active; - optionValueString = OptionValue; - observ = Observ; - directKey = DirectKey; - iconName = IconName; - pulldown = Pulldown; + nameString = OptionName; + name = NONEXISTANT_LOCALE; + optionValuePtr = OptionValue ? OptionValue : &optionValue; + observ = Observ; + pulldown = Pulldown; } @@ -1780,6 +1903,16 @@ CMenuOptionStringChooser::~CMenuOptionStringChooser() options.clear(); } +void CMenuOptionStringChooser::setTitle(std::string &Title) +{ + title = Title; +} + +void CMenuOptionStringChooser::setTitle(const neutrino_locale_t Title) +{ + title = g_Locale->getText(Title); +} + void CMenuOptionStringChooser::addOption(const std::string &value) { options.push_back(value); @@ -1801,35 +1934,36 @@ int CMenuOptionStringChooser::exec(CMenuTarget* parent) if (parent) parent->hide(); - const char *l_name = (name == NONEXISTANT_LOCALE) ? nameString.c_str() : g_Locale->getText(name); - CMenuWidget* menu = new CMenuWidget(l_name, NEUTRINO_ICON_SETTINGS); + std::string title_str = title.empty() ? getName() : title; + + CMenuWidget* menu = new CMenuWidget(title_str, NEUTRINO_ICON_SETTINGS); menu->addIntroItems(NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, CMenuWidget::BTN_TYPE_CANCEL); //if(parent) menu->move(20, 0); CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select); for(unsigned int count = 0; count < options.size(); count++) { - bool selected = optionValueString && (options[count] == *optionValueString); + bool selected = optionValuePtr && (options[count] == *optionValuePtr); CMenuForwarder *mn_option = new CMenuForwarder(options[count], true, NULL, selector, to_string(count).c_str()); mn_option->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true /*for selected item*/); menu->addItem(mn_option, selected); } menu->exec(NULL, ""); ret = menu_return::RETURN_REPAINT; - if(select >= 0 && optionValueString) - *optionValueString = options[select]; + if(select >= 0 && optionValuePtr) + *optionValuePtr = options[select]; delete menu; delete selector; } else { //select next value for(unsigned int count = 0; count < options.size(); count++) { - if (optionValueString && (options[count] == *optionValueString)) { + if (optionValuePtr && (options[count] == *optionValuePtr)) { if(msg == CRCInput::RC_left) { if(count > 0) - *optionValueString = options[(count - 1) % options.size()]; + *optionValuePtr = options[(count - 1) % options.size()]; else - *optionValueString = options[options.size() - 1]; + *optionValuePtr = options[options.size() - 1]; } else - *optionValueString = options[(count + 1) % options.size()]; + *optionValuePtr = options[(count + 1) % options.size()]; //wantsRepaint = true; break; } @@ -1837,13 +1971,10 @@ int CMenuOptionStringChooser::exec(CMenuTarget* parent) paint(true); } -#if ENABLE_LUA if(observ && !luaAction.empty()) - wantsRepaint = observ->changeNotify(luaState, luaAction, luaId, (void *)(optionValueString ? optionValueString->c_str() : "")); - else -#endif - if(observ) { - wantsRepaint = observ->changeNotify(name, (void *)(optionValueString ? optionValueString->c_str() : "")); + wantsRepaint = observ->changeNotify(luaState, luaAction, luaId, (void *)(optionValuePtr ? optionValuePtr->c_str() : "")); + else if(observ) { + wantsRepaint = observ->changeNotify(name, (void *)(optionValuePtr ? optionValuePtr->c_str() : "")); } if (wantsRepaint) ret = menu_return::RETURN_REPAINT; @@ -1853,8 +1984,6 @@ int CMenuOptionStringChooser::exec(CMenuTarget* parent) int CMenuOptionStringChooser::paint( bool selected ) { - const char *l_name = (name == NONEXISTANT_LOCALE) ? nameString.c_str() : g_Locale->getText(name); - //paint item prepareItem(selected, height); @@ -1862,127 +1991,66 @@ int CMenuOptionStringChooser::paint( bool selected ) paintItemButton(selected, height, NEUTRINO_ICON_BUTTON_OKAY); //paint text - paintItemCaption(selected, height , l_name, optionValueString->c_str()); + paintItemCaption(selected, optionValuePtr->c_str()); return y+height; } //------------------------------------------------------------------------------------------------------------------------------- - -CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, - const bool Active, - const std::string &Option, - CMenuTarget* Target, - const char * const ActionKey, - neutrino_msg_t DirectKey, - const char * const IconName, - const char * const IconName_Info_right, - bool IsStatic) +CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, + neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) + : CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic) { - initVarMenuForwarder("", Text, Active, &Option, NULL, Target, ActionKey, DirectKey, IconName, IconName_Info_right, IsStatic); -} - -CMenuForwarder::CMenuForwarder(const std::string& Text, - const bool Active, - const std::string &Option, - CMenuTarget* Target, - const char * const ActionKey, - neutrino_msg_t DirectKey, - const char * const IconName, - const char * const IconName_Info_right, - bool IsStatic) -{ - initVarMenuForwarder(Text, NONEXISTANT_LOCALE, Active, &Option, NULL, Target, ActionKey, DirectKey, IconName, IconName_Info_right, IsStatic); -} - -CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, - const bool Active, - const char * const Option, - CMenuTarget* Target, - const char * const ActionKey, - neutrino_msg_t DirectKey, - const char * const IconName, - const char * const IconName_Info_right, - bool IsStatic) -{ - initVarMenuForwarder("", Text, Active, NULL, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right, IsStatic); -} - -CMenuForwarder::CMenuForwarder(const std::string& Text, - const bool Active, - const char * const Option, - CMenuTarget* Target, - const char * const ActionKey, - neutrino_msg_t DirectKey, - const char * const IconName, - const char * const IconName_Info_right, - bool IsStatic) -{ - initVarMenuForwarder(Text, NONEXISTANT_LOCALE, Active, NULL, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right, IsStatic); -} - -void CMenuForwarder::initVarMenuForwarder( const std::string& string_text, - const neutrino_locale_t& locale_text, - const bool Active, - const std::string * Option_string, - const char * const Option_cstring, - CMenuTarget* Target, - const char * const ActionKey, - neutrino_msg_t DirectKey, - const char * const IconName, - const char * const IconName_Info_right, - bool IsStatic) -{ - name = locale_text; - nameString = string_text; - active = Active; - option_string = Option_string; - option = Option_cstring; - jumpTarget = Target; - actionKey = ActionKey ? ActionKey : ""; - directKey = DirectKey; - iconName = IconName ? IconName : ""; - iconName_Info_right = IconName_Info_right ? IconName_Info_right : ""; - isStatic = IsStatic; -} - -void CMenuForwarder::setName(const std::string& t) -{ - name = NONEXISTANT_LOCALE; - nameString = t; -} - -void CMenuForwarder::setName(const neutrino_locale_t t) -{ - name = t; + option_string_ptr = &Option; + name = Text; nameString = ""; + jumpTarget = Target; + actionKey = ActionKey ? ActionKey : ""; } -void CMenuForwarder::setOption(const char * const Option) +CMenuForwarder::CMenuForwarder(const std::string& Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, + neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) + : CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic) { - option = Option; - option_string = NULL; - if (used && x != -1) - paint(); + option_string_ptr = &Option; + name = NONEXISTANT_LOCALE; + nameString = Text; + jumpTarget = Target; + actionKey = ActionKey ? ActionKey : ""; +} + +CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, + neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) + : CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic) +{ + option_string = Option ? Option : ""; + option_string_ptr = &option_string; + name = Text; + nameString = ""; + jumpTarget = Target; + actionKey = ActionKey ? ActionKey : ""; +} + +CMenuForwarder::CMenuForwarder(const std::string& Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, + neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) + : CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic) +{ + option_string = Option ? Option : ""; + option_string_ptr = &option_string; + name = NONEXISTANT_LOCALE; + nameString = Text; + jumpTarget = Target; + actionKey = ActionKey ? ActionKey : ""; } void CMenuForwarder::setOption(const std::string &Option) { - option = NULL; - option_string = &Option; - if (used && x != -1) - paint(); -} - -int CMenuForwarder::getHeight(void) const -{ - return g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); + option_string = Option; } int CMenuForwarder::getWidth(void) { - const char *_name = (name == NONEXISTANT_LOCALE) ? nameString.c_str() : g_Locale->getText(name); - int tw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(_name); + int tw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(getName()); fb_pixel_t bgcol = 0; std::string option_name = getOption(); @@ -1994,38 +2062,31 @@ int CMenuForwarder::getWidth(void) else if (bgcol) tw += 10 + 60; + const char *desc_text = getDescription(); + if (*desc_text) + tw = std::max(tw, 10 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(desc_text)); return tw; } int CMenuForwarder::exec(CMenuTarget* parent) { if(jumpTarget) - { return jumpTarget->exec(parent, actionKey); - } - else - { - return menu_return::RETURN_EXIT; - } + return menu_return::RETURN_EXIT; } std::string CMenuForwarder::getOption(void) { - if (option) - return (std::string)option; - else if (option_string) - return *option_string; - else if (jumpTarget) + if (!option_string_ptr->empty()) + return *option_string_ptr; + if (jumpTarget) return jumpTarget->getValue(); return ""; } int CMenuForwarder::paint(bool selected) { - int height = getHeight(); - const char * l_name = getName(); - - std::string option_name = getOption(); + std::string option_name = getOption(); fb_pixel_t bgcol = 0; if (jumpTarget) bgcol = jumpTarget->getColor(); @@ -2037,52 +2098,34 @@ int CMenuForwarder::paint(bool selected) paintItemButton(selected, height); //caption - paintItemCaption(selected, height, l_name, option_name.c_str(), bgcol); + paintItemCaption(selected, option_name.c_str(), bgcol); return y+ height; } //------------------------------------------------------------------------------------------------------------------------------- -CMenuSeparator::CMenuSeparator(const int Type, const neutrino_locale_t Text, bool IsStatic) -{ - initVarMenuSeparator(Type, "", Text, IsStatic); -} - -CMenuSeparator::CMenuSeparator(const int Type, const std::string& Text, bool IsStatic) -{ - initVarMenuSeparator(Type, Text, NONEXISTANT_LOCALE, IsStatic); -} - -void CMenuSeparator::initVarMenuSeparator(const int Type, const std::string& string_Text, const neutrino_locale_t locale_Text, bool IsStatic) +CMenuSeparator::CMenuSeparator(const int Type, const neutrino_locale_t Text, bool IsStatic) : CMenuItem(false, CRCInput::RC_nokey, NULL, NULL, IsStatic) { type = Type; - name = locale_Text; - nameString = string_Text; - isStatic = IsStatic; - - directKey = CRCInput::RC_nokey; - iconName = ""; + name = Text; + nameString = ""; } -int CMenuSeparator::getHeight(void) const +CMenuSeparator::CMenuSeparator(const int Type, const std::string Text, bool IsStatic) : CMenuItem(false, CRCInput::RC_nokey, NULL, NULL, IsStatic) +{ + type = Type; + name = NONEXISTANT_LOCALE; + nameString = Text; +} + + +int CMenuSeparator::getHeight(void) { if (nameString.empty() && name == NONEXISTANT_LOCALE) return 10; return g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); } -void CMenuSeparator::setName(const std::string& t) -{ - name = NONEXISTANT_LOCALE; - nameString = t; -} - -void CMenuSeparator::setName(const neutrino_locale_t t) -{ - name = t; - nameString = ""; -} - int CMenuSeparator::getWidth(void) { int w = 0; @@ -2096,7 +2139,7 @@ int CMenuSeparator::getWidth(void) int CMenuSeparator::paint(bool selected) { - int height = getHeight(); + height = getHeight(); CFrameBuffer * frameBuffer = CFrameBuffer::getInstance(); if ((type & SUB_HEAD)) @@ -2122,7 +2165,7 @@ int CMenuSeparator::paint(bool selected) if (*l_name) { - int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_name); + int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_name); // UTF-8 /* if no alignment is specified, align centered */ if (type & ALIGN_LEFT) @@ -2134,7 +2177,7 @@ int CMenuSeparator::paint(bool selected) frameBuffer->paintBoxRel(name_start_x-5, y, stringwidth+10, height, item_bgcolor); - paintItemCaption(selected, height, l_name); + paintItemCaption(selected); } } return y+ height; @@ -2155,6 +2198,7 @@ bool CPINProtection::check() return (cPIN == *validPIN); } + bool CZapProtection::check() { hint = NONEXISTANT_LOCALE; @@ -2168,7 +2212,10 @@ bool CZapProtection::check() res = PINInput->exec(getParent(), ""); delete PINInput; - + if (!access(CONFIGDIR "/pinentered.sh", X_OK)) { + std::string systemstr = CONFIGDIR "/pinentered.sh " + cPIN; + system(systemstr.c_str()); + } hint = LOCALE_PINPROTECTION_WRONGCODE; } while ( (cPIN != *validPIN) && !cPIN.empty() && ( res == menu_return::RETURN_REPAINT ) && @@ -2193,10 +2240,77 @@ int CLockedMenuForwarder::exec(CMenuTarget* parent) int CMenuSelectorTarget::exec(CMenuTarget* /*parent*/, const std::string & actionKey) { - if (actionKey != "") - *m_select = atoi(actionKey.c_str()); - else - *m_select = -1; - return menu_return::RETURN_EXIT; + if (actionKey != "") + *m_select = atoi(actionKey); + else + *m_select = -1; + return menu_return::RETURN_EXIT; } +CMenuProgressbar::CMenuProgressbar(const neutrino_locale_t Text) : CMenuItem(true, CRCInput::RC_nokey, NULL, NULL, false) +{ + init(Text, ""); +} + +CMenuProgressbar::CMenuProgressbar(const std::string &Text) : CMenuItem(true, CRCInput::RC_nokey, NULL, NULL, false) +{ + init(NONEXISTANT_LOCALE, Text); +} + +void CMenuProgressbar::init(const neutrino_locale_t Loc, const std::string &Text) +{ + name = Loc; + nameString = Text; + scale.setDimensionsAll(0, 0, 100, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight()/2); + scale.setValue(100); +} + +int CMenuProgressbar::paint(bool selected) +{ + //paint item + prepareItem(selected, height); + + //left text + const char *left_text = getName(); + int _dx = dx; + + if (*left_text) + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(name_start_x, y + height, _dx- (name_start_x - x), left_text, item_color); + + //progress bar + int pb_x; + if (*left_text) + pb_x = std::max(name_start_x + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(left_text) + icon_frame_w, x + dx - scale.getWidth() - icon_frame_w); + else + pb_x = name_start_x; + + scale.setPos(pb_x, y + (height - scale.getHeight())/2); + scale.reset(); + scale.paint(); + + return y + height; +} + +int CMenuProgressbar::getHeight(void) +{ + return std::max(CMenuItem::getHeight(), scale.getHeight()); +} + +int CMenuProgressbar::getWidth(void) +{ + int width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(getName()); + if (width) + width += 10; + return width + scale.getWidth(); +} + +int CMenuProgressbar::exec(CMenuTarget*) +{ + int val = /*scale.getValue()*/ + 25; + if (val > 100) + val = 0; + scale.setValue(val); + scale.reset(); + scale.paint(); + return menu_return::RETURN_NONE; +} diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index e518034f8..30eda797b 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -39,12 +39,12 @@ #include #include #include +#include #include #include #include #include #include - #if ENABLE_LUA extern "C" { #include @@ -73,7 +73,7 @@ class CChangeObserver { public: virtual ~CChangeObserver(){} - virtual bool changeNotify(const neutrino_locale_t /*OptionName*/, void */*Data*/) + virtual bool changeNotify(const neutrino_locale_t /*OptionName*/, void * /*Data*/) { return false; } @@ -101,6 +101,8 @@ class CMenuTarget class CMenuItem { + private: + void setIconName(); protected: int x, y, dx, offx, name_start_x, icon_frame_w; bool used; @@ -108,28 +110,32 @@ class CMenuItem void initItemColors(const bool select_mode); #if ENABLE_LUA - lua_State *luaState; - std::string luaAction; - std::string luaId; + lua_State *luaState; + std::string luaAction; + std::string luaId; #endif - neutrino_locale_t name; - std::string nameString; - + neutrino_locale_t name; + std::string nameString; + neutrino_locale_t desc; + std::string descString; public: - bool active; - bool marked; + int height; + bool active; + bool marked; bool inert; bool isStatic; + bool directKeyOK; neutrino_msg_t directKey; neutrino_msg_t msg; - std::string iconName; - std::string selected_iconName; - std::string iconName_Info_right; - std::string hintIcon; + const char * iconName; + const char * selected_iconName; + const char * iconName_Info_right; + const char * hintIcon; std::string hintText; neutrino_locale_t hint; - CMenuItem(); + CMenuItem(bool Active = true, neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName= NULL, const char * const IconName_Info_right = NULL, bool IsStatic = false); + virtual ~CMenuItem(){} virtual void isUsed(void) @@ -140,17 +146,14 @@ class CMenuItem virtual void init(const int X, const int Y, const int DX, const int OFFX); virtual int paint (bool selected = false) = 0; - virtual int getHeight(void) const = 0; + virtual int getHeight(void); virtual int getWidth(void) { return 0; } virtual int getYPosition(void) const { return y; } - virtual bool isSelectable(void) const - { - return false; - } + virtual bool isSelectable(void) const { return active; } virtual int exec(CMenuTarget* /*parent*/) { @@ -160,34 +163,35 @@ class CMenuItem virtual void setMarked(const bool Marked); virtual void setInert(const bool Inert); - virtual void paintItemButton(const bool select_mode, const int &item_height, const std::string& icon_Name = NEUTRINO_ICON_BUTTON_RIGHT); + virtual void paintItemButton(const bool select_mode, int item_height, const char * const icon_Name = NEUTRINO_ICON_BUTTON_RIGHT); virtual void prepareItem(const bool select_mode, const int &item_height); - virtual void setItemButton(const std::string& icon_Name, const bool is_select_button = false); + virtual void setItemButton(const char * const icon_Name, const bool is_select_button = false); - virtual void paintItemCaption(const bool select_mode, const int &item_height, const char * left_text=NULL, const char * right_text=NULL, const fb_pixel_t right_bgcol=0); + virtual void paintItemCaption(const bool select_mode, const char * right_text=NULL, const fb_pixel_t right_bgcol=0); virtual void paintItemSlider( const bool select_mode, const int &item_height, const int &optionvalue, const int &factor, const char * left_text=NULL, const char * right_text=NULL); virtual int isMenueOptionChooser(void) const{return 0;} - void setHint(const std::string icon, const neutrino_locale_t text) { hintIcon = icon; hint = text; } - void setHint(const std::string icon, const std::string text) { hintIcon = icon; hintText = text; } - + void setHint(const char * const icon, const neutrino_locale_t text) { hintIcon = (icon && *icon) ? icon : NULL; hint = text; } + void setHint(const char * const icon, const std::string text) { hintIcon = (icon && *icon) ? icon : NULL; hintText = text; } #if ENABLE_LUA void setLua(lua_State *_luaState, std::string &_luaAction, std::string &_luaId) { luaState = _luaState; luaAction = _luaAction; luaId = _luaId; }; #endif virtual const char *getName(); + virtual void setName(const std::string& text); + virtual void setName(const neutrino_locale_t text); + + virtual const char *getDescription(); + virtual void setDescription(const std::string& text); + virtual void setDescription(const neutrino_locale_t text); + virtual int getDescriptionHeight(void); }; class CMenuSeparator : public CMenuItem { - private: int type; - void initVarMenuSeparator( const int Type, - const std::string& string_Text, - const neutrino_locale_t locale_Text, - bool IsStatic); public: @@ -204,15 +208,14 @@ class CMenuSeparator : public CMenuItem CMenuSeparator(const int Type = 0, const neutrino_locale_t Text = NONEXISTANT_LOCALE, bool IsStatic = false); - CMenuSeparator(const int Type, const std::string& Text, bool IsStatic = false); + CMenuSeparator(const int Type, const std::string Text, bool IsStatic = false); virtual ~CMenuSeparator(){} int paint(bool selected=false); - int getHeight(void) const; + int getHeight(void); int getWidth(void); - void setName(const std::string& text); - void setName(const neutrino_locale_t text); + bool isSelectable(void) const { return false; } }; class CMenuForwarder : public CMenuItem @@ -220,125 +223,57 @@ class CMenuForwarder : public CMenuItem std::string actionKey; protected: - const char * option; - const std::string * option_string; + std::string option_string; + const std::string * option_string_ptr; CMenuTarget * jumpTarget; virtual std::string getOption(void); - void initVarMenuForwarder( const std::string& string_text, - const neutrino_locale_t& locale_text, - const bool Active, - const std::string * Option_string, - const char * const Option_cstring, - CMenuTarget* Target, - const char * const ActionKey, - neutrino_msg_t DirectKey, - const char * const IconName, - const char * const IconName_Info_right, - bool IsStatic); - public: - CMenuForwarder( const neutrino_locale_t Text, - const bool Active, - const std::string &Option, - CMenuTarget* Target=NULL, - const char * const ActionKey = NULL, - const neutrino_msg_t DirectKey = CRCInput::RC_nokey, - const char * const IconName = NULL, - const char * const IconName_Info_right = NULL, - bool IsStatic = false); - - CMenuForwarder( const std::string& Text, - const bool Active, - const std::string &Option, - CMenuTarget* Target=NULL, - const char * const ActionKey = NULL, - const neutrino_msg_t DirectKey = CRCInput::RC_nokey, - const char * const IconName = NULL, - const char * const IconName_Info_right = NULL, - bool IsStatic = false); - - CMenuForwarder( const neutrino_locale_t Text, - const bool Active = true, - const char * const Option=NULL, - CMenuTarget* Target=NULL, - const char * const ActionKey = NULL, - const neutrino_msg_t DirectKey = CRCInput::RC_nokey, - const char * const IconName = NULL, - const char * const IconName_Info_right = NULL, - bool IsStatic = false); - - CMenuForwarder( const std::string& Text, - const bool Active = true, - const char * const Option=NULL, - CMenuTarget* Target=NULL, - const char * const ActionKey = NULL, - const neutrino_msg_t DirectKey = CRCInput::RC_nokey, - const char * const IconName = NULL, - const char * const IconName_Info_right = NULL, - bool IsStatic = false); - + CMenuForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, + CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, const char * const IconName_Info_right = NULL, bool IsStatic = false); + CMenuForwarder(const std::string & Text, const bool Active, const std::string &Option, + CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, const char * const IconName_Info_right = NULL, bool IsStatic = false); + CMenuForwarder(const neutrino_locale_t Text, const bool Active = true, const char * const Option=NULL, + CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, const char * const IconName_Info_right = NULL, bool IsStatic = false); + CMenuForwarder(const std::string & Text, const bool Active = true, const char * const Option=NULL, + CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, const char * const IconName_Info_right = NULL, bool IsStatic = false); virtual ~CMenuForwarder(){} int paint(bool selected=false); - int getHeight(void) const; int getWidth(void); neutrino_locale_t getTextLocale() const {return name;} CMenuTarget* getTarget() const {return jumpTarget;} const char *getActionKey(){return actionKey.c_str();} int exec(CMenuTarget* parent); - bool isSelectable(void) const { return active; } void setOption(const std::string &Option); - void setOption(const char * const Option); - void setName(const std::string& text); - void setName(const neutrino_locale_t text); }; class CMenuDForwarder : public CMenuForwarder { public: - CMenuDForwarder(const neutrino_locale_t Text, - const bool Active, - const std::string &Option, - CMenuTarget* Target=NULL, - const char * const ActionKey = NULL, - const neutrino_msg_t DirectKey = CRCInput::RC_nokey, - const char * const IconName = NULL, - const char * const IconName_Info_right = NULL) + CMenuDForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, + CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, const char * const IconName_Info_right = NULL) : CMenuForwarder(Text, Active, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right) { }; - - CMenuDForwarder(const std::string& Text, - const bool Active, - const std::string &Option, - CMenuTarget* Target=NULL, - const char * const ActionKey = NULL, - const neutrino_msg_t DirectKey = CRCInput::RC_nokey, - const char * const IconName = NULL, - const char * const IconName_Info_right = NULL) + CMenuDForwarder(const std::string & Text, const bool Active, const std::string &Option, + CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, const char * const IconName_Info_right = NULL) : CMenuForwarder(Text, Active, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right) { }; - - CMenuDForwarder(const neutrino_locale_t Text, - const bool Active=true, - const char * const Option=NULL, - CMenuTarget* Target=NULL, - const char * const ActionKey = NULL, - const neutrino_msg_t DirectKey = CRCInput::RC_nokey, - const char * const IconName = NULL, - const char * const IconName_Info_right = NULL) + CMenuDForwarder(const neutrino_locale_t Text, const bool Active=true, const char * const Option=NULL, + CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, const char * const IconName_Info_right = NULL) : CMenuForwarder(Text, Active, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right) { }; - - CMenuDForwarder(const std::string& Text, - bool Active=true, - const char * const Option=NULL, - CMenuTarget* Target=NULL, - const char * const ActionKey = NULL, - const neutrino_msg_t DirectKey = CRCInput::RC_nokey, - const char * const IconName = NULL, - const char * const IconName_Info_right = NULL) + CMenuDForwarder(const std::string & Text, const bool Active=true, const char * const Option=NULL, + CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, const char * const IconName_Info_right = NULL) : CMenuForwarder(Text, Active, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right) { }; ~CMenuDForwarder() { delete jumpTarget; } @@ -347,17 +282,11 @@ class CMenuDForwarder : public CMenuForwarder class CAbstractMenuOptionChooser : public CMenuItem { protected: - int height; int * optionValue; - int getHeight(void) const{return height;} - - bool isSelectable(void) const{return active;} public: - CAbstractMenuOptionChooser() + CAbstractMenuOptionChooser(bool Active, const neutrino_msg_t DirectKey, const char * const IconName, const char *const IconName_Info_right = NULL, bool IsStatic = false) : CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic) { - name = NONEXISTANT_LOCALE; - height = 0; optionValue = NULL; } ~CAbstractMenuOptionChooser(){} @@ -380,40 +309,17 @@ private: std::string numberFormat; std::string (*numberFormatFunction)(int num); - void initMenuOptionNumberChooser( const std::string &s_name, - const neutrino_locale_t l_name, - int * const OptionValue, - const bool Active, - const int min_value, - const int max_value, - CChangeObserver * const Observ, - const int print_offset, - const int special_value, - const neutrino_locale_t special_value_name, - bool sliderOn); - public: - CMenuOptionNumberChooser(const neutrino_locale_t name, - int * const OptionValue, - const bool Active, - const int min_value, - const int max_value, - CChangeObserver * const Observ = NULL, - const int print_offset = 0, - const int special_value = 0, - const neutrino_locale_t special_value_name = NONEXISTANT_LOCALE, - bool sliderOn = false ); - - CMenuOptionNumberChooser(const std::string &name, - int * const OptionValue, - const bool Active, - const int min_value, - const int max_value, - CChangeObserver * const Observ = NULL, - const int print_offset = 0, - const int special_value = 0, - const neutrino_locale_t special_value_name = NONEXISTANT_LOCALE, - bool sliderOn = false ); + CMenuOptionNumberChooser(const neutrino_locale_t name, int * const OptionValue, const bool Active, + const int min_value, const int max_value, CChangeObserver * const Observ = NULL, + const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, + const int print_offset = 0, + const int special_value = 0, const neutrino_locale_t special_value_name = NONEXISTANT_LOCALE, bool sliderOn = false ); + CMenuOptionNumberChooser(const std::string &name, int * const OptionValue, const bool Active, + const int min_value, const int max_value, CChangeObserver * const Observ = NULL, + const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, + const int print_offset = 0, + const int special_value = 0, const neutrino_locale_t special_value_name = NONEXISTANT_LOCALE, bool sliderOn = false ); int paint(bool selected); @@ -426,7 +332,7 @@ private: }; class CMenuOptionChooserOptions -{ +{ public: int key; std::string valname; @@ -447,168 +353,119 @@ struct CMenuOptionChooserCompareItem: public std::binary_function options; - std::vector option_chooser_options_v; - unsigned number_of_options; - CChangeObserver * observ; - bool pulldown; - bool optionsSort; + private: + std::vector options; + std::vector option_chooser_options_v; + unsigned number_of_options; + CChangeObserver * observ; + bool pulldown; + bool optionsSort; - void clearChooserOptions(); - void initVarOptionChooser( const std::string &OptionName, - const neutrino_locale_t Name, - int * const OptionValue, - const bool Active, - CChangeObserver * const Observ, - neutrino_msg_t DirectKey, - const std::string & IconName, - bool Pulldown, - bool OptionsSort + void clearChooserOptions(); + void initVarOptionChooser( const std::string &OptionName, + const neutrino_locale_t Name, + int * const OptionValue, + const bool Active, + CChangeObserver * const Observ, + neutrino_msg_t DirectKey, + const char * IconName, + bool Pulldown, + bool OptionsSort ); - public: - CMenuOptionChooser( const neutrino_locale_t Name, - int * const OptionValue, - const struct keyval * const Options, - const unsigned Number_Of_Options, - const bool Active = false, - CChangeObserver * const Observ = NULL, - const neutrino_msg_t DirectKey = CRCInput::RC_nokey, - const std::string & IconName= "", + + public: + CMenuOptionChooser(const neutrino_locale_t Name, int * const OptionValue, const struct keyval * const Options, + const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, + const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, bool Pulldown = false, bool OptionsSort = false); + CMenuOptionChooser(const neutrino_locale_t Name, int * const OptionValue, const struct keyval_ext * const Options, + const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, + const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, + bool Pulldown = false, bool OptionsSort = false); + CMenuOptionChooser(const std::string &Name, int * const OptionValue, const struct keyval * const Options, + const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, + const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, + bool Pulldown = false, bool OptionsSort = false); + CMenuOptionChooser(const std::string &Name, int * const OptionValue, const struct keyval_ext * const Options, + const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, + const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, + bool Pulldown = false, bool OptionsSort = false); + CMenuOptionChooser(const neutrino_locale_t Name, int * const OptionValue, std::vector &Options, + const bool Active = false, CChangeObserver * const Observ = NULL, + const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, + bool Pulldown = false, bool OptionsSort = false); + CMenuOptionChooser(const std::string &Name, int * const OptionValue, std::vector &Options, + const bool Active = false, CChangeObserver * const Observ = NULL, + const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, + bool Pulldown = false, bool OptionsSort = false); + ~CMenuOptionChooser(); - CMenuOptionChooser( const neutrino_locale_t Name, - int * const OptionValue, - const struct keyval_ext * const Options, - const unsigned Number_Of_Options, - const bool Active = false, - CChangeObserver * const Observ = NULL, - const neutrino_msg_t DirectKey = CRCInput::RC_nokey, - const std::string & IconName= "", - bool Pulldown = false, - bool OptionsSort = false); + void setOption(const int newvalue); + int getOption(void) const; + int getWidth(void); + void setOptions(const struct keyval * const Options, const unsigned Number_Of_Options); + void setOptions(const struct keyval_ext * const Options, const unsigned Number_Of_Options); - CMenuOptionChooser( const std::string &Name, - int * const OptionValue, const struct keyval * const Options, - const unsigned Number_Of_Options, - const bool Active = false, - CChangeObserver * const Observ = NULL, - const neutrino_msg_t DirectKey = CRCInput::RC_nokey, - const std::string & IconName= "", - bool Pulldown = false, - bool OptionsSort = false); + int paint(bool selected); - CMenuOptionChooser( const std::string &Name, - int * const OptionValue, - const struct keyval_ext * const Options, - const unsigned Number_Of_Options, - const bool Active = false, - CChangeObserver * const Observ = NULL, - const neutrino_msg_t DirectKey = CRCInput::RC_nokey, - const std::string & IconName= "", - bool Pulldown = false, - bool OptionsSort = false); - - CMenuOptionChooser( const neutrino_locale_t Name, - int * const OptionValue, - std::vector &Options, - const bool Active = false, - CChangeObserver * const Observ = NULL, - const neutrino_msg_t DirectKey = CRCInput::RC_nokey, - const std::string & IconName= "", - bool Pulldown = false, - bool OptionsSort = false); - - CMenuOptionChooser( const std::string &Name, - int * const OptionValue, - std::vector &Options, - const bool Active = false, - CChangeObserver * const Observ = NULL, - const neutrino_msg_t DirectKey = CRCInput::RC_nokey, - const std::string & IconName= "", - bool Pulldown = false, - bool OptionsSort = false); - - ~CMenuOptionChooser(); - - void setOption(const int newvalue); - int getOption(void) const; - int getWidth(void); - void setOptions(const struct keyval * const Options, const unsigned Number_Of_Options); - void setOptions(const struct keyval_ext * const Options, const unsigned Number_Of_Options); - - int paint(bool selected); - - int exec(CMenuTarget* parent); - int isMenueOptionChooser(void) const{return 1;} + int exec(CMenuTarget* parent); + int isMenueOptionChooser(void) const{return 1;} }; class CMenuOptionStringChooser : public CMenuItem { - private: - int height; - std::string * optionValueString; + std::string * optionValuePtr; + std::string title; + std::string optionValue; std::vector options; CChangeObserver * observ; bool pulldown; - void initVarMenuOptionStringChooser( const std::string &string_Name, - const neutrino_locale_t locale_Name, - std::string* OptionValue, - bool Active, - CChangeObserver* Observ, - const neutrino_msg_t DirectKey, - const std::string & IconName, - bool Pulldown); public: - CMenuOptionStringChooser( const neutrino_locale_t Name, - std::string* OptionValue, - bool Active = false, - CChangeObserver* Observ = NULL, - const neutrino_msg_t DirectKey = CRCInput::RC_nokey, - const std::string & IconName= "", - bool Pulldown = false); - - CMenuOptionStringChooser( const std::string &Name, - std::string* OptionValue, - bool Active = false, - CChangeObserver* Observ = NULL, - const neutrino_msg_t DirectKey = CRCInput::RC_nokey, - const std::string & IconName= "", - bool Pulldown = false); + CMenuOptionStringChooser(const neutrino_locale_t Name, std::string* OptionValue, bool Active = false, + CChangeObserver* Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, bool Pulldown = false); + CMenuOptionStringChooser(const std::string &Name, std::string* OptionValue, bool Active = false, + CChangeObserver* Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, bool Pulldown = false); ~CMenuOptionStringChooser(); void addOption(const std::string &value); - void removeOptions(){options.clear();}; + void removeOptions(){options.clear();} + void setOptions(std::vector &vec) { options = vec; } + void setTitle(std::string &Title); + void setTitle(const neutrino_locale_t Title); int paint(bool selected); - int getHeight(void) const { return height; } - bool isSelectable(void) const { return active; } void sortOptions(); int exec(CMenuTarget* parent); int isMenueOptionChooser(void) const{return 1;} + void setOptionValue(std::string &val) { + if (!optionValuePtr) optionValuePtr = &optionValue; + *optionValuePtr = val; + } + std::string getOptionValue() { return *optionValuePtr; } }; class CMenuGlobal @@ -633,7 +490,7 @@ class CMenuWidget : public CMenuTarget bool show_details_line; protected: std::string nameString; - neutrino_locale_t name; + neutrino_locale_t name; CFrameBuffer *frameBuffer; std::vector items; std::vector page_start; @@ -652,24 +509,24 @@ class CMenuWidget : public CMenuTarget int selected; int iconOffset; int sb_width; - int sb_height; fb_pixel_t *background; int full_width, full_height; bool savescreen; bool has_hints; // is any items has hints bool hint_painted; // is hint painted + int fbutton_width; int fbutton_height; int fbutton_count; const struct button_label *fbutton_labels; - unsigned int item_start_y; - unsigned int current_page; - unsigned int total_pages; - bool exit_pressed; - bool from_wizard; - bool fade; - bool washidden; + unsigned int item_start_y; + unsigned int current_page; + unsigned int total_pages; + bool exit_pressed; + bool from_wizard; + bool fade; + bool washidden; void Init(const std::string & Icon, const int mwidth, const mn_widget_id_t &w_index); virtual void paintItems(); @@ -682,7 +539,7 @@ class CMenuWidget : public CMenuTarget public: CMenuWidget(); /* mwidth (minimum width) in percent of screen width */ - CMenuWidget(const char* Name, const std::string & Icon = "", const int mwidth = 30, const mn_widget_id_t &w_index = NO_WIDGET_ID); + CMenuWidget(const std::string &Name, const std::string & Icon = "", const int mwidth = 30, const mn_widget_id_t &w_index = NO_WIDGET_ID); CMenuWidget(const neutrino_locale_t Name, const std::string & Icon = "", const int mwidth = 30, const mn_widget_id_t &w_index = NO_WIDGET_ID); ~CMenuWidget(); @@ -690,10 +547,10 @@ class CMenuWidget : public CMenuTarget enum { - BTN_TYPE_BACK = 0, - BTN_TYPE_CANCEL = 1, - BTN_TYPE_NEXT = 3, - BTN_TYPE_NO = -1 + BTN_TYPE_BACK = 0, + BTN_TYPE_CANCEL = 1, + BTN_TYPE_NEXT = 3, + BTN_TYPE_NO = -1 }; virtual void addIntroItems(neutrino_locale_t subhead_text = NONEXISTANT_LOCALE, neutrino_locale_t section_text = NONEXISTANT_LOCALE, int buttontype = BTN_TYPE_BACK ); bool hasItem(); @@ -706,7 +563,7 @@ class CMenuWidget : public CMenuTarget virtual void paint(); virtual void hide(); virtual int exec(CMenuTarget* parent, const std::string & actionKey); - virtual std::string getName(); + virtual const char *getName(); void setSelected(const int &Preselected){ preselected = Preselected; }; int getSelected()const { return selected; }; void move(int xoff, int yoff); @@ -782,8 +639,6 @@ class CLockedMenuForwarder : public CMenuForwarder, public CPINProtection //but use always an info icon if defined in parameter 'IconName_Info_right' if (IconName_Info_right || ask) iconName_Info_right = IconName_Info_right ? IconName_Info_right : NEUTRINO_ICON_LOCK; - else - iconName_Info_right = ""; }; virtual int exec(CMenuTarget* parent); @@ -791,12 +646,30 @@ class CLockedMenuForwarder : public CMenuForwarder, public CPINProtection class CMenuSelectorTarget : public CMenuTarget { - public: - CMenuSelectorTarget(int *select) {m_select = select;}; - int exec(CMenuTarget* parent, const std::string & actionKey); + public: + CMenuSelectorTarget(int *select) {m_select = select;}; + int exec(CMenuTarget* parent, const std::string & actionKey); - private: - int *m_select; + private: + int *m_select; +}; + +class CMenuProgressbar : public CMenuItem +{ + private: + CProgressBar scale; + void init (const neutrino_locale_t Loc, const std::string & Text); + public: + + CMenuProgressbar(const neutrino_locale_t Text); + CMenuProgressbar(const std::string & Text); + virtual ~CMenuProgressbar(){} + + int paint(bool selected=false); + int getWidth(void); + int getHeight(void); + int exec(CMenuTarget *parent); + CProgressBar *getScale() { return &scale; } }; extern CMenuSeparator * const GenericMenuSeparator; diff --git a/src/system/helpers.h b/src/system/helpers.h index 8f1a13bbf..9d5874cf2 100644 --- a/src/system/helpers.h +++ b/src/system/helpers.h @@ -22,10 +22,16 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include +#include +#include #include #include #include #include +#include +#include +#include #include int my_system(const char * cmd); @@ -88,4 +94,10 @@ template std::string to_string(C i) inline void cstrncpy(char *dest, const char * const src, size_t n) { n--; strncpy(dest, src, n); dest[n] = 0; } inline void cstrncpy(char *dest, const std::string &src, size_t n) { n--; strncpy(dest, src.c_str(), n); dest[n] = 0; } bool split_config_string(const std::string &str, std::map &smap); + +inline int atoi(std::string &s) { return atoi(s.c_str()); } +inline int atoi(const std::string &s) { return atoi(s.c_str()); } +inline int access(std::string &s, int mode) { return access(s.c_str(), mode); } +inline int access(const std::string &s, int mode) { return access(s.c_str(), mode); } + #endif