コード例 #1
0
void CTimerList::updateEvents(void)
{
	timerlist.clear();
	Timer->getTimerList (timerlist);
	sort(timerlist.begin(), timerlist.end());

	theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
	fheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
	//get footerHeight from paintButtons
	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

	listmaxshow = (height-theight)/(fheight*2);
	height = theight+listmaxshow*fheight*2+footerHeight;	// recalc height

	if (timerlist.size() < listmaxshow)
	{
		listmaxshow=timerlist.size();
		height = theight+listmaxshow*fheight*2+footerHeight;	// recalc height
	}

	if (selected==timerlist.size() && !(timerlist.empty()))
	{
		selected=timerlist.size()-1;
		liststart = (selected/listmaxshow)*listmaxshow;
	}

	x = getScreenStartX(width);
	y = getScreenStartY(height);
}
コード例 #2
0
void CImageInfo::Init(void)
{
	frameBuffer = CFrameBuffer::getInstance();

	font_head   = SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME;;
	font_small  = SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL;
	font_info   = SNeutrinoSettings::FONT_TYPE_MENU;

	hheight     = g_Font[font_head]->getHeight();
	iheight     = g_Font[font_info]->getHeight();
	sheight     = g_Font[font_small]->getHeight();

	max_width = frameBuffer->getScreenWidth(true);
	max_height =  frameBuffer->getScreenHeight(true);

	width = frameBuffer->getScreenWidth() - 10;
	height = frameBuffer->getScreenHeight() - 10;
	x=getScreenStartX( width );
	y=getScreenStartY( height );
	
	// calculate max width of used LOCALES
	offset = 0;
	
	for (int i = 0; i < 8; i++) {
		int tmpoffset = g_Font[font_info]->getRenderWidth(g_Locale->getText (info_items[i]));
		if (tmpoffset > offset) {
			offset = tmpoffset;
		}
	}
	
	offset = offset + 15;
}
コード例 #3
0
ファイル: epgview.cpp プロジェクト: FFTEAM/evolux-spark-sh4
void CEpgData::start()
{
	/* This defines the size of the EPG window. We use 90% of the screen width and
	 * 90% of the screen height. It adjusts itself to the "visible screen" settings
	 */
	float epgwin_scale_factor = BIG_FONT_FAKTOR; /* stupid useless use of float */
	if (g_settings.big_windows)
		epgwin_scale_factor = 1;

	ox = (frameBuffer->getScreenWidth()  / 20 * 18) / (bigFonts ? 1 : epgwin_scale_factor);
	oy = (frameBuffer->getScreenHeight() / 20 * 18) / (bigFonts ? 1 : epgwin_scale_factor);
	sx = getScreenStartX(ox);
	sy = getScreenStartY(oy);

	topheight    = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_TITLE]->getHeight();
	topboxheight = topheight + 6;
	botboxheight = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE]->getHeight() + 6;
	buttonheight = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight() + 6;
	if (buttonheight < 30)
		buttonheight = 30; // the buttons and icons need space
	/* this is the text box height - and the height of the scroll bar */
	sb = oy - topboxheight - botboxheight - buttonheight;
	/* button box is handled separately (why?) */
	oy -= buttonheight;
	medlineheight = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]->getHeight();
	medlinecount  = sb / medlineheight;
	toph = topboxheight;
}
コード例 #4
0
void CExtendedInput::calculateDialog()
{
	int ix = 0;
	int iy = 0;
	int maxX = 0;
	int maxY = 0;

	if (valueString->size() < inputFields.size())
		valueString->append(inputFields.size() - valueString->size(), ' ');

	selectedChar = -1;
	for(unsigned int i=0; i<inputFields.size();i++)
	{
		inputFields[i]->init( ix, iy);
		inputFields[i]->setDataPointer( &valueString->at(i) );
		if ((selectedChar==-1) && (inputFields[i]->isSelectable()))
		{
			selectedChar = i;
		}
		maxX = std::max(ix, maxX);
		maxY = std::max(iy, maxY);
	}

	width = std::max(width, maxX + 2*offset);
	height = std::max(height, maxY + bheight);

	x = getScreenStartX(width);
	y = getScreenStartY(height);
}
コード例 #5
0
void CEpgData::start()
{
	/* if you want usably sized epg windows, compile with "-DUSE_SPACE_EFFICIENTLY" */
#ifndef USE_SPACE_EFFICIENTLY
#define EPGWIN_SCALE_FACTOR	BIG_FONT_FAKTOR
#else
#define EPGWIN_SCALE_FACTOR	1
#endif
	/* This defines the size of the EPG window. We use 90% of the screen width and
	 * 90% of the screen height. It adjusts itself to the "visible screen" settings
	 */
	ox = (frameBuffer->getScreenWidth() / 20 * 18)  / (bigFonts ? 1 : EPGWIN_SCALE_FACTOR);
	oy = (frameBuffer->getScreenHeight() / 20 * 18) / (bigFonts ? 1 : EPGWIN_SCALE_FACTOR);
	sx = getScreenStartX(ox);
	sy = getScreenStartY(oy);

	topheight    = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_TITLE]->getHeight();
	topboxheight = topheight + 6;
	botboxheight = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE]->getHeight() + 6;
	buttonheight = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight() + 6;
	if (buttonheight < 30)
		buttonheight = 30; // the buttons and icons need space
	/* this is the text box height - and the height of the scroll bar */
	sb = oy - topboxheight - botboxheight - buttonheight;
	/* button box is handled separately (why?) */
	oy -= buttonheight;
	medlineheight = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]->getHeight();
	medlinecount  = sb / medlineheight;
	toph = topboxheight;
}
コード例 #6
0
int CBEChannelSelectWidget::exec(CMenuTarget* parent, const std::string & actionKey)
{
	width  = frameBuffer->getScreenWidthRel();
	info_height = 2*iheight + 4;
	height = frameBuffer->getScreenHeightRel() - info_height;
	listmaxshow = (height-theight-footerHeight-0)/iheight;
	height = theight+footerHeight+listmaxshow*iheight; // recalc height

	x = getScreenStartX(width);
	if (x < ConnectLineBox_Width)
		x = ConnectLineBox_Width;
	y = getScreenStartY(height + info_height);

	bouquetChannels = mode == CZapitClient::MODE_TV ? &(g_bouquetManager->Bouquets[bouquet]->tvChannels) : &(g_bouquetManager->Bouquets[bouquet]->radioChannels);

	Channels.clear();
	if (mode == CZapitClient::MODE_RADIO) {
		CServiceManager::getInstance()->GetAllRadioChannels(Channels);
	} else {
		CServiceManager::getInstance()->GetAllTvChannels(Channels);
	}
	sort(Channels.begin(), Channels.end(), CmpChannelByChName());

	return CListBox::exec(parent, actionKey);
}
コード例 #7
0
ファイル: listframe.cpp プロジェクト: UkCvs/commando
//////////////////////////////////////////////////////////////////////
// Function Name:	InitVar	
// Description:		
// Parameters:		
// Data IN/OUT:		
// Return:		
// Notes:		
//////////////////////////////////////////////////////////////////////
void CListFrame::initVar(void)
{
	//TRACE("[CListFrame]->InitVar\r\n");
	m_nMode = SCROLL;
	
	m_showSelection = true;

	m_pcFontList  =  FONT_LIST ;
	m_nFontListHeight = m_pcFontList->getHeight();
	
	m_pcFontHeaderList  =  FONT_HEADER_LIST ;
	m_nFontHeaderListHeight = m_pcFontHeaderList->getHeight();
	
	m_pcFontTitle = FONT_TITLE;
	m_textTitle = "MovieBrowser";
	m_nFontTitleHeight = m_pcFontTitle->getHeight();
	
	m_nNrOfPages = 1;
	m_nNrOfLines = 0;
	m_nNrOfRows = 1;
	m_nLinesPerPage = 0;
	m_nCurrentLine = 0;
	m_nCurrentPage = 0;
	m_nSelectedLine = 0;

	m_cFrame.iWidth	= MIN_WINDOW_WIDTH;
	m_cFrame.iHeight	= MIN_WINDOW_HEIGHT;
	m_cFrame.iX		= getScreenStartX(m_cFrame.iWidth);
	m_cFrame.iY		= getScreenStartY(m_cFrame.iHeight);

	m_nMaxHeight = MAX_WINDOW_HEIGHT;
	m_nMaxWidth = MAX_WINDOW_WIDTH;
}
コード例 #8
0
int CUpnpBrowserGui::exec(CMenuTarget* parent, const std::string & /*actionKey*/)
{
	CAudioPlayer::getInstance()->init();

	if (parent)
		parent->hide();

	/* stop playback, disable playback start */
	CNeutrinoApp::getInstance()->stopPlayBack(true);
	m_frameBuffer->showFrame("mp3.jpg");

	// tell neutrino we're in audio mode
	CNeutrinoApp::getInstance()->handleMsg(NeutrinoMessages::CHANGEMODE , NeutrinoMessages::mode_audio);

	// remember last mode
	m_LastMode=(CNeutrinoApp::getInstance()->getLastMode());

	m_width = m_frameBuffer->getScreenWidthRel();
	m_height = m_frameBuffer->getScreenHeightRel();

	m_sheight = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight();
	m_buttonHeight = std::min(25, m_sheight);
	m_theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
	m_mheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
	m_fheight = g_Font[SNeutrinoSettings::FONT_TYPE_FILEBROWSER_ITEM]->getHeight();
	m_title_height = m_mheight*2 + 20 + m_sheight + 4;
	m_info_height = m_mheight*2;
	m_listmaxshow = (m_height - m_info_height - m_title_height - m_theight - 2*m_buttonHeight) / (m_fheight);
	m_height = m_theight + m_info_height + m_title_height + 2*m_buttonHeight + m_listmaxshow * m_fheight; // recalc height

	m_x=getScreenStartX(m_width);
	if (m_x < ConnectLineBox_Width)
		m_x = ConnectLineBox_Width;
	m_y=getScreenStartY(m_height);

	// Stop sectionsd
	g_Sectionsd->setPauseScanning(true);

	m_deviceliststart=0;
	m_selecteddevice=0;
	timeout = 0;

	selectDevice();

	if (CAudioPlayer::getInstance()->getState() != CBaseDec::STOP)
		CAudioPlayer::getInstance()->stop();

	// Start Sectionsd
	g_Sectionsd->setPauseScanning(false);
	m_frameBuffer->stopFrame();
	m_frameBuffer->Clear();

	CZapit::getInstance()->EnablePlayback(true);
	CNeutrinoApp::getInstance()->handleMsg(NeutrinoMessages::CHANGEMODE , m_LastMode);
	g_RCInput->postMsg(NeutrinoMessages::SHOW_INFOBAR, 0);

	return menu_return::RETURN_REPAINT;
}
コード例 #9
0
ファイル: streaminfo.cpp プロジェクト: UkCvs/commando
CStreamInfo::CStreamInfo()
{
	frameBuffer = CFrameBuffer::getInstance();
	hheight     = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
	mheight     = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
	width       = w_max (400, 50);
	height      = h_max (hheight + 14 * mheight + 10, 0);

	x = getScreenStartX (width);
	y = getScreenStartY (height);
}
コード例 #10
0
ファイル: osdlang_setup.cpp プロジェクト: UkCvs/ukcvs
COsdLangSetup::COsdLangSetup()
{
	frameBuffer = CFrameBuffer::getInstance();

	width = w_max (500, 100);
	hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
	mheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
	height 	= hheight+13*mheight+ 10;
	x	= getScreenStartX (width);
	y	= getScreenStartY (height);
}
コード例 #11
0
void CStringInput::init()
{
	frameBuffer = CFrameBuffer::getInstance();

#ifdef DEBUG_STRINGINPUT
	printf("HEAD: %s (len: %d)\n", head, strlen(head));
#endif
	hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
	iheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getHeight();
	fheight = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight() + 6;	// init min buttonbar height
	input_h = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight() + 2;		// font height + border
	input_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("M") + 2;	// hack font width + border
	offset  = 20;

	width = std::max(size*input_w + 2*offset, (int) frameBuffer->getScreenWidth() / 100 * 45);

	int tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(head);

	if (!(iconfile.empty()))
	{
		int icol_w, icol_h;
		frameBuffer->getIconSize(iconfile.c_str(), &icol_w, &icol_h);
		hheight = std::max(hheight, icol_h + (offset/4));
		tmp_w += icol_w + (offset/2);
	}
	width = std::max(width, tmp_w + offset);

	bheight = input_h + 2*offset;
	if ((hint_1 != NONEXISTANT_LOCALE) || (hint_2 != NONEXISTANT_LOCALE))
	{
		if (hint_1 != NONEXISTANT_LOCALE)
		{
			tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getRenderWidth(g_Locale->getText(hint_1));
			width = std::max(width, tmp_w + 2*offset);
			bheight += iheight;
		}
		if (hint_2 != NONEXISTANT_LOCALE)
		{
			tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getRenderWidth(g_Locale->getText(hint_2));
			width = std::max(width, tmp_w + 2*offset);
			bheight += iheight;
		}
		bheight += offset;
	}

	height = hheight+ bheight; // space for the possible numpad and the buttonbar will be added in initSMS()
	
	x = getScreenStartX(width);
	y = getScreenStartY(height);
	selected = 0;
	smstimer = 0;
}
コード例 #12
0
ファイル: themes.cpp プロジェクト: UkCvs/ukcvs
CThemes::CThemes()
: themefile('\t')
{
	frameBuffer = CFrameBuffer::getInstance();
	width 	= w_max (500, 100);
	hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
	mheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
	height = hheight+13*mheight+ 10;
	x	= getScreenStartX (width);
	y	= getScreenStartY (height);

	hasThemeChanged = false;
}
コード例 #13
0
ファイル: alphasetup.cpp プロジェクト: OpenDMM/tuxbox-apps
CAlphaSetup::CAlphaSetup(const neutrino_locale_t Name)
{
    frameBuffer = CFrameBuffer::getInstance();
    name = Name;
    width = w_max (360, 100);
    hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
    mheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
    height = hheight+ mheight*3;
    x = getScreenStartX (width);
    y = getScreenStartY (height);

    alpha1 = &g_settings.gtx_alpha1;
    alpha2 = &g_settings.gtx_alpha2;
}
コード例 #14
0
ファイル: scan_setup.cpp プロジェクト: ChakaZulu/tuxbox_apps
CScanSetup::CScanSetup()
{
	frameBuffer = CFrameBuffer::getInstance();

	width = w_max (500, 100);
	hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
	mheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
	height = hheight+13*mheight+ 10;
	x = getScreenStartX (width);
	y = getScreenStartY (height);

	sat_list_size = 0;
	provider_list_size = 0;
}
コード例 #15
0
ファイル: driver_boot_setup.cpp プロジェクト: UkCvs/ukcvs
CDriverBootSetup::CDriverBootSetup(const neutrino_locale_t title, const char * const IconName)
{
	frameBuffer = CFrameBuffer::getInstance();

	menue_title = title != NONEXISTANT_LOCALE ? title : LOCALE_DRIVERSETTINGS_DRIVER_BOOT;
	menue_icon = IconName != NULL ? IconName : NEUTRINO_ICON_SETTINGS;

	width = w_max (500, 100);
	hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
	mheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
	height 	= hheight+13*mheight+ 10;
	x	= getScreenStartX (width);
	y	= getScreenStartY (height);
}
コード例 #16
0
//------------------------------------------------------------------------
int CPictureViewerGui::exec(CMenuTarget* parent, const std::string & /*actionKey*/)
{
	selected = 0;
	width  = w_max (710, 0);
	height = h_max (570, 0);

	sheight      = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight();
	buttonHeight = std::min(25, sheight);
	theight      = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
	fheight      = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
	listmaxshow = (height-theight-2*buttonHeight)/(fheight);
	height = theight+2*buttonHeight+listmaxshow*fheight;	// recalc height

	x=getScreenStartX( width );
	y=getScreenStartY( height );

	m_viewer->SetScaling((CPictureViewer::ScalingMode)g_settings.picviewer_scaling);
	m_viewer->SetVisible(g_settings.screen_StartX, g_settings.screen_EndX, g_settings.screen_StartY, g_settings.screen_EndY);

	if (g_settings.video_Format == 3)
		m_viewer->SetAspectRatio(16.0/9);
	else
		m_viewer->SetAspectRatio(4.0/3);

	if (parent)
		parent->hide();

	// tell neutrino we're in pic_mode
	CNeutrinoApp::getInstance()->handleMsg( NeutrinoMessages::CHANGEMODE , NeutrinoMessages::mode_pic );
	// remember last mode
	m_LastMode=(CNeutrinoApp::getInstance()->getLastMode() | NeutrinoMessages::norezap);

	g_Sectionsd->setPauseScanning(true);

	show();

	// free picviewer mem
	m_viewer->Cleanup();

	// Start Sectionsd
	g_Sectionsd->setPauseScanning(false);

	// Restore last mode
	CNeutrinoApp::getInstance()->handleMsg( NeutrinoMessages::CHANGEMODE , m_LastMode );

	// always exit all
	return menu_return::RETURN_REPAINT;
}
コード例 #17
0
ファイル: listbox.cpp プロジェクト: OpenDMM/tuxbox-apps
CListBox::CListBox(const char * const Caption)
{
	frameBuffer = CFrameBuffer::getInstance();
	caption = Caption;
	liststart = 0;
	selected =  0;
	width = w_max (400, 100);
	height = 420;
	ButtonHeight = 25;
	modified = false;
	theight     = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
	fheight     = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight();
	listmaxshow = (height-theight-0)/fheight;
	height = theight+0+listmaxshow*fheight; // recalc height
	x = getScreenStartX (width);
	y = getScreenStartY (height);
}
コード例 #18
0
ファイル: timerlist.cpp プロジェクト: Coolstreamto/Coolto
void CTimerList::updateEvents(void)
{
	timerlist.clear();
	Timer->getTimerList (timerlist);
	//Remove last deleted event from List
	CTimerd::TimerList::iterator timer = timerlist.begin();
	for (; timer != timerlist.end(); ++timer)
	{
		if (timer->eventID==skipEventID)
		{
			timerlist.erase(timer);
			break;
		}
	}
	sort(timerlist.begin(), timerlist.end());

	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);

	width = w_max(g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getWidth()*56, 20);
	height = frameBuffer->getScreenHeight() - (2*theight);	// max height

	listmaxshow = (height-theight)/(fheight*2);
	height = theight+listmaxshow*fheight*2+footerHeight;	// recalc height

	if (timerlist.size() < listmaxshow)
	{
		listmaxshow=timerlist.size();
		height = theight+listmaxshow*fheight*2+footerHeight;	// recalc height
	}

	if (selected==timerlist.size() && !(timerlist.empty()))
	{
		selected=timerlist.size()-1;
		liststart = (selected/listmaxshow)*listmaxshow;
	}

	x = getScreenStartX(width);
	y = getScreenStartY(height);
}
コード例 #19
0
void CExtendedInput::Init(void)
{
	frameBuffer = CFrameBuffer::getInstance();

	hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
	iheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getHeight();
	input_h = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight() + 2;		// font height + border
	input_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("M") + 2;	// hack font width + border
	offset  = 20;

	width = frameBuffer->getScreenWidth() / 100 * 45;

	int tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(g_Locale->getText(name), true); // UTF-8
	width = std::max(width, tmp_w + offset);

	bheight = input_h + 2*offset;
	if ((hint_1 != NONEXISTANT_LOCALE) || (hint_2 != NONEXISTANT_LOCALE))
	{
		if (hint_1 != NONEXISTANT_LOCALE)
		{
			tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getRenderWidth(g_Locale->getText(hint_1), true);
			width = std::max(width, tmp_w + 2*offset);
			bheight += iheight;
		}
		if (hint_2 != NONEXISTANT_LOCALE)
		{
			tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getRenderWidth(g_Locale->getText(hint_2), true);
			width = std::max(width, tmp_w + 2*offset);
			bheight += iheight;
		}
		bheight += offset;
	}

	height = hheight+ bheight;

	x = getScreenStartX(width);
	y = getScreenStartY(height);
}
コード例 #20
0
int CImageInfo::exec(CMenuTarget* parent, const std::string &)
{
	if (parent)
		parent->hide();

	width = frameBuffer->getScreenWidth() - 10;
	height = frameBuffer->getScreenHeight() - 10;
	x=getScreenStartX( width );
	y=getScreenStartY( height );

	paint();

	//paint_pig( width-170, y, 215, 170);
	paint_pig (width - width/3 - 10, y + 10, width/3, height/3);

	neutrino_msg_t msg;

	while (1)
	{
		neutrino_msg_data_t data;
		uint64_t timeoutEnd = CRCInput::calcTimeoutEnd_MS(100);
		g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );

		if (msg <= CRCInput::RC_MaxRC)
		{
			break;
		}

		if ( msg >  CRCInput::RC_MaxRC && msg != CRCInput::RC_timeout)
		{
			CNeutrinoApp::getInstance()->handleMsg( msg, data );
		}
	}

	hide();

	return menu_return::RETURN_REPAINT;
}
コード例 #21
0
void CEpgData::start()
{
	ox = frameBuffer->getScreenWidthRel(bigFonts ? false /* big */ : true /* small */);
	oy = frameBuffer->getScreenHeightRel(bigFonts ? false /* big */ : true /* small */);

	topheight    = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_TITLE]->getHeight();
	topboxheight = topheight + 6;
	botboxheight = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE]->getHeight() + 6;
	buttonheight = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight() + 6;
	if (buttonheight < 30)
		buttonheight = 30; // the buttons and icons need space
	oy-=buttonheight/2;
	/* this is the text box height - and the height of the scroll bar */
	sb = oy - topboxheight - botboxheight - buttonheight;
	/* button box is handled separately (why?) */
	oy -= buttonheight;
	medlineheight = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]->getHeight();
	medlinecount  = sb / medlineheight;
	toph = topboxheight;

	sx = getScreenStartX(ox);
	sy = getScreenStartY(oy + buttonheight); /* button box is handled separately (why?) */
}
コード例 #22
0
/* bShowChannelList default to true, returns new bouquet or -1/-2 */
int CBouquetList::show(bool bShowChannelList)
{
	neutrino_msg_t      msg;
	neutrino_msg_data_t data;
	int res = CHANLIST_CANCEL;
	int icol_w, icol_h;
	int w_max_text = 0;
	int w_max_icon = 0;
	int h_max_icon = 0;
	favonly = !bShowChannelList;

	for (unsigned int count = 0; count < sizeof(CBouquetListButtons)/sizeof(CBouquetListButtons[0]); count++)
	{
		int w_text = g_Font[SNeutrinoSettings::FONT_TYPE_BUTTON_TEXT]->getRenderWidth(g_Locale->getText(CBouquetListButtons[count].locale));
		w_max_text = std::max(w_max_text, w_text);
		frameBuffer->getIconSize(CBouquetListButtons[count].button, &icol_w, &icol_h);
		w_max_icon = std::max(w_max_icon, icol_w);
		h_max_icon = std::max(h_max_icon, icol_h);
	}

	item_height = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight();

	/*
	   We align width to needed footer space,
	   but this manual calculation isn't a good idea.
	   It would be better to get the needed width from
	   CComponententsFooter class.
	*/
	width  = (sizeof(CBouquetListButtons)/sizeof(CBouquetListButtons[0]))*(w_max_icon + w_max_text + 2*OFFSET_INNER_MID);
	height = 16*item_height;

	header_height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
	footer_height = header_height;
	listmaxshow = (height - header_height - footer_height)/item_height;
	height      = header_height + footer_height + listmaxshow*item_height; // recalc height

	x = getScreenStartX(width);
	y = getScreenStartY(height);

	int lmaxpos= 1;
	int i= Bouquets.size();
	while ((i= i/10)!=0)
		lmaxpos++;

	CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, "");

	COSDFader fader(g_settings.theme.menu_Content_alpha);
	fader.StartFadeIn();

	paintHead();
	paint();
	frameBuffer->blit();

	int oldselected = selected;
	int firstselected = selected+ 1;
	int zapOnExit = false;

	unsigned int chn= 0;
	int pos= lmaxpos;

	uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_CHANLIST]);

	bool loop=true;
	while (loop) {
		g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );

		if ( msg <= CRCInput::RC_MaxRC )
			timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_CHANLIST]);

		if((msg == NeutrinoMessages::EVT_TIMER) && (data == fader.GetFadeTimer())) {
			if(fader.FadeDone())
				loop = false;
		}
		else if ((msg == CRCInput::RC_timeout                             ) ||
				(msg == (neutrino_msg_t)g_settings.key_channelList_cancel) ||
				((msg == CRCInput::RC_favorites) && (CNeutrinoApp::getInstance()->GetChannelMode() == LIST_MODE_FAV)))
		{
			selected = oldselected;
			if(fader.StartFadeOut()) {
				timeoutEnd = CRCInput::calcTimeoutEnd(1);
				msg = 0;
			} else
				loop=false;
		}
		else if(msg == CRCInput::RC_red || msg == CRCInput::RC_favorites) {
			if (!favonly && CNeutrinoApp::getInstance()->GetChannelMode() != LIST_MODE_FAV) {
				CNeutrinoApp::getInstance()->SetChannelMode(LIST_MODE_FAV);
				hide();
				return CHANLIST_CHANGE_MODE;
			}
		} else if(msg == CRCInput::RC_green) {
			if (!favonly && CNeutrinoApp::getInstance()->GetChannelMode() != LIST_MODE_PROV) {
				CNeutrinoApp::getInstance()->SetChannelMode(LIST_MODE_PROV);
				hide();
				return CHANLIST_CHANGE_MODE;
			}
		} else if(msg == CRCInput::RC_yellow || msg == CRCInput::RC_sat) {
			if(!favonly && bShowChannelList && CNeutrinoApp::getInstance()->GetChannelMode() != LIST_MODE_SAT) {
				CNeutrinoApp::getInstance()->SetChannelMode(LIST_MODE_SAT);
				hide();
				return CHANLIST_CHANGE_MODE;
			}
		} else if(msg == CRCInput::RC_blue) {
			if(!favonly && bShowChannelList && CNeutrinoApp::getInstance()->GetChannelMode() != LIST_MODE_ALL) {
				CNeutrinoApp::getInstance()->SetChannelMode(LIST_MODE_ALL);
				hide();
				return CHANLIST_CHANGE_MODE;
			}
		} else if(msg == CRCInput::RC_www) {
			if(!favonly && bShowChannelList && CNeutrinoApp::getInstance()->GetChannelMode() != LIST_MODE_WEBTV) {
				CNeutrinoApp::getInstance()->SetChannelMode(LIST_MODE_WEBTV);
				hide();
				return CHANLIST_CHANGE_MODE;
			}
		}
		else if ( msg == CRCInput::RC_setup) {
			if (!favonly && !Bouquets.empty()) {
				int ret = doMenu();
				if(ret > 0) {
					res = CHANLIST_NO_RESTORE;
					loop = false;
				} else if(ret < 0) {
					paintHead();
					paint();
				}
			}
		}
		else if ( msg == (neutrino_msg_t) g_settings.key_list_start ) {
			if (!Bouquets.empty())
				updateSelection(0);
		}
		else if ( msg == (neutrino_msg_t) g_settings.key_list_end ) {
			if (!Bouquets.empty())
				updateSelection(Bouquets.size()-1);
		}
		else if (msg == CRCInput::RC_up || (int) msg == g_settings.key_pageup ||
			 msg == CRCInput::RC_down || (int) msg == g_settings.key_pagedown)
		{
			int new_selected = UpDownKey(Bouquets, msg, listmaxshow, selected);
			updateSelection(new_selected);
		}
		else if(msg == (neutrino_msg_t)g_settings.key_bouquet_up || msg == (neutrino_msg_t)g_settings.key_bouquet_down) {
			if(bShowChannelList) {
				int mode = CNeutrinoApp::getInstance()->GetChannelMode();
				mode += (msg == (neutrino_msg_t)g_settings.key_bouquet_down) ? -1 : 1;
				if(mode < 0)
					mode = LIST_MODE_LAST - 1;
				else if(mode >= LIST_MODE_LAST)
					mode = 0;
				CNeutrinoApp::getInstance()->SetChannelMode(mode);
				hide();
				return CHANLIST_CHANGE_MODE;
			}
		}
		else if ( msg == CRCInput::RC_ok ) {
			if(!Bouquets.empty() /* && (!bShowChannelList || !Bouquets[selected]->channelList->isEmpty())*/) {
				zapOnExit = true;
				loop=false;
			}
		}
		else if (CRCInput::isNumeric(msg)) {
			if (!Bouquets.empty()) {
				if (pos == lmaxpos) {
					if (msg == CRCInput::RC_0) {
						chn = firstselected;
						pos = lmaxpos;
					} else {
						chn = CRCInput::getNumericValue(msg);
						pos = 1;
					}
				} else {
					chn = chn*10 + CRCInput::getNumericValue(msg);
					pos++;
				}

				if (chn > Bouquets.size()) {
					chn = firstselected;
					pos = lmaxpos;
				}

				int new_selected = (chn - 1) % Bouquets.size(); // is % necessary (i.e. can firstselected be > Bouquets.size()) ?
				updateSelection(new_selected);
			}
		} else if (msg == NeutrinoMessages::EVT_SERVICESCHANGED || msg == NeutrinoMessages::EVT_BOUQUETSCHANGED) {
			g_RCInput->postMsg(msg, data);
			loop = false;
			res = CHANLIST_CANCEL_ALL;
		} else {
			if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all ) {
				loop = false;
				res = CHANLIST_CANCEL_ALL;
			}
		}
		frameBuffer->blit();
	}
	hide();

	fader.StopFade();

	CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO);

	if (save_bouquets) {
		save_bouquets = false;
#if 0
		if (CNeutrinoApp::getInstance()->GetChannelMode() == LIST_MODE_FAV)
			g_bouquetManager->saveUBouquets();
		else
			g_bouquetManager->saveBouquets();
#endif
		if (g_settings.epg_scan == CEpgScan::SCAN_SEL)
			CEpgScan::getInstance()->Start();
	}

	if (zapOnExit)
		return (selected);

	return (res);
}
コード例 #23
0
//------------------------------------------------------------------------
int CPictureViewerGui::exec(CMenuTarget* parent, const std::string & /*actionKey*/)
{
#ifdef EVOLUX
	CNeutrinoApp::getInstance()->chPSISetup->blankScreen();
#endif
	selected = 0;
	width  = w_max (710, 0);
	height = h_max (570, 0);

	sheight      = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight();

        int icol_w, icol_h;

	theight      = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();

	frameBuffer->getIconSize(NEUTRINO_ICON_MP3, &icol_w, &icol_h);
	theight = std::max(theight, icol_h);

	frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_HELP, &icol_w, &icol_h);
	theight = std::max(theight, icol_h);

	frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_MENU, &icol_w, &icol_h);
	theight = std::max(theight, icol_h);

        frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_RED, &icol_w, &icol_h);
        buttonHeight = 8 + std::max(icol_h+2, sheight); //TODO get value from buttonbar

	fheight      = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
	listmaxshow = (height-theight-2*buttonHeight)/(fheight);
	height = theight+2*buttonHeight+listmaxshow*fheight;	// recalc height

	x=getScreenStartX( width );
	y=getScreenStartY( height );

	m_viewer->SetScaling((CPictureViewer::ScalingMode)g_settings.picviewer_scaling);
	m_viewer->SetVisible(g_settings.screen_StartX, g_settings.screen_EndX, g_settings.screen_StartY, g_settings.screen_EndY);

	if (g_settings.video_Format == 3)
		m_viewer->SetAspectRatio(16.0/9);
	else
		m_viewer->SetAspectRatio(4.0/3);

	if (parent)
		parent->hide();

	// tell neutrino we're in pic_mode
	CNeutrinoApp::getInstance()->handleMsg( NeutrinoMessages::CHANGEMODE , NeutrinoMessages::mode_pic );
	// remember last mode
	m_LastMode=(CNeutrinoApp::getInstance()->getLastMode() | NeutrinoMessages::norezap);

	//g_Zapit->setStandby(true);
	g_Zapit->lockPlayBack();

	// blank background screen
	videoDecoder->setBlank(true);

	// Stop Sectionsd
	g_Sectionsd->setPauseScanning(true);

	// Save and Clear background
	bool usedBackground = frameBuffer->getuseBackground();
	if (usedBackground) {
		frameBuffer->saveBackgroundImage();
		frameBuffer->Clear();
	}

	show();

	// free picviewer mem
	m_viewer->Cleanup();

	//g_Zapit->setStandby(false);
	g_Zapit->unlockPlayBack();

	// Start Sectionsd
	g_Sectionsd->setPauseScanning(false);

	// Restore previous background
	if (usedBackground) {
		frameBuffer->restoreBackgroundImage();
		frameBuffer->useBackground(true);
		frameBuffer->paintBackground();
	}

	// Restore last mode
	CNeutrinoApp::getInstance()->handleMsg( NeutrinoMessages::CHANGEMODE , m_LastMode );

	// always exit all
