home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3212 < prev    next >
Internet Message Format  |  1991-04-19  |  47KB

  1. From: eddyg@syma.sussex.ac.uk (Edward J. Groenendaal)
  2. Newsgroups: alt.sources
  3. Subject: X Desktop Manager(7)
  4. Message-ID: <4870@syma.sussex.ac.uk>
  5. Date: 17 Apr 91 20:51:48 GMT
  6.  
  7. ---- Cut Here and unpack ----
  8. #!/bin/sh
  9. # this is part 7 of a multipart archive
  10. # do not concatenate these parts, unpack them in order with /bin/sh
  11. # file code/Xedw/XedwList.c continued
  12. #
  13. CurArch=7
  14. if test ! -r s2_seq_.tmp
  15. then echo "Please unpack part 1 first!"
  16.      exit 1; fi
  17. ( read Scheck
  18.   if test "$Scheck" != $CurArch
  19.   then echo "Please unpack part $Scheck next!"
  20.        exit 1;
  21.   else exit 0; fi
  22. ) < s2_seq_.tmp || exit 1
  23. echo "x - Continuing file code/Xedw/XedwList.c"
  24. sed 's/^X//' << 'SHAR_EOF' >> code/Xedw/XedwList.c
  25. X        "when computing layout");
  26. X    XtAppWarning(XtWidgetToApplicationContext(w), buf);
  27. X      }
  28. X      request.request_mode = CWWidth | CWHeight;
  29. X      XtMakeGeometryRequest(w, &request, &reply);
  30. X      break;
  31. X    default:
  32. X      XtAppWarning(XtWidgetToApplicationContext(w),
  33. X           "XedwList Widget: Unknown geometry return.");
  34. X      break;
  35. X    }
  36. X    break;
  37. X  default:
  38. X    XtAppWarning(XtWidgetToApplicationContext(w),
  39. X         "XedwList Widget: Unknown geometry return.");
  40. X    break;
  41. X  }
  42. X}
  43. X
  44. X/*  Function Name: Initialise
  45. X *  Description: Function that initilises the widget instance.
  46. X *  Arguments: junk - NOT USED.
  47. X *             new  - the new widget.
  48. X *  Returns: none
  49. X */
  50. X
  51. Xstatic void Initialize(Widget junk, Widget new)
  52. X{
  53. X  XedwListWidget ilw = (XedwListWidget) new;
  54. X
  55. X/*
  56. X * Initialize all private resources.
  57. X */
  58. X
  59. X  GetGCs(new);
  60. X
  61. X  /* Set row height. */
  62. X  if (ilw->xedwList.show_icons)
  63. X    ilw->xedwList.row_height = ilw->xedwList.font->max_bounds.ascent
  64. X      + ilw->xedwList.font->max_bounds.descent
  65. X      + ilw->xedwList.row_space
  66. X      + ilw->xedwList.icon_height;
  67. X  else
  68. X    ilw->xedwList.row_height = ilw->xedwList.font->max_bounds.ascent
  69. X      + ilw->xedwList.font->max_bounds.descent
  70. X      + ilw->xedwList.row_space;
  71. X
  72. X  ResetXedwList(new, (new->core.width == 0), (new->core.height == 0));
  73. X
  74. X  ilw->xedwList.is_highlighted = (LinkedList*) XtMalloc (sizeof(LinkedList));
  75. X
  76. X  ilw->xedwList.highlight = ilw->xedwList.is_highlighted->index = NO_HIGHLIGHT;
  77. X  ilw->xedwList.is_highlighted->next = NULL;
  78. X
  79. X} /* Initialize */
  80. X
  81. X/*  Function Name: CvtToItem
  82. X *  Description: Converts Xcoord to item number of item containing that
  83. X *               point.
  84. X *  Arguments: w - the xedwList widget.
  85. X *             xloc, yloc - x location, and y location.
  86. X *  Returns: the item number.
  87. X */
  88. X
  89. Xstatic int CvtToItem(Widget w, int xloc, int yloc, int *item)
  90. X{
  91. X  int one, another;
  92. X  XedwListWidget ilw = (XedwListWidget) w;
  93. X  int ret_val = OKAY;
  94. X
  95. X  if (ilw->xedwList.vertical_cols) {
  96. X    one = ilw->xedwList.nrows * ((xloc - (int) ilw->xedwList.internal_width)
  97. X                 / ilw->xedwList.col_width);
  98. X    another = (yloc - (int) ilw->xedwList.internal_height)
  99. X      / ilw->xedwList.row_height;
  100. X    /* If out of range, return minimum possible value. */
  101. X    if (another >= ilw->xedwList.nrows) {
  102. X      another = ilw->xedwList.nrows - 1;
  103. X      ret_val = OUT_OF_RANGE;
  104. X    }
  105. X  }
  106. X  else {
  107. X    one = (ilw->xedwList.ncols * ((yloc - (int) ilw->xedwList.internal_height)
  108. X                  / ilw->xedwList.row_height)) ;
  109. X    /* If in right margin handle things right. */
  110. X    another = (xloc - (int) ilw->xedwList.internal_width) / ilw->xedwList.col_width;
  111. X    if (another >= ilw->xedwList.ncols) {
  112. X      another = ilw->xedwList.ncols - 1;
  113. X      ret_val = OUT_OF_RANGE;
  114. X    }
  115. X  }
  116. X  if ((xloc < 0) || (yloc < 0))
  117. X    ret_val = OUT_OF_RANGE;
  118. X  if (one < 0) one = 0;
  119. X  if (another < 0) another = 0;
  120. X  *item = one + another;
  121. X  if (*item >= ilw->xedwList.nitems) return(OUT_OF_RANGE);
  122. X  return(ret_val);
  123. X}
  124. X
  125. X/*  Function Name: FindCornerItems.
  126. X *  Description: Find the corners of the rectangle in item space.
  127. X *  Arguments: w - the xedwList widget.
  128. X *             event - the event structure that has the rectangle it it.
  129. X *             ul_ret, lr_ret - the corners ** RETURNED **.
  130. X *  Returns: none.
  131. X */
  132. X
  133. Xstatic int FindCornerItems(Widget w, XEvent *event, int *ul_ret, int *lr_ret)
  134. X{
  135. X  int xloc, yloc;
  136. X  
  137. X  xloc = event->xexpose.x;
  138. X  yloc = event->xexpose.y;
  139. X  CvtToItem(w, xloc, yloc, ul_ret);
  140. X  xloc += event->xexpose.width;
  141. X  yloc += event->xexpose.height;
  142. X  CvtToItem(w, xloc, yloc, lr_ret);
  143. X}
  144. X
  145. X/*  Function Name: ItemInRectangle
  146. X *  Description: returns TRUE if the item passed is in the given rectangle.
  147. X *  Arguments: w - the xedwList widget.
  148. X *             ul, lr - corners of the rectangle in item space.
  149. X *             item - item to check.
  150. X *  Returns: TRUE if the item passed is in the given rectangle.
  151. X */
  152. X
  153. Xstatic int ItemInRectangle(Widget w, int ul, int lr, int item)
  154. X{
  155. X  XedwListWidget ilw = (XedwListWidget) w;
  156. X  register int mod_item;
  157. X  int things;
  158. X
  159. X  if (item < ul || item > lr)
  160. X    return(FALSE);
  161. X  if (ilw->xedwList.vertical_cols)
  162. X    things = ilw->xedwList.nrows;
  163. X  else
  164. X    things = ilw->xedwList.ncols;
  165. X  
  166. X  mod_item = item % things;
  167. X  if ( (mod_item >= ul % things) && (mod_item <= lr % things ) )
  168. X    return(TRUE);
  169. X  return(FALSE);
  170. X}
  171. X
  172. X/*  Function Name: HighlightBackground
  173. X *  Description: paints the color of the background for the given item.
  174. X *  Arguments: w - the widget.
  175. X *             x, y - ul corner of the area item occupies.
  176. X *             item - the item we are dealing with.
  177. X *             gc - the gc that is used to paint this rectangle
  178. X *  Returns:
  179. X */
  180. X
  181. Xstatic int HighlightBackground(Widget w, int x, int y, int item, GC gc)
  182. X{
  183. X  XedwListWidget ilw = (XedwListWidget) w;
  184. X  int hl_x, hl_y, width, height;
  185. X
  186. X  hl_x = x - ilw->xedwList.column_space/2;
  187. X  width = XTextWidth(ilw->xedwList.font, ilw->xedwList.xedwList[item]->string,
  188. X             strlen(ilw->xedwList.xedwList[item]->string))
  189. X    + ilw->xedwList.column_space;
  190. X  hl_y = y + ((ilw->xedwList.show_icons) ? ilw->xedwList.icon_height : 0);
  191. X  height = ilw->xedwList.row_height - ilw->xedwList.row_space -
  192. X    ((ilw->xedwList.show_icons) ? ilw->xedwList.icon_height : 0);
  193. X
  194. X  XFillRectangle(XtDisplay(w), XtWindow(w), gc, hl_x, hl_y, width, height);
  195. X}
  196. X
  197. X/*  Function Name: PaintItemName
  198. X *  Description: paints the name of the item in the appropriate location.
  199. X *  Arguments: w - the xedwList widget.
  200. X
  201. X *             item - the item to draw.
  202. X *           op - XedwOn, XedwOff
  203. X *  Returns: none.
  204. X *
  205. X *      NOTE: no action taken on an unrealized widget.
  206. X */
  207. X
  208. Xstatic int PaintItemName(Widget w, int item, int operation)
  209. X{
  210. X  char * str;
  211. X  GC gc;
  212. X  unsigned normalmode, inversemode;
  213. X  int x, y, str_y, str_x;
  214. X  XedwListWidget ilw = (XedwListWidget) w;
  215. X
  216. X  if (!XtIsRealized(w)) return; /* Just in case... */
  217. X
  218. X
  219. X  if (ilw->xedwList.vertical_cols) {
  220. X    x = ilw->xedwList.col_width * (item / ilw->xedwList.nrows)
  221. X      + ilw->xedwList.internal_width;
  222. X    y = ilw->xedwList.row_height * (item % ilw->xedwList.nrows)
  223. X      + ilw->xedwList.internal_height;
  224. X  }
  225. X  else {
  226. X    x = ilw->xedwList.col_width * (item % ilw->xedwList.ncols)
  227. X      + ilw->xedwList.internal_width;
  228. X    y = ilw->xedwList.row_height * (item / ilw->xedwList.ncols)
  229. X      + ilw->xedwList.internal_height;
  230. X  }
  231. X
  232. X  
  233. X  str =  ilw->xedwList.xedwList[item]->string;
  234. X  
  235. X  str_y = y + ilw->xedwList.font->max_bounds.ascent;
  236. X
  237. X  if (ilw->xedwList.show_icons)
  238. X    str_x = x + ((ilw->xedwList.longest/2) -
  239. X         (XTextWidth(ilw->xedwList.font, str, strlen(str))/2));
  240. X  else
  241. X    str_x = x;
  242. X  
  243. X  if ((BlackPixelOfScreen(XtScreen(ilw))) == 1) {
  244. X    normalmode = GXcopy;
  245. X    inversemode = GXcopyInverted;
  246. X  } else {
  247. X    normalmode = GXcopyInverted;
  248. X    inversemode = GXcopy;
  249. X  }
  250. X
  251. X  if (ilw->xedwList.is_highlighted->index != NO_HIGHLIGHT) {
  252. X    /* There are some highlighted items */
  253. X    if (ilw->xedwList.highlight == NO_HIGHLIGHT) {
  254. X      /* This is an update */
  255. X      if (operation == XedwOn) {
  256. X    if (XtIsSensitive(w)) {
  257. X      /* Draw Inverse item */
  258. X      gc = ilw->xedwList.revgc;
  259. X      XSetFunction(XtDisplay(w), gc, inversemode);
  260. X      HighlightBackground(w, str_x, y, item, ilw->xedwList.normgc);
  261. X    } else {
  262. X      /* Draw Grey item */
  263. X    }  
  264. X      } else {
  265. X    gc = ilw->xedwList.normgc;
  266. X    /* XSetFunction(XtDisplay(w), gc, normalmode); */
  267. X      }
  268. X    } else {
  269. X      /* Were toggling something */
  270. X      if (operation == XedwOn) {
  271. X        if (XtIsSensitive(w)) {
  272. X          /* Draw Inverse item */
  273. X          gc = ilw->xedwList.revgc;
  274. X          XSetFunction(XtDisplay(w), gc, inversemode); 
  275. X          HighlightBackground(w, str_x, y, item, ilw->xedwList.normgc);
  276. X    } else {
  277. X      /* Draw Grey item */
  278. X    } 
  279. X      } else {
  280. X    /* Draw Normal item */
  281. X    gc = ilw->xedwList.normgc;
  282. X    XSetFunction(XtDisplay(ilw), gc, normalmode);
  283. X    HighlightBackground(w, str_x, y, item, ilw->xedwList.revgc); 
  284. X      }
  285. X    }
  286. X  } else {
  287. X    gc = ilw->xedwList.normgc;
  288. X    XSetFunction(XtDisplay(ilw), gc, normalmode);
  289. X  }
  290. X
  291. X  if (ilw->xedwList.default_icon == NULL)
  292. X    ilw->xedwList.default_icon = 
  293. X      XCreateBitmapFromData(XtDisplay(ilw), XtWindow(ilw), default_bits, 
  294. X                default_width, default_height);
  295. X
  296. X  if (ilw->xedwList.show_icons){
  297. X    Pixmap icon;
  298. X    if (ilw->xedwList.xedwList[item]->icon == NULL &&
  299. X    ilw->xedwList.default_icon != NULL) 
  300. X      icon = ilw->xedwList.default_icon;
  301. X    else 
  302. X      icon = ilw->xedwList.xedwList[item]->icon;
  303. X    if (DefaultDepthOfScreen(XtScreen(ilw)) == 1)
  304. X      XCopyArea(XtDisplay(ilw), icon,
  305. X        XtWindow(ilw), gc, 0, 0,
  306. X        ilw->xedwList.icon_width, ilw->xedwList.icon_height, x +
  307. X        ((ilw->xedwList.longest/2) - (ilw->xedwList.icon_width/2)), y);
  308. X    else
  309. X      XCopyPlane(XtDisplay(ilw), icon,
  310. X         XtWindow(ilw), gc, 0,0,
  311. X         ilw->xedwList.icon_width,ilw->xedwList.icon_height,x +
  312. X         ((ilw->xedwList.longest/2) - (ilw->xedwList.icon_width/2)), y,1);
  313. X    /* Draw string */
  314. X    XSetFunction(XtDisplay(ilw), gc, GXcopy);
  315. X    XDrawString(XtDisplay(ilw), XtWindow(ilw), gc, str_x,
  316. X        str_y+ilw->xedwList.icon_height, str, strlen(str));
  317. X  } else { /* No Icons */
  318. X    XSetFunction(XtDisplay(ilw), gc, GXcopy);
  319. X    XDrawString(XtDisplay(ilw), XtWindow(ilw), gc, str_x, str_y, str, strlen(str));
  320. X  }
  321. X}
  322. X
  323. X/*  Function Name: Redisplay
  324. X *  Description: Repaints the widget window on expose events.
  325. X *  Arguments: w - the xedwList widget.
  326. X *                 event - the expose event for this repaint.
  327. X *                 junk - NOT USED.
  328. X *  Returns:
  329. X */
  330. X
  331. Xstatic void Redisplay(Widget w, XEvent *event, Region junk)
  332. X{
  333. X  int item;           /* an item to work with. */
  334. X  int ul_item, lr_item;       /* corners of items we need to paint. */
  335. X  XedwListWidget ilw = (XedwListWidget) w;
  336. X
  337. X  if (event == NULL) {    /* repaint all. */
  338. X    ul_item = 0;
  339. X    lr_item = ilw->xedwList.nrows * ilw->xedwList.ncols - 1;
  340. X    XClearWindow(XtDisplay(w), XtWindow(w));
  341. X  }
  342. X  else
  343. X    FindCornerItems(w, event, &ul_item, &lr_item);
  344. X
  345. X  ilw->xedwList.highlight = NO_HIGHLIGHT;
  346. X  for (item = ul_item; (item <= lr_item && item < ilw->xedwList.nitems) ; item++)
  347. X    if (ItemInRectangle(w, ul_item, lr_item, item))
  348. X      if (IsHighlighted(w, item))
  349. X    PaintItemName(w, item, XedwOn);
  350. X      else
  351. X    PaintItemName(w, item, XedwOff);
  352. X}
  353. X
  354. X/*  Function Name: PreferredGeom
  355. X *  Description: This tells the parent what size we would like to be
  356. X *                   given certain constraints.
  357. X *  Arguments: w - the widget.
  358. X *                 intended - what the parent intends to do with us.
  359. X *                 requested - what we want to happen.
  360. X *  Returns: none.
  361. X */
  362. X
  363. Xstatic XtGeometryResult PreferredGeom(Widget w, 
  364. X                      XtWidgetGeometry *intended, 
  365. X                      XtWidgetGeometry *requested)
  366. X{
  367. X  Dimension new_width, new_height;
  368. X  Boolean change, width_req, height_req;
  369. X
  370. X  width_req = intended->request_mode & CWWidth;
  371. X  height_req = intended->request_mode & CWHeight;
  372. X
  373. X  if (width_req)
  374. X    new_width = intended->width;
  375. X  else
  376. X    new_width = w->core.width;
  377. X
  378. X  if (height_req)
  379. X    new_height = intended->height;
  380. X  else
  381. X    new_height = w->core.height;
  382. X
  383. X  requested->request_mode = 0;
  384. X
  385. X  /*
  386. X   * We only care about our height and width.
  387. X   */
  388. X
  389. X  if ( !width_req && !height_req)
  390. X    return(XtGeometryYes);
  391. X
  392. X  change = Layout(w, !width_req, !height_req, &new_width, &new_height);
  393. X
  394. X  requested->request_mode |= CWWidth;
  395. X  requested->width = new_width;
  396. X  requested->request_mode |= CWHeight;
  397. X  requested->height = new_height;
  398. X
  399. X  if (change)
  400. X    return(XtGeometryAlmost);
  401. X  return(XtGeometryYes);
  402. X}
  403. X
  404. X/*  Function Name: Resize
  405. X *  Description: resizes the widget, by changing the number of rows and
  406. X *               columns.
  407. X *  Arguments: w - the widget.
  408. X *  Returns: none.
  409. X */
  410. X
  411. Xstatic void Resize(Widget w)
  412. X{
  413. X  Dimension width, height;
  414. X
  415. X  width = w->core.width;
  416. X  height = w->core.height;
  417. X
  418. X  if (Layout(w, FALSE, FALSE, &width, &height))
  419. X    XtAppWarning(XtWidgetToApplicationContext(w),
  420. X         "XedwList Widget: Size changed when it shouldn't have when resising.");
  421. X}
  422. X
  423. X/*  Function Name: Layout
  424. X *  Description: lays out the item in the xedwList.
  425. X *  Arguments: w - the widget.
  426. X *             xfree, yfree - TRUE if we are free to resize the widget in
  427. X *                            this direction.
  428. X *             width, height - the is the current width and height that
  429. X *                             we are going to layout the xedwList widget to,
  430. X *                             depending on xfree and yfree of course.
  431. X *
  432. X *  Returns: TRUE if width or height have been changed.
  433. X */
  434. X
  435. Xstatic Boolean Layout(Widget w, Boolean xfree, Boolean yfree, 
  436. X              Dimension *width, Dimension *height)
  437. X{
  438. X  XedwListWidget ilw = (XedwListWidget) w;
  439. X  Boolean change = FALSE;
  440. X
  441. X  /*
  442. X   * If force columns is set then always use number of columns specified
  443. X   * by default_cols.
  444. X   */
  445. X
  446. X  if (ilw->xedwList.force_cols) {
  447. X    ilw->xedwList.ncols = ilw->xedwList.default_cols;
  448. X    if (ilw->xedwList.ncols <= 0) ilw->xedwList.ncols = 1;
  449. X    /* 12/3 = 4 and 10/3 = 4, but 9/3 = 3 */
  450. X    ilw->xedwList.nrows = ( ( ilw->xedwList.nitems - 1) / ilw->xedwList.ncols) + 1 ;
  451. X    if (xfree) {        /* If allowed resize width. */
  452. X      *width = ilw->xedwList.ncols * ilw->xedwList.col_width
  453. X    + 2 * ilw->xedwList.internal_width;
  454. X      change = TRUE;
  455. X    }
  456. X    if (yfree) {        /* If allowed resize height. */
  457. X      *height = (ilw->xedwList.nrows * ilw->xedwList.row_height)
  458. X    + 2 * ilw->xedwList.internal_height;
  459. X      change = TRUE;
  460. X    }
  461. X    return(change);
  462. X  }
  463. X
  464. X  /*
  465. X   * If both width and height are free to change the use default_cols
  466. X   * to determine the number columns and set new width and height to
  467. X   * just fit the window.
  468. X   */
  469. X
  470. X  if (xfree && yfree) {
  471. X    ilw->xedwList.ncols = ilw->xedwList.default_cols;
  472. X    if (ilw->xedwList.ncols <= 0) ilw->xedwList.ncols = 1;
  473. X    ilw->xedwList.nrows = ( ( ilw->xedwList.nitems - 1) / ilw->xedwList.ncols) + 1 ;
  474. X    *width = ilw->xedwList.ncols * ilw->xedwList.col_width
  475. X      + 2 * ilw->xedwList.internal_width;
  476. X    *height = (ilw->xedwList.nrows * ilw->xedwList.row_height)
  477. X      + 2 * ilw->xedwList.internal_height;
  478. X    change = TRUE;
  479. X  }
  480. X  /*
  481. X   * If the width is fixed then use it to determine the number of columns.
  482. X   * If the height is free to move (width still fixed) then resize the height
  483. X   * of the widget to fit the current xedwList exactly.
  484. X   */
  485. X  else if (!xfree) {
  486. X    ilw->xedwList.ncols = ( (*width - 2 * ilw->xedwList.internal_width)
  487. X               / ilw->xedwList.col_width);
  488. X    if (ilw->xedwList.ncols <= 0) ilw->xedwList.ncols = 1;
  489. X    ilw->xedwList.nrows = ( ( ilw->xedwList.nitems - 1) / ilw->xedwList.ncols) + 1 ;
  490. X    if ( yfree ) {
  491. X      *height = (ilw->xedwList.nrows * ilw->xedwList.row_height)
  492. X    + 2 * ilw->xedwList.internal_height;
  493. X      change = TRUE;
  494. X    }
  495. X  }
  496. X  /*
  497. X   * The last case is xfree and !yfree we use the height to determine
  498. X   * the number of rows and then set the width to just fit the resulting
  499. X   * number of columns.
  500. X   */
  501. X  else if (!yfree) {      /* xfree must be TRUE. */
  502. X    ilw->xedwList.nrows = (*height - 2 * ilw->xedwList.internal_height)
  503. X      / ilw->xedwList.row_height;
  504. X    if (ilw->xedwList.nrows <= 0) ilw->xedwList.nrows = 1;
  505. X    ilw->xedwList.ncols = (( ilw->xedwList.nitems - 1 ) / ilw->xedwList.nrows) + 1;
  506. X    *width = ilw->xedwList.ncols * ilw->xedwList.col_width
  507. X      + 2 * ilw->xedwList.internal_width;
  508. X    change = TRUE;
  509. X  }
  510. X  return(change);
  511. X}
  512. X
  513. X/*  Function Name: Notify
  514. X *  Description: Notifies the user that a button has been pressed, and
  515. X *               calles the callback, if the XtNpasteBuffer resource
  516. X *               is true then the name of the item is also put in the
  517. X *               X cut buffer ( buf (0) ).
  518. X *  Arguments: w - the widget that the notify occured in.
  519. X *             event - event that caused this notification.
  520. X *             params, num_params - not used.
  521. X *  Returns: none.
  522. X */
  523. X
  524. Xstatic void Notify(Widget w, XEvent *event, String *params, 
  525. X           Cardinal *num_params)
  526. X{
  527. X  XedwListWidget ilw = ( XedwListWidget ) w;
  528. X  LinkedList *list = ilw->xedwList.is_highlighted;
  529. X  int item, item_len;
  530. X  XedwListReturnStruct ret_value;
  531. X
  532. X  if ( ((CvtToItem(w, event->xbutton.x, event->xbutton.y, &item))
  533. X    == OUT_OF_RANGE) || (ilw->xedwList.highlight != item) ) {
  534. X    XedwListUnhighlight(w, ilw->xedwList.highlight);
  535. X    RemoveNode(w, ilw->xedwList.highlight);
  536. X    XtCallCallbacks(w, XtNcallback, (caddr_t) 0);
  537. X    return;
  538. X  }
  539. X
  540. X  /* Put the name of ALL highlighted strings into the X cut buffer, 
  541. X   * seperated by spaces.
  542. X
  543. X  item_len = 0;
  544. X  while(list != NULL) {
  545. X    item_len +=  strlen(ilw->xedwList.xedwList[list.index]->string) + 1;
  546. X      list=list->next;
  547. X  }
  548. X
  549. X  */
  550. X
  551. X  item_len = strlen(ilw->xedwList.xedwList[item]->string);
  552. X  
  553. X  if ( ilw->xedwList.paste )   /* if XtNpasteBuffer set then paste it. */
  554. X    XStoreBytes(XtDisplay(w), ilw->xedwList.xedwList[item]->string, item_len);
  555. X
  556. X  /*
  557. X   * Call Callback function.
  558. X   */
  559. X
  560. X  ret_value.string = ilw->xedwList.xedwList[item]->string;
  561. X  ret_value.xedwList_index = item;
  562. X  ret_value.next = NULL;
  563. X  
  564. X  XtCallCallbacks( w, XtNcallback, (caddr_t) &ret_value);
  565. X}
  566. X
  567. X/*  Function Name: Unset
  568. X *  Description: unhighlights the current elements.
  569. X *  Arguments: w - the widget that the event occured in.
  570. X *                 event - not used.
  571. X *                 params, num_params - not used.
  572. X *  Returns: none.
  573. X */
  574. X
  575. Xstatic void Unset(Widget w, XEvent *event, String *params, 
  576. X          Cardinal *num_params)
  577. X{
  578. X  XedwListUnhighlight(w, XedwAll);
  579. X}
  580. X
  581. X/*  Function Name: Set
  582. X *  Description: Highlights the current element.
  583. X *  Arguments: w - the widget that the event occured in.
  584. X *                 event - event that caused this notification.
  585. X *                 params, num_params - not used.
  586. X *  Returns: none.
  587. X */
  588. X
  589. Xstatic void Set(Widget w, XEvent *event, String *params, 
  590. X        Cardinal *num_params)
  591. X{
  592. X  int item;
  593. X  XedwListWidget ilw = (XedwListWidget) w;
  594. X
  595. X  if ( (CvtToItem(w, event->xbutton.x, event->xbutton.y, &item))
  596. X      == OUT_OF_RANGE)
  597. X    XedwListUnhighlight(w, XedwAll);    /* Unhighlight current items. */
  598. X  else {
  599. X    if (ilw->xedwList.highlight != item || 
  600. X    ilw->xedwList.is_highlighted->next != NULL) 
  601. X      XedwListUnhighlight(w, XedwAll);    /* Unhighlight any others */
  602. X    XedwListHighlight(w, item);       /* highlight it */
  603. X  }
  604. X}
  605. X
  606. X/*  Function Name: MultipleSet
  607. X *  Description: Highlights the current element.
  608. X *  Arguments: w - the widget that the event occured in.
  609. X *                 event - event that caused this notification.
  610. X *                 params, num_params - not used.
  611. X *  Returns: none.
  612. X */
  613. X
  614. Xstatic void MultipleSet(Widget w, XEvent *event, String *params, 
  615. X        Cardinal *num_params)
  616. X{
  617. X  int item;
  618. X  XedwListWidget ilw = (XedwListWidget) w;
  619. X
  620. X  if (ilw->xedwList.multiple == True)
  621. X    if ( (CvtToItem(w, event->xbutton.x, event->xbutton.y, &item))
  622. X    == OUT_OF_RANGE)
  623. X      XedwListUnhighlight(w, XedwAll);     /* Unhighlight all current items. */
  624. X    else 
  625. X      if (IsHighlighted(w, item))    /* If already highlighted, */
  626. X    XedwListUnhighlight(w, item);    /* unhighlight it */
  627. X      else
  628. X    XedwListHighlight(w, item);       /* otherwise highlight it */
  629. X  else
  630. X    XBell(XtDisplay(w), 100);
  631. X}
  632. X
  633. X/* 
  634. X * Return state of a list item 
  635. X */
  636. Xstatic Boolean IsHighlighted(Widget w, int item)
  637. X{
  638. X  XedwListWidget ilw = (XedwListWidget) w;
  639. X  LinkedList *list = ilw->xedwList.is_highlighted;
  640. X  Boolean ret_val;
  641. X
  642. X  while (list != NULL && list->index != item && list->index != NO_HIGHLIGHT)
  643. X    list = list->next;
  644. X  
  645. X  if (list == NULL || list->index == NO_HIGHLIGHT)
  646. X    ret_val=FALSE;
  647. X  else
  648. X    ret_val=TRUE;
  649. X  
  650. X  return(ret_val);    /* true if item was in list false otherwise */
  651. X}
  652. X
  653. X/*
  654. X * Set specified arguments into widget
  655. X */
  656. X
  657. Xstatic Boolean SetValues(Widget current, 
  658. X             Widget request, 
  659. X             Widget new)
  660. X{
  661. X  XedwListWidget cl = (XedwListWidget) current;
  662. X  XedwListWidget rl = (XedwListWidget) request;
  663. X  XedwListWidget nl = (XedwListWidget) new;
  664. X  Boolean redraw = FALSE;
  665. X
  666. X  if ((cl->xedwList.foreground != rl->xedwList.foreground) ||
  667. X      (cl->core.background_pixel != rl->core.background_pixel) ||
  668. X      (cl->xedwList.font != rl->xedwList.font) ) {
  669. X    XtDestroyGC(cl->xedwList.normgc);
  670. X    XtDestroyGC(cl->xedwList.graygc);
  671. X    XtDestroyGC(cl->xedwList.revgc);
  672. X    GetGCs(new);
  673. X    redraw = TRUE;
  674. X  }
  675. X
  676. X  /* Reset row height. */
  677. X  
  678. X  if ((cl->xedwList.row_space != rl->xedwList.row_space) ||
  679. X      (cl->xedwList.font != rl->xedwList.font)           ||
  680. X      (cl->xedwList.show_icons != rl->xedwList.show_icons) ||
  681. X      (cl->xedwList.icon_width != rl->xedwList.icon_width)           ||
  682. X      (cl->xedwList.icon_height != rl->xedwList.icon_height))
  683. X    if (rl->xedwList.show_icons) 
  684. X      nl->xedwList.row_height = nl->xedwList.font->max_bounds.ascent
  685. X    + nl->xedwList.font->max_bounds.descent
  686. X    + nl->xedwList.row_space
  687. X        + nl->xedwList.icon_height;
  688. X    else
  689. X      nl->xedwList.row_height = nl->xedwList.font->max_bounds.ascent
  690. X    + nl->xedwList.font->max_bounds.descent
  691. X    + nl->xedwList.row_space;
  692. X
  693. X  if ((cl->core.width != rl->core.width)                     ||
  694. X      (cl->core.height != rl->core.height)                   ||
  695. X      (cl->xedwList.internal_width != rl->xedwList.internal_width)   ||
  696. X      (cl->xedwList.internal_height != rl->xedwList.internal_height) ||
  697. X      (cl->xedwList.column_space != rl->xedwList.column_space)       ||
  698. X      (cl->xedwList.row_space != rl->xedwList.row_space)             ||
  699. X      (cl->xedwList.default_cols != rl->xedwList.default_cols)       ||
  700. X      ((cl->xedwList.force_cols != rl->xedwList.force_cols) &&
  701. X       (rl->xedwList.force_cols != rl->xedwList.ncols))           ||
  702. X      (cl->xedwList.vertical_cols != rl->xedwList.vertical_cols)     ||
  703. X      (cl->xedwList.longest != rl->xedwList.longest)                 ||
  704. X      (cl->xedwList.nitems != rl->xedwList.nitems)                   ||
  705. X      (cl->xedwList.font != rl->xedwList.font)                       ||
  706. X      (cl->xedwList.show_icons != rl->xedwList.show_icons)           ||
  707. X      (cl->xedwList.icon_width != rl->xedwList.icon_width)           ||
  708. X      (cl->xedwList.icon_height != rl->xedwList.icon_height)         ||
  709. X      (cl->xedwList.default_icon != rl->xedwList.default_icon)       ||
  710. X      (cl->xedwList.xedwList != rl->xedwList.xedwList)                        ) {
  711. X    
  712. X    ResetXedwList(new, TRUE, TRUE);
  713. X    redraw = TRUE;
  714. X  }
  715. X
  716. X  if (cl->xedwList.xedwList != rl->xedwList.xedwList)
  717. X    nl->xedwList.highlight = NO_HIGHLIGHT;
  718. X
  719. X  if ((cl->core.sensitive != rl->core.sensitive) ||
  720. X      (cl->core.ancestor_sensitive != rl->core.ancestor_sensitive)) {
  721. X    nl->xedwList.highlight = NO_HIGHLIGHT;
  722. X    redraw = TRUE;
  723. X  }
  724. X  
  725. X  if (!XtIsRealized(current))
  726. X    return(FALSE);
  727. X
  728. X  return(redraw);
  729. X}
  730. X
  731. X/* Exported Functions */
  732. X
  733. X/*  Function Name: XedwListChange.
  734. X *  Description: Changes the xedwList being used and shown.
  735. X *  Arguments: w - the xedwList widget.
  736. X *                 xedwList - the new xedwList.
  737. X *                 nitems - the number of items in the xedwList.
  738. X *                 longest - the length (in Pixels) of the longest element
  739. X *                           in the xedwList.
  740. X *                 resize - if TRUE the the xedwList widget will
  741. X *                          try to resize itself.
  742. X *  Returns: none.
  743. X *      NOTE:      If nitems of longest are <= 0 then they will be calculated.
  744. X *                 If nitems is <= 0 then the xedwList needs to be NULL terminated.
  745. X */
  746. X
  747. Xvoid XedwListChange(Widget w, XedwList **xedwList, 
  748. X               int nitems, int longest, Boolean resize_it)
  749. X{
  750. X  XedwListWidget ilw = (XedwListWidget) w;
  751. X
  752. X  ilw->xedwList.xedwList = xedwList;
  753. X  
  754. X  if (nitems <= 0) nitems = 0;
  755. X  ilw->xedwList.nitems = nitems;
  756. X  if (longest <= 0) longest = 0;
  757. X  ilw->xedwList.longest = longest;
  758. X
  759. X  ResetXedwList(w, resize_it, resize_it);
  760. X  /* Free the memeory in the old list TODO */
  761. X  ilw->xedwList.is_highlighted->index = ilw->xedwList.highlight = NO_HIGHLIGHT;
  762. X  ilw->xedwList.is_highlighted->next = NULL;
  763. X  if ( XtIsRealized(w) )
  764. X    Redisplay(w, NULL, NULL);
  765. X}
  766. X
  767. X/*  Function Name: XedwListUnhighlight
  768. X *  Description: unlights the current highlighted element.
  769. X *  Arguments: w - the widget.
  770. X *  Returns: none.
  771. X */
  772. X
  773. Xvoid XedwListUnhighlight(Widget w, int item)
  774. X{
  775. X  XedwListWidget ilw = ( XedwListWidget ) w;
  776. X  LinkedList *list = ilw->xedwList.is_highlighted;
  777. X  LinkedList *temp;
  778. X
  779. X  if (ilw->xedwList.is_highlighted->index != NO_HIGHLIGHT)
  780. X    if (item == XedwAll) {
  781. X      ilw->xedwList.highlight = list->index;    
  782. X      PaintItemName(w, list->index, XedwOff);    /* unhighlight ALL */
  783. X      while (list->next != NULL) {        
  784. X    temp = list;
  785. X    list = list->next;
  786. X    ilw->xedwList.highlight = list->index;
  787. X    PaintItemName(w, list->index, XedwOff);
  788. X    XtFree(temp);
  789. X      }
  790. X      list->index = NO_HIGHLIGHT;
  791. X      ilw->xedwList.is_highlighted = list;
  792. X    } else {
  793. X      ilw->xedwList.highlight = item;
  794. X      PaintItemName(w, item, XedwOff);
  795. X      RemoveNode(w, item);
  796. X    }
  797. X}
  798. X
  799. X/*  Function Name: XedwListHighlight
  800. X *  Description: Highlights the given item.
  801. X *  Arguments: w - the xedwList widget.
  802. X *             item - the item to hightlight.
  803. X *  Returns: none.
  804. X */
  805. X
  806. Xvoid XedwListHighlight(Widget w, int item)
  807. X{
  808. X  XedwListWidget ilw = ( XedwListWidget ) w;
  809. X  int n;
  810. X
  811. X  if (XtIsSensitive(w)) {
  812. X    if (item == XedwAll) {
  813. X      for(n=0; n < ilw->xedwList.nitems; n++) {
  814. X    ilw->xedwList.highlight = n;
  815. X    RemoveNode(w, n);
  816. X    AddNode(w, n);
  817. X    PaintItemName(w, n, XedwOn);
  818. X      }
  819. X    } else {
  820. X      ilw->xedwList.highlight = item;
  821. X      RemoveNode(w, item);
  822. X      AddNode(w, item);
  823. X      PaintItemName(w, item, XedwOn);    
  824. X    }
  825. X  }
  826. X}
  827. X
  828. X/*  Function Name: XedwListShowCurrent
  829. X *  Description: returns the currently highlighted object.
  830. X *  Arguments: w - the xedwList widget.
  831. X *  Returns: the info about the currently highlighted object.
  832. X */
  833. X
  834. XXedwListReturnStruct *XedwListShowCurrent(Widget w)
  835. X{
  836. X  XedwListWidget ilw = ( XedwListWidget ) w;
  837. X  LinkedList *hl = ilw->xedwList.is_highlighted;
  838. X  XedwListReturnStruct *ret_val, *rest;
  839. X
  840. X  rest = NULL;
  841. X  while (hl != NULL) {
  842. X    ret_val = (XedwListReturnStruct *) XtMalloc (sizeof (XedwListReturnStruct));
  843. X    
  844. X    ret_val->xedwList_index = hl->index;
  845. X    if (ret_val->xedwList_index == XDTM_LIST_NONE)
  846. X      ret_val->string = "";
  847. X    else
  848. X      ret_val->string = 
  849. X    XtNewString(ilw->xedwList.xedwList[ret_val->xedwList_index]->string);
  850. X    hl = hl->next;
  851. X    ret_val->next = rest;
  852. X    rest = ret_val;
  853. X  }
  854. X  return(ret_val);
  855. X}
  856. X
  857. XBoolean XedwListSelection(Widget w)
  858. X{
  859. X  XedwListWidget ilw = ( XedwListWidget ) w;
  860. X  LinkedList *hl = ilw->xedwList.is_highlighted;
  861. X  Boolean ret_val = True;
  862. X  
  863. X  if (hl->index == NO_HIGHLIGHT)
  864. X    ret_val = False;
  865. X
  866. X  return(ret_val);
  867. X}
  868. X
  869. X/* AddNode to LinkedList of highlighted items
  870. X */
  871. Xstatic void AddNode(Widget w, int item)
  872. X{
  873. X  XedwListWidget ilw = ( XedwListWidget ) w;
  874. X  LinkedList *list = ilw->xedwList.is_highlighted;
  875. X  LinkedList *temp;
  876. X
  877. X  if (list->index != NO_HIGHLIGHT) {
  878. X    temp = (LinkedList*) XtMalloc (sizeof(LinkedList));
  879. X    temp->index = item;
  880. X    temp->next = list;
  881. X    ilw->xedwList.is_highlighted = temp;
  882. X  } else 
  883. X    list->index = item;
  884. X}
  885. X  
  886. X
  887. Xstatic void RemoveNode(Widget w, int item)
  888. X{
  889. X  XedwListWidget ilw = ( XedwListWidget ) w;
  890. X  LinkedList *list = ilw->xedwList.is_highlighted;
  891. X  LinkedList *last;                              
  892. X
  893. X  last = list;
  894. X  while (list != NULL && list->index != item) {
  895. X    last = list;
  896. X    list=list->next;
  897. X  }
  898. X  if (list != NULL) {            /* item WAS found */
  899. X    if (last == list) {        /* it was the first item */
  900. X      if (list->next == NULL)   /* there are no more in the list */
  901. X    list->index = NO_HIGHLIGHT;
  902. X      else {
  903. X    ilw->xedwList.is_highlighted = list->next;
  904. X    XtFree(list);
  905. X      }
  906. X    } else {
  907. X      last->next = list->next;
  908. X      XtFree(list);
  909. X    }
  910. X  } 
  911. X}
  912. SHAR_EOF
  913. echo "File code/Xedw/XedwList.c is complete"
  914. chmod 0644 code/Xedw/XedwList.c || echo "restore of code/Xedw/XedwList.c fails"
  915. echo "x - extracting code/Xedw/XedwList.h (Text)"
  916. sed 's/^X//' << 'SHAR_EOF' > code/Xedw/XedwList.h &&
  917. X/*
  918. X * Copyright 1989 Massachusetts Institute of Technology
  919. X *
  920. X * Permission to use, copy, modify, distribute, and sell this software and its
  921. X * documentation for any purpose is hereby granted without fee, provided that
  922. X * the above copyright notice appear in all copies and that both that
  923. X * copyright notice and this permission notice appear in supporting
  924. X * documentation, and that the name of M.I.T. not be used in advertising or
  925. X * publicity pertaining to distribution of the software without specific,
  926. X * written prior permission.  M.I.T. makes no representations about the
  927. X * suitability of this software for any purpose.  It is provided "as is"
  928. X * without express or implied warranty.
  929. X *
  930. X * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  931. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  932. X * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  933. X * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  934. X * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  935. X * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  936. X */
  937. X
  938. X/*
  939. X * XedwList.h - XedwList widget
  940. X *
  941. X * This is the XedwList widget. It is very similar to the Athena Widget List,
  942. X * except it has the ability to display an icon with the string.
  943. X * It allows the user to select an item in a xedwList and notifies the
  944. X * application through a callback function.
  945. X *
  946. X *  List Created:   8/13/88
  947. X *  By:     Chris D. Peterson
  948. X *                      MIT X Consortium
  949. X *
  950. X * Modified to XedwList: 1/26/90
  951. X * By:      Edward Groenendaal
  952. X *                      University of Sussex, UK.
  953. X */
  954. X
  955. X#ifndef _XawXedwList_h
  956. X#define _XawXedwList_h
  957. X
  958. X/***********************************************************************
  959. X *
  960. X * XedwList Widget
  961. X *
  962. X ***********************************************************************/
  963. X
  964. X#include <X11/Xaw/Simple.h>
  965. X
  966. X/* Resources:
  967. X
  968. X Name               Class           RepType             Default Value
  969. X ----               -----           -------             -------------
  970. X background         Background      Pixel               XtDefaultBackground
  971. X border             BorderColor     Pixel               XtDefaultForeground
  972. X borderWidth        BorderWidth     Dimension           1
  973. X callback           Callback        XtCallbackXedwList  NULL       **6
  974. X columnSpacing      Spacing         Dimension           6
  975. X cursor             Cursor          Cursor              left_ptr
  976. X defaultColumns     Columns         int                 2          **5
  977. X destroyCallback    Callback        Pointer             NULL
  978. X font               Font            XFontStruct*        XtDefaultFont
  979. X forceColumns       Columns         Boolean             False      **5
  980. X foreground         Foreground      Pixel               XtDefaultForeground
  981. X height             Height          Dimension           0          **1
  982. X insensitiveBorder  Insensitive     Pixmap              Gray
  983. X internalHeight     Height          Dimension           2
  984. X internalWidth      Width           Dimension           4
  985. X xedwList           XedwList        XedwList **      NULL       **2
  986. X iconWidth          Width           Dimension           32
  987. X iconHeight         Height          Dimension           32
  988. X longest            Longest         int                 0          **3  **4
  989. X mappedWhenManaged  MappedWhenManaged   Boolean         True
  990. X mSelections        Boolean         Boolean             False
  991. X numberStrings      NumberStrings   int                 0          **4
  992. X pasteBuffer        Boolean         Boolean             False
  993. X rowSpacing         Spacing         Dimension           4
  994. X sensitive          Sensitive       Boolean             True
  995. X showIcons          Boolean         Boolean             False                  
  996. X verticalList       Boolean         Boolean             False
  997. X width              Width           Dimension           0          **1
  998. X x                  Position        Position            0
  999. X y                  Position        Position            0
  1000. X
  1001. X **1 - If the Width or Height of the xedwList widget is zero (0) then the value
  1002. X       is set to the minimum size necessay to fit the entire list.
  1003. X
  1004. X       If both Width and Height are zero then they are adjusted to fit the
  1005. X       entire list that is created width the number of default columns
  1006. X       specified in the defaultColumns resource.
  1007. X
  1008. X **2 - This is an array of strings the specify elements of the xedwList.
  1009. X       This resource must be specified.
  1010. X
  1011. X **3 - Longest is the length of the widest string in pixels.
  1012. X
  1013. X **4 - If either of these values are zero (0) then the xedwList widget calculates
  1014. X       the correct value.
  1015. X
  1016. X       (This allows you to make startup faster if you already have
  1017. X        this information calculated)
  1018. X
  1019. X       NOTE: If the numberStrings value is zero the xedwList must
  1020. X             be NULL terminated.
  1021. X
  1022. X **5 - By setting the XedwList.Columns resource you can force the application to
  1023. X       have a given number of columns.
  1024. X
  1025. X **6 - This returns the name and index of the item selected in an
  1026. X       XedwListReturnStruct that is pointed to by the client_data
  1027. X       in the CallbackProc.
  1028. X
  1029. X*/
  1030. X
  1031. X
  1032. X/*
  1033. X * Value returned when there are no highlighted objects.
  1034. X */
  1035. X
  1036. X#define XDTM_LIST_NONE -1
  1037. X
  1038. X#define XtCXedwList "XedwList"
  1039. X#define XtCSpacing "Spacing"
  1040. X#define XtCColumns "Columns"
  1041. X#define XtCLongest "Longest"
  1042. X#define XtCNumberStrings "NumberStrings"
  1043. X
  1044. X#define XtNcursor "cursor"
  1045. X#define XtNcolumnSpacing "columnSpacing"
  1046. X#define XtNdefaultColumns "defaultColumns"
  1047. X#define XtNforceColumns "forceColumns"
  1048. X#define XtNxedwList "xedwList"
  1049. X#define XtNiconWidth "iconWidth"
  1050. X#define XtNiconHeight "iconHeight"
  1051. X#define XtNdefaultIcon "defaultIcon"
  1052. X#define XtNlongest "longest"
  1053. X#define XtNnumberStrings "numberStrings"
  1054. X#define XtNpasteBuffer "pasteBuffer"
  1055. X#define XtNrowSpacing "rowSpacing"
  1056. X#define XtNshowIcons "showIcons"
  1057. X#define XtNmSelections "mSelections"
  1058. X#define XtNverticalList "verticalList"
  1059. X
  1060. X#define XedwSingle    1
  1061. X#define XedwMultiple  2
  1062. X
  1063. X#define XedwAll            -1
  1064. X
  1065. X#define IconBitmapWidth       32
  1066. X#define IconBitmapHeight      32
  1067. X
  1068. X/* Class record constants */
  1069. X
  1070. Xextern WidgetClass xedwListWidgetClass;
  1071. X
  1072. Xtypedef struct _XedwListClassRec *XedwListWidgetClass;
  1073. Xtypedef struct _XedwListRec      *XedwListWidget;
  1074. X
  1075. X/* The structure of XedwList */
  1076. X
  1077. Xtypedef struct _XedwList {
  1078. X  String string;
  1079. X  Pixmap icon;
  1080. X} XedwList;
  1081. X
  1082. X/* The xedwList return structure. */
  1083. X
  1084. Xtypedef struct _XedwListReturnStruct {
  1085. X  String   string;            /* String */
  1086. X  int      xedwList_index;        /* Index into list */
  1087. X  struct _XedwListReturnStruct *next;    /* Next highlighted entry */
  1088. X} XedwListReturnStruct;
  1089. X
  1090. X/******************************************************************
  1091. X *
  1092. X * Exported Functions
  1093. X *
  1094. X *****************************************************************/
  1095. X
  1096. X/*  Function Name:  XedwListChange.
  1097. X *  Description:    Changes the xedwList being used and shown.
  1098. X *  Arguments:      w        -  the xedwList widget.
  1099. X *                  xedwList -  the new xedwList.
  1100. X *                  nitems   -  the number of items in the xedwList.
  1101. X *                  longest  -  the length (in Pixels) of the longest element
  1102. X *                              in the xedwList.
  1103. X *                  resize   -  if TRUE the the xedwList widget will
  1104. X *                              try to resize itself.
  1105. X *  Returns: none.
  1106. X *  NOTE:    If nitems of longest are <= 0 then they will be caluculated.
  1107. X *           If nitems is <= 0 then the xedwList needs to be NULL terminated.
  1108. X */
  1109. X
  1110. Xextern void XedwListChange(Widget, XedwList**,int,int,Boolean); 
  1111. X
  1112. X/*  Function Name:  XedwListUnhighlight
  1113. X *  Description:    unlights the current highlighted element.
  1114. X *  Arguments:      w   -   the widget.
  1115. X *  Returns: none.
  1116. X */
  1117. X
  1118. Xextern void XedwListUnhighlight(Widget, int);
  1119. X
  1120. X/*  Function Name:  XedwListHighlight
  1121. X *  Description:    Highlights the given item.
  1122. X *  Arguments:      w    -  the xedwList widget.
  1123. X *                  item -  the item to hightlight.
  1124. X *  Returns: none.
  1125. X */
  1126. X
  1127. Xextern void XedwListHighlight(Widget, int); 
  1128. X
  1129. X
  1130. X/*  Function Name: XedwListShowCurrent
  1131. X *  Description: returns the currently highlighted objects.
  1132. X *  Arguments: w - the xedwList widget.
  1133. X *  Returns: the info about the currently highlighted object.
  1134. X */
  1135. X
  1136. Xextern XedwListReturnStruct *XedwListShowCurrent(Widget);
  1137. X
  1138. Xextern Boolean XedwListSelection(Widget);
  1139. X
  1140. X#endif /* _XedwList_h */
  1141. X
  1142. SHAR_EOF
  1143. chmod 0644 code/Xedw/XedwList.h || echo "restore of code/Xedw/XedwList.h fails"
  1144. echo "x - extracting code/Xedw/XedwListP.h (Text)"
  1145. sed 's/^X//' << 'SHAR_EOF' > code/Xedw/XedwListP.h &&
  1146. X/*
  1147. X * $XConsortium: XedwListP.h,v 1.12 89/12/11 15:09:04 kit Exp $
  1148. X *
  1149. X * Copyright 1989 Massachusetts Institute of Technology
  1150. X *
  1151. X * Permission to use, copy, modify, distribute, and sell this software and its
  1152. X * documentation for any purpose is hereby granted without fee, provided that
  1153. X * the above copyright notice appear in all copies and that both that
  1154. X * copyright notice and this permission notice appear in supporting
  1155. X * documentation, and that the name of M.I.T. not be used in advertising or
  1156. X * publicity pertaining to distribution of the software without specific,
  1157. X * written prior permission.  M.I.T. makes no representations about the
  1158. X * suitability of this software for any purpose.  It is provided "as is"
  1159. X * without express or implied warranty.
  1160. X *
  1161. X * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  1162. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  1163. X * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1164. X * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  1165. X * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  1166. X * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1167. X *
  1168. X * Author:  Chris D. Peterson, MIT X Consortium
  1169. X */
  1170. X
  1171. X
  1172. X/* 
  1173. X * XedwListP.h - Private definitions for XedwList widget
  1174. X * 
  1175. X * This is the XedwList widget, it is useful to display a xedwList, without the
  1176. X * overhead of having a widget for each item in the xedwList.  It allows 
  1177. X * the user to select an item in a xedwList and notifies the application through
  1178. X * a callback function.
  1179. X *
  1180. X *    Created:     8/13/88
  1181. X *    By:        Chris D. Peterson
  1182. X *                      MIT - Project Athena
  1183. X */
  1184. X
  1185. X#ifndef _XedwListP_h
  1186. X#define _XedwListP_h
  1187. X
  1188. X/***********************************************************************
  1189. X *
  1190. X * XedwList Widget Private Data
  1191. X *
  1192. X ***********************************************************************/
  1193. X
  1194. X#include <X11/Xaw/SimpleP.h>
  1195. X#include "XedwList.h"
  1196. X
  1197. X#define NO_HIGHLIGHT            XDTM_LIST_NONE
  1198. X#define OUT_OF_RANGE            -1
  1199. X#define OKAY                     0
  1200. X#define XedwOff             0
  1201. X#define XedwOn             1
  1202. X
  1203. X/* New fields for the XedwList widget class record */
  1204. X
  1205. Xtypedef struct {int foo;} XedwListClassPart;
  1206. X
  1207. X/* Full class record declaration */
  1208. Xtypedef struct _XedwListClassRec {
  1209. X    CoreClassPart          core_class;
  1210. X    SimpleClassPart        simple_class;
  1211. X    XedwListClassPart    xedwList_class;
  1212. X} XedwListClassRec;
  1213. X
  1214. Xextern XedwListClassRec xedwListClassRec;
  1215. X
  1216. Xtypedef struct _LinkedList {
  1217. X  int index;
  1218. X  struct _LinkedList *next;
  1219. X} LinkedList;
  1220. X
  1221. X/* New fields for the XedwList widget record */
  1222. Xtypedef struct {
  1223. X  /* resources */
  1224. X  Pixel         foreground;
  1225. X  Dimension     internal_width,
  1226. X                internal_height,
  1227. X                column_space,
  1228. X                row_space,
  1229. X                icon_width,
  1230. X                icon_height;
  1231. X  int           default_cols;
  1232. X  Boolean       force_cols,
  1233. X                paste,
  1234. X                vertical_cols,
  1235. X                show_icons,    /* Show icons with list */
  1236. X          multiple;       /* Allow multiple selections */
  1237. X  int           longest;
  1238. X  int           nitems;        /* number of items in the xedwList. */
  1239. X  XFontStruct    *font;
  1240. X  XedwList  **xedwList;
  1241. X  XtCallbackList  callback;
  1242. X
  1243. X  /* private state */
  1244. X
  1245. X  LinkedList  *is_highlighted;    /* set to the items currently highlighted. */
  1246. X  int         highlight,    /* set to the item that should be highlighted.*/
  1247. X              col_width,    /* width of each column. */
  1248. X              row_height,    /* height of each row. */
  1249. X              nrows,        /* number of rows in the xedwList. */
  1250. X              ncols;        /* number of columns in the xedwList. */
  1251. X  GC          normgc,        /* a couple o' GC's. */
  1252. X              revgc,
  1253. X              graygc;        /* used when inactive. */
  1254. X  Pixmap      default_icon;
  1255. X
  1256. X} XedwListPart;
  1257. X
  1258. X
  1259. X/****************************************************************
  1260. X *
  1261. X * Full instance record declaration
  1262. X *
  1263. X ****************************************************************/
  1264. X
  1265. Xtypedef struct _XedwListRec {
  1266. X  CorePart    core;
  1267. X  SimplePart    simple;
  1268. X  XedwListPart    xedwList;
  1269. X} XedwListRec;
  1270. X
  1271. X#endif /* _XedwListP_h */
  1272. X
  1273. X
  1274. X
  1275. SHAR_EOF
  1276. chmod 0644 code/Xedw/XedwListP.h || echo "restore of code/Xedw/XedwListP.h fails"
  1277. echo "x - extracting code/Xedw/XedwTree.c (Text)"
  1278. sed 's/^X//' << 'SHAR_EOF' > code/Xedw/XedwTree.c &&
  1279. X#include <X11/copyright.h>
  1280. X
  1281. X/* $XConsortium: Template.c,v 1.2 88/10/25 17:40:25 swick Exp $ */
  1282. X/* Copyright    Massachusetts Institute of Technology    1987, 1988 */
  1283. X
  1284. X#include <X11/IntrinsicP.h>
  1285. X#include <X11/StringDefs.h>
  1286. X#include "TemplateP.h"
  1287. X
  1288. Xstatic XtResource resources[] = {
  1289. X#define offset(field) XtOffset(TemplateWidget, template.field)
  1290. X    /* {name, class, type, size, offset, default_type, default_addr}, */
  1291. X    { XtNtemplateResource, XtCTemplateResource, XtRTemplateResource, sizeof(char*),
  1292. X      offset(resource), XtRString, "default" },
  1293. X#undef offset
  1294. X};
  1295. X
  1296. Xstatic void TemplateAction(/* Widget, XEvent*, String*, Cardinal* */);
  1297. X
  1298. Xstatic XtActionsRec actions[] =
  1299. X{
  1300. X  /* {name, procedure}, */
  1301. X    {"template",    TemplateAction},
  1302. X};
  1303. X
  1304. Xstatic char translations[] =
  1305. X"<Key>:        template()    \n\
  1306. X";
  1307. X
  1308. XTemplateClassRec templateClassRec = {
  1309. X  { /* core fields */
  1310. X    /* superclass        */    (WidgetClass) &widgetClassRec,
  1311. X    /* class_name        */    "Template",
  1312. X    /* widget_size        */    sizeof(TemplateRec),
  1313. X    /* class_initialize        */    NULL,
  1314. X    /* class_part_initialize    */    NULL,
  1315. X    /* class_inited        */    FALSE,
  1316. X    /* initialize        */    NULL,
  1317. X    /* initialize_hook        */    NULL,
  1318. X    /* realize            */    XtInheritRealize,
  1319. X    /* actions            */    actions,
  1320. X    /* num_actions        */    XtNumber(actions),
  1321. X    /* resources        */    resources,
  1322. X    /* num_resources        */    XtNumber(resources),
  1323. X    /* xrm_class        */    NULLQUARK,
  1324. X    /* compress_motion        */    TRUE,
  1325. X    /* compress_exposure    */    TRUE,
  1326. X    /* compress_enterleave    */    TRUE,
  1327. X    /* visible_interest        */    FALSE,
  1328. X    /* destroy            */    NULL,
  1329. X    /* resize            */    NULL,
  1330. X    /* expose            */    NULL,
  1331. X    /* set_values        */    NULL,
  1332. X    /* set_values_hook        */    NULL,
  1333. X    /* set_values_almost    */    XtInheritSetValuesAlmost,
  1334. X    /* get_values_hook        */    NULL,
  1335. X    /* accept_focus        */    NULL,
  1336. X    /* version            */    XtVersion,
  1337. X    /* callback_private        */    NULL,
  1338. X    /* tm_table            */    translations,
  1339. X    /* query_geometry        */    XtInheritQueryGeometry,
  1340. X    /* display_accelerator    */    XtInheritDisplayAccelerator,
  1341. X    /* extension        */    NULL
  1342. X  },
  1343. X  { /* template fields */
  1344. X    /* empty            */    0
  1345. X  }
  1346. X};
  1347. X
  1348. XWidgetClass templateWidgetClass = (WidgetClass)&templateClassRec;
  1349. SHAR_EOF
  1350. chmod 0644 code/Xedw/XedwTree.c || echo "restore of code/Xedw/XedwTree.c fails"
  1351. echo "x - extracting code/Xedw/XedwTree.h (Text)"
  1352. sed 's/^X//' << 'SHAR_EOF' > code/Xedw/XedwTree.h &&
  1353. X#include <X11/copyright.h>
  1354. X
  1355. X/* $XConsortium: Template.h,v 1.4 89/07/21 01:41:49 kit Exp $ */
  1356. X/* Copyright    Massachusetts Institute of Technology    1987, 1988 */
  1357. X
  1358. X#ifndef _Template_h
  1359. X#define _Template_h
  1360. X
  1361. X/****************************************************************
  1362. X *
  1363. X * Template widget
  1364. X *
  1365. X ****************************************************************/
  1366. X
  1367. X/* Resources:
  1368. X
  1369. X Name             Class        RepType        Default Value
  1370. X ----             -----        -------        -------------
  1371. X background         Background        Pixel        XtDefaultBackground
  1372. X border             BorderColor    Pixel        XtDefaultForeground
  1373. X borderWidth         BorderWidth    Dimension    1
  1374. X destroyCallback     Callback        Pointer        NULL
  1375. X height             Height        Dimension    0
  1376. X mappedWhenManaged   MappedWhenManaged    Boolean        True
  1377. X sensitive         Sensitive        Boolean        True
  1378. X width             Width        Dimension    0
  1379. X x             Position        Position    0
  1380. X y             Position        Position    0
  1381. X
  1382. X*/
  1383. X
  1384. X/* define any special resource names here that are not in <X11/StringDefs.h> */
  1385. X
  1386. X#define XtNtemplateResource "templateResource"
  1387. X
  1388. X#define XtCTemplateResource "TemplateResource"
  1389. X
  1390. X/* declare specific TemplateWidget class and instance datatypes */
  1391. X
  1392. Xtypedef struct _TemplateClassRec*    TemplateWidgetClass;
  1393. Xtypedef struct _TemplateRec*        TemplateWidget;
  1394. X
  1395. X/* declare the class constant */
  1396. X
  1397. Xextern WidgetClass templateWidgetClass;
  1398. X
  1399. X#endif /* _Template_h */
  1400. SHAR_EOF
  1401. chmod 0644 code/Xedw/XedwTree.h || echo "restore of code/Xedw/XedwTree.h fails"
  1402. echo "x - extracting code/Xedw/XedwTreeP.h (Text)"
  1403. sed 's/^X//' << 'SHAR_EOF' > code/Xedw/XedwTreeP.h &&
  1404. X#include <X11/copyright.h>
  1405. X
  1406. X/* $XConsortium: TemplateP.h,v 1.4 89/07/21 01:41:48 kit Exp $ */
  1407. X/* Copyright    Massachusetts Institute of Technology    1987, 1988 */
  1408. X
  1409. X#ifndef _TemplateP_h
  1410. X#define _TemplateP_h
  1411. X
  1412. X#include "Template.h"
  1413. X/* include superclass private header file */
  1414. X#include <X11/CoreP.h>
  1415. X
  1416. X/* define unique representation types not found in <X11/StringDefs.h> */
  1417. X
  1418. X#define XtRTemplateResource "TemplateResource"
  1419. X
  1420. Xtypedef struct {
  1421. X    int empty;
  1422. X} TemplateClassPart;
  1423. X
  1424. Xtypedef struct _TemplateClassRec {
  1425. X    CoreClassPart    core_class;
  1426. X    TemplateClassPart    template_class;
  1427. X} TemplateClassRec;
  1428. X
  1429. Xextern TemplateClassRec templateClassRec;
  1430. X
  1431. Xtypedef struct {
  1432. X    /* resources */
  1433. X    char* resource;
  1434. X    /* private state */
  1435. X} TemplatePart;
  1436. X
  1437. Xtypedef struct _TemplateRec {
  1438. X    CorePart        core;
  1439. X    TemplatePart    template;
  1440. X} TemplateRec;
  1441. X
  1442. X#endif /* _TemplateP_h */
  1443. SHAR_EOF
  1444. chmod 0644 code/Xedw/XedwTreeP.h || echo "restore of code/Xedw/XedwTreeP.h fails"
  1445. rm -f s2_seq_.tmp
  1446. echo "You have unpacked the last part"
  1447. exit 0
  1448.