#incldue "seldialo.h"


@implementation SelectionDialog

- (Widget)create /*:(Widget)ww*/
{

  XmString *str; 
  Widget dialog;
  CollectionListMgr<Compound> *coll;
  static int first_time=1;
  int file_len = 6;
  int i = 0;
  
  if (first_time) {
    first_time = 0;
    coll = db->MyCompoundCollection();
    
    str = (XmString *) XtMalloc(sizeof(XmString)*(coll->MyCardinality()));
    
    ListIter<Compound> cmpd_list = ListIter<Compound>(*coll);
    XmString label = XmStringCreateSimple("Compounds");
    
    for (cmpd_list.MoveToTop();
	 cmpd_list; cmpd_list.MoveToNext(),i++) {
      
      // cout << "*" << cmpd_list().MyName() << "*" << endl;
      str[i] = XmStringCreateSimple(cmpd_list().MyName());
    }
    
    dialog = XmCreateSelectionDialog(ww,"Compounds",NULL,0);
    
    XtVaSetValues(dialog,
		  XmNlistLabelString,label,
		  XmNlistItems,str,
		  XmNlistItemCount,coll->MyCardinality(),
		  XmNmustMatch,True,
		  NULL);
    
    XtUnmanageChild(XmSelectionBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
    
    XtUnmanageChild(XmSelectionBoxGetChild(dialog, XmDIALOG_APPLY_BUTTON));
     
    XtAddCallback(dialog,XmNokCallback,theCallback, self);
    
    XtAddCallback(dialog,XmNnoMatchCallback,theCallback, self);
  }
  while(--i >= 0) XmStringFree(str[i]);
  XtFree((char *) str);
  return dialog;
}



@end





