home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff386.lzh / XLispStat / src1.lzh / IView / dialogs.c < prev    next >
C/C++ Source or Header  |  1990-10-07  |  21KB  |  782 lines

  1. /* dialogs - General Dialog Objects                                    */
  2. /* XLISP-STAT 2.1 Copyright (c) 1990, by Luke Tierney                  */
  3. /* Additions to Xlisp 2.1, Copyright (c) 1989 by David Michael Betz    */
  4. /* You may give out copies of this software; for conditions see the    */
  5. /* file COPYING included with this distribution.                       */
  6.  
  7. #include "xlisp.h"
  8. #include "osdef.h"
  9. #ifdef ANSI
  10. #include "xlproto.h"
  11. #include "xlsproto.h"
  12. #include "iviewproto.h"
  13. #include "Stproto.h"
  14. #else
  15. #include "xlfun.h"
  16. #include "xlsfun.h"
  17. #include "iviewfun.h"
  18. #include "Stfun.h"
  19. #endif ANSI
  20. #include "xlsvar.h"
  21.  
  22. /* forward declarations */
  23. #ifdef ANSI
  24. LVAL simple_dialog_method(int),make_text_item(LVAL),process_items(LVAL);
  25. Point calc_item_size(LVAL,LVAL,int,int),
  26.       calc_item_list_size(LVAL,LVAL,int,int,int);
  27. void calc_size(LVAL),calc_location(LVAL),get_initial_item_values(LVAL,int);
  28. #else
  29. LVAL simple_dialog_method(),make_text_item(),process_items();
  30. Point calc_item_size(),
  31.       calc_item_list_size();
  32. void calc_size(),calc_location(),get_initial_item_values();
  33. #endif
  34.  
  35. /* layout definitions */
  36. # define ITEM_GAP 10
  37. # define SCROLL_MIN 0
  38. # define SCROLL_MAX 100
  39. # define SCROLL_PAGE 5
  40.  
  41. # define has_item_location(i) (slot_value(i, s_location) != NIL)
  42. # define has_item_size(i) (slot_value(i, s_size) != NIL)
  43. # define check_dialog_address(d) valid_dialog_address(slot_value(d, s_hardware_address))
  44.  
  45. /***********************************************************************/
  46. /**                                                                   **/
  47. /**                          Utility Functions                        **/
  48. /**                                                                   **/
  49. /***********************************************************************/
  50.  
  51. int check_point_list(x)
  52.     LVAL x;
  53. {
  54.   return(listp(x) && llength(x) == 2 && fixp(car(x)) && fixp(car(cdr(x))));
  55. }
  56.  
  57. Point ListToPoint(list)
  58.     LVAL list;
  59. {
  60.   Point pt;
  61.   
  62.   if (! check_point_list(list)) xlerror("not a point", list);
  63.   pt.h = getfixnum(car(list));
  64.   pt.v = getfixnum(car(cdr(list)));
  65.   return(pt);
  66. }
  67.  
  68. LVAL PointToList(pt)
  69.     Point pt;
  70. {
  71.   return(integer_list_2((int) pt.h, (int) pt.v));
  72. }
  73.  
  74. /***********************************************************************/
  75. /***********************************************************************/
  76. /**                                                                   **/
  77. /**                         DIALOG-PROTO Methods                      **/
  78. /**                                                                   **/
  79. /***********************************************************************/
  80. /***********************************************************************/
  81.  
  82. /***********************************************************************/
  83. /**                                                                   **/
  84. /**                         Support Functions                         **/
  85. /**                                                                   **/
  86. /***********************************************************************/
  87.  
  88. /* Is this a dialog? */
  89. int dialog_p(x)
  90.     LVAL x;
  91. {
  92.   return (kind_of_p(x, getvalue(s_dialog_proto)));
  93. }
  94.  
  95. /* get a dialog from the stack */
  96. LVAL xsgetdialog()
  97. {
  98.   LVAL x;
  99.   x = xlgetarg();
  100.   if (! dialog_p(x)) xlerror("not a dialog", x);
  101.   return(x);
  102. }
  103.  
  104. static Point calc_item_size(dialog, item, left, top)
  105.     LVAL dialog, item;
  106.     int left, top;
  107. {
  108.   Point sz, loc;
  109.   
  110.   if (! dialog_item_p(item)) xlerror("not a dialog item", item);
  111.   if (slot_value(item, s_dialog) != NIL
  112.       && check_dialog_address(slot_value(item, s_dialog))) 
  113.     xlfail("item is already installed in a dialog");
  114.   sz = ListToPoint(slot_value(item, s_size));
  115.   if (has_item_location(item))
  116.     loc = ListToPoint(slot_value(item, s_location));
  117.   else {
  118.     loc.h = left;
  119.     loc.v = top;
  120.     set_slot_value(item, s_location, PointToList(loc));
  121.   }
  122.   sz.h += loc.h - left;
  123.   sz.v += loc.v - top;
  124.   sz.h = max((int) sz.h, 0);
  125.   sz.v = max((int) sz.v, 0);
  126.   set_slot_value(item, s_dialog, dialog);
  127.   return(sz);
  128.  
  129. static Point calc_item_list_size(dialog, items, left, top, as_column)
  130.     LVAL dialog, items;
  131.     int left, top, as_column;
  132. {
  133.   LVAL item;
  134.   Point sz, pt;
  135.   
  136.   for (sz.h = 0, sz.v = 0; consp(items); items = cdr(items)) {
  137.     item = car(items);
  138.     if consp(item)
  139.       pt = calc_item_list_size(dialog, item, left, top, ! as_column);
  140.     else pt = calc_item_size(dialog, item, left, top);
  141.     if (as_column) {
  142.       sz.h = max((int) sz.h, (int) pt.h);
  143.       sz.v += pt.v + ITEM_GAP;
  144.       top += pt.v + ITEM_GAP;
  145.     }
  146.     else {
  147.       sz.h += pt.h + ITEM_GAP;
  148.       left += pt.h + ITEM_GAP;
  149.       sz.v = max((int) sz.v, (int) pt.v);
  150.     }
  151.   }
  152.   if (as_column) sz.v = max((int) (sz.v - ITEM_GAP), 0);
  153.   else sz.h = max((int) (sz.h - ITEM_GAP), 0);
  154.   
  155.   return(sz);
  156. }
  157.  
  158. static void calc_size(dialog)
  159.     LVAL dialog;
  160. {
  161.   Point sz;
  162.   LVAL size = slot_value(dialog, s_size);
  163.   LVAL items = slot_value(dialog, s_items);
  164.   
  165.   sz = calc_item_list_size(dialog, items, ITEM_GAP, ITEM_GAP, TRUE);
  166.   sz.h += 2 * ITEM_GAP;
  167.   sz.v += 2 * ITEM_GAP;
  168.   if (! check_point_list(size)) {
  169.     set_slot_value(dialog, s_size, PointToList(sz));
  170.   }
  171. }
  172.  
  173. static void calc_location(dialog)
  174.     LVAL dialog;
  175. {
  176.   Point screen, size, location;
  177.   int left, top;
  178.   LVAL loc = slot_value(dialog, s_location);
  179.   
  180.   if (! check_point_list(loc)) {
  181.     StGetScreenSize(&left, &top);
  182.      screen.h = left; screen.v = top; /* needed since components may be shorts */
  183.     size = ListToPoint(slot_value(dialog, s_size));
  184.     location.h = (screen.h - size.h) / 2;
  185.     location.v = (screen.v - size.v) / 2;
  186.     set_slot_value(dialog, s_location, PointToList(location));
  187.   }
  188. }
  189.  
  190. static LVAL simple_dialog_method(which)
  191.     int which;
  192. {
  193.   LVAL dialog, result = NIL;
  194.   
  195.   dialog = xsgetdialog();
  196.   xllastarg();
  197.    
  198.   switch (which) {
  199.   case 'R': DialogRemove(dialog); break;
  200.   case 'A': calc_size(dialog);
  201.             calc_location(dialog);
  202.             DialogAllocate(dialog);
  203.             break;
  204.   case 'a': result = (check_dialog_address(dialog)) ? s_true : NIL; break;
  205.   }
  206.   return(result);
  207. }
  208. /*
  209. extern LVAL s_text_item_proto, sk_new;
  210. extern LVAL copylist();   in headers JKL */
  211.  
  212. static LVAL make_text_item(string)
  213.     LVAL string;
  214. {
  215.   LVAL result;
  216.   
  217.   result = send_message_1L(getvalue(s_text_item_proto), sk_new, string);
  218.   return(result);
  219. }
  220.  
  221. static LVAL process_items(items)
  222.     LVAL items;
  223. {
  224.   LVAL next;
  225.   
  226.   xlprot1(items);
  227.   items = copylist(items);
  228.   for (next = items; consp(next); next = cdr(next)) {
  229.     if (stringp(car(next))) rplaca(next, make_text_item(car(next)));
  230.     else if (consp(car(next))) rplaca(next, process_items(car(next)));
  231.   }
  232.   xlpop();
  233.   return(items);
  234. }
  235.   
  236. /***********************************************************************/
  237. /**                                                                   **/
  238. /**                              Methods                              **/
  239. /**                                                                   **/
  240. /***********************************************************************/
  241.  
  242. /* :ISNEW Method */
  243. LVAL xsdialog_isnew()
  244. {
  245.   LVAL dialog, items;
  246.     
  247.   dialog = xsgetdialog();
  248.   
  249.   items = xlgalist();
  250.   items = process_items(items);
  251.   set_slot_value(dialog, s_items, items);
  252.   
  253.   object_isnew(dialog);
  254.   if (! stringp(slot_value(dialog, s_title)))
  255.     set_slot_value(dialog, s_title, make_string("Dialog"));
  256.  
  257.   if (xsboolkey(sk_show, TRUE)) send_message(dialog, sk_allocate);
  258.   
  259.   return(dialog);
  260. }
  261.  
  262. LVAL xsdialog_allocate()     { return(simple_dialog_method('A')); }
  263. LVAL xsdialog_remove()       { return(simple_dialog_method('R')); }
  264. LVAL xsdialog_allocated_p()  { return(simple_dialog_method('a')); }
  265.  
  266. LVAL xsdialog_default_button()
  267. {
  268.   LVAL dialog,  item;
  269.  
  270.   dialog = xsgetdialog();
  271.   item = xlgetarg();
  272.   xllastarg();
  273.  
  274.   DialogSetDefaultButton(dialog, item);
  275.   
  276.   return (item); 
  277. }
  278.  
  279. /* :MODAL-DIALOG method */
  280. LVAL xsdialog_modal()
  281. {
  282.   LVAL dialog;
  283.     
  284.   dialog = xsgetdialog();
  285.   xllastarg();
  286.   
  287.   return(DialogGetModalItem(dialog));
  288. }
  289.  
  290. /***********************************************************************/
  291. /***********************************************************************/
  292. /**                                                                   **/
  293. /**                      DIALOG-ITEM-PROTO Methods                    **/
  294. /**                                                                   **/
  295. /***********************************************************************/
  296. /***********************************************************************/
  297.  
  298. /* Is this a dialog-item? */
  299. int dialog_item_p(x)
  300.     LVAL x;
  301. {
  302.   return (kind_of_p(x, getvalue(s_dialog_item_proto)));
  303. }
  304.  
  305. /* get a dialog item from the stack */
  306. LVAL xsgetdialogitem()
  307. {
  308.   LVAL x;
  309.   x = xlgetarg();
  310.   if (! dialog_item_p(x)) xlerror("not a dialog item", x);
  311.   return(x);
  312. }
  313.  
  314. static void get_initial_item_values(item, get_first)
  315.     LVAL item;
  316.     int get_first;
  317. {
  318.   LVAL text;
  319.   
  320.   if (get_first) {
  321.     text = xlgastring();
  322.     set_slot_value(item, s_text, text);
  323.   }
  324.   object_isnew(item);
  325. }
  326.  
  327. /* :DO-ACTION Method */
  328. LVAL xsdialog_item_do_action()
  329.   LVAL item, action/*, result rewritten below JKL */;
  330.   item = xsgetdialogitem();
  331.   xllastarg();
  332.   
  333.   action = slot_value(item, s_action);
  334. /*  result = (action != NIL) ? xlapply(pushargs(action, NIL)) : NIL;*/
  335.   return(/*result*/(action != NIL) ? xlapply(pushargs(action, NIL)) : NIL);
  336. }
  337.  
  338. /* :ACTION Method */
  339. LVAL xsdialog_item_action()
  340. {
  341.   LVAL item, action;
  342.   int set;
  343.   
  344.   item = xsgetdialogitem();
  345.   set = moreargs();
  346.   if (set) action = xlgetarg();
  347.   xllastarg();
  348.   
  349.   if (set) set_slot_value(item, s_action, action);
  350.   return(slot_value(item, s_action));
  351. }
  352.  
  353. /***********************************************************************/
  354. /***********************************************************************/
  355. /**                                                                   **/
  356. /**                      BUTTON-ITEM-PROTO Methods                    **/
  357. /**                                                                   **/
  358. /***********************************************************************/
  359. /***********************************************************************/
  360.  
  361. /* Is this a button-item? */
  362. int button_item_p(x)
  363.     LVAL x;
  364. {
  365.   return (kind_of_p(x, getvalue(s_button_item_proto)));
  366. }
  367.  
  368. /* get a button item from the stack */
  369. LVAL xsgetbuttonitem()
  370. {
  371.   LVAL x;
  372.   x = xlgetarg();
  373.   if (! button_item_p(x)) xlerror("not a button item", x);
  374.   return(x);
  375. }
  376.  
  377. /* :ISNEW Method */
  378. LVAL xsbutton_item_isnew()
  379. {
  380.   LVAL item;
  381.   int width, height;
  382.   
  383.   item = xsgetbuttonitem();
  384.   
  385.   get_initial_item_values(item, TRUE);
  386.     
  387.   if (! has_item_size(item)) {
  388.     DialogButtonGetDefaultSize(item, &width, &height);
  389.     set_slot_value(item, s_size, integer_list_2(width, height));
  390.   }
  391.   
  392.   return(item);
  393. }
  394.  
  395. /***********************************************************************/
  396. /***********************************************************************/
  397. /**                                                                   **/
  398. /**                      TOGGLE-ITEM-PROTO Methods                    **/
  399. /**                                                                   **/
  400. /***********************************************************************/
  401. /***********************************************************************/
  402.  
  403. /* Is this a toggle-item? */
  404. int toggle_item_p(x)
  405.     LVAL x;
  406. {
  407.   return (kind_of_p(x, getvalue(s_toggle_item_proto)));
  408. }
  409.  
  410. /* get a toggle item from the stack */
  411. LVAL xsgettoggleitem()
  412. {
  413.   LVAL x;
  414.   x = xlgetarg();
  415.   if (! toggle_item_p(x)) xlerror("not a toggle item", x);
  416.   return(x);
  417. }
  418.  
  419. /* :ISNEW Method */
  420. LVAL xstoggle_item_isnew()
  421. {
  422.   LVAL item;
  423.   int width, height;
  424.   
  425.   item = xsgettoggleitem();
  426.   
  427.   get_initial_item_values(item, TRUE);
  428.     
  429.   if (! has_item_size(item)) {
  430.     DialogToggleGetDefaultSize(item, &width, &height);
  431.     set_slot_value(item, s_size, integer_list_2(width, height));
  432.   }
  433.   
  434.   return(item);
  435. }
  436.  
  437. /* :VALUE Method */
  438. LVAL xstoggle_item_value()
  439. {
  440.   LVAL item, value;
  441.   int set;
  442.    
  443.   item = xsgettoggleitem();
  444.   set = moreargs();
  445.   if (set) value = xlgetarg();
  446.   xllastarg();
  447.   
  448.   return(DialogToggleItemValue(item, set, value));
  449. }
  450.  
  451. /***********************************************************************/
  452. /***********************************************************************/
  453. /**                                                                   **/
  454. /**                       TEXT-ITEM-PROTO Methods                     **/
  455. /**                                                                   **/
  456. /***********************************************************************/
  457. /***********************************************************************/
  458.  
  459. /* Is this a text-item? */
  460. int text_item_p(x)
  461.     LVAL x;
  462. {
  463.   return (kind_of_p(x, getvalue(s_text_item_proto)));
  464. }
  465.  
  466. /* get a text item from the stack */
  467. LVAL xsgettextitem()
  468. {
  469.   LVAL x;
  470.   x = xlgetarg();
  471.   if (! text_item_p(x)) xlerror("not a text item", x);
  472.   return(x);
  473. }
  474.  
  475. /* :ISNEW Method */
  476. LVAL xstext_item_isnew()
  477. {
  478.   LVAL item, edit;
  479.   int width, height;
  480.   
  481.   item = xsgettextitem();
  482.  
  483.   get_initial_item_values(item, TRUE);
  484.     
  485.   if (xlgetkeyarg(sk_editable, &edit) && edit != NIL)
  486.     set_slot_value(item, s_editable, s_true);
  487.     
  488.   if (! has_item_size(item)) {
  489.     DialogTextGetDefaultSize(item, &width, &height);
  490.     set_slot_value(item, s_size, integer_list_2(width, height));
  491.   }
  492.   
  493.   return(item);
  494. }
  495.  
  496. /* :TEXT Method */
  497. LVAL xstext_item_text()
  498. {
  499.   LVAL item;
  500.   int set;
  501.   char *text;
  502.   
  503.   item = xsgettextitem();
  504.   set = moreargs();
  505.   if (set) text = (char *) getstring(xlgastring());
  506.   xllastarg();
  507.   
  508.   return(DialogTextItemText(item, set, text));
  509. }
  510.  
  511. /***********************************************************************/
  512. /***********************************************************************/
  513. /**                                                                   **/
  514. /**                      CHOICE-ITEM-PROTO Methods                    **/
  515. /**                                                                   **/
  516. /***********************************************************************/
  517. /***********************************************************************/
  518.  
  519. /* Is this a choice-item? */
  520. int choice_item_p(x)
  521.     LVAL x;
  522. {
  523.   return (kind_of_p(x, getvalue(s_choice_item_proto)));
  524. }
  525.  
  526. /* get a choice item from the stack */
  527. LVAL xsgetchoiceitem()
  528. {
  529.   LVAL x;
  530.   x = xlgetarg();
  531.   if (! choice_item_p(x)) xlerror("not a choice item", x);
  532.   return(x);
  533. }
  534.  
  535. /* :ISNEW Method */
  536. LVAL xschoice_item_isnew()
  537. {
  538.   LVAL item, text, next;
  539.   int width, height;
  540.   
  541.   item = xsgetchoiceitem();
  542.   text = xlgalist();
  543.   for (next = text; consp(next); next = cdr(next))
  544.     if (! stringp(car(next))) xlerror("not a string", car(next));
  545.   set_slot_value(item, s_text, text);
  546.   
  547.   get_initial_item_values(item, FALSE);
  548.     
  549.   if (! has_item_size(item)) {
  550.     DialogChoiceGetDefaultSize(item, &width, &height);
  551.     set_slot_value(item, s_size, integer_list_2(width, height));
  552.   }
  553.   if (! fixp(slot_value(item, s_value)))
  554.     set_slot_value(item, s_value, cvfixnum((FIXTYPE) 0));
  555.   return(item);
  556. }
  557.  
  558. /* :VALUE Method */
  559. LVAL xschoice_item_value()
  560. {
  561.   LVAL item;
  562.   int value, set;
  563.   
  564.   item = xsgetchoiceitem();
  565.   set = moreargs();
  566.   if (set) value = getfixnum(xlgafixnum());
  567.   xllastarg();
  568.   
  569.   return(DialogChoiceItemValue(item, set, value));
  570. }
  571.  
  572. /***********************************************************************/
  573. /***********************************************************************/
  574. /**                                                                   **/
  575. /**                      SCROLL-ITEM-PROTO Methods                    **/
  576. /**                                                                   **/
  577. /***********************************************************************/
  578. /***********************************************************************/
  579.  
  580. /* Is this a scroll-item? */
  581. int scroll_item_p(x)
  582.     LVAL x;
  583. {
  584.   return (kind_of_p(x, getvalue(s_scroll_item_proto)));
  585. }
  586.  
  587. /* get a scroll item from the stack */
  588. LVAL xsgetscrollitem()
  589. {
  590.   LVAL x;
  591.   x = xlgetarg();
  592.   if (! scroll_item_p(x)) xlerror("not a scroll item", x);
  593.   return(x);
  594. }
  595.  
  596. /* :ISNEW Method */
  597. LVAL xsscroll_item_isnew()
  598. {
  599.   LVAL item, low, high, page;
  600.   int width, height;
  601.   
  602.   item = xsgetscrollitem();
  603.   
  604.   get_initial_item_values(item, FALSE);
  605.   
  606.   if (! xlgetkeyarg(sk_min_value, &low) || ! fixp(low))
  607.     low = cvfixnum((FIXTYPE) SCROLL_MIN);
  608.   set_slot_value(item, s_min_value, low);
  609.   if (! fixp(slot_value(item, s_value)))
  610.     set_slot_value(item, s_value, low);
  611.   if (! xlgetkeyarg(sk_max_value, &high) || ! fixp(high))
  612.     high = cvfixnum((FIXTYPE) SCROLL_MAX);
  613.   set_slot_value(item, s_max_value, high);
  614.   if (! xlgetkeyarg(sk_page_increment, &page) || ! fixp(page))
  615.     page = cvfixnum((FIXTYPE) SCROLL_PAGE);
  616.   set_slot_value(item, s_page_increment, page);
  617.     
  618.   if (! has_item_size(item)) {
  619.     DialogScrollGetDefaultSize(item, &width, &height);
  620.     set_slot_value(item, s_size, integer_list_2(width, height));
  621.   }
  622.   
  623.   return(item);
  624. }
  625.  
  626. /* :VALUE Method */
  627. LVAL xsscroll_item_value()
  628. {
  629.   LVAL item;
  630.   int set, value;
  631.   
  632.   item = xsgetscrollitem();
  633.   set = moreargs();
  634.   if (set) value = getfixnum(xlgafixnum());
  635.   xllastarg();
  636.   
  637.   return(DialogScrollItemValue(item, set, value));
  638. }
  639.  
  640. /* :MAX Method */
  641. LVAL xsscroll_item_max()
  642. {
  643.   LVAL item;
  644.   int set, value;
  645.   
  646.   item = xsgetscrollitem();
  647.   set = moreargs();
  648.   if (set) value = getfixnum(xlgafixnum());
  649.   xllastarg();
  650.   
  651.   return(DialogScrollItemMax(item, set, value));
  652. }
  653.  
  654. /* :MIN Method */
  655. LVAL xsscroll_item_min()
  656. {
  657.   LVAL item;
  658.   int set, value;
  659.   
  660.   item = xsgetscrollitem();
  661.   set = moreargs();
  662.   if (set) value = getfixnum(xlgafixnum());
  663.   xllastarg();
  664.   
  665.   return(DialogScrollItemMin(item, set, value));
  666. }
  667.  
  668. /* :SCROLL-ACTION Method */
  669. LVAL xsscroll_item_action()
  670.   LVAL item, action/*, result rewritten JKL*/;
  671.   
  672.   item = xsgetdialogitem();
  673.   xllastarg();
  674.   
  675.   action = slot_value(item, s_action);
  676. /*  result = (action != NIL) ? xlapply(pushargs(action, NIL)) : NIL;*/
  677.   return(/*result*/(action != NIL) ? xlapply(pushargs(action, NIL)) : NIL);
  678. }
  679.  
  680. /***********************************************************************/
  681. /***********************************************************************/
  682. /**                                                                   **/
  683. /**                       LIST-ITEM-PROTO Methods                     **/
  684. /**                                                                   **/
  685. /***********************************************************************/
  686. /***********************************************************************/
  687.  
  688. /* Is this a list-item? */
  689. int list_item_p(x)
  690.     LVAL x;
  691. {
  692.   return (kind_of_p(x, getvalue(s_list_item_proto)));
  693. }
  694.  
  695. /* get a list item from the stack */
  696. LVAL xsgetlistitem()
  697. {
  698.   LVAL x;
  699.   x = xlgetarg();
  700.   if (! list_item_p(x)) xlerror("not a list item", x);
  701.   return(x);
  702. }
  703.  
  704. /* :ISNEW Method */
  705. LVAL xslist_item_isnew()
  706. {
  707.   LVAL item, data, columns;
  708.   int width, height;
  709.   
  710.   item = xsgetlistitem();
  711.   data = xlgetarg();
  712.   
  713.   if (listp(data)) data = coerce_to_vector(data);
  714.   else data = copyarray(data);
  715.   set_slot_value(item, s_list_data, data);
  716.   
  717.   get_initial_item_values(item, FALSE);
  718.   
  719.   if (! xlgetkeyarg(sk_columns, &columns) || ! fixp(columns)
  720.       || getfixnum(columns) < 1) columns = cvfixnum((FIXTYPE) 1);
  721.   set_slot_value(item, s_columns, columns);
  722.   
  723.   if (! has_item_size(item)) {
  724.     DialogListGetDefaultSize(item, &width, &height);
  725.     set_slot_value(item, s_size, integer_list_2(width, height));
  726.   }
  727.   
  728.   return(item);
  729. }
  730.  
  731. /* :DO-ACTION Method */
  732. LVAL xslist_item_action()
  733.   LVAL item, action, double_click/*, result rewritten JKL*/;
  734.   item = xsgetlistitem();
  735.   double_click = (moreargs() && xlgetarg() != NIL) ? s_true : NIL;
  736.   xllastarg();
  737.   
  738.   action = slot_value(item, s_action);
  739. /*  result = (action != NIL) ? xsfuncall1(action, double_click) : NIL;*/
  740.   return(/*result*/(action != NIL) ? xsfuncall1(action, double_click) : NIL);
  741. }
  742.  
  743. /* :SET-TEXT Method */
  744. LVAL xslist_item_text()
  745. {
  746.   LVAL item, data, index, value;
  747.   char *text;
  748.     
  749.   item = xsgetlistitem();
  750.   index = xlgetarg();
  751.   value = xlgastring();
  752.   text = (char *) getstring(value);
  753.   xllastarg();
  754.  
  755.   data = slot_value(item, s_list_data);
  756.   if (simplevectorp(data))
  757.     setelement(data, rowmajorindex(data, consa(index), FALSE), value);
  758.   else if (arrayp(data))
  759.     setelement(arraydata(data), rowmajorindex(data, index, FALSE), value);
  760.   else xlerror("not an array", data);
  761.   DialogListItemSetText(item, index, text);
  762.   return(NIL);
  763. }
  764.  
  765. /* :SELECTION Method */
  766. LVAL xslist_item_selection()
  767. {
  768.   LVAL item, index;
  769.   int set;
  770.   
  771.   item = xsgetlistitem();
  772.   set = moreargs();
  773.   if (set) index = xlgetarg();
  774.   xllastarg();
  775.   
  776.   return(DialogListItemSelection(item, set, index));
  777. }
  778.