コード例 #1
0
ファイル: button_list.cpp プロジェクト: egeldenhuys/prothesis
void button_list::update()
{
    // Loop through each item in UserData
    for (uint i = 0; i < sourceList->size(); i++)
    {
        // If the item does not exist in the button list create it
        if (! exists(sourceList->at(i)))
        {
            add_button(QString::fromStdString(sourceList->at(i)), "");
        }
    }

    bool found = false;
    uint loopsDone = 0;
    uint initialSize = cButtonList_.size();

    // Loop through every button
    for (uint i = 0; loopsDone < initialSize; i++)
    {
        // We do this because the button has been popped from the array
        // and we need to account for this

        if ((found == false) && (loopsDone >= 1))
            i = i -1;

        found = false;

         QString wat;

        // If the button does not exist in the source list, remove the button
        for (uint j = 0; j < sourceList->size(); j++)
        {

            if (QString::fromStdString(sourceList->at(j)) == cButtonList_.at(i)->text())
            {
                found = true;
                break;
            }
        }

        if (found == false)
            remove_button(i);

        loopsDone++;

    }

}
コード例 #2
0
ファイル: CODEGEN3.C プロジェクト: krattai/flosh
int options(void)
{
	int key,
		buton = 1,
		h,
		v,
		end=0;
	int poly[10]={100,100,300,100,300,300,100,300,100,100};
/*		on=0; */

	optionplates();
	defbutton(220,450,"Previous");

	/* while exit not requested */
	do {
		key = checkinput();
		h = rat.horiz;
		v = rat.verti;

		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(0,h,v)))
		{
		/* This option should toggle printing of file on and off.
			If on, file will be printed when the program that was created
			is saved.
		*/
			ratoff();
			setcolor(CCSLWHITE);
			setfillstyle(SOLID_FILL,CCSLLTBLUE);
			fillpoly(5,poly);
			raton();
			getch();
			ratoff();
			setcolor(CCSLDKBLUE);
			setfillstyle(SOLID_FILL,CCSLDKBLUE);
			fillpoly(5,poly);
			raton();
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(1,h,v)))
		{
		/* new */
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(2,h,v)))
		{
		/* load */
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(3,h,v)))
		{
		/* save */
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(4,h,v)))
		{
		/* write */
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(5,h,v)))
		{
		/* save */
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(6,h,v)))
		{
		/* change type from graphics (default) to text and vice versa */
			ratoff();
			setcolor(CCSLWHITE);
			setfillstyle(SOLID_FILL,CCSLLTBLUE);
			fillpoly(5,poly);
			raton();
			getch();
			ratoff();
			setcolor(CCSLDKBLUE);
			setfillstyle(SOLID_FILL,CCSLDKBLUE);
			fillpoly(5,poly);
			raton();
		}
		if((rat.buttons == RBUTTON && key == HELD) && (checkhit(1,h,v)))
		{
			if(buton)
			{
				buttonoff(1);
				buton = 0;
			}
			else
			{
				buttonon(1);
				buton = 1;
			}
		}
		if((rat.buttons == CBUTTON && key == RELEASE) && (checkhit(1,h,v)))
		{
			if(buton)
			{
				buttonoff(1);
				buton = 0;
			}
			else
			{
				buttonon(1);
				buton = 1;
			}
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (checkhit(2,h,v)))
		{
			key = ESC;
			end = 1;
		}
	} while(!(((rat.buttons == LBUTTON && key == PRESS) || (key == ENTER))
			&& checkhit(0,h,v) || key == ESC));

	clearplates();
	remove_button(2);

	if(end)
		return(0);
	else
		return(1);
}