source: trunk/third/xmh/pick.c @ 9658

Revision 9658, 20.6 KB checked in by ghudson, 28 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r9657, which included commits to RCS files with non-trunk default branches.
Line 
1/*
2 * $XConsortium: pick.c,v 2.45 91/07/17 21:26:54 converse Exp $
3 *
4 *
5 *                        COPYRIGHT 1987
6 *                 DIGITAL EQUIPMENT CORPORATION
7 *                     MAYNARD, MASSACHUSETTS
8 *                      ALL RIGHTS RESERVED.
9 *
10 * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
11 * SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
12 * DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR
13 * ANY PURPOSE.  IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
14 *
15 * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT
16 * RIGHTS, APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN
17 * ADDITION TO THAT SET FORTH ABOVE.
18 *
19 * Permission to use, copy, modify, and distribute this software and its
20 * documentation for any purpose and without fee is hereby granted, provided
21 * that the above copyright notice appear in all copies and that both that
22 * copyright notice and this permission notice appear in supporting
23 * documentation, and that the name of Digital Equipment Corporation not be
24 * used in advertising or publicity pertaining to distribution of the software
25 * without specific, written prior permission.
26 */
27
28/* pick.c -- handle a pick subwidget. */
29
30#include "xmh.h"
31
32#define WTlabel         labelWidgetClass
33#define WTbutton        commandWidgetClass
34#define WTtextentry     asciiTextWidgetClass
35
36#define RTfrom          0
37#define RTto            1
38#define RTcc            2
39#define RTdate          3
40#define RTsubject       4
41#define RTsearch        5
42#define RTother         6
43#define RTignore        7
44
45#define FIRSTROWTYPE            RTfrom
46#define LASTUSEFULROWTYPE       RTother
47#define NUMROWTYPE              (RTignore+1)
48
49static int stdwidth = -1;       /* Width to make text fields, and other
50                                   things that want to be the same width as
51                                   text fields. */
52
53static char *TypeName[NUMROWTYPE];
54static short true_data = 1;     /* radio data */
55static short false_data = 0;    /* radio data */
56
57typedef struct {
58   WidgetClass  type;           /* Encode what type of Widget this is. */
59   Widget       widget;         /* The widget id itself. */
60   struct _RowListRec *row;     /* Which row this widget is in. */
61} FormEntryRec, *FormEntry;
62
63typedef struct _RowListRec {
64   short        type;           /* Encode what type of list this is. */
65   Widget       widget;         /* Widget containing this row */
66   short        numwidgets;     /* How many widgets in this list. */
67   FormEntry    *wlist;         /* List of widgets. */
68   struct _GroupRec *group;     /* Which group this is in. */
69} RowListRec, *RowList;
70
71typedef struct _GroupRec {
72   short         numrows;       /* How many rows of widget. */
73   Widget       widget;         /* Widget containing this group */
74   RowList      *rlist;         /* List of widget rows. */
75   struct _FormBoxRec *form;    /* Which form this is in. */
76} GroupRec, *Group;
77
78typedef struct _FormBoxRec {
79   Widget outer;        /* Outer widget (contains scrollbars if any) */
80   Widget inner;        /* Inner widget (contains master form) */
81   short numgroups;     /* How many groups of form entries we have. */
82   Group *glist;        /* List of form groups. */
83   struct _PickRec *pick; /* Which pick this is in. */
84} FormBoxRec, *FormBox;
85
86typedef struct _PickRec {
87   Scrn scrn;                   /* Scrn containing this pick. */
88   Widget label;                /* Widget with label for this pick. */
89   Toc toc;                     /* Toc for folder being scanned. */
90   FormBox general;             /* Form for general info about this pick. */
91   FormBox details;             /* Form for details about this pick. */
92} PickRec;
93
94
95static FormEntry CreateWidget();
96static void DeleteWidget(), AddDetailGroup();
97
98
99InitPick()
100{
101    TypeName[RTfrom]    = "From:";
102    TypeName[RTto]      = "To:";
103    TypeName[RTcc]      = "Cc:";
104    TypeName[RTdate]    = "Date:";
105    TypeName[RTsubject] = "Subject:";
106    TypeName[RTsearch]  = "Search:";
107    TypeName[RTother]   = NULL;
108
109    /* Translations which will prevent the Search and Replace functionality
110     * of the Text widget in text fields of pick and popups.  The toc's
111     * Search and Replace functionality is removed in the app defaults file.
112     */
113    NoTextSearchAndReplace = XtParseTranslationTable
114        ("Ctrl<Key>R: no-op(RingBell)\n\
115          Ctrl<Key>S: no-op(RingBell)\n");
116}
117
118
119static PrepareToUpdate(form)
120  FormBox form;
121{
122    XawFormDoLayout(form->inner, FALSE);
123}
124
125static ExecuteUpdate(form)
126  FormBox form;
127{
128    XawFormDoLayout(form->inner, TRUE);
129    XtManageChild(form->inner);
130    XtManageChild(form->outer);
131}
132
133static void AddLabel(row, text, usestd)
134  RowList row;
135  char *text;
136  int usestd;
137{
138    static Arg arglist[] = {
139        {XtNlabel, (XtArgVal)NULL},
140        {XtNborderWidth, (XtArgVal) 0},
141        {XtNjustify, (XtArgVal) XtJustifyRight},
142        {XtNwidth, (XtArgVal) NULL}
143    };
144
145    arglist[0].value = (XtArgVal) text;
146    arglist[XtNumber(arglist) - 1].value = (XtArgVal) stdwidth;
147    (void) CreateWidget(row, WTlabel, arglist,
148                        usestd ? XtNumber(arglist) : XtNumber(arglist) - 1);
149}
150
151
152static void AddButton(row, text, func)
153  RowList row;
154  char *text;
155  void (*func)();
156{
157    FormEntry entry;
158    static Arg args[] = {
159        {XtNlabel, (XtArgVal)NULL},
160    };
161
162    args[0].value = (XtArgVal)text;
163    entry = CreateWidget( row, WTbutton, args, XtNumber(args) );
164    XtAddCallback( entry->widget, XtNcallback, func, (XtPointer)entry );
165}
166
167
168static void AddToggle(row, text, initial_state, radio_group, radio_data)
169    RowList     row;
170    char        *text;
171    int         initial_state;
172    Widget      radio_group;
173    XtPointer   radio_data;
174{
175    FormEntry   entry;
176    Arg         args[4];
177    int         n = 0;
178    XtTranslations      translations;
179
180    XtSetArg(args[n], XtNlabel, text);                  n++;
181    XtSetArg(args[n], XtNstate, initial_state);         n++;
182    XtSetArg(args[n], XtNradioGroup, radio_group);      n++;
183    XtSetArg(args[n], XtNradioData, radio_data);        n++;
184    entry = CreateWidget(row, toggleWidgetClass, args, (Cardinal)n);
185    translations = XtParseTranslationTable("<Btn1Down>,<Btn1Up>:set()\n");
186    XtOverrideTranslations(entry->widget, translations);
187}
188
189
190static void AddTextEntry(row, str)
191  RowList row;
192  char *str;
193{
194    FormEntry   entry;
195    static Arg arglist[] = {
196        {XtNstring, (XtArgVal) NULL},
197        {XtNwidth, (XtArgVal) NULL},
198        {XtNlength, (XtArgVal) 300},
199        {XtNresize, (XtArgVal) XawtextResizeBoth},
200        {XtNeditType, (XtArgVal)XawtextEdit},
201    };
202    arglist[0].value = (XtArgVal) str;
203    arglist[1].value = (XtArgVal) stdwidth;
204    entry = CreateWidget( row, WTtextentry, arglist, XtNumber(arglist) );
205    XtOverrideTranslations(entry->widget, NoTextSearchAndReplace);
206}
207
208
209static void ChangeTextEntry(entry, str)
210FormEntry entry;
211char *str;
212{
213    Arg arglist[1];
214    char *ptr;
215
216    XtSetArg(arglist[0], XtNstring, &ptr);
217    XtGetValues(entry->widget, arglist, (Cardinal) 1);
218    if (strcmp(str, ptr) == 0)
219        return;
220
221    XtSetArg(arglist[0], XtNstring, str);
222    XtSetValues(entry->widget, arglist, (Cardinal) 1);
223}
224
225/* ARGSUSED */
226static void ExecRowOr(w, closure, call_data)
227    Widget w;                   /* unused */
228    XtPointer closure;          /* FormEntry */
229    XtPointer call_data;        /* unused */
230{
231    FormEntry entry = (FormEntry)closure;
232    RowList row = entry->row;
233    FormBox form = row->group->form;
234    PrepareToUpdate(form);
235    DeleteWidget(entry);
236    AddLabel(row, "or", FALSE);
237    AddTextEntry(row, "");
238    AddButton(row, "Or", ExecRowOr);
239    ExecuteUpdate(form);
240}
241   
242
243/* ARGSUSED */
244static void ExecGroupOr(w, closure, call_data)
245    Widget w;                   /* unused */
246    XtPointer closure;          /* FormEntry */
247    XtPointer call_data;        /* unused */
248{
249    FormBox form = ((FormEntry)closure)->row->group->form;
250/* %%%    XUnmapWindow(theDisplay, XtWindow(form->inner)); */
251    PrepareToUpdate(form);
252    AddDetailGroup(form);
253    ExecuteUpdate(form);
254/* %%%    XtMapWidget(form->inner); */
255}
256
257static char **argv;
258static int argvsize;
259
260
261static AppendArgv(ptr)
262  char *ptr;
263{
264    argvsize++;
265    argv = ResizeArgv(argv, argvsize);
266    argv[argvsize - 1] = XtNewString(ptr);
267}
268
269static EraseLast()
270{
271    argvsize--;
272    XtFree((char *) argv[argvsize]);
273    argv[argvsize] = 0;
274}
275
276
277
278static ParseRow(row)
279  RowList row;
280{
281    int         result = FALSE;
282    int         i;
283    FormEntry   entry;
284    char        str[1000];
285    Arg         args[4];
286    char        *ptr;
287    char        *other;
288
289    if (row->type > LASTUSEFULROWTYPE)
290        return FALSE;
291
292    for (i = 3; i < row->numwidgets; i += 2) {
293        entry = row->wlist[i];
294        XtSetArg(args[0], XtNstring, &ptr);
295        XtGetValues(entry->widget, args, (Cardinal) 1);
296        if (ptr && *ptr) {
297            if (!result) {
298                result = TRUE;
299                if (! (*((short *)
300                         (XawToggleGetCurrent(row->wlist[0]->widget)))))
301                    AppendArgv("-not");
302                AppendArgv("-lbrace");
303            }
304            switch (row->type) {
305                case RTfrom:
306                    AppendArgv("-from");
307                    break;
308                case RTto:
309                    AppendArgv("-to");
310                    break;
311                case RTcc:
312                    AppendArgv("-cc");
313                    break;
314                case RTdate:
315                    AppendArgv("-date");
316                    break;
317                case RTsubject:
318                    AppendArgv("-subject");
319                    break;
320                case RTsearch:
321                    AppendArgv("-search");
322                    break;
323                case RTother:
324                    XtSetArg(args[0], XtNstring, &other);
325                    XtGetValues(row->wlist[2]->widget, args, (Cardinal) 1);
326                    (void) sprintf(str, "--%s", other);
327                    AppendArgv(str);
328                    break;
329            }
330            AppendArgv(ptr);
331            AppendArgv("-or");
332        }
333    }
334    if (result) {
335        EraseLast();
336        AppendArgv("-rbrace");
337        AppendArgv("-and");
338    }
339    return result;
340}
341           
342
343static ParseGroup(group)
344  Group group;
345{
346    int found = FALSE;
347    int i;
348    for (i=0 ; i<group->numrows ; i++)
349        found |= ParseRow(group->rlist[i]);
350    if (found) {
351        EraseLast();
352        AppendArgv("-rbrace");
353        AppendArgv("-or");
354        AppendArgv("-lbrace");
355    }
356    return found;
357}
358
359/* ARGSUSED */
360static void ExecOK(w, closure, call_data)
361    Widget w;                   /* unused */
362    XtPointer closure;          /* FormEntry */
363    XtPointer call_data;        /* unused */
364{
365    Pick pick = ((FormEntry)closure)->row->group->form->pick;
366    Toc toc = pick->toc;
367    FormBox details = pick->details;
368    FormBox general = pick->general;
369    Group group = general->glist[0];
370    RowList row0 = group->rlist[0];
371    RowList row1 = group->rlist[1];
372    RowList row2 = group->rlist[2];
373    char *fromseq;
374    char *toseq;
375    char *datefield;
376    char *fromdate;
377    char *todate;
378    short removeoldmsgs =
379        *((short*)XawToggleGetCurrent(row2->wlist[1]->widget));
380    int i, found;
381    char *folderpath;
382    int cmd_status;
383    Arg args[5];
384
385    XtSetArg(args[0], XtNstring, &toseq);
386    XtGetValues(row0->wlist[1]->widget, args, (Cardinal) 1);
387    if (strcmp(toseq, "all") == 0) {
388        PopupError(pick->scrn->parent,
389                   "Can't create a sequence called \"all\".");
390        return;
391    }
392    XtSetArg(args[0], XtNstring, &fromseq);
393    XtGetValues(row0->wlist[3]->widget, args, (Cardinal) 1);
394    if (TocGetSeqNamed(toc, fromseq) == NULL) {
395        char str[200];
396        (void) sprintf(str, "Sequence \"%s\" doesn't exist!", fromseq);
397        PopupError(pick->scrn->parent, str);
398        return;
399    }
400
401    argv = MakeArgv(1);
402    argvsize = 0;
403    AppendArgv("pick");
404    AppendArgv(folderpath = TocMakeFolderName(toc));
405    XtFree(folderpath);
406    AppendArgv(fromseq);
407    AppendArgv("-sequence");
408    AppendArgv(toseq);
409    if (removeoldmsgs)
410        AppendArgv("-zero");
411    else
412        AppendArgv("-nozero");
413    XtSetArg(args[0], XtNstring, &datefield);
414    XtGetValues(row1->wlist[5]->widget, args, (Cardinal) 1);
415    if (*datefield) {
416        AppendArgv("-datefield");
417        AppendArgv(datefield);
418    }
419    XtSetArg(args[0], XtNstring, &fromdate);
420    XtGetValues(row1->wlist[1]->widget, args, (Cardinal) 1);
421    if (*fromdate) {
422        AppendArgv("-after");
423        AppendArgv(fromdate);
424        AppendArgv("-and");
425    }
426    XtSetArg(args[0], XtNstring, &todate);
427    XtGetValues(row1->wlist[3]->widget, args, (Cardinal) 1);
428    if (*todate) {
429        AppendArgv("-before");
430        AppendArgv(todate);
431        AppendArgv("-and");
432    }
433    found = FALSE;
434    AppendArgv("-lbrace");
435    AppendArgv("-lbrace");
436    for (i=0 ; i<details->numgroups ; i++)
437        found |= ParseGroup(details->glist[i]);
438    EraseLast();
439    EraseLast();
440    if (found) AppendArgv("-rbrace");
441    else if (*fromdate || *todate) EraseLast();
442    if (app_resources.debug) {
443        for (i=0 ; i<argvsize ; i++)
444            (void) fprintf(stderr, "%s ", argv[i]);
445        (void) fprintf(stderr, "\n");
446    }
447    if (app_resources.block_events_on_busy) ShowBusyCursor();
448
449    cmd_status = DoCommand(argv, (char*)NULL, (char*)NULL);
450    TocReloadSeqLists(toc);
451    TocChangeViewedSeq(toc, TocGetSeqNamed(toc, toseq));
452
453    if (app_resources.block_events_on_busy) UnshowBusyCursor();
454    if (cmd_status == 0 /*succeeded*/) DestroyScrn(pick->scrn);
455    for (i=0 ; i<argvsize ; i++) XtFree((char *) argv[i]);
456    XtFree((char *) argv);
457}
458
459
460/* ARGSUSED */
461static void ExecCancel(w, closure, call_data)
462    Widget w;                   /* unused */
463    XtPointer closure;          /* FormEntry */
464    XtPointer call_data;        /* unused */
465{
466    Pick pick = ((FormEntry)closure)->row->group->form->pick;
467    Scrn scrn = pick->scrn;
468    (void) DestroyScrn(scrn);
469}
470
471
472static FormEntry CreateWidget(row, class, args, num_args)
473  RowList row;
474  WidgetClass class;
475  ArgList args;
476  Cardinal num_args;
477{
478    static Arg arglist[] = {
479        {XtNfromHoriz, (XtArgVal)NULL},
480        {XtNresizable, (XtArgVal)TRUE},
481        {XtNtop, (XtArgVal) XtChainTop},
482        {XtNleft, (XtArgVal) XtChainLeft},
483        {XtNbottom, (XtArgVal) XtChainTop},
484        {XtNright, (XtArgVal) XtChainLeft},
485    };
486    ArgList merged_args;
487    FormEntry entry;
488
489    row->numwidgets++;
490    row->wlist = (FormEntry *)
491        XtRealloc((char *) row->wlist,
492                  (unsigned) row->numwidgets * sizeof(FormEntry));
493    entry = XtNew(FormEntryRec);
494    entry->row = row;
495    entry->type = class;
496    row->wlist[row->numwidgets - 1] = entry;
497    if (row->numwidgets > 1)
498        arglist[0].value = (XtArgVal) row->wlist[row->numwidgets - 2]->widget;
499    else
500        arglist[0].value = (XtArgVal) NULL;
501
502    merged_args = XtMergeArgLists(args, num_args, arglist, XtNumber(arglist) );
503
504    entry->widget = XtCreateManagedWidget( (String) NULL, class, row->widget,
505                                           merged_args,
506                                           num_args + XtNumber(arglist) );
507                       
508    XtFree((char *) merged_args);
509    return entry;
510}
511   
512
513static void
514DeleteWidget(entry)
515  FormEntry entry;
516{
517    RowList row = entry->row;
518    int i;
519    XtDestroyWidget(entry->widget);
520    for (i = 0; i < row->numwidgets; i++)
521        if (row->wlist[i] == entry)
522            break;
523    row->numwidgets--;
524    for (; i < row->numwidgets; i++)
525        row->wlist[i] = row->wlist[i + 1];
526}
527
528
529/* Figure out how wide text fields and labels should be so that they'll all
530   line up correctly, and be big enough to hold everything, but not too big. */
531
532static void FindStdWidth()
533{
534    stdwidth = 100;             /* %%% HACK! */
535}
536
537
538static RowList AddRow(group, type)
539  Group group;
540  int type;
541{
542    static Arg arglist[] = {
543        {XtNborderWidth, (XtArgVal) 0},
544        {XtNfromVert, (XtArgVal) NULL},
545        {XtNresizable, (XtArgVal) TRUE},
546        {XtNtop, (XtArgVal) XtChainTop},
547        {XtNleft, (XtArgVal) XtChainLeft},
548        {XtNbottom, (XtArgVal) XtChainTop},
549        {XtNright, (XtArgVal) XtChainLeft}
550    };
551    RowList row;
552    group->numrows++;
553    group->rlist = (RowList *)
554        XtRealloc((char *) group->rlist,
555                  (unsigned) group->numrows * sizeof(RowList));
556    group->rlist[group->numrows - 1] = row = XtNew(RowListRec);
557    row->type = type;
558    row->numwidgets = 0;
559    row->wlist = (FormEntry *) NULL;
560    row->group = group;
561    if (group->numrows > 1)
562        arglist[1].value = (XtArgVal)group->rlist[group->numrows - 2]->widget;
563    else
564        arglist[1].value = (XtArgVal) NULL;
565    row->widget = XtCreateWidget("rowform", formWidgetClass, group->widget,
566                                  arglist, XtNumber(arglist) );
567    if (type == RTignore) return row;
568    AddToggle(row, "Pick", TRUE, (Widget)NULL, (XtPointer)(&true_data));
569    AddToggle(row, "Skip", FALSE, row->wlist[row->numwidgets - 1]->widget,
570              (XtPointer)(&false_data));
571    if (TypeName[type])
572        AddLabel(row, TypeName[type], TRUE);
573    else
574        AddTextEntry(row, "");
575    AddTextEntry(row, "");
576    AddButton(row, "Or", ExecRowOr);
577    XtManageChild(row->widget);
578    return row;
579}
580
581
582static Group AddGroup(form)
583  FormBox form;
584{
585    static Arg arglist[] = {
586        {XtNborderWidth, (XtArgVal) 0},
587        {XtNfromVert, (XtArgVal) NULL},
588        {XtNresizable, (XtArgVal) TRUE},
589        {XtNtop, (XtArgVal) XtChainTop},
590        {XtNleft, (XtArgVal) XtChainLeft},
591        {XtNbottom, (XtArgVal) XtChainTop},
592        {XtNright, (XtArgVal) XtChainLeft}
593    };
594    Group group;
595    form->numgroups++;
596    form->glist = (Group *)
597        XtRealloc((char *) form->glist,
598                  (unsigned) form->numgroups * sizeof(Group));
599    form->glist[form->numgroups - 1] = group =
600        (Group) XtMalloc((Cardinal) sizeof(GroupRec));
601    group->numrows = 0;
602    group->form = form;
603    group->rlist = (RowList *) NULL;
604    if (form->numgroups > 1)
605        arglist[1].value = (XtArgVal)form->glist[form->numgroups - 2]->widget;
606    else
607        arglist[1].value = (XtArgVal)NULL;
608    group->widget = XtCreateWidget("groupform", formWidgetClass, form->inner,
609                                    arglist, XtNumber(arglist) );
610    return group;
611}
612
613
614
615static void
616AddDetailGroup(form)
617  FormBox form;
618{
619    Group group;
620    RowList row;
621    int     type;
622
623    if (form->numgroups > 0) {
624        group = form->glist[form->numgroups - 1];
625        row = group->rlist[group->numrows - 1];
626        DeleteWidget(row->wlist[0]);
627        AddLabel(row, "- or -", FALSE);
628    }
629    group = AddGroup(form);
630    for (type = FIRSTROWTYPE; type <= LASTUSEFULROWTYPE; type++)
631        (void) AddRow(group, type);
632    row =  AddRow(group, RTignore);
633    AddButton(row, "- Or -", ExecGroupOr);
634    XtManageChild(row->widget);
635    if (XtIsRealized(XtParent(group->widget)))
636        XtRealizeWidget(group->widget);
637    XtManageChild(group->widget);
638}
639
640
641static AddGeneralGroup(form)
642  FormBox form;
643{
644    Group group;
645    RowList row;
646    Widget widgetList[4];
647    group = AddGroup(form);
648    row =  AddRow(group, RTignore);
649    widgetList[0] = row->widget;
650    AddLabel(row, "Creating sequence:", FALSE);
651    AddTextEntry(row, "");
652    AddLabel(row, "with msgs from sequence:", FALSE);
653    AddTextEntry(row, "");
654    row =  AddRow(group, RTignore);
655    widgetList[1] = row->widget;
656    AddLabel(row, "Date range:", FALSE);
657    AddTextEntry(row, "");
658    AddLabel(row, " - ", FALSE);
659    AddTextEntry(row, "");
660    AddLabel(row, "Date field:", FALSE);
661    AddTextEntry(row, "");
662    row =  AddRow(group, RTignore);
663    widgetList[2] = row->widget;
664    AddLabel(row, "Clear old entries from sequence?", FALSE);
665    AddToggle(row, "Yes", TRUE, (Widget) NULL, (XtPointer)(&true_data));
666    AddToggle(row, "No", FALSE, row->wlist[row->numwidgets - 1]->widget,
667              (XtPointer)(&false_data));
668    row =  AddRow(group, RTignore);
669    widgetList[3] = row->widget;
670    AddButton(row, "OK", ExecOK);
671    AddButton(row, "Cancel", ExecCancel);
672    XtManageChildren(widgetList, XtNumber(widgetList));
673    XtManageChild(group->widget);
674}
675
676
677static void InitGeneral(pick, fromseq, toseq)
678Pick pick;
679char *fromseq, *toseq;
680{
681    RowList row;
682    row = pick->general->glist[0]->rlist[0];
683    ChangeTextEntry(row->wlist[1], toseq);
684    ChangeTextEntry(row->wlist[3], fromseq);
685}
686
687
688static void CleanForm(form)
689FormBox form;
690{
691    int i, j, k;
692    Group group;
693    RowList row;
694    FormEntry entry;
695    for (i=0 ; i<form->numgroups ; i++) {
696        group = form->glist[i];
697        for (j=0 ; j<group->numrows ; j++) {
698            row = group->rlist[j];
699            for (k=0 ; k<row->numwidgets ; k++) {
700                entry = row->wlist[k];
701                if (entry->type == WTtextentry)
702                    ChangeTextEntry(entry, "");
703            }
704        }
705    }
706}
707
708
709static FormBox MakeAForm(pick)
710Pick pick;
711{
712    static Arg arglist1[] = {
713        {XtNallowHoriz, (XtArgVal)TRUE},
714        {XtNallowVert, (XtArgVal)TRUE},
715/* %%%  {XtNallowResize, (XtArgVal)TRUE}, */
716        {XtNmin, (XtArgVal)50},
717        {XtNmax, (XtArgVal)1500}
718    };
719    static Arg arglist2[] = {
720        {XtNborderWidth, (XtArgVal) 0}
721    };
722    FormBox result;
723    result = (FormBox) XtMalloc((Cardinal) sizeof(FormBoxRec));
724    result->outer = XtCreateWidget( "pick", viewportWidgetClass,
725                                    pick->scrn->widget,
726                                    arglist1, XtNumber(arglist1) );
727    result->inner = XtCreateWidget( "form", formWidgetClass, result->outer,
728                                    arglist2, XtNumber(arglist2) );
729    result->pick = pick;
730    result->numgroups = 0;
731    result->glist = (Group *) NULL;
732    return result;
733}
734
735
736AddPick(scrn, toc, fromseq, toseq)
737  Scrn scrn;
738  Toc toc;
739  char *fromseq, *toseq;
740{
741    Pick pick;
742    FormBox general, details;
743    char str[100];
744#ifdef notdef
745    int height;
746#endif /* notdef */
747
748    if (scrn->pick) {
749        pick = scrn->pick;
750        CleanForm(pick->details);
751        CleanForm(pick->general);
752    } else {
753        pick = scrn->pick = (Pick) XtMalloc((Cardinal) sizeof(PickRec));
754        pick->scrn = scrn;
755        pick->label = CreateTitleBar(scrn, "pickTitlebar");
756        pick->details = details = MakeAForm(pick);
757        pick->general = general = MakeAForm(pick);
758        FindStdWidth();
759        XawPanedSetRefigureMode(scrn->widget, False);
760        PrepareToUpdate(details);
761        AddDetailGroup(details);
762        ExecuteUpdate(details);
763        PrepareToUpdate(general);
764        AddGeneralGroup(general);
765        ExecuteUpdate(general);
766#ifdef notdef
767        height = general->inner->core.height;
768        if (general->inner->core.width > scrn->widget->core.width)
769            height += XtScrollMgrGetThickness(general->outer);
770        XawPanedSetMinMax(scrn->widget, general->outer, height, height);
771        XawPanedSetMinMax(scrn->widget, general->outer, 10, 10000);
772#endif /* notdef */
773        XawPanedSetRefigureMode(scrn->widget, True);
774    }
775    pick->toc = toc;
776    InitGeneral(pick, fromseq, toseq);
777    (void) sprintf(str, "Pick: %s", TocName(toc));
778    ChangeLabel(pick->label, str);
779    StoreWindowName(scrn, str);
780}
781
782
783
784
Note: See TracBrowser for help on using the repository browser.