#include #include /* some f2c string conversions */ char *_stringF2C(char *title,int len_title){ char *headtitle=NULL; int i=len_title-1; /* get c string length of fortran string */ while ((i>=0)&&(title[i]==' ')) i--; /* if it has characters copy them else return a NULL string */ /* return a headtitle as NULL pointer is not accepted by Dialog's 3-04-06*/ headtitle=malloc((i+1)*sizeof(char)); headtitle[i+1]='\0'; if (i>=0){ while (i>=0){headtitle[i]=title[i];i--;} } return headtitle; } void _stringC2F(char *F,char *C,int lenF){ int i=0; if (C!=NULL) { while (iextra; /* fix up scroll bars */ r = app_get_control_area(c); f = lb->parent->font; h = app_font_height(f) + 1; /* count items in list */ list = lb->list; if (list != NULL) for (max=0; list[max] != NULL; max++) continue; else max = 0; /* determine vertical scrollbar placement */ pagesize = (r.height -BOX_BORDER -8) / h; max = max - pagesize; if (max < 0) max = 0; if (lb->top > max) lb->top = max; lb->vert_max = max; lb->vert_pagesize = pagesize; app_set_control_area(lb->vert, rect(r.width-SCROLL_SIZE, 0, SCROLL_SIZE, r.height-BOX_BORDER)); app_change_scroll_bar(lb->vert, lb->top, max, pagesize); /* find maximum item width */ if (list != NULL) { for (i=max=0; list[i] != NULL; i++) { w = app_font_width(f, list[i], (int) strlen(list[i])); if (max < w) max = w; } } else max = 0; /* determine horizontal scrollbar placement */ pagesize = r.width -BOX_BORDER -8; max = max - pagesize; if (max < 0) max = 0; if (lb->left > max) lb->left = max; lb->horz_max = max; lb->horz_pagesize = pagesize; app_set_control_area(lb->horz, rect(0, r.height-SCROLL_SIZE, r.width-BOX_BORDER, SCROLL_SIZE)); app_change_scroll_bar(lb->horz, lb->left, max, pagesize); /* resize the list box itself */ app_set_control_area(lb->box, rect(0, 0, r.width-BOX_BORDER, r.height-BOX_BORDER)); } /* ende copy uit listbox.c */ void add_list_item__(c,txt,lentxt) int *c,lentxt;char *txt;{ ListBox *lb; Control *control; char **new_list; int lenlist; control=(Control*)*c; lb = control->extra; if (lb->num_lines) { /* exist */ lb->num_lines+=1; lb->list=(char**)realloc(lb->list,(lb->num_lines+1)*sizeof(char*)); } else { /* new */ lb->num_lines=1; lb->list=(char**)malloc((lb->num_lines+1)*sizeof(char*)); } lb->list[lb->num_lines]=0; lb->list[lb->num_lines-1]=_stringF2C(txt, lentxt); if (lb->parent->value >= lb->num_lines)lb->parent->value = lb->num_lines-1; app_listbox_resize(control); app_redraw_control(lb->box); } int get_list_box_item__(c) int *c;{ return app_get_list_box_item((Control*)*c); } /* text-boxes */ int new_text_box__(win,rect,list,lentxt) int *win,*rect;char *list;{ int res; char *txt; Rect r={rect[0],rect[1],rect[2],rect[3]}; printf("listbox %d %d\n",*win,lentxt); txt=_stringF2C(list, lentxt); res = (int)app_new_text_box((Window*)*win,r,txt); free(txt); return res; } void get_control_text__(b,lentxt,c) int *c,lentxt;char* b;{ /* Fortran G77 character *k txt,get_control_text txt=get_control_text(Control) The char_function seems be handled as a procedure . The first parameter is the position of the answer . Second the length of the answer . Third the first parameter given in the caller . */ _stringC2F(b,app_get_control_text((Control*)*c),lentxt); } /* buttons */ int new_button__(w,rect,txt,hook,lentxt) int *w,*rect,*hook,lentxt;char *txt;{ Rect r={rect[0],rect[1],rect[2],rect[3]}; return (int)app_new_button((Window*)*w,r,_stringF2C(txt,lentxt),(ControlFunc)get_hook(hook)); }