trunk 20080912
[gitenigma.git] / src / setup_lcd.cpp
blob9cf0bd38ac8c67f9570ce8cd083c2e36752e5532
1 #ifndef DISABLE_LCD
2 #include <setup_lcd.h>
4 #include <lib/gui/slider.h>
5 #include <lib/gui/ebutton.h>
6 #include <lib/gui/echeckbox.h>
7 #include <lib/gui/elabel.h>
8 #include <lib/gui/enumber.h>
9 #include <lib/gui/eskin.h>
10 #include <lib/system/econfig.h>
11 #include <lib/base/i18n.h>
12 #include <lib/dvb/dvbwidgets.h>
13 #include <lib/gdi/lcd.h>
15 void eZapLCDSetup::brightnessChanged( int i )
17 eDebug("Brightness changed to %i", i);
18 lcdbrightness = i;
19 update(lcdbrightness, lcdcontrast);
22 void eZapLCDSetup::contrastChanged( int i )
24 eDebug("contrast changed to %i", i);
25 lcdcontrast = i;
26 update(lcdbrightness, lcdcontrast);
29 void eZapLCDSetup::standbyChanged( int i )
31 eDebug("standby changed to %i", i);
32 lcdstandby = i;
33 update(lcdstandby, lcdcontrast);
36 void eZapLCDSetup::invertedChanged( int i )
38 eDebug("invertion changed to %s", (i?"inverted":"not inverted") );
39 eDBoxLCD::getInstance()->setInverted( i?255:0 );
42 void eZapLCDSetup::update(int brightness, int contrast)
44 eDBoxLCD::getInstance()->setLCDParameter(brightness, contrast);
47 eZapLCDSetup::eZapLCDSetup()
48 :eWindow(0)
50 init_eZapLCDSetup();
53 void eZapLCDSetup::init_eZapLCDSetup()
55 setText(_("LC-Display Setup"));
56 move(ePoint(150, 126));
57 cresize(eSize(400, 290));
59 int fd=eSkin::getActive()->queryValue("fontsize", 20);
61 eConfig::getInstance()->getKey("/ezap/lcd/brightness", lcdbrightness);
62 eConfig::getInstance()->getKey("/ezap/lcd/contrast", lcdcontrast);
63 eConfig::getInstance()->getKey("/ezap/lcd/standby", lcdstandby );
64 int tmp;
65 eConfig::getInstance()->getKey("/ezap/lcd/inverted", tmp );
66 unsigned char lcdinverted = (unsigned char) tmp;
68 bbrightness=new eLabel(this);
69 bbrightness->setText(_("Brightness:"));
70 bbrightness->move(ePoint(20, 20));
71 bbrightness->resize(eSize(110, fd+4));
73 bcontrast=new eLabel(this);
74 bcontrast->setText(_("Contrast:"));
75 bcontrast->move(ePoint(20, 60));
76 bcontrast->resize(eSize(110, fd+4));
78 bstandby=new eLabel(this);
79 bstandby->setText(_("Standby:"));
80 bstandby->move(ePoint(20, 100));
81 bstandby->resize(eSize(110, fd+4));
83 p_brightness=new eSlider(this, bbrightness, 0, LCD_BRIGHTNESS_MAX );
84 p_brightness->setName("brightness");
85 p_brightness->move(ePoint(140, 20));
86 p_brightness->resize(eSize(240, fd+4));
87 p_brightness->setHelpText(_("set LCD brightness ( left / right )"));
88 CONNECT( p_brightness->changed, eZapLCDSetup::brightnessChanged );
90 p_contrast=new eSlider(this, bcontrast, 0, LCD_CONTRAST_MAX );
91 p_contrast->setName("contrast");
92 p_contrast->move(ePoint(140, 60));
93 p_contrast->resize(eSize(240, fd+4));
94 p_contrast->setHelpText(_("set LCD contrast ( left / right )"));
95 CONNECT( p_contrast->changed, eZapLCDSetup::contrastChanged );
97 p_standby=new eSlider(this, bstandby, 0, LCD_BRIGHTNESS_MAX );
98 p_standby->setName("standby");
99 p_standby->move(ePoint(140, 100));
100 p_standby->resize(eSize(240, fd+4));
101 p_standby->setHelpText(_("set LCD brightness for Standby Mode ( left / right )"));
102 CONNECT( p_standby->changed, eZapLCDSetup::standbyChanged );
104 inverted=new eCheckbox(this);
105 inverted->move(ePoint(20, 140));
106 inverted->resize(eSize(150, fd+4));
107 inverted->setText(_("Inverted: "));
108 inverted->setCheck(lcdinverted);
109 inverted->setHelpText(_("enable/disable inverted LCD (ok)"));
110 CONNECT( inverted->checked, eZapLCDSetup::invertedChanged );
112 ok=new eButton(this);
113 ok->setText(_("save"));
114 ok->setShortcut("green");
115 ok->setShortcutPixmap("green");
116 ok->move(ePoint(20, 190));
117 ok->resize(eSize(220, 40));
118 ok->setHelpText(_("save changes and return"));
119 ok->loadDeco();
120 CONNECT(ok->selected, eZapLCDSetup::okPressed);
122 statusbar=new eStatusBar(this);
123 statusbar->move( ePoint(0, clientrect.height()-50 ) );
124 statusbar->resize( eSize( clientrect.width(), 50) );
125 statusbar->loadDeco();
127 p_brightness->setValue(lcdbrightness);
128 p_contrast->setValue(lcdcontrast);
129 p_standby->setValue(lcdstandby);
131 setHelpID(84);
134 eZapLCDSetup::~eZapLCDSetup()
138 void eZapLCDSetup::okPressed()
140 eConfig::getInstance()->setKey("/ezap/lcd/brightness", lcdbrightness);
141 eConfig::getInstance()->setKey("/ezap/lcd/contrast", lcdcontrast);
142 eConfig::getInstance()->setKey("/ezap/lcd/standby", lcdstandby);
143 eConfig::getInstance()->setKey("/ezap/lcd/inverted", inverted->isChecked()?255:0 );
144 eConfig::getInstance()->flush();
145 update(lcdbrightness, lcdcontrast);
146 close(1);
149 int eZapLCDSetup::eventHandler( const eWidgetEvent& e)
151 switch (e.type)
153 case eWidgetEvent::execDone:
154 eConfig::getInstance()->getKey("/ezap/lcd/brightness", lcdbrightness);
155 eConfig::getInstance()->getKey("/ezap/lcd/contrast", lcdcontrast);
156 eDBoxLCD::getInstance()->setInverted( inverted->isChecked()?255:0 );
157 update(lcdbrightness, lcdcontrast);
158 break;
159 default:
160 return eWindow::eventHandler( e );
162 return 1;
165 #endif //DISABLE_LCD