コード例 #1
0
ファイル: button.c プロジェクト: Chaduke/bah.mod
/*
 * This injects a single character into the widget.
 */
static int _injectCDKButton (CDKOBJS *object, chtype input)
{
   CDKBUTTON *widget = (CDKBUTTON *)object;
   int ret = unknownInt;
   bool complete = FALSE;

   setExitType (widget, 0);

   /* Check a predefined binding. */
   if (checkCDKObjectBind (vBUTTON, widget, input) != 0)
   {
      checkEarlyExit (widget);
      complete = TRUE;
   }
   else
   {
      switch (input)
      {
      case KEY_ESC:
	 setExitType (widget, input);
	 complete = TRUE;
	 break;

      case KEY_ERROR:
	 setExitType (widget, input);
	 complete = TRUE;
	 break;

      case KEY_ENTER:
      case SPACE:
	 if (widget->callback)
	    widget->callback (widget);
	 setExitType (widget, KEY_ENTER);
	 ret = 0;
	 complete = TRUE;
	 break;

      case CDK_REFRESH:
	 eraseCDKScreen (ScreenOf (widget));
	 refreshCDKScreen (ScreenOf (widget));
	 break;

      default:
	 BEEP ();
	 break;
      }
   }

   if (!complete)
   {
      setExitType (widget, 0);
   }

   ResultOf (widget).valueInt = ret;
   return (ret != unknownInt);
}
コード例 #2
0
ファイル: alphalist.c プロジェクト: iamjamestl/school
/*
 * This injects a single character into the alphalist.
 */
static int _injectCDKAlphalist (CDKOBJS *object, chtype input)
{
   CDKALPHALIST *alphalist = (CDKALPHALIST *)object;
   char *ret = unknownString;

   /* Draw the widget. */
   drawCDKAlphalist (alphalist, ObjOf (alphalist)->box);

   /* Inject a character into the widget. */
   ret = injectCDKEntry (alphalist->entryField, input);

   /* Copy the exit type from the entry field. */
   copyExitType (alphalist, alphalist->entryField);

   /* Determine the exit status. */
   if (alphalist->exitType == vEARLY_EXIT)
      ret = unknownString;

   ResultOf (alphalist).valueString = ret;
   return (ret != unknownString);
}
コード例 #3
0
ファイル: scroll.c プロジェクト: Chaduke/bah.mod
/*
 * This injects a single character into the widget.
 */
static int _injectCDKScroll (CDKOBJS *object, chtype input)
{
   CDKSCROLL *widget = (CDKSCROLL *)object;
   int ppReturn = 1;
   int ret = unknownInt;
   bool complete = FALSE;

   /* Set the exit type for the widget. */
   setExitType (widget, 0);

   /* Draw the scrolling list */
   drawCDKScrollList (widget, ObjOf (widget)->box);

   /* Check if there is a pre-process function to be called. */
   if (PreProcessFuncOf (widget) != 0)
   {
      /* Call the pre-process function. */
      ppReturn = PreProcessFuncOf (widget) (vSCROLL,
					    widget,
					    PreProcessDataOf (widget),
					    input);
   }

   /* Should we continue? */
   if (ppReturn != 0)
   {
      /* Check for a predefined key binding. */
      if (checkCDKObjectBind (vSCROLL, widget, input) != 0)
      {
	 checkEarlyExit (widget);
	 complete = TRUE;
      }
      else
      {
	 switch (input)
	 {
	 case KEY_UP:
	    scroller_KEY_UP (widget);
	    break;

	 case KEY_DOWN:
	    scroller_KEY_DOWN (widget);
	    break;

	 case KEY_RIGHT:
	    scroller_KEY_RIGHT (widget);
	    break;

	 case KEY_LEFT:
	    scroller_KEY_LEFT (widget);
	    break;

	 case KEY_PPAGE:
	    scroller_KEY_PPAGE (widget);
	    break;

	 case KEY_NPAGE:
	    scroller_KEY_NPAGE (widget);
	    break;

	 case KEY_HOME:
	    scroller_KEY_HOME (widget);
	    break;

	 case KEY_END:
	    scroller_KEY_END (widget);
	    break;

	 case '$':
	    widget->leftChar = widget->maxLeftChar;
	    break;

	 case '|':
	    widget->leftChar = 0;
	    break;

	 case KEY_ESC:
	    setExitType (widget, input);
	    complete = TRUE;
	    break;

	 case KEY_ERROR:
	    setExitType (widget, input);
	    complete = TRUE;
	    break;

	 case CDK_REFRESH:
	    eraseCDKScreen (ScreenOf (widget));
	    refreshCDKScreen (ScreenOf (widget));
	    break;

	 case KEY_TAB:
	 case KEY_ENTER:
	    setExitType (widget, input);
	    ret = widget->currentItem;
	    complete = TRUE;
	    break;

	 default:
	    break;
	 }
      }

      /* Should we call a post-process? */
      if (!complete && (PostProcessFuncOf (widget) != 0))
      {
	 PostProcessFuncOf (widget) (vSCROLL,
				     widget,
				     PostProcessDataOf (widget),
				     input);
      }
   }

   if (!complete)
   {
      drawCDKScrollList (widget, ObjOf (widget)->box);
      setExitType (widget, 0);
   }

   fixCursorPosition (widget);
   ResultOf (widget).valueInt = ret;
   return (ret != unknownInt);
}
コード例 #4
0
ファイル: uscale.c プロジェクト: Chaduke/bah.mod
/*
 * This function injects a single character into the widget.
 */
