summaryrefslogtreecommitdiff
path: root/xc/unsupported
diff options
context:
space:
mode:
authorkit <empty>1989-10-08 16:01:42 +0000
committerkit <empty>1989-10-08 16:01:42 +0000
commit7b9f44c1e79dbaeb7f2361bda37c9d633cfdda06 (patch)
treeaef6027c9cbfb27ff7beee732279d6a76f70529b /xc/unsupported
parent5c95590374fad62cb3938b53c3de952bc70fefe6 (diff)
I have updated things to use the new text widget interface. There were
not alot of changes, and I tried to leave most of the logic alone. I did, however, make a change that causes the "record" popup to never be destroyed, and I keep all the widgets around rather than just the filename. This fits better with the model, and should also save a bunch of widget creations.
Diffstat (limited to 'xc/unsupported')
-rw-r--r--xc/unsupported/programs/xgc/getfile.c34
-rw-r--r--xc/unsupported/programs/xgc/main.c7
-rw-r--r--xc/unsupported/programs/xgc/record.c19
-rw-r--r--xc/unsupported/programs/xgc/tests.c16
-rw-r--r--xc/unsupported/programs/xgc/text.c5
5 files changed, 37 insertions, 44 deletions
diff --git a/xc/unsupported/programs/xgc/getfile.c b/xc/unsupported/programs/xgc/getfile.c
index d09cb794b..335ecb5f1 100644
--- a/xc/unsupported/programs/xgc/getfile.c
+++ b/xc/unsupported/programs/xgc/getfile.c
@@ -17,9 +17,9 @@
extern XStuff X;
extern Widget topform;
-static Widget popupshell; /* popup dialog box */
-char filename[60]; /* the name of the file the user
- has selected */
+static Widget popupshell = NULL; /* popup dialog box */
+Widget filename_text_widget; /* Widget containing the name of
+ the file the user has selected */
extern XtAppContext appcontext;
void kill_popup_shell();
@@ -33,7 +33,6 @@ get_filename(success,failure)
{
static Widget popupform; /* form inside shell */
static Widget label; /* "Filename :" */
- static Widget text; /* where the user edits filename */
static Widget cancel; /* command, select to cancel */
Window dummy1, dummy2;
@@ -77,12 +76,9 @@ get_filename(success,failure)
static Arg textargs[] = { /* ArgList for the text widget */
{XtNeditType, (XtArgVal) XawtextEdit},
- {XtNstring, (XtArgVal) NULL},
- {XtNlength, (XtArgVal) NULL},
- {XtNwidth, (XtArgVal) NULL},
+ {XtNwidth, (XtArgVal) 200},
{XtNhorizDistance, (XtArgVal) 10},
{XtNfromHoriz, (XtArgVal) NULL},
- {XtNinsertPosition, (XtArgVal) NULL}
};
static Arg cancelargs[] = { /* ArgList for the cancel button */
@@ -97,6 +93,11 @@ get_filename(success,failure)
{NULL, NULL}
};
+ if (popupshell != NULL) {
+ XtPopup(popupshell,XtGrabExclusive);
+ return;
+ }
+
/* Find out where the pointer is, so we can put the popup window there */
(void) XQueryPointer(X.dpy,XtWindow(topform),&dummy1,&dummy2,&x1,&y1,
@@ -114,14 +115,11 @@ get_filename(success,failure)
label = XtCreateManagedWidget("Filename: ",labelWidgetClass,popupform,
labelargs,XtNumber(labelargs));
- textargs[1].value = (XtArgVal) filename;
- textargs[2].value = (XtArgVal) 40;
- textargs[3].value = (XtArgVal) 200;
- textargs[5].value = (XtArgVal) label;
- textargs[6].value = (XtArgVal) strlen(filename);
+ textargs[3].value = (XtArgVal) label;
- text = XtCreateManagedWidget("text",asciiStringWidgetClass,popupform,
- textargs,XtNumber(textargs));
+ filename_text_widget = XtCreateManagedWidget("text",asciiTextWidgetClass,
+ popupform,
+ textargs,XtNumber(textargs));
/* Complete the action table. We have to do it here because success
** isn't known at compile time. */
@@ -131,10 +129,11 @@ get_filename(success,failure)
/* Register actions, translations, callbacks */
XtAppAddActions(appcontext,actiontable,XtNumber(actiontable));
- XtOverrideTranslations(text,XtParseTranslationTable(translationtable));
+ XtOverrideTranslations(filename_text_widget,
+ XtParseTranslationTable(translationtable));
cancelcallbacklist[1].callback = (XtCallbackProc) failure;
- cancelargs[0].value = (XtArgVal) text;
+ cancelargs[0].value = (XtArgVal) filename_text_widget;
cancelargs[1].value = (XtArgVal) cancelcallbacklist;
cancel = XtCreateManagedWidget("Cancel",commandWidgetClass,popupform,
@@ -155,5 +154,4 @@ static void
kill_popup_shell()
{
XtPopdown(popupshell);
- XtDestroyWidget(popupshell);
}
diff --git a/xc/unsupported/programs/xgc/main.c b/xc/unsupported/programs/xgc/main.c
index a5ecd8b78..b4c9a6713 100644
--- a/xc/unsupported/programs/xgc/main.c
+++ b/xc/unsupported/programs/xgc/main.c
@@ -46,7 +46,6 @@ FILE *outend;
#endif
XStuff X; /* GC stuff plus some global variables */
-char resultstring[80] = "";
Boolean recording = FALSE; /* Whether we're recording into a file */
XtAppContext appcontext; /* To make Xt happy */
@@ -112,8 +111,7 @@ main(argc,argv)
{XtNheight, (XtArgVal) 50},
{XtNwidth, (XtArgVal) 400},
{XtNfromHoriz, (XtArgVal) NULL}, /* put it to the right of GCform */
- {XtNfromVert, (XtArgVal) NULL}, /* and under test */
- {XtNstring, (XtArgVal) NULL}
+ {XtNfromVert, (XtArgVal) NULL} /* and under test */
};
static Arg gcchoiceargs[] = {
@@ -249,8 +247,7 @@ main(argc,argv)
resultargs[2].value = (XtArgVal) GCform; /* to the right of */
resultargs[3].value = (XtArgVal) test; /* under */
- resultargs[4].value = (XtArgVal) resultstring;
- result = XtCreateManagedWidget("result",asciiStringWidgetClass,topform,
+ result = XtCreateManagedWidget("result",asciiTextWidgetClass,topform,
resultargs,XtNumber(resultargs));
/* Now realize all the widgets */
diff --git a/xc/unsupported/programs/xgc/record.c b/xc/unsupported/programs/xgc/record.c
index 5e20cd064..cde4649b6 100644
--- a/xc/unsupported/programs/xgc/record.c
+++ b/xc/unsupported/programs/xgc/record.c
@@ -33,9 +33,7 @@ extern XgcStuff ArcmodeStuff;
extern XStuff X;
extern Boolean recording;
-extern Widget recordbutton;
-
-extern char filename[]; /* name of the file we're recording to */
+extern Widget filename_text_widget, recordbutton;
void cancel_record();
void done_choosing_filename();
@@ -126,9 +124,12 @@ done_choosing_filename()
{XtNlabel, (XtArgVal) NULL},
{XtNresize, (XtArgVal) True}
};
-
- char tmp[20];
-
+ Arg args[1];
+ char tmp[20], *filename;
+
+ XtSetArg(args[0], XtNstring, &filename);
+ XtGetValues(filename_text_widget, args, (Cardinal) 1);
+
if (recordfile = fopen(filename,"w")) {
recording = TRUE;
sprintf(tmp,"End Record");
@@ -271,6 +272,12 @@ cancel_playback()
static void
chose_playback_filename()
{
+ Arg args[1];
+ char *filename;
+
+ XtSetArg(args[0], XtNstring, &filename);
+ XtGetValues(filename_text_widget, args, (Cardinal) 1);
+
if (playbackfile = fopen(filename,"r")) {
yyin = playbackfile;
yyparse();
diff --git a/xc/unsupported/programs/xgc/tests.c b/xc/unsupported/programs/xgc/tests.c
index 51f7c981c..689f08ce1 100644
--- a/xc/unsupported/programs/xgc/tests.c
+++ b/xc/unsupported/programs/xgc/tests.c
@@ -524,20 +524,10 @@ set_text(w,string)
Widget w;
char *string;
{
- static Arg args[] = {
- {XtNstring, (XtArgVal) NULL}
- };
- XawTextSource source;
- char *current_string;
+ static Arg args[1];
- args[0].value = (XtArgVal) &current_string;
- XtGetValues(w,args,XtNumber(args));
-
- strcpy(current_string,string);
-
- args[0].value = (XtArgVal) current_string;
- source = XawStringSourceCreate(w,args,XtNumber(args));
- XawTextSetSource(w,source,(XawTextPosition) 0);
+ XtSetArg(args[0], XtNstring, string);
+ XtSetValues(w, args, (Cardinal) 1 );
}
void
diff --git a/xc/unsupported/programs/xgc/text.c b/xc/unsupported/programs/xgc/text.c
index 2e1f31251..fad7b6c98 100644
--- a/xc/unsupported/programs/xgc/text.c
+++ b/xc/unsupported/programs/xgc/text.c
@@ -74,7 +74,8 @@ create_text_choice(w,type,length,width)
{XtNwidth, (XtArgVal) NULL},
{XtNhorizDistance, (XtArgVal) 10},
{XtNfromHoriz, (XtArgVal) NULL},
- {XtNinsertPosition, (XtArgVal) NULL}
+ {XtNinsertPosition, (XtArgVal) NULL},
+ {XtNuseStringInPlace, (XtArgVal) True}
};
static Widget text; /* the text widget */
@@ -124,7 +125,7 @@ create_text_choice(w,type,length,width)
textargs[5].value = (XtArgVal) label;
textargs[6].value = (XtArgVal) strlen(textstrings[type]);
- text = XtCreateManagedWidget("text",asciiStringWidgetClass,w,
+ text = XtCreateManagedWidget("text", asciiTextWidgetClass,w,
textargs,XtNumber(textargs));
/* Register the actions and translations */