|
|
1.1 ! root 1: #ifndef lint ! 2: static char rcs_id[] = "$Header: pick.c,v 1.11 87/09/11 08:18:17 toddb Exp $"; ! 3: #endif lint ! 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 RIGHTS, ! 16: * APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN ADDITION TO THAT ! 17: * SET FORTH ABOVE. ! 18: * ! 19: * ! 20: * Permission to use, copy, modify, and distribute this software and its ! 21: * documentation for any purpose and without fee is hereby granted, provided ! 22: * that the above copyright notice appear in all copies and that both that ! 23: * copyright notice and this permission notice appear in supporting documentation, ! 24: * and that the name of Digital Equipment Corporation not be used in advertising ! 25: * or publicity pertaining to distribution of the software without specific, ! 26: * written prior permission. ! 27: */ ! 28: ! 29: /* pick.c -- handle a pick subwindow. */ ! 30: ! 31: #include "xmh.h" ! 32: #include "Form.h" ! 33: ! 34: #define WTlabel 0 ! 35: #define WTbutton 1 ! 36: #define WTtextentry 2 ! 37: ! 38: #define RTfrom 0 ! 39: #define RTto 1 ! 40: #define RTcc 2 ! 41: #define RTdate 3 ! 42: #define RTsubject 4 ! 43: #define RTsearch 5 ! 44: #define RTother 6 ! 45: #define RTignore 7 ! 46: ! 47: #define FIRSTROWTYPE RTfrom ! 48: #define LASTUSEFULROWTYPE RTother ! 49: #define NUMROWTYPE (RTignore+1) ! 50: ! 51: static int stdwidth = -1; /* Width to make text fields, and other ! 52: things that want to be the same width as ! 53: text fields. */ ! 54: ! 55: static char *TypeName[NUMROWTYPE]; ! 56: ! 57: typedef struct { ! 58: short type; /* Encode what type of window this is. */ ! 59: Window window; /* The window id itself. */ ! 60: struct _RowListRec *row; /* Which row this window is in. */ ! 61: short hilite; /* Whether to hilight (if button subwindow) */ ! 62: char *ptr; /* Data (if text subwindow) */ ! 63: } FormEntryRec, *FormEntryPtr; ! 64: ! 65: typedef struct _RowListRec { ! 66: short type; /* Encode what type of list this is. */ ! 67: Window window; /* Window containing this row */ ! 68: short numwindows; /* How many windows in this list. */ ! 69: FormEntryPtr *wlist; /* List of windows. */ ! 70: struct _GroupRec *group; /* Which group this is in. */ ! 71: } RowListRec, *RowListPtr; ! 72: ! 73: typedef struct _GroupRec { ! 74: short numrows; /* How many rows of window. */ ! 75: Window window; /* Window containing this group */ ! 76: RowListPtr *rlist; /* List of window rows. */ ! 77: struct _FormBoxRec *form; /* Which form this is in. */ ! 78: } GroupRec, *GroupPtr; ! 79: ! 80: typedef struct _FormBoxRec { ! 81: Window outer; /* Outer window (contains scrollbars if any) */ ! 82: Window inner; /* Inner window (contains master form) */ ! 83: short numgroups; /* How many groups of form entries we have. */ ! 84: GroupPtr *glist; /* List of form groups. */ ! 85: struct _PickRec *pick; /* Which pick this is in. */ ! 86: } FormBoxRec, *FormBoxPtr; ! 87: ! 88: typedef struct _PickRec { ! 89: Scrn scrn; /* Scrn containing this pick. */ ! 90: Window label; /* Window with label for this pick. */ ! 91: Toc toc; /* Toc for folder being scanned. */ ! 92: FormBoxPtr general; /* Form for general info about this pick. */ ! 93: FormBoxPtr details; /* Form for details about this pick. */ ! 94: Window errorwindow; /* Pop-up error window. */ ! 95: } PickRec; ! 96: ! 97: ! 98: InitPick() ! 99: { ! 100: TypeName[RTfrom] = "From:"; ! 101: TypeName[RTto] = "To:"; ! 102: TypeName[RTcc] = "Cc:"; ! 103: TypeName[RTdate] = "Date:"; ! 104: TypeName[RTsubject] = "Subject:"; ! 105: TypeName[RTsearch] = "Search:"; ! 106: TypeName[RTother] = NULL; ! 107: } ! 108: ! 109: static PickFlipColors(window) ! 110: Window window; ! 111: { ! 112: static Arg arglist[] = { ! 113: {XtNforeground, NULL}, ! 114: {XtNbackground, NULL}, ! 115: }; ! 116: XtArgVal temp; ! 117: XtCommandGetValues(DISPLAY window, arglist, XtNumber(arglist)); ! 118: temp = arglist[0].value; ! 119: arglist[0].value = arglist[1].value; ! 120: arglist[1].value = temp; ! 121: XtCommandSetValues(DISPLAY window, arglist, XtNumber(arglist)); ! 122: } ! 123: ! 124: ! 125: static PrepareToUpdate(form) ! 126: FormBoxPtr form; ! 127: { ! 128: XtFormDoLayout(DISPLAY form->inner, FALSE); ! 129: } ! 130: ! 131: static ExecuteUpdate(form) ! 132: FormBoxPtr form; ! 133: { ! 134: XtFormDoLayout(DISPLAY form->inner, TRUE); ! 135: } ! 136: ! 137: static FormEntryPtr CreateEntry(window, type) ! 138: Window window; ! 139: int type; ! 140: { ! 141: FormEntryPtr entry; ! 142: entry = (FormEntryPtr) XtMalloc(sizeof(FormEntryRec)); ! 143: entry->row = NULL; ! 144: entry->window = window; ! 145: entry->type = type; ! 146: return entry; ! 147: } ! 148: ! 149: ! 150: static void AddLabel(row, text, usestd) ! 151: RowListPtr row; ! 152: char *text; ! 153: int usestd; ! 154: { ! 155: Window window; ! 156: static Arg arglist[] = { ! 157: {XtNlabel, NULL}, ! 158: {XtNborderWidth, (XtArgVal) 0}, ! 159: {XtNjustify, (XtArgVal) XtjustifyRight}, ! 160: {XtNwidth, (XtArgVal) NULL} ! 161: }; ! 162: arglist[0].value = (XtArgVal) text; ! 163: arglist[XtNumber(arglist) - 1].value = (XtArgVal) stdwidth; ! 164: window = XtLabelCreate(DISPLAY row->window, arglist, ! 165: usestd ? XtNumber(arglist) : XtNumber(arglist) - 1); ! 166: AddWindow(row, CreateEntry(window, WTlabel)); ! 167: } ! 168: ! 169: ! 170: static void AddButton(row, text, func, hilite) ! 171: RowListPtr row; ! 172: char *text; ! 173: int (*func)(); ! 174: int hilite; ! 175: { ! 176: FormEntryPtr entry; ! 177: static Arg arglist[] = { ! 178: {XtNlabel, NULL}, ! 179: {XtNfunction, NULL}, ! 180: {XtNparameter, NULL} ! 181: }; ! 182: entry = CreateEntry((Window) 0, WTbutton); ! 183: arglist[0].value = (XtArgVal)text; ! 184: arglist[1].value = (XtArgVal)func; ! 185: arglist[2].value = (XtArgVal)entry; ! 186: entry->window = XtCommandCreate(DISPLAY row->window, ! 187: arglist, XtNumber(arglist)); ! 188: entry->hilite = hilite; ! 189: if (hilite) PickFlipColors(entry->window); ! 190: AddWindow(row, entry); ! 191: } ! 192: ! 193: ! 194: static void AddTextEntry(row, str) ! 195: RowListPtr row; ! 196: char *str; ! 197: { ! 198: static Arg arglist[] = { ! 199: {XtNstring, (XtArgVal) NULL}, ! 200: {XtNwidth, (XtArgVal) NULL}, ! 201: {XtNlength, (XtArgVal) 300}, ! 202: {XtNtextOptions, (XtArgVal)(resizeWidth | resizeHeight)}, ! 203: {XtNeditType, (XtArgVal)XttextEdit}, ! 204: }; ! 205: char *ptr; ! 206: FormEntryPtr entry; ! 207: ptr = XtMalloc(310); ! 208: arglist[0].value = (XtArgVal) ptr; ! 209: arglist[1].value = (XtArgVal) stdwidth; ! 210: (void) strcpy(ptr, str); ! 211: entry = CreateEntry(XtTextStringCreate(DISPLAY row->window, arglist, ! 212: XtNumber(arglist)), ! 213: WTtextentry); ! 214: entry->ptr = ptr; ! 215: AddWindow(row, entry); ! 216: } ! 217: ! 218: ! 219: static void ChangeTextEntry(entry, str) ! 220: FormEntryPtr entry; ! 221: char *str; ! 222: { ! 223: static Arg arglist[] = { ! 224: {XtNtextSource, (XtArgVal) NULL} ! 225: }; ! 226: XtTextSource *source; ! 227: if (strcmp(str, entry->ptr) == 0) return; ! 228: XtTextGetValues(DISPLAY entry->window, arglist, XtNumber(arglist)); ! 229: source = (XtTextSource *) arglist[0].value; ! 230: XtStringSourceDestroy(source); ! 231: (void) strcpy(entry->ptr, str); ! 232: source = (XtTextSource *) ! 233: XtStringSourceCreate(entry->ptr, 300, XttextEdit); ! 234: XtTextNewSource(DISPLAY entry->window, source, (XtTextPosition) 0); ! 235: } ! 236: ! 237: ! 238: static ExecYesNo(entry) ! 239: FormEntryPtr entry; ! 240: { ! 241: RowListPtr row = entry->row; ! 242: int i; ! 243: if (!entry->hilite) { ! 244: entry->hilite = TRUE; ! 245: PickFlipColors(entry->window); ! 246: for (i = 0; i < row->numwindows; i++) ! 247: if (entry == row->wlist[i]) ! 248: break; ! 249: if (i > 0 && row->wlist[i-1]->type == WTbutton) ! 250: i--; ! 251: else ! 252: i++; ! 253: entry = row->wlist[i]; ! 254: entry->hilite = FALSE; ! 255: PickFlipColors(entry->window); ! 256: } ! 257: } ! 258: ! 259: ! 260: ! 261: ! 262: static ExecRowOr(entry) ! 263: FormEntryPtr entry; ! 264: { ! 265: RowListPtr row = entry->row; ! 266: FormBoxPtr form = row->group->form; ! 267: PrepareToUpdate(form); ! 268: DeleteWindow(entry); ! 269: AddLabel(row, "or", FALSE); ! 270: AddTextEntry(row, ""); ! 271: AddButton(row, "Or", ExecRowOr, FALSE); ! 272: ExecuteUpdate(form); ! 273: } ! 274: ! 275: ! 276: static ExecGroupOr(entry) ! 277: FormEntryPtr entry; ! 278: { ! 279: FormBoxPtr form = entry->row->group->form; ! 280: QXUnmapWindow(theDisplay, form->inner); ! 281: PrepareToUpdate(form); ! 282: AddDetailGroup(form); ! 283: ExecuteUpdate(form); ! 284: QXMapWindow(theDisplay, form->inner); ! 285: } ! 286: ! 287: static char **argv; ! 288: static int argvsize; ! 289: ! 290: ! 291: static AppendArgv(ptr) ! 292: char *ptr; ! 293: { ! 294: argvsize++; ! 295: argv = ResizeArgv(argv, argvsize); ! 296: argv[argvsize - 1] = MallocACopy(ptr); ! 297: } ! 298: ! 299: static EraseLast() ! 300: { ! 301: argvsize--; ! 302: XtFree((char *) argv[argvsize]); ! 303: argv[argvsize] = 0; ! 304: } ! 305: ! 306: ! 307: ! 308: static ParseRow(row) ! 309: RowListPtr row; ! 310: { ! 311: int result = FALSE; ! 312: int i; ! 313: FormEntryPtr entry; ! 314: char str[1000]; ! 315: if (row->type > LASTUSEFULROWTYPE) ! 316: return FALSE; ! 317: for (i = 3; i < row->numwindows; i += 2) { ! 318: entry = row->wlist[i]; ! 319: if (*(entry->ptr)) { ! 320: if (!result) { ! 321: result = TRUE; ! 322: if (row->wlist[1]->hilite) ! 323: AppendArgv("-not"); ! 324: AppendArgv("-lbrace"); ! 325: } ! 326: switch (row->type) { ! 327: case RTfrom: ! 328: AppendArgv("-from"); ! 329: break; ! 330: case RTto: ! 331: AppendArgv("-to"); ! 332: break; ! 333: case RTcc: ! 334: AppendArgv("-cc"); ! 335: break; ! 336: case RTdate: ! 337: AppendArgv("-date"); ! 338: break; ! 339: case RTsubject: ! 340: AppendArgv("-subject"); ! 341: break; ! 342: case RTsearch: ! 343: AppendArgv("-search"); ! 344: break; ! 345: case RTother: ! 346: AppendArgv(sprintf(str, "--%s", row->wlist[2]->ptr)); ! 347: break; ! 348: } ! 349: AppendArgv(entry->ptr); ! 350: AppendArgv("-or"); ! 351: } ! 352: } ! 353: if (result) { ! 354: EraseLast(); ! 355: AppendArgv("-rbrace"); ! 356: AppendArgv("-and"); ! 357: } ! 358: return result; ! 359: } ! 360: ! 361: ! 362: static ParseGroup(group) ! 363: GroupPtr group; ! 364: { ! 365: int found = FALSE; ! 366: int i; ! 367: for (i=0 ; i<group->numrows ; i++) ! 368: found |= ParseRow(group->rlist[i]); ! 369: if (found) { ! 370: EraseLast(); ! 371: AppendArgv("-rbrace"); ! 372: AppendArgv("-or"); ! 373: AppendArgv("-lbrace"); ! 374: } ! 375: return found; ! 376: } ! 377: ! 378: ! 379: ! 380: static void DestroyErrorWindow(pick) ! 381: Pick pick; ! 382: { ! 383: if (pick->errorwindow) { ! 384: (void) XtSendDestroyNotify(DISPLAY pick->errorwindow); ! 385: QXDestroyWindow(theDisplay, pick->errorwindow); ! 386: pick->errorwindow = NULL; ! 387: } ! 388: } ! 389: ! 390: static void MakeErrorWindow(pick, str) ! 391: Pick pick; ! 392: char *str; ! 393: { ! 394: DestroyErrorWindow(pick); ! 395: pick->errorwindow = XtDialogCreate(DISPLAY pick->scrn->window, str, ! 396: (char *)NULL, (ArgList)NULL, 0); ! 397: XtDialogAddButton(DISPLAY pick->errorwindow, "OK", DestroyErrorWindow, ! 398: (caddr_t)pick); ! 399: CenterWindow(pick->scrn->window, pick->errorwindow); ! 400: QXMapWindow(theDisplay, pick->errorwindow); ! 401: } ! 402: ! 403: ! 404: ! 405: static ExecOK(entry) ! 406: FormEntryPtr entry; ! 407: { ! 408: Pick pick = entry->row->group->form->pick; ! 409: Toc toc = pick->toc; ! 410: FormBoxPtr details = pick->details; ! 411: FormBoxPtr general = pick->general; ! 412: GroupPtr group = general->glist[0]; ! 413: RowListPtr row0 = group->rlist[0]; ! 414: RowListPtr row1 = group->rlist[1]; ! 415: RowListPtr row2 = group->rlist[2]; ! 416: char *fromseq = row0->wlist[3]->ptr; ! 417: char *toseq = row0->wlist[1]->ptr; ! 418: char *fromdate = row1->wlist[1]->ptr; ! 419: char *todate = row1->wlist[3]->ptr; ! 420: char *datefield = row1->wlist[5]->ptr; ! 421: short removeoldmsgs = row2->wlist[1]->hilite; ! 422: char str[1000]; ! 423: int i, found; ! 424: ! 425: DestroyErrorWindow(pick); ! 426: if (strcmp(toseq, "all") == 0) { ! 427: MakeErrorWindow(pick, "Can't create a sequence called \"all\"."); ! 428: return; ! 429: } ! 430: if (TocGetSeqNamed(toc, fromseq) == NULL) { ! 431: (void) sprintf(str, "Sequence \"%s\" doesn't exist!", fromseq); ! 432: MakeErrorWindow(pick, str); ! 433: return; ! 434: } ! 435: argv = MakeArgv(1); ! 436: argvsize = 0; ! 437: AppendArgv("pick"); ! 438: AppendArgv(sprintf(str, "+%s", TocGetFolderName(toc))); ! 439: AppendArgv(fromseq); ! 440: AppendArgv("-sequence"); ! 441: AppendArgv(toseq); ! 442: if (removeoldmsgs) ! 443: AppendArgv("-zero"); ! 444: else ! 445: AppendArgv("-nozero"); ! 446: if (*datefield) { ! 447: AppendArgv("-datefield"); ! 448: AppendArgv(datefield); ! 449: } ! 450: if (*fromdate) { ! 451: AppendArgv("-after"); ! 452: AppendArgv(fromdate); ! 453: AppendArgv("-and"); ! 454: } ! 455: if (*todate) { ! 456: AppendArgv("-before"); ! 457: AppendArgv(todate); ! 458: AppendArgv("-and"); ! 459: } ! 460: found = FALSE; ! 461: AppendArgv("-lbrace"); ! 462: AppendArgv("-lbrace"); ! 463: for (i=0 ; i<details->numgroups ; i++) ! 464: found |= ParseGroup(details->glist[i]); ! 465: EraseLast(); ! 466: EraseLast(); ! 467: if (found) AppendArgv("-rbrace"); ! 468: else if (*fromdate || *todate) EraseLast(); ! 469: if (debug) { ! 470: for (i=0 ; i<argvsize ; i++) ! 471: (void) fprintf(stderr, "%s ", argv[i]); ! 472: (void) fprintf(stderr, "\n"); ! 473: } ! 474: (void) DoCommand(argv, (char *) NULL, "/dev/null"); ! 475: TocReloadSeqLists(toc); ! 476: TocChangeViewedSeq(toc, TocGetSeqNamed(toc, toseq)); ! 477: DestroyScrn(pick->scrn); ! 478: for (i=0 ; i<argvsize ; i++) XtFree((char *) argv[i]); ! 479: XtFree((char *) argv); ! 480: } ! 481: ! 482: ! 483: ! 484: static ExecCancel(entry) ! 485: FormEntryPtr entry; ! 486: { ! 487: Pick pick = entry->row->group->form->pick; ! 488: Scrn scrn = pick->scrn; ! 489: (void) DestroyScrn(scrn); ! 490: #ifdef X10 ! 491: { ! 492: XEvent event; ! 493: event.type = LeaveWindow; ! 494: event.window = entry->window; ! 495: XtDispatchEvent(DISPLAY &event); ! 496: } ! 497: #endif ! 498: } ! 499: ! 500: ! 501: ! 502: static AddWindow(row, entry) ! 503: RowListPtr row; ! 504: FormEntryPtr entry; ! 505: { ! 506: static Arg arglist[] = { ! 507: {XtNfromHoriz, (XtArgVal)NULL}, ! 508: {XtNresizable, (XtArgVal)TRUE}, ! 509: {XtNtop, (XtArgVal) XtChainTop}, ! 510: {XtNleft, (XtArgVal) XtChainLeft}, ! 511: {XtNbottom, (XtArgVal) XtChainTop}, ! 512: {XtNright, (XtArgVal) XtChainLeft}, ! 513: }; ! 514: ! 515: row->numwindows++; ! 516: row->wlist = (FormEntryPtr *) ! 517: XtRealloc((char *) row->wlist, ! 518: (unsigned) row->numwindows * sizeof(FormEntryPtr)); ! 519: row->wlist[row->numwindows - 1] = entry; ! 520: entry->row = row; ! 521: if (row->numwindows > 1) ! 522: arglist[0].value = (XtArgVal) row->wlist[row->numwindows - 2]->window; ! 523: else ! 524: arglist[0].value = (XtArgVal) NULL; ! 525: XtFormAddWidget(DISPLAY row->window, ! 526: entry->window, arglist, XtNumber(arglist)); ! 527: } ! 528: ! 529: ! 530: static DeleteWindow(entry) ! 531: FormEntryPtr entry; ! 532: { ! 533: RowListPtr row = entry->row; ! 534: int i; ! 535: QXDestroyWindow(theDisplay, entry->window); ! 536: (void) XtSendDestroyNotify(DISPLAY entry->window); ! 537: if (entry->type == WTtextentry) ! 538: XtFree((char *) entry->ptr); ! 539: for (i = 0; i < row->numwindows; i++) ! 540: if (row->wlist[i] == entry) ! 541: break; ! 542: row->numwindows--; ! 543: for (; i < row->numwindows; i++) ! 544: row->wlist[i] = row->wlist[i + 1]; ! 545: } ! 546: ! 547: ! 548: /* Figure out how wide text fields and labels should be so that they'll all ! 549: line up correctly, and be big enough to hold everything, but not too big. */ ! 550: ! 551: static void FindStdWidth() ! 552: { ! 553: stdwidth = 100; /* %%% HACK! */ ! 554: } ! 555: ! 556: ! 557: static RowListPtr AddRow(group, type) ! 558: GroupPtr group; ! 559: int type; ! 560: { ! 561: static Arg arglist1[] = { ! 562: {XtNborderWidth, (XtArgVal) 0}, ! 563: }; ! 564: static Arg arglist2[] = { ! 565: {XtNfromVert, (XtArgVal) NULL}, ! 566: {XtNresizable, (XtArgVal) TRUE}, ! 567: {XtNtop, (XtArgVal) XtChainTop}, ! 568: {XtNleft, (XtArgVal) XtChainLeft}, ! 569: {XtNbottom, (XtArgVal) XtChainTop}, ! 570: {XtNright, (XtArgVal) XtChainLeft} ! 571: }; ! 572: RowListPtr row; ! 573: group->numrows++; ! 574: group->rlist = (RowListPtr *) ! 575: XtRealloc((char *) group->rlist, ! 576: (unsigned) group->numrows * sizeof(RowListPtr)); ! 577: group->rlist[group->numrows - 1] = row = ! 578: (RowListPtr) XtMalloc(sizeof(RowListRec)); ! 579: row->type = type; ! 580: row->numwindows = 0; ! 581: row->wlist = (FormEntryPtr *) XtMalloc(1); ! 582: row->group = group; ! 583: row->window = XtFormCreate(DISPLAY group->window, ! 584: arglist1, XtNumber(arglist1)); ! 585: if (group->numrows > 1) ! 586: arglist2[0].value = (XtArgVal)group->rlist[group->numrows - 2]->window; ! 587: else ! 588: arglist2[0].value = (XtArgVal) NULL; ! 589: XtFormAddWidget(DISPLAY group->window, ! 590: row->window, arglist2, XtNumber(arglist2)); ! 591: if (type == RTignore) return row; ! 592: AddButton(row, "Pick", ExecYesNo, TRUE); ! 593: AddButton(row, "Skip", ExecYesNo, FALSE); ! 594: if (TypeName[type]) ! 595: AddLabel(row, TypeName[type], TRUE); ! 596: else ! 597: AddTextEntry(row, ""); ! 598: AddTextEntry(row, ""); ! 599: AddButton(row, "Or", ExecRowOr, FALSE); ! 600: return row; ! 601: } ! 602: ! 603: ! 604: static GroupPtr AddGroup(form) ! 605: FormBoxPtr form; ! 606: { ! 607: static Arg arglist1[] = { ! 608: {XtNborderWidth, (XtArgVal) 0}, ! 609: }; ! 610: static Arg arglist2[] = { ! 611: {XtNfromVert, (XtArgVal) NULL}, ! 612: {XtNresizable, (XtArgVal) TRUE}, ! 613: {XtNtop, (XtArgVal) XtChainTop}, ! 614: {XtNleft, (XtArgVal) XtChainLeft}, ! 615: {XtNbottom, (XtArgVal) XtChainTop}, ! 616: {XtNright, (XtArgVal) XtChainLeft} ! 617: }; ! 618: GroupPtr group; ! 619: form->numgroups++; ! 620: form->glist = (GroupPtr *) ! 621: XtRealloc((char *) form->glist, ! 622: (unsigned) form->numgroups * sizeof(GroupPtr)); ! 623: form->glist[form->numgroups - 1] = group = ! 624: (GroupPtr) XtMalloc(sizeof(GroupRec)); ! 625: group->numrows = 0; ! 626: group->form = form; ! 627: group->rlist = (RowListPtr *) XtMalloc(1); ! 628: group->window = XtFormCreate(DISPLAY form->inner, ! 629: arglist1, XtNumber(arglist1)); ! 630: if (form->numgroups > 1) ! 631: arglist2[0].value = (XtArgVal)form->glist[form->numgroups - 2]->window; ! 632: else ! 633: arglist2[0].value = (XtArgVal)NULL; ! 634: XtFormAddWidget(DISPLAY form->inner, ! 635: group->window, arglist2, XtNumber(arglist2)); ! 636: return group; ! 637: } ! 638: ! 639: ! 640: ! 641: static AddDetailGroup(form) ! 642: FormBoxPtr form; ! 643: { ! 644: GroupPtr group; ! 645: RowListPtr row; ! 646: int type; ! 647: if (form->numgroups > 0) { ! 648: group = form->glist[form->numgroups - 1]; ! 649: row = group->rlist[group->numrows - 1]; ! 650: DeleteWindow(row->wlist[0]); ! 651: AddLabel(row, "- or -", FALSE); ! 652: } ! 653: group = AddGroup(form); ! 654: for (type = FIRSTROWTYPE; type <= LASTUSEFULROWTYPE; type++) ! 655: (void) AddRow(group, type); ! 656: row = AddRow(group, RTignore); ! 657: AddButton(row, "- Or -", ExecGroupOr, FALSE); ! 658: } ! 659: ! 660: ! 661: static AddGeneralGroup(form) ! 662: FormBoxPtr form; ! 663: { ! 664: GroupPtr group; ! 665: RowListPtr row; ! 666: group = AddGroup(form); ! 667: row = AddRow(group, RTignore); ! 668: AddLabel(row, "Creating sequence:", FALSE); ! 669: AddTextEntry(row, ""); ! 670: AddLabel(row, "with msgs from sequence:", FALSE); ! 671: AddTextEntry(row, ""); ! 672: row = AddRow(group, RTignore); ! 673: AddLabel(row, "Date range:", FALSE); ! 674: AddTextEntry(row, ""); ! 675: AddLabel(row, " - ", FALSE); ! 676: AddTextEntry(row, ""); ! 677: AddLabel(row, "Date field:", FALSE); ! 678: AddTextEntry(row, ""); ! 679: row = AddRow(group, RTignore); ! 680: AddLabel(row, "Clear old entries from sequence?", FALSE); ! 681: AddButton(row, "Yes", ExecYesNo, TRUE); ! 682: AddButton(row, "No", ExecYesNo, FALSE); ! 683: row = AddRow(group, RTignore); ! 684: AddButton(row, "OK", ExecOK, FALSE); ! 685: AddButton(row, "Cancel", ExecCancel, FALSE); ! 686: } ! 687: ! 688: ! 689: static void InitGeneral(pick, fromseq, toseq) ! 690: Pick pick; ! 691: char *fromseq, *toseq; ! 692: { ! 693: RowListPtr row; ! 694: row = pick->general->glist[0]->rlist[0]; ! 695: ChangeTextEntry(row->wlist[1], toseq); ! 696: ChangeTextEntry(row->wlist[3], fromseq); ! 697: } ! 698: ! 699: ! 700: static void CleanForm(form) ! 701: FormBoxPtr form; ! 702: { ! 703: int i, j, k; ! 704: GroupPtr group; ! 705: RowListPtr row; ! 706: FormEntryPtr entry; ! 707: for (i=0 ; i<form->numgroups ; i++) { ! 708: group = form->glist[i]; ! 709: for (j=0 ; j<group->numrows ; j++) { ! 710: row = group->rlist[j]; ! 711: for (k=0 ; k<row->numwindows ; k++) { ! 712: entry = row->wlist[k]; ! 713: if (entry->type == WTtextentry) ! 714: ChangeTextEntry(entry, ""); ! 715: } ! 716: } ! 717: } ! 718: } ! 719: ! 720: ! 721: static FormBoxPtr MakeAForm(pick, position) ! 722: Pick pick; ! 723: int position; ! 724: { ! 725: static Arg arglist1[] = { ! 726: {XtNname, (XtArgVal) "pick"}, ! 727: {XtNallowHoriz, (XtArgVal)TRUE}, ! 728: {XtNallowVert, (XtArgVal)TRUE}, ! 729: }; ! 730: static Arg arglist2[] = { ! 731: {XtNborderWidth, (XtArgVal) 0} ! 732: }; ! 733: FormBoxPtr result; ! 734: result = (FormBoxPtr) XtMalloc(sizeof(FormBoxRec)); ! 735: result->outer = XtScrolledWindowCreate(DISPLAY pick->scrn->window, ! 736: arglist1, XtNumber(arglist1)); ! 737: result->inner = XtFormCreate(DISPLAY ! 738: XtScrolledWindowGetFrame(DISPLAY ! 739: result->outer), ! 740: arglist2, XtNumber(arglist2)); ! 741: XtScrolledWindowSetChild(DISPLAY result->outer, result->inner); ! 742: XtVPanedWindowAddPane(DISPLAY pick->scrn->window, result->outer, position, ! 743: 50, 1500, TRUE); ! 744: result->pick = pick; ! 745: result->numgroups = 0; ! 746: result->glist = (GroupPtr *) XtMalloc(1); ! 747: return result; ! 748: } ! 749: ! 750: ! 751: ! 752: AddPick(scrn, toc, fromseq, toseq) ! 753: Scrn scrn; ! 754: Toc toc; ! 755: char *fromseq, *toseq; ! 756: { ! 757: Pick pick; ! 758: FormBoxPtr general, details; ! 759: char str[100]; ! 760: int width, height, scrnwidth, scrnheight; ! 761: ! 762: if (scrn->pick) { ! 763: pick = scrn->pick; ! 764: CleanForm(pick->details); ! 765: CleanForm(pick->general); ! 766: } else { ! 767: pick = scrn->pick = (Pick) XtMalloc(sizeof(PickRec)); ! 768: pick->scrn = scrn; ! 769: pick->errorwindow = NULL; ! 770: ! 771: pick->label = CreateTitleBar(scrn, 0); ! 772: ! 773: pick->details = details = MakeAForm(pick, 1); ! 774: pick->general = general = MakeAForm(pick, 2); ! 775: FindStdWidth(); ! 776: ! 777: PrepareToUpdate(details); ! 778: AddDetailGroup(details); ! 779: ExecuteUpdate(details); ! 780: PrepareToUpdate(general); ! 781: AddGeneralGroup(general); ! 782: ExecuteUpdate(general); ! 783: GetWindowSize(general->inner, &width, &height); ! 784: GetWindowSize(scrn->window, &scrnwidth, &scrnheight); ! 785: if (width > scrnwidth) ! 786: height += XtScrollMgrGetThickness(DISPLAY general->outer); ! 787: XtVPanedSetMinMax(DISPLAY scrn->window, ! 788: general->outer, height, height); ! 789: XtVPanedSetMinMax(DISPLAY scrn->window, ! 790: general->outer, 10, 10000); ! 791: } ! 792: pick->toc = toc; ! 793: InitGeneral(pick, fromseq, toseq); ! 794: (void) sprintf(str, "Pick: %s", TocGetFolderName(toc)); ! 795: ChangeLabel(pick->label, str); ! 796: QXStoreName(theDisplay, scrn->window, str); ! 797: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.