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 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
/* $Id: mentry_ex2.c,v 1.3 2025/01/09 00:20:21 tom Exp $ */
#include <cdk_test.h>
#ifdef HAVE_XCURSES
char *XCursesProgramName = "mentry_ex2";
#endif
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkscreen = NULL;
CDKMENTRY *widget = NULL;
char *info = NULL;
const char *label = "</R>Message";
const char *title =
"<C></5>Enter a message (\".\" to exit).<!5>\n"
"<C>It can be </3>multi<!3>-line!";
int boxWidth;
CDK_PARAMS params;
CDKparseParams (argc, argv, ¶ms, "w:h:l:" CDK_MIN_PARAMS);
cdkscreen = initCDKScreen (NULL);
/* Start CDK Colors. */
initCDKColor ();
/* Set up the multi-line entry field. */
boxWidth = CDKparamValue (¶ms, 'w', 40);
widget = newCDKMentry (cdkscreen,
CDKparamValue (¶ms, 'X', CENTER),
CDKparamValue (¶ms, 'Y', CENTER),
title, label, A_BOLD, '.', vMIXED,
boxWidth,
CDKparamValue (¶ms, 'h', 5),
CDKparamValue (¶ms, 'l', 20),
0,
CDKparamValue (¶ms, 'N', TRUE),
CDKparamValue (¶ms, 'S', FALSE));
/* Is the object null? */
if (widget == NULL)
{
/* Shut down CDK. */
destroyCDKScreen (cdkscreen);
endCDK ();
printf ("Cannot create CDK object. Is the window too small?\n");
ExitProgram (EXIT_FAILURE);
}
refreshCDKScreen (cdkscreen);
for (;;)
{
info = getCdkTitle (ObjOf (widget));
setCDKMentry (widget, info, 0, TRUE);
free (info);
activateCDKMentry (widget, NULL);
if (strlen (widget->info) > 1)
{
setCdkTitle (ObjOf (widget), widget->info, getmaxx (widget->win));
eraseCDKScreen (ScreenOf (widget));
drawCDKScreen (ScreenOf (widget));
}
else
{
break;
}
}
destroyCDKMentry (widget);
destroyCDKScreen (cdkscreen);
endCDK ();
ExitProgram (EXIT_SUCCESS);
}
|