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 / src3.lzh / Mac / macdialogs1.c < prev    next >
C/C++ Source or Header  |  1990-07-30  |  18KB  |  623 lines

  1. /* macdialogs1 - Low Level Dialog Objects for Macintosh                */
  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 "dialogs.h"
  8.  
  9. extern doDialog(), closeDialog(), clobberDialog();
  10.  
  11. /* layout definitions */
  12. # define MAX_ENTRY_LENGTH 30
  13. # define SCROLL_MIN 0
  14. # define SCROLL_MAX 100
  15. # define CHOICE_HEIGHT 20
  16.  
  17.  
  18. /***********************************************************************/
  19. /***********************************************************************/
  20. /**                                                                   **/
  21. /**                       Internal Dialog Functions                   **/
  22. /**                                                                   **/
  23. /***********************************************************************/
  24. /***********************************************************************/
  25.  
  26. /***********************************************************************/
  27. /**                                                                   **/
  28. /**                          Utility Functions                        **/
  29. /**                                                                   **/
  30. /***********************************************************************/
  31.  
  32. DialogItemData *GetDialogItemData(theDialog)
  33.     DialogPtr theDialog;
  34. {
  35.   char *p;
  36.   
  37.   p = (char *) *GetDialogData(theDialog);
  38.   return((DialogItemData *) (p + sizeof(DialogData)));
  39. }
  40.  
  41. DialogItemData FindItemData(theDialog, item)
  42.     DialogPtr theDialog;
  43.     LVAL item;
  44. {
  45.   int n = DialogItemCount(theDialog);
  46.   DialogItemData *data, *itemData;
  47.   
  48.   data = GetDialogItemData(theDialog);
  49.   for (itemData = nil; n > 0 && itemData == nil; n--, data++)
  50.     if (data->object == item) itemData = data;
  51.   
  52.   return(*itemData);
  53. }
  54.  
  55. truncateListEntry(s)
  56.     char *s;
  57. {
  58.   if (strlen(s) > MAX_ENTRY_LENGTH) {
  59.     s = s + MAX_ENTRY_LENGTH - 3;
  60.     s[0] = '.'; s[1] = '.'; s[2] = '.'; s[3] = '\0';
  61.   }
  62. }
  63.  
  64. check_alloc(p, check_nil)
  65.     char *p;
  66.     Boolean check_nil;
  67. {
  68.   if (check_nil && p == nil)
  69.     xlfail("allocation failed - null pointer or handle retirned");
  70.   if (MemErr)
  71.     xlfail("allocation failed - MemErr reported");
  72. }
  73.  
  74. /***********************************************************************/
  75. /**                                                                   **/
  76. /**                         DIALOG-PROTO Methods                      **/
  77. /**                                                                   **/
  78. /***********************************************************************/
  79.  
  80. static MakeDialogItemData(dialog, items, data)
  81.     LVAL dialog;
  82.     Handle *items, *data;
  83. {
  84.   int numItems;
  85.  
  86.   numItems = count_hardware_items(slot_value(dialog, s_items)) + 1;
  87.   *items = NewHandle(2 + 14 * numItems);
  88.   check_alloc(*items, true);
  89.   zero_ptr(**items, 2 + 14 * numItems);
  90.   **(short **)(*items) = numItems - 1;
  91.   
  92.   *data = NewHandle(sizeof(DialogData) + numItems * sizeof(DialogItemData));
  93.   check_alloc(*data, true);
  94.   zero_ptr(**data, sizeof(DialogData) + numItems * sizeof(DialogItemData));
  95. }
  96.  
  97. static pascal void OutlineDefaultButton(theDialog, item)
  98.     DialogPtr theDialog;
  99.     short item;
  100. {
  101.   Rect r;
  102.   short itemType;
  103.   Handle theItem;
  104.   
  105.   item = ((DialogPeek) theDialog)->aDefItem;
  106.   if (item < 1 || item > DialogItemCount(theDialog)) return;
  107.   
  108.   GetDItem(theDialog, item, &itemType, &theItem, &r);
  109.   if (itemType != ctrlItem + btnCtrl) return;
  110.   
  111.   PenSize(3, 3);
  112.   InsetRect(&r, -4, -4);
  113.   FrameRoundRect(&r, 16, 16);
  114. }
  115.  
  116. static SetDialogItemData(dialog)
  117.     LVAL dialog;
  118. {
  119.   DialogPtr theDialog;
  120.   Rect r;
  121.   DialogItemData *data;
  122.   DialogData *dialogData;
  123.   LVAL items = slot_value(dialog, s_items);
  124.   
  125.   theDialog = (DialogPtr) GETDIALOGADDRESS(dialog);
  126.   if (theDialog == nil) xlfail("dialog not allocated");
  127.   
  128.   SetDialogObject(theDialog, dialog);
  129.   
  130.   SetRect(&r, 0, 0, 0, 0);
  131.   SetDItem(theDialog, 1, userItem, (Handle) OutlineDefaultButton, &r);
  132.   ((DialogPeek) theDialog)->aDefItem = 1;
  133.   
  134.   data = GetDialogItemData(theDialog);
  135.   dialogData = *GetDialogData(theDialog);
  136.   data[0].type = NULL_ITEM;
  137.   data[0].itemNumber = 1;
  138.   data[0].itemHandle = nil;
  139.   dialogData->count = 1;
  140.   
  141.   InstallItemList(theDialog, items);
  142. }
  143.  
  144. static InstallItemList(theDialog, items)
  145.     DialogPtr theDialog;
  146.     LVAL items;
  147. {
  148.   for (; consp(items); items = cdr(items))
  149.     if (consp(car(items))) InstallItemList(theDialog, car(items));
  150.     else InstallItem(theDialog, car(items));
  151. }
  152.  
  153. static FindItemType(item)
  154.     LVAL item;
  155. {
  156.   if (consp(item)) return(ITEM_LIST);
  157.   else if (button_item_p(item)) return(BUTTON_ITEM);
  158.   else if (toggle_item_p(item)) return(TOGGLE_ITEM);
  159.   else if (text_item_p(item)) return(TEXT_ITEM);
  160.   else if (choice_item_p(item)) return(CHOICE_ITEM);
  161.   else if (scroll_item_p(item)) return(SCROLL_ITEM);
  162.   else if (list_item_p(item)) return(LIST_ITEM);
  163.   else xlerror("item of unknown type");
  164. }
  165.   
  166. static InstallItem(theDialog, item)
  167.     DialogPtr theDialog;
  168.     LVAL item;
  169. {
  170.   int type;
  171.   
  172.   if (! dialog_item_p(item)) xlerror("not a dialog item", item);
  173.   
  174.   type = FindItemType(item);
  175.   
  176.   switch (type) {
  177.   case BUTTON_ITEM: InstallButtonItem(theDialog, item); break;
  178.   case TOGGLE_ITEM: InstallToggleItem(theDialog, item); break;
  179.   case CHOICE_ITEM: InstallChoiceItem(theDialog, item); break;
  180.   case MESSAGE_ITEM:
  181.   case TEXT_ITEM:   InstallTextItem(theDialog, item); break;
  182.   case SCROLL_ITEM: InstallScrollItem(theDialog, item); break;
  183.   case REAL_SCROLL_ITEM:
  184.   case LIST_ITEM:   InstallListItem(theDialog, item); break;
  185.   default: xlfail("unkown item type");
  186.   }
  187. }
  188.  
  189. static InstallButtonItem(theDialog, item)
  190.     DialogPtr theDialog;
  191.     LVAL item;
  192. {
  193.   InstallControlItem(theDialog, item, BUTTON_ITEM);
  194. }
  195.  
  196. static InstallToggleItem(theDialog, item)
  197.     DialogPtr theDialog;
  198.     LVAL item;
  199. {
  200.   InstallControlItem(theDialog, item, TOGGLE_ITEM);
  201. }
  202.  
  203. static InstallTextItem(theDialog, item)
  204.     DialogPtr theDialog;
  205.     LVAL item;
  206. {
  207.   Rect r;
  208.   DialogItemData *data;
  209.   DialogData *dialogData;
  210.   Handle theItem;
  211.   int type, itemIndex;
  212.   char *text;
  213.   Point loc, size;
  214.   
  215.   dialogData = *GetDialogData(theDialog);
  216.   itemIndex = ++(dialogData->count);
  217.   
  218.   if (! stringp(slot_value(item, s_text))) 
  219.     xlerror("not a string", slot_value(item, s_text));
  220.   text = (char *) getstring(slot_value(item, s_text));
  221.     
  222.   loc = ListToPoint(slot_value(item, s_location));
  223.   size = ListToPoint(slot_value(item, s_size));
  224.   SetRect(&r, loc.h, loc.v, loc.h + size.h, loc.v + size.v);
  225.     
  226.   type = (slot_value(item, s_editable)) ? editText : statText;
  227.   
  228.   theItem = NewHandle(1);
  229.   SetDItem(theDialog, itemIndex, type, theItem, &r);
  230.   check_alloc(theItem, true);
  231.   strcpy(buf, text);
  232.   convert_newlines(buf);
  233.   CtoPstr(buf);
  234.   SetIText(theItem, buf);
  235.   if (type == editText) SelIText(theDialog, itemIndex, 0, strlen(text));
  236.   check_alloc(theItem, true);
  237.  
  238.   data = GetDialogItemData(theDialog);
  239.   data[itemIndex - 1].type = TEXT_ITEM;
  240.   data[itemIndex - 1].itemNumber = itemIndex;
  241.   data[itemIndex - 1].itemHandle = theItem;
  242.   data[itemIndex - 1].object = item;
  243. }
  244.  
  245. static InstallChoiceItem(theDialog, item)
  246.     DialogPtr theDialog;
  247.     LVAL item;
  248. {
  249.   LVAL titles, temp;
  250.   Rect r;
  251.   DialogItemData *data;
  252.   DialogData *dialogData;
  253.   Handle theItem;
  254.   int type, procID, itemIndex, clusterLeader, clusterSize, initial;
  255.   char *text;
  256.   Point loc, size;
  257.   
  258.   dialogData = *GetDialogData(theDialog);
  259.   
  260.   titles = slot_value(item, s_text);
  261.     
  262.   loc = ListToPoint(slot_value(item, s_location));
  263.   size = ListToPoint(slot_value(item, s_size));
  264.   size.v = CHOICE_HEIGHT;
  265.     
  266.   type = ctrlItem + radCtrl;
  267.   procID = radioButProc;
  268.   
  269.   if (! listp(titles)) xlerror("not a list", titles);
  270.   clusterLeader = dialogData->count + 1;
  271.   clusterSize = llength(titles);
  272.   for (; consp(titles); titles = cdr(titles)) {
  273.     if (! stringp(car(titles))) xlerror("not a string", car(titles));
  274.     text = (char *) getstring(car(titles));
  275.  
  276.     dialogData = *GetDialogData(theDialog);
  277.     itemIndex = ++(dialogData->count);
  278.     SetRect(&r, loc.h, loc.v, loc.h + size.h, loc.v + size.v);
  279.     loc.v += CHOICE_HEIGHT;
  280.     CtoPstr(text);
  281.     theItem = (Handle) NewControl(theDialog, &r, text, true,
  282.                                   0, 0, 1, procID, (long) item);
  283.     PtoCstr(text);
  284.     check_alloc(theItem, true);
  285.     SetDItem(theDialog, itemIndex, type, theItem, &r);
  286.  
  287.     data = GetDialogItemData(theDialog);
  288.     data[itemIndex - 1].type = CHOICE_ITEM;
  289.     data[itemIndex - 1].itemNumber = itemIndex;
  290.     data[itemIndex - 1].itemHandle = theItem;
  291.     data[itemIndex - 1].object = item;
  292.     data[itemIndex - 1].clusterLeader = clusterLeader;
  293.     data[itemIndex - 1].clusterSize = clusterSize;
  294.   }
  295.   data = GetDialogItemData(theDialog);
  296.   temp = slot_value(item, s_value);
  297.   initial = (fixp(temp)) ? getfixnum(temp) : 0;
  298.   initial = ((initial >= 0 && initial < clusterSize) ? initial : 0) + clusterLeader - 1;
  299.   SetCtlValue((ControlHandle) data[initial].itemHandle, 1);
  300. }
  301.  
  302. static InstallScrollItem(theDialog, item)
  303.     DialogPtr theDialog;
  304.     LVAL item;
  305. {
  306.   Rect r;
  307.   DialogItemData *data;
  308.   DialogData *dialogData;
  309.   Handle theItem;
  310.   int low, high, value;
  311.   int type, procID, itemIndex;
  312.   Point loc, size;
  313.   LVAL temp;
  314.   
  315.   dialogData = *GetDialogData(theDialog);
  316.   itemIndex = ++(dialogData->count);
  317.   
  318.   loc = ListToPoint(slot_value(item, s_location));
  319.   size = ListToPoint(slot_value(item, s_size));
  320.     
  321.   type = userItem;
  322.   procID = scrollBarProc;
  323.   
  324.   temp = slot_value(item, s_min_value);
  325.   low = fixp(temp) ? getfixnum(temp) : SCROLL_MIN;
  326.   temp = slot_value(item, s_max_value);
  327.   high = fixp(temp) ? getfixnum(temp) : SCROLL_MAX;
  328.   temp = slot_value(item, s_value);
  329.   value = (fixp(temp)) ? getfixnum(temp) : low;
  330.  
  331.   SetRect(&r, loc.h, loc.v, loc.h + size.h, loc.v + size.v);
  332.   theItem = (Handle) NewControl(theDialog, &r, "\p", true,
  333.                                 value, low, high, procID, (long) item);
  334.   check_alloc(theItem, true);
  335.   SetDItem(theDialog, itemIndex, type, nil, &r);
  336.  
  337.   data = GetDialogItemData(theDialog);
  338.   data[itemIndex - 1].type = SCROLL_ITEM;
  339.   data[itemIndex - 1].itemNumber = itemIndex;
  340.   data[itemIndex - 1].itemHandle = theItem;
  341.   data[itemIndex - 1].object = item;
  342. }
  343.  
  344. static pascal void drawList(theDialog, item)
  345.     DialogPtr theDialog;
  346.     short item;
  347. {
  348.   Rect r;
  349.   DialogItemData *data;
  350.   int type;
  351.   ListHandle theList;
  352.   
  353.   data = GetDialogItemData(theDialog);
  354.   theList = (ListHandle) data[item - 1].itemHandle;
  355.   type = data[item - 1].type;
  356.   
  357.   if (type == LIST_ITEM) {
  358.     LUpdate(thePort->visRgn, theList);
  359.     r = (*theList)->rView;
  360.     InsetRect(&r, -1, -1);
  361.     FrameRect(&r);
  362.   }
  363. }
  364.  
  365. static InstallListItem(theDialog, item)
  366.     DialogPtr theDialog;
  367.     LVAL item;
  368. {
  369.   Rect r, b;
  370.   DialogItemData *data;
  371.   DialogData *dialogData;
  372.   ListHandle theItem;
  373.   int type, itemIndex, columns, n, m, i;
  374.   Point loc, size, cell;
  375.   LVAL listData, next, temp;
  376.   Boolean vscroll, hscroll;
  377.   char *s;
  378.   
  379.   dialogData = *GetDialogData(theDialog);
  380.   itemIndex = ++(dialogData->count);
  381.   
  382.   loc = ListToPoint(slot_value(item, s_location));
  383.   size = ListToPoint(slot_value(item, s_size));
  384.     
  385.   type = userItem;
  386.   
  387.   listData = slot_value(item, s_list_data);
  388.   
  389.   if (! listp(listData) && ! arrayp(listData)) listData = NIL;
  390.   if (listp(listData) || simplevectorp(listData)) {
  391.     n = (listp(listData)) ? llength(listData) : getsize(listData);
  392.     m = 1;
  393.   }
  394.   else if (matrixp(listData)) {
  395.     n = getfixnum(getelement(displacedarraydim(listData), 0));
  396.     m = getfixnum(getelement(displacedarraydim(listData), 1));
  397.   }
  398.   else xlerror("this form of data is not yet supported", listData);
  399.   temp = slot_value(item, s_columns);
  400.   if (! fixp(temp) || getfixnum(temp) < 1) columns = 1;
  401.   else columns = getfixnum(temp);
  402.   hscroll = (columns < m) ? true : false;
  403.   vscroll = (n * 16 > size.v - ((hscroll) ? 15 : 0)) ? true : false;
  404.  
  405.   SetRect(&b, 0, 0, columns, n);
  406.   SetRect(&r, loc.h, loc.v, loc.h + size.h, loc.v + size.v);
  407.   if (vscroll) r.right -= 15;
  408.   if (hscroll) r.bottom -= 15;
  409.   
  410.   cell.h = 0; cell.v = 0;
  411.   theItem = LNew(&r, &b, cell, 0, theDialog, true, false, hscroll, vscroll);
  412.   check_alloc(theItem, true);
  413.   if (slot_value(item, s_multiple) != NIL)
  414.     (*theItem)->selFlags = lExtendDrag | lNoDisjoint;
  415.   else (*theItem)->selFlags = lOnlyOne;
  416.  
  417.   if (columns < m) LAddColumn(m - columns, columns, theItem);
  418.   if (vscroll) r.right += 15;
  419.   if (hscroll) r.bottom += 15;
  420.   check_alloc(theItem, true);
  421.   
  422.   SetDItem(theDialog, itemIndex, userItem, (Handle) drawList, &r);
  423.  
  424.   if (arrayp(listData)) listData = arraydata(listData);
  425.   for (cell.v = 0, i = 0; cell.v < n; cell.v++)
  426.     for (cell.h = 0; cell.h < m; cell.h++, i++) {
  427.       next = getnextelement(&listData, i);
  428.       s = (stringp(next)) ? (char *) getstring(next) : "";
  429.       strcpy(buf, s);
  430.       truncateListEntry(buf);
  431.       LSetCell(buf, strlen(buf), cell, theItem);
  432.       check_alloc(theItem, true);
  433.     }
  434.  
  435.   data = GetDialogItemData(theDialog);
  436.   data[itemIndex - 1].type = LIST_ITEM;
  437.   data[itemIndex - 1].itemNumber = itemIndex;
  438.   data[itemIndex - 1].itemHandle = (Handle) theItem;
  439.   data[itemIndex - 1].object = item;
  440. }
  441.  
  442. static InstallControlItem(theDialog, item, which)
  443.     DialogPtr theDialog;
  444.     LVAL item;
  445.     int which;
  446. {
  447.   Rect r;
  448.   DialogItemData *data;
  449.   DialogData *dialogData;
  450.   Handle theItem;
  451.   int type, value, low, high, procID, itemIndex;
  452.   char *text;
  453.   Point loc, size;
  454.   LVAL val;
  455.   
  456.   dialogData = *GetDialogData(theDialog);
  457.   itemIndex = ++(dialogData->count);
  458.   
  459.   if (! stringp(slot_value(item, s_text))) 
  460.     xlerror("not a string", slot_value(item, s_text));
  461.   text = (char *) getstring(slot_value(item, s_text));
  462.     
  463.   loc = ListToPoint(slot_value(item, s_location));
  464.   size = ListToPoint(slot_value(item, s_size));
  465.   SetRect(&r, loc.h, loc.v, loc.h + size.h, loc.v + size.v);
  466.     
  467.   value = 0; low = 0; high = 1; 
  468.   switch (which) {
  469.   case BUTTON_ITEM: procID = pushButProc; type = ctrlItem + btnCtrl; break;
  470.   case TOGGLE_ITEM: procID = checkBoxProc; type = ctrlItem + chkCtrl; break;
  471.   default: xlfail("unknown item type");
  472.   }
  473.   
  474.   CtoPstr(text);
  475.   theItem = (Handle) NewControl(theDialog, &r, text, true,
  476.                                 value, low, high, procID, (long) item);
  477.   PtoCstr(text);
  478.   check_alloc(theItem, true);
  479.   SetDItem(theDialog, itemIndex, type, theItem, &r);
  480.  
  481.   data = GetDialogItemData(theDialog);
  482.   data[itemIndex - 1].type = which;
  483.   data[itemIndex - 1].itemNumber = itemIndex;
  484.   data[itemIndex - 1].itemHandle = theItem;
  485.   data[itemIndex - 1].object = item;
  486.   
  487.   if (which == TOGGLE_ITEM) {
  488.     val = slot_value(item, s_value);
  489.     SetCtlValue((ControlHandle) theItem, (val != NIL));
  490.   }
  491. }
  492.  
  493. static zero_ptr(p, n)
  494.     char *p;
  495.     int n;
  496. {
  497.   while (n-- > 0) *p++ = 0;
  498. }
  499.  
  500. static count_hardware_items(items)
  501.     LVAL items; 
  502.   LVAL temp;
  503.   int n;
  504.   
  505.   if (! consp (items)) return(0);
  506.   else 
  507.     for (n = 0; consp(items); items = cdr(items))
  508.       switch(FindItemType(car(items))) {
  509.       case CHOICE_ITEM: 
  510.         temp = slot_value(car(items), s_text);
  511.         if (! consp(temp)) xlerror("not a list", temp);
  512.         n += llength(temp);
  513.         break;
  514.       case ITEM_LIST: n += count_hardware_items(car(items)); break;
  515.       default: n += 1;
  516.       }
  517.   return(n);
  518. }
  519.  
  520. /***********************************************************************/
  521. /***********************************************************************/
  522. /**                                                                   **/
  523. /**                       Public Dialog Functions                     **/
  524. /**                                                                   **/
  525. /***********************************************************************/
  526. /***********************************************************************/
  527.  
  528. DialogAllocate(dialog)
  529.   LVAL dialog;
  530. {
  531.   DialogPtr theDialog;
  532.   Point loc, size;
  533.   Rect bounds;
  534.   char *title;
  535.   Boolean visible, goAway;
  536.   int type;
  537.   WindowPtr behind;
  538.   Handle items, ref;
  539.   
  540.   if (check_dialog_address(dialog)) DialogRemove(dialog);
  541.     
  542.   if (! stringp(slot_value(dialog, s_title))) 
  543.     xlerror("not a string", slot_value(dialog, s_title));
  544.   title = (char *) getstring(slot_value(dialog, s_title));
  545.   
  546.   loc = ListToPoint(slot_value(dialog, s_location));
  547.   loc.v += MBarHeight;
  548.   size = ListToPoint(slot_value(dialog, s_size));
  549.   SetRect(&bounds, loc.h, loc.v, loc.h + size.h, loc.v + size.v);
  550.   
  551.   visible = true;
  552.   goAway = (slot_value(dialog, s_go_away) != NIL) ? true : false;
  553.   
  554.   if (slot_value(dialog, s_type) == s_modeless)
  555.     type = noGrowDocProc;
  556.   else type = dBoxProc;
  557.   
  558.   behind = (WindowPtr) -1;
  559.   
  560.   MakeDialogItemData(dialog, &items, &ref);
  561.     
  562.   CtoPstr(title);
  563.   theDialog = NewDialog(nil, &bounds, title, visible, type,
  564.                         behind, goAway, (long) ref, items);
  565.   PtoCstr(title);
  566.   check_alloc(theDialog, true);
  567.   SkelDialog(theDialog, doDialog, closeDialog, clobberDialog);
  568.   set_dialog_address(theDialog, dialog);
  569.  
  570.   SetDialogItemData(dialog);
  571.   DialogSetDefaultButton(dialog, slot_value(dialog, s_default_button));
  572. }
  573.  
  574. DialogRemove(dialog)
  575.     LVAL dialog;
  576. {
  577.   if (check_dialog_address(dialog))
  578.       SkelRmveDlog(GETDIALOGADDRESS(dialog));
  579.   if (objectp(dialog)) standard_hardware_clobber(dialog);
  580. }
  581.  
  582. DialogSetDefaultButton(dialog, item)
  583.     LVAL dialog, item;
  584. {
  585.   DialogItemData itemData;
  586.   DialogPtr theDialog;
  587.   GrafPtr savePort;
  588.   int noDflt;
  589.   
  590.   if (item != NIL && ! button_item_p(item))
  591.     xlerror("not a button item", item);
  592.  
  593.   set_slot_value(dialog, s_default_button, item);
  594.     
  595.   theDialog = (DialogPtr) GETDIALOGADDRESS(dialog);
  596.   if (theDialog != nil) {
  597.     noDflt = (((DialogPeek) theDialog)->aDefItem == 1);
  598.   
  599.     if (item == NIL)
  600.       ((DialogPeek) theDialog)->aDefItem = 1;
  601.     else {
  602.       itemData = FindItemData(theDialog, item);
  603.       ((DialogPeek) theDialog)->aDefItem = itemData.itemNumber;
  604.     }
  605.   
  606.   
  607.     if (! noDflt) {
  608.       GetPort(&savePort);
  609.       SetPort(theDialog);
  610.       EraseRect(&theDialog->portRect);
  611.       SetPort(savePort);
  612.       DrawDialog(theDialog);
  613.     }
  614.   }
  615. }
  616.  
  617. convert_newlines(s)
  618.     char *s;
  619. {
  620.   for (; *s != '\0'; s++) if (*s == '\n') *s = RETURNCHAR;
  621. }
  622.