Files
neutrino/src/gui/vfd_setup.cpp
satbaby aac749a682 vfd: rework vfd menu (use ItemSlider), vfdcontroler deprecated
git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1420 e54a6e83-5905-42d5-8d5c-058d10e6a962
2011-05-02 10:57:53 +00:00

182 lines
6.9 KiB
C++

/*
$similar port: lcd_setup.cpp,v 1.1 2010/07/30 20:52:16 tuxbox-cvs Exp $
vfd setup implementation, similar to lcd_setup.cpp of tuxbox-cvs - Neutrino-GUI
Copyright (C) 2001 Steffen Hehn 'McClean'
and some other guys
Homepage: http://dbox.cyberphoria.org/
Copyright (C) 2010 T. Graf 'dbt'
Homepage: http://www.dbox2-tuning.net/
License: GPL
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gui/vfd_setup.h"
#include <global.h>
#include <neutrino.h>
#include <mymenu.h>
#include <gui/widget/icons.h>
#include <gui/widget/vfdcontroler.h>
#include <gui/widget/stringinput.h>
#include <driver/screen_max.h>
#include <system/debug.h>
#include <cs_api.h>
CVfdSetup::CVfdSetup()
{
width = w_max (40, 10);
selected = -1;
}
CVfdSetup::~CVfdSetup()
{
}
int CVfdSetup::exec(CMenuTarget* parent, const std::string &actionKey)
{
dprintf(DEBUG_DEBUG, "init lcd setup\n");
if(parent != NULL)
parent->hide();
if(actionKey=="def")
{
brightness = DEFAULT_VFD_BRIGHTNESS;
brightnessstandby = DEFAULT_VFD_STANDBYBRIGHTNESS;
brightnessdeepstandby = DEFAULT_VFD_STANDBYBRIGHTNESS;
CVFD::getInstance()->setBrightness(brightness);
CVFD::getInstance()->setBrightnessStandby(brightnessstandby);
CVFD::getInstance()->setBrightnessDeepStandby(brightnessdeepstandby);
return menu_return::RETURN_REPAINT;;
}
showSetup();
return menu_return::RETURN_REPAINT;
}
#define LCDMENU_STATUSLINE_OPTION_COUNT 2
const CMenuOptionChooser::keyval LCDMENU_STATUSLINE_OPTIONS[LCDMENU_STATUSLINE_OPTION_COUNT] =
{
{ 0, LOCALE_LCDMENU_STATUSLINE_PLAYTIME },
{ 1, LOCALE_LCDMENU_STATUSLINE_VOLUME }
//,{ 2, LOCALE_LCDMENU_STATUSLINE_BOTH }
};
#define LEDMENU_OPTION_COUNT 4
const CMenuOptionChooser::keyval LEDMENU_OPTIONS[LEDMENU_OPTION_COUNT] =
{
{ 0, LOCALE_LEDCONTROLER_OFF },
{ 1, LOCALE_LEDCONTROLER_ON_ALL },
{ 2, LOCALE_LEDCONTROLER_ON_LED1 },
{ 3, LOCALE_LEDCONTROLER_ON_LED2 }
};
#define LCD_INFO_OPTION_COUNT 2
const CMenuOptionChooser::keyval LCD_INFO_OPTIONS[LCD_INFO_OPTION_COUNT] =
{
{ 0, LOCALE_LCD_INFO_LINE_CHANNEL },
{ 1, LOCALE_LCD_INFO_LINE_CLOCK }
};
void CVfdSetup::showSetup()
{
CMenuWidget *vfds = new CMenuWidget(LOCALE_MAINMENU_SETTINGS, NEUTRINO_ICON_LCD, width);
vfds->addIntroItems(LOCALE_LCDMENU_HEAD);
vfds->setSelected(selected);
bool vfd_enabled = (cs_get_revision() != 10);
CMenuWidget* lcdsliders = new CMenuWidget(LOCALE_LCDMENU_HEAD, NEUTRINO_ICON_LCD,width);
lcdsliders->addIntroItems(LOCALE_LCDMENU_LCDCONTROLER);
lcdsliders->setSelected(selected);
//vfd
brightness = CVFD::getInstance()->getBrightness();
brightnessstandby = CVFD::getInstance()->getBrightnessStandby();
brightnessdeepstandby = CVFD::getInstance()->getBrightnessDeepStandby();
lcdsliders->addItem(new CMenuOptionNumberChooser(LOCALE_LCDCONTROLER_BRIGHTNESS, &brightness, true, 0, 15, this, 0, 0, NONEXISTANT_LOCALE, NULL, true));
lcdsliders->addItem(new CMenuOptionNumberChooser(LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY, &brightnessstandby, true, 0, 15, this, 0, 0, NONEXISTANT_LOCALE, NULL, true));
if(cs_get_revision() > 7)
lcdsliders->addItem(new CMenuOptionNumberChooser(LOCALE_LCDCONTROLER_BRIGHTNESSDEEPSTANDBY, &brightnessdeepstandby, true, 0, 15, this, 0, 0, NONEXISTANT_LOCALE, NULL, true));
lcdsliders->addItem(GenericMenuSeparatorLine);
lcdsliders->addItem(new CMenuForwarder(LOCALE_OPTIONS_DEFAULT, true, NULL, this, "def", CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED));
lcdsliders->addItem(GenericMenuSeparatorLine);
lcdsliders->addItem(new CMenuOptionNumberChooser(LOCALE_LCDMENU_DIM_BRIGHTNESS, &g_settings.lcd_setting_dim_brightness, vfd_enabled, -1, 15, NULL, 0, -1, LOCALE_OPTIONS_OFF, NULL, true));
CStringInput * dim_time = new CStringInput(LOCALE_LCDMENU_DIM_TIME, g_settings.lcd_setting_dim_time, 3, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE,"0123456789 ");
lcdsliders->addItem(new CMenuForwarder(LOCALE_LCDMENU_DIM_TIME, vfd_enabled, g_settings.lcd_setting_dim_time,dim_time));
vfds->addItem(new CMenuForwarder(LOCALE_LCDMENU_LCDCONTROLER, vfd_enabled, NULL, lcdsliders, NULL, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED));
if(cs_get_revision() > 7)
{
CMenuWidget * ledMenu = new CMenuWidget(LOCALE_LCDMENU_HEAD, NEUTRINO_ICON_LCD);
ledMenu->addIntroItems(LOCALE_LEDCONTROLER_MENU);
ledMenu->addItem(new CMenuOptionChooser(LOCALE_LEDCONTROLER_MODE_TV, &g_settings.led_tv_mode, LEDMENU_OPTIONS, LEDMENU_OPTION_COUNT, true, new CLedControlNotifier()));
ledMenu->addItem(new CMenuOptionChooser(LOCALE_LEDCONTROLER_MODE_STANDBY, &g_settings.led_standby_mode, LEDMENU_OPTIONS, LEDMENU_OPTION_COUNT, true));
ledMenu->addItem(new CMenuOptionChooser(LOCALE_LEDCONTROLER_MODE_DEEPSTANDBY, &g_settings.led_deep_mode, LEDMENU_OPTIONS, LEDMENU_OPTION_COUNT, true));
ledMenu->addItem(new CMenuOptionChooser(LOCALE_LEDCONTROLER_MODE_RECORD, &g_settings.led_rec_mode, LEDMENU_OPTIONS, LEDMENU_OPTION_COUNT, true));
ledMenu->addItem(new CMenuOptionChooser(LOCALE_LEDCONTROLER_BLINK, &g_settings.led_blink, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true));
vfds->addItem(new CMenuForwarder(LOCALE_LEDCONTROLER_MENU, true, NULL, ledMenu, NULL, CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN));
}
vfds->addItem(GenericMenuSeparatorLine);
CMenuOptionChooser* oj = new CMenuOptionChooser(LOCALE_LCDMENU_STATUSLINE, &g_settings.lcd_setting[SNeutrinoSettings::LCD_SHOW_VOLUME], LCDMENU_STATUSLINE_OPTIONS, LCDMENU_STATUSLINE_OPTION_COUNT, vfd_enabled);
CMenuOptionChooser* lcd_clock_channelname_menu = new CMenuOptionChooser(LOCALE_LCD_INFO_LINE, &g_settings.lcd_info_line, LCD_INFO_OPTIONS, LCD_INFO_OPTION_COUNT, vfd_enabled);
vfds->addItem(oj);
vfds->addItem(lcd_clock_channelname_menu);
vfds->exec(NULL, "");
vfds->hide();
selected = vfds->getSelected();
delete vfds;
}
bool CVfdSetup::changeNotify(const neutrino_locale_t OptionName, void */* data */)
{
if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LCDCONTROLER_BRIGHTNESS))
{
CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO);
CVFD::getInstance()->setBrightness(brightness);
}
else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY))
{
CVFD::getInstance()->setMode(CVFD::MODE_STANDBY);
CVFD::getInstance()->setBrightnessStandby(brightnessstandby);
}
else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LCDCONTROLER_BRIGHTNESSDEEPSTANDBY))
{
CVFD::getInstance()->setBrightnessDeepStandby(brightnessdeepstandby);
}
return true;
}