home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume16 / hman / part02 < prev    next >
Encoding:
Text File  |  1992-03-06  |  19.5 KB  |  773 lines

  1. Newsgroups: comp.sources.x
  2. Path: uunet!munnari.oz.au!mips!mips!msi!dcmartin
  3. From: mab@ecmwf.co.uk (Baudouin Raoult)
  4. Subject: v16i144: hyperwidget & manual browser, Part02/06
  5. Message-ID: <1992Mar6.204813.8655@msi.com>
  6. Originator: dcmartin@fascet
  7. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  8. Organization: Molecular Simulations, Inc.
  9. References: <csx-16i143-hman@uunet.UU.NET>
  10. Date: Fri, 6 Mar 1992 20:48:13 GMT
  11. Approved: dcmartin@msi.com
  12.  
  13. Submitted-by: mab@ecmwf.co.uk (Baudouin Raoult)
  14. Posting-number: Volume 16, Issue 144
  15. Archive-name: hman/part02
  16.  
  17. #!/bin/sh
  18. # this is part 2 of a multipart archive
  19. # do not concatenate these parts, unpack them in order with /bin/sh
  20. # file cbacks.c continued
  21. #
  22. CurArch=2
  23. if test ! -r s2_seq_.tmp
  24. then echo "Please unpack part 1 first!"
  25.      exit 1; fi
  26. ( read Scheck
  27.   if test "$Scheck" != $CurArch
  28.   then echo "Please unpack part $Scheck next!"
  29.        exit 1;
  30.   else exit 0; fi
  31. ) < s2_seq_.tmp || exit 1
  32. echo "x - Continuing file cbacks.c"
  33. sed 's/^X//' << 'SHAR_EOF' >> cbacks.c
  34. Xstatic char *history[MAX_HISTORY];
  35. Xstatic int  history_count   = 0;
  36. Xstatic int  history_current = 0;
  37. X
  38. X/*----------------
  39. X  
  40. X  add the last call to man in the history list 
  41. X
  42. X---------------*/
  43. X
  44. Xvoid add_to_history(cmd)
  45. Xchar *cmd;
  46. X{
  47. X    int i;
  48. X
  49. X    if(history_count < MAX_HISTORY)
  50. X        history[history_count++] = XtNewString(cmd);
  51. X    else
  52. X    {
  53. X        XtFree(history[0]);
  54. X        for(i=1;i<MAX_HISTORY;i++)
  55. X            history[i+1] = history[i];
  56. X        history[history_count-1] =  XtNewString(cmd);
  57. X    }
  58. X    history_current = history_count-1;
  59. X    XtSetSensitive(previous,history_current>0);
  60. X    XtSetSensitive(next,FALSE);
  61. X}
  62. X
  63. X
  64. X/*-------------
  65. X
  66. X    When selecting a word on the HyperWidget,
  67. X    open a new page.
  68. X
  69. X-------------*/
  70. X
  71. Xvoid hyper_callback(w,cd,cb)
  72. XWidget w;
  73. XXtPointer cd;
  74. XhyperCallbackStruct *cb;
  75. X{
  76. X    char buf[256];
  77. X    char *word,*sec;
  78. X    int i;
  79. X
  80. X    strcpy(buf,cb->text);
  81. X
  82. X    word = strtok(buf,"(");
  83. X    sec  = strtok(NULL,")");
  84. X
  85. X    /* man wants lower case */
  86. X    i=0;
  87. X    while(sec[i])
  88. X    {
  89. X        if(isupper(sec[i])) sec[i]+=32;
  90. X        i++;
  91. X    }
  92. X    sec[2]=0; /* man does not want section > 3 chars */
  93. X
  94. X    sprintf(cmd,"%s %s %s",MAN,sec,word);
  95. X    do_man(cmd);
  96. X    add_to_history(cmd);
  97. X}
  98. X
  99. X/*-------------
  100. X
  101. X    Set the application icon.
  102. X
  103. X-------------*/
  104. X
  105. X#include "hman.xbm"
  106. Xvoid init_icon()
  107. X{
  108. X    Arg al[1];
  109. X    Pixmap icon_pixmap = NULL;
  110. X
  111. X
  112. X    XtSetArg(al[0],XtNiconPixmap, &icon_pixmap);
  113. X    XtGetValues(top,al,1);
  114. X
  115. X    /* if the icon is not user defined */
  116. X
  117. X    if (icon_pixmap == NULL)
  118. X    {
  119. X        XtSetArg(al[0],XmNiconPixmap,
  120. X            XCreateBitmapFromData(XtDisplay(top),
  121. X            XtScreen(top)->root,
  122. X            hman_bits, hman_width, hman_height)
  123. X            );
  124. X        XtSetValues(top, al,1);
  125. X    }
  126. X}
  127. X
  128. X/*-------------
  129. X    
  130. X    Create the HyperWidget.
  131. X    Open new page with the command arguments
  132. X
  133. X-------------*/
  134. X
  135. Xinit_manual(argc,argv)
  136. Xint argc;
  137. Xchar **argv;
  138. X{
  139. X    init_icon();
  140. X
  141. X    hyper = CreateHyper(scrollw,"hyper",NULL,0);
  142. X    XtAddCallback(hyper,XtNactivateCallback,hyper_callback,NULL);
  143. X    XtManageChild(hyper);
  144. X
  145. X    /* Set start and end of highlight tags */
  146. X
  147. X    HyperSetTags(hyper,START_OF_HIGHLIGHT,END_OF_HIGHLIGHT);
  148. X
  149. X    progname = argv[0];
  150. X
  151. X    if(argc>1)
  152. X    {
  153. X        ++argv;
  154. X        if(strcmp(argv[0],"-file")==0)
  155. X        {
  156. X            /* use file */
  157. X            if(argc != 3)
  158. X            {
  159. X                HyperSetText(hyper,"missing file name");
  160. X                return;
  161. X            }
  162. X            else
  163. X                sprintf(cmd,"%s %s",NROFF,argv[1]);
  164. X        }
  165. X        else
  166. X        {
  167. X            /* pass options to man command */
  168. X
  169. X            strcpy(cmd,MAN);
  170. X            while(--argc)
  171. X            {
  172. X                strcat(cmd," ");
  173. X                strcat(cmd,argv[0]);
  174. X                argv++;
  175. X            }
  176. X        }
  177. X
  178. X        do_man(cmd);
  179. X        add_to_history(cmd);
  180. X    }
  181. X}
  182. X
  183. X/*-------------
  184. X
  185. X    Set cursor to watch
  186. X
  187. X-------------*/
  188. X
  189. Xwatch_on()
  190. X{
  191. X    static Cursor watch = NULL;
  192. X    if(XtIsRealized(top))
  193. X    {
  194. X        if(!watch) watch = XCreateFontCursor(XtDisplay(top),XC_watch);
  195. X
  196. X        XDefineCursor(XtDisplay(top),XtWindow(top),watch);
  197. X        XDefineCursor(XtDisplay(hyper),XtWindow(hyper),watch);
  198. X        XDefineCursor(XtDisplay(find),XtWindow(find),watch);
  199. X        XmUpdateDisplay(top);
  200. X    }
  201. X}
  202. X
  203. X/*-------------
  204. X
  205. X    Reset cursor to default
  206. X
  207. X-------------*/
  208. X
  209. Xwatch_off()
  210. X{
  211. X    if(XtIsRealized(top))
  212. X    {
  213. X        XUndefineCursor(XtDisplay(top),XtWindow(top));
  214. X        XUndefineCursor(XtDisplay(hyper),XtWindow(hyper));
  215. X        XUndefineCursor(XtDisplay(find),XtWindow(find));
  216. X        XmUpdateDisplay(top);
  217. X    }
  218. X}
  219. X
  220. X
  221. X/*-------------
  222. X
  223. X    Call the man command. 
  224. X    Set the HyperWidget with the text 
  225. X    processed by lex.
  226. X
  227. X-------------*/
  228. X
  229. Xdo_man(cmd)
  230. Xchar *cmd;
  231. X{
  232. X    extern FILE *yyin,*yyout;
  233. X    FILE *f;
  234. X    char *tmp = tmpnam(NULL);
  235. X    char buf[1204];
  236. X
  237. X    watch_on();
  238. X
  239. X/* ----- 
  240. X
  241. X    This is what I use on the Sun.
  242. X
  243. X    sprintf(buf,"%s 2>&1 %s",cmd,FILTER);
  244. X
  245. X    The 2>&1 sends errors to standard output
  246. X    so errors are visible in the HyperWidget.
  247. X
  248. X    Some systems don't like it. 
  249. X
  250. X-----*/
  251. X
  252. X
  253. X    sprintf(buf,"%s %s",cmd,FILTER);
  254. X
  255. X    yyin = popen(buf,"r");
  256. X    yyout = fopen(tmp,"w");
  257. X    yylex();
  258. X    pclose(yyin);
  259. X    fclose(yyout);
  260. X
  261. X    HyperLoadFile(hyper,tmp);
  262. X    unlink(tmp);
  263. X
  264. X    watch_off();
  265. X}
  266. X
  267. X/*-------------
  268. X
  269. X    Byebye ..
  270. X
  271. X-------------*/
  272. X
  273. Xvoid quit_callback()
  274. X{
  275. X    exit(0);
  276. X}
  277. X
  278. X/*-------------
  279. X
  280. X    Move to previous page in history.
  281. X
  282. X-------------*/
  283. X
  284. Xvoid previous_callback(w,cd,cb)
  285. XWidget w;
  286. XXtPointer cd;
  287. XXmAnyCallbackStruct *cb;
  288. X{
  289. X    do_man(history[--history_current]);
  290. X    XtSetSensitive(next,TRUE);
  291. X    if(history_current==0)
  292. X        XtSetSensitive(previous,FALSE);
  293. X}
  294. X
  295. X/*-------------
  296. X
  297. X    Move to next page in history.
  298. X
  299. X-------------*/
  300. X
  301. Xvoid next_callback(w,cd,cb)
  302. XWidget w;
  303. XXtPointer cd;
  304. XXmAnyCallbackStruct *cb;
  305. X{
  306. X    do_man(history[++history_current]);
  307. X    XtSetSensitive(previous,TRUE);
  308. X    if(history_current==history_count-1)
  309. X        XtSetSensitive(next,FALSE);
  310. X}
  311. X
  312. X
  313. X/*-------------
  314. X
  315. X    Open new page using the text fields.
  316. X
  317. X-------------*/
  318. X
  319. Xvoid text_activate_callback(w,cd,cb)
  320. XWidget w;
  321. XXtPointer cd;
  322. XXmAnyCallbackStruct *cb;
  323. X{
  324. X    char *word = XmTextFieldGetString(keyword_text);
  325. X    char *sec  = XmTextFieldGetString(section_text);
  326. X
  327. X    sprintf(cmd,"%s %s %s %s",
  328. X        MAN,
  329. X        XmToggleButtonGetState(in_index)?"-k":"",
  330. X        sec,word);
  331. X    XtFree(word);
  332. X    XtFree(sec);
  333. X    do_man(cmd);
  334. X    add_to_history(cmd);
  335. X}
  336. X
  337. X/*-------------
  338. X
  339. X    Start a new copy of hman with the same manual page
  340. X
  341. X-------------*/
  342. X
  343. Xvoid clone_callback(w,cd,cb)
  344. XWidget w;
  345. XXtPointer cd;
  346. XXmAnyCallbackStruct *cb;
  347. X{
  348. X    char *h = history[history_current];
  349. X
  350. X    if(strncmp(h,MAN,strlen(MAN))==0)
  351. X        sprintf(cmd,"%s %s&",progname,h+strlen(MAN));
  352. X    else
  353. X        sprintf(cmd,"%s -file %s&",progname,h+strlen(NROFF));
  354. X
  355. X    system(cmd);
  356. X}
  357. X
  358. X/*---------
  359. X
  360. X Open a manual file
  361. X
  362. X----------*/
  363. X
  364. Xvoid fsb_callback(w,cd,cb)
  365. XWidget w;
  366. XXtPointer cd;
  367. XXmFileSelectionBoxCallbackStruct *cb;
  368. X{
  369. X    char *fname;
  370. X    XmStringGetLtoR(cb->value,XmSTRING_DEFAULT_CHARSET,&fname);
  371. X
  372. X
  373. X    sprintf(cmd,"%s %s",NROFF,fname);
  374. X    do_man(cmd);
  375. X    add_to_history(cmd);
  376. X
  377. X    XtFree(fname);
  378. X}
  379. X
  380. X/*---------
  381. X
  382. X  Search a string in the text
  383. X
  384. X----------*/
  385. X
  386. Xvoid find_callback(w,cd,cb)
  387. XWidget w;
  388. XXtPointer cd;
  389. XXtPointer cb;
  390. X{
  391. X    char *p = XmTextFieldGetString(find_text);
  392. X
  393. X    watch_on();
  394. X    if(!HyperGrep(hyper,p,TRUE,FALSE,TRUE))
  395. X        XBell(XtDisplay(w),0);
  396. X    watch_off();
  397. X
  398. X    XtFree(p);
  399. X}
  400. SHAR_EOF
  401. echo "File cbacks.c is complete"
  402. chmod 0644 cbacks.c || echo "restore of cbacks.c fails"
  403. set `wc -c cbacks.c`;Sum=$1
  404. if test "$Sum" != "7437"
  405. then echo original size 7437, current size $Sum;fi
  406. echo "x - extracting Hyper.c (Text)"
  407. sed 's/^X//' << 'SHAR_EOF' > Hyper.c &&
  408. X/*==================================================================*/
  409. X/*                                                                  */
  410. X/* HyperWidget                                                      */
  411. X/*                                                                  */
  412. X/* B.Raoult (mab@ecmwf.co.uk)                              Oct.91   */
  413. X/*                                                                  */
  414. X/*                                                                  */
  415. X/* Hyper text like widget.                                          */
  416. X/*                                                                  */
  417. X/* (c)  B.Raoult 91                                                 */
  418. X/*==================================================================*/
  419. X
  420. X#include <stdio.h>
  421. X#include <errno.h>
  422. X#include <ctype.h>
  423. X#include <X11/IntrinsicP.h>
  424. X#include <X11/Intrinsic.h>
  425. X#include <X11/StringDefs.h>
  426. X#include <X11/CoreP.h>
  427. X#include <X11/cursorfont.h>
  428. X#include "Hyper.h"
  429. X#include "HyperP.h"
  430. X
  431. X
  432. X#define ABS(a)           ((a)>=0?(a):-(a))
  433. X#define MIN(a,b)         ((a)>(b)?(b):(a))
  434. X
  435. X
  436. X#define NORMAL           0
  437. X#define HIGHLIGHT        1
  438. X#define NEWLINE          2
  439. X
  440. X#define MAX_LINE_SIZE    1024
  441. X
  442. X/* 
  443. X  Private functions 
  444. X*/
  445. X
  446. Xstatic void    free_text();
  447. Xstatic void    create_gcs();
  448. Xstatic void    create_new_text();
  449. Xstatic void    select();
  450. Xstatic void    cursor();
  451. Xstatic void    activate();
  452. Xstatic void    add_to_text ();
  453. Xstatic void    calc_new_size ();
  454. Xstatic void    zoom_open ();
  455. Xstatic void    show_selection();
  456. X
  457. X/*
  458. X  Widget class methods
  459. X*/
  460. X
  461. Xstatic void    Initialize();
  462. Xstatic void    Redisplay();
  463. Xstatic void    Resize();
  464. Xstatic void    Destroy();
  465. Xstatic Boolean SetValues();
  466. X
  467. Xstatic char defaultTranslations[] = 
  468. X"<Btn1Down>:select()\n<Btn1Up>: activate()\n<Motion>:cursor()";
  469. X
  470. Xstatic XtActionsRec actionsList[] = {
  471. X    { "select",   (XtActionProc) select},
  472. X    { "activate", (XtActionProc) activate},
  473. X    { "cursor",   (XtActionProc) cursor},
  474. X};
  475. X
  476. Xstatic XtResource resources[] = {
  477. X
  478. X    {XtNhighlightFont, XtCFont, XtRFontStruct, sizeof (XFontStruct *),
  479. X    XtOffset(HyperWidget, hyper.highlight_font), XtRString, "Fixed"},
  480. X
  481. X    {XtNnormalFont, XtCFont, XtRFontStruct, sizeof (XFontStruct *),
  482. X    XtOffset(HyperWidget, hyper.normal_font), XtRString, "Fixed"},
  483. X
  484. X    {XtNhighlightColor, XtCColor, XtRPixel, sizeof (Pixel),
  485. X    XtOffset(HyperWidget, hyper.highlight_color),XtRString, "Red"},
  486. X
  487. X    {XtNselectColor, XtCColor, XtRPixel, sizeof (Pixel),
  488. X    XtOffset(HyperWidget, hyper.select_color),XtRString, "Blue"},
  489. X
  490. X    {XtNnormalColor, XtCColor, XtRPixel, sizeof (Pixel),
  491. X    XtOffset(HyperWidget, hyper.normal_color),XtRString,"Black"},
  492. X
  493. X    {XtNactivateCallback,XtCCallback,XtRCallback,sizeof(caddr_t),
  494. X    XtOffset (HyperWidget, hyper.activate),XtRCallback,NULL},
  495. X
  496. X    {XtNzoomEffect,XtCZoom,XtRBoolean,sizeof(Boolean),
  497. X    XtOffset (HyperWidget, hyper.zoom),XtRImmediate,(XtPointer)TRUE},
  498. X
  499. X#ifndef XDESIGNER
  500. X    {XtNstartHighlight,XtCTagChar,XtRUnsignedChar,sizeof(unsigned char),
  501. X    XtOffset(HyperWidget,hyper.start_of_highlight),XtRImmediate,
  502. X    (XtPointer)'{'},
  503. X
  504. X    {XtNendHighlight,XtCTagChar,XtRUnsignedChar,sizeof(unsigned char),
  505. X    XtOffset (HyperWidget, hyper.end_of_highlight),XtRImmediate,
  506. X    (XtPointer)'}'},
  507. X#endif
  508. X
  509. X    {XtNzoomSpeed,XtCZoomSpeed,XtRInt,sizeof(int),
  510. X    XtOffset (HyperWidget, hyper.speed),XtRImmediate,(XtPointer)4},
  511. X
  512. X    {XtNmargin,XtCMargin,XtRInt,sizeof(int),
  513. X    XtOffset (HyperWidget, hyper.margin),XtRImmediate,(XtPointer)10},
  514. X};
  515. X
  516. X/*---------------------------------------------------------------*/
  517. X/* Static initialisation of the class record                     */
  518. X/*---------------------------------------------------------------*/
  519. X
  520. XHyperClassRec  hyperClassRec = {
  521. X    {
  522. X#ifdef MOTIF
  523. X    (WidgetClass) &xmPrimitiveClassRec,  /* superclass            */
  524. X#else
  525. X    (WidgetClass) &widgetClassRec,       /* superclass            */
  526. X#endif
  527. X    "Hyper",                             /* class_name            */
  528. X    sizeof(HyperRec),                    /* widget_size           */
  529. X    NULL,                                /* class_initialize      */
  530. X    NULL,                                /* class_part_initialize */
  531. X    FALSE,                               /* class_inited          */
  532. X    Initialize,                          /* initialize            */
  533. X    NULL,                                /* initialize_hook       */
  534. X    XtInheritRealize,                    /* realize               */
  535. X    actionsList,                         /* actions               */
  536. X    XtNumber(actionsList),               /* num_actions           */
  537. X    resources,                           /* resources             */
  538. X    XtNumber(resources),                 /* num_resources         */
  539. X    NULLQUARK,                           /* xrm_class             */
  540. X    TRUE,                                /* compress_motion       */
  541. X    TRUE,                                /* compress_exposure     */
  542. X    TRUE,                                /* compress_enterleave   */
  543. X    TRUE,                                /* visible_interest      */
  544. X    Destroy,                             /* destroy               */
  545. X    Resize,                              /* resize                */
  546. X    Redisplay,                           /* expose                */
  547. X    SetValues,                           /* set_values            */
  548. X    NULL,                                /* set_values_hook       */
  549. X    XtInheritSetValuesAlmost,            /* set_values_almost     */
  550. X    NULL,                                /* get_values_hook       */
  551. X    NULL,                                /* accept_focus          */
  552. X    XtVersion,                           /* version               */
  553. X    NULL,                                /* callback private      */
  554. X    defaultTranslations,                 /* tm_table              */
  555. X    NULL,                                /* query_geometry        */
  556. X    NULL,                                /* display_accelerator   */
  557. X    NULL,                                /* extension             */
  558. X    },
  559. X#ifdef MOTIF
  560. X    {
  561. X    (XtWidgetProc)_XtInherit,             /* border_highlight      */
  562. X    (XtWidgetProc)_XtInherit,             /* border_unhighligh     */
  563. X    XtInheritTranslations,                /* translations          */
  564. X    (XtActionProc)_XtInherit,             /* arm_and_activate      */
  565. X    NULL,                                 /* syn_resources         */
  566. X    0,                                    /* num_syn_resources     */
  567. X    NULL,                                 /* extension             */
  568. X    },
  569. X#endif
  570. X    {
  571. X    0,                                    /* ignore                */
  572. X    }
  573. X};
  574. X
  575. X
  576. X
  577. X
  578. X
  579. X
  580. X
  581. X
  582. X
  583. XWidgetClass hyperWidgetClass = (WidgetClass) &hyperClassRec;
  584. X
  585. X/*---------------------------------------------------------------*/
  586. X/* Create the two GCs needed                                     */
  587. X/*---------------------------------------------------------------*/
  588. X
  589. Xstatic void create_gcs(w)
  590. XHyperWidget w;
  591. X{
  592. X    XGCValues values;
  593. X    XtGCMask  valueMask;
  594. X
  595. X    valueMask = GCForeground | GCBackground | GCFont;
  596. X
  597. X    values.background = w->core.background_pixel;
  598. X
  599. X    values.foreground = w->hyper.highlight_color;
  600. X    values.font       = w->hyper.highlight_font->fid;
  601. X    w->hyper.highlight_gc = XtGetGC (w, valueMask, &values);
  602. X
  603. X    values.foreground = w->hyper.select_color;
  604. X    w->hyper.select_gc = XtGetGC (w, valueMask, &values);
  605. X
  606. X    values.foreground = w->hyper.normal_color;
  607. X    values.font       = w->hyper.normal_font->fid;
  608. X    w->hyper.normal_gc = XtGetGC (w, valueMask, &values);
  609. X
  610. X
  611. X
  612. X    valueMask = GCBackground | GCForeground | GCFunction;
  613. X
  614. X    values.background = w->core.background_pixel;
  615. X    values.foreground = w->hyper.normal_color;
  616. X
  617. X    values.function   = GXxor;
  618. X    w->hyper.xor_gc = XtGetGC (w, valueMask, &values);
  619. X
  620. X
  621. X}
  622. X
  623. X/*--------------------------------------------------------------*/
  624. X/* Initialize: Create the GCs                                   */
  625. X/*--------------------------------------------------------------*/
  626. X
  627. Xstatic void Initialize (request, new)
  628. XHyperWidget request, new;
  629. X{
  630. X    /* Check the size of the widget */
  631. X
  632. X    if (request->core.width == 0)
  633. X        new->core.width = 100;
  634. X    if (request->core.height == 0)
  635. X        new->core.height = 100;
  636. X
  637. X
  638. X    /* Create the GCs */
  639. X
  640. X    create_gcs(new);
  641. X
  642. X    /* No text yet */
  643. X
  644. X    new->hyper.first_seg     = new->hyper.last_selected 
  645. X        = new->hyper.last_cursor =  NULL;
  646. X    new->hyper.hand     = XCreateFontCursor(XtDisplay(new),XC_hand2);
  647. X
  648. X    /* Nothing found */
  649. X
  650. X    new->hyper.grep_seg = NULL;
  651. X    new->hyper.grep_txt = NULL;
  652. X    new->hyper.grep_len = 0;
  653. X    new->hyper.grep_off = 0;
  654. X
  655. X}
  656. X
  657. X/*--------------------------------------------------------------*/
  658. X/* Free all memory allocated for the text segments              */
  659. X/*--------------------------------------------------------------*/
  660. X
  661. Xstatic void free_text(s)
  662. Xtext_segment *s;
  663. X{
  664. X
  665. X    while(s)
  666. X    {
  667. X        text_segment *p=s->next;
  668. X        if(s->text) XtFree(s->text);
  669. X        XtFree(s);
  670. X        s = p;
  671. X    }
  672. X
  673. X}
  674. X
  675. X/*--------------------------------------------------------------*/
  676. X/* Destroy the widget: release all memory alocated              */
  677. X/*--------------------------------------------------------------*/
  678. X
  679. Xstatic void Destroy (w)
  680. XHyperWidget w;
  681. X{
  682. X    free_text(w->hyper.first_seg);
  683. X    XtReleaseGC (w, w->hyper.normal_gc);
  684. X    XtReleaseGC (w, w->hyper.highlight_gc);
  685. X    XtReleaseGC (w, w->hyper.xor_gc);
  686. X    XtReleaseGC (w, w->hyper.select_gc);
  687. X    XtRemoveAllCallbacks (w,XtNactivateCallback,w->hyper.activate);
  688. X}
  689. X
  690. X/*--------------------------------------------------------------*/
  691. X/* Resize : not implemented                                     */
  692. X/*--------------------------------------------------------------*/
  693. X
  694. X
  695. Xstatic void Resize (w)
  696. XHyperWidget w;
  697. X{
  698. X    /* 
  699. X       For futur implementation
  700. X       May be for text warp ...
  701. X    */
  702. X}
  703. X
  704. X/*--------------------------------------------------------------*/
  705. X/* Redisplay : redraw the text                                  */
  706. X/*--------------------------------------------------------------*/
  707. X
  708. X
  709. Xstatic void Redisplay (w, event, region)
  710. XHyperWidget  w;
  711. XXEvent       *event;
  712. XRegion        region;
  713. X{
  714. X
  715. X    if(w->core.visible)
  716. X    {
  717. X        text_segment *s = w->hyper.first_seg;
  718. X        int x = w->hyper.margin;
  719. X        int y = 0;
  720. X        Boolean newline = TRUE;
  721. X
  722. X        while(s)
  723. X        {
  724. X
  725. X            /* change line on new lines */
  726. X
  727. X            if(newline)
  728. X            {
  729. X                x = w->hyper.margin;
  730. X                y += s->height;
  731. X            }
  732. X
  733. X            /* redraw only what is needed */
  734. X
  735. X            if(XRectInRegion(region,x,y-s->height+s->desc,s->width,s->height)
  736. X                != RectangleOut)
  737. X            {
  738. X
  739. X                XDrawImageString(XtDisplay (w), XtWindow (w), 
  740. X                    s->gc,
  741. X                    x,
  742. X                    y,
  743. X                    s->text,
  744. X                    s->length);
  745. X            }
  746. X
  747. X            x += s->width;
  748. X
  749. X            newline = (s->type == NEWLINE);
  750. X
  751. X            s = s->next;
  752. X        }
  753. X
  754. X
  755. X        if(w->hyper.grep_seg)
  756. X        {
  757. X            if(XRectInRegion(region,
  758. X                w->hyper.grep_x,
  759. X                w->hyper.grep_y,
  760. X                w->hyper.grep_width,
  761. X                w->hyper.grep_height) != RectangleOut)
  762. X
  763. SHAR_EOF
  764. echo "End of part 2"
  765. echo "File Hyper.c is continued in part 3"
  766. echo "3" > s2_seq_.tmp
  767. exit 0
  768. -- 
  769. --
  770. Molecular Simulations, Inc.            mail: dcmartin@msi.com
  771. 796 N. Pastoria Avenue                uucp: uunet!dcmartin
  772. Sunnyvale, California 94086            at&t: 408/522-9236
  773.