Anda di halaman 1dari 3

/*******************************************************************************

Function : checkList
Description : Visualiza un checklist
Input : fila_in: coordenada en X
col_in : coordenada en Y
Array : vector de la estructura que contiene los
datos a visuzlizar en el checklist
items : total de items del checklist
itemsY: items a visualizar en pantalla
multi : 1-multiple selección
0-selección sencilla
Return : Nothing
*******************************************************************************/
BYTE checkList(BYTE fila_in, BYTE col_in,checkListData *Array, BYTE items, BYTE
itemsY,BOOLEAN multi)
{
BYTE i,posy,tecla,tem,scroll,next;
ListData last;
posy = 0;
scroll = 0;
tem = fila_in;
next = fila_in;
last.num = 0;
last.x = col_in;
last.y = fila_in;
// clrscr();
for (i=0;i<itemsY;i++)
{
if (Array[i].selection)
boton_radio(1,col_in,tem);
else
boton_radio(0,col_in,tem);
gotoxy(tem,col_in+1);
printf("%s",Array[i].name);
tem ++;
}
scroll = fila_in;
os_disp_putc( MW_LREV_ON );
gotoxy(next,col_in+1);
printf("%s",Array[posy].name);
os_disp_putc( MW_LREV_OFF );
tem = 1;
do
{
if (tem > itemsY)
{
scroll = fila_in;
if (last.y > fila_in)
last.y --;
for (i=posy-(itemsY-1);i<=posy;i++)
{
if (Array[i].selection)
boton_radio(1,col_in,scroll);
else
boton_radio(0,col_in,scroll);
gotoxy(scroll,col_in+1);
printf(" ");
gotoxy(scroll,col_in+1);
printf("%s",Array[i].name);
scroll++;
}
tem = itemsY;
scroll = fila_in+itemsY-1;
next = fila_in+itemsY-1;
os_disp_putc( MW_LREV_ON );
gotoxy(scroll,col_in+1);
printf("%s",Array[posy].name);
os_disp_putc( MW_LREV_OFF );
}
if (tem < 1)
{
scroll = fila_in;
if (!multi)
if (last.y < (fila_in+itemsY)-1)
last.y ++;
for (i=posy;i<=posy+(itemsY-1);i++)
{
if (Array[i].selection)
boton_radio(1,col_in,scroll);
else
boton_radio(0,col_in,scroll);
gotoxy(scroll,col_in+1);
printf(" ");
gotoxy(scroll,col_in+1);
os_disp_putc( MW_LREV_OFF );
printf("%s",Array[i].name);
scroll++;
}
tem = 1;
scroll = fila_in;
next = fila_in;
os_disp_putc( MW_LREV_ON );
gotoxy(scroll,col_in+1);
printf("%s",Array[posy].name);
os_disp_putc( MW_LREV_OFF );
}
if (next<fila_in)
next++;
if (next>fila_in+itemsY-1)
next--;
os_disp_putc( MW_LREV_ON );
gotoxy(next,col_in+1);
printf("%s",Array[posy].name);
os_disp_putc( MW_LREV_OFF );
tecla = (BYTE)getch(0);
gotoxy(scroll,col_in+1);
printf("%s",Array[posy].name);
switch(tecla)
{
case KEY_F3:
if (posy != 0)
{
posy--;
tem--;
scroll--;
}
next--;
break;
case KEY_F4:
if (posy < items-1)
{
posy++;
tem++;
scroll++;
}
else
{
posy = items-1;
}
next++;
break;
case KEY_CLR:
if (Array[posy].selection == TRUE)
{
Array[posy].selection = FALSE;
selectedItems--;
}
else
{
if (!multi)
{
Array[last.num].selection = FALSE;
boton_radio(FALSE,last.x,last.y);
last.num = posy;
last.y = scroll;
// printf("\fafaasdfasd");getch(0);
}
Array[posy].selection = TRUE;
selectedItems++;
}
boton_radio(Array[posy].selection,col_in,scroll);
break;
}
}while (tecla != KEY_CANCL && tecla != KEY_ENTER);
return 1;
}

Anda mungkin juga menyukai