Exemplo n.º 1
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;
}
Exemplo n.º 2
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.º 3
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 itemCount = getItemCount();
			if (itemCount > 0)
			{
				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 = itemCount - 1;
				updateSelection(new_selected);
			}
		}
		else if (msg_repeatok == CRCInput::RC_down || msg_repeatok == g_settings.key_channelList_pagedown)
		{
			unsigned int itemCount = getItemCount();
			if (itemCount > 0)
			{
				unsigned int step = (msg_repeatok == g_settings.key_channelList_pagedown) ? listmaxshow : 1;  // browse or step 1
				unsigned int new_selected = selected + step;
				if (new_selected >= itemCount)
				{
					if ((itemCount / listmaxshow + 1) * listmaxshow == itemCount + listmaxshow) // last page has full entries
						new_selected = 0;
					else
						new_selected = ((step == listmaxshow) && (new_selected < ((itemCount / listmaxshow + 1) * listmaxshow))) ? (itemCount - 1) : 0;
				}
				updateSelection(new_selected);
			}
		}
		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;
}