void CBouquetList::paint()
{
	//ensure stop info clock before paint this window
	CInfoClock::getInstance()->disableInfoClock();
	liststart = (selected/listmaxshow)*listmaxshow;
	int lastnum =  liststart + listmaxshow;

	numwidth = 0;
	int maxDigitWidth = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getMaxDigitWidth();
	int _lastnum = lastnum;
        while (_lastnum) {
                numwidth += maxDigitWidth;
                _lastnum /= 10;
        }

	frameBuffer->paintBoxRel(x, y + header_height, width, height - header_height - footer_height, COL_MENUCONTENT_PLUS_0);

	// no buttons in favonly mode
	int numButtons = (favonly) ? 0 : sizeof(CBouquetListButtons)/sizeof(CBouquetListButtons[0]);

	CComponentsFooter footer;
	footer.enableShadow(CC_SHADOW_ON, -1, true);
	footer.paintButtons(x, y + height - footer_height, width, footer_height, numButtons, CBouquetListButtons);

	if (!Bouquets.empty())
	{
		for (unsigned int count = 0; count < listmaxshow; count++)
		{
			paintItem(count);
		}
	}

	int total_pages;
	int current_page;
	getScrollBarData(&total_pages, &current_page, Bouquets.size(), listmaxshow, selected);
	paintScrollBar(x + width - SCROLLBAR_WIDTH, y + header_height, SCROLLBAR_WIDTH, item_height*listmaxshow, total_pages, current_page, CC_SHADOW_RIGHT_CORNER_ALL);
}
Exemplo n.º 2
0
// paint
void CWebTV::paint()
{
	liststart = (selected/listmaxshow)*listmaxshow;
	
	int lastnum =  liststart + listmaxshow;
	
	if(lastnum<10)
		numwidth = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth("0");
	else if(lastnum<100)
		numwidth = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth("00");
	else if(lastnum<1000)
		numwidth = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth("000");
	else if(lastnum<10000)
		numwidth = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth("0000");
	else // if(lastnum<100000)
		numwidth = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth("00000");
	
	// channelslist body
	frameBuffer->paintBoxRel(x, y + theight, width, height - buttonHeight - theight, COL_MENUCONTENT_PLUS_0);
	
	// paint item
	for(unsigned int count = 0; count < listmaxshow; count++) 
	{
		paintItem(count);
	}

	// sb
	int ypos = y + theight;
	int sb = iheight*listmaxshow;
	
	frameBuffer->paintBoxRel(x + width - SCROLLBAR_WIDTH, ypos, SCROLLBAR_WIDTH, sb,  COL_MENUCONTENT_PLUS_1);

	int sbc = ((channels.size() - 1)/ listmaxshow) + 1;
	int sbs = (selected/listmaxshow);

	frameBuffer->paintBoxRel(x + width - 13, ypos + 2 + sbs*(sb - 4)/sbc, 11, (sb - 4)/sbc, COL_MENUCONTENT_PLUS_3);
}
Exemplo n.º 3
0
void CPictureViewerGui::paint()
{
	liststart = (selected/listmaxshow)*listmaxshow;

	paintHead();
	for (unsigned int count=0; count<listmaxshow; count++)
	{
		paintItem(count);
	}

	int ypos = y+ theight;
	int sb = fheight* listmaxshow;
	frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb,  COL_MENUCONTENT_PLUS_1);

	int sbc= ((playlist.size()- 1)/ listmaxshow)+ 1;
	int sbs= (selected/listmaxshow);

	frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ sbs * (sb-4)/sbc, 11, (sb-4)/sbc,  COL_MENUCONTENT_PLUS_3);

	paintFoot();
	paintInfo();

	visible = true;
}
Exemplo n.º 4
0
int CBEChannelWidget::exec(CMenuTarget* parent, const std::string &/*actionKey*/)
{
	neutrino_msg_t      msg;
	neutrino_msg_data_t data;

	int res = menu_return::RETURN_REPAINT;

	if (parent)
		parent->hide();

	width = w_max ( (frameBuffer->getScreenWidth() / 20 * 17), (frameBuffer->getScreenWidth() / 20 ));
	height = h_max ( (frameBuffer->getScreenHeight() / 20 * 16), (frameBuffer->getScreenHeight() / 20));
	
	listmaxshow = (height - theight)/fheight;
	height = theight + listmaxshow*fheight; // recalc height
	
	// info height
	info_height = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getHeight() + 10;
	
	// coordinate
	x = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - (width + ConnectLineBox_Width)) / 2 + ConnectLineBox_Width;
	y = frameBuffer->getScreenY() + (frameBuffer->getScreenHeight() - height -ButtonHeight - 2 - info_height) / 2;

	Channels = mode == CZapitClient::MODE_TV ? &(g_bouquetManager->Bouquets[bouquet]->tvChannels) : &(g_bouquetManager->Bouquets[bouquet]->radioChannels);
	
	paintHead();
	paint();
	paintFoot();
	
	frameBuffer->blit();	

	channelsChanged = false;

	unsigned long long timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]);

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

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

		if ((msg == CRCInput::RC_timeout) || (msg == (neutrino_msg_t)g_settings.key_channelList_cancel))
		{
			if (state == beDefault)
			{
				loop = false;
			}
			else if (state == beMoving)
			{
				cancelMoveChannel();
			}
		}
		else if (msg==CRCInput::RC_up || msg==(neutrino_msg_t)g_settings.key_channelList_pageup)
		{
			if (!(Channels->empty()))
			{
				int step = 0;
				int prev_selected = selected;

				step = (msg == (neutrino_msg_t)g_settings.key_channelList_pageup) ? listmaxshow : 1;  // browse or step 1
				selected -= step;
				if((prev_selected-step) < 0)		// because of uint
				{
					selected = Channels->size() - 1;
				}

				if (state == beDefault)
				{
					paintItem(prev_selected - liststart);
					unsigned int oldliststart = liststart;
					liststart = (selected/listmaxshow)*listmaxshow;
					
					if(oldliststart!=liststart)
					{
						paint();
					}
					else
					{
						paintItem(selected - liststart);
					}
				}
				else if (state == beMoving)
				{
					internalMoveChannel(prev_selected, selected);
				}
			}
		}
		else if (msg == CRCInput::RC_down || msg == (neutrino_msg_t)g_settings.key_channelList_pagedown)
		{
			unsigned int step = 0;
			int prev_selected = selected;

			step = (msg == (neutrino_msg_t)g_settings.key_channelList_pagedown) ? listmaxshow : 1;  // browse or step 1
			selected += step;

			if(selected >= Channels->size())
			{
				if (((Channels->size() / listmaxshow) + 1)*listmaxshow == Channels->size() + listmaxshow) // last page has full entries
					selected = 0;
				else
					selected = ((step == listmaxshow) && (selected < (((Channels->size() / listmaxshow) + 1)*listmaxshow))) ? (Channels->size() - 1) : 0;
			}

			if (state == beDefault)
			{
				paintItem(prev_selected - liststart);
				unsigned int oldliststart = liststart;
				liststart = (selected/listmaxshow)*listmaxshow;
				
				if(oldliststart!=liststart)
				{
					paint();
				}
				else
				{
					paintItem(selected - liststart);
				}
			}
			else if (state == beMoving)
			{
				internalMoveChannel(prev_selected, selected);
			}
		}
		else if(msg == CRCInput::RC_red)
		{
			if (state == beDefault)
				deleteChannel();
		}
		else if(msg == CRCInput::RC_green)
		{
			if (state == beDefault)
				addChannel();
		}
		else if(msg == CRCInput::RC_blue)
		{
			if (state == beDefault)
			{
				if (mode == CZapitClient::MODE_TV)
					mode = CZapitClient::MODE_RADIO;
				else
					mode = CZapitClient::MODE_TV;

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

				selected = 0;
				paint();
			}
		}
		else if(msg == CRCInput::RC_yellow)
		{
			liststart = (selected/listmaxshow)*listmaxshow;
			if (state == beDefault)
				beginMoveChannel();
			paintItem(selected - liststart);
		}
		else if(msg == CRCInput::RC_ok)
		{
			if (state == beDefault)
			{
				if (selected < Channels->size()) /* Channels.size() might be 0 */
					g_Zapit->zapTo_serviceID((*Channels)[selected]->channel_id);

			} 
			else if (state == beMoving) 
			{
				finishMoveChannel();
			}
		}
		else if( CRCInput::isNumeric(msg) )
		{
			if (state == beDefault)
			{
				//kein pushback - wenn man versehentlich wo draufkommt is die edit-arbeit umsonst
				//selected = oldselected;
				//g_RCInput->postMsg( msg, data );
				//loop=false;
			}
			else if (state == beMoving)
			{
				cancelMoveChannel();
			}
		}
		else
		{
			CNeutrinoApp::getInstance()->handleMsg( msg, data );
		}

		frameBuffer->blit();	
	}
	
	hide();
	
	return res;
}
Exemplo n.º 5
0
int CPictureViewerGui::show()
{
	neutrino_msg_t      msg;
	neutrino_msg_data_t data;

	int res = -1;

	CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, g_Locale->getText(LOCALE_PICTUREVIEWER_HEAD));
	m_state=MENU;

	int timeout;

	bool loop=true;
	bool update=true;

	while (loop)
	{
		if (update)
		{
			hide();
			update=false;
			paint();
			frameBuffer->blit();
		}

		if (m_state!=SLIDESHOW)
			timeout=50; // egal
		else
		{
			timeout=(m_time+atoi(g_settings.picviewer_slide_time)-(long)time(NULL))*10;
			if (timeout <0 )
				timeout=1;
		}
		g_RCInput->getMsg( &msg, &data, timeout );

		if ( msg == CRCInput::RC_home)
		{ //Exit after cancel key
			if (m_state!=MENU)
			{
				endView();
				update=true;
			}
			else
				loop=false;
		}
		else if (msg == CRCInput::RC_timeout)
		{
			if (m_state == SLIDESHOW)
			{
				m_time=(long)time(NULL);
				unsigned int next = selected + 1;
				if (next >= playlist.size())
					next = 0;
				view(next);
			}
		}
		else if (msg == CRCInput::RC_left)
		{
			if (!playlist.empty())
			{
				if (m_state == MENU)
				{
					if (selected < listmaxshow)
						selected=playlist.size()-1;
					else
						selected -= listmaxshow;
					liststart = (selected/listmaxshow)*listmaxshow;
					paint();
				}
				else
				{
					view((selected == 0) ? (playlist.size() - 1) : (selected - 1));
				}
			}
		}
		else if (msg == CRCInput::RC_right)
		{
			if (!playlist.empty())
			{
				if (m_state == MENU)
				{
					selected += listmaxshow;
					if (selected >= playlist.size()) {
						if (((playlist.size() / listmaxshow) + 1) * listmaxshow == playlist.size() + listmaxshow)
							selected=0;
						else
							selected = selected < (((playlist.size() / listmaxshow) + 1) * listmaxshow) ? (playlist.size() - 1) : 0;
					}
					liststart = (selected/listmaxshow)*listmaxshow;
					paint();
				}
				else
				{
					unsigned int next = selected + 1;
					if (next >= playlist.size())
						next = 0;
					view(next);
				}
			}
		}
		else if (msg == CRCInput::RC_up)
		{
			if ((m_state == MENU) && (!playlist.empty()))
			{
				int prevselected=selected;
				if (selected==0)
				{
					selected = playlist.size()-1;
				}
				else
					selected--;
				paintItem(prevselected - liststart);
				unsigned int oldliststart = liststart;
				liststart = (selected/listmaxshow)*listmaxshow;
				if (oldliststart!=liststart)
				{
					update=true;
				}
				else
				{
					paintItem(selected - liststart);
				}
			}
		}
		else if (msg == CRCInput::RC_down)
		{
			if ((m_state == MENU) && (!playlist.empty()))
			{
				int prevselected=selected;
				selected = (selected+1)%playlist.size();
				paintItem(prevselected - liststart);
				unsigned int oldliststart = liststart;
				liststart = (selected/listmaxshow)*listmaxshow;
				if (oldliststart!=liststart)
				{
					update=true;
				}
				else
				{
					paintItem(selected - liststart);
				}
			}
		}
		else if (msg == CRCInput::RC_spkr)
		{
			if (!playlist.empty())
			{
				if (m_state == MENU)
				{
					deletePicFile(selected, false);
					update = true;
				}
				else{
					deletePicFile(selected, true);
				}
			}
		}

		else if (msg == CRCInput::RC_ok)
		{
			if (!playlist.empty())
				view(selected);
		}
		else if (msg == CRCInput::RC_red)
		{
			if (m_state == MENU)
			{
				if (!playlist.empty())
				{
					CViewList::iterator p = playlist.begin()+selected;
					playlist.erase(p);
					if (selected >= playlist.size())
						selected = playlist.size()-1;
					update = true;
				}
			}
		}
		else if (msg==CRCInput::RC_green)
		{
			if (m_state == MENU)
			{
				CFileBrowser filebrowser((g_settings.filebrowser_denydirectoryleave) ? g_settings.network_nfs_picturedir : "");

				filebrowser.Multi_Select    = true;
				filebrowser.Dirs_Selectable = true;
				filebrowser.Filter          = &picture_filter;

				hide();

				if (filebrowser.exec(Path.c_str()))
				{
					Path = filebrowser.getCurrentDir();
					CFileList::const_iterator files = filebrowser.getSelectedFiles().begin();
					for (; files != filebrowser.getSelectedFiles().end(); files++)
					{
						if (files->getType() == CFile::FILE_PICTURE)
						{
							CPicture pic;
							pic.Filename = files->Name;
							std::string tmp   = files->Name.substr(files->Name.rfind('/')+1);
							pic.Name     = tmp.substr(0,tmp.rfind('.'));
							pic.Type     = tmp.substr(tmp.rfind('.')+1);
							struct stat statbuf;
							if (stat(pic.Filename.c_str(),&statbuf) != 0)
								printf("stat error");
							pic.Date     = statbuf.st_mtime;
							playlist.push_back(pic);
						}
						else
							printf("Wrong Filetype %s:%d\n",files->Name.c_str(), files->getType());
					}
					if (m_sort == FILENAME)
						std::sort(playlist.begin(), playlist.end(), comparePictureByFilename);
					else if (m_sort == DATE)
						std::sort(playlist.begin(), playlist.end(), comparePictureByDate);
				}
				update=true;
			}
		}
		else if (msg==CRCInput::RC_yellow)
		{
			if (m_state == MENU && !playlist.empty())
			{
				playlist.clear();
				selected=0;
				update=true;
			}
		}
		else if (msg==CRCInput::RC_blue)
		{
			if ((m_state == MENU) && (!playlist.empty()))
			{
				m_time=(long)time(NULL);
				view(selected);
				m_state=SLIDESHOW;
			} else {
				if (m_state == SLIDESHOW)
					m_state = VIEW;
				else
					m_state = SLIDESHOW;
			}
		}
#ifdef EVOLUX
		else if (msg==g_settings.key_help)
#else
		else if (msg==CRCInput::RC_help)
#endif
		{
			if (m_state == MENU)
			{
				showHelp();
				paint();
			}
		}
		else if ( msg == CRCInput::RC_1 )
		{
			if (m_state != MENU && !playlist.empty())
			{
				m_viewer->Zoom(2.0/3);
			}

		}
		else if ( msg == CRCInput::RC_2 )
		{
			if (m_state != MENU && !playlist.empty())
			{
				m_viewer->Move(0,-50);
			}
		}
		else if ( msg == CRCInput::RC_3 )
		{
			if (m_state != MENU && !playlist.empty())
			{
				m_viewer->Zoom(1.5);
			}

		}
		else if ( msg == CRCInput::RC_4 )
		{
			if (m_state != MENU && !playlist.empty())
			{
				m_viewer->Move(-50,0);
			}
		}
		else if ( msg == CRCInput::RC_5 )
		{
			if (m_state==MENU)
			{
				if (!playlist.empty())
				{
					if (m_sort==FILENAME)
					{
						m_sort=DATE;
						std::sort(playlist.begin(),playlist.end(),comparePictureByDate);
					}
					else if (m_sort==DATE)
					{
						m_sort=FILENAME;
						std::sort(playlist.begin(),playlist.end(),comparePictureByFilename);
					}
					update=true;
				}
			}
		}
		else if ( msg == CRCInput::RC_6 )
		{
			if (m_state != MENU && !playlist.empty())
			{
				m_viewer->Move(50,0);
			}
		}
		else if ( msg == CRCInput::RC_8 )
		{
			if (m_state != MENU && !playlist.empty())
			{
				m_viewer->Move(0,50);
			}
		}
		else if (msg==CRCInput::RC_0)
		{
			if (!playlist.empty())
				view(selected, true);
		}
		else if (msg==CRCInput::RC_setup)
		{
			if (m_state==MENU)
			{
				CNFSSmallMenu nfsMenu;
				nfsMenu.exec(this, "");
				update=true;
				CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, g_Locale->getText(LOCALE_PICTUREVIEWER_HEAD));
			}
		}
		else if (msg == NeutrinoMessages::CHANGEMODE)
		{
			if ((data & NeutrinoMessages::mode_mask) !=NeutrinoMessages::mode_pic)
			{
				loop = false;
				m_LastMode=data;
			}
		}
		else if (msg == NeutrinoMessages::RECORD_START ||
				msg == NeutrinoMessages::ZAPTO ||
				msg == NeutrinoMessages::STANDBY_ON ||
				msg == NeutrinoMessages::SHUTDOWN ||
				msg == NeutrinoMessages::SLEEPTIMER)
		{
			// Exit for Record/Zapto Timers
			if (m_state != MENU)
				endView();
			loop = false;
			g_RCInput->postMsg(msg, data);
		}
		else if ((msg == CRCInput::RC_sat) || (msg == CRCInput::RC_favorites)) {
		}
		else
		{
			if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all )
			{
				loop = false;
			}
		}
		frameBuffer->blit();
	}
	hide();

	return(res);
}
Exemplo n.º 6
0
bool CFileBrowser::exec(const char * const dirname)
{
	neutrino_msg_t      msg;
	neutrino_msg_data_t data;

	bool res = false;

#ifdef ENABLE_INTERNETRADIO
	if (m_Mode == ModeSC) {
		m_baseurl = base;
	} else
#endif
	{
		m_baseurl = "http://" + g_settings.streaming_server_ip + ':'
			  + g_settings.streaming_server_port + "/requests/browse.xml?dir=";
	}
	name = dirname;
	std::replace(name.begin(), name.end(), '\\', '/');

	paintHead();
	ChangeDir(name);
	paint();
	paintFoot();

	int oldselected = selected;

	unsigned long long timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_FILEBROWSER]);

	bool loop=true;
	while (loop)
	{
		g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );
		neutrino_msg_t msg_repeatok = msg & ~CRCInput::RC_Repeat;

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

		if(!CRCInput::isNumeric(msg))
		{
			m_SMSKeyInput.resetOldKey();
		}

		if (msg == CRCInput::RC_yellow)
		{
			if ((Multi_Select) && (selected < filelist.size()))
			{
				if(filelist[selected].getFileName() != "..")
				{
					if( (S_ISDIR(filelist[selected].Mode) && Dirs_Selectable) || !S_ISDIR(filelist[selected].Mode) )
					{
						filelist[selected].Marked = !filelist[selected].Marked;
						paintItem(selected - liststart);
					}
				}
				msg_repeatok = CRCInput::RC_down;	// jump to next item
			}
		}

		if ((msg == CRCInput::RC_red) || msg == CRCInput::RC_page_down)
		{
			selected += listmaxshow;
			if (selected >= filelist.size()) {
				if (((filelist.size() / listmaxshow) + 1) * listmaxshow == filelist.size() + listmaxshow) // last page has full entries
					selected = 0;
				else
					selected = selected < (((filelist.size() / listmaxshow) + 1) * listmaxshow) ? (filelist.size() - 1) : 0;
			}
			liststart = (selected / listmaxshow) * listmaxshow;
			paint();
		}
		else if ((msg == CRCInput::RC_green) || (msg == CRCInput::RC_page_up) )
		{
			if ((int(selected)-int(listmaxshow))<0)
				selected=filelist.size()-1;
			else
				selected -= listmaxshow;
			liststart = (selected/listmaxshow)*listmaxshow;
			paint();
		}
		else if (msg_repeatok == CRCInput::RC_up)
		{
			int prevselected=selected;
			if(selected==0)
			{
				selected = filelist.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_repeatok == CRCInput::RC_down)
		{
			if (!(filelist.empty()))
			{
				int prevselected=selected;
				selected = (selected + 1) % filelist.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_timeout ) )
		{
			selected = oldselected;
			loop=false;
		}
		else if ( msg == CRCInput::RC_right )
		{
			if (!(filelist.empty()))
			{
				if (S_ISDIR(filelist[selected].Mode))
				{
#ifdef ENABLE_INTERNETRADIO
					if (m_Mode == ModeSC) {
						ChangeDir(filelist[selected].Url);
					} else 
#endif
					{
	 					if (filelist[selected].getFileName() != "..") {
							selections.push_back(selected);
							ChangeDir(filelist[selected].Name);
						}
					}
				}
			}
		}
		else if ( msg == CRCInput::RC_left )
		{
#ifdef ENABLE_INTERNETRADIO
			if (m_Mode == ModeSC)
			{
				for(unsigned int i = 0; i < filelist.size();i++) {
					if (S_ISDIR(filelist[i].Mode) && filelist[i].getFileName() == "..") {
						ChangeDir(filelist[i].Url);
						break;
					}
				}
			}
			else
#endif
			if (selections.size() > 0)
			{
				ChangeDir("..",selections.back());
				selections.pop_back();
			} else
			{
				ChangeDir("..");
			}
		}
		else if ( msg == CRCInput::RC_blue )
		{
			if(Filter != NULL)
			{
				use_filter = !use_filter;
				paintFoot();
				ChangeDir(Path);
			}
		}
		else if ( msg == CRCInput::RC_home )
		{
			loop = false;
		}
		else if ( msg == CRCInput::RC_spkr && strncmp(Path.c_str(), VLC_URI, strlen(VLC_URI)) != 0) //Not in vlc mode
		{
			if(".." !=(filelist[selected].getFileName().substr(0,2))) // do not delete that
			{
				std::stringstream _msg;
				_msg << g_Locale->getText(LOCALE_FILEBROWSER_DODELETE1) << " ";
				if (filelist[selected].getFileName().length() > 25)
				{
					_msg << filelist[selected].getFileName().substr(0, 25) << "...";
				}
				else
					_msg << filelist[selected].getFileName();

				_msg << " " << g_Locale->getText(LOCALE_FILEBROWSER_DODELETE2);
				if (ShowMsgUTF(LOCALE_FILEBROWSER_DELETE, _msg.str(), CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)==CMessageBox::mbrYes)
				{
					recursiveDelete(filelist[selected].Name.c_str());
					if(".ts" ==(filelist[selected].getFileName().substr(filelist[selected].getFileName().length()-3,filelist[selected].getFileName().length())))//if bla.ts
					{
						recursiveDelete((filelist[selected].Name.substr(0,filelist[selected].Name.length()-7)+".xml").c_str());//remove bla.xml von bla.ts
					}
					ChangeDir(Path);

				}
			}
		}
		else if (msg == CRCInput::RC_ok)
		{
			if (!(filelist.empty()))
			{
				if (filelist[selected].getFileName() == "..")
				{
#ifdef ENABLE_INTERNETRADIO
					if (m_Mode == ModeSC)
						ChangeDir(filelist[selected].Url);
					else
#endif
					{
						if (selections.size() > 0)
						{
							ChangeDir("..",selections.back());
							selections.pop_back();
						} else
						{
							std::string::size_type pos = Path.substr(0,Path.length()-1).rfind('/');
							if (pos != std::string::npos) {
								ChangeDir("..");
							}
							else {
								loop = false;
								res = true;
								filelist[selected].Name = "/";
							}
						}
					}
				}
				else
				{
					std::string filename = filelist[selected].Name;
					if ( filename.length() > 1 )
					{
						if((!Multi_Select) && S_ISDIR(filelist[selected].Mode) && !Dir_Mode)
						{
#ifdef ENABLE_INTERNETRADIO
							if (m_Mode == ModeSC)
								ChangeDir(filelist[selected].Url);
							else
#endif
								ChangeDir(filelist[selected].Name);
						}
						else
						{
							filelist[selected].Marked = true;
							loop = false;
							res = true;
						}
					}
				}
			}
		}
		else if (msg==CRCInput::RC_help)
		{
			if (++g_settings.filebrowser_sortmethod >= FILEBROWSER_NUMBER_OF_SORT_VARIANTS)
				g_settings.filebrowser_sortmethod = 0;

			sort(filelist.begin(), filelist.end(), sortBy[g_settings.filebrowser_sortmethod]);

			paint();
			paintFoot();
		}
		else if (CRCInput::isNumeric(msg_repeatok))
		{
			if (!(filelist.empty()))
				SMSInput(msg_repeatok);
		}
		else
		{
			if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all )
			{
				loop = false;
			}
		}
	}

	hide();

	selected_filelist.clear();

	if(res && Multi_Select)
	{
		CProgressWindow * progress = new CProgressWindow();
		progress->setTitle(LOCALE_FILEBROWSER_SCAN);
		progress->exec(NULL,"");
		for(unsigned int i = 0; i < filelist.size();i++)
			if(filelist[i].Marked)
			{
				if(S_ISDIR(filelist[i].Mode)) {
#ifdef ENABLE_INTERNETRADIO
					if (m_Mode == ModeSC)
						addRecursiveDir(&selected_filelist,filelist[i].Url, true, progress);
					else
#endif
						addRecursiveDir(&selected_filelist,filelist[i].Name, true, progress);
				} else
					selected_filelist.push_back(filelist[i]);
			}
		progress->hide();
		delete progress;
	}

	return res;
}
Exemplo n.º 7
0
int CTimerList::show()
{
	neutrino_msg_t      msg;
	neutrino_msg_data_t data;

	int res = menu_return::RETURN_REPAINT;

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

	bool loop=true;
	bool update=true;

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

	while (loop)
	{
		if (update)
		{
			hide();
			updateEvents();
			update=false;
			paint();
		}
		g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );
		
		//ignore numeric keys
		if (g_RCInput->isNumeric(msg)){
			msg = CRCInput::RC_nokey;
		}
			
		if ( msg <= CRCInput::RC_MaxRC )
			timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings
							      ::TIMING_MENU]);

		if((msg == NeutrinoMessages::EVT_TIMER) && (data == fader.GetTimer())) {
			if(fader.Fade())
				loop = false;
		}
		else if ( ( msg == CRCInput::RC_timeout ) ||
				( msg == CRCInput::RC_home)  || (msg == CRCInput::RC_left) ||
				(( msg == CRCInput::RC_ok) && (timerlist.empty())) )
		{	//Exit after timeout or cancel key
			if(fader.StartFadeOut()) {
				timeoutEnd = CRCInput::calcTimeoutEnd( 1 );
				msg = 0;
			} else
				loop=false;

		}
		else if ((msg == CRCInput::RC_up || msg == (unsigned int)g_settings.key_channelList_pageup) && !(timerlist.empty()))
		{
			int step = 0;
			int prev_selected = selected;

			step = (msg == (unsigned int)g_settings.key_channelList_pageup) ? listmaxshow : 1;  // browse or step 1
			selected -= step;
			if((prev_selected-step) < 0)		// because of uint
				selected = timerlist.size() - 1;

			paintItem(prev_selected - liststart);
			unsigned int oldliststart = liststart;
			liststart = (selected/listmaxshow)*listmaxshow;
			if (oldliststart!=liststart)
			{
				paint();
			}
			else
			{
				paintItem(selected - liststart);
			}

			paintFoot();
		}
		else if ((msg == CRCInput::RC_down || msg == (unsigned int)g_settings.key_channelList_pagedown) && !(timerlist.empty()))
		{
			unsigned int step = 0;
			int prev_selected = selected;

			step = (msg == (unsigned int)g_settings.key_channelList_pagedown) ? listmaxshow : 1;  // browse or step 1
			selected += step;

			if(selected >= timerlist.size())
			{
				if (((timerlist.size() / listmaxshow) + 1) * listmaxshow == timerlist.size() + listmaxshow) // last page has full entries
					selected = 0;
				else
					selected = ((step == listmaxshow) && (selected < (((timerlist.size() / listmaxshow) + 1) * listmaxshow))) ? (timerlist.size() - 1) : 0;
			}
			paintItem(prev_selected - liststart);

			unsigned int oldliststart = liststart;
			liststart = (selected/listmaxshow)*listmaxshow;
			if (oldliststart!=liststart)
			{
				paint();
			}
			else
			{
				paintItem(selected - liststart);
			}

			paintFoot();
		}
		else if ((msg == CRCInput::RC_right || msg == CRCInput::RC_ok || msg==CRCInput::RC_blue) && !(timerlist.empty()))
		{
			if (modifyTimer()==menu_return::RETURN_EXIT_ALL)
			{
				res=menu_return::RETURN_EXIT_ALL;
				loop=false;
			}
			else
				update=true;
		}
		else if ((msg == CRCInput::RC_red) && !(timerlist.empty()))
		{
			bool killTimer = true;
			if (CRecordManager::getInstance()->RecordingStatus(timerlist[selected].channel_id)) {
				CTimerd::RecordingStopInfo recinfo;
				recinfo.channel_id = timerlist[selected].channel_id;
				recinfo.eventID = timerlist[selected].eventID;
				if (CRecordManager::getInstance()->IsRecording(&recinfo)) {
					std::string title = "";
					char buf1[1024];
					CEPGData epgdata;
					CEitManager::getInstance()->getEPGid(timerlist[selected].epgID, timerlist[selected].epg_starttime, &epgdata);
					memset(buf1, '\0', sizeof(buf1));
					if (epgdata.title != "")
						title = "(" + epgdata.title + ")\n";
					snprintf(buf1, sizeof(buf1)-1, g_Locale->getText(LOCALE_TIMERLIST_ASK_TO_DELETE), title.c_str());
					if(ShowMsg(LOCALE_RECORDINGMENU_RECORD_IS_RUNNING, buf1,
							CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrNo) {
						killTimer = false;
						update = false;
					}
				}
			}
			if (killTimer) {
				Timer->removeTimerEvent(timerlist[selected].eventID);
				skipEventID=timerlist[selected].eventID;
				update = true;
			}
		}
		else if (msg==CRCInput::RC_green)
		{
			if (newTimer()==menu_return::RETURN_EXIT_ALL)
			{
				res=menu_return::RETURN_EXIT_ALL;
				loop=false;
			}
			else
				update=true;
		}
		else if (msg==CRCInput::RC_yellow)
		{
			update=true;
		}
#if 0
		else if ((msg==CRCInput::RC_blue)||
				(CRCInput::isNumeric(msg)) )
		{
			//pushback key if...
			g_RCInput->postMsg( msg, data );
			loop=false;
		}
#endif
		else if (msg==CRCInput::RC_setup)
		{
			res=menu_return::RETURN_EXIT_ALL;
			loop=false;
		}
		else if ( msg == CRCInput::RC_help || msg == CRCInput::RC_info)
		{
			CTimerd::responseGetTimer* timer=&timerlist[selected];
			if (timer!=NULL)
			{
				if (timer->eventType == CTimerd::TIMER_RECORD || timer->eventType == CTimerd::TIMER_ZAPTO)
				{
					hide();
					if (timer->epgID != 0)
						res = g_EpgData->show(timer->channel_id, timer->epgID, &timer->epg_starttime);
					else
						ShowHint(LOCALE_MESSAGEBOX_INFO, LOCALE_EPGVIEWER_NOTFOUND);
					if (res==menu_return::RETURN_EXIT_ALL)
						loop=false;
					else
						paint();
				}
			}
			// help key
		}
		else if (msg == CRCInput::RC_sat || msg == CRCInput::RC_favorites) {
			g_RCInput->postMsg (msg, 0);
			loop = false;
			res = menu_return::RETURN_EXIT_ALL;
		}
		else
		{
			if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all )
			{
				loop = false;
				res = menu_return::RETURN_EXIT_ALL;
			}
		}
	}
	hide();
	fader.Stop();

	return(res);
}
Exemplo n.º 8
0
int CListBox::exec(CMenuTarget* parent, string actionKey)
{
    int res = menu_return::RETURN_REPAINT;
    selected=0;

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

    paintHead();
    paint();
    paintFoot();

    bool loop=true;
    toSave = false;
    while (loop)
    {
        uint msg;
        uint data;
        g_RCInput->getMsg( &msg, &data, g_settings.timing_epg );

        if (( msg == (uint) g_settings.key_channelList_cancel) || ( msg ==CRCInput::RC_home))
        {
            loop = false;
        }
        else if ( msg ==CRCInput::RC_up)
        {
            if(getItemCount()!=0)
            {
                int prevselected=selected;
                if(selected==0)
                {
                    selected = getItemCount()-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)
        {
            if(getItemCount()!=0)
            {
                int prevselected=selected;
                selected = (selected+1)%getItemCount();
                paintItem(prevselected - liststart);
                unsigned int oldliststart = liststart;
                liststart = (selected/listmaxshow)*listmaxshow;
                if(oldliststart!=liststart)
                {
                    paint();
                }
                else
                {
                    paintItem(selected - liststart);
                }
            }
        }
        else if ( msg == (uint) g_settings.key_channelList_pageup)
        {
            selected+=listmaxshow;
            if (selected>getItemCount()-1)
                selected=0;
            liststart = (selected/listmaxshow)*listmaxshow;
            paint();
        }
        else if ( msg == (uint) g_settings.key_channelList_pagedown)
        {
            if ((int(selected)-int(listmaxshow))<0)
                selected=getItemCount()-1;
            else
                selected -= listmaxshow;
            liststart = (selected/listmaxshow)*listmaxshow;
            paint();
        }
        else if( msg ==CRCInput::RC_ok)
        {
            onOkKeyPressed();
        }
        else if ( msg ==CRCInput::RC_red)
        {
            onRedKeyPressed();
        }
        else if ( msg ==CRCInput::RC_green)
        {
            onGreenKeyPressed();
        }
        else if ( msg ==CRCInput::RC_yellow)
        {
            onYellowKeyPressed();
        }
        else if ( msg ==CRCInput::RC_blue)
        {
            onBlueKeyPressed();
        }
        else
        {
            CNeutrinoApp::getInstance()->handleMsg( msg, data );
            // kein canceling...
        }
    }

    //want2save?
    if((toSave) && (saveBoxCaption!="") && (saveBoxText!=""))
    {
        if( ShowMsg ( saveBoxCaption, saveBoxText, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo ) == CMessageBox::mbrYes )
        {
            onSaveData();
        }
    }

    hide();
    return res;
}
Exemplo n.º 9
0
void TreeViewItem::paintRecursively (Graphics& g, int width)
{
    jassert (ownerView != 0);
    if (ownerView == 0)
        return;

    const int indent = getIndentX();
    const int itemW = itemWidth < 0 ? width - indent : itemWidth;

    {
        Graphics::ScopedSaveState ss (g);
        g.setOrigin (indent, 0);

        if (g.reduceClipRegion (drawsInLeftMargin ? -indent : 0, 0,
                                drawsInLeftMargin ? itemW + indent : itemW, itemHeight))
            paintItem (g, itemW, itemHeight);
    }

    g.setColour (ownerView->findColour (TreeView::linesColourId));

    const float halfH = itemHeight * 0.5f;
    int depth = 0;
    TreeViewItem* p = parentItem;

    while (p != 0)
    {
        ++depth;
        p = p->parentItem;
    }

    if (! ownerView->rootItemVisible)
        --depth;

    const int indentWidth = ownerView->getIndentSize();

    if (depth >= 0 && ownerView->openCloseButtonsVisible)
    {
        float x = (depth + 0.5f) * indentWidth;

        if (depth >= 0)
        {
            if (parentItem != 0 && parentItem->drawLinesInside)
                g.drawLine (x, 0, x, isLastOfSiblings() ? halfH : (float) itemHeight);


            if ((parentItem != 0 && parentItem->drawLinesInside)
                 || (parentItem == 0 && drawLinesInside))
                g.drawLine (x, halfH, x + indentWidth / 2, halfH);
        }

        p = parentItem;
        int d = depth;

        while (p != 0 && --d >= 0)
        {
            x -= (float) indentWidth;

            if ((p->parentItem == 0 || p->parentItem->drawLinesInside)
                 && ! p->isLastOfSiblings())
            {
                g.drawLine (x, 0, x, (float) itemHeight);
            }

            p = p->parentItem;
        }

        if (mightContainSubItems())
        {
            Graphics::ScopedSaveState ss (g);

            g.setOrigin (depth * indentWidth, 0);
            g.reduceClipRegion (0, 0, indentWidth, itemHeight);

            paintOpenCloseButton (g, indentWidth, itemHeight,
                static_cast <TreeViewContentComponent*> (ownerView->viewport->getViewedComponent())
                    ->isMouseOverButton (this));
        }
    }

    if (isOpen())
    {
        const Rectangle<int> clip (g.getClipBounds());

        for (int i = 0; i < subItems.size(); ++i)
        {
            TreeViewItem* const ti = subItems.getUnchecked(i);

            const int relY = ti->y - y;

            if (relY >= clip.getBottom())
                break;

            if (relY + ti->totalHeight >= clip.getY())
            {
                Graphics::ScopedSaveState ss (g);

                g.setOrigin (0, relY);

                if (g.reduceClipRegion (0, 0, width, ti->totalHeight))
                    ti->paintRecursively (g, width);
            }
        }
    }
}
Exemplo n.º 10
0
int CListBox::exec(CMenuTarget* parent, const std::string &)
{
	neutrino_msg_t      msg;
	neutrino_msg_data_t data;

	int res = menu_return::RETURN_REPAINT;
	selected=0;

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

	paintHead();
	paint();
	paintFoot();

	bool loop=true;
	modified = false;
	while (loop)
	{
		g_RCInput->getMsg(&msg, &data, g_settings.timing[SNeutrinoSettings::TIMING_EPG]);
		neutrino_msg_t msg_repeatok = msg & ~CRCInput::RC_Repeat;

		if (msg == g_settings.key_channelList_cancel || msg == CRCInput::RC_home)
		{
			loop = false;
		}
		else if (msg_repeatok == CRCInput::RC_up || msg_repeatok == g_settings.key_channelList_pageup)
		{
			int step = 0;
			int prev_selected = selected;

			step = (msg_repeatok == g_settings.key_channelList_pageup) ? listmaxshow : 1;  // browse or step 1
			selected -= step;
			if((prev_selected-step) < 0)		// because of uint
				selected = getItemCount() - 1;

			paintItem(prev_selected - liststart);
			unsigned int oldliststart = liststart;
			liststart = (selected/listmaxshow)*listmaxshow;

			if(oldliststart!=liststart)
				paint();
			else
				paintItem(selected - liststart);
		}
		else if (msg_repeatok == CRCInput::RC_down || msg_repeatok == g_settings.key_channelList_pagedown)
		{
			unsigned int step = 0;
			int prev_selected = selected;

			step = (msg_repeatok == g_settings.key_channelList_pagedown) ? listmaxshow : 1;  // browse or step 1
			selected += step;

			if(selected >= getItemCount())
				if (((getItemCount() / listmaxshow) + 1) * listmaxshow == getItemCount() + listmaxshow) // last page has full entries
					selected = 0;
				else
					selected = ((step == listmaxshow) && (selected < (((getItemCount() / listmaxshow) + 1) * listmaxshow))) ? (getItemCount() - 1) : 0;
			
			paintItem(prev_selected - liststart);
			unsigned int oldliststart = liststart;
			liststart = (selected/listmaxshow)*listmaxshow;
			if(oldliststart!=liststart)
				paint();
			else
				paintItem(selected - liststart);
		}
		else if( msg ==CRCInput::RC_ok)
		{
			onOkKeyPressed();
		}
		else if ( msg ==CRCInput::RC_red)
		{
			onRedKeyPressed();
		}
		else if ( msg ==CRCInput::RC_green)
		{
			onGreenKeyPressed();
		}
		else if ( msg ==CRCInput::RC_yellow)
		{
			onYellowKeyPressed();
		}
		else if ( msg ==CRCInput::RC_blue)
		{
			onBlueKeyPressed();
		}
		else
		{
			CNeutrinoApp::getInstance()->handleMsg( msg, data );
			// kein canceling...
		}
	}

	hide();
	return res;
}
//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;
}
Exemplo n.º 12
0
// main
int CSysInfoWidget::exec(CMenuTarget *parent, const std::string &/*actionKey*/)
{
	int res = menu_return::RETURN_REPAINT;

	if(mode == SYSINFO)
	{
		sysinfo();
	}
	else if(mode == DMESGINFO)
	{
		dmesg();
	}
	else if(mode == CPUINFO)
	{
		cpuinfo();
	}
	else if(mode == PSINFO)
	{
		ps();
	}

	if (parent)
		parent->hide();

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

	neutrino_msg_t msg; 
	neutrino_msg_data_t data;
	int timercount = 0;
	unsigned long long timeoutEnd = g_RCInput->calcTimeoutEnd(5);

	while (msg != (neutrino_msg_t) g_settings.key_channelList_cancel)
	{
		g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );

		if (msg <= CRCInput::RC_MaxRC  ) 
			timeoutEnd = g_RCInput->calcTimeoutEnd(5);
		
		if (msg == CRCInput::RC_timeout)
		{
			if (mode == SYSINFO)
			{
				timercount = 0;
				sysinfo();
				selected = 0;
				paintHead();
				paint();
				paintFoot();
			}
			
			if ((mode == DMESGINFO) && (++timercount>11))
			{
				timercount = 0;
				dmesg();
				paintHead();
				paint();
				paintFoot();
			}
			
			if ((mode == PSINFO)&&(refreshIt == true))
			{
				timercount = 0;
				ps();
				paintHead();
				paint();
				paintFoot();
			}

			timeoutEnd = g_RCInput->calcTimeoutEnd(5);
			g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );
		}
		
		if ( ((int) msg == g_settings.key_channelList_pageup) && (mode != SYSINFO))
		{
			int step = 0;
			int prev_selected = selected;

			step =  ((int) msg == g_settings.key_channelList_pageup) ? listmaxshow : 1;  // browse or step 1
			selected -= step;
			if((prev_selected - step) < 0) 
				selected = syscount - 1;
			
			if(state == beDefault)
			{
				paintItem(prev_selected - liststart);
				unsigned int oldliststart = liststart;
				liststart = (selected/listmaxshow)*listmaxshow;
				if(oldliststart!=liststart) 
					paint();
				else 
					paintItem(selected - liststart);
			}
		}
		else if (((int) msg == g_settings.key_channelList_pagedown) && (mode != SYSINFO))
		{
			int step = 0;
			int prev_selected = selected;

			step =  ((int) msg == g_settings.key_channelList_pagedown) ? listmaxshow : 1;  // browse or step 1
			selected += step;
			if((int)selected >= syscount) 
				selected = 0;
			
			if(state == beDefault)
			{
				paintItem(prev_selected - liststart);
				unsigned int oldliststart = liststart;
				liststart = (selected/listmaxshow)*listmaxshow;
				if(oldliststart != liststart) 
					paint();
				else 
					paintItem(selected - liststart);
			}
		}
		else if ((msg == CRCInput::RC_red) && (mode != SYSINFO))
		{
			mode = SYSINFO;
			sysinfo();
			selected = 0;
			paintHead();
			paint();
			paintFoot();

		}
		else if ((msg == CRCInput::RC_green) && (mode != DMESGINFO))
		{
			mode = DMESGINFO;
			timercount = 0;
			dmesg();
			selected = 0;
			paintHead();
			paint();
			paintFoot();
		}
		else if ((msg == CRCInput::RC_yellow) && (mode != CPUINFO))
		{
			mode = CPUINFO;
			cpuinfo();
			selected = 0;
			paintHead();
			paint();
			paintFoot();
		}
		else if (msg == CRCInput::RC_blue)
		{
			mode = PSINFO;
			ps();
			selected = 0;
			paintHead();
			paint();
			paintFoot();
		}
		else
		{
			CNeutrinoApp::getInstance()->handleMsg( msg, data );
			// kein canceling...
		}

		frameBuffer->blit();	
	}
	
	hide();
	
	return res;
}
Exemplo n.º 13
0
int EventList::exec(const t_channel_id channel_id, const std::string& channelname) // UTF-8
{
	neutrino_msg_t      msg;
	neutrino_msg_data_t data;
	bool in_search = 0;

	// windows size
	width  = w_max ( (frameBuffer->getScreenWidth() / 20 * 17), (frameBuffer->getScreenWidth() / 20 ));
	height = h_max ( (frameBuffer->getScreenHeight() / 20 * 16), (frameBuffer->getScreenHeight() / 20));

	//iheight = 30;	// FIXME: info bar height (see below, hard coded at this time)
	int icon_w;
	int icon_h;
	frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_RED, &icon_w, &icon_h);
	
	iheight = std::max(icon_h, g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight()) + 6;;
	
	//
	theight  = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_TITLE]->getHeight();

	fheight1 = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMLARGE]->getHeight();
	{
		int h1 = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMSMALL]->getHeight();
		int h2 = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_DATETIME]->getHeight();
		fheight2 = (h1 > h2) ? h1 : h2;
	}
	
	fheight = fheight1 + fheight2 + 2;
	fwidth1 = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_DATETIME]->getRenderWidth("DDD, 00:00,  ");
	fwidth2 = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMSMALL]->getRenderWidth("[999 min] ");

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

	x = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - width) / 2;
	y = frameBuffer->getScreenY() + (frameBuffer->getScreenHeight() - height) / 2;

	int res = menu_return::RETURN_REPAINT;
	
	if(m_search_list == SEARCH_LIST_NONE) // init globals once only
	{
		m_search_epg_item = SEARCH_EPG_TITLE;
		m_search_list = SEARCH_LIST_CHANNEL;
		m_search_bouquet_id= bouquetList->getActiveBouquetNumber();
	}
	
	m_search_channel_id = channel_id;
	m_showChannel = false; // do not show the channel in normal mode, we just need it in search mode

	name = channelname;
	sort_mode = SORT_DESCRIPTION;
	
	paintHead(channel_id);
	readEvents(channel_id);
	paint(channel_id);
	showFunctionBar(true);
	
	// blit
	frameBuffer->blit();

	int oldselected = selected;

	unsigned long long 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 == CRCInput::RC_up || (int) msg == g_settings.key_channelList_pageup)
		{
			int step = 0;
			int prev_selected = selected;

			step = ((int) msg == g_settings.key_channelList_pageup) ? listmaxshow : 1;  // browse or step 1
			selected -= step;
			if((prev_selected-step) < 0)            // because of uint
				selected = evtlist.size() - 1;

			paintItem(prev_selected - liststart, channel_id);
			unsigned int oldliststart = liststart;
			liststart = (selected/listmaxshow)*listmaxshow;

			if(oldliststart!=liststart)
				paint(channel_id);
			else
				paintItem(selected - liststart, channel_id);
		}
		else if (msg == CRCInput::RC_down || (int) msg == g_settings.key_channelList_pagedown)
		{
			unsigned int step = 0;
			int prev_selected = selected;

			step = ((int) msg == g_settings.key_channelList_pagedown) ? listmaxshow : 1;  // browse or step 1
			selected += step;

			if(selected >= evtlist.size()) 
			{
				if (((evtlist.size() / listmaxshow) + 1) * listmaxshow == evtlist.size() + listmaxshow) // last page has full entries
					selected = 0;
				else
					selected = ((step == listmaxshow) && (selected < (((evtlist.size() / listmaxshow) + 1) * listmaxshow))) ? (evtlist.size() - 1) : 0;
			}

			paintItem(prev_selected - liststart, channel_id);
			unsigned int oldliststart = liststart;
			liststart = (selected/listmaxshow)*listmaxshow;
			if(oldliststart!=liststart)
				paint(channel_id);
			else
				paintItem(selected - liststart, channel_id);
		}
		// sort
		else if (msg == (neutrino_msg_t)g_settings.key_channelList_sort)
		{
			unsigned long long selected_id = evtlist[selected].eventID;
			
			if(sort_mode == SORT_DESCRIPTION) // by description
			{
				sort_mode++;
				sort(evtlist.begin(), evtlist.end(), sortByDescription);
			}
			else// datetime
			{
				sort_mode = SORT_DESCRIPTION;
				sort(evtlist.begin(), evtlist.end(), sortByDateTime);
			}
			
			// find selected
			for ( selected = 0 ; selected < evtlist.size(); selected++ )
			{
				if ( evtlist[selected].eventID == selected_id )
					break;
			}
			oldselected = selected;
			if(selected <=listmaxshow)
				liststart=0;
			else
				liststart=(selected/listmaxshow)*listmaxshow;
			
			hide();
			paintHead(channel_id);
			paint(channel_id);
			showFunctionBar(true);
		}
		// epg reload
		else if (msg == (neutrino_msg_t)g_settings.key_channelList_reload)
		{
			sort_mode = SORT_DESCRIPTION;
			hide();
			paintHead(channel_id);
			readEvents(channel_id);
			paint(channel_id);
			showFunctionBar(true);
		}
		// add record
		else if ( msg == (neutrino_msg_t)g_settings.key_channelList_addrecord )
		{
			if (recDir != NULL)
			{
				int tID = -1;
				CTimerd::CTimerEventTypes etype = isScheduled(channel_id, &evtlist[selected], &tID);
				if(etype == CTimerd::TIMER_RECORD) 
				{
					g_Timerd->removeTimerEvent(tID);
					timerlist.clear();
					g_Timerd->getTimerList(timerlist);
					paint(channel_id);
					continue;
				}
				
				if (recDir != NULL)
				{
					if (g_Timerd->addRecordTimerEvent(channel_id,
								evtlist[selected].startTime,
								evtlist[selected].startTime + evtlist[selected].duration,
								evtlist[selected].eventID, evtlist[selected].startTime,
								evtlist[selected].startTime - (ANNOUNCETIME + 120),
								TIMERD_APIDS_CONF, true, recDir,false) == -1)
					{
						if(askUserOnTimerConflict(evtlist[selected].startTime - (ANNOUNCETIME + 120), evtlist[selected].startTime + evtlist[selected].duration))
						{
							g_Timerd->addRecordTimerEvent(channel_id,
									evtlist[selected].startTime,
									evtlist[selected].startTime + evtlist[selected].duration,
									evtlist[selected].eventID, evtlist[selected].startTime,
									evtlist[selected].startTime - (ANNOUNCETIME + 120),
									TIMERD_APIDS_CONF, true, recDir,true);
									
							MessageBox(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO);
						}
					} 
					else 
					{
						MessageBox(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO);
					}
				}
				timerlist.clear();
				g_Timerd->getTimerList(timerlist);
				
				paint(channel_id);
			}					
		}
		// add remind
		else if ( msg == (neutrino_msg_t) g_settings.key_channelList_addremind )		  
		{
			int tID = -1;
			CTimerd::CTimerEventTypes etype = isScheduled(channel_id, &evtlist[selected], &tID);
			
			if(etype == CTimerd::TIMER_ZAPTO) 
			{
				g_Timerd->removeTimerEvent(tID);
				timerlist.clear();
				g_Timerd->getTimerList (timerlist);
				paint(channel_id);
				continue;
			}

			g_Timerd->addZaptoTimerEvent(channel_id, 
					evtlist[selected].startTime,
					evtlist[selected].startTime - ANNOUNCETIME, 0,
					evtlist[selected].eventID, evtlist[selected].startTime, 0);
					
			MessageBox(LOCALE_TIMER_EVENTTIMED_TITLE, LOCALE_TIMER_EVENTTIMED_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO);
			timerlist.clear();
			g_Timerd->getTimerList (timerlist);
			
			paint(channel_id);
		}
		else if (msg == CRCInput::RC_timeout)
		{
			selected = oldselected;
			loop = false;
		}
		else if (msg == (neutrino_msg_t)g_settings.key_channelList_cancel) 
		{
			if(in_search) 
			{
				in_search = false;
				name = channelname;
				paintHead(channel_id);
				readEvents(channel_id);
				paint(channel_id);
				showFunctionBar(true);
			} 
			else 
			{
				selected = oldselected;
				loop = false;
			}
		}
		else if (msg == CRCInput::RC_epg)
		{
			hide();
			CEPGplusHandler eplus;
			eplus.exec(NULL, "");
			
			paintHead(channel_id);
			readEvents(channel_id);
			paint(channel_id);
			showFunctionBar(true);
		}
		else if ( msg==CRCInput::RC_left )		  
		{
			loop = false;
		}
		else if ( msg == CRCInput::RC_right || msg == CRCInput::RC_ok || msg == CRCInput::RC_info)
		{
			if ( evtlist[selected].eventID != 0 )
			{
				hide();

				res = g_EpgData->show(channel_id, evtlist[selected].eventID, &evtlist[selected].startTime);
				
				if ( res == menu_return::RETURN_EXIT_ALL )
				{
					loop = false;
				}
				else
				{
					g_RCInput->getMsg( &msg, &data, 0 );

					if ( ( msg != CRCInput::RC_red ) && ( msg != CRCInput::RC_timeout ) )
					{
						// RC_red schlucken
						g_RCInput->postMsg( msg, data );
					}
					timerlist.clear();
					g_Timerd->getTimerList (timerlist);

					paintHead(channel_id);
					paint(channel_id);
					showFunctionBar(true);
				}
			}
		}
		else if ( msg == CRCInput::RC_green )
		{
			in_search = findEvents();
			timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_CHANLIST]);
		}
		else if (msg == CRCInput::RC_sat || msg == CRCInput::RC_favorites)
		{
			g_RCInput->postMsg (msg, 0);
			res = menu_return::RETURN_EXIT_ALL;
			loop = false;
		}
		else
		{
			if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all )
			{
				loop = false;
				res = menu_return::RETURN_EXIT_ALL;
			}
		}

		// blit
		frameBuffer->blit();	
	}

	hide();

	return res;
}
void AbstractWheelWidget::paintEvent(QPaintEvent* event)
{
    Q_UNUSED( event );

    // -- first calculate size and position.
    int w = width();
    int h = height();

    QPainter painter(this);
    QPalette palette = QApplication::palette();
    QPalette::ColorGroup colorGroup = isEnabled() ? QPalette::Active : QPalette::Disabled;

    // linear gradient brush
    QLinearGradient grad(0.5, 0, 0.5, 1.0);
    grad.setColorAt(0, palette.color(colorGroup, QPalette::ButtonText));
    grad.setColorAt(0.2, palette.color(colorGroup, QPalette::Button));
    grad.setColorAt(0.8, palette.color(colorGroup, QPalette::Button));
    grad.setColorAt(1.0, palette.color(colorGroup, QPalette::ButtonText));
    grad.setCoordinateMode( QGradient::ObjectBoundingMode );
    QBrush gBrush( grad );

    // paint a border and background
    painter.setPen(palette.color(colorGroup, QPalette::ButtonText));
    painter.setBrush(gBrush);
    // painter.setBrushOrigin( QPointF( 0.0, 0.0 ) );
    painter.drawRect( 0, 0, w-1, h-1 );

    // paint inner border
    painter.setPen(palette.color(colorGroup, QPalette::Button));
    painter.setBrush(Qt::NoBrush);
    painter.drawRect( 1, 1, w-3, h-3 );

    // paint the items
    painter.setClipRect( QRect( 3, 3, w-6, h-6 ) );
    painter.setPen(palette.color(colorGroup, QPalette::ButtonText));

    int iH = itemHeight();
    int iC = itemCount();
    if (iC > 0) {

        m_itemOffset = m_itemOffset % iH;

        for (int i=-h/2/iH; i<=h/2/iH+1; i++) {

            int itemNum = m_currentItem + i;
            while (itemNum < 0)
                itemNum += iC;
            while (itemNum >= iC)
                itemNum -= iC;

            paintItem(&painter, itemNum, QRect(6, h/2 +i*iH - m_itemOffset - iH/2, w-6, iH ));
        }
    }

    // draw a transparent bar over the center
    QColor highlight = palette.color(colorGroup, QPalette::Highlight);
    highlight.setAlpha(150);

    QLinearGradient grad2(0.5, 0, 0.5, 1.0);
    grad2.setColorAt(0, highlight);
    grad2.setColorAt(1.0, highlight.lighter());
    grad2.setCoordinateMode( QGradient::ObjectBoundingMode );
    QBrush gBrush2( grad2 );

    QLinearGradient grad3(0.5, 0, 0.5, 1.0);
    grad3.setColorAt(0, highlight);
    grad3.setColorAt(1.0, highlight.darker());
    grad3.setCoordinateMode( QGradient::ObjectBoundingMode );
    QBrush gBrush3( grad3 );

    painter.fillRect( QRect( 0, h/2 - iH/2, w, iH/2 ), gBrush2 );
    painter.fillRect( QRect( 0, h/2,        w, iH/2 ), gBrush3 );
}
Exemplo n.º 15
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 = -1;

	//if(Bouquets.size()==0)
	//	return res;

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

	width  = w_max (500, 0);
	height = h_max (440, 40);

	buttonHeight = 7 + std::min(16, g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight());
	theight     = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
	fheight     = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight();
	listmaxshow = (height - theight - buttonHeight)/fheight;
	height      = theight + buttonHeight + listmaxshow * fheight; // recalc height

	x = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - width) / 2;
	y = frameBuffer->getScreenY() + (frameBuffer->getScreenHeight() - height) / 2;

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

	paintHead();
	paint();

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

	unsigned int chn= 0;
	int pos= maxpos;

	unsigned long long 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 == CRCInput::RC_timeout                             ) ||
				(msg == (neutrino_msg_t)g_settings.key_channelList_cancel))
		{
			selected = oldselected;
			loop=false;
		}
		else if(msg == CRCInput::RC_red || msg == CRCInput::RC_favorites) {
			CNeutrinoApp::getInstance()->SetChannelMode(LIST_MODE_FAV);
			hide();
			return -3;
		} else if(msg == CRCInput::RC_green) {
			CNeutrinoApp::getInstance()->SetChannelMode(LIST_MODE_PROV);
			hide();
			return -3;
		} else if(msg == CRCInput::RC_yellow || msg == CRCInput::RC_sat) {
			CNeutrinoApp::getInstance()->SetChannelMode(LIST_MODE_SAT);
			hide();
			return -3;
		} else if(msg == CRCInput::RC_blue) {
			CNeutrinoApp::getInstance()->SetChannelMode(LIST_MODE_ALL);
			hide();
			return -3;
		}
		else if(Bouquets.size() == 0)
			continue; //FIXME msgs not forwarded to neutrino !!
		else if ( msg == CRCInput::RC_setup) {
			int ret = doMenu();
			if(ret) {
				res = -4;
				loop = false;
			} else
				paint();
		}
		else if ( msg == (neutrino_msg_t) g_settings.key_list_start ) {
			selected=0;
			liststart = (selected/listmaxshow)*listmaxshow;
			paint();
		}
		else if ( msg == (neutrino_msg_t) g_settings.key_list_end ) {
			selected=Bouquets.size()-1;
			liststart = (selected/listmaxshow)*listmaxshow;
			paint();
		}
		else if (msg == CRCInput::RC_up || (int) msg == g_settings.key_channelList_pageup)
		{
			int step = 0;
			int prev_selected = selected;

			step = ((int) msg == g_settings.key_channelList_pageup) ? listmaxshow : 1;  // browse or step 1
			selected -= step;
			if((prev_selected-step) < 0)            // because of uint
				selected = Bouquets.size()-1;

			paintItem(prev_selected - liststart);
			unsigned int oldliststart = liststart;
			liststart = (selected/listmaxshow)*listmaxshow;
			if(oldliststart!=liststart)
				paint();
			else
				paintItem(selected - liststart);
		}
		else if (msg == CRCInput::RC_down || (int) msg == g_settings.key_channelList_pagedown)
		{
			unsigned int step = 0;
			int prev_selected = selected;

			step = ((int) msg == g_settings.key_channelList_pagedown) ? listmaxshow : 1;  // browse or step 1
			selected += step;

			if(selected >= Bouquets.size()) {
				if (((Bouquets.size() / listmaxshow) + 1) * listmaxshow == Bouquets.size() + listmaxshow) // last page has full entries
					selected = 0;
				else
					selected = ((step == listmaxshow) && (selected < (((Bouquets.size() / listmaxshow) + 1) * listmaxshow))) ? (Bouquets.size() - 1) : 0;
			}
			paintItem(prev_selected - liststart);
			unsigned int oldliststart = liststart;
			liststart = (selected/listmaxshow)*listmaxshow;
			if(oldliststart!=liststart)
				paint();
			else
				paintItem(selected - liststart);
		}

		else if ( msg == CRCInput::RC_ok ) {
			if(!bShowChannelList || Bouquets[selected]->channelList->getSize() > 0) {
				zapOnExit = true;
				loop=false;
			}
		}
		else if (CRCInput::isNumeric(msg)) {
			if (pos == maxpos) {
				if (msg == CRCInput::RC_0) {
					chn = firstselected;
					pos = maxpos;
				} else {
					chn = CRCInput::getNumericValue(msg);
					pos = 1;
				}
			} else {
				chn = chn * 10 + CRCInput::getNumericValue(msg);
				pos++;
			}

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

			int prevselected=selected;
			selected = (chn - 1) % Bouquets.size(); // is % necessary (i.e. can firstselected be > Bouquets.size()) ?
			paintItem(prevselected - liststart);
			unsigned int oldliststart = liststart;
			liststart = (selected/listmaxshow)*listmaxshow;
			if(oldliststart!=liststart) {
				paint();
			} else {
				paintItem(selected - liststart);
			}

		} else {
			if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all ) {
				loop = false;
				res = -2;
			}
		};
	}
	hide();
	CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO);
	if(zapOnExit) {
		return (selected);
	} else {
		return (res);
	}
}
Exemplo n.º 16
0
void CListBox::paintItem(int pos)
{
    paintItem(liststart+pos, pos, (liststart+pos==selected) );
}
Exemplo n.º 17
0
int CBEChannelSelectWidget::exec(CMenuTarget * parent, const std::string & actionKey)
{
	dprintf(DEBUG_NORMAL, "CBEChannelSelectWidget::exec: actionKey:%s\n", actionKey.c_str());

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

	Channels.clear();
	
	if (mode == CZapitClient::MODE_RADIO) 
	{
		for (tallchans_iterator it = allchans.begin(); it != allchans.end(); it++)
			if (it->second.getServiceType() == ST_DIGITAL_RADIO_SOUND_SERVICE)
				Channels.push_back(&(it->second));
	} 
	else 
	{
		for (tallchans_iterator it = allchans.begin(); it != allchans.end(); it++)
			if (it->second.getServiceType() != ST_DIGITAL_RADIO_SOUND_SERVICE)
				Channels.push_back(&(it->second));
	}
	sort(Channels.begin(), Channels.end(), CmpChannelByChName());

	neutrino_msg_t      msg;
	neutrino_msg_data_t data;

	int res = menu_return::RETURN_REPAINT;
	selected = 0;

	if (parent)
		parent->hide();

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

	bool loop = true;
	modified = false;

	// add sec timer
	sec_timer_id = g_RCInput->addTimer(1*1000*1000, false);

	unsigned long long timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]);
	
	while (loop)
	{
		g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );

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

		if( msg == CRCInput::RC_ok)
		{
			setModified();
	
			if (isChannelInBouquet(selected))
				g_bouquetManager->Bouquets[bouquet]->removeService(Channels[selected]->channel_id);
			else
				addChannelToBouquet( bouquet, Channels[selected]->channel_id);

			bouquetChannels = mode == CZapitClient::MODE_TV ? &(g_bouquetManager->Bouquets[bouquet]->tvChannels) : &(g_bouquetManager->Bouquets[bouquet]->radioChannels);
	
			// paint item with marked icon
			paintItem(selected - liststart);

			// jump to next item
			g_RCInput->postMsg(CRCInput::RC_down, 0);
		}
		else if (msg == CRCInput::RC_home)
		{
			loop = false;
		}
		else if (msg == CRCInput::RC_page_up)
		{
			if ((int(selected) - int(listmaxshow)) < 0)
				selected = 0;
			else
				selected -= listmaxshow;
			liststart = (selected/listmaxshow)*listmaxshow;
			paint();
		}
		else if (msg == CRCInput::RC_page_down)
		{
			selected += listmaxshow;
			if (selected > getItemCount() - 1)
				selected = getItemCount() - 1;
			liststart = (selected/listmaxshow)*listmaxshow;
			paint();
		}
		else if (msg == CRCInput::RC_up)
		{
			int prevselected = selected;
			
			if(getItemCount())
			{
				if(selected == 0)
				{
					selected = getItemCount() - 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)
		{
			int prevselected = selected;
			
			if(getItemCount())
			{
				selected = (selected + 1)%getItemCount();
				paintItem(prevselected - liststart);

				unsigned int oldliststart = liststart;
				liststart = (selected/listmaxshow)*listmaxshow;

				if(oldliststart != liststart)
				{
					paint();
				}
				else
				{
					paintItem(selected - liststart);
				}
			}
		}
		else if ( (msg == NeutrinoMessages::EVT_TIMER) && (data == sec_timer_id) )
		{
			paintHead();
			//paint();
			//paintFoot();
		}
		else if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::cancel_all)
		{
			loop = false;
			res = menu_return::RETURN_EXIT_ALL;
		}

		frameBuffer->blit();	
	}

	hide();
	
	g_RCInput->killTimer(sec_timer_id);
	sec_timer_id = 0;
	
	return res;
}
Exemplo n.º 18
0
bool CUpnpBrowserGui::selectItem(std::string id)
{
	bool loop = true;
	bool endall = false;
	bool changed = true;
	bool rchanged = true;
	neutrino_msg_t      msg;
	neutrino_msg_data_t data;
	std::vector<UPnPEntry> *entries;
	unsigned int index, selected, dirnum;

	index = 0;
	selected = 0;
	dirnum = 0;
	entries = NULL;

	while (loop)
	{
		updateTimes();		
		
		if (rchanged)
		{
			if (entries)
				delete entries;
			
			entries = NULL;

			std::list<UPnPAttribute>attribs;
			std::list<UPnPAttribute>results;
			std::list<UPnPAttribute>::iterator i;
			std::stringstream sindex;
			std::stringstream scount;
			unsigned int returned = 0;

			bool rfound = false;
			bool nfound = false;
			bool tfound = false;

			sindex << index;
			scount << m_listmaxshow;

			attribs.push_back(UPnPAttribute("ObjectID", id));
			attribs.push_back(UPnPAttribute("BrowseFlag", "BrowseDirectChildren"));
			attribs.push_back(UPnPAttribute("Filter", "*"));
			attribs.push_back(UPnPAttribute("StartingIndex", sindex.str()));
			attribs.push_back(UPnPAttribute("RequestedCount", scount.str()));
			attribs.push_back(UPnPAttribute("SortCriteria", ""));

			results = m_devices[m_selecteddevice].SendSOAP("urn:schemas-upnp-org:service:ContentDirectory:1", "Browse", attribs);
			for (i = results.begin(); i != results.end(); i++)
			{
				if (i->first == "NumberReturned")
				{
					returned = atoi(i->second.c_str());
					nfound = true;
				}
				if (i->first == "TotalMatches")
				{
					dirnum = atoi(i->second.c_str());
					tfound = true;
				}
				if (i->first == "Result")
				{
					entries = decodeResult(i->second);
					rfound = true;
				}
			}
			if (!entries)
				return endall;
			if (!nfound || !tfound || !rfound)
			{
				delete entries;
				return endall;
			}
			if (returned != entries->size())
			{
				delete entries;
				return endall;
			}

			if (returned == 0)
			{
				delete entries;
				return endall;
			}
			rchanged=false;
			changed=true;
		}

		if (changed)
		{
			paintItem(entries, selected - index, dirnum - index, index);
			changed = false;
		}
		
		m_frameBuffer->blit();

		g_RCInput->getMsg(&msg, &data, 10); // 1 sec timeout to update play/stop state display
		neutrino_msg_t msg_repeatok = msg & ~CRCInput::RC_Repeat;

		if( msg == CRCInput::RC_timeout)
		{
			// nothing
		}
		else if(msg == CRCInput::RC_home)
		{
			loop = false;
			endall = true;
		}
		else if(msg == CRCInput::RC_left)
		{
			loop = false;
		}

		else if (msg_repeatok == CRCInput::RC_up && selected > 0)
		{
			selected--;
			if (selected < index)
			{
				index -= m_listmaxshow;
				rchanged = true;
			}
			changed = true;
		}

		else if( (msg == CRCInput::RC_yellow || (int) msg == g_settings.key_channelList_pageup) && selected > 0)
		{
			if (index > 0)
			{
				index-=m_listmaxshow;
				selected-=m_listmaxshow;
				rchanged=true;
			}
			else
				selected=0;
			changed = true;
		}
		else if (msg_repeatok == CRCInput::RC_down && selected + 1 < dirnum)
		{
			selected++;
			if (selected + 1 > index + m_listmaxshow)
			{
				index += m_listmaxshow;
				rchanged = true;
			}
			changed=true;
		}
		else if( (msg == CRCInput::RC_green || (int) msg == g_settings.key_channelList_pagedown)&& selected + 1 < dirnum)
		{
			if (index < ((dirnum - 1) / m_listmaxshow) * m_listmaxshow)
			{
				index += m_listmaxshow;
				selected += m_listmaxshow;
				if (selected + 1 >= dirnum)
					selected = dirnum - 1;
				rchanged = true;
			}
			else
				selected = dirnum - 1;
			changed = true;
		}
		else if(msg == CRCInput::RC_right)
		{
			if ((*entries)[selected - index].isdir)
			{
				endall = selectItem((*entries)[selected - index].id);
				if (endall)
					loop = false;
			}
			changed = true;
		}
		else if(msg == CRCInput::RC_ok)
		{
			if (!(*entries)[selected - index].isdir)
			{
				m_folderplay = false;
				
				int preferred = (*entries)[selected - index].preferred;
				if (preferred != -1)
				{
					std::string protocol, prot, network, mime, additional;
					protocol=(*entries)[selected - index].resources[preferred].protocol;
					splitProtocol(protocol, prot, network, mime, additional);
					
					if (mime == "audio/mpeg")
					{
						CAudioPlayerGui tmpAudioPlayerGui;
			
						CAudiofileExt audiofile((*entries)[selected - index].resources[preferred].url, CFile::EXTENSION_MP3);
						tmpAudioPlayerGui.addToPlaylist(audiofile);
						tmpAudioPlayerGui.exec(NULL, "urlplayback");
					}
					else if ((mime == "image/gif") || (mime == "image/jpeg"))
					{
						CPictureViewerGui tmpPictureViewerGui;
						CPicture pic;
						struct stat statbuf;
						
						pic.Filename = (*entries)[selected - index].resources[preferred].url;
						std::string tmp = (*entries)[selected - index].resources[preferred].url.substr((*entries)[selected - index].resources[preferred].url.rfind('/') + 1);
						pic.Name = tmp.substr(0, tmp.rfind('.'));
						pic.Type = tmp.substr(tmp.rfind('.') + 1);
						
						if(stat(pic.Filename.c_str(), &statbuf) != 0)
							printf("stat error");
						pic.Date = statbuf.st_mtime;
										
						tmpPictureViewerGui.addToPlaylist(pic);
						tmpPictureViewerGui.exec(NULL, "urlplayback");

						changed = true;
					}

					else if (mime.substr(0,6) == "video/")
					{
						m_frameBuffer->ClearFrameBuffer();
						m_frameBuffer->blit();	
						
						CFile file;
						file.Name = (*entries)[selected - index].resources[preferred].url.c_str(); //FIXME
						
						CMoviePlayerGui tmpMoviePlayerGui;
						tmpMoviePlayerGui.addToPlaylist(file);
						tmpMoviePlayerGui.exec(NULL, "urlplayback");
						
						changed = true;
					}
					
					m_playing_entry = (*entries)[selected - index];
				}

			} 
			else 
			{
				m_folderplay = true;
				m_playfolder = (*entries)[selected - index].id;
				m_playid = 0;
				playnext();
			}
			
			changed = true;
		}
		else if( msg == CRCInput::RC_red)
		{
			if(CAudioPlayer::getInstance()->getState() != CBaseDec::STOP)
				CAudioPlayer::getInstance()->stop();
			m_folderplay = false;
		}
		else if(msg == NeutrinoMessages::RECORD_START ||
			msg == NeutrinoMessages::ZAPTO ||
			msg == NeutrinoMessages::STANDBY_ON ||
			msg == NeutrinoMessages::SHUTDOWN ||
			msg == NeutrinoMessages::SLEEPTIMER)
		{
			loop = false;
			g_RCInput->postMsg(msg, data);
		}

		else if(msg == NeutrinoMessages::EVT_TIMER)
		{
			CNeutrinoApp::getInstance()->handleMsg( msg, data );
		}
		else
		{
			if( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all )
				loop = false;
			changed = true;
		}

		if (m_folderplay && (CAudioPlayer::getInstance()->getState() == CBaseDec::STOP))
			playnext();
								
		m_frameBuffer->blit();	
	}
	
	if (entries)
		delete entries;
	
	m_frameBuffer->ClearFrameBuffer();
	m_frameBuffer->blit();
	
	return endall;
}
int CBEBouquetWidget::exec(CMenuTarget* parent, const std::string&)
{
	neutrino_msg_t      msg;
	neutrino_msg_data_t data;

	int res = menu_return::RETURN_REPAINT;

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

// getting all bouquets from zapit
	Bouquets.clear();
	g_Zapit->getBouquets(Bouquets, true);
	paintHead();
	paint();
	paintFoot();

	bouquetsChanged = false;

	unsigned long long timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]);

	bool loop=true;
	while (loop)
	{
		g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );
		neutrino_msg_t msg_repeatok = msg & ~CRCInput::RC_Repeat;

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

		if (msg == CRCInput::RC_timeout || msg == g_settings.key_channelList_cancel)
		{
			if (state == beDefault)
			{
				if (bouquetsChanged)
				{
					int result = ShowLocalizedMessage(LOCALE_BOUQUETEDITOR_NAME, LOCALE_BOUQUETEDITOR_SAVECHANGES, CMessageBox::mbrYes, CMessageBox::mbAll);

					switch( result )
					{
						case CMessageBox::mbrYes :
							loop=false;
							saveChanges();
						break;
						case CMessageBox::mbrNo :
							loop=false;
							discardChanges();
						break;
						case CMessageBox::mbrCancel :
							paintHead();
							paint();
							paintFoot();
						break;
					}
				}
				else
				{
					loop = false;
				}
			}
			else if (state == beMoving)
			{
				cancelMoveBouquet();
			}
		}
		//
		// -- For more convenience: include browsing of list (paging)  (rasc, 2002-04-02)
		// -- The keys should be configurable. Problem is: red/green key, which is the
		// -- default in neutrino is used as a function key here... so use left/right
		//
		else if (msg_repeatok==CRCInput::RC_up || msg_repeatok == g_settings.key_channelList_pageup)
		{
			if (!(Bouquets.empty()))
			{
				int step = 0;
				int prev_selected = selected;

				step = (msg_repeatok == g_settings.key_channelList_pageup) ? listmaxshow : 1;  // browse or step 1
				selected -= step;
				if((prev_selected-step) < 0)		// because of uint
				{
					selected = Bouquets.size()-1;
				}

				if (state == beDefault)
				{
					paintItem(prev_selected - liststart);
					unsigned int oldliststart = liststart;
					liststart = (selected/listmaxshow)*listmaxshow;
					if(oldliststart!=liststart)
					{
						paint();
					}
					else
					{
						paintItem(selected - liststart);
					}
				}
				else if (state == beMoving)
				{
					internalMoveBouquet(prev_selected, selected);
				}
			}
		}
		else if (msg_repeatok == CRCInput::RC_down || msg_repeatok == g_settings.key_channelList_pagedown)
		{
			unsigned int step = 0;
			int prev_selected = selected;

			step = (msg_repeatok == g_settings.key_channelList_pagedown) ? listmaxshow : 1;  // browse or step 1
			selected += step;

			if(selected >= Bouquets.size())
			{
				if (((Bouquets.size() / listmaxshow) + 1) * listmaxshow == Bouquets.size() + listmaxshow) // last page has full entries
					selected = 0;
				else
					selected = ((step == listmaxshow) && (selected < (((Bouquets.size() / listmaxshow) + 1) * listmaxshow))) ? (Bouquets.size() - 1) : 0;
			}


			if (state == beDefault)
			{
				paintItem(prev_selected - liststart);
				unsigned int oldliststart = liststart;
				liststart = (selected/listmaxshow)*listmaxshow;
				if(oldliststart!=liststart)
				{
					paint();
				}
				else
				{
					paintItem(selected - liststart);
				}
			}
			else if (state == beMoving)
			{
				internalMoveBouquet(prev_selected, selected);
			}
		}
		else if(msg==CRCInput::RC_red)
		{
			if (state == beDefault)
				deleteBouquet();
		}
		else if(msg==CRCInput::RC_green)
		{
			if (state == beDefault)
				addBouquet();
		}
		else if(msg==CRCInput::RC_yellow)
		{
			if (selected < Bouquets.size()) /* Bouquets.size() might be 0 */
			{
				liststart = (selected/listmaxshow)*listmaxshow;
				if (state == beDefault)
					beginMoveBouquet();
				paintItem(selected - liststart);
			}
		}
		else if(msg==CRCInput::RC_blue)
		{
			if (selected < Bouquets.size()) /* Bouquets.size() might be 0 */
			{
				if (state == beDefault)
					switch (blueFunction)
					{
					case beRename:
						renameBouquet();
						break;
					case beHide:
						switchHideBouquet();
						break;
					case beLock:
						switchLockBouquet();
						break;
					}
			}
		}
		else if(msg==CRCInput::RC_setup)
		{
			if (state == beDefault)
			switch (blueFunction)
			{
				case beRename:
					blueFunction = beHide;
				break;
				case beHide:
					blueFunction = beLock;
				break;
				case beLock:
					blueFunction = beRename;
				break;
			}
			paintFoot();
		}
		else if(msg==CRCInput::RC_ok)
		{
			if (state == beDefault)
			{
				if (selected < Bouquets.size()) /* Bouquets.size() might be 0 */
				{
					CBEChannelWidget* channelWidget = new CBEChannelWidget(Bouquets[selected].name, selected);
					channelWidget->exec( this, "");
					if (channelWidget->hasChanged())
						bouquetsChanged = true;
					delete channelWidget;
					paintHead();
					paint();
					paintFoot();
				}
			}
			else if (state == beMoving)
			{
				finishMoveBouquet();
			}
		}
		else if( CRCInput::isNumeric(msg) )
		{
			if (state == beDefault)
			{
				//kein pushback - wenn man versehentlich wo draufkommt is die edit-arbeit umsonst
				//selected = oldselected;
				//g_RCInput->postMsg( msg, data );
				//loop=false;
			}
			else if (state == beMoving)
			{
				cancelMoveBouquet();
			}
		}
		else
		{
			CNeutrinoApp::getInstance()->handleMsg( msg, data );
			// kein canceling...
		}
	}
	hide();
	return res;
}
Exemplo n.º 20
0
bool CUpnpBrowserGui::selectItem(std::string id)
{
	bool loop = true;
	bool endall = false;
	bool changed = true;
	bool rchanged = true;
	neutrino_msg_t      msg;
	neutrino_msg_data_t data;
	std::vector<UPnPEntry> *entries;
	unsigned int index, selected, dirnum;

	index=0;
	selected=0;
	dirnum=0;
	entries=NULL;

	while (loop)
	{
		updateTimes();
		if (rchanged)
		{
			if (entries)
				delete entries;
			entries=NULL;

			std::list<UPnPAttribute>attribs;
			std::list<UPnPAttribute>results;
			std::list<UPnPAttribute>::iterator i;
			std::stringstream sindex;
			std::stringstream scount;
			unsigned int returned = 0;

			bool rfound = false;
			bool nfound = false;
			bool tfound = false;

			sindex << index;
			scount << m_listmaxshow;

			attribs.push_back(UPnPAttribute("ObjectID", id));
			attribs.push_back(UPnPAttribute("BrowseFlag", "BrowseDirectChildren"));
			attribs.push_back(UPnPAttribute("Filter", "*"));
			attribs.push_back(UPnPAttribute("StartingIndex", sindex.str()));
			attribs.push_back(UPnPAttribute("RequestedCount", scount.str()));
			attribs.push_back(UPnPAttribute("SortCriteria", ""));
#if 0
			try
			{
				results=m_devices[m_selecteddevice].SendSOAP("urn:schemas-upnp-org:service:ContentDirectory:1", "Browse", attribs);
			}
			catch (std::runtime_error error)
			{
				ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, error.what(), CMessageBox::mbrBack, CMessageBox::mbBack, "info.raw");
				if (entries)
					delete entries;
				return endall;
			}
#endif
			results=m_devices[m_selecteddevice].SendSOAP("urn:schemas-upnp-org:service:ContentDirectory:1", "Browse", attribs);
			for (i=results.begin(); i!=results.end(); i++)
			{
				if (i->first=="NumberReturned")
				{
					returned=atoi(i->second.c_str());
					nfound=true;
				}
				if (i->first=="TotalMatches")
				{
					dirnum=atoi(i->second.c_str());
					tfound=true;
				}
				if (i->first=="Result")
				{
					entries=decodeResult(i->second);
					rfound=true;
				}
			}
			if (!entries)
				return endall;
			if (!nfound || !tfound || !rfound)
			{
				delete entries;
				return endall;
			}
			if (returned != entries->size())
			{
				delete entries;
				return endall;
			}

			if (returned == 0)
			{
				delete entries;
				return endall;
			}
			rchanged=false;
			changed=true;
		}

		if (changed)
		{
			paintItem(entries, selected - index, dirnum - index, index);
			changed=false;
		}

		g_RCInput->getMsg(&msg, &data, 10); // 1 sec timeout to update play/stop state display
		neutrino_msg_t msg_repeatok = msg & ~CRCInput::RC_Repeat;

		if( msg == CRCInput::RC_timeout)
		{
			// nothing
		}
		else if(msg == CRCInput::RC_home)
		{
			loop=false;
			endall=true;
		}
		else if(msg == CRCInput::RC_left)
		{
			loop=false;
		}

		else if (msg_repeatok == CRCInput::RC_up && selected > 0)
		{
			selected--;
			if (selected < index)
			{
				index-=m_listmaxshow;
				rchanged=true;
			}
			changed=true;
		}

		else if(msg == CRCInput::RC_green && selected > 0)
		{
			if (index > 0)
			{
				index-=m_listmaxshow;
				selected-=m_listmaxshow;
				rchanged=true;
			}
			else
				selected=0;
			changed=true;
		}
		else if (msg_repeatok == CRCInput::RC_down && selected + 1 < dirnum)
		{
			selected++;
			if (selected + 1 > index + m_listmaxshow)
			{
				index+=m_listmaxshow;
				rchanged=true;
			}
			changed=true;
		}
		else if(msg == CRCInput::RC_red && selected + 1 < dirnum)
		{
			if (index < ((dirnum - 1) / m_listmaxshow) * m_listmaxshow)
			{
				index+=m_listmaxshow;
				selected+=m_listmaxshow;
				if (selected + 1 >= dirnum)
					selected=dirnum - 1;
				rchanged=true;
			}
			else
				selected=dirnum - 1;
			changed=true;
		}
		else if(msg == CRCInput::RC_right)
		{
			if ((*entries)[selected - index].isdir)
			{
				endall=selectItem((*entries)[selected - index].id);
				if (endall)
					loop=false;
			}
			changed=true;
		}
		else if(msg == CRCInput::RC_ok)
		{
			if (!(*entries)[selected - index].isdir)
			{
				m_folderplay = false;
				int preferred=(*entries)[selected - index].preferred;
				if (preferred != -1)
				{
					std::string protocol, prot, network, mime, additional;
					protocol=(*entries)[selected - index].resources[preferred].protocol;
					splitProtocol(protocol, prot, network, mime, additional);
					if (mime == "audio/mpeg")
					{
						CAudiofile mp3((*entries)[selected - index].resources[preferred].url, CFile::FILE_MP3);
						CAudioPlayer::getInstance()->play(&mp3, g_settings.audioplayer_highprio == 1);
					}
					else if (mime == "audio/x-vorbis+ogg")
					{
						CAudiofile mp3((*entries)[selected - index].resources[preferred].url, CFile::FILE_OGG);
						CAudioPlayer::getInstance()->play(&mp3, g_settings.audioplayer_highprio == 1);
					}
					m_playing_entry = (*entries)[selected - index];
#if 0
// #ifdef ENABLE_PICTUREVIEWER
					else if ((mime == "image/gif") || (mime == "image/jpeg"))
					{
						CPictureViewer *viewer = new CPictureViewer();
						bool loop=true;
						viewer->SetScaling((CPictureViewer::ScalingMode)g_settings.picviewer_scaling);
						viewer->SetVisible(g_settings.screen_StartX, g_settings.screen_EndX, g_settings.screen_StartY, g_settings.screen_EndY);

						if(g_settings.video_Format==1)
							viewer->SetAspectRatio(16.0/9);
						else if(g_settings.video_Format==0)
						{
							CControldClient cdc;
							cdc.setVideoFormat(CControldClient::VIDEOFORMAT_4_3);
							viewer->SetAspectRatio(4.0/3);
						}
						else
							viewer->SetAspectRatio(4.0/3);

						m_frameBuffer->setMode(720, 576, 16);
						m_frameBuffer->setTransparency(0);
						viewer->ShowImage((*entries)[selected - index].resources[preferred].url, true);
						while (loop)
						{
							g_RCInput->getMsg(&msg, &data, 10); // 1 sec timeout to update play/stop state display

							if( msg == CRCInput::RC_home)
								loop=false;
						}
						m_frameBuffer->setMode(720, 576, 8 * sizeof(fb_pixel_t));
						m_frameBuffer->setBlendLevel(g_settings.gtx_alpha1, g_settings.gtx_alpha2);
						m_frameBuffer->ClearFrameBuffer();
						delete viewer;
					}
// #endif
#endif
				}

			} 
Exemplo n.º 21
0
int CWebTV::Show()
{
	int res = -1;
	
	neutrino_msg_t      msg;
	neutrino_msg_data_t data;
	
	if(channels.empty())
		loadChannels();
	
	// display channame in vfd	
	CVFD::getInstance()->setMode(CVFD::MODE_IPTV);
	
	// windows size
	width  = w_max ( (frameBuffer->getScreenWidth() / 20 * 17), (frameBuffer->getScreenWidth() / 20 ));
	height = h_max ( (frameBuffer->getScreenHeight() / 20 * 16), (frameBuffer->getScreenHeight() / 20));
	
	// head height
	frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_HELP, &icon_hd_w, &icon_hd_h);
	theight = std::max(icon_hd_h, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight()) + 6;
	
	// buttonheight
	frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_RED, &icon_bf_w, &icon_bf_h);
	buttonHeight = std::max(icon_bf_h, g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight()) + 6;

	// listbox/items
	iheight = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight() + 2;
	listmaxshow = (height - theight - buttonHeight)/iheight;
	height = theight + buttonHeight + listmaxshow * iheight;
	
	// info height
	info_height = 5 + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight() + 5 + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getHeight() + 5;
	
	// x/y
	x = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - (width + ConnectLineBox_Width)) / 2 + ConnectLineBox_Width;
	y = frameBuffer->getScreenY() + (frameBuffer->getScreenHeight() - (height + info_height)) / 2;
	
