added cdk to deps and building fileapprove
This commit is contained in:
167
deps/cdk-5.0-20161210/examples/Makefile.in
vendored
Normal file
167
deps/cdk-5.0-20161210/examples/Makefile.in
vendored
Normal file
@@ -0,0 +1,167 @@
|
||||
# $Id: Makefile.in,v 1.22 2016/11/20 19:41:20 tom Exp $
|
||||
#
|
||||
# Makefile for the examples directory.
|
||||
#
|
||||
SHELL = /bin/sh
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = $(srcdir)
|
||||
|
||||
CC = @CC@
|
||||
RM = rm -f
|
||||
CTAGS = @CTAGS@
|
||||
ETAGS = @ETAGS@
|
||||
LINT = @LINT@
|
||||
LINT_OPTS = @LINT_OPTS@
|
||||
|
||||
LIBS = -l@LIB_ROOTNAME@ @LIBS@
|
||||
|
||||
LIBTOOL = @LIBTOOL@ @ECHO_LT@
|
||||
LIBTOOL_CLEAN = @LIB_CLEAN@
|
||||
LIBTOOL_LINK = @LIB_LINK@
|
||||
LINK = $(LIBTOOL_LINK)
|
||||
|
||||
x = @EXEEXT@
|
||||
o = .@OBJEXT@
|
||||
LOCAL_LIBDIR = @top_builddir@
|
||||
|
||||
CFLAGS = @CFLAGS@ @EXTRA_CFLAGS@
|
||||
CPPFLAGS = @DEFS@ -I../include -I$(srcdir)/../include -I. @CPPFLAGS@
|
||||
LDFLAGS = -L.. @LDFLAGS@ @LOCAL_LDFLAGS@
|
||||
|
||||
BINS = \
|
||||
alphalist_ex$x \
|
||||
bind_ex$x \
|
||||
buttonbox_ex$x \
|
||||
calendar_ex$x \
|
||||
cdkscreen_ex$x \
|
||||
dialog_ex$x \
|
||||
entry_ex$x \
|
||||
fscale_ex$x \
|
||||
fselect_ex$x \
|
||||
fslider_ex$x \
|
||||
graph_ex$x \
|
||||
hello_ex$x \
|
||||
histogram_ex$x \
|
||||
itemlist_ex$x \
|
||||
label_ex$x \
|
||||
lowerCDKObject_ex$x \
|
||||
marquee_ex$x \
|
||||
matrix_ex$x \
|
||||
mentry_ex$x \
|
||||
menu_ex$x \
|
||||
position_ex$x \
|
||||
preprocess_ex$x \
|
||||
radio1_ex$x \
|
||||
radio_ex$x \
|
||||
raiseCDKObject_ex$x \
|
||||
scale_ex$x \
|
||||
scroll_ex$x \
|
||||
selection_ex$x \
|
||||
slider_ex$x \
|
||||
subwindow_ex$x \
|
||||
swindow_ex$x \
|
||||
template_ex$x \
|
||||
traverse_ex$x \
|
||||
uslider_ex$x \
|
||||
viewer_ex$x \
|
||||
viewer_ex2$x
|
||||
|
||||
CDKSRC = \
|
||||
alphalist_ex.c \
|
||||
bind_ex.c \
|
||||
buttonbox_ex.c \
|
||||
calendar_ex.c \
|
||||
cdkscreen_ex.c \
|
||||
dialog_ex.c \
|
||||
entry_ex.c \
|
||||
fscale_ex.c \
|
||||
fselect_ex.c \
|
||||
fslider_ex.c \
|
||||
graph_ex.c \
|
||||
hello_ex.c \
|
||||
histogram_ex.c \
|
||||
itemlist_ex.c \
|
||||
label_ex.c \
|
||||
lowerCDKObject_ex.c \
|
||||
marquee_ex.c \
|
||||
matrix_ex.c \
|
||||
mentry_ex.c \
|
||||
menu_ex.c \
|
||||
position_ex.c \
|
||||
preprocess_ex.c \
|
||||
radio1_ex.c \
|
||||
radio_ex.c \
|
||||
raiseCDKObject_ex.c \
|
||||
scale_ex.c \
|
||||
scroll_ex.c \
|
||||
selection_ex.c \
|
||||
slider_ex.c \
|
||||
subwindow_ex.c \
|
||||
swindow_ex.c \
|
||||
template_ex.c \
|
||||
traverse_ex.c \
|
||||
uslider_ex.c \
|
||||
viewer_ex.c \
|
||||
viewer_ex2.c
|
||||
|
||||
LINKIT = @ECHO_LD@$(LINK) $(CFLAGS) $(CPPFLAGS) $? -o $@ $(LDFLAGS) $(LIBS)
|
||||
|
||||
all : $(BINS)
|
||||
|
||||
alphalist_ex$x : alphalist_ex.c ; $(LINKIT)
|
||||
bind_ex$x : bind_ex.c ; $(LINKIT)
|
||||
buttonbox_ex$x : buttonbox_ex.c ; $(LINKIT)
|
||||
calendar_ex$x : calendar_ex.c ; $(LINKIT)
|
||||
cdkscreen_ex$x : cdkscreen_ex.c ; $(LINKIT)
|
||||
dialog_ex$x : dialog_ex.c ; $(LINKIT)
|
||||
entry_ex$x : entry_ex.c ; $(LINKIT)
|
||||
fscale_ex$x : fscale_ex.c ; $(LINKIT)
|
||||
fselect_ex$x : fselect_ex.c ; $(LINKIT)
|
||||
fslider_ex$x : fslider_ex.c ; $(LINKIT)
|
||||
graph_ex$x : graph_ex.c ; $(LINKIT)
|
||||
hello_ex$x : hello_ex.c ; $(LINKIT)
|
||||
histogram_ex$x : histogram_ex.c ; $(LINKIT)
|
||||
itemlist_ex$x : itemlist_ex.c ; $(LINKIT)
|
||||
label_ex$x : label_ex.c ; $(LINKIT)
|
||||
lowerCDKObject_ex$x : lowerCDKObject_ex.c ; $(LINKIT)
|
||||
marquee_ex$x : marquee_ex.c ; $(LINKIT)
|
||||
matrix_ex$x : matrix_ex.c ; $(LINKIT)
|
||||
mentry_ex$x : mentry_ex.c ; $(LINKIT)
|
||||
menu_ex$x : menu_ex.c ; $(LINKIT)
|
||||
position_ex$x : position_ex.c ; $(LINKIT)
|
||||
preprocess_ex$x : preprocess_ex.c ; $(LINKIT)
|
||||
radio1_ex$x : radio1_ex.c ; $(LINKIT)
|
||||
radio_ex$x : radio_ex.c ; $(LINKIT)
|
||||
raiseCDKObject_ex$x : raiseCDKObject_ex.c ; $(LINKIT)
|
||||
scale_ex$x : scale_ex.c ; $(LINKIT)
|
||||
scroll_ex$x : scroll_ex.c ; $(LINKIT)
|
||||
selection_ex$x : selection_ex.c ; $(LINKIT)
|
||||
slider_ex$x : slider_ex.c ; $(LINKIT)
|
||||
subwindow_ex$x : subwindow_ex.c ; $(LINKIT)
|
||||
swindow_ex$x : swindow_ex.c ; $(LINKIT)
|
||||
template_ex$x : template_ex.c ; $(LINKIT)
|
||||
traverse_ex$x : traverse_ex.c ; $(LINKIT)
|
||||
uslider_ex$x : uslider_ex.c ; $(LINKIT)
|
||||
viewer_ex$x : viewer_ex.c ; $(LINKIT)
|
||||
viewer_ex2$x : viewer_ex2.c ; $(LINKIT)
|
||||
#
|
||||
# Standard clean directives.
|
||||
#
|
||||
clean::
|
||||
-$(LIBTOOL_CLEAN) $(RM) *.o core $(BINS)
|
||||
|
||||
distclean:: clean
|
||||
$(RM) Makefile
|
||||
|
||||
@MAKE_LOWER_TAGS@tags :
|
||||
@MAKE_LOWER_TAGS@ $(CTAGS) *.[ch] */*.[ch]
|
||||
|
||||
@MAKE_LOWER_TAGS@TAGS :
|
||||
@MAKE_LOWER_TAGS@ $(ETAGS) *.[ch] */*.[ch]
|
||||
|
||||
lint: $(CDKSRC)
|
||||
$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(CDKSRC)
|
293
deps/cdk-5.0-20161210/examples/alphalist_ex.c
vendored
Normal file
293
deps/cdk-5.0-20161210/examples/alphalist_ex.c
vendored
Normal file
@@ -0,0 +1,293 @@
|
||||
/* $Id: alphalist_ex.c,v 1.30 2016/12/04 15:38:55 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "alphalist_ex";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This program demonstrates the Cdk alphalist widget.
|
||||
*
|
||||
* Options (in addition to normal CLI parameters):
|
||||
* -c create the data after the widget
|
||||
*/
|
||||
static CDKSCREEN *cdkscreen = 0;
|
||||
static char **myUserList = 0;
|
||||
static int userSize;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int deleted; /* index in current list which is deleted */
|
||||
int original; /* index in myUserList[] of deleted item */
|
||||
int position; /* position before delete */
|
||||
int topline; /* top-line before delete */
|
||||
} UNDO;
|
||||
|
||||
static UNDO *myUndoList;
|
||||
static int undoSize;
|
||||
|
||||
/*
|
||||
* This reads the passwd file and retrieves user information.
|
||||
*/
|
||||
static int getUserList (char ***list)
|
||||
{
|
||||
#if defined (HAVE_PWD_H)
|
||||
struct passwd *ent;
|
||||
#endif
|
||||
int x = 0;
|
||||
unsigned used = 0;
|
||||
|
||||
#if defined (HAVE_PWD_H)
|
||||
while ((ent = getpwent ()) != 0)
|
||||
{
|
||||
used = CDKallocStrings (list, ent->pw_name, (unsigned)x++, used);
|
||||
}
|
||||
endpwent ();
|
||||
#endif
|
||||
return x;
|
||||
}
|
||||
|
||||
#define CB_PARAMS EObjectType cdktype GCC_UNUSED, void* object GCC_UNUSED, void* clientdata GCC_UNUSED, chtype key GCC_UNUSED
|
||||
|
||||
static void fill_undo (CDKALPHALIST *widget, int deleted, char *data)
|
||||
{
|
||||
int top = getCDKScrollCurrentTop (widget->scrollField);
|
||||
int item = getCDKAlphalistCurrentItem (widget);
|
||||
int n;
|
||||
|
||||
myUndoList[undoSize].deleted = deleted;
|
||||
myUndoList[undoSize].topline = top;
|
||||
myUndoList[undoSize].original = -1;
|
||||
myUndoList[undoSize].position = item;
|
||||
for (n = 0; n < userSize; ++n)
|
||||
{
|
||||
if (!strcmp (myUserList[n], data))
|
||||
{
|
||||
myUndoList[undoSize].original = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
++undoSize;
|
||||
}
|
||||
|
||||
static int do_delete (CB_PARAMS)
|
||||
{
|
||||
CDKALPHALIST *widget = (CDKALPHALIST *)clientdata;
|
||||
int size;
|
||||
char **list = getCDKAlphalistContents (widget, &size);
|
||||
int result = FALSE;
|
||||
|
||||
if (size)
|
||||
{
|
||||
int save = getCDKScrollCurrentTop (widget->scrollField);
|
||||
int first = getCDKAlphalistCurrentItem (widget);
|
||||
int n;
|
||||
|
||||
fill_undo (widget, first, list[first]);
|
||||
for (n = first; n < size; ++n)
|
||||
list[n] = list[n + 1];
|
||||
setCDKAlphalistContents (widget, (CDK_CSTRING *)list, size - 1);
|
||||
setCDKScrollCurrentTop (widget->scrollField, save);
|
||||
setCDKAlphalistCurrentItem (widget, first);
|
||||
drawCDKAlphalist (widget, BorderOf (widget));
|
||||
result = TRUE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static int do_delete1 (CB_PARAMS)
|
||||
{
|
||||
CDKALPHALIST *widget = (CDKALPHALIST *)clientdata;
|
||||
int size;
|
||||
char **list = getCDKAlphalistContents (widget, &size);
|
||||
int result = FALSE;
|
||||
|
||||
if (size)
|
||||
{
|
||||
int save = getCDKScrollCurrentTop (widget->scrollField);
|
||||
int first = getCDKAlphalistCurrentItem (widget);
|
||||
|
||||
if (first-- > 0)
|
||||
{
|
||||
int n;
|
||||
|
||||
fill_undo (widget, first, list[first]);
|
||||
for (n = first; n < size; ++n)
|
||||
list[n] = list[n + 1];
|
||||
setCDKAlphalistContents (widget, (CDK_CSTRING *)list, size - 1);
|
||||
setCDKScrollCurrentTop (widget->scrollField, save);
|
||||
setCDKAlphalistCurrentItem (widget, first);
|
||||
drawCDKAlphalist (widget, BorderOf (widget));
|
||||
result = TRUE;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static int do_help (CB_PARAMS)
|
||||
{
|
||||
static const char *message[] =
|
||||
{
|
||||
"Alpha List tests:",
|
||||
"",
|
||||
"F1 = help (this message)",
|
||||
"F2 = delete current item",
|
||||
"F3 = delete previous item",
|
||||
"F4 = reload all items",
|
||||
"F5 = undo deletion",
|
||||
0
|
||||
};
|
||||
popupLabel (cdkscreen,
|
||||
(CDK_CSTRING2)message,
|
||||
(int)CDKcountStrings ((CDK_CSTRING2)message));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int do_reload (CB_PARAMS)
|
||||
{
|
||||
int result = FALSE;
|
||||
|
||||
if (userSize)
|
||||
{
|
||||
CDKALPHALIST *widget = (CDKALPHALIST *)clientdata;
|
||||
setCDKAlphalistContents (widget, (CDK_CSTRING *)myUserList, userSize);
|
||||
setCDKAlphalistCurrentItem (widget, 0);
|
||||
drawCDKAlphalist (widget, BorderOf (widget));
|
||||
result = TRUE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static int do_undo (CB_PARAMS)
|
||||
{
|
||||
int result = FALSE;
|
||||
|
||||
if (undoSize > 0)
|
||||
{
|
||||
CDKALPHALIST *widget = (CDKALPHALIST *)clientdata;
|
||||
int size;
|
||||
int n;
|
||||
char **oldlist = getCDKAlphalistContents (widget, &size);
|
||||
char **newlist = (char **)malloc ((size_t) (++size + 1) * sizeof (char *));
|
||||
|
||||
--undoSize;
|
||||
newlist[size] = 0;
|
||||
for (n = size - 1; n > myUndoList[undoSize].deleted; --n)
|
||||
{
|
||||
newlist[n] = copyChar (oldlist[n - 1]);
|
||||
}
|
||||
newlist[n--] = copyChar (myUserList[myUndoList[undoSize].original]);
|
||||
while (n >= 0)
|
||||
{
|
||||
newlist[n] = copyChar (oldlist[n]);
|
||||
--n;
|
||||
}
|
||||
setCDKAlphalistContents (widget, (CDK_CSTRING *)newlist, size);
|
||||
setCDKScrollCurrentTop (widget->scrollField, myUndoList[undoSize].topline);
|
||||
setCDKAlphalistCurrentItem (widget, myUndoList[undoSize].position);
|
||||
drawCDKAlphalist (widget, BorderOf (widget));
|
||||
free (newlist);
|
||||
result = TRUE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKALPHALIST *alphaList = 0;
|
||||
const char *title = "<C></B/24>Alpha List\n<C>Title";
|
||||
const char *label = "</B>Account: ";
|
||||
char *word = 0;
|
||||
char **userList = 0;
|
||||
const char *mesg[5];
|
||||
char temp[256];
|
||||
|
||||
CDK_PARAMS params;
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, "c" CDK_CLI_PARAMS);
|
||||
|
||||
/* Get the user list. */
|
||||
userSize = getUserList (&userList);
|
||||
if (userSize <= 0)
|
||||
{
|
||||
fprintf (stderr, "Cannot get user list\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
myUserList = copyCharList ((const char **)userList);
|
||||
myUndoList = (UNDO *) malloc ((size_t) userSize * sizeof (UNDO));
|
||||
undoSize = 0;
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start color. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Create the alpha list widget. */
|
||||
alphaList = newCDKAlphalist (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
CDKparamValue (¶ms, 'H', 0),
|
||||
CDKparamValue (¶ms, 'W', 0),
|
||||
title, label,
|
||||
(CDKparamNumber (¶ms, 'c')
|
||||
? 0
|
||||
: (CDK_CSTRING *)userList),
|
||||
(CDKparamNumber (¶ms, 'c')
|
||||
? 0
|
||||
: userSize),
|
||||
'_', A_REVERSE,
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
if (alphaList == 0)
|
||||
{
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
fprintf (stderr, "Cannot create widget\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bindCDKObject (vALPHALIST, alphaList, '?', do_help, NULL);
|
||||
bindCDKObject (vALPHALIST, alphaList, KEY_F1, do_help, NULL);
|
||||
bindCDKObject (vALPHALIST, alphaList, KEY_F2, do_delete, alphaList);
|
||||
bindCDKObject (vALPHALIST, alphaList, KEY_F3, do_delete1, alphaList);
|
||||
bindCDKObject (vALPHALIST, alphaList, KEY_F4, do_reload, alphaList);
|
||||
bindCDKObject (vALPHALIST, alphaList, KEY_F5, do_undo, alphaList);
|
||||
|
||||
if (CDKparamNumber (¶ms, 'c'))
|
||||
{
|
||||
setCDKAlphalistContents (alphaList, (CDK_CSTRING *)userList, userSize);
|
||||
}
|
||||
|
||||
/* Let them play with the alpha list. */
|
||||
word = activateCDKAlphalist (alphaList, 0);
|
||||
|
||||
/* Determine what the user did. */
|
||||
if (alphaList->exitType == vESCAPE_HIT)
|
||||
{
|
||||
mesg[0] = "<C>You hit escape. No word was selected.";
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 3);
|
||||
}
|
||||
else if (alphaList->exitType == vNORMAL)
|
||||
{
|
||||
mesg[0] = "<C>You selected the following";
|
||||
sprintf (temp, "<C>(%.*s)", (int)(sizeof (temp) - 10), word);
|
||||
mesg[1] = temp;
|
||||
mesg[2] = "";
|
||||
mesg[3] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 4);
|
||||
}
|
||||
|
||||
freeCharList (myUserList, (unsigned)userSize);
|
||||
free (myUserList);
|
||||
|
||||
destroyCDKAlphalist (alphaList);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
164
deps/cdk-5.0-20161210/examples/bind_ex.c
vendored
Normal file
164
deps/cdk-5.0-20161210/examples/bind_ex.c
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
/* $Id: bind_ex.c,v 1.20 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "bind_ex";
|
||||
#endif
|
||||
|
||||
static int dialogHelpCB (EObjectType cdktype GCC_UNUSED,
|
||||
void *object,
|
||||
void *clientData GCC_UNUSED,
|
||||
chtype key GCC_UNUSED)
|
||||
{
|
||||
CDKDIALOG *dialog = (CDKDIALOG *)object;
|
||||
const char *mesg[5];
|
||||
|
||||
/* Check which button we are on. */
|
||||
if (dialog->currentButton == 0)
|
||||
{
|
||||
mesg[0] = "<C></U>Help for </U>Who<!U>.";
|
||||
mesg[1] = "<C>When this button is picked the name of the current";
|
||||
mesg[2] = "<C>user is displayed on the screen in a popup window.";
|
||||
popupLabel (ScreenOf (dialog), (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
else if (dialog->currentButton == 1)
|
||||
{
|
||||
mesg[0] = "<C></U>Help for </U>Time<!U>.";
|
||||
mesg[1] = "<C>When this button is picked the current time is";
|
||||
mesg[2] = "<C>displayed on the screen in a popup window.";
|
||||
popupLabel (ScreenOf (dialog), (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
else if (dialog->currentButton == 2)
|
||||
{
|
||||
mesg[0] = "<C></U>Help for </U>Date<!U>.";
|
||||
mesg[1] = "<C>When this button is picked the current date is";
|
||||
mesg[2] = "<C>displayed on the screen in a popup window.";
|
||||
popupLabel (ScreenOf (dialog), (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
else if (dialog->currentButton == 3)
|
||||
{
|
||||
mesg[0] = "<C></U>Help for </U>Quit<!U>.";
|
||||
mesg[1] = "<C>When this button is picked the dialog box is exited.";
|
||||
popupLabel (ScreenOf (dialog), (CDK_CSTRING2) mesg, 2);
|
||||
}
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
CDKSCREEN *cdkscreen;
|
||||
CDKDIALOG *question;
|
||||
const char *buttons[40];
|
||||
const char *message[40];
|
||||
const char *info[5];
|
||||
char *loginName = 0;
|
||||
char temp[256];
|
||||
int selection;
|
||||
time_t clck;
|
||||
struct tm *currentTime;
|
||||
CDK_PARAMS params;
|
||||
/* *INDENT-ON* */
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, CDK_MIN_PARAMS);
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start color. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Set up the dialog box. */
|
||||
message[0] = "<C></U>Simple Command Interface";
|
||||
message[1] = "Pick the command you wish to run.";
|
||||
message[2] = "<C>Press </R>?<!R> for help.";
|
||||
buttons[0] = "Who";
|
||||
buttons[1] = "Time";
|
||||
buttons[2] = "Date";
|
||||
buttons[3] = "Quit";
|
||||
|
||||
/* Create the dialog box. */
|
||||
question = newCDKDialog (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
(CDK_CSTRING2) message, 3,
|
||||
(CDK_CSTRING2) buttons, 4,
|
||||
A_REVERSE,
|
||||
TRUE,
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
|
||||
/* Check if we got a null value back. */
|
||||
if (question == (CDKDIALOG *)0)
|
||||
{
|
||||
destroyCDKScreen (cdkscreen);
|
||||
|
||||
/* End curses... */
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot create the dialog box. ");
|
||||
printf ("Is the window too small?\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Create the key binding. */
|
||||
bindCDKObject (vDIALOG, question, '?', dialogHelpCB, 0);
|
||||
|
||||
/* Activate the dialog box. */
|
||||
selection = 0;
|
||||
while (selection != 3)
|
||||
{
|
||||
/* Get the users button selection. */
|
||||
selection = activateCDKDialog (question, (chtype *)0);
|
||||
|
||||
/* Check the results. */
|
||||
if (selection == 0)
|
||||
{
|
||||
/* Get the users login name. */
|
||||
info[0] = "<C> </U>Login Name<!U> ";
|
||||
#if defined (HAVE_GETLOGIN)
|
||||
loginName = getlogin ();
|
||||
#endif
|
||||
if (loginName == (char *)0)
|
||||
{
|
||||
strcpy (temp, "<C></R>Unknown");
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (temp, "<C><%.*s>", (int)(sizeof (temp) - 10), loginName);
|
||||
}
|
||||
info[1] = temp;
|
||||
popupLabel (ScreenOf (question), (CDK_CSTRING2) info, 2);
|
||||
}
|
||||
else if (selection == 1)
|
||||
{
|
||||
time (&clck);
|
||||
currentTime = localtime (&clck);
|
||||
sprintf (temp, "<C>%2d:%02d:%02d",
|
||||
currentTime->tm_hour,
|
||||
currentTime->tm_min,
|
||||
currentTime->tm_sec);
|
||||
info[0] = "<C> </U>Current Time<!U> ";
|
||||
info[1] = temp;
|
||||
popupLabel (ScreenOf (question), (CDK_CSTRING2) info, 2);
|
||||
}
|
||||
else if (selection == 2)
|
||||
{
|
||||
time (&clck);
|
||||
currentTime = localtime (&clck);
|
||||
sprintf (temp, "<C>%d/%02d/%02d",
|
||||
currentTime->tm_mday,
|
||||
currentTime->tm_mon + 1,
|
||||
currentTime->tm_year % 100);
|
||||
info[0] = "<C> </U>Current Date<!U> ";
|
||||
info[1] = temp;
|
||||
popupLabel (ScreenOf (question), (CDK_CSTRING2) info, 2);
|
||||
}
|
||||
}
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKDialog (question);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
102
deps/cdk-5.0-20161210/examples/buttonbox_ex.c
vendored
Normal file
102
deps/cdk-5.0-20161210/examples/buttonbox_ex.c
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
/* $Id: buttonbox_ex.c,v 1.21 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "buttonbox_ex";
|
||||
#endif
|
||||
|
||||
static BINDFN_PROTO (entryCB);
|
||||
|
||||
/*
|
||||
* This program demonstrates the Cdk buttonbox widget.
|
||||
*/
|
||||
int main (void)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKSCREEN *cdkscreen = 0;
|
||||
CDKBUTTONBOX *buttonWidget = 0;
|
||||
CDKENTRY *entry = 0;
|
||||
const char *buttons[] =
|
||||
{
|
||||
" OK ",
|
||||
" Cancel "
|
||||
};
|
||||
char *info = 0;
|
||||
int selection;
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start color. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Create the entry widget. */
|
||||
entry = newCDKEntry (cdkscreen, CENTER, CENTER,
|
||||
"<C>Enter a name", "Name ", A_NORMAL, '.', vMIXED,
|
||||
40, 0, 256, TRUE, FALSE);
|
||||
if (entry == 0)
|
||||
{
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
fprintf (stderr, "Cannot create entry-widget\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
/* Create the button box widget. */
|
||||
buttonWidget = newCDKButtonbox (cdkscreen,
|
||||
getbegx (entry->win),
|
||||
getbegy (entry->win) + entry->boxHeight - 1,
|
||||
1, entry->boxWidth - 1,
|
||||
0, 1, 2,
|
||||
(CDK_CSTRING2) buttons, 2, A_REVERSE,
|
||||
TRUE, FALSE);
|
||||
if (buttonWidget == 0)
|
||||
{
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
fprintf (stderr, "Cannot create buttonbox-widget\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Set the lower left and right characters of the box. */
|
||||
setCDKEntryLLChar (entry, ACS_LTEE);
|
||||
setCDKEntryLRChar (entry, ACS_RTEE);
|
||||
setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
|
||||
setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
|
||||
|
||||
/*
|
||||
* Bind the Tab key in the entry field to send a
|
||||
* Tab key to the button box widget.
|
||||
*/
|
||||
bindCDKObject (vENTRY, entry, KEY_TAB, entryCB, buttonWidget);
|
||||
|
||||
/* Activate the entry field. */
|
||||
drawCDKButtonbox (buttonWidget, TRUE);
|
||||
info = copyChar (activateCDKEntry (entry, 0));
|
||||
selection = buttonWidget->currentButton;
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKButtonbox (buttonWidget);
|
||||
destroyCDKEntry (entry);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("You typed in (%s) and selected button (%s)\n",
|
||||
(info != 0) ? info : "<null>",
|
||||
buttons[selection]);
|
||||
|
||||
freeChar (info);
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static int entryCB (EObjectType cdktype GCC_UNUSED,
|
||||
void *object GCC_UNUSED,
|
||||
void *clientData, chtype key)
|
||||
{
|
||||
CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
|
||||
(void)injectCDKButtonbox (buttonbox, key);
|
||||
return (TRUE);
|
||||
}
|
155
deps/cdk-5.0-20161210/examples/calendar_ex.c
vendored
Normal file
155
deps/cdk-5.0-20161210/examples/calendar_ex.c
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
/* $Id: calendar_ex.c,v 1.17 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "calendar_ex";
|
||||
#endif
|
||||
|
||||
static BINDFN_PROTO (createCalendarMarkCB);
|
||||
static BINDFN_PROTO (removeCalendarMarkCB);
|
||||
|
||||
/*
|
||||
* This program demonstrates the Cdk calendar widget.
|
||||
*/
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKSCREEN *cdkscreen = 0;
|
||||
CDKCALENDAR *calendar = 0;
|
||||
const char *mesg[5];
|
||||
char temp[256];
|
||||
struct tm *dateInfo;
|
||||
time_t clck, retVal;
|
||||
|
||||
CDK_PARAMS params;
|
||||
char *title;
|
||||
int day;
|
||||
int month;
|
||||
int year;
|
||||
|
||||
/*
|
||||
* Get the current dates and set the default values for
|
||||
* the day/month/year values for the calendar.
|
||||
*/
|
||||
time (&clck);
|
||||
dateInfo = gmtime (&clck);
|
||||
|
||||
/* *INDENT-EQLS* */
|
||||
CDKparseParams (argc, argv, ¶ms, "d:m:y:t:w:" CDK_MIN_PARAMS);
|
||||
day = CDKparamNumber2 (¶ms, 'd', dateInfo->tm_mday);
|
||||
month = CDKparamNumber2 (¶ms, 'm', dateInfo->tm_mon + 1);
|
||||
year = CDKparamNumber2 (¶ms, 'y', dateInfo->tm_year + 1900);
|
||||
title = CDKparamString2 (¶ms, 't', "<C></U>CDK Calendar Widget\n<C>Demo");
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start CDK Colors. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Create the calendar widget. */
|
||||
calendar = newCDKCalendar (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
title, day, month, year,
|
||||
COLOR_PAIR (16) | A_BOLD,
|
||||
COLOR_PAIR (24) | A_BOLD,
|
||||
COLOR_PAIR (32) | A_BOLD,
|
||||
COLOR_PAIR (40) | A_REVERSE,
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
|
||||
/* Is the widget null? */
|
||||
if (calendar == 0)
|
||||
{
|
||||
/* Clean up the memory. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
|
||||
/* End curses... */
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot create the calendar. Is the window too small?\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Create a key binding to mark days on the calendar. */
|
||||
bindCDKObject (vCALENDAR, calendar, 'm', createCalendarMarkCB, calendar);
|
||||
bindCDKObject (vCALENDAR, calendar, 'M', createCalendarMarkCB, calendar);
|
||||
bindCDKObject (vCALENDAR, calendar, 'r', removeCalendarMarkCB, calendar);
|
||||
bindCDKObject (vCALENDAR, calendar, 'R', removeCalendarMarkCB, calendar);
|
||||
|
||||
calendar->weekBase = CDKparamNumber (¶ms, 'w');
|
||||
|
||||
/* Draw the calendar widget. */
|
||||
drawCDKCalendar (calendar, ObjOf (calendar)->box);
|
||||
|
||||
/* Let the user play with the widget. */
|
||||
retVal = activateCDKCalendar (calendar, 0);
|
||||
|
||||
/* Check which day they selected. */
|
||||
if (calendar->exitType == vESCAPE_HIT)
|
||||
{
|
||||
mesg[0] = "<C>You hit escape. No date selected.";
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
else if (calendar->exitType == vNORMAL)
|
||||
{
|
||||
mesg[0] = "You selected the following date";
|
||||
sprintf (temp, "<C></B/16>%02d/%02d/%d (dd/mm/yyyy)",
|
||||
calendar->day,
|
||||
calendar->month,
|
||||
calendar->year);
|
||||
mesg[1] = temp;
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
|
||||
/* Clean up and exit. */
|
||||
destroyCDKCalendar (calendar);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
fflush (stdout);
|
||||
printf ("Selected Time: %s\n", ctime (&retVal));
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* This adds a marker to the calendar.
|
||||
*/
|
||||
static int createCalendarMarkCB (EObjectType objectType GCC_UNUSED,
|
||||
void *object,
|
||||
void *clientData GCC_UNUSED,
|
||||
chtype key GCC_UNUSED)
|
||||
{
|
||||
CDKCALENDAR *calendar = (CDKCALENDAR *)object;
|
||||
|
||||
setCDKCalendarMarker (calendar,
|
||||
calendar->day,
|
||||
calendar->month,
|
||||
calendar->year,
|
||||
COLOR_PAIR (5) | A_REVERSE);
|
||||
|
||||
drawCDKCalendar (calendar, ObjOf (calendar)->box);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* This removes a marker from the calendar.
|
||||
*/
|
||||
static int removeCalendarMarkCB (EObjectType objectType GCC_UNUSED,
|
||||
void *object,
|
||||
void *clientData GCC_UNUSED,
|
||||
chtype key GCC_UNUSED)
|
||||
{
|
||||
CDKCALENDAR *calendar = (CDKCALENDAR *)object;
|
||||
|
||||
removeCDKCalendarMarker (calendar,
|
||||
calendar->day,
|
||||
calendar->month,
|
||||
calendar->year);
|
||||
|
||||
drawCDKCalendar (calendar, ObjOf (calendar)->box);
|
||||
return (FALSE);
|
||||
}
|
134
deps/cdk-5.0-20161210/examples/cdkscreen_ex.c
vendored
Normal file
134
deps/cdk-5.0-20161210/examples/cdkscreen_ex.c
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
/* $Id: cdkscreen_ex.c,v 1.9 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
/*
|
||||
* This demonstrates how to create four different Cdk
|
||||
* screens and flip between them.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "cdkscreen_ex";
|
||||
#endif
|
||||
|
||||
int main (void)
|
||||
{
|
||||
CDKSCREEN *cdkScreen1, *cdkScreen2;
|
||||
CDKSCREEN *cdkScreen3, *cdkScreen4;
|
||||
CDKSCREEN *cdkScreen5;
|
||||
CDKLABEL *label1, *label2;
|
||||
CDKLABEL *label3, *label4;
|
||||
CDKDIALOG *dialog;
|
||||
const char *title1Mesg[4];
|
||||
const char *title2Mesg[4];
|
||||
const char *title3Mesg[4];
|
||||
const char *title4Mesg[4];
|
||||
const char *dialogMesg[10];
|
||||
const char *buttons[] =
|
||||
{
|
||||
"Continue",
|
||||
"Exit"
|
||||
};
|
||||
|
||||
/* Create the screens. */
|
||||
cdkScreen1 = initCDKScreen (NULL);
|
||||
cdkScreen2 = initCDKScreen (stdscr);
|
||||
cdkScreen3 = initCDKScreen (stdscr);
|
||||
cdkScreen4 = initCDKScreen (stdscr);
|
||||
cdkScreen5 = initCDKScreen (stdscr);
|
||||
|
||||
/* Create the first screen. */
|
||||
title1Mesg[0] = "<C><#HL(30)>";
|
||||
title1Mesg[1] = "<C></R>This is the first screen.";
|
||||
title1Mesg[2] = "<C>Hit space to go to the next screen";
|
||||
title1Mesg[3] = "<C><#HL(30)>";
|
||||
label1 = newCDKLabel (cdkScreen1, CENTER, TOP,
|
||||
(CDK_CSTRING2)title1Mesg, 4,
|
||||
FALSE, FALSE);
|
||||
|
||||
/* Create the second screen. */
|
||||
title2Mesg[0] = "<C><#HL(30)>";
|
||||
title2Mesg[1] = "<C></R>This is the second screen.";
|
||||
title2Mesg[2] = "<C>Hit space to go to the next screen";
|
||||
title2Mesg[3] = "<C><#HL(30)>";
|
||||
label2 = newCDKLabel (cdkScreen2, RIGHT, CENTER,
|
||||
(CDK_CSTRING2)title2Mesg, 4,
|
||||
FALSE, FALSE);
|
||||
|
||||
/* Create the third screen. */
|
||||
title3Mesg[0] = "<C><#HL(30)>";
|
||||
title3Mesg[1] = "<C></R>This is the third screen.";
|
||||
title3Mesg[2] = "<C>Hit space to go to the next screen";
|
||||
title3Mesg[3] = "<C><#HL(30)>";
|
||||
label3 = newCDKLabel (cdkScreen3, CENTER, BOTTOM,
|
||||
(CDK_CSTRING2)title3Mesg, 4,
|
||||
FALSE, FALSE);
|
||||
|
||||
/* Create the fourth screen. */
|
||||
title4Mesg[0] = "<C><#HL(30)>";
|
||||
title4Mesg[1] = "<C></R>This is the fourth screen.";
|
||||
title4Mesg[2] = "<C>Hit space to go to the next screen";
|
||||
title4Mesg[3] = "<C><#HL(30)>";
|
||||
label4 = newCDKLabel (cdkScreen4, LEFT, CENTER,
|
||||
(CDK_CSTRING2)title4Mesg, 4,
|
||||
FALSE, FALSE);
|
||||
|
||||
/* Create the fifth screen. */
|
||||
dialogMesg[0] = "<C><#HL(30)>";
|
||||
dialogMesg[1] = "<C>Screen 5";
|
||||
dialogMesg[2] = "<C>This is the last of 5 screens. If you want";
|
||||
dialogMesg[3] = "<C>to continue press the 'Continue' button.";
|
||||
dialogMesg[4] = "<C>Otherwise press the 'Exit' button";
|
||||
dialogMesg[5] = "<C><#HL(30)>";
|
||||
dialog = newCDKDialog (cdkScreen5, CENTER, CENTER,
|
||||
(CDK_CSTRING2)dialogMesg, 6,
|
||||
(CDK_CSTRING2)buttons, 2,
|
||||
A_REVERSE, TRUE, TRUE, FALSE);
|
||||
|
||||
/* Do this for ever... (almost) */
|
||||
for (;;)
|
||||
{
|
||||
int answer;
|
||||
|
||||
/* Draw the first screen. */
|
||||
drawCDKScreen (cdkScreen1);
|
||||
waitCDKLabel (label1, ' ');
|
||||
eraseCDKScreen (cdkScreen1);
|
||||
|
||||
/* Draw the second screen. */
|
||||
drawCDKScreen (cdkScreen2);
|
||||
waitCDKLabel (label2, ' ');
|
||||
eraseCDKScreen (cdkScreen2);
|
||||
|
||||
/* Draw the third screen. */
|
||||
drawCDKScreen (cdkScreen3);
|
||||
waitCDKLabel (label3, ' ');
|
||||
eraseCDKScreen (cdkScreen3);
|
||||
|
||||
/* Draw the fourth screen. */
|
||||
drawCDKScreen (cdkScreen4);
|
||||
waitCDKLabel (label4, ' ');
|
||||
eraseCDKScreen (cdkScreen4);
|
||||
|
||||
/* Draw the fourth screen. */
|
||||
drawCDKScreen (cdkScreen5);
|
||||
answer = activateCDKDialog (dialog, 0);
|
||||
|
||||
/* Check the users answer. */
|
||||
if (answer == 1)
|
||||
{
|
||||
destroyCDKLabel (label1);
|
||||
destroyCDKLabel (label2);
|
||||
destroyCDKLabel (label3);
|
||||
destroyCDKLabel (label4);
|
||||
destroyCDKDialog (dialog);
|
||||
destroyCDKScreen (cdkScreen1);
|
||||
destroyCDKScreen (cdkScreen2);
|
||||
destroyCDKScreen (cdkScreen3);
|
||||
destroyCDKScreen (cdkScreen4);
|
||||
destroyCDKScreen (cdkScreen5);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
||||
}
|
||||
}
|
89
deps/cdk-5.0-20161210/examples/dialog_ex.c
vendored
Normal file
89
deps/cdk-5.0-20161210/examples/dialog_ex.c
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
/* $Id: dialog_ex.c,v 1.14 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "dialog_ex";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This program demonstrates the Cdk dialog widget.
|
||||
*/
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKSCREEN *cdkscreen = 0;
|
||||
CDKDIALOG *question = 0;
|
||||
const char *buttons[] =
|
||||
{"</B/24>Ok", "</B16>Cancel"};
|
||||
const char *message[10];
|
||||
const char *mesg[3];
|
||||
char temp[100];
|
||||
int selection;
|
||||
|
||||
CDK_PARAMS params;
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, CDK_MIN_PARAMS);
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start color. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Create the message within the dialog box. */
|
||||
message[0] = "<C></U>Dialog Widget Demo";
|
||||
message[1] = " ";
|
||||
message[2] = "<C>The dialog widget allows the programmer to create";
|
||||
message[3] = "<C>a popup dialog box with buttons. The dialog box";
|
||||
message[4] = "<C>can contain </B/32>colours<!B!32>, </R>character attributes<!R>";
|
||||
message[5] = "<R>and even be right justified.";
|
||||
message[6] = "<L>and left.";
|
||||
|
||||
/* Create the dialog box. */
|
||||
question = newCDKDialog (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
(CDK_CSTRING2) message, 7,
|
||||
(CDK_CSTRING2) buttons, 2,
|
||||
COLOR_PAIR (2) | A_REVERSE,
|
||||
TRUE,
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
|
||||
/* Check if we got a null value back. */
|
||||
if (question == 0)
|
||||
{
|
||||
/* Shut down Cdk. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot create the dialog box. Is the window too small?\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Activate the dialog box. */
|
||||
selection = activateCDKDialog (question, 0);
|
||||
|
||||
/* Tell them what was selected. */
|
||||
if (question->exitType == vESCAPE_HIT)
|
||||
{
|
||||
mesg[0] = "<C>You hit escape. No button selected.";
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
else if (question->exitType == vNORMAL)
|
||||
{
|
||||
sprintf (temp, "<C>You selected button #%d", selection);
|
||||
mesg[0] = temp;
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKDialog (question);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
108
deps/cdk-5.0-20161210/examples/entry_ex.c
vendored
Normal file
108
deps/cdk-5.0-20161210/examples/entry_ex.c
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
/* $Id: entry_ex.c,v 1.17 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "entry_ex";
|
||||
#endif
|
||||
|
||||
static BINDFN_PROTO (XXXCB);
|
||||
|
||||
/*
|
||||
* This demonstrates the Cdk entry field widget.
|
||||
*/
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKSCREEN *cdkscreen = 0;
|
||||
CDKENTRY *directory = 0;
|
||||
const char *title = "<C>Enter a\n<C>directory name.";
|
||||
const char *label = "</U/5>Directory:<!U!5>";
|
||||
char *info;
|
||||
const char *mesg[10];
|
||||
char temp[256];
|
||||
|
||||
CDK_PARAMS params;
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, CDK_MIN_PARAMS);
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start CDK colors. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Create the entry field widget. */
|
||||
directory = newCDKEntry (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
title, label, A_NORMAL, '.', vMIXED,
|
||||
40, 0, 256,
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
bindCDKObject (vENTRY, directory, '?', XXXCB, 0);
|
||||
|
||||
/* Is the widget null? */
|
||||
if (directory == 0)
|
||||
{
|
||||
/* Clean up. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot create the entry box. Is the window too small?\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Draw the screen. */
|
||||
refreshCDKScreen (cdkscreen);
|
||||
|
||||
/*
|
||||
* Pass in whatever was given off of the command line. Notice we
|
||||
* don't check if argv[1] is null or not. The function setCDKEntry
|
||||
* already performs any needed checks.
|
||||
*/
|
||||
setCDKEntry (directory, argv[optind], 0, 256, TRUE);
|
||||
|
||||
/* Activate the entry field. */
|
||||
info = activateCDKEntry (directory, 0);
|
||||
|
||||
/* Tell them what they typed. */
|
||||
if (directory->exitType == vESCAPE_HIT)
|
||||
{
|
||||
mesg[0] = "<C>You hit escape. No information passed back.";
|
||||
mesg[1] = "",
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
|
||||
destroyCDKEntry (directory);
|
||||
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
else if (directory->exitType == vNORMAL)
|
||||
{
|
||||
mesg[0] = "<C>You typed in the following";
|
||||
sprintf (temp, "<C>(%.*s)", (int)(sizeof (temp) - 10), info);
|
||||
mesg[1] = temp;
|
||||
mesg[2] = "";
|
||||
mesg[3] = "<C>Press any key to continue.";
|
||||
|
||||
destroyCDKEntry (directory);
|
||||
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
destroyCDKEntry (directory);
|
||||
}
|
||||
|
||||
/* Clean up and exit. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static int XXXCB (EObjectType cdktype GCC_UNUSED,
|
||||
void *object GCC_UNUSED,
|
||||
void *clientData GCC_UNUSED,
|
||||
chtype key GCC_UNUSED)
|
||||
{
|
||||
return (TRUE);
|
||||
}
|
96
deps/cdk-5.0-20161210/examples/fscale_ex.c
vendored
Normal file
96
deps/cdk-5.0-20161210/examples/fscale_ex.c
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
/* $Id: fscale_ex.c,v 1.9 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "fscale_ex";
|
||||
#endif
|
||||
|
||||
static float myFloatParam (CDK_PARAMS * params, int code, double missing)
|
||||
{
|
||||
char *opt = CDKparamString (params, code);
|
||||
double result = missing;
|
||||
|
||||
if (opt != 0)
|
||||
result = atof (opt);
|
||||
return (float)result;
|
||||
}
|
||||
|
||||
/*
|
||||
* This program demonstrates the Cdk scale widget.
|
||||
*/
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKSCREEN *cdkscreen = 0;
|
||||
CDKFSCALE *scale = 0;
|
||||
const char *title = "<C>Select a value";
|
||||
const char *label = "</5>Current value";
|
||||
char temp[256];
|
||||
const char *mesg[5];
|
||||
float selection;
|
||||
|
||||
CDK_PARAMS params;
|
||||
float high;
|
||||
float inc;
|
||||
float low;
|
||||
|
||||
/* *INDENT-EQLS* */
|
||||
CDKparseParams (argc, argv, ¶ms, "h:i:l:w:" CDK_MIN_PARAMS);
|
||||
high = myFloatParam (¶ms, 'h', 2.4);
|
||||
inc = myFloatParam (¶ms, 'i', 0.2);
|
||||
low = myFloatParam (¶ms, 'l', -1.2);
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start CDK Colors. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Create the scale. */
|
||||
scale = newCDKFScale (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
title, label, A_NORMAL,
|
||||
CDKparamNumber2 (¶ms, 'w', 10),
|
||||
low, low, high,
|
||||
inc, (inc * (float)2.), 1,
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
|
||||
/* Is the scale null? */
|
||||
if (scale == 0)
|
||||
{
|
||||
/* Exit CDK. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Can't make the scale widget. Is the window too small?\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Activate the scale. */
|
||||
selection = activateCDKFScale (scale, 0);
|
||||
|
||||
/* Check the exit value of the scale widget. */
|
||||
if (scale->exitType == vESCAPE_HIT)
|
||||
{
|
||||
mesg[0] = "<C>You hit escape. No value selected.";
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
else if (scale->exitType == vNORMAL)
|
||||
{
|
||||
sprintf (temp, "<C>You selected %f", selection);
|
||||
mesg[0] = temp;
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKFScale (scale);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
326
deps/cdk-5.0-20161210/examples/fselect_ex.c
vendored
Normal file
326
deps/cdk-5.0-20161210/examples/fselect_ex.c
vendored
Normal file
@@ -0,0 +1,326 @@
|
||||
/* $Id: fselect_ex.c,v 1.27 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "fselect_ex";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This program demonstrates the file selector and the viewer widget.
|
||||
*/
|
||||
static CDKSCREEN *cdkscreen = 0;
|
||||
static char **myUserList = 0;
|
||||
static int userSize;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int deleted; /* index in current list which is deleted */
|
||||
int original; /* index in myUserList[] of deleted item */
|
||||
int position; /* position before delete */
|
||||
int topline; /* top-line before delete */
|
||||
} UNDO;
|
||||
|
||||
static UNDO *myUndoList;
|
||||
static int undoSize;
|
||||
|
||||
#define CB_PARAMS EObjectType cdktype GCC_UNUSED, void* object GCC_UNUSED, void* clientdata GCC_UNUSED, chtype key GCC_UNUSED
|
||||
|
||||
static void fill_undo (CDKFSELECT *widget, int deleted, char *data)
|
||||
{
|
||||
int top = getCDKScrollCurrentTop (widget->scrollField);
|
||||
int item = getCDKFselectCurrentItem (widget);
|
||||
int n;
|
||||
|
||||
myUndoList[undoSize].deleted = deleted;
|
||||
myUndoList[undoSize].topline = top;
|
||||
myUndoList[undoSize].original = -1;
|
||||
myUndoList[undoSize].position = item;
|
||||
for (n = 0; n < userSize; ++n)
|
||||
{
|
||||
if (!strcmp (myUserList[n], data))
|
||||
{
|
||||
myUndoList[undoSize].original = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
++undoSize;
|
||||
}
|
||||
|
||||
static int do_delete (CB_PARAMS)
|
||||
{
|
||||
CDKFSELECT *widget = (CDKFSELECT *)clientdata;
|
||||
int size;
|
||||
char **list = getCDKFselectContents (widget, &size);
|
||||
int result = FALSE;
|
||||
|
||||
if (size)
|
||||
{
|
||||
int save = getCDKScrollCurrentTop (widget->scrollField);
|
||||
int first = getCDKFselectCurrentItem (widget);
|
||||
int n;
|
||||
|
||||
fill_undo (widget, first, list[first]);
|
||||
for (n = first; n < size; ++n)
|
||||
list[n] = list[n + 1];
|
||||
setCDKFselectContents (widget, (CDK_CSTRING2)list, size - 1);
|
||||
setCDKScrollCurrentTop (widget->scrollField, save);
|
||||
setCDKFselectCurrentItem (widget, first);
|
||||
drawCDKFselect (widget, BorderOf (widget));
|
||||
result = TRUE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static int do_delete1 (CB_PARAMS)
|
||||
{
|
||||
CDKFSELECT *widget = (CDKFSELECT *)clientdata;
|
||||
int size;
|
||||
char **list = getCDKFselectContents (widget, &size);
|
||||
int result = FALSE;
|
||||
|
||||
if (size)
|
||||
{
|
||||
int save = getCDKScrollCurrentTop (widget->scrollField);
|
||||
int first = getCDKFselectCurrentItem (widget);
|
||||
|
||||
if (first-- > 0)
|
||||
{
|
||||
int n;
|
||||
|
||||
fill_undo (widget, first, list[first]);
|
||||
for (n = first; n < size; ++n)
|
||||
list[n] = list[n + 1];
|
||||
setCDKFselectContents (widget, (CDK_CSTRING2)list, size - 1);
|
||||
setCDKScrollCurrentTop (widget->scrollField, save);
|
||||
setCDKFselectCurrentItem (widget, first);
|
||||
drawCDKFselect (widget, BorderOf (widget));
|
||||
result = TRUE;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static int do_help (CB_PARAMS)
|
||||
{
|
||||
static const char *message[] =
|
||||
{
|
||||
"File Selection tests:",
|
||||
"",
|
||||
"F1 = help (this message)",
|
||||
"F2 = delete current item",
|
||||
"F3 = delete previous item",
|
||||
"F4 = reload all items",
|
||||
"F5 = undo deletion",
|
||||
0
|
||||
};
|
||||
popupLabel (cdkscreen,
|
||||
(CDK_CSTRING2)message,
|
||||
(int)CDKcountStrings ((CDK_CSTRING2)message));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int do_reload (CB_PARAMS)
|
||||
{
|
||||
int result = FALSE;
|
||||
|
||||
if (userSize)
|
||||
{
|
||||
CDKFSELECT *widget = (CDKFSELECT *)clientdata;
|
||||
setCDKFselectContents (widget, (CDK_CSTRING2)myUserList, userSize);
|
||||
setCDKFselectCurrentItem (widget, 0);
|
||||
drawCDKFselect (widget, BorderOf (widget));
|
||||
result = TRUE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static int do_undo (CB_PARAMS)
|
||||
{
|
||||
int result = FALSE;
|
||||
|
||||
if (undoSize > 0)
|
||||
{
|
||||
CDKFSELECT *widget = (CDKFSELECT *)clientdata;
|
||||
int size;
|
||||
int n;
|
||||
char **oldlist = getCDKFselectContents (widget, &size);
|
||||
char **newlist = (char **)malloc ((size_t) (++size + 1) * sizeof (char *));
|
||||
|
||||
--undoSize;
|
||||
newlist[size] = 0;
|
||||
for (n = size - 1; n > myUndoList[undoSize].deleted; --n)
|
||||
{
|
||||
newlist[n] = copyChar (oldlist[n - 1]);
|
||||
}
|
||||
newlist[n--] = copyChar (myUserList[myUndoList[undoSize].original]);
|
||||
while (n >= 0)
|
||||
{
|
||||
newlist[n] = copyChar (oldlist[n]);
|
||||
--n;
|
||||
}
|
||||
setCDKFselectContents (widget, (CDK_CSTRING2)newlist, size);
|
||||
setCDKScrollCurrentTop (widget->scrollField, myUndoList[undoSize].topline);
|
||||
setCDKFselectCurrentItem (widget, myUndoList[undoSize].position);
|
||||
drawCDKFselect (widget, BorderOf (widget));
|
||||
free (newlist);
|
||||
result = TRUE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKVIEWER *example = 0;
|
||||
CDKFSELECT *fSelect = 0;
|
||||
const char *title = "<C>Pick\n<C>A\n<C>File";
|
||||
const char *label = "File: ";
|
||||
char **info = 0;
|
||||
const char *button[5];
|
||||
const char *mesg[4];
|
||||
char *filename;
|
||||
char vTitle[256];
|
||||
char temp[256];
|
||||
int selected, lines;
|
||||
|
||||
CDK_PARAMS params;
|
||||
char *directory;
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, "d:" CDK_CLI_PARAMS);
|
||||
directory = CDKparamString2 (¶ms, 'd', ".");
|
||||
|
||||
/* Create the viewer buttons. */
|
||||
button[0] = "</5><OK><!5>";
|
||||
button[1] = "</5><Cancel><!5>";
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start color. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Get the filename. */
|
||||
fSelect = newCDKFselect (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
CDKparamValue (¶ms, 'H', 20),
|
||||
CDKparamValue (¶ms, 'W', 65),
|
||||
title, label, A_NORMAL, '_', A_REVERSE,
|
||||
"</5>", "</48>", "</N>", "</N>",
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
|
||||
if (fSelect == 0)
|
||||
{
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
fprintf (stderr, "Cannot create widget\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bindCDKObject (vFSELECT, fSelect, '?', do_help, NULL);
|
||||
bindCDKObject (vFSELECT, fSelect, KEY_F1, do_help, NULL);
|
||||
bindCDKObject (vFSELECT, fSelect, KEY_F2, do_delete, fSelect);
|
||||
bindCDKObject (vFSELECT, fSelect, KEY_F3, do_delete1, fSelect);
|
||||
bindCDKObject (vFSELECT, fSelect, KEY_F4, do_reload, fSelect);
|
||||
bindCDKObject (vFSELECT, fSelect, KEY_F5, do_undo, fSelect);
|
||||
|
||||
/*
|
||||
* Set the starting directory. This is not necessary because when
|
||||
* the file selector starts it uses the present directory as a default.
|
||||
*/
|
||||
setCDKFselect (fSelect, directory, A_NORMAL, ' ', A_REVERSE,
|
||||
"</5>", "</48>", "</N>", "</N>", ObjOf (fSelect)->box);
|
||||
myUserList = copyCharList ((const char **)getCDKFselectContents (fSelect, &userSize));
|
||||
myUndoList = (UNDO *) malloc ((size_t) userSize * sizeof (UNDO));
|
||||
undoSize = 0;
|
||||
|
||||
/* Activate the file selector. */
|
||||
filename = activateCDKFselect (fSelect, 0);
|
||||
|
||||
/* Check how the person exited from the widget. */
|
||||
if (fSelect->exitType == vESCAPE_HIT)
|
||||
{
|
||||
/* Pop up a message for the user. */
|
||||
mesg[0] = "<C>Escape hit. No file selected.";
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 3);
|
||||
|
||||
/* Exit CDK. */
|
||||
destroyCDKFselect (fSelect);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/* Create the file viewer to view the file selected. */
|
||||
example = newCDKViewer (cdkscreen, CENTER, CENTER, 20, -2,
|
||||
(CDK_CSTRING2)button, 2, A_REVERSE, TRUE, FALSE);
|
||||
|
||||
/* Could we create the viewer widget? */
|
||||
if (example == 0)
|
||||
{
|
||||
/* Exit CDK. */
|
||||
destroyCDKFselect (fSelect);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Can't seem to create viewer. Is the window too small?\n");
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/* Open the file and read the contents. */
|
||||
lines = CDKreadFile (filename, &info);
|
||||
if (lines == -1)
|
||||
{
|
||||
filename = copyChar (filename);
|
||||
|
||||
destroyCDKFselect (fSelect);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Could not open \"%s\"\n", filename);
|
||||
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Set up the viewer title, and the contents to the widget. */
|
||||
sprintf (vTitle, "<C></B/21>Filename:<!21></22>%20s<!22!B>", filename);
|
||||
setCDKViewer (example, vTitle,
|
||||
(CDK_CSTRING2)info, lines,
|
||||
A_REVERSE, TRUE, TRUE, TRUE);
|
||||
|
||||
CDKfreeStrings (info);
|
||||
|
||||
/* Destroy the file selector widget. */
|
||||
destroyCDKFselect (fSelect);
|
||||
|
||||
/* Activate the viewer widget. */
|
||||
selected = activateCDKViewer (example, 0);
|
||||
|
||||
/* Check how the person exited from the widget. */
|
||||
if (example->exitType == vESCAPE_HIT)
|
||||
{
|
||||
mesg[0] = "<C>Escape hit. No Button selected.";
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 3);
|
||||
}
|
||||
else if (example->exitType == vNORMAL)
|
||||
{
|
||||
sprintf (temp, "<C>You selected button %d", selected);
|
||||
mesg[0] = temp;
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 3);
|
||||
}
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKViewer (example);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
102
deps/cdk-5.0-20161210/examples/fslider_ex.c
vendored
Normal file
102
deps/cdk-5.0-20161210/examples/fslider_ex.c
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
/* $Id: fslider_ex.c,v 1.4 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "slider_ex";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This program demonstrates the Cdk slider widget.
|
||||
*/
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKSCREEN *cdkscreen = 0;
|
||||
CDKFSLIDER *widget = 0;
|
||||
const char *title = "<C></U>Enter a value:";
|
||||
const char *label = "</B>Current Value:";
|
||||
char temp[256];
|
||||
const char *mesg[5];
|
||||
float selection;
|
||||
|
||||
CDK_PARAMS params;
|
||||
double high;
|
||||
double inc;
|
||||
double low;
|
||||
|
||||
double scale;
|
||||
int n, digits;
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, "h:i:l:w:p:" CDK_MIN_PARAMS);
|
||||
digits = CDKparamNumber2 (¶ms, 'p', 0);
|
||||
|
||||
scale = 1.0;
|
||||
for (n = 0; n < digits; ++n)
|
||||
{
|
||||
scale = scale * 10.0;
|
||||
}
|
||||
|
||||
/* *INDENT-EQLS* */
|
||||
high = CDKparamNumber2 (¶ms, 'h', 100) / scale;
|
||||
inc = CDKparamNumber2 (¶ms, 'i', 1) / scale;
|
||||
low = CDKparamNumber2 (¶ms, 'l', 1) / scale;
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start CDK Colors. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Create the widget. */
|
||||
widget = newCDKFSlider (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
title, label,
|
||||
A_REVERSE | COLOR_PAIR (29) | ' ',
|
||||
CDKparamNumber2 (¶ms, 'w', 50),
|
||||
(float)low,
|
||||
(float)low,
|
||||
(float)high,
|
||||
(float)inc,
|
||||
(float)(inc * 2),
|
||||
digits,
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
|
||||
/* Is the widget null? */
|
||||
if (widget == 0)
|
||||
{
|
||||
/* Exit CDK. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot make the widget. Is the window too small?\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Activate the widget. */
|
||||
selection = activateCDKFSlider (widget, 0);
|
||||
|
||||
/* Check the exit value of the widget. */
|
||||
if (widget->exitType == vESCAPE_HIT)
|
||||
{
|
||||
mesg[0] = "<C>You hit escape. No value selected.";
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
else if (widget->exitType == vNORMAL)
|
||||
{
|
||||
sprintf (temp, "<C>You selected %.*f", digits, selection);
|
||||
mesg[0] = temp;
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKFSlider (widget);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
104
deps/cdk-5.0-20161210/examples/graph_ex.c
vendored
Normal file
104
deps/cdk-5.0-20161210/examples/graph_ex.c
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
/* $Id: graph_ex.c,v 1.15 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "graph_ex";
|
||||
#endif
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKSCREEN *cdkscreen = 0;
|
||||
CDKGRAPH *graph = 0;
|
||||
CDKLABEL *pausep = 0;
|
||||
const char *title = 0;
|
||||
const char *xtitle = 0;
|
||||
const char *ytitle = 0;
|
||||
const char *graphChars = 0;
|
||||
const char *mesg[2];
|
||||
int values[20];
|
||||
int count;
|
||||
|
||||
CDK_PARAMS params;
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, CDK_CLI_PARAMS); /* -N, -S unused */
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start CDK Colors. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Create the graph values. */
|
||||
/* *INDENT-EQLS* */
|
||||
values[0] = 10;
|
||||
values[1] = 15;
|
||||
values[2] = 20;
|
||||
values[3] = 25;
|
||||
values[4] = 30;
|
||||
values[5] = 35;
|
||||
values[6] = 40;
|
||||
values[7] = 45;
|
||||
values[8] = 50;
|
||||
values[9] = 55;
|
||||
count = 10;
|
||||
title = "<C>Test Graph";
|
||||
xtitle = "<C>X AXIS TITLE";
|
||||
ytitle = "<C>Y AXIS TITLE";
|
||||
graphChars = "0123456789";
|
||||
|
||||
/* Create the label values. */
|
||||
mesg[0] = "Press any key when done viewing the graph.";
|
||||
|
||||
/* Create the graph widget. */
|
||||
graph = newCDKGraph (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
CDKparamValue (¶ms, 'H', 10),
|
||||
CDKparamValue (¶ms, 'W', 20),
|
||||
title, xtitle, ytitle);
|
||||
|
||||
/* Is the graph null? */
|
||||
if (graph == 0)
|
||||
{
|
||||
/* Shut down CDK. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot make the graph widget. Is the window too small?\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Create the label widget. */
|
||||
pausep = newCDKLabel (cdkscreen, CENTER, BOTTOM,
|
||||
(CDK_CSTRING2) mesg, 1,
|
||||
TRUE, FALSE);
|
||||
if (pausep == 0)
|
||||
{
|
||||
/* Shut down CDK. */
|
||||
destroyCDKGraph (graph);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot make the label widget. Is the window too small?\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Set the graph values. */
|
||||
setCDKGraph (graph, values, count, graphChars, FALSE, vPLOT);
|
||||
|
||||
/* Draw the screen. */
|
||||
refreshCDKScreen (cdkscreen);
|
||||
drawCDKGraph (graph, FALSE);
|
||||
drawCDKLabel (pausep, TRUE);
|
||||
|
||||
/* Pause until the user says so... */
|
||||
waitCDKLabel (pausep, 0);
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKGraph (graph);
|
||||
destroyCDKLabel (pausep);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
61
deps/cdk-5.0-20161210/examples/hello_ex.c
vendored
Normal file
61
deps/cdk-5.0-20161210/examples/hello_ex.c
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
/* $Id: hello_ex.c,v 1.12 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "hello_ex";
|
||||
#endif
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
CDKSCREEN *cdkscreen;
|
||||
CDKLABEL *demo;
|
||||
const char *mesg[4];
|
||||
|
||||
CDK_PARAMS params;
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, CDK_MIN_PARAMS);
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start CDK Colors. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Set the labels up. */
|
||||
mesg[0] = "</5><#UL><#HL(30)><#UR>";
|
||||
mesg[1] = "</5><#VL(10)>Hello World!<#VL(10)>";
|
||||
mesg[2] = "</5><#LL><#HL(30)><#LR>";
|
||||
|
||||
/* Declare the labels. */
|
||||
demo = newCDKLabel (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
(CDK_CSTRING2) mesg, 3,
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', TRUE));
|
||||
|
||||
/* Is the label null? */
|
||||
if (demo == 0)
|
||||
{
|
||||
/* Clean up the memory. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
|
||||
/* End curses... */
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot create the label. Is the window too small?\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
setCDKLabelBackgroundAttrib (demo, COLOR_PAIR (2));
|
||||
|
||||
/* Draw the CDK screen. */
|
||||
refreshCDKScreen (cdkscreen);
|
||||
waitCDKLabel (demo, ' ');
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKLabel (demo);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
144
deps/cdk-5.0-20161210/examples/histogram_ex.c
vendored
Normal file
144
deps/cdk-5.0-20161210/examples/histogram_ex.c
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
/* $Id: histogram_ex.c,v 1.12 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "histogram_ex";
|
||||
#endif
|
||||
|
||||
#if !defined (HAVE_SLEEP) && defined (_WIN32) /* Mingw */
|
||||
#define sleep(x) _sleep(x*1000)
|
||||
#endif
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKSCREEN *cdkscreen = 0;
|
||||
CDKHISTOGRAM *volume = 0;
|
||||
CDKHISTOGRAM *bass = 0;
|
||||
CDKHISTOGRAM *treble = 0;
|
||||
const char *volumeTitle = "<C></5>Volume<!5>";
|
||||
const char *bassTitle = "<C></5>Bass <!5>";
|
||||
const char *trebleTitle = "<C></5>Treble<!5>";
|
||||
|
||||
CDK_PARAMS params;
|
||||
boolean Box;
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, CDK_CLI_PARAMS);
|
||||
Box = CDKparamValue (¶ms, 'N', TRUE);
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start CDK Color. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Create the histogram objects. */
|
||||
volume = newCDKHistogram (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', 10),
|
||||
CDKparamValue (¶ms, 'Y', 10),
|
||||
CDKparamValue (¶ms, 'H', 1),
|
||||
CDKparamValue (¶ms, 'W', -2),
|
||||
HORIZONTAL, volumeTitle,
|
||||
Box,
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
if (volume == 0)
|
||||
{
|
||||
/* Exit CDK. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot make volume histogram. Is the window big enough??\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bass = newCDKHistogram (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', 10),
|
||||
CDKparamValue (¶ms, 'Y', 14),
|
||||
CDKparamValue (¶ms, 'H', 1),
|
||||
CDKparamValue (¶ms, 'W', -2),
|
||||
HORIZONTAL, bassTitle,
|
||||
Box,
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
if (bass == 0)
|
||||
{
|
||||
/* Exit CDK. */
|
||||
destroyCDKHistogram (volume);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot make bass histogram. Is the window big enough??\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
treble = newCDKHistogram (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', 10),
|
||||
CDKparamValue (¶ms, 'Y', 18),
|
||||
CDKparamValue (¶ms, 'H', 1),
|
||||
CDKparamValue (¶ms, 'W', -2),
|
||||
HORIZONTAL, trebleTitle,
|
||||
Box,
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
if (treble == 0)
|
||||
{
|
||||
/* Exit CDK. */
|
||||
destroyCDKHistogram (volume);
|
||||
destroyCDKHistogram (bass);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot make treble histogram. Is the window big enough??\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
#define BAR(a,b,c) A_BOLD, a, b, c, ' '|A_REVERSE|COLOR_PAIR(3), Box
|
||||
|
||||
/* Set the histogram values. */
|
||||
setCDKHistogram (volume, vPERCENT, CENTER, BAR (0, 10, 6));
|
||||
setCDKHistogram (bass, vPERCENT, CENTER, BAR (0, 10, 3));
|
||||
setCDKHistogram (treble, vPERCENT, CENTER, BAR (0, 10, 7));
|
||||
refreshCDKScreen (cdkscreen);
|
||||
sleep (4);
|
||||
|
||||
/* Set the histogram values. */
|
||||
setCDKHistogram (volume, vPERCENT, CENTER, BAR (0, 10, 8));
|
||||
setCDKHistogram (bass, vPERCENT, CENTER, BAR (0, 10, 1));
|
||||
setCDKHistogram (treble, vPERCENT, CENTER, BAR (0, 10, 9));
|
||||
refreshCDKScreen (cdkscreen);
|
||||
sleep (4);
|
||||
|
||||
/* Set the histogram values. */
|
||||
setCDKHistogram (volume, vPERCENT, CENTER, BAR (0, 10, 10));
|
||||
setCDKHistogram (bass, vPERCENT, CENTER, BAR (0, 10, 7));
|
||||
setCDKHistogram (treble, vPERCENT, CENTER, BAR (0, 10, 10));
|
||||
refreshCDKScreen (cdkscreen);
|
||||
sleep (4);
|
||||
|
||||
/* Set the histogram values. */
|
||||
setCDKHistogram (volume, vPERCENT, CENTER, BAR (0, 10, 1));
|
||||
setCDKHistogram (bass, vPERCENT, CENTER, BAR (0, 10, 8));
|
||||
setCDKHistogram (treble, vPERCENT, CENTER, BAR (0, 10, 3));
|
||||
refreshCDKScreen (cdkscreen);
|
||||
sleep (4);
|
||||
|
||||
/* Set the histogram values. */
|
||||
setCDKHistogram (volume, vPERCENT, CENTER, BAR (0, 10, 3));
|
||||
setCDKHistogram (bass, vPERCENT, CENTER, BAR (0, 10, 3));
|
||||
setCDKHistogram (treble, vPERCENT, CENTER, BAR (0, 10, 3));
|
||||
refreshCDKScreen (cdkscreen);
|
||||
sleep (4);
|
||||
|
||||
/* Set the histogram values. */
|
||||
setCDKHistogram (volume, vPERCENT, CENTER, BAR (0, 10, 10));
|
||||
setCDKHistogram (bass, vPERCENT, CENTER, BAR (0, 10, 10));
|
||||
setCDKHistogram (treble, vPERCENT, CENTER, BAR (0, 10, 10));
|
||||
refreshCDKScreen (cdkscreen);
|
||||
sleep (4);
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKHistogram (volume);
|
||||
destroyCDKHistogram (bass);
|
||||
destroyCDKHistogram (treble);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
121
deps/cdk-5.0-20161210/examples/itemlist_ex.c
vendored
Normal file
121
deps/cdk-5.0-20161210/examples/itemlist_ex.c
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
/* $Id: itemlist_ex.c,v 1.15 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "itemlist_ex";
|
||||
#endif
|
||||
|
||||
#define MONTHS 12
|
||||
|
||||
/*
|
||||
* This program demonstrates the Cdk itemlist widget.
|
||||
*
|
||||
* Options (in addition to minimal CLI parameters):
|
||||
* -c create the data after the widget
|
||||
*/
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKSCREEN *cdkscreen = 0;
|
||||
CDKITEMLIST *monthlist = 0;
|
||||
const char *title = "<C>Pick A Month";
|
||||
const char *label = "</U/5>Month:";
|
||||
const char *info[MONTHS];
|
||||
const char *mesg[10];
|
||||
char temp[256];
|
||||
int choice, startMonth;
|
||||
struct tm *dateInfo;
|
||||
time_t clck;
|
||||
|
||||
CDK_PARAMS params;
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, "c" CDK_MIN_PARAMS);
|
||||
|
||||
/*
|
||||
* Get the current date and set the default month to the
|
||||
* current month.
|
||||
*/
|
||||
time (&clck);
|
||||
dateInfo = localtime (&clck);
|
||||
startMonth = dateInfo->tm_mon;
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start CDK colors. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Create the choice list. */
|
||||
/* *INDENT-EQLS* */
|
||||
info[0] = "<C></5>January";
|
||||
info[1] = "<C></5>February";
|
||||
info[2] = "<C></B/19>March";
|
||||
info[3] = "<C></5>April";
|
||||
info[4] = "<C></5>May";
|
||||
info[5] = "<C></K/5>June";
|
||||
info[6] = "<C></12>July";
|
||||
info[7] = "<C></5>August";
|
||||
info[8] = "<C></5>September";
|
||||
info[9] = "<C></32>October";
|
||||
info[10] = "<C></5>November";
|
||||
info[11] = "<C></11>December";
|
||||
|
||||
/* Create the itemlist widget. */
|
||||
monthlist = newCDKItemlist (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
title,
|
||||
label,
|
||||
(CDKparamNumber (¶ms, 'c')
|
||||
? 0
|
||||
: (CDK_CSTRING2) info),
|
||||
(CDKparamNumber (¶ms, 'c')
|
||||
? 0
|
||||
: MONTHS),
|
||||
startMonth,
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
|
||||
/* Is the widget null? */
|
||||
if (monthlist == 0)
|
||||
{
|
||||
/* Clean up. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot create the itemlist box. Is the window too small?\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (CDKparamNumber (¶ms, 'c'))
|
||||
{
|
||||
setCDKItemlistValues (monthlist, (CDK_CSTRING2) info, MONTHS, 0);
|
||||
}
|
||||
|
||||
/* Activate the widget. */
|
||||
choice = activateCDKItemlist (monthlist, 0);
|
||||
|
||||
/* Check how they exited from the widget. */
|
||||
if (monthlist->exitType == vESCAPE_HIT)
|
||||
{
|
||||
mesg[0] = "<C>You hit escape. No item selected.";
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (ScreenOf (monthlist), (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
else if (monthlist->exitType == vNORMAL)
|
||||
{
|
||||
sprintf (temp, "<C>You selected the %dth item which is", choice);
|
||||
mesg[0] = temp;
|
||||
mesg[1] = info[choice];
|
||||
mesg[2] = "";
|
||||
mesg[3] = "<C>Press any key to continue.";
|
||||
popupLabel (ScreenOf (monthlist), (CDK_CSTRING2) mesg, 4);
|
||||
}
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKItemlist (monthlist);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
60
deps/cdk-5.0-20161210/examples/label_ex.c
vendored
Normal file
60
deps/cdk-5.0-20161210/examples/label_ex.c
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
/* $Id: label_ex.c,v 1.11 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "label_ex";
|
||||
#endif
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
CDKSCREEN *cdkscreen;
|
||||
CDKLABEL *demo;
|
||||
const char *mesg[10];
|
||||
|
||||
CDK_PARAMS params;
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, CDK_MIN_PARAMS);
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start CDK Colors. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Set the labels up. */
|
||||
mesg[0] = "</29/B>This line should have a yellow foreground and a blue background.";
|
||||
mesg[1] = "</5/B>This line should have a white foreground and a blue background.";
|
||||
mesg[2] = "</26/B>This line should have a yellow foreground and a red background.";
|
||||
mesg[3] = "<C>This line should be set to whatever the screen default is.";
|
||||
|
||||
/* Declare the labels. */
|
||||
demo = newCDKLabel (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
(CDK_CSTRING2) mesg, 4,
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', TRUE));
|
||||
|
||||
/* Is the label null? */
|
||||
if (demo == 0)
|
||||
{
|
||||
/* Clean up the memory. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
|
||||
/* End curses... */
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot create the label. Is the window too small?\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Draw the CDK screen. */
|
||||
refreshCDKScreen (cdkscreen);
|
||||
waitCDKLabel (demo, ' ');
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKLabel (demo);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
83
deps/cdk-5.0-20161210/examples/lowerCDKObject_ex.c
vendored
Normal file
83
deps/cdk-5.0-20161210/examples/lowerCDKObject_ex.c
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
/* $Id: lowerCDKObject_ex.c,v 1.10 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "lowerCDKObject_ex";
|
||||
#endif
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
char ch;
|
||||
|
||||
const char *mesg[1];
|
||||
const char *mesg1[10];
|
||||
const char *mesg2[10];
|
||||
|
||||
CDKSCREEN *cdkscreen;
|
||||
CDKLABEL *label1, *label2, *instruct;
|
||||
|
||||
CDK_PARAMS params;
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, CDK_MIN_PARAMS);
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
mesg1[0] = "label1 label1 label1 label1 label1 label1 label1";
|
||||
mesg1[1] = "label1 label1 label1 label1 label1 label1 label1";
|
||||
mesg1[2] = "label1 label1 label1 label1 label1 label1 label1";
|
||||
mesg1[3] = "label1 label1 label1 label1 label1 label1 label1";
|
||||
mesg1[4] = "label1 label1 label1 label1 label1 label1 label1";
|
||||
mesg1[5] = "label1 label1 label1 label1 label1 label1 label1";
|
||||
mesg1[6] = "label1 label1 label1 label1 label1 label1 label1";
|
||||
mesg1[7] = "label1 label1 label1 label1 label1 label1 label1";
|
||||
mesg1[8] = "label1 label1 label1 label1 label1 label1 label1";
|
||||
mesg1[9] = "label1 label1 label1 label1 label1 label1 label1";
|
||||
label1 = newCDKLabel (cdkscreen, 8, 5, (CDK_CSTRING2) mesg1, 10, TRUE, FALSE);
|
||||
|
||||
mesg2[0] = "label2 label2 label2 label2 label2 label2 label2";
|
||||
mesg2[1] = "label2 label2 label2 label2 label2 label2 label2";
|
||||
mesg2[2] = "label2 label2 label2 label2 label2 label2 label2";
|
||||
mesg2[3] = "label2 label2 label2 label2 label2 label2 label2";
|
||||
mesg2[4] = "label2 label2 label2 label2 label2 label2 label2";
|
||||
mesg2[5] = "label2 label2 label2 label2 label2 label2 label2";
|
||||
mesg2[6] = "label2 label2 label2 label2 label2 label2 label2";
|
||||
mesg2[7] = "label2 label2 label2 label2 label2 label2 label2";
|
||||
mesg2[8] = "label2 label2 label2 label2 label2 label2 label2";
|
||||
mesg2[9] = "label2 label2 label2 label2 label2 label2 label2";
|
||||
label2 = newCDKLabel (cdkscreen, 14, 9, (CDK_CSTRING2) mesg2, 10, TRUE, FALSE);
|
||||
|
||||
mesg[0] = "</B>1<!B> - lower </U>label1<!U>, </B>2<!B> - lower </U>label2<!U>, </B>q<!B> - </U>quit<!U>";
|
||||
instruct = newCDKLabel (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', BOTTOM),
|
||||
(CDK_CSTRING2) mesg, 1,
|
||||
CDKparamValue (¶ms, 'N', FALSE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
|
||||
refreshCDKScreen (cdkscreen);
|
||||
|
||||
while ((ch = (char)getch ()) != 'q')
|
||||
{
|
||||
switch (ch)
|
||||
{
|
||||
case '1':
|
||||
lowerCDKObject (vLABEL, label1);
|
||||
break;
|
||||
case '2':
|
||||
lowerCDKObject (vLABEL, label2);
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
refreshCDKScreen (cdkscreen);
|
||||
}
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKLabel (label1);
|
||||
destroyCDKLabel (label2);
|
||||
destroyCDKLabel (instruct);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
162
deps/cdk-5.0-20161210/examples/marquee_ex.c
vendored
Normal file
162
deps/cdk-5.0-20161210/examples/marquee_ex.c
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
/* $Id: marquee_ex.c,v 1.13 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "marquee_ex";
|
||||
#endif
|
||||
|
||||
static char startAttr[100];
|
||||
static char endAttr[100];
|
||||
|
||||
/*
|
||||
* This spits out help about this demo program.
|
||||
*/
|
||||
static void help (char *programName)
|
||||
{
|
||||
const char *USAGE = "[-m Message] [-R repeat value] [-d delay value] [-b|r|u|k] [-h]";
|
||||
|
||||
printf ("Usage: %s %s\n", programName, USAGE);
|
||||
printf (" -m TEXT Sets the message to display in the marquee\n");
|
||||
printf (" If no message is provided, one will be created.\n");
|
||||
printf (" -R COUNT Repeat the message the given COUNT.\n");
|
||||
printf (" A of -1 repeats the message forever.\n");
|
||||
printf (" -d COUNT number of milliseconds to delay between repeats.\n");
|
||||
printf (" -b display the message with the bold attribute.\n");
|
||||
printf (" -r display the message with a reversed attribute.\n");
|
||||
printf (" -u display the message with an underline attribute.\n");
|
||||
printf (" -k display the message with the blinking attribute.\n");
|
||||
}
|
||||
|
||||
static void myParseAttr (CDK_PARAMS * params, int lower, int upper)
|
||||
{
|
||||
if (CDKparamString (params, lower) != 0)
|
||||
{
|
||||
char starting[3];
|
||||
char ending[3];
|
||||
|
||||
if (startAttr[0] == '\0')
|
||||
{
|
||||
startAttr[0] = '<';
|
||||
endAttr[0] = '<';
|
||||
}
|
||||
sprintf (starting, "/%c", upper);
|
||||
sprintf (ending, "!%c", upper);
|
||||
strcat (startAttr, starting);
|
||||
strcat (endAttr, ending);
|
||||
}
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
CDKSCREEN *cdkscreen;
|
||||
CDKMARQUEE *scrollMessage;
|
||||
char message[1024];
|
||||
time_t clck;
|
||||
|
||||
CDK_PARAMS params;
|
||||
char *mesg;
|
||||
int delay;
|
||||
int repeat;
|
||||
/* *INDENT-ON* */
|
||||
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, "brkud:R:m:hw:" CDK_MIN_PARAMS);
|
||||
myParseAttr (¶ms, 'b', 'B');
|
||||
myParseAttr (¶ms, 'r', 'R');
|
||||
myParseAttr (¶ms, 'k', 'K');
|
||||
myParseAttr (¶ms, 'u', 'U');
|
||||
repeat = CDKparamNumber2 (¶ms, 'R', 3);
|
||||
delay = CDKparamNumber2 (¶ms, 'd', 5);
|
||||
mesg = CDKparamString (¶ms, 'm');
|
||||
|
||||
if (CDKparamString (¶ms, 'h') != 0)
|
||||
help (argv[0]);
|
||||
|
||||
/* Clean up the strings. */
|
||||
cleanChar (message, sizeof (message), '\0');
|
||||
cleanChar (startAttr, sizeof (startAttr), '\0');
|
||||
cleanChar (endAttr, sizeof (endAttr), '\0');
|
||||
|
||||
/* Put the end of the attributes if they asked for then. */
|
||||
if (startAttr[0] == '<')
|
||||
{
|
||||
strcat (startAttr, ">");
|
||||
strcat (endAttr, ">");
|
||||
}
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
curs_set (0);
|
||||
|
||||
/* Start CDK Colors. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Create the marquee. */
|
||||
scrollMessage = newCDKMarquee (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', TOP),
|
||||
CDKparamValue (¶ms, 'w', 30),
|
||||
CDKparamValue (¶ms, 'N', FALSE),
|
||||
CDKparamValue (¶ms, 'S', TRUE));
|
||||
|
||||
/* Check if the marquee is null. */
|
||||
if (scrollMessage == 0)
|
||||
{
|
||||
/* Exit Cdk. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot create the marquee window. Is the window too small?\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Draw the CDK screen. */
|
||||
refreshCDKScreen (cdkscreen);
|
||||
|
||||
/* Create the marquee message. */
|
||||
if (mesg == 0)
|
||||
{
|
||||
char *currentTime;
|
||||
|
||||
/* Get the current time and chop off the newline. */
|
||||
time (&clck);
|
||||
currentTime = ctime (&clck);
|
||||
currentTime[strlen (currentTime) - 1] = 0;
|
||||
|
||||
if (startAttr[0] != '\0')
|
||||
{
|
||||
currentTime[strlen (currentTime) - 1] = '\0';
|
||||
sprintf (message, "%s%s%s (This Space For Rent) ",
|
||||
startAttr,
|
||||
currentTime,
|
||||
endAttr);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (message, "%s (This Space For Rent) ", currentTime);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (startAttr[0] != '\0')
|
||||
{
|
||||
sprintf (message, "%s%s%s ", startAttr, mesg, endAttr);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (message, "%s ", mesg);
|
||||
}
|
||||
}
|
||||
|
||||
/* Run the marquee. */
|
||||
activateCDKMarquee (scrollMessage, message, delay, repeat, TRUE);
|
||||
activateCDKMarquee (scrollMessage, message, delay, repeat, FALSE);
|
||||
activateCDKMarquee (scrollMessage, message, delay, repeat, TRUE);
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKMarquee (scrollMessage);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
147
deps/cdk-5.0-20161210/examples/matrix_ex.c
vendored
Normal file
147
deps/cdk-5.0-20161210/examples/matrix_ex.c
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
/* $Id: matrix_ex.c,v 1.19 2016/12/10 13:29:08 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "matrix_ex";
|
||||
#endif
|
||||
|
||||
#define MY_COLS 10
|
||||
|
||||
/*
|
||||
* This program demonstrates the Cdk matrix widget.
|
||||
*/
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKSCREEN *cdkscreen = 0;
|
||||
CDKMATRIX *courseList = 0;
|
||||
const char *title = 0;
|
||||
int rows = 8;
|
||||
int cols = 5;
|
||||
int vrows = 3;
|
||||
int vcols = 5;
|
||||
|
||||
bool use_coltitles;
|
||||
bool use_rowtitles;
|
||||
|
||||
const char *coltitle[MY_COLS];
|
||||
const char *rowtitle[MY_COLS];
|
||||
const char *mesg[MY_COLS];
|
||||
|
||||
int colwidth[MY_COLS];
|
||||
int colvalue[MY_COLS];
|
||||
|
||||
int col_spacing;
|
||||
int row_spacing;
|
||||
|
||||
CDK_PARAMS params;
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, "trcT:C:R:" CDK_MIN_PARAMS);
|
||||
|
||||
/* invert, so giving -S causes the shadow to turn off */
|
||||
params.Shadow = !params.Shadow;
|
||||
|
||||
/* cancel the default title, or supply a new one */
|
||||
if (CDKparamValue (¶ms, 't', FALSE))
|
||||
{
|
||||
title = 0;
|
||||
}
|
||||
else if ((title = CDKparamString (¶ms, 'T')) == 0)
|
||||
{
|
||||
title = "<C>This is the CDK\n<C>matrix widget.\n<C><#LT><#HL(30)><#RT>";
|
||||
}
|
||||
|
||||
/* allow cancelling of column and/or row titles with -c and/or -r */
|
||||
use_coltitles = !CDKparamValue (¶ms, 'c', FALSE);
|
||||
use_rowtitles = !CDKparamValue (¶ms, 'r', FALSE);
|
||||
col_spacing = CDKparamNumber2 (¶ms, 'C', -1);
|
||||
row_spacing = CDKparamNumber2 (¶ms, 'R', -1);
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start CDK Colors. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Create the horizontal and vertical matrix labels. */
|
||||
#define set_col(n, width, string) \
|
||||
coltitle[n] = use_coltitles ? string : 0 ;\
|
||||
colwidth[n] = width ;\
|
||||
colvalue[n] = vUMIXED
|
||||
|
||||
set_col (1, 7, "</B/5>Course");
|
||||
set_col (2, 7, "</B/33>Lec 1");
|
||||
set_col (3, 7, "</B/33>Lec 2");
|
||||
set_col (4, 7, "</B/33>Lec 3");
|
||||
set_col (5, 1, "</B/7>Flag");
|
||||
|
||||
#define set_row(n, string) \
|
||||
rowtitle[n] = use_rowtitles ? "<C></B/6>" string : 0
|
||||
|
||||
set_row (1, "Course 1");
|
||||
set_row (2, "Course 2");
|
||||
set_row (3, "Course 3");
|
||||
set_row (4, "Course 4");
|
||||
set_row (5, "Course 5");
|
||||
set_row (6, "Course 6");
|
||||
set_row (7, "Course 7");
|
||||
set_row (8, "Course 8");
|
||||
|
||||
/* Create the matrix object. */
|
||||
courseList = newCDKMatrix (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
rows, cols, vrows, vcols,
|
||||
title,
|
||||
(CDK_CSTRING2)rowtitle,
|
||||
(CDK_CSTRING2)coltitle,
|
||||
colwidth, colvalue,
|
||||
col_spacing, row_spacing, '.',
|
||||
COL, params.Box,
|
||||
params.Box,
|
||||
params.Shadow);
|
||||
|
||||
/* Check to see if the matrix is null. */
|
||||
if (courseList == 0)
|
||||
{
|
||||
/* Clean up. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot create the matrix widget.\n");
|
||||
printf ("Is the window too small ?\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Activate the matrix. */
|
||||
activateCDKMatrix (courseList, 0);
|
||||
|
||||
/* Check if the user hit escape or not. */
|
||||
if (courseList->exitType == vESCAPE_HIT)
|
||||
{
|
||||
mesg[0] = "<C>You hit escape. No information passed back.";
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 3);
|
||||
}
|
||||
else if (courseList->exitType == vNORMAL)
|
||||
{
|
||||
char temp[80];
|
||||
|
||||
sprintf (temp, "Current cell (%d,%d)", courseList->crow, courseList->ccol);
|
||||
mesg[0] = "<L>You exited the matrix normally.";
|
||||
mesg[1] = temp;
|
||||
mesg[2] = "<L>To get the contents of the matrix cell, you can";
|
||||
mesg[3] = "<L>use getCDKMatrixCell():";
|
||||
mesg[4] = getCDKMatrixCell (courseList, courseList->crow, courseList->ccol);
|
||||
mesg[5] = "";
|
||||
mesg[6] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 7);
|
||||
}
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKMatrix (courseList);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
69
deps/cdk-5.0-20161210/examples/mentry_ex.c
vendored
Normal file
69
deps/cdk-5.0-20161210/examples/mentry_ex.c
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
/* $Id: mentry_ex.c,v 1.11 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "mentry_ex";
|
||||
#endif
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKSCREEN *cdkscreen = 0;
|
||||
CDKMENTRY *widget = 0;
|
||||
char *info = 0;
|
||||
const char *label = "</R>Message";
|
||||
const char *title = "<C></5>Enter a message.<!5>";
|
||||
|
||||
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. */
|
||||
widget = newCDKMentry (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
title, label, A_BOLD, '.', vMIXED,
|
||||
CDKparamValue (¶ms, 'w', 20),
|
||||
CDKparamValue (¶ms, 'h', 5),
|
||||
CDKparamValue (¶ms, 'l', 20),
|
||||
0,
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
|
||||
/* Is the object null? */
|
||||
if (widget == 0)
|
||||
{
|
||||
/* Shut down CDK. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot create CDK object. Is the window too small?\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Draw the CDK screen. */
|
||||
refreshCDKScreen (cdkscreen);
|
||||
|
||||
/* Set what ever was given from the command line. */
|
||||
setCDKMentry (widget, argv[optind], 0, TRUE);
|
||||
|
||||
/* Activate this thing. */
|
||||
activateCDKMentry (widget, 0);
|
||||
info = strdup (widget->info);
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKMentry (widget);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("\n\n\n");
|
||||
printf ("Your message was : <%s>\n", info);
|
||||
free (info);
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
159
deps/cdk-5.0-20161210/examples/menu_ex.c
vendored
Normal file
159
deps/cdk-5.0-20161210/examples/menu_ex.c
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
/* $Id: menu_ex.c,v 1.13 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "menu_ex";
|
||||
#endif
|
||||
|
||||
static int displayCallback (EObjectType cdktype, void *object,
|
||||
void *clientData,
|
||||
chtype input);
|
||||
static const char *menulist[MAX_MENU_ITEMS][MAX_SUB_ITEMS];
|
||||
static const char *menuInfo[3][4] =
|
||||
{
|
||||
{
|
||||
"",
|
||||
"This saves the current info.",
|
||||
"This exits the program.",
|
||||
""
|
||||
},
|
||||
{
|
||||
"",
|
||||
"This cuts text",
|
||||
"This copies text",
|
||||
"This pastes text"
|
||||
},
|
||||
{
|
||||
"",
|
||||
"Help for editing",
|
||||
"Help for file management",
|
||||
"Info about the program"}
|
||||
};
|
||||
|
||||
/*
|
||||
* This program demonstratres the Cdk menu widget.
|
||||
*/
|
||||
int main (void)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKSCREEN *cdkscreen = 0;
|
||||
CDKLABEL *infoBox = 0;
|
||||
CDKMENU *menu = 0;
|
||||
int submenusize[3], menuloc[4];
|
||||
const char *mesg[5];
|
||||
char temp[256];
|
||||
int selection;
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start CDK color. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Set up the menu. */
|
||||
menulist[0][0] = "</B>File<!B>";
|
||||
menulist[0][1] = "</B>Save<!B>";
|
||||
menulist[0][2] = "</B>Exit<!B>";
|
||||
|
||||
menulist[1][0] = "</B>Edit<!B>";
|
||||
menulist[1][1] = "</B>Cut<!B> ";
|
||||
menulist[1][2] = "</B>Copy<!B>";
|
||||
menulist[1][3] = "</B>Paste<!B>";
|
||||
|
||||
menulist[2][0] = "</B>Help<!B>";
|
||||
menulist[2][1] = "</B>On Edit <!B>";
|
||||
menulist[2][2] = "</B>On File <!B>";
|
||||
menulist[2][3] = "</B>About...<!B>";
|
||||
|
||||
submenusize[0] = 3;
|
||||
submenusize[1] = 4;
|
||||
submenusize[2] = 4;
|
||||
|
||||
menuloc[0] = LEFT;
|
||||
menuloc[1] = LEFT;
|
||||
menuloc[2] = RIGHT;
|
||||
|
||||
/* Create the label window. */
|
||||
mesg[0] = " ";
|
||||
mesg[1] = " ";
|
||||
mesg[2] = " ";
|
||||
mesg[3] = " ";
|
||||
infoBox = newCDKLabel (cdkscreen, CENTER, CENTER,
|
||||
(CDK_CSTRING2) mesg, 4,
|
||||
TRUE, TRUE);
|
||||
|
||||
/* Create the menu. */
|
||||
menu = newCDKMenu (cdkscreen, menulist, 3, submenusize, menuloc,
|
||||
TOP, A_UNDERLINE, A_REVERSE);
|
||||
|
||||
/* Create the post process function. */
|
||||
setCDKMenuPostProcess (menu, displayCallback, infoBox);
|
||||
|
||||
/* Draw the CDK screen. */
|
||||
refreshCDKScreen (cdkscreen);
|
||||
|
||||
/* Activate the menu. */
|
||||
selection = activateCDKMenu (menu, 0);
|
||||
|
||||
/* Determine how the user exited from the widget. */
|
||||
if (menu->exitType == vEARLY_EXIT)
|
||||
{
|
||||
mesg[0] = "<C>You hit escape. No menu item was selected.";
|
||||
mesg[1] = "",
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
else if (menu->exitType == vNORMAL)
|
||||
{
|
||||
sprintf (temp, "<C>You selected menu #%d, submenu #%d",
|
||||
selection / 100,
|
||||
selection % 100);
|
||||
mesg[0] = temp;
|
||||
mesg[1] = "",
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKMenu (menu);
|
||||
destroyCDKLabel (infoBox);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* This gets called after every movement.
|
||||
*/
|
||||
static int displayCallback (EObjectType cdktype GCC_UNUSED, void *object,
|
||||
void *clientData,
|
||||
chtype input GCC_UNUSED)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKMENU *menu = (CDKMENU *)object;
|
||||
CDKLABEL *infoBox = (CDKLABEL *)clientData;
|
||||
char *mesg[10];
|
||||
char temp[256];
|
||||
|
||||
/* Recreate the label message. */
|
||||
sprintf (temp, "Title: %.*s",
|
||||
(int)(sizeof (temp) - 20),
|
||||
menulist[menu->currentTitle][0]);
|
||||
mesg[0] = strdup (temp);
|
||||
sprintf (temp, "Sub-Title: %.*s",
|
||||
(int)(sizeof (temp) - 20),
|
||||
menulist[menu->currentTitle][menu->currentSubtitle + 1]);
|
||||
mesg[1] = strdup (temp);
|
||||
mesg[2] = strdup ("");
|
||||
sprintf (temp, "<C>%.*s",
|
||||
(int)(sizeof (temp) - 20),
|
||||
menuInfo[menu->currentTitle][menu->currentSubtitle + 1]);
|
||||
mesg[3] = strdup (temp);
|
||||
|
||||
/* Set the message of the label. */
|
||||
setCDKLabel (infoBox, (CDK_CSTRING2) mesg, 4, TRUE);
|
||||
drawCDKLabel (infoBox, TRUE);
|
||||
|
||||
freeCharList (mesg, 4);
|
||||
return 0;
|
||||
}
|
82
deps/cdk-5.0-20161210/examples/position_ex.c
vendored
Normal file
82
deps/cdk-5.0-20161210/examples/position_ex.c
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
/* $Id: position_ex.c,v 1.15 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "position_ex";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This demonstrates the positioning of a Cdk entry field widget.
|
||||
*/
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKSCREEN *cdkscreen = 0;
|
||||
CDKENTRY *directory = 0;
|
||||
const char *label = "</U/5>Directory:<!U!5> ";
|
||||
char *info = 0;
|
||||
const char *mesg[10];
|
||||
char temp[256];
|
||||
|
||||
CDK_PARAMS params;
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, "w:" CDK_MIN_PARAMS);
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start CDK colors. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Create the entry field widget. */
|
||||
directory = newCDKEntry (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
0, label, A_NORMAL, '.', vMIXED,
|
||||
CDKparamValue (¶ms, 'w', 40),
|
||||
0, 256,
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
|
||||
/* Is the widget null? */
|
||||
if (directory == 0)
|
||||
{
|
||||
/* Clean up. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot create the entry box. Is the window too small?\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Let the user move the widget around the window. */
|
||||
drawCDKEntry (directory, ObjOf (directory)->box);
|
||||
positionCDKEntry (directory);
|
||||
|
||||
/* Activate the entry field. */
|
||||
info = activateCDKEntry (directory, 0);
|
||||
|
||||
/* Tell them what they typed. */
|
||||
if (directory->exitType == vESCAPE_HIT)
|
||||
{
|
||||
mesg[0] = "<C>You hit escape. No information passed back.";
|
||||
mesg[1] = "",
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
else if (directory->exitType == vNORMAL)
|
||||
{
|
||||
mesg[0] = "<C>You typed in the following";
|
||||
sprintf (temp, "<C>(%.*s)", (int)(sizeof (temp) - 20), info);
|
||||
mesg[1] = temp;
|
||||
mesg[2] = "";
|
||||
mesg[3] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 4);
|
||||
}
|
||||
|
||||
/* Clean up and exit. */
|
||||
destroyCDKEntry (directory);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
108
deps/cdk-5.0-20161210/examples/preprocess_ex.c
vendored
Normal file
108
deps/cdk-5.0-20161210/examples/preprocess_ex.c
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
/* $Id: preprocess_ex.c,v 1.20 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "preprocess_ex";
|
||||
#endif
|
||||
|
||||
static BINDFN_PROTO (entryPreProcessCB);
|
||||
|
||||
/*
|
||||
* This demonstrates the Cdk preprocess feature.
|
||||
*/
|
||||
int main (void)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKSCREEN *cdkscreen = 0;
|
||||
CDKENTRY *widget = 0;
|
||||
const char *title = "<C>Type in anything you want\n<C>but the dreaded letter </B>G<!B>!";
|
||||
char *info;
|
||||
const char *mesg[10];
|
||||
char temp[256];
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start CDK colors. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Create the entry field widget. */
|
||||
widget = newCDKEntry (cdkscreen, CENTER, CENTER,
|
||||
title, 0, A_NORMAL, '.', vMIXED,
|
||||
40, 0, 256, TRUE, FALSE);
|
||||
|
||||
/* Is the widget null? */
|
||||
if (widget == 0)
|
||||
{
|
||||
/* Clean up. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot create the entry box. Is the window too small?\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
setCDKEntryPreProcess (widget, entryPreProcessCB, 0);
|
||||
|
||||
/* Activate the entry field. */
|
||||
info = activateCDKEntry (widget, 0);
|
||||
|
||||
/* Tell them what they typed. */
|
||||
if (widget->exitType == vESCAPE_HIT)
|
||||
{
|
||||
mesg[0] = "<C>You hit escape. No information passed back.";
|
||||
mesg[1] = "",
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 3);
|
||||
}
|
||||
else if (widget->exitType == vNORMAL)
|
||||
{
|
||||
mesg[0] = "<C>You typed in the following";
|
||||
sprintf (temp, "<C>(%.*s)", (int)(sizeof (temp) - 20), info);
|
||||
mesg[1] = temp;
|
||||
mesg[2] = "";
|
||||
mesg[3] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 4);
|
||||
}
|
||||
|
||||
/* Clean up and exit. */
|
||||
destroyCDKEntry (widget);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static int entryPreProcessCB (EObjectType cdkType GCC_UNUSED, void *object,
|
||||
void *clientData GCC_UNUSED,
|
||||
chtype input)
|
||||
{
|
||||
CDKENTRY *entry = (CDKENTRY *)object;
|
||||
|
||||
/* Check the input. */
|
||||
if ((input == 'g') || (input == 'G'))
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKDIALOG *widget = 0;
|
||||
int buttonCount = 1;
|
||||
int lines = 0;
|
||||
const char *buttons[] =
|
||||
{
|
||||
"OK"
|
||||
};
|
||||
const char *mesg[5];
|
||||
|
||||
mesg[lines++] = "<C><#HL(30)>";
|
||||
mesg[lines++] = "<C>I told you </B>NOT<!B> to type G";
|
||||
mesg[lines++] = "<C><#HL(30)>";
|
||||
|
||||
widget = newCDKDialog (ScreenOf (entry), CENTER, CENTER,
|
||||
(CDK_CSTRING2)mesg, lines,
|
||||
(CDK_CSTRING2)buttons, buttonCount,
|
||||
A_REVERSE, FALSE, TRUE, FALSE);
|
||||
activateCDKDialog (widget, 0);
|
||||
destroyCDKDialog (widget);
|
||||
drawCDKEntry (entry, ObjOf (entry)->box);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
87
deps/cdk-5.0-20161210/examples/radio1_ex.c
vendored
Normal file
87
deps/cdk-5.0-20161210/examples/radio1_ex.c
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
/* $Id: radio1_ex.c,v 1.14 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "radio_ex";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This program demonstrates the Cdk radio widget.
|
||||
*/
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
CDKSCREEN *cdkscreen;
|
||||
CDKRADIO *radio;
|
||||
const char *item[5] =
|
||||
{
|
||||
"Choice A",
|
||||
"Choice B",
|
||||
"Choice C"
|
||||
};
|
||||
const char *mesg[5];
|
||||
char temp[100];
|
||||
int selection;
|
||||
|
||||
CDK_PARAMS params;
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, "s:t:" CDK_CLI_PARAMS);
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Set up CDK Colors. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Create the radio list. */
|
||||
radio = newCDKRadio (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
CDKparsePosition (CDKparamString2 (¶ms, 's',
|
||||
"NONE")),
|
||||
CDKparamValue (¶ms, 'H', 5),
|
||||
CDKparamValue (¶ms, 'W', 20),
|
||||
CDKparamString (¶ms, 't'),
|
||||
(CDK_CSTRING2)item, 3,
|
||||
'#' | A_REVERSE, 1,
|
||||
A_REVERSE,
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
|
||||
/* Check if the radio list is NULL. */
|
||||
if (radio == (CDKRADIO *)NULL)
|
||||
{
|
||||
/* Exit CDK. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot create the radio widget. ");
|
||||
printf ("Is the window too small?\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Activate the radio list. */
|
||||
selection = activateCDKRadio (radio, (chtype *)NULL);
|
||||
|
||||
/* Check the exit status of the widget. */
|
||||
if (radio->exitType == vESCAPE_HIT)
|
||||
{
|
||||
mesg[0] = "<C>You hit escape. No item selected.";
|
||||
mesg[1] = "",
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 3);
|
||||
}
|
||||
else if (radio->exitType == vNORMAL)
|
||||
{
|
||||
mesg[0] = "<C>You selected the filename";
|
||||
sprintf (temp, "<C>%.*s", (int)(sizeof (temp) - 20), item[selection]);
|
||||
mesg[1] = temp;
|
||||
mesg[2] = "";
|
||||
mesg[3] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 4);
|
||||
}
|
||||
|
||||
destroyCDKRadio (radio);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
137
deps/cdk-5.0-20161210/examples/radio_ex.c
vendored
Normal file
137
deps/cdk-5.0-20161210/examples/radio_ex.c
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
/* $Id: radio_ex.c,v 1.20 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "radio_ex";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This program demonstrates the Cdk radio widget.
|
||||
*
|
||||
* Options (in addition to normal CLI parameters):
|
||||
* -c create the data after the widget
|
||||
* -s SPOS location for the scrollbar
|
||||
* -t TEXT title for the widget
|
||||
*
|
||||
*/
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKSCREEN *cdkscreen = 0;
|
||||
CDKRADIO *radio = 0;
|
||||
const char *title = "<C></5>Select a filename";
|
||||
char **item = 0;
|
||||
const char *mesg[5];
|
||||
char temp[256];
|
||||
int count;
|
||||
|
||||
CDK_PARAMS params;
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, "cs:t:" CDK_CLI_PARAMS);
|
||||
|
||||
/* Use the current diretory list to fill the radio list. */
|
||||
count = CDKgetDirectoryContents (".", &item);
|
||||
if (count <= 0)
|
||||
{
|
||||
fprintf (stderr, "Cannot get directory list\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Set up CDK Colors. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Create the radio list. */
|
||||
radio = newCDKRadio (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
CDKparsePosition (CDKparamString2 (¶ms,
|
||||
's',
|
||||
"RIGHT")),
|
||||
CDKparamValue (¶ms, 'H', 10),
|
||||
CDKparamValue (¶ms, 'W', 40),
|
||||
CDKparamString2 (¶ms, 't', title),
|
||||
CDKparamNumber (¶ms, 'c') ? 0 : (CDK_CSTRING2)item,
|
||||
CDKparamNumber (¶ms, 'c') ? 0 : count,
|
||||
'#' | A_REVERSE, 1,
|
||||
A_REVERSE,
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
|
||||
/* Check if the radio list is null. */
|
||||
if (radio == 0)
|
||||
{
|
||||
/* Exit CDK. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot create the radio widget. Is the window too small?\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (CDKparamNumber (¶ms, 'c'))
|
||||
{
|
||||
setCDKRadioItems (radio, (CDK_CSTRING2)item, count);
|
||||
}
|
||||
|
||||
/* loop until user selects a file, or cancels */
|
||||
for (;;)
|
||||
{
|
||||
/* Activate the radio list. */
|
||||
int selection = activateCDKRadio (radio, 0);
|
||||
|
||||
/* Check the exit status of the widget. */
|
||||
if (radio->exitType == vESCAPE_HIT)
|
||||
{
|
||||
mesg[0] = "<C>You hit escape. No item selected.";
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 3);
|
||||
break;
|
||||
}
|
||||
else if (radio->exitType == vNORMAL)
|
||||
{
|
||||
struct stat sb;
|
||||
|
||||
if (stat (item[selection], &sb) == 0
|
||||
&& (sb.st_mode & S_IFMT) == S_IFDIR)
|
||||
{
|
||||
char **nitem = 0;
|
||||
|
||||
mesg[0] = "<C>You selected a directory";
|
||||
sprintf (temp, "<C>%.*s", (int)(sizeof (temp) - 20), item[selection]);
|
||||
mesg[1] = temp;
|
||||
mesg[2] = "";
|
||||
mesg[3] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 4);
|
||||
count = CDKgetDirectoryContents (item[selection], &nitem);
|
||||
if (count > 0)
|
||||
{
|
||||
CDKfreeStrings (item);
|
||||
item = nitem;
|
||||
if (chdir (item[selection]) == 0)
|
||||
setCDKRadioItems (radio, (CDK_CSTRING2)item, count);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mesg[0] = "<C>You selected the filename";
|
||||
sprintf (temp, "<C>%.*s", (int)(sizeof (temp) - 20), item[selection]);
|
||||
mesg[1] = temp;
|
||||
mesg[2] = "";
|
||||
mesg[3] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 4);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Clean up. */
|
||||
CDKfreeStrings (item);
|
||||
destroyCDKRadio (radio);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
142
deps/cdk-5.0-20161210/examples/raiseCDKObject_ex.c
vendored
Normal file
142
deps/cdk-5.0-20161210/examples/raiseCDKObject_ex.c
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
/* $Id: raiseCDKObject_ex.c,v 1.12 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "raiseCDKObject_ex";
|
||||
#endif
|
||||
|
||||
#define MY_LABEL(p) ((chtype)ObjOf(p)->screenIndex | 0x30 | A_UNDERLINE | A_BOLD)
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
char ch;
|
||||
|
||||
const char *mesg[1];
|
||||
const char *mesg1[10];
|
||||
const char *mesg2[10];
|
||||
const char *mesg3[10];
|
||||
const char *mesg4[10];
|
||||
|
||||
CDKSCREEN *cdkscreen;
|
||||
CDKLABEL *label1, *label2, *label3, *label4, *instruct;
|
||||
|
||||
CDK_PARAMS params;
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, CDK_MIN_PARAMS);
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
mesg1[0] = "label1 label1 label1 label1 label1 label1 label1";
|
||||
mesg1[1] = "label1 label1 label1 label1 label1 label1 label1";
|
||||
mesg1[2] = "label1 label1 label1 label1 label1 label1 label1";
|
||||
mesg1[3] = "label1 label1 label1 label1 label1 label1 label1";
|
||||
mesg1[4] = "label1 label1 label1 label1 label1 label1 label1";
|
||||
mesg1[5] = "label1 label1 label1 label1 label1 label1 label1";
|
||||
mesg1[6] = "label1 label1 label1 label1 label1 label1 label1";
|
||||
mesg1[7] = "label1 label1 label1 label1 label1 label1 label1";
|
||||
mesg1[8] = "label1 label1 label1 label1 label1 label1 label1";
|
||||
mesg1[9] = "label1 label1 label1 label1 label1 label1 label1";
|
||||
label1 = newCDKLabel (cdkscreen, 10, 4, (CDK_CSTRING2)mesg1, 10, TRUE, FALSE);
|
||||
setCDKLabelULChar (label1, '1' | A_BOLD);
|
||||
|
||||
mesg2[0] = "label2 label2 label2 label2 label2 label2 label2";
|
||||
mesg2[1] = "label2 label2 label2 label2 label2 label2 label2";
|
||||
mesg2[2] = "label2 label2 label2 label2 label2 label2 label2";
|
||||
mesg2[3] = "label2 label2 label2 label2 label2 label2 label2";
|
||||
mesg2[4] = "label2 label2 label2 label2 label2 label2 label2";
|
||||
mesg2[5] = "label2 label2 label2 label2 label2 label2 label2";
|
||||
mesg2[6] = "label2 label2 label2 label2 label2 label2 label2";
|
||||
mesg2[7] = "label2 label2 label2 label2 label2 label2 label2";
|
||||
mesg2[8] = "label2 label2 label2 label2 label2 label2 label2";
|
||||
mesg2[9] = "label2 label2 label2 label2 label2 label2 label2";
|
||||
label2 = newCDKLabel (cdkscreen, 8, 8, (CDK_CSTRING2)mesg2, 10, TRUE, FALSE);
|
||||
setCDKLabelULChar (label2, '2' | A_BOLD);
|
||||
|
||||
mesg3[0] = "label3 label3 label3 label3 label3 label3 label3";
|
||||
mesg3[1] = "label3 label3 label3 label3 label3 label3 label3";
|
||||
mesg3[2] = "label3 label3 label3 label3 label3 label3 label3";
|
||||
mesg3[3] = "label3 label3 label3 label3 label3 label3 label3";
|
||||
mesg3[4] = "label3 label3 label3 label3 label3 label3 label3";
|
||||
mesg3[5] = "label3 label3 label3 label3 label3 label3 label3";
|
||||
mesg3[6] = "label3 label3 label3 label3 label3 label3 label3";
|
||||
mesg3[7] = "label3 label3 label3 label3 label3 label3 label3";
|
||||
mesg3[8] = "label3 label3 label3 label3 label3 label3 label3";
|
||||
mesg3[9] = "label3 label3 label3 label3 label3 label3 label3";
|
||||
label3 = newCDKLabel (cdkscreen, 6, 12, (CDK_CSTRING2)mesg3, 10, TRUE, FALSE);
|
||||
setCDKLabelULChar (label3, '3' | A_BOLD);
|
||||
|
||||
mesg4[0] = "label4 label4 label4 label4 label4 label4 label4";
|
||||
mesg4[1] = "label4 label4 label4 label4 label4 label4 label4";
|
||||
mesg4[2] = "label4 label4 label4 label4 label4 label4 label4";
|
||||
mesg4[3] = "label4 label4 label4 label4 label4 label4 label4";
|
||||
mesg4[4] = "label4 label4 label4 label4 label4 label4 label4";
|
||||
mesg4[5] = "label4 label4 label4 label4 label4 label4 label4";
|
||||
mesg4[6] = "label4 label4 label4 label4 label4 label4 label4";
|
||||
mesg4[7] = "label4 label4 label4 label4 label4 label4 label4";
|
||||
mesg4[8] = "label4 label4 label4 label4 label4 label4 label4";
|
||||
mesg4[9] = "label4 label4 label4 label4 label4 label4 label4";
|
||||
label4 = newCDKLabel (cdkscreen, 4, 16, (CDK_CSTRING2)mesg4, 10, TRUE, FALSE);
|
||||
setCDKLabelULChar (label4, '4' | A_BOLD);
|
||||
|
||||
mesg[0] = "</B>#<!B> - raise </U>label#<!U>, </B>r<!B> - </U>redraw<!U>, </B>q<!B> - </U>quit<!U>";
|
||||
instruct = newCDKLabel (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', BOTTOM),
|
||||
(CDK_CSTRING2)mesg, 1,
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
setCDKLabelULChar (instruct, ' ' | A_NORMAL);
|
||||
setCDKLabelURChar (instruct, ' ' | A_NORMAL);
|
||||
setCDKLabelLLChar (instruct, ' ' | A_NORMAL);
|
||||
setCDKLabelVerticalChar (instruct, ' ' | A_NORMAL);
|
||||
setCDKLabelHorizontalChar (instruct, ' ' | A_NORMAL);
|
||||
|
||||
setCDKLabelLRChar (label1, MY_LABEL (label1));
|
||||
setCDKLabelLRChar (label2, MY_LABEL (label2));
|
||||
setCDKLabelLRChar (label3, MY_LABEL (label3));
|
||||
setCDKLabelLRChar (label4, MY_LABEL (label4));
|
||||
setCDKLabelLRChar (instruct, MY_LABEL (instruct));
|
||||
refreshCDKScreen (cdkscreen);
|
||||
|
||||
while ((ch = (char)getch ()) != 'q')
|
||||
{
|
||||
switch (ch)
|
||||
{
|
||||
case '1':
|
||||
raiseCDKObject (vLABEL, label1);
|
||||
break;
|
||||
case '2':
|
||||
raiseCDKObject (vLABEL, label2);
|
||||
break;
|
||||
case '3':
|
||||
raiseCDKObject (vLABEL, label3);
|
||||
break;
|
||||
case '4':
|
||||
raiseCDKObject (vLABEL, label4);
|
||||
break;
|
||||
case 'r':
|
||||
refreshCDKScreen (cdkscreen);
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
setCDKLabelLRChar (label1, MY_LABEL (label1));
|
||||
setCDKLabelLRChar (label2, MY_LABEL (label2));
|
||||
setCDKLabelLRChar (label3, MY_LABEL (label3));
|
||||
setCDKLabelLRChar (label4, MY_LABEL (label4));
|
||||
setCDKLabelLRChar (instruct, MY_LABEL (instruct));
|
||||
refreshCDKScreen (cdkscreen);
|
||||
}
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKLabel (label1);
|
||||
destroyCDKLabel (label2);
|
||||
destroyCDKLabel (label3);
|
||||
destroyCDKLabel (label4);
|
||||
destroyCDKLabel (instruct);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
86
deps/cdk-5.0-20161210/examples/scale_ex.c
vendored
Normal file
86
deps/cdk-5.0-20161210/examples/scale_ex.c
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
/* $Id: scale_ex.c,v 1.11 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "scale_ex";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This program demonstrates the Cdk scale widget.
|
||||
*/
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKSCREEN *cdkscreen = 0;
|
||||
CDKSCALE *widget = 0;
|
||||
const char *title = "<C>Select a value";
|
||||
const char *label = "</5>Current value";
|
||||
char temp[256];
|
||||
const char *mesg[5];
|
||||
int selection;
|
||||
|
||||
CDK_PARAMS params;
|
||||
int high;
|
||||
int inc;
|
||||
int low;
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, "h:i:l:w:" CDK_MIN_PARAMS);
|
||||
high = CDKparamNumber2 (¶ms, 'h', 100);
|
||||
inc = CDKparamNumber2 (¶ms, 'i', 1);
|
||||
low = CDKparamNumber2 (¶ms, 'l', 0);
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start CDK Colors. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Create the widget. */
|
||||
widget = newCDKScale (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
title, label,
|
||||
A_NORMAL,
|
||||
CDKparamNumber2 (¶ms, 'w', 5),
|
||||
low, low, high,
|
||||
inc, (inc * 2),
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
|
||||
/* Is the widget null? */
|
||||
if (widget == 0)
|
||||
{
|
||||
/* Exit CDK. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot make the widget. Is the window too small?\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Activate the widget. */
|
||||
selection = activateCDKScale (widget, 0);
|
||||
|
||||
/* Check the exit value of the widget. */
|
||||
if (widget->exitType == vESCAPE_HIT)
|
||||
{
|
||||
mesg[0] = "<C>You hit escape. No value selected.";
|
||||
mesg[1] = "",
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
else if (widget->exitType == vNORMAL)
|
||||
{
|
||||
sprintf (temp, "<C>You selected %d", selection);
|
||||
mesg[0] = temp;
|
||||
mesg[1] = "",
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKScale (widget);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
178
deps/cdk-5.0-20161210/examples/scroll_ex.c
vendored
Normal file
178
deps/cdk-5.0-20161210/examples/scroll_ex.c
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
/* $Id: scroll_ex.c,v 1.25 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "scroll_ex";
|
||||
#endif
|
||||
|
||||
static char *newLabel (const char *prefix)
|
||||
{
|
||||
static int count;
|
||||
static char result[80];
|
||||
sprintf (result, "%s%d", prefix, ++count);
|
||||
return result;
|
||||
}
|
||||
|
||||
static int addItemCB (EObjectType cdktype GCC_UNUSED,
|
||||
void *object,
|
||||
void *clientData GCC_UNUSED,
|
||||
chtype input GCC_UNUSED)
|
||||
{
|
||||
CDKSCROLL *s = (CDKSCROLL *)object;
|
||||
|
||||
addCDKScrollItem (s, newLabel ("add"));
|
||||
|
||||
refreshCDKScreen (ScreenOf (s));
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static int insItemCB (EObjectType cdktype GCC_UNUSED,
|
||||
void *object,
|
||||
void *clientData GCC_UNUSED,
|
||||
chtype input GCC_UNUSED)
|
||||
{
|
||||
CDKSCROLL *s = (CDKSCROLL *)object;
|
||||
|
||||
insertCDKScrollItem (s, newLabel ("insert"));
|
||||
|
||||
refreshCDKScreen (ScreenOf (s));
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static int delItemCB (EObjectType cdktype GCC_UNUSED,
|
||||
void *object,
|
||||
void *clientData GCC_UNUSED,
|
||||
chtype input GCC_UNUSED)
|
||||
{
|
||||
CDKSCROLL *s = (CDKSCROLL *)object;
|
||||
|
||||
deleteCDKScrollItem (s, getCDKScrollCurrent (s));
|
||||
|
||||
refreshCDKScreen (ScreenOf (s));
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* This program demonstrates the Cdk scrolling list widget.
|
||||
*
|
||||
* Options (in addition to normal CLI parameters):
|
||||
* -c create the data after the widget
|
||||
* -s SPOS location for the scrollbar
|
||||
* -t TEXT title for the widget
|
||||
*/
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* Declare variables. */
|
||||
CDKSCREEN *cdkscreen = 0;
|
||||
CDKSCROLL *scrollList = 0;
|
||||
const char *title = "<C></5>Pick a file";
|
||||
char **item = 0;
|
||||
const char *mesg[5];
|
||||
char temp[256];
|
||||
int selection, count;
|
||||
|
||||
CDK_PARAMS params;
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, "cs:t:" CDK_CLI_PARAMS);
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Set up CDK Colors. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Use the current diretory list to fill the radio list. */
|
||||
count = CDKgetDirectoryContents (".", &item);
|
||||
|
||||
/* Create the scrolling list. */
|
||||
scrollList = newCDKScroll (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
CDKparsePosition (CDKparamString2 (¶ms,
|
||||
's',
|
||||
"RIGHT")),
|
||||
CDKparamValue (¶ms, 'H', 10),
|
||||
CDKparamValue (¶ms, 'W', 50),
|
||||
CDKparamString2 (¶ms, 't', title),
|
||||
(CDKparamNumber (¶ms, 'c')
|
||||
? 0
|
||||
: (CDK_CSTRING2) item),
|
||||
(CDKparamNumber (¶ms, 'c')
|
||||
? 0
|
||||
: count),
|
||||
TRUE,
|
||||
A_REVERSE,
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
|
||||
/* Is the scrolling list null? */
|
||||
if (scrollList == 0)
|
||||
{
|
||||
/* Exit CDK. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot make scrolling list. Is the window too small?\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (CDKparamNumber (¶ms, 'c'))
|
||||
{
|
||||
setCDKScrollItems (scrollList, (CDK_CSTRING2) item, count, TRUE);
|
||||
}
|
||||
#if 0
|
||||
drawCDKScroll (scrollList, 1);
|
||||
|
||||
setCDKScrollPosition (scrollList, 10);
|
||||
drawCDKScroll (scrollList, 1);
|
||||
sleep (3);
|
||||
|
||||
setCDKScrollPosition (scrollList, 20);
|
||||
drawCDKScroll (scrollList, 1);
|
||||
sleep (3);
|
||||
|
||||
setCDKScrollPosition (scrollList, 30);
|
||||
drawCDKScroll (scrollList, 1);
|
||||
sleep (3);
|
||||
|
||||
setCDKScrollPosition (scrollList, 70);
|
||||
drawCDKScroll (scrollList, 1);
|
||||
sleep (3);
|
||||
#endif
|
||||
bindCDKObject (vSCROLL, scrollList, 'a', addItemCB, NULL);
|
||||
bindCDKObject (vSCROLL, scrollList, 'i', insItemCB, NULL);
|
||||
bindCDKObject (vSCROLL, scrollList, 'd', delItemCB, NULL);
|
||||
|
||||
/* Activate the scrolling list. */
|
||||
|
||||
selection = activateCDKScroll (scrollList, 0);
|
||||
|
||||
/* Determine how the widget was exited. */
|
||||
if (scrollList->exitType == vESCAPE_HIT)
|
||||
{
|
||||
mesg[0] = "<C>You hit escape. No file selected.";
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
else if (scrollList->exitType == vNORMAL)
|
||||
{
|
||||
char *theItem = chtype2Char (scrollList->item[selection]);
|
||||
mesg[0] = "<C>You selected the following file";
|
||||
sprintf (temp, "<C>%.*s", (int)(sizeof (temp) - 20), theItem);
|
||||
mesg[1] = temp;
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
|
||||
freeChar (theItem);
|
||||
}
|
||||
|
||||
/* Clean up. */
|
||||
CDKfreeStrings (item);
|
||||
destroyCDKScroll (scrollList);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
164
deps/cdk-5.0-20161210/examples/selection_ex.c
vendored
Normal file
164
deps/cdk-5.0-20161210/examples/selection_ex.c
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
/* $Id: selection_ex.c,v 1.21 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "selection_ex";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This program demonstrates the Cdk selection widget.
|
||||
*
|
||||
* Options (in addition to normal CLI parameters):
|
||||
* -c create the data after the widget
|
||||
* -f TEXT title for a footer label
|
||||
* -h TEXT title for a header label
|
||||
* -s SPOS location for the scrollbar
|
||||
* -t TEXT title for the widget
|
||||
*
|
||||
*/
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
static const char *choices[] =
|
||||
{
|
||||
" ",
|
||||
"-->"
|
||||
};
|
||||
/* *INDENT-EQLS* */
|
||||
CDKSCREEN *cdkscreen = 0;
|
||||
CDKSELECTION *selection = 0;
|
||||
const char *title = "<C></5>Pick one or more accounts.";
|
||||
char *title_string = 0;
|
||||
char **item = 0;
|
||||
char temp[256];
|
||||
const char *mesg[200];
|
||||
#if defined (HAVE_PWD_H)
|
||||
struct passwd *ent;
|
||||
#endif
|
||||
unsigned x, y;
|
||||
unsigned used = 0;
|
||||
unsigned count = 0;
|
||||
|
||||
CDK_PARAMS params;
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, "cf:h:s:t:" CDK_CLI_PARAMS);
|
||||
|
||||
/* Use the account names to create a list. */
|
||||
count = 0;
|
||||
#if defined (HAVE_PWD_H)
|
||||
while ((ent = getpwent ()) != 0)
|
||||
{
|
||||
used = CDKallocStrings (&item, ent->pw_name, count++, used);
|
||||
}
|
||||
endpwent ();
|
||||
#endif
|
||||
count--;
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Set up CDK Colors. */
|
||||
initCDKColor ();
|
||||
|
||||
if ((title_string = CDKparamString2 (¶ms, 'h', 0)) != 0)
|
||||
{
|
||||
const char *list[2];
|
||||
CDKLABEL *header;
|
||||
|
||||
list[0] = title_string;
|
||||
list[1] = 0;
|
||||
header = newCDKLabel (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', TOP),
|
||||
(CDK_CSTRING2)list, 1,
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', TRUE));
|
||||
if (header != 0)
|
||||
activateCDKLabel (header, 0);
|
||||
}
|
||||
|
||||
if ((title_string = CDKparamString2 (¶ms, 'f', 0)) != 0)
|
||||
{
|
||||
const char *list[2];
|
||||
CDKLABEL *footer;
|
||||
|
||||
list[0] = title_string;
|
||||
list[1] = 0;
|
||||
footer = newCDKLabel (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', BOTTOM),
|
||||
(CDK_CSTRING2)list, 1,
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', TRUE));
|
||||
if (footer != 0)
|
||||
activateCDKLabel (footer, 0);
|
||||
}
|
||||
/* Create the selection list. */
|
||||
selection = newCDKSelection (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
CDKparsePosition
|
||||
(CDKparamString2 (¶ms, 's', "RIGHT")),
|
||||
CDKparamValue (¶ms, 'H', 10),
|
||||
CDKparamValue (¶ms, 'W', 50),
|
||||
CDKparamString2 (¶ms, 't', title),
|
||||
(CDKparamNumber (¶ms, 'c')
|
||||
? 0
|
||||
: (CDK_CSTRING2)item),
|
||||
(CDKparamNumber (¶ms, 'c')
|
||||
? 0
|
||||
: (int)count),
|
||||
(CDK_CSTRING2)choices, 2,
|
||||
A_REVERSE,
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
|
||||
/* Is the selection list null? */
|
||||
if (selection == 0)
|
||||
{
|
||||
/* Exit CDK. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot to create the selection list.\n");
|
||||
printf ("Is the window too small?\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (CDKparamNumber (¶ms, 'c'))
|
||||
{
|
||||
setCDKSelectionItems (selection, (CDK_CSTRING2)item, (int)count);
|
||||
}
|
||||
|
||||
/* Activate the selection list. */
|
||||
activateCDKSelection (selection, 0);
|
||||
|
||||
/* Check the exit status of the widget. */
|
||||
if (selection->exitType == vESCAPE_HIT)
|
||||
{
|
||||
mesg[0] = "<C>You hit escape. No items selected.";
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 3);
|
||||
}
|
||||
else if (selection->exitType == vNORMAL)
|
||||
{
|
||||
mesg[0] = "<C>Here are the accounts you selected.";
|
||||
y = 1;
|
||||
for (x = 0; x < count; x++)
|
||||
{
|
||||
if (selection->selections[x] == 1)
|
||||
{
|
||||
sprintf (temp, "<C></5>%.*s", (int)(sizeof (temp) - 20), item[x]);
|
||||
mesg[y++] = copyChar (temp);
|
||||
}
|
||||
}
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, (int)y);
|
||||
}
|
||||
|
||||
/* Clean up. */
|
||||
CDKfreeStrings (item);
|
||||
destroyCDKSelection (selection);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
86
deps/cdk-5.0-20161210/examples/slider_ex.c
vendored
Normal file
86
deps/cdk-5.0-20161210/examples/slider_ex.c
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
/* $Id: slider_ex.c,v 1.11 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "slider_ex";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This program demonstrates the Cdk slider widget.
|
||||
*/
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKSCREEN *cdkscreen = 0;
|
||||
CDKSLIDER *widget = 0;
|
||||
const char *title = "<C></U>Enter a value:";
|
||||
const char *label = "</B>Current Value:";
|
||||
char temp[256];
|
||||
const char *mesg[5];
|
||||
int selection;
|
||||
|
||||
CDK_PARAMS params;
|
||||
int high;
|
||||
int inc;
|
||||
int low;
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, "h:i:l:w:" CDK_MIN_PARAMS);
|
||||
high = CDKparamNumber2 (¶ms, 'h', 100);
|
||||
inc = CDKparamNumber2 (¶ms, 'i', 1);
|
||||
low = CDKparamNumber2 (¶ms, 'l', 1);
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start CDK Colors. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Create the widget. */
|
||||
widget = newCDKSlider (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
title, label,
|
||||
A_REVERSE | COLOR_PAIR (29) | ' ',
|
||||
CDKparamNumber2 (¶ms, 'w', 50),
|
||||
low, low, high,
|
||||
inc, (inc * 2),
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
|
||||
/* Is the widget null? */
|
||||
if (widget == 0)
|
||||
{
|
||||
/* Exit CDK. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot make the widget. Is the window too small?\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Activate the widget. */
|
||||
selection = activateCDKSlider (widget, 0);
|
||||
|
||||
/* Check the exit value of the widget. */
|
||||
if (widget->exitType == vESCAPE_HIT)
|
||||
{
|
||||
mesg[0] = "<C>You hit escape. No value selected.";
|
||||
mesg[1] = "",
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
else if (widget->exitType == vNORMAL)
|
||||
{
|
||||
sprintf (temp, "<C>You selected %d", selection);
|
||||
mesg[0] = temp;
|
||||
mesg[1] = "",
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKSlider (widget);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
90
deps/cdk-5.0-20161210/examples/subwindow_ex.c
vendored
Normal file
90
deps/cdk-5.0-20161210/examples/subwindow_ex.c
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
/* $Id: subwindow_ex.c,v 1.13 2016/12/04 16:20:33 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "subwindow_ex";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This demo displays the ability to put widgets within a curses subwindow.
|
||||
*/
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
CDKSCREEN *cdkscreen;
|
||||
CDKSCROLL *dowList;
|
||||
CDKLABEL *title;
|
||||
WINDOW *subWindow;
|
||||
const char *dow[] =
|
||||
{
|
||||
"Monday",
|
||||
"Tuesday",
|
||||
"Wednesday",
|
||||
"Thursday",
|
||||
"Friday",
|
||||
"Saturday",
|
||||
"Sunday"
|
||||
};
|
||||
const char *mesg[5];
|
||||
int pick;
|
||||
|
||||
CDK_PARAMS params;
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, "s:" CDK_CLI_PARAMS);
|
||||
|
||||
/* Start curses. */
|
||||
(void) initCDKScreen (NULL);
|
||||
curs_set (0);
|
||||
|
||||
/* Create a basic window. */
|
||||
subWindow = newwin (LINES - 5, COLS - 10, 2, 5);
|
||||
|
||||
/* Start Cdk. */
|
||||
cdkscreen = initCDKScreen (subWindow);
|
||||
|
||||
/* Box our window. */
|
||||
box (subWindow, ACS_VLINE, ACS_HLINE);
|
||||
wrefresh (subWindow);
|
||||
|
||||
/* Create a basic scrolling list inside the window. */
|
||||
dowList = newCDKScroll (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
CDKparsePosition (CDKparamString2 (¶ms,
|
||||
's',
|
||||
"RIGHT")),
|
||||
CDKparamValue (¶ms, 'H', 10),
|
||||
CDKparamValue (¶ms, 'W', 15),
|
||||
"<C></U>Pick a Day",
|
||||
(CDK_CSTRING2) dow, 7,
|
||||
NONUMBERS,
|
||||
A_REVERSE,
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
|
||||
/* Put a title within the window. */
|
||||
mesg[0] = "<C><#HL(30)>";
|
||||
mesg[1] = "<C>This is a Cdk scrolling list";
|
||||
mesg[2] = "<C>inside a curses window.";
|
||||
mesg[3] = "<C><#HL(30)>";
|
||||
title = newCDKLabel (cdkscreen, CENTER, 0,
|
||||
(CDK_CSTRING2) mesg, 4,
|
||||
FALSE, FALSE);
|
||||
|
||||
/* Refresh the screen. */
|
||||
refreshCDKScreen (cdkscreen);
|
||||
|
||||
/* Let the user play. */
|
||||
pick = activateCDKScroll (dowList, 0);
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKScroll (dowList);
|
||||
destroyCDKLabel (title);
|
||||
eraseCursesWindow (subWindow);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
/* Tell them what they picked. */
|
||||
printf ("You picked %s\n", dow[pick]);
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
115
deps/cdk-5.0-20161210/examples/swindow_ex.c
vendored
Normal file
115
deps/cdk-5.0-20161210/examples/swindow_ex.c
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
/* $Id: swindow_ex.c,v 1.14 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "swindow_ex";
|
||||
#endif
|
||||
|
||||
#if !defined (HAVE_SLEEP) && defined (_WIN32) /* Mingw */
|
||||
#define sleep(x) _sleep(x*1000)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Demonstrate a scrolling-window.
|
||||
*/
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKSCREEN *cdkscreen = 0;
|
||||
CDKSWINDOW *swindow = 0;
|
||||
const char *title = "<C></5>Error Log";
|
||||
const char *mesg[5];
|
||||
|
||||
CDK_PARAMS params;
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, CDK_CLI_PARAMS);
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start CDK colors. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Create the scrolling window. */
|
||||
swindow = newCDKSwindow (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
CDKparamValue (¶ms, 'H', 6),
|
||||
CDKparamValue (¶ms, 'W', 65),
|
||||
title, 100,
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
|
||||
/* Is the window null. */
|
||||
if (swindow == 0)
|
||||
{
|
||||
/* Exit CDK. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot create the scrolling window. ");
|
||||
printf ("Is the window too small?\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Draw the scrolling window. */
|
||||
drawCDKSwindow (swindow, ObjOf (swindow)->box);
|
||||
|
||||
/* Load up the scrolling window. */
|
||||
addCDKSwindow (swindow, "<C></11>TOP: This is the first line.", BOTTOM);
|
||||
addCDKSwindow (swindow, "<C>Sleeping for 1 second.", BOTTOM);
|
||||
sleep (1);
|
||||
|
||||
addCDKSwindow (swindow, "<L></11>1: This is another line.", BOTTOM);
|
||||
addCDKSwindow (swindow, "<C>Sleeping for 1 second.", BOTTOM);
|
||||
sleep (1);
|
||||
|
||||
addCDKSwindow (swindow, "<C></11>2: This is another line.", BOTTOM);
|
||||
addCDKSwindow (swindow, "<C>Sleeping for 1 second.", BOTTOM);
|
||||
sleep (1);
|
||||
|
||||
addCDKSwindow (swindow, "<R></11>3: This is another line.", BOTTOM);
|
||||
addCDKSwindow (swindow, "<C>Sleeping for 1 second.", BOTTOM);
|
||||
sleep (1);
|
||||
|
||||
addCDKSwindow (swindow, "<C></11>4: This is another line.", BOTTOM);
|
||||
addCDKSwindow (swindow, "<C>Sleeping for 1 second.", BOTTOM);
|
||||
sleep (1);
|
||||
|
||||
addCDKSwindow (swindow, "<L></11>5: This is another line.", BOTTOM);
|
||||
addCDKSwindow (swindow, "<C>Sleeping for 1 second.", BOTTOM);
|
||||
sleep (1);
|
||||
|
||||
addCDKSwindow (swindow, "<C></11>6: This is another line.", BOTTOM);
|
||||
addCDKSwindow (swindow, "<C>Sleeping for 1 second.", BOTTOM);
|
||||
sleep (1);
|
||||
|
||||
addCDKSwindow (swindow, "<C>Done. You can now play.", BOTTOM);
|
||||
|
||||
addCDKSwindow (swindow, "<C>This is being added to the top.", TOP);
|
||||
|
||||
/* Activate the scrolling window. */
|
||||
activateCDKSwindow (swindow, 0);
|
||||
|
||||
/* Check how the user exited this widget. */
|
||||
if (swindow->exitType == vESCAPE_HIT)
|
||||
{
|
||||
mesg[0] = "<C>You hit escape to leave this widget.";
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
else if (swindow->exitType == vNORMAL)
|
||||
{
|
||||
mesg[0] = "<C>You hit return to exit this widget.";
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKSwindow (swindow);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
97
deps/cdk-5.0-20161210/examples/template_ex.c
vendored
Normal file
97
deps/cdk-5.0-20161210/examples/template_ex.c
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
/* $Id: template_ex.c,v 1.13 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "template_ex";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This program demonstrates the Cdk template widget.
|
||||
*/
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKSCREEN *cdkscreen = 0;
|
||||
CDKTEMPLATE *phoneNumber = 0;
|
||||
const char *title = "<C>Title";
|
||||
const char *label = "</5>Phone Number:<!5>";
|
||||
const char *Overlay = "</B/6>(___)<!6> </5>___-____";
|
||||
const char *plate = "(###) ###-####";
|
||||
char *info;
|
||||
char *mixed;
|
||||
char temp[256];
|
||||
const char *mesg[5];
|
||||
|
||||
CDK_PARAMS params;
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, CDK_MIN_PARAMS);
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start CDK Colors. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Declare the template. */
|
||||
phoneNumber = newCDKTemplate (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
title, label,
|
||||
plate, Overlay,
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
|
||||
/* Is the template pointer null? */
|
||||
if (phoneNumber == 0)
|
||||
{
|
||||
/* Exit CDK. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot create template. Is the window too small?");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Activate the template. */
|
||||
info = activateCDKTemplate (phoneNumber, 0);
|
||||
|
||||
/* Tell them what they typed. */
|
||||
if (phoneNumber->exitType == vESCAPE_HIT)
|
||||
{
|
||||
mesg[0] = "<C>You hit escape. No information typed in.";
|
||||
mesg[1] = "",
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
else if (phoneNumber->exitType == vNORMAL)
|
||||
{
|
||||
char *with_mix;
|
||||
char *with_out;
|
||||
|
||||
/* Mix the plate and the number. */
|
||||
mixed = mixCDKTemplate (phoneNumber);
|
||||
|
||||
/* Create the message to display. */
|
||||
sprintf (temp, "Phone Number with out plate mixing : %.*s",
|
||||
(int)(sizeof (temp) - 50),
|
||||
info);
|
||||
mesg[0] = with_out = copyChar (temp);
|
||||
sprintf (temp, "Phone Number with the plate mixed in: %.*s",
|
||||
(int)(sizeof (temp) - 50),
|
||||
mixed);
|
||||
mesg[1] = with_mix = copyChar (temp);
|
||||
mesg[2] = "";
|
||||
mesg[3] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 4);
|
||||
|
||||
freeChar (with_out);
|
||||
freeChar (with_mix);
|
||||
freeChar (mixed);
|
||||
}
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKTemplate (phoneNumber);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
768
deps/cdk-5.0-20161210/examples/traverse_ex.c
vendored
Normal file
768
deps/cdk-5.0-20161210/examples/traverse_ex.c
vendored
Normal file
@@ -0,0 +1,768 @@
|
||||
/* $Id: traverse_ex.c,v 1.25 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "entry_ex";
|
||||
#endif
|
||||
|
||||
#define NumElements(a) ((sizeof a)/(sizeof a[0]))
|
||||
|
||||
#define MY_MAX 3
|
||||
|
||||
static CDKOBJS *all_objects[MY_MAX];
|
||||
|
||||
static const char *yes_no[] =
|
||||
{
|
||||
"Yes", "NO"
|
||||
};
|
||||
static const char *months[] =
|
||||
{
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
||||
};
|
||||
static const char *choices[] =
|
||||
{
|
||||
"[ ]", "[*]"
|
||||
};
|
||||
|
||||
/*
|
||||
* Exercise all widgets except
|
||||
* CDKMENU
|
||||
* CDKTRAVERSE
|
||||
* The names in parentheses do not accept input, so they will never have
|
||||
* focus for traversal. The names with leading "*" have some limitation
|
||||
* that makes them not useful in traversal.
|
||||
*/
|
||||
/* *INDENT-OFF* */
|
||||
static const struct
|
||||
{
|
||||
const char *name;
|
||||
EObjectType type;
|
||||
}
|
||||
menu_table[] =
|
||||
{
|
||||
{ "(CDKGRAPH)", vGRAPH }, /* no traversal (not active) */
|
||||
{ "(CDKHISTOGRAM)", vHISTOGRAM }, /* no traversal (not active) */
|
||||
{ "(CDKLABEL)", vLABEL }, /* no traversal (not active) */
|
||||
{ "(CDKMARQUEE)", vMARQUEE }, /* hangs (leaves trash) */
|
||||
{ "*CDKVIEWER", vVIEWER }, /* traversal out-only on OK */
|
||||
{ "CDKALPHALIST", vALPHALIST },
|
||||
{ "CDKBUTTON", vBUTTON },
|
||||
{ "CDKBUTTONBOX", vBUTTONBOX },
|
||||
{ "CDKCALENDAR", vCALENDAR },
|
||||
{ "CDKDIALOG", vDIALOG },
|
||||
{ "CDKDSCALE", vDSCALE },
|
||||
{ "CDKENTRY", vENTRY },
|
||||
{ "CDKFSCALE", vFSCALE },
|
||||
{ "CDKFSELECT", vFSELECT },
|
||||
{ "CDKFSLIDER", vFSLIDER },
|
||||
{ "CDKITEMLIST", vITEMLIST },
|
||||
{ "CDKMATRIX", vMATRIX },
|
||||
{ "CDKMENTRY", vMENTRY },
|
||||
{ "CDKRADIO", vRADIO },
|
||||
{ "CDKSCALE", vSCALE },
|
||||
{ "CDKSCROLL", vSCROLL },
|
||||
{ "CDKSELECTION", vSELECTION },
|
||||
{ "CDKSLIDER", vSLIDER },
|
||||
{ "CDKSWINDOW", vSWINDOW },
|
||||
{ "CDKTEMPLATE", vTEMPLATE },
|
||||
{ "CDKUSCALE", vUSCALE },
|
||||
{ "CDKUSLIDER", vUSLIDER },
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
static CDKOBJS *make_alphalist (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
CDKALPHALIST *widget = newCDKAlphalist (cdkscreen,
|
||||
x, y, 10, 15,
|
||||
"AlphaList",
|
||||
"->",
|
||||
(CDK_CSTRING *)months,
|
||||
NumElements (months),
|
||||
'_', A_REVERSE,
|
||||
TRUE, FALSE);
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_button (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
CDKBUTTON *widget = newCDKButton (cdkscreen, x, y,
|
||||
"A Button!", NULL,
|
||||
TRUE, FALSE);
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_buttonbox (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
CDKBUTTONBOX *widget = newCDKButtonbox (cdkscreen, x, y,
|
||||
10, 16,
|
||||
"ButtonBox", 6, 2,
|
||||
months,
|
||||
NumElements (months),
|
||||
A_REVERSE,
|
||||
TRUE, FALSE);
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_calendar (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
CDKCALENDAR *widget = newCDKCalendar (cdkscreen, x, y,
|
||||
"Calendar", 25, 1, 2000,
|
||||
COLOR_PAIR (16) | A_BOLD,
|
||||
COLOR_PAIR (24) | A_BOLD,
|
||||
COLOR_PAIR (32) | A_BOLD,
|
||||
COLOR_PAIR (40) | A_REVERSE,
|
||||
TRUE,
|
||||
FALSE);
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_dialog (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
static const char *message[] =
|
||||
{
|
||||
"This is a simple dialog box"
|
||||
,"Is it simple enough?"
|
||||
};
|
||||
|
||||
CDKDIALOG *widget = newCDKDialog (cdkscreen, x, y,
|
||||
(CDK_CSTRING2)message, NumElements (message),
|
||||
(CDK_CSTRING2)yes_no, NumElements (yes_no),
|
||||
COLOR_PAIR (2) | A_REVERSE,
|
||||
TRUE,
|
||||
TRUE, FALSE);
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_dscale (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
CDKDSCALE *widget = newCDKDScale (cdkscreen, x, y,
|
||||
"DScale", "Value", A_NORMAL,
|
||||
15,
|
||||
0.0, 0.0, 100.0,
|
||||
1.0, (1.0 * 2.), 1,
|
||||
TRUE,
|
||||
FALSE);
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_entry (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
CDKENTRY *widget = newCDKEntry (cdkscreen, x, y,
|
||||
NULL, "Entry: ", A_NORMAL,
|
||||
'.', vMIXED, 40, 0, 256, TRUE, FALSE);
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_fscale (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
CDKFSCALE *widget = newCDKFScale (cdkscreen, x, y,
|
||||
"FScale", "Value", A_NORMAL,
|
||||
15,
|
||||
0.0, 0.0, 100.0,
|
||||
1.0, (1.0 * 2.), 1,
|
||||
TRUE,
|
||||
FALSE);
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_fslider (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
float low = -32;
|
||||
float high = 64;
|
||||
float inc = (float)0.1;
|
||||
CDKFSLIDER *widget = newCDKFSlider (cdkscreen,
|
||||
x,
|
||||
y,
|
||||
"FSlider", "Label",
|
||||
A_REVERSE | COLOR_PAIR (29) | ' ',
|
||||
20,
|
||||
low, low, high, inc, (inc * 2),
|
||||
3,
|
||||
TRUE,
|
||||
FALSE);
|
||||
/* selection = activateCDKSlider (widget, 0); */
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_fselect (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
CDKFSELECT *widget = newCDKFselect (cdkscreen,
|
||||
x,
|
||||
y,
|
||||
15,
|
||||
25,
|
||||
"FSelect", "->", A_NORMAL, '_', A_REVERSE,
|
||||
"</5>", "</48>", "</N>", "</N>",
|
||||
TRUE,
|
||||
FALSE);
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_graph (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
static int values[] =
|
||||
{
|
||||
10, 15, 20, 25, 30, 35, 40, 45, 50, 55
|
||||
};
|
||||
static const char *graphChars = "0123456789";
|
||||
CDKGRAPH *widget = newCDKGraph (cdkscreen, x, y,
|
||||
10, 25,
|
||||
"title", "X-axis", "Y-axis");
|
||||
setCDKGraph (widget, values, NumElements (values), graphChars, TRUE, vPLOT);
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_histogram (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
CDKHISTOGRAM *widget = newCDKHistogram (cdkscreen,
|
||||
x,
|
||||
y,
|
||||
1,
|
||||
20,
|
||||
HORIZONTAL, "Histogram",
|
||||
TRUE,
|
||||
FALSE);
|
||||
setCDKHistogram (widget, vPERCENT, CENTER, A_BOLD, 0, 10, 6, ' ' |
|
||||
A_REVERSE, TRUE);
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_itemlist (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
CDKITEMLIST *widget = newCDKItemlist (cdkscreen, x, y,
|
||||
NULL, "Month ",
|
||||
(CDK_CSTRING2)months,
|
||||
NumElements (months),
|
||||
1, TRUE, FALSE);
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_label (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
static const char *message[] =
|
||||
{
|
||||
"This is a simple label."
|
||||
,"Is it simple enough?"
|
||||
};
|
||||
CDKLABEL *widget = newCDKLabel (cdkscreen,
|
||||
x,
|
||||
y,
|
||||
(CDK_CSTRING2)message, NumElements (message),
|
||||
TRUE,
|
||||
TRUE);
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_marquee (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
CDKMARQUEE *widget = newCDKMarquee (cdkscreen,
|
||||
x,
|
||||
y,
|
||||
30,
|
||||
TRUE,
|
||||
TRUE);
|
||||
activateCDKMarquee (widget, "This is a message", 5, 3, TRUE);
|
||||
destroyCDKMarquee (widget);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static CDKOBJS *make_matrix (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
#define NUMROWS 8
|
||||
#define NUMCOLS 5
|
||||
|
||||
CDKMATRIX *widget;
|
||||
const char *coltitle[NUMCOLS + 1];
|
||||
const char *rowtitle[NUMROWS + 1];
|
||||
char temp[80];
|
||||
int cols = NUMCOLS;
|
||||
int colwidth[NUMCOLS + 1];
|
||||
int coltypes[NUMCOLS + 1];
|
||||
int maxwidth = 0;
|
||||
int n;
|
||||
int rows = NUMROWS;
|
||||
int vcols = 3;
|
||||
int vrows = 3;
|
||||
|
||||
for (n = 0; n <= NUMROWS; ++n)
|
||||
{
|
||||
sprintf (temp, "row%d", n);
|
||||
rowtitle[n] = copyChar (temp);
|
||||
}
|
||||
for (n = 0; n <= NUMCOLS; ++n)
|
||||
{
|
||||
sprintf (temp, "col%d", n);
|
||||
coltitle[n] = copyChar (temp);
|
||||
colwidth[n] = (int)strlen (temp);
|
||||
coltypes[n] = vUCHAR;
|
||||
if (colwidth[n] > maxwidth)
|
||||
maxwidth = colwidth[n];
|
||||
}
|
||||
|
||||
widget = newCDKMatrix (cdkscreen,
|
||||
x,
|
||||
y,
|
||||
rows, cols, vrows, vcols,
|
||||
"Matrix", (CDK_CSTRING2)rowtitle, (CDK_CSTRING2)coltitle,
|
||||
colwidth, coltypes,
|
||||
-1, -1, '.',
|
||||
COL, TRUE,
|
||||
TRUE,
|
||||
FALSE);
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_mentry (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
CDKMENTRY *widget = newCDKMentry (cdkscreen,
|
||||
x,
|
||||
y,
|
||||
"MEntry", "Label", A_BOLD, '.', vMIXED,
|
||||
20,
|
||||
5,
|
||||
20,
|
||||
0,
|
||||
TRUE,
|
||||
FALSE);
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_radio (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
CDKRADIO *widget = newCDKRadio (cdkscreen,
|
||||
x,
|
||||
y,
|
||||
RIGHT,
|
||||
10,
|
||||
20,
|
||||
"Radio",
|
||||
(CDK_CSTRING2)months, NumElements (months),
|
||||
'#' | A_REVERSE, 1,
|
||||
A_REVERSE,
|
||||
TRUE,
|
||||
FALSE);
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_scale (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
int low = 2;
|
||||
int high = 25;
|
||||
int inc = 1;
|
||||
CDKSCALE *widget = newCDKScale (cdkscreen,
|
||||
x,
|
||||
y,
|
||||
"Scale", "Label", A_NORMAL,
|
||||
5,
|
||||
low, low, high,
|
||||
inc, (inc * 2),
|
||||
TRUE,
|
||||
FALSE);
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_scroll (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
CDKSCROLL *widget = newCDKScroll (cdkscreen,
|
||||
x,
|
||||
y,
|
||||
RIGHT,
|
||||
10,
|
||||
20,
|
||||
"Scroll",
|
||||
(CDK_CSTRING2)months, NumElements (months),
|
||||
TRUE,
|
||||
A_REVERSE,
|
||||
TRUE,
|
||||
FALSE);
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_slider (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
int low = 2;
|
||||
int high = 25;
|
||||
int inc = 1;
|
||||
CDKSLIDER *widget = newCDKSlider (cdkscreen,
|
||||
x,
|
||||
y,
|
||||
"Slider", "Label",
|
||||
A_REVERSE | COLOR_PAIR (29) | ' ',
|
||||
20,
|
||||
low, low, high, inc, (inc * 2),
|
||||
TRUE,
|
||||
FALSE);
|
||||
/* selection = activateCDKSlider (widget, 0); */
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_selection (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
CDKSELECTION *widget = newCDKSelection (cdkscreen, x, y,
|
||||
NONE, 8, 20, "Selection",
|
||||
(CDK_CSTRING2)months,
|
||||
NumElements (months),
|
||||
(CDK_CSTRING2)choices,
|
||||
NumElements (choices),
|
||||
A_REVERSE, TRUE, FALSE);
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_swindow (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
CDKSWINDOW *widget = newCDKSwindow (cdkscreen,
|
||||
x,
|
||||
y,
|
||||
6,
|
||||
25,
|
||||
"SWindow", 100,
|
||||
TRUE,
|
||||
FALSE);
|
||||
int n;
|
||||
for (n = 0; n < 30; ++n)
|
||||
{
|
||||
char temp[80];
|
||||
sprintf (temp, "Line %d", n);
|
||||
addCDKSwindow (widget, temp, BOTTOM);
|
||||
}
|
||||
activateCDKSwindow (widget, 0);
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_template (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
const char *Overlay = "</B/6>(___)<!6> </5>___-____";
|
||||
const char *plate = "(###) ###-####";
|
||||
CDKTEMPLATE *widget = newCDKTemplate (cdkscreen,
|
||||
x,
|
||||
y,
|
||||
"Template", "Label",
|
||||
plate, Overlay,
|
||||
TRUE,
|
||||
FALSE);
|
||||
activateCDKTemplate (widget, 0);
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_uscale (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
unsigned low = 0;
|
||||
unsigned high = 65535;
|
||||
unsigned inc = 1;
|
||||
CDKUSCALE *widget = newCDKUScale (cdkscreen,
|
||||
x,
|
||||
y,
|
||||
"UScale", "Label", A_NORMAL,
|
||||
5,
|
||||
low, low, high,
|
||||
inc, (inc * 32),
|
||||
TRUE,
|
||||
FALSE);
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_uslider (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
unsigned low = 0;
|
||||
unsigned high = 65535;
|
||||
unsigned inc = 1;
|
||||
CDKUSLIDER *widget = newCDKUSlider (cdkscreen,
|
||||
x,
|
||||
y,
|
||||
"USlider", "Label",
|
||||
A_REVERSE | COLOR_PAIR (29) | ' ',
|
||||
20,
|
||||
low, low, high, inc, (inc * 32),
|
||||
TRUE,
|
||||
FALSE);
|
||||
/* selection = activateCDKSlider (widget, 0); */
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static CDKOBJS *make_viewer (CDKSCREEN *cdkscreen, int x, int y)
|
||||
{
|
||||
static const char *button[1] =
|
||||
{
|
||||
"Ok"
|
||||
};
|
||||
CDKVIEWER *widget = newCDKViewer (cdkscreen,
|
||||
x,
|
||||
y,
|
||||
10,
|
||||
20,
|
||||
(CDK_CSTRING2)button, 1, A_REVERSE,
|
||||
TRUE,
|
||||
FALSE);
|
||||
setCDKViewer (widget, "Viewer",
|
||||
(CDK_CSTRING2)months, NumElements (months),
|
||||
A_REVERSE, FALSE, TRUE, TRUE);
|
||||
activateCDKViewer (widget, 0);
|
||||
return ObjPtr (widget);
|
||||
}
|
||||
|
||||
static void rebind_esc (CDKOBJS *obj)
|
||||
{
|
||||
bindCDKObject (ObjTypeOf (obj), obj, KEY_F (1), getcCDKBind, (void *)KEY_ESC);
|
||||
}
|
||||
|
||||
static void make_any (CDKSCREEN *cdkscreen, int menu, EObjectType type)
|
||||
{
|
||||
CDKOBJS *(*func) (CDKSCREEN *, int, int) = 0;
|
||||
CDKOBJS *prior = 0;
|
||||
int x;
|
||||
int y;
|
||||
|
||||
/* setup positions, staggered a little */
|
||||
switch (menu)
|
||||
{
|
||||
case 0:
|
||||
x = LEFT;
|
||||
y = 2;
|
||||
break;
|
||||
case 1:
|
||||
x = CENTER;
|
||||
y = 4;
|
||||
break;
|
||||
case 2:
|
||||
x = RIGHT;
|
||||
y = 6;
|
||||
break;
|
||||
default:
|
||||
beep ();
|
||||
return;
|
||||
}
|
||||
|
||||
/* find the function to make a widget of the given type */
|
||||
switch (type)
|
||||
{
|
||||
case vALPHALIST:
|
||||
func = make_alphalist;
|
||||
break;
|
||||
case vBUTTON:
|
||||
func = make_button;
|
||||
break;
|
||||
case vBUTTONBOX:
|
||||
func = make_buttonbox;
|
||||
break;
|
||||
case vCALENDAR:
|
||||
func = make_calendar;
|
||||
break;
|
||||
case vDIALOG:
|
||||
func = make_dialog;
|
||||
break;
|
||||
case vDSCALE:
|
||||
func = make_dscale;
|
||||
break;
|
||||
case vENTRY:
|
||||
func = make_entry;
|
||||
break;
|
||||
case vFSCALE:
|
||||
func = make_fscale;
|
||||
break;
|
||||
case vFSELECT:
|
||||
func = make_fselect;
|
||||
break;
|
||||
case vFSLIDER:
|
||||
func = make_fslider;
|
||||
break;
|
||||
case vGRAPH:
|
||||
func = make_graph;
|
||||
break;
|
||||
case vHISTOGRAM:
|
||||
func = make_histogram;
|
||||
break;
|
||||
case vITEMLIST:
|
||||
func = make_itemlist;
|
||||
break;
|
||||
case vLABEL:
|
||||
func = make_label;
|
||||
break;
|
||||
case vMARQUEE:
|
||||
func = make_marquee;
|
||||
break;
|
||||
case vMATRIX:
|
||||
func = make_matrix;
|
||||
break;
|
||||
case vMENTRY:
|
||||
func = make_mentry;
|
||||
break;
|
||||
case vRADIO:
|
||||
func = make_radio;
|
||||
break;
|
||||
case vSCALE:
|
||||
func = make_scale;
|
||||
break;
|
||||
case vSCROLL:
|
||||
func = make_scroll;
|
||||
break;
|
||||
case vSELECTION:
|
||||
func = make_selection;
|
||||
break;
|
||||
case vSLIDER:
|
||||
func = make_slider;
|
||||
break;
|
||||
case vSWINDOW:
|
||||
func = make_swindow;
|
||||
break;
|
||||
case vTEMPLATE:
|
||||
func = make_template;
|
||||
break;
|
||||
case vUSCALE:
|
||||
func = make_uscale;
|
||||
break;
|
||||
case vUSLIDER:
|
||||
func = make_uslider;
|
||||
break;
|
||||
case vVIEWER:
|
||||
func = make_viewer;
|
||||
break;
|
||||
case vMENU:
|
||||
case vTRAVERSE:
|
||||
case vNULL:
|
||||
if (type > 0)
|
||||
beep ();
|
||||
return;
|
||||
}
|
||||
|
||||
/* erase the old widget */
|
||||
if ((prior = all_objects[menu]) != 0)
|
||||
{
|
||||
EraseObj (prior);
|
||||
_destroyCDKObject (prior);
|
||||
all_objects[menu] = 0;
|
||||
}
|
||||
|
||||
/* create the new widget */
|
||||
if (func != 0)
|
||||
{
|
||||
CDKOBJS *widget = func (cdkscreen, x, y);
|
||||
if (widget != 0)
|
||||
{
|
||||
all_objects[menu] = widget;
|
||||
rebind_esc (widget);
|
||||
}
|
||||
else
|
||||
flash ();
|
||||
}
|
||||
else
|
||||
{
|
||||
beep ();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Whenever we get a menu selection, create the selected widget.
|
||||
*/
|
||||
static int preHandler (EObjectType cdktype GCC_UNUSED, void *object,
|
||||
void *clientData GCC_UNUSED,
|
||||
chtype input GCC_UNUSED)
|
||||
{
|
||||
int mp, sp;
|
||||
CDKSCREEN *screen;
|
||||
WINDOW *window;
|
||||
|
||||
switch (input)
|
||||
{
|
||||
case KEY_ENTER:
|
||||
getCDKMenuCurrentItem ((CDKMENU *)object, &mp, &sp);
|
||||
|
||||
screen = ScreenOf ((CDKMENU *)object);
|
||||
window = screen->window;
|
||||
mvwprintw (window, getmaxy (window) - 1, 0, "selection %d/%d", mp, sp);
|
||||
clrtoeol ();
|
||||
refresh ();
|
||||
if (sp >= 0 && sp < (int)NumElements (menu_table))
|
||||
make_any (screen, mp, menu_table[sp].type);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* This demonstrates the Cdk widget-traversal.
|
||||
*/
|
||||
int main (int argc GCC_UNUSED, char **argv GCC_UNUSED)
|
||||
{
|
||||
unsigned j, k;
|
||||
|
||||
/* Declare local variables. */
|
||||
CDKSCREEN *cdkscreen = NULL;
|
||||
CDKMENU *menu = NULL;
|
||||
const char *mesg[3];
|
||||
static const char *menulist[MAX_MENU_ITEMS][MAX_SUB_ITEMS] =
|
||||
{
|
||||
{"Left"},
|
||||
{"Center"},
|
||||
{"Right"},
|
||||
};
|
||||
static int submenusize[] =
|
||||
{
|
||||
NumElements (menu_table) + 1,
|
||||
NumElements (menu_table) + 1,
|
||||
NumElements (menu_table) + 1
|
||||
};
|
||||
static int menuloc[] =
|
||||
{LEFT, LEFT, RIGHT};
|
||||
|
||||
for (j = 0; j < MY_MAX; ++j)
|
||||
{
|
||||
for (k = 0; k < NumElements (menu_table); ++k)
|
||||
{
|
||||
menulist[j][k + 1] = menu_table[k].name;
|
||||
}
|
||||
}
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start CDK colors. */
|
||||
initCDKColor ();
|
||||
|
||||
|
||||
menu = newCDKMenu (cdkscreen, menulist, MY_MAX, submenusize, menuloc,
|
||||
TOP, A_UNDERLINE, A_REVERSE);
|
||||
if (menu == 0)
|
||||
{
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("? Cannot create menus\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
rebind_esc (ObjOf (menu));
|
||||
|
||||
setCDKMenuPreProcess (menu, preHandler, 0);
|
||||
|
||||
/* setup the initial display */
|
||||
make_any (cdkscreen, 0, vENTRY);
|
||||
#if MY_MAX > 1
|
||||
make_any (cdkscreen, 1, vITEMLIST);
|
||||
#if MY_MAX > 2
|
||||
make_any (cdkscreen, 2, vSELECTION);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Draw the screen. */
|
||||
refreshCDKScreen (cdkscreen);
|
||||
|
||||
/* Traverse the screen */
|
||||
traverseCDKScreen (cdkscreen);
|
||||
|
||||
mesg[0] = "Done";
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 3);
|
||||
|
||||
/* Clean up and exit. */
|
||||
for (j = 0; j < MY_MAX; ++j)
|
||||
{
|
||||
if (all_objects[j] != 0)
|
||||
_destroyCDKObject (all_objects[j]);
|
||||
}
|
||||
destroyCDKMenu (menu);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
89
deps/cdk-5.0-20161210/examples/uslider_ex.c
vendored
Normal file
89
deps/cdk-5.0-20161210/examples/uslider_ex.c
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
/* $Id: uslider_ex.c,v 1.5 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "uslider_ex";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This program demonstrates the Cdk unsigned-slider widget.
|
||||
*/
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKSCREEN *cdkscreen = 0;
|
||||
CDKUSLIDER *widget = 0;
|
||||
char title[256];
|
||||
const char *label = "</B>Current Value:";
|
||||
const char *mesg[5];
|
||||
char temp[256];
|
||||
unsigned selection;
|
||||
|
||||
CDK_PARAMS params;
|
||||
unsigned high;
|
||||
unsigned inc;
|
||||
unsigned low;
|
||||
|
||||
/* *INDENT-EQLS* */
|
||||
CDKparseParams (argc, argv, ¶ms, "h:i:l:w:" CDK_MIN_PARAMS);
|
||||
high = (unsigned)CDKparamNumber2 (¶ms, 'h', 100);
|
||||
inc = (unsigned)CDKparamNumber2 (¶ms, 'i', 1);
|
||||
low = (unsigned)CDKparamNumber2 (¶ms, 'l', 1);
|
||||
|
||||
sprintf (title, "<C></U>Enter a value:\nLow %#x\nHigh %#x", low, high);
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start CDK Colors. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Create the widget. */
|
||||
widget = newCDKUSlider (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
title, label,
|
||||
A_REVERSE | COLOR_PAIR (29) | ' ',
|
||||
CDKparamNumber2 (¶ms, 'w', 50),
|
||||
low, low, high,
|
||||
inc, (inc * 2),
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
|
||||
/* Is the widget null? */
|
||||
if (widget == 0)
|
||||
{
|
||||
/* Exit CDK. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot make the widget. Is the window too small?\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Activate the widget. */
|
||||
selection = activateCDKUSlider (widget, 0);
|
||||
|
||||
/* Check the exit value of the widget. */
|
||||
if (widget->exitType == vESCAPE_HIT)
|
||||
{
|
||||
mesg[0] = "<C>You hit escape. No value selected.";
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
else if (widget->exitType == vNORMAL)
|
||||
{
|
||||
sprintf (temp, "<C>You selected %u", selection);
|
||||
mesg[0] = temp;
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3);
|
||||
}
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKUSlider (widget);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
177
deps/cdk-5.0-20161210/examples/viewer_ex.c
vendored
Normal file
177
deps/cdk-5.0-20161210/examples/viewer_ex.c
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
/* $Id: viewer_ex.c,v 1.22 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "viewer_ex";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This program demonstrates the file selector and the viewer widget.
|
||||
*/
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKSCREEN *cdkscreen = 0;
|
||||
CDKVIEWER *example = 0;
|
||||
CDKFSELECT *fSelect = 0;
|
||||
char **info = 0;
|
||||
const char *button[5];
|
||||
char vTitle[256];
|
||||
const char *mesg[4];
|
||||
char temp[256];
|
||||
int selected, lines;
|
||||
|
||||
CDK_PARAMS params;
|
||||
char *filename; /* specify filename, bypassing fselect */
|
||||
char *directory; /* specify starting directory for fselect */
|
||||
int interp_it; /* interpret embedded markup */
|
||||
int link_it; /* load file via embedded link */
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, "f:d:il" CDK_CLI_PARAMS);
|
||||
/* *INDENT-EQLS* */
|
||||
filename = CDKparamString (¶ms, 'f');
|
||||
directory = CDKparamString2 (¶ms, 'd', ".");
|
||||
interp_it = CDKparamNumber2 (¶ms, 'i', FALSE);
|
||||
link_it = CDKparamNumber2 (¶ms, 'l', FALSE);
|
||||
|
||||
/* Create the viewer buttons. */
|
||||
button[0] = "</5><OK><!5>";
|
||||
button[1] = "</5><Cancel><!5>";
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start color. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Get the filename. */
|
||||
if (filename == 0)
|
||||
{
|
||||
const char *title = "<C>Pick\n<C>A\n<C>File";
|
||||
const char *label = "File: ";
|
||||
|
||||
fSelect = newCDKFselect (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
CDKparamValue (¶ms, 'H', 20),
|
||||
CDKparamValue (¶ms, 'W', 65),
|
||||
title, label, A_NORMAL, '_', A_REVERSE,
|
||||
"</5>", "</48>", "</N>", "</N>",
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
if (fSelect == 0)
|
||||
{
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
fprintf (stderr, "Cannot create fselect-widget\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the starting directory. This is not necessary because when
|
||||
* the file selector starts it uses the present directory as a default.
|
||||
*/
|
||||
setCDKFselect (fSelect, directory, A_NORMAL, '.', A_REVERSE,
|
||||
"</5>", "</48>", "</N>", "</N>", ObjOf (fSelect)->box);
|
||||
|
||||
/* Activate the file selector. */
|
||||
filename = activateCDKFselect (fSelect, 0);
|
||||
|
||||
/* Check how the person exited from the widget. */
|
||||
if (fSelect->exitType == vESCAPE_HIT)
|
||||
{
|
||||
/* Pop up a message for the user. */
|
||||
mesg[0] = "<C>Escape hit. No file selected.";
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 3);
|
||||
|
||||
/* Exit CDK. */
|
||||
destroyCDKFselect (fSelect);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
/* Create the file viewer to view the file selected. */
|
||||
example = newCDKViewer (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
CDKparamValue (¶ms, 'H', 20),
|
||||
CDKparamValue (¶ms, 'W', -2),
|
||||
(CDK_CSTRING2)button, 2, A_REVERSE,
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
|
||||
/* Could we create the viewer widget? */
|
||||
if (example == 0)
|
||||
{
|
||||
/* Exit CDK. */
|
||||
destroyCDKFselect (fSelect);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
printf ("Cannot create viewer. Is the window too small?\n");
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (link_it)
|
||||
{
|
||||
info = (char **)calloc (2, sizeof (char *));
|
||||
info[0] = (char *)malloc (5 + strlen (filename));
|
||||
sprintf (info[0], "<F=%s>", filename);
|
||||
lines = -1;
|
||||
interp_it = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
setCDKViewer (example, "reading...", 0, 0, A_REVERSE, TRUE, TRUE, TRUE);
|
||||
/* Open the file and read the contents. */
|
||||
lines = CDKreadFile (filename, &info);
|
||||
if (lines == -1)
|
||||
{
|
||||
endCDK ();
|
||||
printf ("Could not open \"%s\"\n", filename);
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set up the viewer title, and the contents to the widget. */
|
||||
sprintf (vTitle, "<C></B/21>Filename:<!21></22>%20s<!22!B>", filename);
|
||||
setCDKViewer (example, vTitle,
|
||||
(CDK_CSTRING2)info, lines,
|
||||
A_REVERSE, interp_it, TRUE, TRUE);
|
||||
|
||||
CDKfreeStrings (info);
|
||||
|
||||
/* Destroy the file selector widget. */
|
||||
destroyCDKFselect (fSelect);
|
||||
|
||||
/* Activate the viewer widget. */
|
||||
selected = activateCDKViewer (example, 0);
|
||||
|
||||
/* Check how the person exited from the widget. */
|
||||
if (example->exitType == vESCAPE_HIT)
|
||||
{
|
||||
mesg[0] = "<C>Escape hit. No Button selected.";
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 3);
|
||||
}
|
||||
else if (example->exitType == vNORMAL)
|
||||
{
|
||||
sprintf (temp, "<C>You selected button %d", selected);
|
||||
mesg[0] = temp;
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 3);
|
||||
}
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKViewer (example);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
114
deps/cdk-5.0-20161210/examples/viewer_ex2.c
vendored
Normal file
114
deps/cdk-5.0-20161210/examples/viewer_ex2.c
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
/* $Id: viewer_ex2.c,v 1.8 2016/12/04 15:22:16 tom Exp $ */
|
||||
|
||||
#include <cdk_test.h>
|
||||
|
||||
#ifdef HAVE_XCURSES
|
||||
char *XCursesProgramName = "viewer_ex";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This program demonstrates the viewFile() function.
|
||||
*/
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* *INDENT-EQLS* */
|
||||
CDKSCREEN *cdkscreen = 0;
|
||||
CDKFSELECT *fSelect = 0;
|
||||
const char *button[5];
|
||||
char vTitle[256];
|
||||
const char *mesg[4];
|
||||
char temp[256];
|
||||
int selected;
|
||||
|
||||
CDK_PARAMS params;
|
||||
char *filename; /* specify filename, bypassing fselect */
|
||||
char *directory; /* specify starting directory for fselect */
|
||||
int interp_it; /* interpret embedded markup */
|
||||
|
||||
CDKparseParams (argc, argv, ¶ms, "f:d:i" CDK_CLI_PARAMS);
|
||||
/* *INDENT-EQLS* */
|
||||
filename = CDKparamString (¶ms, 'f');
|
||||
directory = CDKparamString2 (¶ms, 'd', ".");
|
||||
interp_it = CDKparamNumber2 (¶ms, 'i', FALSE);
|
||||
|
||||
/* Create the viewer buttons. */
|
||||
button[0] = "</5><OK><!5>";
|
||||
button[1] = "</5><Cancel><!5>";
|
||||
|
||||
cdkscreen = initCDKScreen (NULL);
|
||||
|
||||
/* Start color. */
|
||||
initCDKColor ();
|
||||
|
||||
/* Get the filename. */
|
||||
if (filename == 0)
|
||||
{
|
||||
const char *title = "<C>Pick\n<C>A\n<C>File";
|
||||
const char *label = "File: ";
|
||||
|
||||
fSelect = newCDKFselect (cdkscreen,
|
||||
CDKparamValue (¶ms, 'X', CENTER),
|
||||
CDKparamValue (¶ms, 'Y', CENTER),
|
||||
CDKparamValue (¶ms, 'H', 20),
|
||||
CDKparamValue (¶ms, 'W', 65),
|
||||
title, label, A_NORMAL, '_', A_REVERSE,
|
||||
"</5>", "</48>", "</N>", "</N>",
|
||||
CDKparamValue (¶ms, 'N', TRUE),
|
||||
CDKparamValue (¶ms, 'S', FALSE));
|
||||
if (fSelect == 0)
|
||||
{
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
fprintf (stderr, "Cannot create fselect-widget\n");
|
||||
ExitProgram (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the starting directory. This is not necessary because when
|
||||
* the file selector starts it uses the present directory as a default.
|
||||
*/
|
||||
setCDKFselect (fSelect, directory, A_NORMAL, '.', A_REVERSE,
|
||||
"</5>", "</48>", "</N>", "</N>", ObjOf (fSelect)->box);
|
||||
|
||||
/* Activate the file selector. */
|
||||
filename = activateCDKFselect (fSelect, 0);
|
||||
|
||||
/* Check how the person exited from the widget. */
|
||||
if (fSelect->exitType == vESCAPE_HIT)
|
||||
{
|
||||
/* Pop up a message for the user. */
|
||||
mesg[0] = "<C>Escape hit. No file selected.";
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 3);
|
||||
|
||||
/* Exit CDK. */
|
||||
destroyCDKFselect (fSelect);
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set up the viewer title, and the contents to the widget. */
|
||||
sprintf (vTitle, "<C></B/21>Filename:<!21></22>%20s<!22!B>", filename);
|
||||
|
||||
selected = viewFile (cdkscreen, vTitle, filename, (CDK_CSTRING2)button, 2);
|
||||
|
||||
/* Destroy the file selector widget (do not need filename anymore) */
|
||||
destroyCDKFselect (fSelect);
|
||||
|
||||
/* Check how the person exited from the widget. */
|
||||
sprintf (temp, "<C>You selected button %d", selected);
|
||||
mesg[0] = temp;
|
||||
mesg[1] = "";
|
||||
mesg[2] = "<C>Press any key to continue.";
|
||||
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 3);
|
||||
|
||||
/* Clean up. */
|
||||
destroyCDKScreen (cdkscreen);
|
||||
endCDK ();
|
||||
ExitProgram (EXIT_SUCCESS);
|
||||
}
|
Reference in New Issue
Block a user