5 #include <enigma_main.h>
6 #include <lib/base/i18n.h>
7 #include <lib/dvb/edvb.h>
8 #include <lib/gdi/gfbdc.h>
9 #include <lib/gdi/font.h>
10 #include <lib/gui/eskin.h>
11 #include <lib/gui/ebutton.h>
12 #include <lib/gui/echeckbox.h>
13 #include <lib/gui/guiactions.h>
14 #include <lib/gui/slider.h>
15 #include <lib/gui/statusbar.h>
16 #include <lib/gui/emessage.h>
17 #include <lib/system/econfig.h>
18 #include <lib/system/info.h>
19 #include <lib/system/init.h>
20 #include <lib/system/init_num.h>
22 class PluginOffsetScreen
: public eWidget
24 enum { posLeftTop
, posRightBottom
} curPos
;
26 int eventHandler( const eWidgetEvent
& e
);
27 int left
, top
, right
, bottom
;
28 void redrawLeftTop( gPainter
*target
);
29 void redrawRightBottom( gPainter
*target
);
30 void redrawWidget(gPainter
*target
, const eRect
&where
);
31 gColor foreColor
, backColor
;
36 struct PluginOffsetActions
39 eAction leftTop
, rightBottom
, store
;
41 :map("PluginOffsetActions", _("PluginOffsetActions")),
42 leftTop(map
,"leftTop", _("enable set the leftTop Point of the rectangle")),
43 rightBottom(map
,"rightBottom", _("enable set the rightBottom Point of the rectangle")),
44 store(map
, "store", _("saves the current positions"))
49 eAutoInitP0
<PluginOffsetActions
> i_PluginOffsetActions(eAutoInitNumbers::actions
, "tuxtxt offset actions");
51 int PluginOffsetScreen::eventHandler( const eWidgetEvent
&event
)
55 case eWidgetEvent::execBegin
:
56 eConfig::getInstance()->getKey("/enigma/plugins/needoffsets/left", left
);
57 eConfig::getInstance()->getKey("/enigma/plugins/needoffsets/top", top
);
58 eConfig::getInstance()->getKey("/enigma/plugins/needoffsets/right", right
);
59 eConfig::getInstance()->getKey("/enigma/plugins/needoffsets/bottom", bottom
);
62 case eWidgetEvent::execDone
:
63 eConfig::getInstance()->setKey("/enigma/plugins/needoffsets/left", left
);
64 eConfig::getInstance()->setKey("/enigma/plugins/needoffsets/top", top
);
65 eConfig::getInstance()->setKey("/enigma/plugins/needoffsets/right", right
);
66 eConfig::getInstance()->setKey("/enigma/plugins/needoffsets/bottom", bottom
);
68 case eWidgetEvent::willShow
:
71 case eWidgetEvent::evtAction
:
72 if (event
.action
== &i_PluginOffsetActions
->leftTop
)
77 else if (event
.action
== &i_PluginOffsetActions
->rightBottom
)
79 curPos
=posRightBottom
;
82 else if (event
.action
== &i_cursorActions
->cancel
)
87 else if (event
.action
== &i_PluginOffsetActions
->store
)
92 else if (event
.action
== &i_cursorActions
->left
)
94 if ( curPos
== posLeftTop
)
96 else if (curPos
== posRightBottom
)
99 else if (event
.action
== &i_cursorActions
->right
)
101 if ( curPos
== posLeftTop
)
103 else if (curPos
== posRightBottom
)
106 else if (event
.action
== &i_cursorActions
->up
)
108 if ( curPos
== posLeftTop
)
110 else if (curPos
== posRightBottom
)
113 else if (event
.action
== &i_cursorActions
->down
)
115 if ( curPos
== posLeftTop
)
117 else if (curPos
== posRightBottom
)
122 if ( curPos
== posLeftTop
)
123 invalidate( eRect( ePoint(left
-1, top
-1), eSize(102, 102) ) );
124 else if ( curPos
== posRightBottom
)
125 invalidate( eRect( ePoint(right
-101, bottom
-101), eSize(102, 102) ) );
130 return eWidget::eventHandler( event
);
133 void PluginOffsetScreen::redrawLeftTop( gPainter
*target
)
135 target
->fill( eRect( ePoint( left
, top
), eSize( 100, 3 ) ) );
136 target
->fill( eRect( ePoint( left
, top
), eSize( 3, 100 ) ) );
139 void PluginOffsetScreen::redrawRightBottom( gPainter
*target
)
141 target
->fill( eRect( ePoint( right
-3, bottom
-100 ), eSize( 3, 100 ) ) );
142 target
->fill( eRect( ePoint( right
-100, bottom
-3 ), eSize( 100, 3 ) ) );
145 void PluginOffsetScreen::redrawWidget(gPainter
*target
, const eRect
&where
)
147 target
->setForegroundColor( foreColor
);
148 if ( where
.intersects( eRect( ePoint( left
, top
), eSize( 100, 100 ) ) ) )
149 redrawLeftTop( target
);
150 if ( where
.intersects( eRect( ePoint( right
-3, bottom
-100 ), eSize( 3, 100 ) ) ) )
151 redrawRightBottom( target
);
154 PluginOffsetScreen::PluginOffsetScreen()
155 :eWidget(0, 1), curPos( posLeftTop
),
156 left(20), top(20), right( 699 ), bottom( 555 )
158 foreColor
= eSkin::getActive()->queryColor("eWindow.titleBarFont");
159 setForegroundColor( foreColor
);
161 resize(eSize(768,576));
162 descr
= new eLabel( this );
163 descr
->setFlags( eLabel::flagVCenter
|RS_WRAP
);
164 descr
->setForegroundColor( foreColor
);
165 descr
->resize(eSize(568,300));
166 descr
->move(ePoint(100,100));
167 descr
->setText(_("here you can center the tuxtxt rectangle...\npress red to select the left top edge\npress green to select the right bottom edge\nuse the cursor keys to move the selected edges"));
168 eSize ext
= descr
->getExtend();
169 ext
+=eSize(8,4); // the given Size of the Text is okay... but the renderer sucks...
170 descr
->resize( ext
);
171 descr
->move( ePoint( (width()/2)-(ext
.width()/2) , (height()/2)-(ext
.height()/2) ) );
173 addActionMap(&i_PluginOffsetActions
->map
);
174 addActionMap(&i_cursorActions
->map
);
175 addActionToHelpList( &i_PluginOffsetActions
->leftTop
);
176 addActionToHelpList( &i_PluginOffsetActions
->rightBottom
);
180 eZapOsdSetup::eZapOsdSetup()
186 void eZapOsdSetup::init_eZapOsdSetup()
188 setText(_("OSD Settings"));
189 cmove(ePoint(140, 125));
190 cresize(eSize(460, 350));
192 int fd
=eSkin::getActive()->queryValue("fontsize", 20);
194 alpha
= gFBDC::getInstance()->getAlpha();
195 eLabel
* l
= new eLabel(this);
196 l
->setText(_("Alpha:"));
197 l
->move(ePoint(20, 20));
198 l
->resize(eSize(110, fd
+4));
199 sAlpha
= new eSlider( this, l
, 0, 512 );
200 sAlpha
->setIncrement( eSystemInfo::getInstance()->getAlphaIncrement() ); // Percent !
202 sAlpha
->move( ePoint( 150, 20 ) );
203 sAlpha
->resize(eSize( 290, fd
+4 ) );
204 sAlpha
->setHelpText(_("change the transparency correction"));
205 sAlpha
->setValue( alpha
);
206 CONNECT( sAlpha
->changed
, eZapOsdSetup::alphaChanged
);
208 brightness
= gFBDC::getInstance()->getBrightness();
209 l
= new eLabel(this);
210 l
->setText(_("Brightness:"));
211 l
->move(ePoint(20, 60));
212 l
->resize(eSize(120, fd
+4));
213 sBrightness
= new eSlider( this, l
, 0, 255 );
214 sBrightness
->setIncrement( 5 ); // Percent !
215 sBrightness
->move( ePoint( 150, 60 ) );
216 sBrightness
->resize(eSize( 290, fd
+4 ) );
217 sBrightness
->setHelpText(_("change the brightness correction"));
218 sBrightness
->setValue( brightness
);
219 CONNECT( sBrightness
->changed
, eZapOsdSetup::brightnessChanged
);
221 gamma
= gFBDC::getInstance()->getGamma();
222 l
= new eLabel(this);
223 l
->setText(_("Contrast:"));
224 l
->move(ePoint(20, 100));
225 l
->resize(eSize(120, fd
+4));
226 sGamma
= new eSlider( this, l
, 0, 255 );
227 sGamma
->setIncrement( 5 ); // Percent !
228 sGamma
->move( ePoint( 150, 100 ) );
229 sGamma
->resize(eSize( 290, fd
+4 ) );
230 sGamma
->setHelpText(_("change the contrast"));
231 sGamma
->setValue( gamma
);
232 CONNECT( sGamma
->changed
, eZapOsdSetup::gammaChanged
);
234 simpleMainMenu
=new eCheckbox(this);
235 simpleMainMenu
->setText(_("Show Mainmenu like Listbox"));
236 simpleMainMenu
->setHelpText(_("show the Mainmenu in normal listbox style"));
237 simpleMainMenu
->move(ePoint(20,140));
238 simpleMainMenu
->resize(eSize(420,35));
240 eConfig::getInstance()->getKey("/ezap/osd/simpleMainMenu", bla
);
241 simpleMainMenu
->setCheck(bla
);
243 skin
=new eButton(this);
244 skin
->setText(_("Change skin"));
245 skin
->setShortcut("blue");
246 skin
->setShortcutPixmap("blue");
247 skin
->move(ePoint(20, 190));
248 skin
->resize(eSize(205, 40));
250 skin
->setHelpText(_("press ok to open skin selector"));
251 CONNECT( skin
->selected
, eZapOsdSetup::skinPressed
);
253 pluginoffs
=new eButton(this);
254 pluginoffs
->setText(_("TuxText position"));
255 pluginoffs
->setHelpText(_("here you can center the Tuxtxt (builtin videotext)"));
256 pluginoffs
->setShortcut("yellow");
257 pluginoffs
->setShortcutPixmap("yellow");
258 pluginoffs
->move(ePoint(235, 190));
259 pluginoffs
->resize(eSize(205, 40));
260 pluginoffs
->loadDeco();
261 CONNECT( pluginoffs
->selected
, eZapOsdSetup::pluginPositionPressed
);
263 ok
=new eButton(this);
264 ok
->setText(_("save"));
265 ok
->setShortcut("green");
266 ok
->setShortcutPixmap("green");
267 ok
->move(ePoint(20, 245));
268 ok
->resize(eSize(205, 40));
269 ok
->setHelpText(_("save changes and return"));
272 CONNECT(ok
->selected
, eZapOsdSetup::okPressed
);
274 statusbar
=new eStatusBar(this);
275 statusbar
->move( ePoint(0, clientrect
.height()-50 ) );
276 statusbar
->resize( eSize( clientrect
.width(), 50) );
277 statusbar
->loadDeco();
281 eZapOsdSetup::~eZapOsdSetup()
285 void eZapOsdSetup::alphaChanged( int i
)
288 gFBDC::getInstance()->setAlpha(alpha
);
291 void eZapOsdSetup::brightnessChanged( int i
)
294 gFBDC::getInstance()->setBrightness(brightness
);
297 void eZapOsdSetup::gammaChanged( int i
)
300 gFBDC::getInstance()->setGamma(gamma
);
303 void eZapOsdSetup::pluginPositionPressed()
305 eWidget
*oldfocus
=focus
;
307 PluginOffsetScreen scr
;
315 void eZapOsdSetup::okPressed()
317 eConfig::getInstance()->setKey("/ezap/osd/simpleMainMenu", simpleMainMenu
->isChecked());
318 gFBDC::getInstance()->saveSettings();
319 eConfig::getInstance()->flush();
323 void eZapOsdSetup::skinPressed()
325 eWidget
*oldfocus
=focus
;
330 setup
.setLCD(LCDTitle
, LCDElement
);
337 eMessageBox
msg(_("You have to restart enigma to apply the new skin\nRestart now?"), _("Skin changed"), eMessageBox::btYes
|eMessageBox::btNo
|eMessageBox::iconQuestion
, eMessageBox::btYes
);
339 int ret
= msg
.exec();
341 if ( ret
== eMessageBox::btYes
)
343 if ( eZapMain::getInstance()->checkRecordState() )
344 eZap::getInstance()->quit(2);
352 int eZapOsdSetup::eventHandler( const eWidgetEvent
&e
)
356 case eWidgetEvent::execDone
:
358 gFBDC::getInstance()->reloadSettings();
362 return eWindow::eventHandler( e
);