Example #1
0
int horizmenu(int itemnum,int curitem,int y,...)  /* Dots are start of each item */
  {
  int selected=FALSE;
  int mx,my,mbut;
  int inkey;
  char upkey,lowkey;
  int *lens;
  register int l;        /* Loop variable */
  #ifdef USEJOYSTICK
  int joypos=0,joybut=0;
  #endif  

  lens=&y;
  lens++;    /* Lens now points to the  x coord of the first item */

  if (curitem==0) curitem++;
  curitem--;

  moucur(0);
  setmoupos( (lens[curitem]+lens[curitem+1])/2,y);
  moustats(&mx,&my,&butstat);
  drawcursor(lens[curitem],y,lens[curitem+1]-1,CURATTR);

  do
    {
    if (bioskey(1))
      {
      inkey = bioskey (0);
      lowkey = inkey&255;
      if (lowkey==0)
        {
        upkey = inkey>>8;
        switch (upkey)
          {
          case 77:   /* right arrow */
            erasecursor();
            curitem++; if (curitem>=itemnum) curitem=0;
            setmoupos(lens[curitem+1]-1,y);
            drawcursor(lens[curitem],y,lens[curitem+1]-1,CURATTR);
            break;

          case 75:   /* left arrow */
            erasecursor();
            curitem--; if (curitem<0) curitem=itemnum-1;
            setmoupos(lens[curitem]+1,y);
            drawcursor(lens[curitem],y,lens[curitem+1]-1,CURATTR);
            break;

          case 72:   /* up arrow */
            lowkey = 27;  /* escape is the same as up arrow */
            break;

          case 80:   /* down arrow */
            lowkey = 13;  /* return is the same as dn arrow */
            break;
          }
        }
      if ((lowkey==13)||(lowkey==27)) selected = TRUE;
      }
Example #2
0
void restore_data(int n)
{
	stamp_structure s;
	fflockstruct1 *fs1;
	fflockstruct2 *fs2;
	fflockstruct3 *fs3;


	if (!stamp_data[n])
		return;

	s = *stamp_data[n];	/* copy it, we might loose it */
	switch (s.dimension)
	{
	case LOGISTIC:
		if (!memok(sizeof(fflockstruct1)) ||
		    (fs1 = malloc(sizeof(fflockstruct1))) == NULL)
		{
			ErrorBox("Not enough memory to restore stamp.");
			return;
		}
		memcpy(fs1, s.s.lo.fflock1ptr, sizeof(fflockstruct1));
		s.s.lo.fflock1ptr = fs1;
		break;
	case HENON:
      if (!memok(sizeof(fflockstruct2)) ||
		    (fs2 = malloc(sizeof(fflockstruct2))) == NULL)
		{
			ErrorBox("Not enough memory to restore stamp.");
			return;
		}
		memcpy(fs2, s.s.h.fflock2ptr, sizeof(fflockstruct2));
		s.s.h.fflock2ptr = fs2;
		break;
	case YORKE:
#ifdef OLDWAY
		if (!memok(sizeof(fflockstruct2)) ||
		    (fs2 = malloc(sizeof(fflockstruct2))) == NULL)
		{
			ErrorBox("Not enough memory to restore stamp.");
			return;
		}
		memcpy(fs2, s.s.y.fflock2ptr, sizeof(fflockstruct2));
		s.s.y.fflock2ptr = fs2;
#endif
		break;
	case LORENZ:
		if (!memok(sizeof(fflockstruct3)) ||
		    (fs3 = malloc(sizeof(fflockstruct3))) == NULL)
		{
			ErrorBox("Not enough memory to restore stamp.");
			return;
		}
		memcpy(fs3, s.s.lz.fflock3ptr, sizeof(fflockstruct3));
		s.s.lz.fflock3ptr = fs3;
		break;
	}


	erasecursor();
	if (Stamping)
	{
		preserve_data();
		slide_stamps();
	}
	/* the restorer will free the proper flockptr */
	(*restorers[s.dimension - 1]) (&s);
}