1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#include <cdk_int.h>
/*
* $Author: tom $
* $Date: 2003/11/27 22:13:46 $
* $Revision: 1.1 $
*/
/*
* This returns a selected value in a list.
*/
int getListIndex (CDKSCREEN *screen, char *title, char **list, int listSize, boolean numbers)
{
CDKSCROLL *scrollp = 0;
int selected = -1;
int height = 10;
int width = -1;
int len = 0;
int x;
/* Determine the height of the list. */
if (listSize < 10)
{
height = listSize + (title == 0 ? 2 : 3);
}
/* Determine the width of the list. */
for (x=0; x < listSize; x++)
{
int temp = strlen (list[x]) + 10;
width = MAXIMUM (width, temp);
}
if (title != 0)
{
len = strlen (title);
}
width = MAXIMUM (width, len);
width += 5;
/* Create the scrolling list. */
scrollp = newCDKScroll (screen, CENTER, CENTER, RIGHT,
height, width, title,
list, listSize, numbers,
A_REVERSE, TRUE, FALSE);
/* Check if we made the list. */
if (scrollp == 0)
{
refreshCDKScreen (screen);
return -1;
}
/* Let the user play. */
selected = activateCDKScroll (scrollp, 0);
/* Check how they exited. */
if (scrollp->exitType != vNORMAL)
{
selected = -1;
}
/* Clean up. */
destroyCDKScroll (scrollp);
refreshCDKScreen (screen);
return selected;
}
|