#ifdef EVOLUX
	CNeutrinoApp::getInstance()->chPSISetup->blankScreen(false);
#endif
	return menu_return::RETURN_REPAINT;
}
コード例 #24
0
int CPictureViewerGui::exec(CMenuTarget* parent, const std::string & actionKey)
{
	audioplayer = false;
	if (actionKey == "audio")
		audioplayer = true;

	selected = 0;

	width = frameBuffer->getScreenWidthRel();
	height = frameBuffer->getScreenHeightRel();

	sheight = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight();
	theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
	fheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();

        //get footerHeight from paintButtons
	buttons1Height = ::paintButtons(0, 0, 0, PictureViewerButtons1Count, PictureViewerButtons1, 0, 0, "", false, COL_INFOBAR_SHADOW_TEXT, NULL, 0, false);
	buttons2Height = ::paintButtons(0, 0, 0, PictureViewerButtons2Count, PictureViewerButtons2, 0, 0, "", false, COL_INFOBAR_SHADOW_TEXT, NULL, 0, false);
	footerHeight = buttons1Height + buttons2Height;

	listmaxshow = (height-theight-footerHeight)/(fheight);
	height = theight+listmaxshow*fheight+footerHeight;	// recalc height

	x=getScreenStartX( width );
	y=getScreenStartY( height );

	m_viewer->SetScaling((CPictureViewer::ScalingMode)g_settings.picviewer_scaling);
	m_viewer->SetVisible(g_settings.screen_StartX, g_settings.screen_EndX, g_settings.screen_StartY, g_settings.screen_EndY);

	if (g_settings.video_Format == 3)
		m_viewer->SetAspectRatio(16.0/9);
	else
		m_viewer->SetAspectRatio(4.0/3);

	if (parent)
		parent->hide();

	// remember last mode
	m_LastMode = CNeutrinoApp::getInstance()->getMode();
	// tell neutrino we're in pic_mode
	CNeutrinoApp::getInstance()->handleMsg( NeutrinoMessages::CHANGEMODE , NeutrinoMessages::mode_pic );

	if (!audioplayer) { // !!! why? !!!
		CNeutrinoApp::getInstance()->stopPlayBack(true);

		// blank background screen
		videoDecoder->setBlank(true);

		// Stop Sectionsd
		g_Sectionsd->setPauseScanning(true);
	}

	// Save and Clear background
	bool usedBackground = frameBuffer->getuseBackground();
	if (usedBackground) {
		frameBuffer->saveBackgroundImage();
		frameBuffer->Clear();
	}

	show();

	// free picviewer mem
	m_viewer->Cleanup();

	if (!audioplayer) { // !!! why? !!!
		//g_Zapit->unlockPlayBack();
		CZapit::getInstance()->EnablePlayback(true);

		// Start Sectionsd
		g_Sectionsd->setPauseScanning(false);
	}

	// Restore previous background
	if (usedBackground) {
		frameBuffer->restoreBackgroundImage();
		frameBuffer->useBackground(true);
		frameBuffer->paintBackground();
	}

	// Restore last mode
	CNeutrinoApp::getInstance()->handleMsg( NeutrinoMessages::CHANGEMODE , m_LastMode );

	// always exit all
	return menu_return::RETURN_REPAINT;
}
コード例 #25
0
//never used
const CBookmark * CBookmarkManager::getBookmark(CMenuTarget* parent)
{
	if (parent)
	{
		parent->hide();
	}

	frameBuffer = CFrameBuffer::getInstance();
	visible = false;
	selected = 0;
	// Max
	width = 90;
	footerHeight = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight()+8; //initial height value for buttonbar
	theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
	fheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
	x=getScreenStartX( width );
	y=getScreenStartY( height + info_height );
	listmaxshow = (height-theight-0)/(fheight*2);
	liststart = 0;

	height = (g_settings.screen_EndY-g_settings.screen_StartY)-(info_height+50);
	listmaxshow = (height-theight-0)/(fheight*2);
	height = theight+0+listmaxshow*fheight*2;	// recalc height
	if (bookmarks.size() < listmaxshow)
	{
		listmaxshow=bookmarks.size();
		height = theight+0+listmaxshow*fheight*2;	// recalc height
	}
	if ((!bookmarks.empty() && selected==bookmarks.size()))
	{
		selected=bookmarks.size()-1;
		liststart = (selected/listmaxshow)*listmaxshow;
	}


	int res = -1;

	uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
	uint32_t msg;
	uint32_t data;

	bool loop=true;
	bool update=true;
	while (loop)
	{
		if (update)
		{
			hide();
			update=false;
			paint();
		}
		g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );

		if ( msg <= CRCInput::RC_MaxRC )
			timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]);

		if ( ( msg == CRCInput::RC_timeout ) ||
				( msg == CRCInput::RC_home) )
		{ //Exit after timeout or cancel key
			res = -1;
			loop=false;
		}
		else if ((msg == CRCInput::RC_up) && !(bookmarks.empty()))
		{
			int prevselected=selected;
			if (selected==0)
			{
				selected = bookmarks.size()-1;
			}
			else
				selected--;
			paintItem(prevselected - liststart);
			unsigned int oldliststart = liststart;
			liststart = (selected/listmaxshow)*listmaxshow;
			if (oldliststart!=liststart)
			{
				paint();
			}
			else
			{
				paintItem(selected - liststart);
			}
		}
		else if ((msg == CRCInput::RC_down) && !(bookmarks.empty()))
		{
			int prevselected=selected;
			selected = (selected+1)%bookmarks.size();
			paintItem(prevselected - liststart);
			unsigned int oldliststart = liststart;
			liststart = (selected/listmaxshow)*listmaxshow;
			if (oldliststart!=liststart)
			{
				paint();
			}
			else
			{
				paintItem(selected - liststart);
			}
		}
		else if ((msg == CRCInput::RC_ok) && !(bookmarks.empty()))
		{
			res = selected;
			loop=false;
		}
		else if ((msg == CRCInput::RC_red) && !(bookmarks.empty()))
		{
			removeBookmark(selected);
			update=true;
		}
		else if ((msg==CRCInput::RC_yellow) && !(bookmarks.empty()))
		{
			renameBookmark(selected);
			update=true;
		}
		else if ((msg==CRCInput::RC_blue)||(msg==CRCInput::RC_green)||
				(CRCInput::isNumeric(msg)) )
		{
			//Ignore
		}
		else if (msg==CRCInput::RC_setup)
		{
			res=-1;
			loop=false;
		}
		else if ( msg == CRCInput::RC_help )
		{
			// TODO Add Help
		}
		else
		{
			if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all )
			{
				loop = false;
				res = menu_return::RETURN_EXIT_ALL;
			}
		}
	}
	hide();

	if ((res >=0) && (((unsigned int)res) < bookmarks.size()))
		return &bookmarks[res];
	else
		return NULL;
}
コード例 #26
0
ファイル: dboxinfo.cpp プロジェクト: Coolstreamto/Coolto
void CDBoxInfoWidget::paint()
{
	const int head_info_lines = 3;
	const char *head_info[head_info_lines] = {"Uptime", "Load average", "Current load"};

	height = hheight;
	height += mheight/2;	// space
	int cpuload_y0 = height;
	int head_info_ypos = height;
	height += mheight*head_info_lines;	// head info lines
	int cpuload_y1 = height;
	height += mheight/2;	// space

	int icon_w = 0, icon_h = 0;
	frameBuffer->getIconSize(NEUTRINO_ICON_REC, &icon_w, &icon_h);

#define MEMINFO_TOTAL 0
#define MEMINFO_USED 1
#define MEMINFO_FREE 2
#define MEMINFO_COLUMNS 3

#define MEMINFO_RAM 0
#define MEMINFO_SWAP 1
#define MEMINFO_ROWS 2
	unsigned long memstat[MEMINFO_ROWS][MEMINFO_COLUMNS] = { { 0, 0, 0 }, { 0, 0, 0 } }; // total, used, free
	const char *memtype[MEMINFO_ROWS] = { "RAM", "Swap" };
	FILE *procmeminfo = fopen("/proc/meminfo", "r");
	if (procmeminfo) {
		char buf[80], a[80];
		unsigned long v;
		while (fgets(buf, sizeof(buf), procmeminfo)) {
			if (2 == sscanf(buf, "%[^:]: %lu", a, &v)) {
				if (!strcasecmp(a, "MemTotal"))
					memstat[MEMINFO_RAM][MEMINFO_TOTAL] += v;
				else if (!strcasecmp(a, "MemFree"))
					memstat[MEMINFO_RAM][MEMINFO_FREE] += v;
				else if (!strcasecmp(a, "Inactive"))
					memstat[MEMINFO_RAM][MEMINFO_FREE] += v;
				else if (!strcasecmp(a, "SwapTotal"))
					memstat[MEMINFO_SWAP][MEMINFO_TOTAL] = v;
				else if (!strcasecmp(a, "SwapFree"))
					memstat[MEMINFO_SWAP][MEMINFO_FREE] += v;
			}
		}
		fclose(procmeminfo);
	}
	bool have_swap = memstat[MEMINFO_SWAP][MEMINFO_TOTAL];
	height += mheight;		// header
	height += mheight;		// ram
	height += have_swap * mheight;	// swap
	height += mheight/2;		// space

	std::ifstream in;

	std::map<std::string,bool> mounts;
	in.open("/proc/mounts");
	if (in.is_open()) {
		struct stat rec_st;
		struct statfs s;
		if (stat(g_settings.network_nfs_recordingdir.c_str(), &rec_st)
		|| (!::statfs(g_settings.network_nfs_recordingdir.c_str(), &s) && ((s.f_type == 0x72b6) || (s.f_type == 0x5941ff53))))
			memset(&rec_st, 0, sizeof(rec_st));

		std::map<dev_t,std::string> seen;
		std::string line;

		while (getline(in, line)) {
			size_t firstslash = line.find_first_of('/');
			size_t firstspace = line.find_first_of(' ');
			if ( (firstspace != string::npos && firstslash != string::npos && firstslash < firstspace) || (line.find("rootfs") == 0) ) {
				firstspace++;
				size_t nextspace = line.find_first_of(' ', firstspace);
				if (nextspace == string::npos || line.find("nodev", nextspace + 1) != string::npos)
					continue;
				std::string mountpoint = line.substr(firstspace, nextspace - firstspace);
				struct stat st;
				if (stat(mountpoint.c_str(), &st) || (seen.find(st.st_dev) != seen.end()))
					continue;
				seen[st.st_dev] = mountpoint;
				bool is_rec = (st.st_dev == rec_st.st_dev);
				mounts[mountpoint] = is_rec;
				int icon_space = is_rec ? 10 + icon_w : 0;
				const char *mnt = mountpoint.c_str();
				nameWidth = std::max(nameWidth, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(basename((char *)mnt), true) + icon_space + 10);
			}
		}
		in.close();
	}

	height += mheight;			// header
	height += mounts.size() * mheight;	// file systems
	height += mheight/2;			// space

	int offsetw = nameWidth+ (sizeWidth+10)*3 +10+percWidth+10;
	width = offsetw + 10 + 120;

	int diff = frameBuffer->getScreenWidth() - width;
	if (diff < 0) {
		width += diff;
		offsetw += diff;
		nameWidth += diff;
	}
	height = h_max(height, 0);
	x = getScreenStartX(width);
	y = getScreenStartY(height);

	// fprintf(stderr, "CDBoxInfoWidget::CDBoxInfoWidget() x = %d, y = %d, width = %d height = %d\n", x, y, width, height);

	int ypos=y;

	//paint head
	std::string title(g_Locale->getText(LOCALE_EXTRA_DBOXINFO));
	std::map<std::string,std::string> cpuinfo;
	in.open("/proc/cpuinfo");
	if (in.is_open()) {
		std::string line;
		while (getline(in, line)) {
			size_t colon = line.find_first_of(':');
			if (colon != string::npos && colon > 1) {
				std::string key = line.substr(0, colon - 1);
				std::string val = line.substr(colon + 1);
				cpuinfo[trim(key)] = trim(val);
			}
		}
		in.close();
	}
	if (!cpuinfo["Hardware"].empty()) {
		title += ": ";
		title += cpuinfo["Hardware"];
	} else if (!cpuinfo["machine"].empty()) {
		title += ": ";
		title + cpuinfo["machine"];
	}

	CComponentsHeader header(x, ypos, width, hheight, title, NEUTRINO_ICON_SHELL);
	header.paint(CC_SAVE_SCREEN_NO);

	//paint body
	frameBuffer->paintBoxRel(x, ypos+ hheight, width, height- hheight, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM);

	ypos += hheight + mheight/2;

	int head_info_rw = 0;
	for (int line = 0; line < head_info_lines; line++) {
		head_info_rw = std::max(head_info_rw, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(head_info[line], true));
	}

	int dw = offsetw - 3*10 - head_info_rw;
	int buf_size=256;
	char ubuf[buf_size];
	char sbuf[buf_size];
	memset(sbuf, 0, 256);

	struct sysinfo info;
	sysinfo(&info);

	//get uptime
#if 0
	struct tm *current_time;
	time_t current_secs;
	time(&current_secs);
	current_time = localtime(&current_secs);

	snprintf( ubuf,buf_size, "%02d:%02d%s  up ",
		  current_time->tm_hour%12 ? current_time->tm_hour%12 : 12,
		  current_time->tm_min, current_time->tm_hour > 11 ? "pm" : "am");
	strcat(sbuf, ubuf);
#endif

	int updays, uphours, upminutes;

	updays = (int) info.uptime / (60*60*24);
	upminutes = (int) info.uptime / 60;
	uphours = (upminutes / 60) % 24;
	upminutes %= 60;

	if (updays) {
		snprintf(ubuf,buf_size, "%d day%s, ", updays, (updays != 1) ? "s" : "");
		strcat(sbuf, ubuf);
	}
	if (uphours) {
		snprintf(ubuf,buf_size,"%d hour%s, ", uphours, (uphours != 1) ? "s" : "");
		strcat(sbuf, ubuf);
	}
	snprintf(ubuf,buf_size,"%d minute%s", upminutes, (upminutes != 1) ? "s" : "");
	strcat(sbuf, ubuf);

	//paint uptime
	g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + 2*10 + head_info_rw, ypos+ mheight, dw, sbuf, COL_MENUCONTENT_TEXT);
	ypos += mheight;

	//get load avg
	snprintf(ubuf,buf_size, "%ld.%02ld, %ld.%02ld, %ld.%02ld",
		 LOAD_INT(info.loads[0]), LOAD_FRAC(info.loads[0]),
		 LOAD_INT(info.loads[1]), LOAD_FRAC(info.loads[1]),
		 LOAD_INT(info.loads[2]), LOAD_FRAC(info.loads[2]));

	//paint load avg
	g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + 2*10 + head_info_rw, ypos+ mheight, dw, ubuf, COL_MENUCONTENT_TEXT);
	ypos += mheight;

	//get current load
	cSysLoad *sysload = cSysLoad::getInstance();
	int data_last = sysload->data_last;

	//paint current load
	if (data_last > -1) {
		snprintf(ubuf, sizeof(ubuf), "%d%s%d%%", data_last/10, g_Locale->getText(LOCALE_UNIT_DECIMAL), data_last%10);
		g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + 2*10 + head_info_rw, ypos+ mheight, dw, ubuf, COL_MENUCONTENT_TEXT);
	}
	ypos += mheight;

	int pbw = width - offsetw - 10;
	if (pbw > 8) /* smaller progressbar is not useful ;) */
	{
		unsigned int h = cpuload_y1 - cpuload_y0;
		cpuload_y0 += y;
		cpuload_y1 += y;
		frameBuffer->paintBoxRel(x + offsetw, cpuload_y0, pbw, h, COL_MENUCONTENT_PLUS_2);

		int off = std::max(0, (int)sysload->data_avail - pbw);
		for (unsigned int i = 0; i < sysload->data_avail - off; i++) {
			if (sysload->data[i + off] > -1)
				frameBuffer->paintVLine(x+offsetw + i, cpuload_y1 - sysload->data[i + off] * h / 1000, cpuload_y1, COL_MENUCONTENT_PLUS_7);
		}
	}

	ypos += mheight/2;

	int headOffset=0;
	int mpOffset=0;
	int offsets[] = {
		10,
		nameWidth + 10,
		nameWidth + 10 + (sizeWidth+10)*1,
		nameWidth + 10 + (sizeWidth+10)*2,
		nameWidth + 10 + (sizeWidth+10)*3,
	};
	int widths[] = { 0, sizeWidth, sizeWidth, sizeWidth, percWidth };

	const int headSize = 5;
	int maxWidth[headSize];
	memset(maxWidth, 0, headSize * sizeof(int));

	int ypos_mem_head = ypos;
	ypos += mheight;

	for (int row = 0; row < 1 + have_swap; row++) {
		std::string tmp;
		memstat[row][MEMINFO_USED] = memstat[row][MEMINFO_TOTAL] - memstat[row][MEMINFO_FREE];
		for (int column = 0; column < headSize; column++) {
			switch (column) {
				case 0:
					tmp = memtype[row];
					break;
				case 1:
					tmp = bytes2string(memstat[row][MEMINFO_TOTAL] << 10);
					break;
				case 2:
					tmp = bytes2string(memstat[row][MEMINFO_USED] << 10);
					break;
				case 3:
					tmp = bytes2string(memstat[row][MEMINFO_FREE] << 10);
					break;
				case 4:
					tmp = to_string(memstat[row][MEMINFO_TOTAL] ? (memstat[row][MEMINFO_USED] * 100) / memstat[row][MEMINFO_TOTAL] : 0) + "%";
					break;
			}
			mpOffset = offsets[column];
			int space = 0;
			int rw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(tmp, true);
			if (column > 0) {
				space = widths[column] - rw;
			}
			maxWidth[column] = std::max(maxWidth[column], rw)+6;
			if ((mpOffset + space + maxWidth[column]) > width)
				maxWidth[column] = width - (mpOffset + space);
			g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + mpOffset + space, ypos+ mheight, maxWidth[column], tmp, COL_MENUCONTENT_TEXT);
		}
		if (pbw > 8) /* smaller progressbar is not useful ;) */
		{
			CProgressBar pb(x+offsetw, ypos+3, pbw, mheight-10);
			pb.setBlink();
			pb.setInvert();
			pb.setValues(memstat[row][MEMINFO_TOTAL] ? (memstat[row][MEMINFO_USED] * 100) / memstat[row][MEMINFO_TOTAL] : 0, 100);
			pb.paint(false);
		}
		ypos += mheight;
	}
	ypos += mheight/2;

	int ypos_mnt_head = ypos;
	ypos += mheight;

	int width_i = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("i", true);

	for (std::map<std::string, bool>::iterator it = mounts.begin(); it != mounts.end(); ++it) {
		struct statfs s;
		if (::statfs((*it).first.c_str(), &s) == 0) {
			if (s.f_blocks > 0) {
				uint64_t bytes_total = s.f_blocks * s.f_bsize;
				uint64_t bytes_free  = s.f_bfree  * s.f_bsize;
				uint64_t bytes_used = bytes_total - bytes_free;
				int percent_used = (bytes_used * 200 + bytes_total) / 2 / bytes_total;
				//paint mountpoints
				for (int column = 0; column < headSize; column++) {
					std::string tmp;
					const char *mnt;
					mpOffset = offsets[column];
					int _w = maxWidth[column];
					switch (column) {
					case 0:
						tmp = (*it).first;
						if (tmp == "/")
							tmp = "rootfs";
						mnt = tmp.c_str();
						tmp = basename((char *)mnt);
						_w = nameWidth - mpOffset;
						if ((*it).second)
							_w -= icon_w + 10;
						_w += width_i/2;
						break;
					case 1:
						tmp = bytes2string(bytes_total, false);
						break;
					case 2:
						tmp = bytes2string(bytes_used, false);
						break;
					case 3:
						tmp = bytes2string(bytes_free, false);
						break;
					case 4:
						tmp = to_string(percent_used) + "%";
						break;
					}
					int space = 0;
					if (column > 0) {
						int rw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(tmp, true);
						maxWidth[column] = std::max(maxWidth[column], rw);
						space = widths[column] - rw;
						_w = rw;
					}
					if ((mpOffset + space + _w) > width)
						_w = width - (mpOffset + space);
					g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + mpOffset + space, ypos+ mheight, _w, tmp, COL_MENUCONTENT_TEXT);
					if ((*it).second && icon_w>0 && icon_h>0)
						frameBuffer->paintIcon(NEUTRINO_ICON_REC, x + nameWidth - icon_w + width_i/2, ypos + (mheight/2 - icon_h/2));
				}
				if (pbw > 8) /* smaller progressbar is not useful ;) */
				{
					CProgressBar pb(x+offsetw, ypos+3, pbw, mheight-10);
					pb.setBlink();
					pb.setInvert();
					pb.setValues(percent_used, 100);
					pb.paint(false);
				}
				ypos += mheight;
			}
		}
		if (ypos > y + height - mheight)	/* the screen is not high enough */
			break;				/* todo: scrolling? */
	}
	// paint info heads
	head_info_ypos += y;
	for (int line = 0; line < head_info_lines; line++) {
		g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + 10, head_info_ypos + mheight*(line+1), head_info_rw, head_info[line], COL_MENUCONTENTINACTIVE_TEXT);
	}
	// paint mem head
	const char *head_mem[headSize] = {"Memory", "Size", "Used", "Available", "Use"};
	for (int column = 0; column < headSize; column++) {
		headOffset = offsets[column];
		int space = 0;
		int rw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(head_mem[column], true);
		int _w = rw;
		if (column > 0) {
			if (rw > maxWidth[column])
				space = widths[column] - rw;
			else
				space = widths[column] - maxWidth[column] + (maxWidth[column] - rw)/2;
		}
		g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ headOffset + space, ypos_mem_head + mheight, _w, head_mem[column], COL_MENUCONTENTINACTIVE_TEXT);
	}
	// paint mount head
	const char *head_mnt[headSize] = {"Filesystem", "Size", "Used", "Available", "Use"};
	for (int column = 0; column < headSize; column++) {
		headOffset = offsets[column];
		int space = 0;
		int rw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(head_mnt[column], true);
		int _w = rw;
		if (column > 0) {
			if (rw > maxWidth[column])
				space = widths[column] - rw;
			else
				space = widths[column] - maxWidth[column] + (maxWidth[column] - rw)/2;
		}
		g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ headOffset + space, ypos_mnt_head + mheight, _w, head_mnt[column], COL_MENUCONTENTINACTIVE_TEXT);
	}
}
コード例 #27
0
ファイル: upnpbrowser.cpp プロジェクト: silid/tuxbox-cvs-apps
int CUpnpBrowserGui::exec(CMenuTarget* parent, const std::string & /*actionKey*/)
{

	CAudioPlayer::getInstance()->init();

	if(parent)
	{
		parent->hide();
	}

	if(g_settings.video_Format != CControldClient::VIDEOFORMAT_4_3)
		g_Controld->setVideoFormat(CControldClient::VIDEOFORMAT_4_3);

#ifdef HAVE_DBOX_HARDWARE
	// If Audiomode is OST then save setting and switch to AVS-Mode
	if(g_settings.audio_avs_Control == CControld::TYPE_OST)
	{
		m_vol_ost = true;
		g_settings.audio_avs_Control = CControld::TYPE_AVS;
	}
	else
#endif
		m_vol_ost = false;

	// tell neutrino we're in audio mode
	CNeutrinoApp::getInstance()->handleMsg( NeutrinoMessages::CHANGEMODE , NeutrinoMessages::mode_audio );
	// remember last mode
	CZapitClient::responseGetLastChannel firstchannel;
	g_Zapit->getLastChannel(firstchannel.channelNumber, firstchannel.mode);
	if ((firstchannel.mode == 'r') ?
	    (CNeutrinoApp::getInstance()->zapto_radio_on_init_done) :
	    (CNeutrinoApp::getInstance()->zapto_tv_on_init_done))
		m_LastMode=(CNeutrinoApp::getInstance()->getLastMode() | NeutrinoMessages::norezap);
	else
		m_LastMode=(CNeutrinoApp::getInstance()->getLastMode());

	// set zapit in standby mode
	g_Zapit->setStandby(true);

	m_width = w_max(710, ConnectLineBox_Width);
	m_height = h_max(570, 0);
	m_sheight = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight();
	m_buttonHeight = std::min(25, m_sheight);
	m_frameBuffer->getIconSize(NEUTRINO_ICON_UPNP, &m_ticonwidth, &m_ticonheight);
	m_theight = std::max(m_ticonheight, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight());
	m_mheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
	m_fheight = g_Font[SNeutrinoSettings::FONT_TYPE_FILEBROWSER_ITEM]->getHeight();
	m_title_height = m_mheight*2 + 20 + m_sheight + 4;
	m_info_height = m_mheight*2;
	m_listmaxshow = (m_height - m_info_height - m_title_height - m_theight - 2*m_buttonHeight) / (m_fheight);
	m_height = m_theight + m_info_height + m_title_height + 2*m_buttonHeight + m_listmaxshow * m_fheight; // recalc height

	m_x = getScreenStartX(m_width + ConnectLineBox_Width) + ConnectLineBox_Width;
	m_y = getScreenStartY(m_height);

	// Stop sectionsd
	g_Sectionsd->setPauseScanning(true);

#ifdef HAVE_DBOX_HARDWARE
	// disable iec aka digi out
	g_Zapit->IecOff();
#endif

	m_indexdevice=0;
	m_selecteddevice=0;

	selectDevice();

	if(CAudioPlayer::getInstance()->getState() != CBaseDec::STOP)
		CAudioPlayer::getInstance()->stop();

	g_Zapit->setStandby(false);
#ifdef HAVE_DBOX_HARDWARE
	if(m_vol_ost)
	{
		g_Controld->setVolume(100, CControld::TYPE_AVS);
		g_settings.audio_avs_Control = CControld::TYPE_OST;
	}
#endif

	// Start Sectionsd
	g_Sectionsd->setPauseScanning(false);

#ifdef HAVE_DBOX_HARDWARE
	// enable iec aka digi out
	g_Zapit->IecOn();
#endif

	CNeutrinoApp::getInstance()->handleMsg( NeutrinoMessages::CHANGEMODE , m_LastMode );
	g_RCInput->postMsg( NeutrinoMessages::SHOW_INFOBAR, 0 );

	return menu_return::RETURN_EXIT_ALL;
}
コード例 #28
0
void CDBoxInfoWidget::paint()
{
	const int headSize = 5;
	const char *head[headSize] = {"Filesystem", "Size", "Used", "Available", "Use%"};
	int fontWidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getWidth();
	int sizeOffset = fontWidth * 7;//9999.99M
	int percOffset = fontWidth * 3 ;//100%
	int nameOffset = fontWidth * 9;//WWWwwwwwww
	int offsetw = nameOffset+ (sizeOffset+10)*3 +10+percOffset+10;
	offsetw += 20;
	width = offsetw + 10 + 120;
	height = hheight + 6 * mheight;

	struct statfs s;
	FILE *          mountFile;
	struct mntent * mnt;

	/* this is lame, as it duplicates code. OTOH, it is small and fast enough...
	   The algorithm is exactly the same as below in the display routine */
	if ((mountFile = setmntent("/proc/mounts", "r")) == NULL) {
		perror("/proc/mounts");
	} else {
		while ((mnt = getmntent(mountFile)) != NULL) {
			if (::statfs(mnt->mnt_dir, &s) == 0) {
				switch (s.f_type)	/* f_type is long */
				{
				case 0xEF53L:		/*EXT2 & EXT3*/
				case 0x6969L:		/*NFS*/
				case 0xFF534D42L:	/*CIFS*/
				case 0x517BL:		/*SMB*/
				case 0x52654973L:	/*REISERFS*/
				case 0x65735546L:	/*fuse for ntfs*/
				case 0x58465342L:	/*xfs*/
				case 0x4d44L:		/*msdos*/
					break;
				case 0x72b6L:		/*jffs2*/
					if (strcmp(mnt->mnt_fsname, "rootfs") == 0)
						continue;
					height += mheight;
					break;
				default:
					continue;
				}
				height += mheight;
			}
		}
		endmntent(mountFile);
	}

	width = w_max(width, 0);
	height = h_max(height, 0);
	x = getScreenStartX(width);
	y = getScreenStartY(height);

	fprintf(stderr, "CDBoxInfoWidget::CDBoxInfoWidget() x = %d, y = %d, width = %d height = %d\n", x, y, width, height);
	int ypos=y;
	int i = 0;
	frameBuffer->paintBoxRel(x, ypos, width, hheight, COL_MENUHEAD_PLUS_0, RADIUS_LARGE, CORNER_TOP);
	frameBuffer->paintBoxRel(x, ypos+ hheight, width, height- hheight, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM);

	ypos+= hheight + (mheight >>1);
	FILE* fd = fopen("/proc/cpuinfo", "rt");
	if (fd==NULL) {
		printf("error while opening proc-cpuinfo\n" );
	} else {
		char *buffer=NULL;
		size_t len = 0;
		ssize_t read;
		while ((read = getline(&buffer, &len, fd)) != -1) {
			if (!(strncmp(const_cast<char *>("Hardware"),buffer,8))) {
				char *t=rindex(buffer,'\n');
				if (t)
					*t='\0';

				std::string hw;
				char *p=rindex(buffer,':');
				if (p)
					hw=++p;
				hw+=" Info";
				g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+10, y + hheight+1, width - 10, hw.c_str(), COL_MENUHEAD, 0, true); // UTF-8
				break;
			}
			i++;
			if (i > 2)
				continue;
			g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ 10, ypos+ mheight, width - 10, buffer, COL_MENUCONTENT);
			ypos+= mheight;
		}
		fclose(fd);
		if (buffer)
			free(buffer);
	}
	char *ubuf=NULL, *sbuf=NULL;
	int buf_size=256;
	ubuf = new char[buf_size];
	sbuf = new char[buf_size];

	if (sbuf != NULL && ubuf != NULL) {
		int updays, uphours, upminutes;
		struct sysinfo info;
		struct tm *current_time;
		time_t current_secs;
		memset(sbuf, 0, 256);
		time(&current_secs);
		current_time = localtime(&current_secs);

		sysinfo(&info);

		snprintf( ubuf,buf_size, "%2d:%02d%s  up ",
			  current_time->tm_hour%12 ? current_time->tm_hour%12 : 12,
			  current_time->tm_min, current_time->tm_hour > 11 ? "pm" : "am");
		strcat(sbuf, ubuf);
		updays = (int) info.uptime / (60*60*24);
		if (updays) {
			snprintf(ubuf,buf_size, "%d day%s, ", updays, (updays != 1) ? "s" : "");
			strcat(sbuf, ubuf);
		}
		upminutes = (int) info.uptime / 60;
		uphours = (upminutes / 60) % 24;
		upminutes %= 60;
		if (uphours)
			snprintf(ubuf,buf_size,"%2d:%02d, ", uphours, upminutes);
		else
			snprintf(ubuf,buf_size,"%d min, ", upminutes);
		strcat(sbuf, ubuf);

		snprintf(ubuf,buf_size, "load: %ld.%02ld, %ld.%02ld, %ld.%02ld\n",
			 LOAD_INT(info.loads[0]), LOAD_FRAC(info.loads[0]),
			 LOAD_INT(info.loads[1]), LOAD_FRAC(info.loads[1]),
			 LOAD_INT(info.loads[2]), LOAD_FRAC(info.loads[2]));
		strcat(sbuf, ubuf);
		ypos+= mheight/2;
		g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ 10, ypos+ mheight, width - 10, sbuf, COL_MENUCONTENT);
		ypos+= mheight;

		snprintf(ubuf,buf_size, "memory total %dKb, free %dKb", (int) info.totalram/1024, (int) info.freeram/1024);
		ypos+= mheight/2;
		g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ 10, ypos+ mheight, width - 10, ubuf, COL_MENUCONTENT);
		ypos+= mheight;
		int headOffset=0;
		int mpOffset=0;
		bool rec_mp=false;
		if ((mountFile = setmntent("/proc/mounts", "r")) == 0 ) {
			perror("/proc/mounts");
		}
		else {
			float gb=0;
			char c=' ';
			while ((mnt = getmntent(mountFile)) != 0) {
				if (::statfs(mnt->mnt_dir, &s) == 0) {
					switch (s.f_type)
					{
					case (int) 0xEF53:      /*EXT2 & EXT3*/
					case (int) 0x6969:      /*NFS*/
					case (int) 0xFF534D42:  /*CIFS*/
					case (int) 0x517B:      /*SMB*/
					case (int) 0x52654973:  /*REISERFS*/
					case (int) 0x65735546:  /*fuse for ntfs*/
					case (int) 0x58465342:  /*xfs*/
					case (int) 0x4d44:      /*msdos*/
						gb = 1024.0*1024.0;
						c = 'G';
						break;
					case (int) 0x72b6:	/*jffs2*/
						if (strcmp(mnt->mnt_fsname, "rootfs") == 0)
							continue;
						// paint mount head
						for (int j = 0; j < headSize; j++) {
							switch (j)
							{
							case 0:
								headOffset = 10;
								break;
							case 1:
								headOffset = nameOffset + 20;
								break;
							case 2:
								headOffset = nameOffset + sizeOffset+10 +20;
								break;
							case 3:
								headOffset = nameOffset + (sizeOffset+10)*2+15;
								break;
							case 4:
								headOffset = nameOffset + (sizeOffset+10)*3+15;
								break;
							}
							g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ headOffset, ypos+ mheight, width - 10, head[j], COL_MENUCONTENTINACTIVE);
						}
						ypos+= mheight;

						gb = 1024.0;
						c = 'M';
						break;
					default:
						continue;
					}
					if ( s.f_blocks > 0 ) {
						long	blocks_used;
						long	blocks_percent_used;
						blocks_used = s.f_blocks - s.f_bfree;
						blocks_percent_used = (long)(blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
						//paint mountpoints
						for (int j = 0; j < headSize; j++) {
							switch (j)
							{
							case 0: {
								if (s.f_type != 0x72b6)
								{
									char *p1=NULL, *p2=NULL;
									p1=strchr(g_settings.network_nfs_recordingdir+1,'/') ;
									p2=strchr(mnt->mnt_dir+1,'/') ;
									if (p2) {
										if (strstr(p1,p2)) {

											rec_mp = true;
										}
									}
									else {
										if (strstr(g_settings.network_nfs_recordingdir,mnt->mnt_dir)) {
											rec_mp = true;
										}
									}
								}
								mpOffset = 10;
								snprintf(ubuf,buf_size,"%-10.10s",basename(mnt->mnt_fsname));
							}
							break;
							case 1:
								mpOffset = nameOffset + 10;
								snprintf(ubuf,buf_size,"%7.2f%c", (s.f_blocks * (s.f_bsize / 1024.0)) / gb, c);
								break;
							case 2:
								mpOffset = nameOffset+ (sizeOffset+10)*1+10;
								snprintf(ubuf,buf_size,"%7.2f%c", ((s.f_blocks - s.f_bfree)  * (s.f_bsize / 1024.0)) / gb, c);
								break;
							case 3:
								mpOffset = nameOffset+ (sizeOffset+10)*2+10;
								snprintf(ubuf,buf_size,"%7.2f%c", s.f_bavail * (s.f_bsize / 1024.0) / gb, c);
								break;
							case 4:
								mpOffset = nameOffset+ (sizeOffset+10)*3+10;
								snprintf(ubuf,buf_size,"%4ld%c", blocks_percent_used,'%');
								break;
							}
							g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + mpOffset, ypos+ mheight, width - 10, ubuf, rec_mp ? COL_MENUHEAD+2:COL_MENUCONTENT);
							rec_mp = false;
						}
						int pbw = width - offsetw - 10;
//fprintf(stderr, "width: %d offsetw: %d pbw: %d\n", width, offsetw, pbw);
						if (pbw > 8) /* smaller progressbar is not useful ;) */
						{
							CProgressBar pb(true, -1, -1, 30, 100, 70, true);
							pb.paintProgressBarDefault(x+offsetw, ypos+3, pbw, mheight-10, blocks_percent_used, 100);
						}
						ypos+= mheight;
					}
					i++;
				}
				if (ypos > y + height - mheight)	/* the screen is not high enough */
					break;				/* todo: scrolling? */
			}
			endmntent(mountFile);
		}
	}
	if (sbuf)
		delete[] sbuf;
	if (ubuf)
		delete[] ubuf;

}
コード例 #29
0
int CUpnpBrowserGui::exec(CMenuTarget* parent, const std::string & /*actionKey*/)
{

	CAudioPlayer::getInstance()->init();

	if (parent)
	{
		parent->hide();
	}

	g_Zapit->stopPlayBack();

#ifndef EVOLUX
	videoDecoder->ShowPicture(DATADIR "/neutrino/icons/mp3.jpg");
#endif

	// tell neutrino we're in audio mode
	CNeutrinoApp::getInstance()->handleMsg( NeutrinoMessages::CHANGEMODE , NeutrinoMessages::mode_audio );
	// remember last mode
#if 0
	CZapitClient::responseGetLastChannel firstchannel;
	g_Zapit->getLastChannel(firstchannel.channelNumber, firstchannel.mode);
	if ((firstchannel.mode == 'r') ?
			(CNeutrinoApp::getInstance()->zapto_radio_on_init_done) :
			(CNeutrinoApp::getInstance()->zapto_tv_on_init_done))
		m_LastMode=(CNeutrinoApp::getInstance()->getLastMode() | NeutrinoMessages::norezap);
	else
		m_LastMode=(CNeutrinoApp::getInstance()->getLastMode());
#endif
	m_LastMode=(CNeutrinoApp::getInstance()->getLastMode());

	m_width=(g_settings.screen_EndX - g_settings.screen_StartX) - ConnectLineBox_Width;
	m_height = (g_settings.screen_EndY - g_settings.screen_StartY);

	m_sheight = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight();
	m_buttonHeight = std::min(25, m_sheight);
	m_theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
	m_mheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
	m_fheight = g_Font[SNeutrinoSettings::FONT_TYPE_FILEBROWSER_ITEM]->getHeight();
	m_title_height = m_mheight*2 + 20 + m_sheight + 4;
	m_info_height = m_mheight*2;
	m_listmaxshow = (m_height - m_info_height - m_title_height - m_theight - 2*m_buttonHeight) / (m_fheight);
	m_height = m_theight + m_info_height + m_title_height + 2*m_buttonHeight + m_listmaxshow * m_fheight; // recalc height

	m_x=getScreenStartX( m_width + ConnectLineBox_Width ) + ConnectLineBox_Width;
	m_y=getScreenStartY( m_height );

	// Stop sectionsd
	g_Sectionsd->setPauseScanning(true);

	m_indexdevice=0;
	m_selecteddevice=0;

	selectDevice();

	if (CAudioPlayer::getInstance()->getState() != CBaseDec::STOP)
		CAudioPlayer::getInstance()->stop();

	//g_Zapit->setStandby(false);

	// Start Sectionsd
	g_Sectionsd->setPauseScanning(false);
	videoDecoder->StopPicture();

	CNeutrinoApp::getInstance()->handleMsg( NeutrinoMessages::CHANGEMODE , m_LastMode );
	g_RCInput->postMsg( NeutrinoMessages::SHOW_INFOBAR, 0 );

	return menu_return::RETURN_EXIT_ALL;
}
コード例 #30
0
ファイル: pictureviewer.cpp プロジェクト: UkCvs/commando
//------------------------------------------------------------------------
int CPictureViewerGui::exec(CMenuTarget* parent, const std::string & /*actionKey*/)
{
	selected = 0;
	width = w_max (710, 30);
	height = h_max (570, 0);
	sheight      = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight();
	buttonHeight = std::max(25, sheight);
	frameBuffer->getIconSize(NEUTRINO_ICON_MP3, &ticonwidth, &ticonheight);
	theight      = std::max(ticonheight, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight());
	fheight      = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
	listmaxshow = (height-theight-2*buttonHeight)/(fheight);
	height = theight+2*buttonHeight+listmaxshow*fheight;	// recalc height

	x = getScreenStartX (width);
	y = getScreenStartY (height);

	m_viewer->SetScaling((CPictureViewer::ScalingMode)g_settings.picviewer_scaling);
	m_viewer->SetVisible(g_settings.screen_StartX, g_settings.screen_EndX, g_settings.screen_StartY, g_settings.screen_EndY);

	if(g_settings.video_Format == CControldClient::VIDEOFORMAT_16_9)
		m_viewer->SetAspectRatio(16.0/9);
	else if(g_settings.video_Format == CControldClient::VIDEOFORMAT_AUTO)
	{
		g_Controld->setVideoFormat(CControldClient::VIDEOFORMAT_4_3);
		m_viewer->SetAspectRatio(4.0/3);
	}
	else
		m_viewer->SetAspectRatio(4.0/3);

	if(parent)
	{
		parent->hide();
	}

	puts("[pictureviewer.cpp] executing " PICTUREVIEWER_START_SCRIPT ".");
	if (my_system(PICTUREVIEWER_START_SCRIPT) != 0)
		perror(PICTUREVIEWER_START_SCRIPT " failed");

	// tell neutrino we're in pic_mode
	CNeutrinoApp::getInstance()->handleMsg( NeutrinoMessages::CHANGEMODE , NeutrinoMessages::mode_pic );
	// remember last mode
	CZapitClient::responseGetLastChannel firstchannel;
	g_Zapit->getLastChannel(firstchannel.channelNumber, firstchannel.mode);
	if ((firstchannel.mode == 'r') ?
	    (CNeutrinoApp::getInstance()->zapto_radio_on_init_done) :
	    (CNeutrinoApp::getInstance()->zapto_tv_on_init_done))
		m_LastMode=(CNeutrinoApp::getInstance()->getLastMode() | NeutrinoMessages::norezap);
	else
		m_LastMode=(CNeutrinoApp::getInstance()->getLastMode());

	g_Sectionsd->setPauseScanning(true); 

	show();

	// free picviewer mem
	m_viewer->Cleanup();

	puts("[pictureviewer.cpp] executing " PICTUREVIEWER_END_SCRIPT ".");
	if (my_system(PICTUREVIEWER_END_SCRIPT) != 0)
		perror(PICTUREVIEWER_END_SCRIPT " failed");

	// Start Sectionsd
	g_Sectionsd->setPauseScanning(false);
	
	// Restore last mode
	CNeutrinoApp::getInstance()->handleMsg( NeutrinoMessages::CHANGEMODE , m_LastMode );
	g_RCInput->postMsg( NeutrinoMessages::SHOW_INFOBAR, 0 );

	// always exit all	
	return menu_return::RETURN_EXIT_ALL;
}