home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume20 / xarchie / part23 < prev    next >
Encoding:
Text File  |  1993-06-14  |  50.5 KB  |  1,500 lines

  1. Newsgroups: comp.sources.x
  2. From: ferguson@cs.rochester.edu (George Ferguson)
  3. Subject: v20i051:  xarchie - An X browser interface to Archie, v2.0.6, Part23/24
  4. Message-ID: <1993Jun15.223557.2048@sparky.imd.sterling.com>
  5. X-Md4-Signature: 52b76dace6363cd82b3f45f3b536168b
  6. Sender: chris@sparky.imd.sterling.com (Chris Olson)
  7. Organization: Sterling Software
  8. Date: Tue, 15 Jun 1993 22:35:57 GMT
  9. Approved: chris@sparky.imd.sterling.com
  10.  
  11. Submitted-by: ferguson@cs.rochester.edu (George Ferguson)
  12. Posting-number: Volume 20, Issue 51
  13. Archive-name: xarchie/part23
  14. Environment: X11
  15. Supersedes: xarchie: Volume 14, Issue 82-90
  16.  
  17. Submitted-by: ferguson@cs.rochester.edu
  18. Archive-name: xarchie-2.0.6/part23
  19.  
  20. #!/bin/sh
  21. # this is Part.23 (part 23 of xarchie-2.0.6)
  22. # do not concatenate these parts, unpack them in order with /bin/sh
  23. # file xarchie-2.0.6/FWF/MultiList/MultiList.c continued
  24. #
  25. if test ! -r _shar_seq_.tmp; then
  26.     echo 'Please unpack part 1 first!'
  27.     exit 1
  28. fi
  29. (read Scheck
  30.  if test "$Scheck" != 23; then
  31.     echo Please unpack part "$Scheck" next!
  32.     exit 1
  33.  else
  34.     exit 0
  35.  fi
  36. ) < _shar_seq_.tmp || exit 1
  37. if test ! -f _shar_wnt_.tmp; then
  38.     echo 'x - still skipping xarchie-2.0.6/FWF/MultiList/MultiList.c'
  39. else
  40. echo 'x - continuing file xarchie-2.0.6/FWF/MultiList/MultiList.c'
  41. sed 's/^X//' << 'SHAR_EOF' >> 'xarchie-2.0.6/FWF/MultiList/MultiList.c' &&
  42. X
  43. X    values.foreground = MultiListHighlightFG(mlw);
  44. X    values.background = MultiListHighlightBG(mlw);
  45. X    MultiListHighlightForeGC(mlw) = XtGetGC((Widget)mlw,attribs,&values);
  46. X
  47. X    values.foreground = MultiListHighlightBG(mlw);
  48. X    values.background = MultiListHighlightBG(mlw);
  49. X    MultiListHighlightBackGC(mlw) = XtGetGC((Widget)mlw,attribs,&values);
  50. X
  51. X    attribs |= GCTile | GCFillStyle;
  52. X    values.foreground = MultiListFG(mlw);
  53. X    values.background = MultiListBG(mlw);
  54. X    values.fill_style = FillTiled;
  55. X    values.tile = XmuCreateStippledPixmap(XtScreen(mlw),MultiListFG(mlw),
  56. X                          MultiListBG(mlw),MultiListDepth(mlw));
  57. X    MultiListGrayGC(mlw) = XtGetGC((Widget)mlw,attribs,&values);
  58. } /* End CreateNewGCs */
  59. X
  60. /*===========================================================================*
  61. X
  62. X        L A Y O U T    A N D    G E O M E T R Y    M A N A G E M E N T
  63. X
  64. X *===========================================================================*/
  65. X
  66. /*---------------------------------------------------------------------------*
  67. X
  68. X        RecalcCoords(mlw,width_changeable,height_changeable)
  69. X
  70. X    This routine takes a MultiList widget <mlw> and recalculates
  71. X    the coordinates, and item placement based on the current
  72. X    width, height, and list of items.  The <width_changeable> and
  73. X    <height_changeable> indicate if the width and/or height can
  74. X    be arbitrarily set.
  75. X
  76. X    This routine requires that the internal list data be initialized.
  77. X
  78. X *---------------------------------------------------------------------------*/
  79. X
  80. #if NeedFunctionPrototypes
  81. static void
  82. RecalcCoords(XfwfMultiListWidget mlw,
  83. X         Boolean width_changeable, Boolean height_changeable)
  84. #else
  85. static void
  86. RecalcCoords(mlw,width_changeable,height_changeable)
  87. XXfwfMultiListWidget mlw;
  88. Boolean width_changeable,height_changeable;
  89. #endif
  90. {
  91. X    String str;
  92. X    Dimension width,height;
  93. X    register int i,text_width;
  94. X
  95. X    width = MultiListWidth(mlw);
  96. X    height = MultiListHeight(mlw);
  97. X    if (MultiListNumItems(mlw) != 0 && MultiListLongest(mlw) == 0)
  98. X    {
  99. X        for (i = 0; i < MultiListNumItems(mlw); i++)
  100. X        {
  101. X            str = MultiListItemString(MultiListNthItem(mlw,i));
  102. X            text_width = FontW(MultiListFont(mlw),str);
  103. X            MultiListLongest(mlw) = max(MultiListLongest(mlw),
  104. X                            text_width);
  105. X        }
  106. X    }
  107. X    if (Layout(mlw,width_changeable,height_changeable,&width,&height))
  108. X    {
  109. X        NegotiateSizeChange(mlw,width,height);
  110. X    }
  111. } /* End RecalcCoords */
  112. X
  113. X
  114. /*---------------------------------------------------------------------------*
  115. X
  116. X        NegotiateSizeChange(mlw,width,height)
  117. X
  118. X    This routine tries to change the MultiList widget <mlw> to have the
  119. X    new size <width> by <height>.  A negotiation will takes place
  120. X    to try to change the size.  The resulting size is not necessarily
  121. X    the requested size.
  122. X
  123. X *---------------------------------------------------------------------------*/
  124. X
  125. #if NeedFunctionPrototypes
  126. static void
  127. NegotiateSizeChange(XfwfMultiListWidget mlw, Dimension width, Dimension height)
  128. #else
  129. static void
  130. NegotiateSizeChange(mlw,width,height)
  131. XXfwfMultiListWidget mlw;
  132. Dimension width,height;
  133. #endif
  134. {
  135. X    int attempt_number;
  136. X    Boolean w_fixed,h_fixed;
  137. X    Dimension *w_ptr,*h_ptr;
  138. X    
  139. X    XtWidgetGeometry request,reply;
  140. X
  141. X    request.request_mode = CWWidth | CWHeight;
  142. X    request.width = width;
  143. X    request.height = height;
  144. X    
  145. X    for (attempt_number = 1; attempt_number <= 3; attempt_number++)
  146. X    {
  147. X        switch (XtMakeGeometryRequest((Widget)mlw,&request,&reply))
  148. X        {
  149. X            case XtGeometryYes:
  150. X            case XtGeometryNo:
  151. X            return;
  152. X            case XtGeometryAlmost:
  153. X            switch (attempt_number)
  154. X            {
  155. X                case 1:
  156. X                w_fixed = (request.width != reply.width);
  157. X                h_fixed = (request.height != reply.height);
  158. X                w_ptr = &(reply.width);
  159. X                h_ptr = &(reply.height);
  160. X                Layout(mlw,!w_fixed,!h_fixed,w_ptr,h_ptr);
  161. X                break;
  162. X                case 2:
  163. X                w_ptr = &(reply.width);
  164. X                h_ptr = &(reply.height);
  165. X                Layout(mlw,False,False,w_ptr,h_ptr);
  166. X                break;
  167. X                case 3:
  168. X                return;
  169. X            }
  170. X            break;
  171. X            default:
  172. X            XtAppWarning(XtWidgetToApplicationContext((Widget)mlw),
  173. X                "MultiList Widget: Unknown geometry return.");
  174. X            break;
  175. X        }
  176. X        request = reply;
  177. X    }
  178. } /* End NegotiateSizeChange */
  179. X
  180. X
  181. /*---------------------------------------------------------------------------*
  182. X
  183. X    Boolean Layout(mlw,w_changeable,h_changeable,w_ptr,h_ptr)
  184. X
  185. X    This routine tries to generate a layout for the MultiList widget
  186. X    <mlw>.  The Layout routine is free to arbitrarily set the width
  187. X    or height if the corresponding variables <w_changeable> and
  188. X    <h_changeable> are set True.  Otherwise the original width or
  189. X    height in <w_ptr> and <h_ptr> are used as fixed values.  The
  190. X    resulting new width and height are stored back through the
  191. X    <w_ptr> and <h_ptr> pointers.  False is returned if no size
  192. X    change was done, True is returned otherwise.
  193. X
  194. X *---------------------------------------------------------------------------*/
  195. X
  196. #if NeedFunctionPrototypes
  197. static Boolean
  198. Layout(XfwfMultiListWidget mlw, Boolean w_changeable, Boolean h_changeable,
  199. X       Dimension *w_ptr, Dimension *h_ptr)
  200. #else
  201. static Boolean
  202. Layout(mlw,w_changeable,h_changeable,w_ptr,h_ptr)
  203. XXfwfMultiListWidget mlw;
  204. Boolean w_changeable,h_changeable;
  205. Dimension *w_ptr,*h_ptr;
  206. #endif
  207. {
  208. X    Boolean size_changed = False;
  209. X
  210. X    /*
  211. X     * If force columns is set, then always use the number
  212. X     * of columns specified by default_cols.
  213. X     */
  214. X
  215. X    MultiListColWidth(mlw) = MultiListLongest(mlw) +
  216. X        MultiListColumnSpace(mlw);
  217. X    MultiListRowHeight(mlw) = FontH(MultiListFont(mlw)) +
  218. X        MultiListRowSpace(mlw);
  219. X    if (MultiListForceCols(mlw))
  220. X    {
  221. X        MultiListNumCols(mlw) = max(MultiListDefaultCols(mlw),1);
  222. X        if (MultiListNumItems(mlw) == 0)
  223. X            MultiListNumRows(mlw) = 1;
  224. X            else
  225. X            MultiListNumRows(mlw) = (MultiListNumItems(mlw) - 1) /
  226. X                MultiListNumCols(mlw) + 1;
  227. X        if (w_changeable)
  228. X        {
  229. X            *w_ptr = MultiListNumCols(mlw) *
  230. X                MultiListColWidth(mlw);
  231. X            size_changed = True;
  232. X        }
  233. X            else
  234. X        {
  235. X            MultiListColWidth(mlw) = *w_ptr /
  236. X                (Dimension)MultiListNumCols(mlw);
  237. X        }
  238. X        if (h_changeable)
  239. X        {
  240. X            *h_ptr = MultiListNumRows(mlw) *
  241. X                MultiListRowHeight(mlw);
  242. X            size_changed = True;
  243. X        }
  244. X        return(size_changed);
  245. X    }
  246. X
  247. X    /*
  248. X     * If both width and height are free to change then use
  249. X     * default_cols to determine the number of columns and set
  250. X     * the new width and height to just fit the window.
  251. X     */
  252. X
  253. X    if (w_changeable && h_changeable)
  254. X    {
  255. X        MultiListNumCols(mlw) = max(MultiListDefaultCols(mlw),1);
  256. X        if (MultiListNumItems(mlw) == 0)
  257. X            MultiListNumRows(mlw) = 1;
  258. X            else
  259. X            MultiListNumRows(mlw) = (MultiListNumItems(mlw) - 1) /
  260. X                MultiListNumCols(mlw) + 1;
  261. X        *w_ptr = MultiListNumCols(mlw) * MultiListColWidth(mlw);
  262. X        *h_ptr = MultiListNumRows(mlw) * MultiListRowHeight(mlw);
  263. X        return(True);
  264. X    }
  265. X
  266. X    /*
  267. X     * If the width is fixed then use it to determine the
  268. X     * number of columns.  If the height is free to move
  269. X     * (width still fixed) then resize the height of the
  270. X     * widget to fit the current MultiList exactly.
  271. X     */
  272. X
  273. X    if (!w_changeable)
  274. X    {
  275. X        MultiListNumCols(mlw) = *w_ptr / MultiListColWidth(mlw);
  276. X        MultiListNumCols(mlw) = max(MultiListNumCols(mlw),1);
  277. X        MultiListNumRows(mlw) = (MultiListNumItems(mlw) - 1) /
  278. X            MultiListNumCols(mlw) + 1;
  279. X        MultiListColWidth(mlw) = *w_ptr / (Dimension)MultiListNumCols(mlw);
  280. X        if (h_changeable)
  281. X        {
  282. X            *h_ptr = MultiListNumRows(mlw) * MultiListRowHeight(mlw);
  283. X            size_changed = True;
  284. X        }
  285. X        return(size_changed);
  286. X    }
  287. X
  288. X    /*
  289. X     * The last case is xfree and !yfree we use the height to
  290. X     * determine the number of rows and then set the width to
  291. X     * just fit the resulting number of columns.
  292. X     */
  293. X
  294. X    MultiListNumRows(mlw) = *h_ptr / MultiListRowHeight(mlw);
  295. X    MultiListNumRows(mlw) = max(MultiListNumRows(mlw),1);
  296. X    MultiListNumCols(mlw) = (MultiListNumItems(mlw) - 1) /
  297. X        MultiListNumRows(mlw) + 1;
  298. X    *w_ptr = MultiListNumCols(mlw) * MultiListColWidth(mlw);
  299. X    return(True);
  300. } /* End Layout */
  301. X
  302. /*===========================================================================*
  303. X
  304. X                    R E D R A W    R O U T I N E S
  305. X
  306. X *===========================================================================*/
  307. X
  308. /*---------------------------------------------------------------------------*
  309. X
  310. X    RedrawAll(mlw)
  311. X
  312. X    This routine simple calls Redisplay to redraw the entire
  313. X    MultiList widget <mlw>.
  314. X
  315. X *---------------------------------------------------------------------------*/
  316. X
  317. static void RedrawAll(mlw)
  318. XXfwfMultiListWidget mlw;
  319. {
  320. X    Redisplay(mlw,NULL,NULL);
  321. } /* End RedrawAll */
  322. X
  323. X
  324. /*---------------------------------------------------------------------------*
  325. X
  326. X    RedrawItem(mlw,item_index)
  327. X
  328. X    This routine redraws the item with index <item_index> in the
  329. X    MultiList widget <mlw>.  If the item number is bad, nothing is drawn.
  330. X
  331. X *---------------------------------------------------------------------------*/
  332. X
  333. static void RedrawItem(mlw,item_index)
  334. XXfwfMultiListWidget mlw;
  335. int item_index;
  336. {
  337. X    int row,column;
  338. X
  339. X    if (ItemToRowColumn(mlw,item_index,&row,&column))
  340. X    {
  341. X        RedrawRowColumn(mlw,row,column);
  342. X    }
  343. } /* End RedrawItem */
  344. X
  345. X
  346. /*---------------------------------------------------------------------------*
  347. X
  348. X    RedrawRowColumn(mlw,row,column)
  349. X
  350. X    This routine paints the item in row/column position <row>,<column>
  351. X    on the MultiList widget <mlw>.  If the row/column coordinates are
  352. X    outside the widget, nothing is drawn.  If the position is empty,
  353. X    blank space is drawn.
  354. X
  355. X *---------------------------------------------------------------------------*/
  356. X
  357. static void RedrawRowColumn(mlw,row,column)
  358. XXfwfMultiListWidget mlw;
  359. int row,column;
  360. {
  361. X    GC bg_gc,fg_gc;
  362. X    XfwfMultiListItem *item;
  363. X    int ul_x,ul_y,str_x,str_y,w,h,item_index,has_item,text_h;
  364. X
  365. X    if (!XtIsRealized((Widget)mlw)) return;
  366. X    has_item = RowColumnToItem(mlw,row,column,&item_index);
  367. X    RowColumnToPixels(mlw,row,column,&ul_x,&ul_y,&w,&h);
  368. X
  369. X    if (has_item == False)                    /* No Item */
  370. X    {
  371. X        if (MultiListShadeSurplus(mlw))
  372. X            bg_gc = MultiListGrayGC(mlw);
  373. X            else
  374. X            bg_gc = MultiListEraseGC(mlw);
  375. X    }
  376. X        else
  377. X    {
  378. X        item = MultiListNthItem(mlw,item_index);
  379. X        if ((!MultiListSensitive(mlw)) ||
  380. X            (!MultiListItemSensitive(item)))    /* Insensitive */
  381. X        {
  382. X                if (MultiListItemHighlighted(item))    /* Selected */
  383. X            {
  384. X                bg_gc = MultiListGrayGC(mlw);
  385. X                fg_gc = MultiListEraseGC(mlw);
  386. X            }
  387. X                else                /* !Selected */
  388. X            {
  389. X                bg_gc = MultiListEraseGC(mlw);
  390. X                fg_gc = MultiListGrayGC(mlw);
  391. X            }
  392. X        }
  393. X            else                /* Sensitive */
  394. X        {
  395. X                if (MultiListItemHighlighted(item))    /* Selected */
  396. X            {
  397. X                bg_gc = MultiListHighlightBackGC(mlw);
  398. X                fg_gc = MultiListHighlightForeGC(mlw);
  399. X            }
  400. X                else                /* !Selected */
  401. X            {
  402. X                bg_gc = MultiListEraseGC(mlw);
  403. X                fg_gc = MultiListDrawGC(mlw);
  404. X            }
  405. X        }
  406. X    }
  407. X    XFillRectangle(XtDisplay(mlw),XtWindow(mlw),bg_gc,ul_x,ul_y,w,h);
  408. X    if (has_item == True)
  409. X    {
  410. X        text_h = min(FontH(MultiListFont(mlw)) +
  411. X                 (int)MultiListRowSpace(mlw),(int)MultiListRowHeight(mlw));
  412. X        str_x = ul_x + MultiListColumnSpace(mlw) / 2;
  413. X        str_y = ul_y + FontAscent(MultiListFont(mlw)) +
  414. X            ((int)MultiListRowHeight(mlw) - text_h) / 2;
  415. X        XDrawString(XtDisplay(mlw),XtWindow(mlw),fg_gc,
  416. X                str_x,str_y,MultiListItemString(item),
  417. X                strlen(MultiListItemString(item)));
  418. X    }
  419. } /* End RedrawRowColumn */
  420. X    
  421. /*===========================================================================*
  422. X
  423. X               I T E M    L O C A T I O N    R O U T I N E S
  424. X
  425. X *===========================================================================*/
  426. X
  427. /*---------------------------------------------------------------------------*
  428. X
  429. X    void PixelToRowColumn(mlw,x,y,row_ptr,column_ptr)
  430. X
  431. X    This routine takes pixel coordinates <x>, <y> and converts
  432. X    the pixel coordinate into a row/column coordinate.  This row/column
  433. X    coordinate can then easily be converted into the specific item
  434. X    in the list via the function RowColumnToItem().
  435. X
  436. X    If the pixel lies in blank space outside of the items, the
  437. X    row & column numbers will be outside of the range of normal
  438. X    row & columns numbers, but will correspond to the row & column
  439. X    of the item, if an item was actually there.
  440. X
  441. X *---------------------------------------------------------------------------*/
  442. X
  443. static void PixelToRowColumn(mlw,x,y,row_ptr,column_ptr)
  444. XXfwfMultiListWidget mlw;
  445. int x,y,*row_ptr,*column_ptr;
  446. {
  447. X    *row_ptr = y / (int)MultiListRowHeight(mlw);
  448. X    *column_ptr = x / (int)MultiListColWidth(mlw);
  449. } /* End PixelToRowColumn */
  450. X
  451. /*---------------------------------------------------------------------------*
  452. X
  453. X    void RowColumnToPixels(mlw,row,col,x_ptr,y_ptr,w_ptr,h_ptr)
  454. X
  455. X    This routine takes a row/column coordinate <row>,<col> and
  456. X    converts it into the bounding pixel rectangle which is returned.
  457. X
  458. X *---------------------------------------------------------------------------*/
  459. X
  460. static void RowColumnToPixels(mlw,row,col,x_ptr,y_ptr,w_ptr,h_ptr)
  461. XXfwfMultiListWidget mlw;
  462. int row,col,*x_ptr,*y_ptr,*w_ptr,*h_ptr;
  463. {
  464. X    *x_ptr = col * MultiListColWidth(mlw);
  465. X    *y_ptr = row * MultiListRowHeight(mlw);
  466. X    *w_ptr = MultiListColWidth(mlw);
  467. X    *h_ptr = MultiListRowHeight(mlw);
  468. } /* End RowColumnToPixels */
  469. X
  470. /*---------------------------------------------------------------------------*
  471. X
  472. X    Boolean RowColumnToItem(mlw,row,column,item_ptr)
  473. X
  474. X    This routine takes a row number <row> and a column number <column>
  475. X    and tries to resolve this row and column into the index of the
  476. X    item in this position of the MultiList widget <mlw>.  The resulting
  477. X    item index is placed through <item_ptr>.  If there is no item at
  478. X    this location, False is returned, else True is returned.
  479. X
  480. X *---------------------------------------------------------------------------*/
  481. X
  482. static Boolean RowColumnToItem(mlw,row,column,item_ptr)
  483. XXfwfMultiListWidget mlw;
  484. int row,column,*item_ptr;
  485. {
  486. X    register int x_stride,y_stride;
  487. X
  488. X    if (row < 0 || row >= MultiListNumRows(mlw) ||
  489. X        column < 0 || column >= MultiListNumCols(mlw))
  490. X    {
  491. X        return(False);
  492. X    }
  493. X    if (MultiListRowMajor(mlw))
  494. X    {
  495. X        x_stride = 1;
  496. X        y_stride = MultiListNumCols(mlw);
  497. X    }
  498. X        else
  499. X    {
  500. X        x_stride = MultiListNumRows(mlw);
  501. X        y_stride = 1;
  502. X    }
  503. X    *item_ptr = row * y_stride + column * x_stride;
  504. X    if (*item_ptr >= MultiListNumItems(mlw))
  505. X        return(False);
  506. X        else
  507. X        return(True);
  508. } /* End RowColumnToItem */
  509. X
  510. X
  511. /*---------------------------------------------------------------------------*
  512. X
  513. X    Boolean ItemToRowColumn(mlw,item_index,row_ptr,column_ptr)
  514. X
  515. X    This routine takes an item number <item_index> and attempts
  516. X    to convert the index into row and column numbers stored through
  517. X    <row_ptr> and <column_ptr>.  If the item number does not
  518. X    corespond to a valid item, False is returned, else True is
  519. X    returned.
  520. X
  521. X *---------------------------------------------------------------------------*/
  522. X
  523. static Boolean ItemToRowColumn(mlw,item_index,row_ptr,column_ptr)
  524. XXfwfMultiListWidget mlw;
  525. int item_index,*row_ptr,*column_ptr;
  526. {
  527. X    if (item_index < 0 || item_index >= MultiListNumItems(mlw))
  528. X    {
  529. X        return(False);
  530. X    }
  531. X    if (MultiListRowMajor(mlw))
  532. X    {
  533. X        *row_ptr = item_index / MultiListNumCols(mlw);
  534. X        *column_ptr = item_index % MultiListNumCols(mlw);
  535. X    }
  536. X        else
  537. X    {
  538. X        *row_ptr = item_index % MultiListNumRows(mlw);
  539. X        *column_ptr = item_index / MultiListNumRows(mlw);
  540. X    }
  541. X    return(True);
  542. } /* End ItemToRowColumn */
  543. X
  544. /*===========================================================================*
  545. X
  546. X                E V E N T    A C T I O N    H A N D L E R S
  547. X
  548. X *===========================================================================*/
  549. X
  550. /*---------------------------------------------------------------------------*
  551. X
  552. X    Select(mlw,event,params,num_params)
  553. X
  554. X    This action handler is called when a user selects an item in the
  555. X    MultiList.  This action first unselects all previously selected
  556. X    items, then selects the item under the mouse, if it is not a
  557. X    background gap, and if it is sensitive.
  558. X
  559. X    The MultiListMostRecentItem(mlw) variable will be set to the
  560. X    item clicked on, or -1 if the item is background or insensitive.
  561. X    The MultiListMostRecentAct(mlw) variable will be set to
  562. X    XfwfMultiListActionHighlight, in case the selection region is extended.
  563. X
  564. X *---------------------------------------------------------------------------*/
  565. X
  566. /* ARGSUSED */
  567. static void Select(mlw,event,params,num_params)
  568. XXfwfMultiListWidget mlw;
  569. XXEvent *event;
  570. String *params;
  571. Cardinal *num_params;
  572. {
  573. X    int click_x,click_y;
  574. X    int status,item_index,row,column;
  575. X
  576. X    click_x = event->xbutton.x;
  577. X    click_y = event->xbutton.y;
  578. X    PixelToRowColumn(mlw,click_x,click_y,&row,&column);
  579. X    XfwfMultiListUnhighlightAll(mlw);
  580. X    MultiListMostRecentAct(mlw) = XfwfMultiListActionHighlight;
  581. X    status = RowColumnToItem(mlw,row,column,&item_index);
  582. X    if ((status == False) ||
  583. X        (!MultiListItemSensitive(MultiListNthItem(mlw,item_index))))
  584. X    {
  585. X        MultiListMostRecentItem(mlw) = -1;
  586. X    }
  587. X        else
  588. X    {
  589. X        MultiListMostRecentItem(mlw) = item_index;
  590. X        XfwfMultiListHighlightItem(mlw,item_index);
  591. X    }
  592. } /* End Select */
  593. X
  594. X
  595. /*---------------------------------------------------------------------------*
  596. X
  597. X    Unselect(mlw,event,params,num_params)
  598. X
  599. X    This function unselects the single text item pointed to by the
  600. X    mouse, if any.  Any remaining selected entries are left selected.
  601. X
  602. X    The MultiListMostRecentItem(mlw) variable will be set to -1, and
  603. X    the MultiListMostRecentAct(mlw) variable will be set to
  604. X    XfwfMultiListActionUnhighlight, in case the deselection region is
  605. X    extended.
  606. X    
  607. X *---------------------------------------------------------------------------*/
  608. X
  609. /* ARGSUSED */
  610. static void Unselect(mlw,event,params,num_params)
  611. XXfwfMultiListWidget mlw;
  612. XXEvent *event;
  613. String *params;
  614. Cardinal *num_params;
  615. {
  616. X    int click_x,click_y;
  617. X    int status,item_index,row,column;
  618. X
  619. X    click_x = event->xbutton.x;
  620. X    click_y = event->xbutton.y;
  621. X    PixelToRowColumn(mlw,click_x,click_y,&row,&column);
  622. X    MultiListMostRecentItem(mlw) = -1;
  623. X    MultiListMostRecentAct(mlw) = XfwfMultiListActionUnhighlight;
  624. X    status = RowColumnToItem(mlw,row,column,&item_index);
  625. X    if ((status == True) &&
  626. X        (MultiListItemSensitive(MultiListNthItem(mlw,item_index))))
  627. X        XfwfMultiListHighlightItem(mlw,item_index);
  628. } /* End Unselect */
  629. X
  630. X
  631. /*---------------------------------------------------------------------------*
  632. X
  633. X    Toggle(mlw,event,params,num_params)
  634. X
  635. X    This action handler implements the toggling of selection status
  636. X    for a single item.  Any remaining selected entries are left selected.
  637. X
  638. X    If the mouse is not over a selectable text item, the
  639. X    MultiListMostRecentAct(mlw) variable is set to
  640. X    XfwfMultiListActionHighlight, in case the region is extended into
  641. X    selectable items later.  MultiListMostRecentItem(mlw) is set to -1.
  642. X
  643. X    If the mouse is over a selectable text item, the item highlight is
  644. X    toggled.  If the item is currently selected, it becomes deselected.
  645. X    If unselected, the item becomes selected.  At the same time, the
  646. X    MultiListMostRecentAct(mlw) variable is set to
  647. X    XfwfMultiListActionHighlight if the item was not previously selected,
  648. X    or XfwfMultiListActionUnhighlight if the item was previously selected.
  649. X    MultiListMostRecentItem(mlw) is set to the index of the item clicked
  650. X    on if the item is selected, or -1 if it is unselected.
  651. X
  652. X *---------------------------------------------------------------------------*/
  653. X
  654. /* ARGSUSED */
  655. static void Toggle(mlw,event,params,num_params)
  656. XXfwfMultiListWidget mlw;
  657. XXEvent *event;
  658. String *params;
  659. Cardinal *num_params;
  660. {
  661. X    int click_x,click_y;
  662. X    int status,item_index,row,column;
  663. X
  664. X    click_x = event->xbutton.x;
  665. X    click_y = event->xbutton.y;
  666. X    PixelToRowColumn(mlw,click_x,click_y,&row,&column);
  667. X    status = RowColumnToItem(mlw,row,column,&item_index);
  668. X    if ((status == False) ||
  669. X        (!MultiListItemSensitive(MultiListNthItem(mlw,item_index))))
  670. X    {
  671. X        MultiListMostRecentAct(mlw) = XfwfMultiListActionHighlight;
  672. X        MultiListMostRecentItem(mlw) = -1;
  673. X    }
  674. X        else
  675. X    {
  676. X        MultiListMostRecentAct(mlw) =
  677. X            XfwfMultiListToggleItem(mlw,item_index);
  678. X        MultiListMostRecentItem(mlw) = item_index;
  679. X    }
  680. } /* End Toggle */
  681. X
  682. X
  683. /*---------------------------------------------------------------------------*
  684. X
  685. X    Extend(mlw,event,params,num_params)
  686. X
  687. X    This action handler implements the extension of a selection/
  688. X    deselection region.
  689. X
  690. X    The MultiListMostRecentAct(mlw) variable is used to determine
  691. X    if items are to be selected or unselected.  This routine performs
  692. X    select or unselect actions on each item it is called on.
  693. X
  694. X *---------------------------------------------------------------------------*/
  695. X
  696. /* ARGSUSED */
  697. static void Extend(mlw,event,params,num_params)
  698. XXfwfMultiListWidget mlw;
  699. XXEvent *event;
  700. String *params;
  701. Cardinal *num_params;
  702. {
  703. X    int click_x,click_y;
  704. X    int status,item_index,row,column;
  705. X
  706. X    click_x = ((XMotionEvent*)event)->x;
  707. X    click_y = ((XMotionEvent*)event)->y;
  708. X    PixelToRowColumn(mlw,click_x,click_y,&row,&column);
  709. X    status = RowColumnToItem(mlw,row,column,&item_index);
  710. X    if ((status == True) &&
  711. X        (MultiListItemSensitive(MultiListNthItem(mlw,item_index))))
  712. X    {
  713. X        MultiListMostRecentItem(mlw) = item_index;
  714. X        if (MultiListMostRecentAct(mlw) == XfwfMultiListActionHighlight)
  715. X            XfwfMultiListHighlightItem(mlw,item_index);
  716. X            else
  717. X            XfwfMultiListUnhighlightItem(mlw,item_index);
  718. X    }
  719. } /* End Extend */
  720. X
  721. X
  722. /*---------------------------------------------------------------------------*
  723. X
  724. X    Notify(mlw,event,params,num_params)
  725. X
  726. X    This function performs the Notify action, which issues a callback
  727. X    after a selection/unselection has completed.  All callbacks on the
  728. X    callback list are invoked, and a XfxfMultiListReturnStruct describing
  729. X    the selection state is returned.
  730. X
  731. X    In addition, if the XtNpasteBuffer resource is true and at least one
  732. X    text item is selected, all the selected items are placed in the X
  733. X    cut buffer (buf(0)) separated by newlines.
  734. X
  735. X *---------------------------------------------------------------------------*/
  736. X
  737. /* ARGSUSED */
  738. static void Notify(mlw,event,params,num_params)
  739. XXfwfMultiListWidget mlw;
  740. XXEvent *event;
  741. String *params;
  742. Cardinal *num_params;
  743. {
  744. X    char *buffer;
  745. X    String string;
  746. X    int i,byte_count,item_index;
  747. X    XfwfMultiListReturnStruct ret_value;
  748. X
  749. X    if ((MultiListNumSelected(mlw) != 0) && MultiListPaste(mlw))
  750. X    {
  751. X        byte_count = 0;
  752. X        for (i = 0; i < MultiListNumSelected(mlw); i++)
  753. X        {
  754. X            item_index = MultiListSelArray(mlw)[i];
  755. X            string = MultiListItemString(MultiListNthItem(mlw,
  756. X                item_index));
  757. X            byte_count = byte_count + strlen(string) + 1;
  758. X        }
  759. X        buffer = (char *)malloc(byte_count);
  760. X        buffer[0] = '\0';
  761. X        for (i = 0; i < MultiListNumSelected(mlw); i++)
  762. X        {
  763. X            if (i != 0) strcat(buffer,"\n");
  764. X            item_index = MultiListSelArray(mlw)[i];
  765. X            string = MultiListItemString(MultiListNthItem(mlw,
  766. X                item_index));
  767. X            strcat(buffer,string);
  768. X        }
  769. X        XStoreBytes(XtDisplay(mlw),buffer,byte_count);
  770. X        free(buffer);
  771. X    }
  772. X
  773. X    ret_value.action = MultiListMostRecentAct(mlw);
  774. X    ret_value.item = MultiListMostRecentItem(mlw);
  775. X    if (ret_value.item == -1)
  776. X        ret_value.string = NULL;
  777. X        else
  778. X        ret_value.string = MultiListItemString(MultiListNthItem(mlw,
  779. X            ret_value.item));
  780. X    ret_value.num_selected = MultiListNumSelected(mlw);
  781. X    ret_value.selected_items = MultiListSelArray(mlw);
  782. X    XtCallCallbacks((Widget)mlw,XtNcallback,(caddr_t)&ret_value);
  783. } /* End Notify */
  784. X
  785. /*===========================================================================*
  786. X
  787. X        U S E R    C A L L A B L E    U T I L I T Y    R O U T I N E S
  788. X
  789. X *===========================================================================*/
  790. X
  791. /*---------------------------------------------------------------------------*
  792. X
  793. X    Boolean XfwfMultiListHighlightItem(mlw,item_index)
  794. X
  795. X    This routine selects an item with index <item_index> in the
  796. X    MultiList widget <mlw>.  If a maximum number of selections is specified
  797. X    and exceeded, the earliest selection will be unselected.  If
  798. X    <item_index> doesn't correspond to an item the most recently
  799. X    clicked item will be set to -1 and this routine will immediately
  800. X    return, otherwise the most recently clicked item will be set to the
  801. X    current item.  If the clicked on item is not sensitive, or if the
  802. X    click is not on an item, False is returned, else True is returned.
  803. X
  804. X *---------------------------------------------------------------------------*/
  805. X
  806. Boolean XfwfMultiListHighlightItem(mlw,item_index)
  807. XXfwfMultiListWidget mlw;
  808. int item_index;
  809. {
  810. X    XfwfMultiListItem *item;
  811. X
  812. X    if (MultiListMaxSelectable(mlw) == 0) return(False);
  813. X    if (item_index < 0 || item_index >= MultiListNumItems(mlw))
  814. X    {
  815. X        MultiListMostRecentItem(mlw) = -1;
  816. X        return(False);
  817. X    }
  818. X    item = MultiListNthItem(mlw,item_index);
  819. X    if (MultiListItemSensitive(item) == False) return(False);
  820. X    MultiListMostRecentItem(mlw) = item_index;
  821. X    if (MultiListItemHighlighted(item) == True) return(True);
  822. X    if (MultiListNumSelected(mlw) == MultiListMaxSelectable(mlw))
  823. X    {
  824. X        XfwfMultiListUnhighlightItem(mlw,MultiListSelArray(mlw)[0]);
  825. X    }
  826. X    MultiListItemHighlighted(item) = True;
  827. X    MultiListSelArray(mlw)[MultiListNumSelected(mlw)] = item_index;
  828. X    ++ MultiListNumSelected(mlw);
  829. X    RedrawItem(mlw,item_index);
  830. X    return(True);
  831. } /* End XfwfMultiListHighlightItem */
  832. X
  833. X
  834. /*---------------------------------------------------------------------------*
  835. X
  836. X    XfwfMultiListHighlightAll(mlw)
  837. X
  838. X    This routine highlights all highlightable items in the MultiList
  839. X    widget <mlw>, up to the maximum number of allowed highlightable
  840. X    items;
  841. X
  842. X *---------------------------------------------------------------------------*/
  843. X
  844. void XfwfMultiListHighlightAll(mlw)
  845. XXfwfMultiListWidget mlw;
  846. {
  847. X    int i;
  848. X    XfwfMultiListItem *item;
  849. X
  850. X    MultiListNumSelected(mlw) = 0;
  851. X    for (i = 0; i < MultiListNumItems(mlw); i++)
  852. X    {
  853. X        item = MultiListNthItem(mlw,i);
  854. X        MultiListItemHighlighted(item) = False;
  855. X    }
  856. X    for (i = 0; i < MultiListNumItems(mlw); i++)
  857. X    {
  858. X        if (MultiListNumSelected(mlw) == MultiListMaxSelectable(mlw))
  859. X            break;
  860. X        item = MultiListNthItem(mlw,i);
  861. X        if (MultiListItemSensitive(item) == False) continue;
  862. X        MultiListItemHighlighted(item) = True;
  863. X        MultiListSelArray(mlw)[MultiListNumSelected(mlw)] = i;
  864. X        ++ MultiListNumSelected(mlw);
  865. X    }
  866. X    RedrawAll(mlw);
  867. } /* End XfwfMultiListHighlightAll */
  868. X
  869. X
  870. /*---------------------------------------------------------------------------*
  871. X
  872. X    XfwfMultiListUnhighlightItem(mlw,item_index)
  873. X
  874. X    This routine unselects the item with index <item_index> in the
  875. X    MultiList widget <mlw>.  If <item_index> doesn't correspond to a
  876. X    selected item, then nothing will happen.  Otherwise, the item
  877. X    is unselected and the selection array and count are updated.
  878. X
  879. X *---------------------------------------------------------------------------*/
  880. X
  881. void XfwfMultiListUnhighlightItem(mlw,item_index)
  882. XXfwfMultiListWidget mlw;
  883. int item_index;
  884. {
  885. X    int i;
  886. X    XfwfMultiListItem *item;
  887. X
  888. X    if (MultiListMaxSelectable(mlw) == 0) return;
  889. X    if (item_index < 0 || item_index >= MultiListNumItems(mlw)) return;
  890. X    item = MultiListNthItem(mlw,item_index);
  891. X    if (MultiListItemHighlighted(item) == False) return;
  892. X    MultiListItemHighlighted(item) = False;
  893. X
  894. X    for (i = 0; i < MultiListNumSelected(mlw); i++)
  895. X        if (MultiListSelArray(mlw)[i] == item_index) break;
  896. X    for (i = i + 1; i < MultiListNumSelected(mlw); i++)
  897. X        MultiListSelArray(mlw)[i - 1] = MultiListSelArray(mlw)[i];
  898. X    -- MultiListNumSelected(mlw);
  899. X
  900. X    RedrawItem(mlw,item_index);
  901. } /* End XfwfMultiListUnhighlightItem */
  902. X
  903. X
  904. /*---------------------------------------------------------------------------*
  905. X
  906. X    XfwfMultiListUnhighlightAll(mlw)
  907. X
  908. X    This routine unhighlights all items in the MultiList widget <mlw>.
  909. X
  910. X *---------------------------------------------------------------------------*/
  911. X
  912. void XfwfMultiListUnhighlightAll(mlw)
  913. XXfwfMultiListWidget mlw;
  914. {
  915. X    int i;
  916. X    XfwfMultiListItem *item;
  917. X
  918. X    for (i = 0; i < MultiListNumItems(mlw); i++)
  919. X    {
  920. X        item = MultiListNthItem(mlw,i);
  921. X        if (MultiListItemHighlighted(item))
  922. X            XfwfMultiListUnhighlightItem(mlw,i);
  923. X    }
  924. X    MultiListNumSelected(mlw) = 0;
  925. } /* End XfwfMultiListUnhighlightAll */
  926. X
  927. X
  928. /*---------------------------------------------------------------------------*
  929. X
  930. X    int XfwfMultiListToggleItem(mlw,item_index)
  931. X
  932. X    This routine highlights the item with index <item_index>
  933. X    if it is unhighlighted and unhighlights it if it is already
  934. X    highlighted.  The action performed by the toggle is returned
  935. X    (XfwfMultiListActionHighlight or XfwfMultiListActionUnhighlight).
  936. X
  937. X *---------------------------------------------------------------------------*/
  938. X
  939. int XfwfMultiListToggleItem(mlw,item_index)
  940. XXfwfMultiListWidget mlw;
  941. int item_index;
  942. {
  943. X    XfwfMultiListItem *item;
  944. X
  945. X    if (MultiListMaxSelectable(mlw) == 0)
  946. X        return(XfwfMultiListActionNothing);
  947. X    if (item_index < 0 || item_index >= MultiListNumItems(mlw))
  948. X        return(XfwfMultiListActionNothing);
  949. X    item = MultiListNthItem(mlw,item_index);
  950. X    if (MultiListItemSensitive(item) == False)
  951. X        return(XfwfMultiListActionNothing);
  952. X    if (MultiListItemHighlighted(item))
  953. X    {
  954. X        XfwfMultiListUnhighlightItem(mlw,item_index);
  955. X        return(XfwfMultiListActionUnhighlight);
  956. X    }
  957. X        else
  958. X    {
  959. X        XfwfMultiListHighlightItem(mlw,item_index);
  960. X        return(XfwfMultiListActionHighlight);
  961. X    }
  962. } /* End XfwfMultiListToggleItem */
  963. X
  964. X
  965. /*---------------------------------------------------------------------------*
  966. X
  967. X    XfwfMultiListReturnStruct *XfwfMultiListGetHighlighted(mlw)
  968. X
  969. X    This routine takes a MultiList widget <mlw> and returns a
  970. X    XfwfMultiListReturnStruct whose num_selected and selected_items
  971. X    fields contain the highlight information.  The action field
  972. X    is set to MULTILIST_ACTION_STATUS, and the item_index and string
  973. X    fields are invalid.
  974. X
  975. X *---------------------------------------------------------------------------*/
  976. X
  977. XXfwfMultiListReturnStruct *XfwfMultiListGetHighlighted(mlw)
  978. XXfwfMultiListWidget mlw;
  979. {
  980. X    XfwfMultiListItem *item;
  981. X    static XfwfMultiListReturnStruct ret_value;
  982. X
  983. X    ret_value.action = XfwfMultiListActionStatus;
  984. X    if (MultiListNumSelected(mlw) == 0)
  985. X    {
  986. X        ret_value.item = -1;
  987. X        ret_value.string = NULL;
  988. X    }
  989. X        else
  990. X    {
  991. X        ret_value.item = MultiListSelArray(mlw)
  992. X            [MultiListNumSelected(mlw) - 1];
  993. X        item = MultiListNthItem(mlw,ret_value.item);
  994. X        ret_value.string = MultiListItemString(item);
  995. X    }
  996. X    ret_value.num_selected = MultiListNumSelected(mlw);
  997. X    ret_value.selected_items = MultiListSelArray(mlw);
  998. X    return(&ret_value);
  999. } /* End XfwfMultiListGetHighlighted */
  1000. X
  1001. X
  1002. /*---------------------------------------------------------------------------*
  1003. X
  1004. X    Boolean XfwfMultiListIsHighlighted(mlw,item_index)
  1005. X
  1006. X    This routine checks if the item with index <item_index>
  1007. X    is highlighted and returns True or False depending.  If
  1008. X    <item_index> is invalid, False is returned.
  1009. X
  1010. X *---------------------------------------------------------------------------*/
  1011. X
  1012. Boolean XfwfMultiListIsHighlighted(mlw,item_index)
  1013. XXfwfMultiListWidget mlw;
  1014. int item_index;
  1015. {
  1016. X    XfwfMultiListItem *item;
  1017. X
  1018. X    if (item_index < 0 || item_index >= MultiListNumItems(mlw))
  1019. X        return(False);
  1020. X    item = MultiListNthItem(mlw,item_index);
  1021. X    return(MultiListItemHighlighted(item));
  1022. } /* End XfwfMultiListIsHighlighted */
  1023. X
  1024. X
  1025. /*---------------------------------------------------------------------------*
  1026. X
  1027. X    Boolean XfwfMultiListGetItemInfo(mlw,item_index,str_ptr,h_ptr,s_ptr)
  1028. X
  1029. X    This routine returns the string, highlight status and
  1030. X    sensitivity information for the item with index <item_index>
  1031. X    via the pointers <str_ptr>, <h_ptr> and <s_ptr>.  If the item
  1032. X    index is invalid, False is returned, else True is returned.
  1033. X
  1034. X *---------------------------------------------------------------------------*/
  1035. X
  1036. Boolean XfwfMultiListGetItemInfo(mlw,item_index,str_ptr,h_ptr,s_ptr)
  1037. XXfwfMultiListWidget mlw;
  1038. int item_index;
  1039. String *str_ptr;
  1040. Boolean *h_ptr,*s_ptr;
  1041. {
  1042. X    XfwfMultiListItem *item;
  1043. X
  1044. X    if (item_index < 0 || item_index >= MultiListNumItems(mlw))
  1045. X        return(False);
  1046. X    item = MultiListNthItem(mlw,item_index);
  1047. X    *str_ptr = MultiListItemString(item);
  1048. X    *h_ptr = MultiListItemHighlighted(item);
  1049. X    *s_ptr = MultiListItemSensitive(item);
  1050. X    return(True);
  1051. } /* End XfwfMultiListGetItemInfo */
  1052. X
  1053. X
  1054. /*---------------------------------------------------------------------------*
  1055. X
  1056. X    XfwfMultiListSetNewData(mlw,list,nitems,longest,resize,
  1057. X        sensitivity_array)
  1058. X
  1059. X    This routine will set a new set of strings <list> into the
  1060. X    MultiList widget <mlw>.  If <resize> is True, the MultiList widget will
  1061. X    try to resize itself.
  1062. X
  1063. X *---------------------------------------------------------------------------*/
  1064. X
  1065. #if NeedFunctionPrototypes
  1066. void
  1067. XXfwfMultiListSetNewData(XfwfMultiListWidget mlw, String *list,
  1068. X            int nitems, int longest, Boolean resize,
  1069. X            Boolean *sensitivity_array)
  1070. #else
  1071. void
  1072. XXfwfMultiListSetNewData(mlw,list,nitems,longest,resize,sensitivity_array)
  1073. XXfwfMultiListWidget mlw;
  1074. String *list;
  1075. int nitems,longest;
  1076. Boolean resize;
  1077. Boolean *sensitivity_array;
  1078. #endif
  1079. {
  1080. X    DestroyOldData(mlw);
  1081. X    MultiListList(mlw) = list;
  1082. X    MultiListNumItems(mlw) = max(nitems,0);
  1083. X    MultiListLongest(mlw) = max(longest,0);
  1084. X    MultiListSensitiveArray(mlw) = sensitivity_array;
  1085. X    InitializeNewData(mlw);
  1086. X    RecalcCoords(mlw,resize,resize);
  1087. X    if (XtIsRealized((Widget)mlw)) Redisplay(mlw,NULL,NULL);
  1088. } /* End XfwfMultiListSetNewData */
  1089. X
  1090. X
  1091. SHAR_EOF
  1092. echo 'File xarchie-2.0.6/FWF/MultiList/MultiList.c is complete' &&
  1093. chmod 0644 xarchie-2.0.6/FWF/MultiList/MultiList.c ||
  1094. echo 'restore of xarchie-2.0.6/FWF/MultiList/MultiList.c failed'
  1095. Wc_c="`wc -c < 'xarchie-2.0.6/FWF/MultiList/MultiList.c'`"
  1096. test 55449 -eq "$Wc_c" ||
  1097.     echo 'xarchie-2.0.6/FWF/MultiList/MultiList.c: original size 55449, current size' "$Wc_c"
  1098. rm -f _shar_wnt_.tmp
  1099. fi
  1100. # ============= xarchie-2.0.6/FWF/MultiList/MultiList.h ==============
  1101. if test -f 'xarchie-2.0.6/FWF/MultiList/MultiList.h' -a X"$1" != X"-c"; then
  1102.     echo 'x - skipping xarchie-2.0.6/FWF/MultiList/MultiList.h (File already exists)'
  1103.     rm -f _shar_wnt_.tmp
  1104. else
  1105. > _shar_wnt_.tmp
  1106. echo 'x - extracting xarchie-2.0.6/FWF/MultiList/MultiList.h (Text)'
  1107. sed 's/^X//' << 'SHAR_EOF' > 'xarchie-2.0.6/FWF/MultiList/MultiList.h' &&
  1108. /****************************************************************************
  1109. X
  1110. X    MultiList.h
  1111. X
  1112. X    This file is the public header file for the MultiList widget, an
  1113. X    extension to the Athena List widget.
  1114. X
  1115. X    This code is loosely based on the Athena List source which
  1116. X    is why the MIT copyright notice appears below.
  1117. X
  1118. X    The code was changed substantially in V3.4 to change the
  1119. X    action/callback interface which was unnecessarily ugly.  Code
  1120. X    using some features of the old interface may need to be changed.
  1121. X    Hope the changes don't make people's lives too miserable.
  1122. X
  1123. X ****************************************************************************/
  1124. X
  1125. /*
  1126. X * Author:
  1127. X *     Brian Totty
  1128. X *     Department of Computer Science
  1129. X *     University Of Illinois at Urbana-Champaign
  1130. X *    1304 West Springfield Avenue
  1131. X *     Urbana, IL 61801
  1132. X * 
  1133. X *     totty@cs.uiuc.edu
  1134. X *     
  1135. X */ 
  1136. X
  1137. /*
  1138. X * Copyright 1989 Massachusetts Institute of Technology
  1139. X *
  1140. X * Permission to use, copy, modify, distribute, and sell this software and its
  1141. X * documentation for any purpose is hereby granted without fee, provided that
  1142. X * the above copyright notice appear in all copies and that both that
  1143. X * copyright notice and this permission notice appear in supporting
  1144. X * documentation, and that the name of M.I.T. not be used in advertising or
  1145. X * publicity pertaining to distribution of the software without specific,
  1146. X * written prior permission.  M.I.T. makes no representations about the
  1147. X * suitability of this software for any purpose.  It is provided "as is"
  1148. X * without express or implied warranty.
  1149. X *
  1150. X * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  1151. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  1152. X * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1153. X * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  1154. X * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  1155. X * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1156. X *
  1157. X * Original Athena Author:  Chris D. Peterson, MIT X Consortium
  1158. X */
  1159. X
  1160. #ifndef _MULTILIST_H_
  1161. #define _MULTILIST_H_
  1162. X
  1163. #include <X11/Xaw/Simple.h>
  1164. X
  1165. /*---------------------------------------------------------------------------*
  1166. X
  1167. X      R E S O U R C E    D E S C R I P T I O N S    A N D    N O T E S
  1168. X
  1169. X *---------------------------------------------------------------------------*/
  1170. X
  1171. /*
  1172. X
  1173. X Name             Class        RepType        Default Value
  1174. X ----             -----        -------        -------------
  1175. X background         Background        Pixel        XtDefaultBackground
  1176. X border             BorderColor    Pixel        XtDefaultForeground
  1177. X borderWidth         BorderWidth    Dimension    1
  1178. X callback            Callback           XtCallbackList  NULL                *1
  1179. X columnWidth         Width              Dimension       0                   *9
  1180. X columnSpacing       Spacing            Dimension       8
  1181. X cursor             Cursor        Cursor        left_ptr
  1182. X defaultColumns      Columns            int             1                   *2
  1183. X destroyCallback     Callback        Pointer        NULL 
  1184. X font             Font        XFontStruct*    XtDefaultFont
  1185. X forceColumns        Columns            Boolean         False               *2
  1186. X foreground         Foreground        Pixel        XtDefaultForeground
  1187. X height             Height        Dimension    0                   *3
  1188. X highlightBackground HBackground    Pixel        XtDefaultForeground *4
  1189. X highlightForeground HForeground    Pixel        XtDefaultBackground *4
  1190. X insensitiveBorder   Insensitive    Pixmap        Gray
  1191. X list                List               String *        NULL                *5
  1192. X longest             Longest            int             0                   *6
  1193. X mappedWhenManaged   MappedWhenManaged    Boolean        True
  1194. X maxSelectable       Value              int             1                   *7
  1195. X numberStrings       NumberStrings      int             0                   *5
  1196. X pasteBuffer         Boolean            Boolean         False
  1197. X rowHeight           Height             Dimension       0                   *9
  1198. X rowSpacing          Spacing            Dimension       2
  1199. X sensitive         Sensitive        Boolean        True
  1200. X sensitiveArray      List               Boolean *       NULL                *8
  1201. X shadeSurplus         Boolean        Boolean        True            *10
  1202. X verticalList        Boolean            Boolean         False
  1203. X width             Width        Dimension    0
  1204. X x             Position        Position    0
  1205. X y             Position        Position    0
  1206. X
  1207. X *1 -  The callback functions are called whenever a highlight or unhighlight
  1208. X       takes place.  More precisely, a callback occurs whenever the Notify()
  1209. X       action is triggered.  By default, this occurs when the mouse button is
  1210. X       lifted after a selection or deselection occurred.  The callback returns
  1211. X       an XfwfMultiListReturnStruct data structure which contains numerous
  1212. X       fields describing the selection state.  The most important fields
  1213. X       indicate the total number of items selected, and a list of those items.
  1214. X
  1215. X *2 -  The defaultColumns resource is used in two cases.  If forceColumns
  1216. X       is true, the widget will set the number of columns to the value of
  1217. X       default columns.  If the widget width is unconstrained by the parent
  1218. X       widgets, the defaultColumns is also used to determine the number of
  1219. X       columns and the resulting width.  Otherwise, the number of columns
  1220. X       will be calcultaed based on the current width and will be changed to
  1221. X       an appropriate value.
  1222. X
  1223. X *3 -  If the width or height is set to zero (0), which is the default case,
  1224. X       then the widget will calculate the size of that dimension to be just
  1225. X       large enough to hold the contents of the widget.
  1226. X
  1227. X *4 -  The highlightForeground and highlightBackground colors specify the
  1228. X       colors used to highlight the text (foreground) and the surrounding
  1229. X       background space of a list item when it is selected (highlighted).
  1230. X       The default is the reverse of the default foreground and background
  1231. X       colors.
  1232. X
  1233. X *5 -  The list resource is an array of strings (char * array) which tell
  1234. X       the names of each item of the list.  The number of elements of this
  1235. X       array are indicated by the resource numberStrings.  If numberStrings
  1236. X       is set to 0 (the default), then the MultiList widget will count the
  1237. X       number of strings in the list.  This requires that the list be
  1238. X       NULL terminated.  If list is NULL, then the widget treats it as an
  1239. X       empty list.  Once the list is set the list resource is set to NULL,
  1240. X       so you won't be able to read back the list after it has been set.  The
  1241. X       widgets copies the strings internally, so the user can free the list
  1242. X       storage after setting it.
  1243. X
  1244. X *6 -  This resource represent the longest string in pixels.  If this
  1245. X       resource is zero (0), which is the default and probably the value
  1246. X       most people should use, the longest string length is calculated
  1247. X       and the resource is updated.
  1248. X
  1249. X *7 -  The maxSelectable resource indicates the maximum number of items
  1250. X       which can be selected at any one time.  In the original Athena
  1251. X       widget, you could have at most one item selected at a time.  In
  1252. X       this widget, you can choose how many will be selected at a time.
  1253. X
  1254. X *8 -  Each item in the MultiList can be made insensitive, so it is printed in
  1255. X       gray shading and can not be highlighted.  This can be done by
  1256. X       setting the sensitivity list, which is an array of Booleans which
  1257. X       indicate whether or not the corresponding item is sensitive (can be
  1258. X       selected).  If sensitivity list is NULL, all items are sensitive.  The
  1259. X       widget copies the sensitivity information, so the user can delete the
  1260. X       sensitivity array storage after setting it.  The widget sets the
  1261. X       resource to NULL after it has been set, so the user cannot read the
  1262. X       old list back.
  1263. X
  1264. X *9 -  These values are intended for reading only.  They indicate the pixel
  1265. X       width/height of the column/row.
  1266. X
  1267. X *10 - If the list height is made larger than the sum of the list entry
  1268. X       heights, the surplus space is shaded in the background color if
  1269. X       shadeSurplus is False, or in a gray stipple pattern if shadeSurplus
  1270. X       is True.       
  1271. X
  1272. */
  1273. X
  1274. /*---------------------------------------------------------------------------*
  1275. X
  1276. X                    S T R I N G    D E F I N I T I O N S
  1277. X
  1278. X *---------------------------------------------------------------------------*/
  1279. X
  1280. #define XtCList            "List"
  1281. #define XtCSpacing        "Spacing"
  1282. #define XtCColumns        "Columns"
  1283. #define XtCLongest        "Longest"
  1284. #define XtCNumberStrings    "NumberStrings"
  1285. #define    XtCHForeground        "HForeground"
  1286. #define    XtCHBackground        "HBackground"
  1287. X
  1288. #ifndef XtNcursor
  1289. #define XtNcursor        "cursor"
  1290. #endif
  1291. X
  1292. #define    XtNhighlightForeground    "highlightForeground"
  1293. #define    XtNhighlightBackground    "highlightBackground"
  1294. #define XtNcolumnSpacing    "columnSpacing"
  1295. #define XtNrowSpacing        "rowSpacing"
  1296. #define XtNdefaultColumns    "defaultColumns"
  1297. #define XtNforceColumns        "forceColumns"
  1298. #define XtNpasteBuffer        "pasteBuffer"
  1299. #define XtNverticalList        "verticalList"
  1300. #define XtNlongest        "longest"
  1301. #define XtNnumberStrings    "numberStrings"
  1302. #define XtNlist            "list"
  1303. #define    XtNsensitiveArray    "sensitiveArray"
  1304. #define    XtNmaxSelectable    "maxSelectable"
  1305. #define    XtNshadeSurplus        "shadeSurplus"
  1306. X
  1307. #ifndef XtNrowHeight
  1308. #define    XtNrowHeight        "rowHeight"
  1309. #endif
  1310. #ifndef XtNcolumnWidth
  1311. #define    XtNcolumnWidth        "columnWidth"
  1312. #endif
  1313. X
  1314. X    /* Class Record Constants */
  1315. X
  1316. extern WidgetClass xfwfMultiListWidgetClass;
  1317. X
  1318. typedef struct _XfwfMultiListClassRec *XfwfMultiListWidgetClass;
  1319. typedef struct _XfwfMultiListRec      *XfwfMultiListWidget;
  1320. X
  1321. /*---------------------------------------------------------------------------*
  1322. X
  1323. X                     R E T U R N    S T R U C T U R E
  1324. X
  1325. X *---------------------------------------------------------------------------*/
  1326. X
  1327. #define    XfwfMultiListActionNothing        0
  1328. #define    XfwfMultiListActionHighlight        1
  1329. #define    XfwfMultiListActionUnhighlight        2
  1330. #define    XfwfMultiListActionStatus        3
  1331. X
  1332. typedef struct _XfwfMultiListReturnStruct
  1333. {
  1334. X    int num_selected;        /* Number Of Items Now Selected */
  1335. X    int *selected_items;        /* Indexes Of Selected Items */
  1336. X
  1337. X    int action;            /* Last Action Performed */
  1338. X    int item;            /* Last Item Index Modified */
  1339. X    String string;            /* String Of Last Index Modified */
  1340. } XfwfMultiListReturnStruct;
  1341. X
  1342. /*---------------------------------------------------------------------------*
  1343. X
  1344. X                     U T I L I T Y    R O U T I N E S
  1345. X
  1346. X *---------------------------------------------------------------------------*/
  1347. X
  1348. #if (!NeedFunctionPrototypes)
  1349. X
  1350. extern Boolean        XfwfMultiListHighlightItem();
  1351. extern void        XfwfMultiListHighlightAll();
  1352. extern void        XfwfMultiListUnhighlightItem();
  1353. extern void        XfwfMultiListUnhighlightAll();
  1354. extern int        XfwfMultiListToggleItem();
  1355. extern XfwfMultiListReturnStruct *
  1356. X            XfwfMultiListGetHighlighted();
  1357. extern Boolean        XfwfMultiListIsHighlighted();
  1358. extern Boolean        XfwfMultiListGetItemInfo();
  1359. extern void        XfwfMultiListSetNewData();
  1360. X
  1361. #else
  1362. X
  1363. extern Boolean        XfwfMultiListHighlightItem(XfwfMultiListWidget mlw,
  1364. X                int item_index);
  1365. extern void        XfwfMultiListHighlightAll(XfwfMultiListWidget mlw);
  1366. extern void        XfwfMultiListUnhighlightItem(XfwfMultiListWidget mlw,
  1367. X                int item_index);
  1368. extern void        XfwfMultiListUnhighlightAll(XfwfMultiListWidget mlw);
  1369. extern int        XfwfMultiListToggleItem(XfwfMultiListWidget mlw,
  1370. X                int item_index);
  1371. extern XfwfMultiListReturnStruct *
  1372. X            XfwfMultiListGetHighlighted(XfwfMultiListWidget mlw);
  1373. extern Boolean        XfwfMultiListIsHighlighted(XfwfMultiListWidget mlw,
  1374. X                int item_index);
  1375. extern Boolean        XfwfMultiListGetItemInfo(XfwfMultiListWidget mlw,
  1376. X                int item_index, String *str_ptr,
  1377. X                Boolean *h_ptr, Boolean *s_ptr);
  1378. extern void        XfwfMultiListSetNewData(XfwfMultiListWidget mlw,
  1379. X                String *list, int nitems, int longest,
  1380. X                Boolean resize, Boolean *sensitivity_array);
  1381. X
  1382. #endif
  1383. #endif
  1384. SHAR_EOF
  1385. chmod 0644 xarchie-2.0.6/FWF/MultiList/MultiList.h ||
  1386. echo 'restore of xarchie-2.0.6/FWF/MultiList/MultiList.h failed'
  1387. Wc_c="`wc -c < 'xarchie-2.0.6/FWF/MultiList/MultiList.h'`"
  1388. test 11706 -eq "$Wc_c" ||
  1389.     echo 'xarchie-2.0.6/FWF/MultiList/MultiList.h: original size 11706, current size' "$Wc_c"
  1390. rm -f _shar_wnt_.tmp
  1391. fi
  1392. # ============= xarchie-2.0.6/FWF/MultiList/MultiList.man ==============
  1393. if test -f 'xarchie-2.0.6/FWF/MultiList/MultiList.man' -a X"$1" != X"-c"; then
  1394.     echo 'x - skipping xarchie-2.0.6/FWF/MultiList/MultiList.man (File already exists)'
  1395.     rm -f _shar_wnt_.tmp
  1396. else
  1397. > _shar_wnt_.tmp
  1398. echo 'x - extracting xarchie-2.0.6/FWF/MultiList/MultiList.man (Text)'
  1399. sed 's/^X//' << 'SHAR_EOF' > 'xarchie-2.0.6/FWF/MultiList/MultiList.man' &&
  1400. '\" t
  1401. .TH "MultiList" "3" "19 May 1992" "Version 3.4" "Free Widget Foundation"
  1402. .SH Name
  1403. MultiList \- list from which multiple entries can be selected
  1404. .SH Synopsis
  1405. #include <X11/Intrinsic.h>
  1406. #include <X11/MultiList.h>
  1407. X
  1408. widget = XtCreateManagedWidget(name, multiListWidgetClass, ...);
  1409. .SH Class Hierarchy
  1410. Core-->Simple-->MultiList
  1411. .SH Description
  1412. X
  1413. MultiList is a replacement for the Athena List widget, which allows
  1414. multiple selections to be made.  The aesthetics have also been
  1415. slightly improved: the highlight colors can now be selected, and the
  1416. selection extends across the entire width of the column rather than
  1417. just the length of the string.
  1418. X
  1419. The maximum number of multiple selections can be specified.  Items are
  1420. selected and unselected by an action interface.  By default, mouse
  1421. button 1 is used to select, unselect, and toggle items.  When the
  1422. mouse button is lifted, any callbacks in the callback list are called
  1423. with a data structure which describes the count of select items, and
  1424. lists the indices of the selected items.  The return structure
  1425. contains some additional information describing the last item modified
  1426. and the last action performed, which will probably not be of general
  1427. use, and I'd love to delete if I was sure that people didn't use them.
  1428. (The behavior of these fields has changed slightly in V3.4).
  1429. X
  1430. .SH Resources
  1431. In addition to the resources defined by superclasses, this widget
  1432. defines the following:
  1433. .TS
  1434. tab(/) ;
  1435. lB lB lB lB.
  1436. Name/Class/Type/Default
  1437. .T&
  1438. lB l l l.
  1439. XXtNbackground/Background/Pixel/XtDefaultBackground
  1440. XXtNborder/BorderColor/Pixel/XtDefaultForeground
  1441. XXtNborderWidth/BorderWidth/Dimension/1
  1442. XXtNcallback/Callback/XtCallbackList/NULL
  1443. XXtNcolumnWidth/Width/Dimension/0
  1444. XXtNcolumnSpacing/Spacing/Dimension/8
  1445. XXtNcursor/Cursor/Cursor/left_ptr
  1446. XXtNdefaultColumns/Columns/int/1
  1447. XXtNdestroyCallback/Callback/Pointer/NULL 
  1448. XXtNfont/Font/XFontStruct/XtDefaultFont
  1449. XXtNforceColumns/Columns/Boolean/False
  1450. XXtNforeground/Foreground/Pixel/XtDefaultForeground
  1451. XXtNheight/Height/Dimension/0
  1452. XXtNhighlightBackground/HBackground/Pixel/XtDefaultForeground
  1453. XXtNhighlightForeground/HForeground/Pixel/XtDefaultBackground
  1454. XXtNinsensitiveBorder/Insensitive/Pixmap/Gray
  1455. XXtNlist/List/String/NULL
  1456. XXtNlongest/Longest/int/0
  1457. XXtNmappedWhenManaged/MappedWhenManaged/Boolean/True
  1458. XXtNmaxSelectable/Value/int/1
  1459. XXtNnumberStrings/NumberStrings/int/0
  1460. XXtNpasteBuffer/Boolean/Boolean/False
  1461. XXtNrowHeight/Height/Dimension/0
  1462. XXtNrowSpacing/Spacing/Dimension/2
  1463. XXtNsensitive/Sensitive/Boolean/True
  1464. XXtNsensitiveArray/List/Boolean/NULL
  1465. XXtNverticalList/Boolean/Boolean/False
  1466. XXtNwidth/Width/Dimension/0
  1467. XXtNx/Position/Position/0
  1468. XXtNy/Position/Position/0
  1469. .TE
  1470. .ne 4
  1471. .SH Public Functions
  1472. .nf
  1473. .ta 3i
  1474. void XfwfMultiListHighlightItem(mlw,item_index)
  1475. XXfwfMultiListWidget mlw;
  1476. int item_index;
  1477. .fi
  1478. .sp
  1479. .RS 5
  1480. This routine selects an item with index <item_index> in the MultiList
  1481. widget <mlw>.  If a maximum number of selections is specified and
  1482. exceeded, the earliest selection will be unselected.  If <item_index>
  1483. doesn't correspond to an item the most recently clicked item will be
  1484. set to -1 and this routine will immediately return, otherwise the most
  1485. recently clicked item will be set to the current item.
  1486. SHAR_EOF
  1487. true || echo 'restore of xarchie-2.0.6/FWF/MultiList/MultiList.man failed'
  1488. fi
  1489. echo 'End of xarchie-2.0.6 part 23'
  1490. echo 'File xarchie-2.0.6/FWF/MultiList/MultiList.man is continued in part 24'
  1491. echo 24 > _shar_seq_.tmp
  1492. exit 0
  1493.  
  1494. exit 0 # Just in case...
  1495. -- 
  1496.   // chris@IMD.Sterling.COM       | Send comp.sources.x submissions to:
  1497. \X/  Amiga - The only way to fly! |    sources-x@imd.sterling.com
  1498.  "It's intuitively obvious to the |
  1499.   most casual observer..."        | GCS d+/-- p+ c++ l+ m+ s++/+ g+ w+ t+ r+ x+
  1500.