bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patches suggestions to CDK


From: Fu Steve X
Subject: Patches suggestions to CDK
Date: Fri, 6 Jan 2006 11:04:38 -0500

The highlighting and cursor behaviors appear to be correct in the test program below. But I had to make the function switchFocus in traverse.c public in order to call it in user code. Is it possible to patch setCDKFocusFirst and setCDKFocusNext so they also take care of switching from oldObj to newObj? Or, do I miss anything and don't use them correctly?

Thanks.


Steve Fu

---------------------- cut here ------------------------

#include <cdk.h>

WINDOW *cursesWin       = 0;
CDKSCREEN *cdkscreen = 0;
CDKENTRY *entry = 0;
CDKBUTTON *btn1 = 0;
CDKBUTTON *btn2 = 0;
CDKLABEL *lbl = 0;

static int  escCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData GCC_UNUSED, chtype key GCC_UNUSED)

{
        endCDK();
   exit(0);
}

static int  resetCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData GCC_UNUSED, chtype key GCC_UNUSED)

{

        CDKOBJS * currObj = getCDKFocusCurrent(cdkscreen);

        setCDKEntryValue(entry, "");   
        drawCDKEntry(entry, TRUE);

        switchFocus(setCDKFocusFirst(cdkscreen), currObj);

   return (TRUE);
}

static int  enterCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData GCC_UNUSED, chtype key GCC_UNUSED)

{

        CDKOBJS * currObj = getCDKFocusCurrent(cdkscreen);

        switchFocus(setCDKFocusNext(cdkscreen), currObj);

   return (TRUE);
}

/*
 * This demonstrates the Cdk entry field widget.
 */
int main(int argc, char **argv)
{
   /* Declare local variables. */

   char *title          = "<C>Enter \n<C>Something.";
   char *label          = "Value: ";
   char *info,  temp[256];
   char *msg[1] = { "</U/5>F7<!U!5> - RESET"};

   CDK_PARAMS params;

   CDKparseParams(argc, argv, &params, CDK_MIN_PARAMS);

   /* Set up CDK. */
   cursesWin = initscr();
   cdkscreen = initCDKScreen (cursesWin);

   /* Create the entry field widget. */
   entry = newCDKEntry (cdkscreen,
                            CDKparamValue(&params, 'X', CENTER),
                            CDKparamValue(&params, 'Y', 1),
                            title, label, A_NORMAL, '.', vMIXED,
                            40, 0, 256,
                            CDKparamValue(&params, 'N', TRUE),
                            CDKparamValue(&params, 'S', FALSE));

        btn1 = newCDKButton (cdkscreen,
                                CDKparamValue(&params, 'X', CENTER),
             CDKparamValue(&params, 'Y', 7),
                 "Button 1", NULL,
                 TRUE, FALSE);

        btn2 = newCDKButton (cdkscreen,
                                CDKparamValue(&params, 'X', CENTER),
             CDKparamValue(&params, 'Y', 11),
                 "Button 2", NULL,
                 TRUE, FALSE);

        lbl = newCDKLabel (cdkscreen,
             CDKparamValue(&params, 'X', CENTER),
             CDKparamValue(&params, 'Y', 16),
             msg, 1,
             CDKparamValue(&params, 'N', FALSE),
             CDKparamValue(&params, 'S', FALSE));

   bindCDKObject (vENTRY, entry, KEY_F(7), resetCB, NULL);
   bindCDKObject (vENTRY, entry, KEY_ESC, escCB, NULL);

   bindCDKObject (vBUTTON, btn1, KEY_F(7), resetCB, NULL);
   bindCDKObject (vBUTTON, btn1, KEY_ESC, resetCB, NULL);
   bindCDKObject (vBUTTON, btn1, KEY_ENTER, enterCB, NULL);

   bindCDKObject (vBUTTON, btn2, KEY_F(7), resetCB, NULL);
   bindCDKObject (vBUTTON, btn2, KEY_ESC, resetCB, NULL);

        refreshCDKScreen(cdkscreen);

        traverseCDKScreen(cdkscreen);

   /* Clean up and exit. */
   destroyCDKScreen (cdkscreen);
   endCDK();
   exit (EXIT_SUCCESS);
}


reply via email to

[Prev in Thread] Current Thread [Next in Thread]