//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;
}
const CBookmark * CBookmarkManager::getBookmark(CMenuTarget* parent)
{
	if(parent)
	{
		parent->hide();
	}
	
	frameBuffer = CFrameBuffer::getInstance();
	visible = false;
	selected = 0;

	width = w_max (720, 30);

	int iconw = 0, iconh = 0;
	frameBuffer->getIconSize(NEUTRINO_ICON_BOOKMARKMANAGER, &ticonwidth, &ticonheight);
	theight = std::max(ticonheight, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight());
	fheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
	frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_OKAY, &iconw, &iconh);
	footHeight = std::max(iconh, g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight());
	liststart = 0;
	
	height = h_max(576, 50);
	listmaxshow = (height-theight-footHeight-0)/(fheight*2);
	height = theight+footHeight+0+listmaxshow*fheight*2;	// recalc height
	if(bookmarks.size() < listmaxshow)
	{
		listmaxshow=bookmarks.size();
		height = theight+footHeight+0+listmaxshow*fheight*2;	// recalc height
	}
	if (!bookmarks.empty() && selected==bookmarks.size())
	{
		selected=bookmarks.size()-1;
		liststart = (selected/listmaxshow)*listmaxshow;
	}
	x = getScreenStartX (width);
	y = getScreenStartY (height);


	int res = -1;

	unsigned long long timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
	neutrino_msg_t msg;
	neutrino_msg_data_t data;

	bool loop=true;
	bool update=true;
	while(loop)
	{
		if(update)
		{
			hide();
			update=false;
			paint();
		}
		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_MENU]);

		if( ( msg == CRCInput::RC_timeout ) ||
			 ( msg == CRCInput::RC_home) )
		{ //Exit after timeout or cancel key
			res = -1;
			loop=false;
		}
		else if ((msg_repeatok == CRCInput::RC_up || msg_repeatok == g_settings.key_channelList_pageup) && !(bookmarks.empty()))
		{
			int step = (msg_repeatok == g_settings.key_channelList_pageup) ? listmaxshow : 1;  // browse or step 1
			int new_selected = selected - step;
			if (new_selected < 0)
				new_selected = bookmarks.size() - 1;
			updateSelection(new_selected);
		}
		else if ((msg_repeatok == CRCInput::RC_down || msg_repeatok == g_settings.key_channelList_pagedown) && !(bookmarks.empty()))
		{
			unsigned int step = (msg_repeatok == g_settings.key_channelList_pagedown) ? listmaxshow : 1;  // browse or step 1
			unsigned int new_selected = selected + step;
			unsigned int b_size = bookmarks.size();
			if (new_selected >= b_size)
			{
				if ((b_size / listmaxshow + 1) * listmaxshow == b_size + listmaxshow) // last page has full entries
					new_selected = 0;
				else
					new_selected = ((step == listmaxshow) && (new_selected < ((b_size / listmaxshow + 1) * listmaxshow))) ? (b_size - 1) : 0;
			}
			updateSelection(new_selected);
		}
		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 = -1;
			}
		}
	}
	hide();

	if ((res >=0) && (((unsigned int)res) < bookmarks.size()))
		return &bookmarks[res];
	else
		return NULL;
}