1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
/*
* Motif
*
* Copyright (c) 1987-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these librararies and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/*
* HISTORY
*/
#ifdef REV_INFO
#ifndef lint
static char rcsid[] = "$XConsortium: Command1.c /main/7 1995/07/13 19:16:34 drk $"
#endif
#endif
/*
* (c) Copyright 1987, 1988, 1989 HEWLETT-PACKARD COMPANY */
#include <testlib.h>
#define NITEMS 14
#define VITEMS 10
char *Istrings[] = {
"btest1a",
"decor00",
"decor06",
"func00",
"func05",
"func10",
"iplac00",
"iplac05",
"menu00",
"menu04",
"mtest1",
"parse00",
"prop00",
"rstest1"
};
Widget Command1;
void main(argc, argv)
int argc;
char **argv;
{
register int n;
Arg args[MAX_ARGS];
XmString tcs, ItemList[NITEMS];
Widget ChildW, Frame;
CommonTestInit(argc, argv);
n = 0;
Frame = XmCreateFrame(Shell1, "Frame1", args, n);
XtManageChild(Frame);
/* Convert the items to Xm strings */
for (n = 0; n < NITEMS; n++)
ItemList[n] = XmStringLtoRCreate(Istrings[n], XmSTRING_DEFAULT_CHARSET);
tcs = XmStringLtoRCreate("Pick a Command",XmSTRING_DEFAULT_CHARSET);
/* add them to the widget's list */
n = 0;
XtSetArg(args[n], XmNhistoryItems, ItemList); n++;
XtSetArg(args[n], XmNhistoryItemCount, NITEMS); n++;
XtSetArg(args[n], XmNhistoryVisibleItemCount, VITEMS); n++;
XtSetArg(args[n], XmNlistLabelString, tcs); n++;
XtSetArg(args[n], XmNforeground, CommonGetColor("white")); n++;
Command1 = XmCreateCommand(Frame, "Command1", args, n);
XtManageChild(Command1);
XmStringFree(tcs);
/* Set up the initial command */
tcs = XmStringLtoRCreate("ls ",XmSTRING_DEFAULT_CHARSET);
XmCommandSetValue(Command1, tcs);
XmStringFree(tcs);
tcs = XmStringLtoRCreate("-l",XmSTRING_DEFAULT_CHARSET);
XmCommandAppendValue(Command1, tcs);
XmStringFree(tcs);
/* use XtSetValues to change prompt */
tcs = XmStringLtoRCreate(">>",XmSTRING_DEFAULT_CHARSET);
n = 0;
XtSetArg(args[n], XmNpromptString, tcs); n++;
XtSetValues(Command1,args,n);
XmStringFree(tcs);
/* See about the children */
ChildW = XmCommandGetChild(Command1,XmDIALOG_PROMPT_LABEL);
printf("Prompt Label Child Name - %s\n", XtName(ChildW));
ChildW = XmCommandGetChild(Command1,XmDIALOG_COMMAND_TEXT);
printf("Command Text Child Name - %s\n", XtName(ChildW));
ChildW = XmCommandGetChild(Command1,XmDIALOG_HISTORY_LIST);
printf("History List Child Name - %s\n", XtName(ChildW));
fflush(stdout);
/* add an error message to the list */
tcs = XmStringLtoRCreate("erroror",XmSTRING_DEFAULT_CHARSET);
XmCommandError(Command1,tcs);
XmStringFree(tcs);
/* realize widgets */
XtRealizeWidget(Shell1);
CommonPause();
CommonPause();
CommonPause();
CommonPause();
XtAppMainLoop(app_context);
}
|