• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

A method to our madness....... PANEL

fergy

Member +
Joined
Jan 11, 2007
Messages
170
Likes
3
#1
NOTE THAT THIS EXAMPLE IS NOT FOR BEGINNERS but anyway, this will introduce You how easy is to make new control panel.
For first I will explain how things going and if anyone want to try, I will help.
Please, don't let this scare You. Nobody is perfect and also nobody of us was NOT BORN as Einstein!!!!! : multi :

In order to add into our cvs image an control panel, some parts of enigma We must change.

OK, let's start:
The advanced formulation, We want enter here........ who would not want to enter in the room of the buttons! : colors1
An look to enigma sources

setup_extra.cpp

Code:
.............................................
eExpertSetup::eExpertSetup()
	:eSetupWindow(_("Expert Setup"), 10, 400)
{
	init_eExpertSetup();
}

void eExpertSetup::init_eExpertSetup()
{
	cmove(ePoint(170, 115));

	int lockWebIf=1;
	if ( eConfig::getInstance()->getKey("/ezap/webif/lockWebIf", lockWebIf) )
		eConfig::getInstance()->setKey("/ezap/webif/lockWebIf", lockWebIf);

	int showSatPos=1;
	if ( eConfig::getInstance()->getKey("/extras/showSatPos", showSatPos) )
		eConfig::getInstance()->setKey("/extras/showSatPos", showSatPos);

	int entry=0;
#ifndef DISABLE_NETWORK
	if (eSystemInfo::getInstance()->hasNetwork())
	{
		CONNECT((new eListBoxEntryMenu(&list, _("Communication Setup"), eString().sprintf("(%d) %s", ++entry, _("open communication setup")) ))->selected, eExpertSetup::communication_setup);
		CONNECT((new eListBoxEntryMenu(&list, _("Ngrab Streaming Setup"), eString().sprintf("(%d) %s", ++entry, _("open ngrab server setup")) ))->selected, eExpertSetup::ngrab_setup);
		if ( eSystemInfo::getInstance()->getHwType() != eSystemInfo::DM7020 )  // no update for 7020 yet
			CONNECT((new eListBoxEntryMenu(&list, _("Software Update"), eString().sprintf("(%d) %s", ++entry, _("open software update")) ))->selected, eExpertSetup::software_update);
	}
	int startSamba=1;
	if ( eConfig::getInstance()->getKey("/elitedvb/network/samba", startSamba) )
		eConfig::getInstance()->setKey("/elitedvb/network/samba", startSamba);
#endif
	CONNECT((new eListBoxEntryMenu(&list, _("Remote Control"), eString().sprintf("(%d) %s", ++entry, _("open remote control setup")) ))->selected, eExpertSetup::rc_setup);
	if ( eSystemInfo::getInstance()->getHwType() >= eSystemInfo::DM7000 )
		CONNECT((new eListBoxEntryMenu(&list, _("Factory reset"), eString().sprintf("(%d) %s", ++entry, _("all settings will set to factory defaults")) ))->selected, eExpertSetup::factory_reset);
	new eListBoxEntryMenuSeparator(&list, eSkin::getActive()->queryImage("listbox.separator"), 0, true );
	list.setFlags(list.getFlags()|eListBoxBase::flagNoPageMovement);
#ifndef DISABLE_FILE
	if ( eSystemInfo::getInstance()->canRecordTS() && !eDVB::getInstance()->recorder )
	{
		record_split_size = new eListBoxEntryMulti(&list, _("record split size (left, right)"));
.....................................................
and setup_extra.h:

Code:
.....................................................
eSetupWindow::eSetupWindow( const char *title, int entries, int width )
	:eListBoxWindow<eListBoxEntryMenu>(title, entries, width, true)
{
	addActionMap(&i_shortcutActions->map);
}

void eSetupWindow::sel_num(int n)
{
	list.forEachEntry(eSetupWindowSelectN(n));
}

int eSetupWindow::eventHandler(const eWidgetEvent &event)
{
	int num=-1;
	switch (event.type)
	{
	case eWidgetEvent::evtAction:
		if (event.action == &i_shortcutActions->number0)
			num=9;
		else if (event.action == &i_shortcutActions->number1)
			num=0;
		else if (event.action == &i_shortcutActions->number2)
			num=1;
		else if (event.action == &i_shortcutActions->number3)
....................................................
It is a window formulations that call selected entry through callback directed from the remote control, from 1 to 9. We see also that the 3 parameters are the title it of the window, the number of the entries and the width of the window. The sintax is a complicated P2o more, the setup window is derived of one class template. The definitions are in the header listbox.h:

Code:
......................................
template <class T>
class eListBoxWindow: public eWindow
{
public:
	int Entrys;
	int width;
	eListBox<T> list;
	eStatusBar *statusbar;
	eListBoxWindow(eString Title="", int Entrys=0, int width=400, bool sbar=0);
};

template <class T>
inline eListBoxWindow<T>::eListBoxWindow(eString Title, int Entrys, int width, bool sbar)
	: eWindow(0), Entrys(Entrys), width(width), list(this), statusbar(sbar?new eStatusBar(this):0)
{
	setText(Title);
	cresize( eSize(width, (sbar?60:10)+Entrys*T::getEntryHeight() ) );
	list.setFlags( eListBoxBase::flagShowEntryHelp );
	list.move(ePoint(10, 5));
	list.resize(eSize(getClientSize().width()-20, getClientSize().height()-(sbar?60:10) ));
	if (sbar)
	{
		statusbar->setFlags(eStatusBar::flagVCenter);
		statusbar->move( ePoint(0, getClientSize().height()-50) );
...................................
Our model have parameters “eString Title= "", int Entrys=0, int width=400, bool sbar=0”, already seen before except the last one, a variable bool that defines the presence (true) or the absence (false) in the generated window, of the status bar.
Here a P2o comes with one more class defined, always in listbox.h,

Code:
.................................
class eListBoxEntryMenu: public eListBoxEntryText
{
	friend class eListBox<eListBoxEntryMenu>;
.................................
Here We go:

1 - Include the header of the panel:

Code:
#include <tnspanel.h>
2 - Add the new entrymenu…. (we also add an other separator in order “to distinguish it” better :)

Code:
	new eListBoxEntryMenuSeparator(&list, eSkin::getActive()->queryImage("listbox.separator"), 0, true );
	CONNECT((new eListBoxEntryMenu(&list, _("Dream Control Panel"), eString().sprintf("(%d) %s", ++entry, _("open control panel")) ))->selected, eExpertSetup::tns_panel);
3 -….connected to the new method tns_panel (), the function that calls the panel:

Code:
void eExpertSetup::tns_panel()
{
	hide();
	eTnsPanel setup;
................
4 - We will go to declare the new method tns_panel () of eExpertSetup in the header relative:

Code:
	void tns_panel();
tnsspanel.h

Code:
#ifndef __tnspanel_h
#define __tnspanel_h

#include <src/setup_window.h> 
#include <lib/gui/ewindow.h>  
#include <lib/gui/listbox.h> 
#include <lib/gdi/epng.h> 
#include <lib/gdi/gfbdc.h> 

class eTnsPanel: public eSetupWindow
{
private:
	restart_enigma();

public:
	eTnsPanel();
	~eTnsPanel();
};

#endif
tnspanel.cpp

Code:
#include <tnspanel.h>	
#include <enigma.h>	
#include <enigma_main.h>	
#include <lib/system/info.h>	


eTnsPanel::eTnsPanel()
	:eSetupWindow(_("Tns control panel"), 10, 400) 
{	
	move(ePoint(200, 60));	


	gPixmap *img = loadPNG("/share/tuxbox/enigma/pictures/tnspanel.png");
	if (img)
	{
		move(ePoint(200, 60));
		resize(eSize(400, 470));

		gPixmap *mp = &gFBDC::getInstance()->getPixmap();
		gPixmapDC mydc(img);
		gPainter p(mydc);
		p.mergePalette(*mp);

		eLabel *logo = new eLabel(this);
		logo->move(ePoint(65, clientrect.height() - 70));
		logo->resize(eSize(181, 66));
		logo->setName("logo");
		logo->setPixmap(img);
	}
	else resize(eSize(400, 400));

	int entry=0;	
	CONNECT((new eListBoxEntryMenu(&list, _("Restart Enigma"), eString().sprintf("(%d) %s", ++entry, _("only enigma restart")) ))->selected,  eTnsPanel::restart_enigma);

eTnsPanel::~eTnsPanel()
{

}
// entry number one .....at the moment!
void eTnsPanel::restart_enigma()
{
 file include/lib/system/info.h
..................
 public:
	static eSystemInfo *getInstance() { return instance; }
..................
	int hasKeyboard() { return haskeyboard; }	
	int canMeasureLNBCurrent() { return canmeasurelnbcurrent; }
	int canShutdown() { return canshutdown; }
	int canRecordTS() { return canrecordts; }
..................
file 

	if (eSystemInfo::getInstance()->canShutdown())
		eZap::getInstance()->quit(2);
}
So, just few steps:
cd "mycdk"/cdk
rm .enigma
make .enigma
make rebuild-flash