static int _injectCDKUScale (CDKOBJS *object, chtype input)
{
    CDKUSCALE *widget = (CDKUSCALE *)object;
    int ppReturn = 1;
    unsigned ret = unknownUnsigned;
    bool complete = FALSE;

    /* Set the exit type. */
    setExitType(widget, 0);

    /* Draw the field. */
    drawCDKUScaleField (widget);

    /* Check if there is a pre-process function to be called. */
    if (PreProcessFuncOf(widget) != 0)
    {
        /* Call the pre-process function. */
        ppReturn = PreProcessFuncOf(widget) (vUSCALE, widget, PreProcessDataOf(widget), input);
    }

    /* Should we continue? */
    if (ppReturn != 0)
    {
        /* Check for a key binding. */
        if (checkCDKObjectBind(vUSCALE, widget, input) != 0)
        {
            checkEarlyExit(widget);
            complete = TRUE;
        }
        else
        {
            switch (input)
            {
            case KEY_LEFT :
                setEditPosition(widget, widget->fieldEdit + 1);
                break;

            case KEY_RIGHT :
                setEditPosition(widget, widget->fieldEdit - 1);
                break;

            case KEY_DOWN :
                Decrement(widget->current, widget->inc);
                break;

            case KEY_UP :
                Increment(widget->current, widget->inc);
                break;

            case KEY_PPAGE :
                Increment(widget->current, widget->fastinc);
                break;

            case KEY_NPAGE :
                Decrement(widget->current, widget->fastinc);
                break;

            case KEY_HOME :
                widget->current = widget->low;
                break;

            case KEY_END :
                widget->current = widget->high;
                break;

            case KEY_TAB :
            case KEY_ENTER :
                setExitType(widget, input);
                ret = (widget->current);
                complete = TRUE;
                break;

            case KEY_ESC :
                setExitType(widget, input);
                complete = TRUE;
                break;

            case CDK_REFRESH :
                eraseCDKScreen (ScreenOf(widget));
                refreshCDKScreen (ScreenOf(widget));
                break;

            default :
                if (widget->fieldEdit)
                {
                    if (!performEdit(widget, input))
                        BEEP();
                }
                else
                {
                    /*
                     * The cursor is not within the editable text.  Interpret
                     * input as commands.
                     */
                    switch (input)
                    {
                    case 'd':
                    case '-':
                        return _injectCDKUScale(object, KEY_DOWN);
                    case '+':
                        return _injectCDKUScale(object, KEY_UP);
                    case 'D':
                        return _injectCDKUScale(object, KEY_NPAGE);
                    case '0':
                        return _injectCDKUScale(object, KEY_HOME);
                    default:
                        BEEP();
                        break;
                    }
                }
                break;
            }
        }
        limitCurrentValue(widget);

        /* Should we call a post-process? */
        if (!complete && (PostProcessFuncOf(widget) != 0))
        {
            PostProcessFuncOf(widget) (vUSCALE, widget, PostProcessDataOf(widget), input);
        }
    }

    if (!complete) {
        drawCDKUScaleField (widget);
        setExitType(widget, 0);
    }

    ResultOf(widget).valueUnsigned = ret;
    return (ret != unknownUnsigned);
}