showList:	
	
	// head
	paintHead();
	
	// foot
	paintFoot();
		
	// paint all
	paint();
		
	frameBuffer->blit();

	oldselected = selected;
	int zapOnExit = false;

	// loop control
	unsigned long long 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 == CRCInput::RC_timeout ) || ( msg == (neutrino_msg_t)g_settings.key_channelList_cancel) ) 
		{
			selected = oldselected;
			
			loop = false;
			res = -1;
		}
		else if ( msg == CRCInput::RC_up || (int) msg == g_settings.key_channelList_pageup || msg == CRCInput::RC_yellow)
                {
                        int step = 0;
                        int prev_selected = selected;

			step =  ((int) msg == g_settings.key_channelList_pageup || (int) msg == CRCInput::RC_yellow) ? listmaxshow : 1;  // browse or step 1
                        selected -= step;
                        if((prev_selected-step) < 0)            // because of uint
                                selected = channels.size() - 1;

                        paintItem(prev_selected - liststart);
			
                        unsigned int oldliststart = liststart;
                        liststart = (selected/listmaxshow)*listmaxshow;
                        if(oldliststart!=liststart)
                                paint();
                        else
                                paintItem(selected - liststart);
                }
                else if ( msg == CRCInput::RC_down || (int) msg == g_settings.key_channelList_pagedown || msg == CRCInput::RC_green)
                {
                        unsigned int step = 0;
                        int prev_selected = selected;

			step =  ((int) msg == g_settings.key_channelList_pagedown || (int)msg == CRCInput::RC_green) ? listmaxshow : 1;  // browse or step 1
                        selected += step;

                        if(selected >= channels.size()) 
			{
                                if (((channels.size() / listmaxshow) + 1) * listmaxshow == channels.size() + listmaxshow) 	// last page has full entries
                                        selected = 0;
                                else
                                        selected = ((step == listmaxshow) && (selected < (((channels.size() / listmaxshow)+1) * listmaxshow))) ? (channels.size() - 1) : 0;
			}

                        paintItem(prev_selected - liststart);
			
                        unsigned int oldliststart = liststart;
                        liststart = (selected/listmaxshow)*listmaxshow;
                        if(oldliststart != liststart)
                                paint();
                        else
                                paintItem(selected - liststart);
                }
                else if ( msg == CRCInput::RC_ok || msg == (neutrino_msg_t) g_settings.mpkey_play) 
		{
			zapOnExit = true;
			loop = false;
		}
		else if (msg == CRCInput::RC_info) 
		{
			showFileInfoWebTV(selected);
			res = -1;
			
			goto showList;
		}
		else if (msg == CRCInput::RC_red) 
		{
			addUserBouquet();
			res = -1;
			
			goto showList;
		}
		else if(msg == CRCInput::RC_blue || msg == CRCInput::RC_favorites)
		{
			showUserBouquet();
			res = -1;
			
			goto showList;
		}
		else if( msg == (neutrino_msg_t) g_settings.key_timeshift) // pause playing
		{
			if(playstate == PAUSE)
				continuePlayBack();
			else if(playstate == PLAY)
				pausePlayBack();
			
			res = -1;
			loop = false;
		}
		else if( msg == CRCInput::RC_stop) // pause playing
		{
			if(playstate == PLAY || playstate == PAUSE)
				stopPlayBack();
			
			res = -1;
			loop = false;
		}
		else if(msg == (neutrino_msg_t)g_settings.mpkey_play)
		{
			if(playstate == PAUSE)
				continuePlayBack();
			
			res = -1;
			loop = false;
		}
		else
		{
			if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all ) 
			{
				loop = false;
				res = - 1;
			}
		}
			
		frameBuffer->blit();	
	}
	
	hide();
	
	//CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO);
	
	if(zapOnExit)
		res = selected;

	printf("CWebTV::show res %d\n", res);
			
	return (res);
}