📄 xlabel.c
字号:
obj = objlist; while(obj) { if((lf = obj->labels)) { while(lf) { if(lf->first_label) rewrite_labels(lf); lf = lf->next; } } if(strcmp(obj->name,program->name)) waves_send(obj->name,"unmark all t",dumcol,dumtime); obj = obj->next; }}/*********************************************************************/char *meth_quit(ob, args) Objects *ob; char *args;{ cleanup(); terminate_communication(registry_name); exit(0);}/**********************************************************************/get_decor_size(height, width) int *height, *width;{ static Rect rect, *rec; Frame fr; if(panel && daddy) { frame_get_rect(daddy, &rect); rec = (Rect*)xv_get(panel, WIN_RECT); *height = rect.r_height - rec->r_height; *width = rect.r_width - rec->r_width; /* One sleazy hack deserves another... */ if((*height < 0) || (*width < 0)) *height = *width = 0; if(debug_level){ fprintf(stderr,"decor: h:%d w:%d\n",*height, *width); fprintf(stderr,"fr.height:%d panel.height:%d\n",rect.r_height,rec->r_height); } return(TRUE); } else return(FALSE);}/**********************************************************************/set_display_size(ob) Objects *ob;{ if(ob) { int height, width, nf, head; Wobject *w; Labelfile *lf; Frame fr; Rect rect; lf = ob->labels; nf = 1; get_decor_size(&head, &width); while(lf && (lf = lf->next))nf++; if(plotting_charts(w = (Wobject*)get_wobject(ob))) height = (SCREEN_HEIGHT - ob->yloc - ob->height) - head; else height = (nf * wind_height); if(w) w->label_size = (nf * wind_height); if(debug_level) fprintf(stderr, "set_display_size: height=%d width=%d ob_height=%d ob_yloc=%d wind_height=%d N=%d dec_w:%d dec_y:%d\n", height,ob->width,ob->height,ob->yloc,wind_height,nf,width,head); if(height > 0) { ob->resize_status |= RESIZE_STATUS_FORCED_RESIZE; fr = (Frame)xv_get(ob->canvas,XV_OWNER); frame_get_rect(fr, &rect);#ifdef SG rect_construct(&rect, ob->xloc + (width/2) + xlabel_frame_hoff, ob->yloc + ob->height + head + xlabel_frame_voff, ob->width, height + head);#else rect_construct(&rect, ob->xloc + xlabel_frame_hoff, ob->yloc + ob->height + xlabel_frame_voff, ob->width, height + head);#endif frame_set_rect(fr, &rect); } return(TRUE); } return(FALSE);}/**********************************************************************/initial_bad_values(){ m_time = start = sec_cm = -1.0; color = -1; width = height = loc_x = loc_y = -123; *signame = 0; type = 0; sep = ';'; nfields = 1; *comment = 0;}/**********************************************************************/install_signal_name(ob,name) Objects *ob; char *name;{ if(*name) { if(ob->signal_name) free(ob->signal_name); ob->signal_name = malloc(MAXPATHLEN); strcpy(ob->signal_name,name); }}/**********************************************************************/char *meth_make_object(ob,args) Objects *ob; char *args;{ Objects *ob2, *new_objects(); Labelfile *lf; Frame frame; Canvas canvas; Rect rect; static void doit(), repaint(), resize(); static Notify_value iocatcher(); extern Objects *objlist, *new_objects(); extern Methods base_methods; extern int cmap_depth; char mes[MES_BUF_SIZE]; initial_bad_values(); if(get_args(args,&a0) && *objectname) { if(debug_level) fprintf(stderr,"xlabel.meth_make_object(%s)\n",args); if(!(ob2 = (Objects *)get_receiver(objectname))) { /* does it already exist? */ if((ob2 = new_objects(objectname))) { /* create one */ frame = xv_create(XV_NULL, FRAME, XV_VISUAL, visual_ptr, XV_LABEL, objectname, XV_WIDTH, ob2->width + 5, XV_HEIGHT, wind_height, WIN_X, ob2->xloc, WIN_Y, ob2->yloc + ob2->height, XV_SHOW, FALSE, FRAME_INHERIT_COLORS, FALSE, WIN_CLIENT_DATA, ob2, 0); window_wash(frame ); exv_attach_icon(frame, ERL_NOBORD_ICON, objectname, TRANSPARENT); /* fill window code in pseudo_event */ event_window(&pseudo_event) = (Xv_object) frame; canvas = xv_create(frame, CANVAS, XV_X, 0, XV_Y, 0, CANVAS_RETAINED, FALSE, CANVAS_FIXED_IMAGE, FALSE, CANVAS_AUTO_SHRINK, TRUE, CANVAS_AUTO_EXPAND, TRUE, CANVAS_CMS_REPAINT, FALSE, CANVAS_PAINTWINDOW_ATTRS, WIN_DEPTH, cmap_depth, XV_VISUAL, visual_ptr, 0, OPENWIN_NO_MARGIN, TRUE, XV_WIDTH, WIN_EXTEND_TO_EDGE, XV_HEIGHT, WIN_EXTEND_TO_EDGE, CANVAS_NO_CLIPPING, TRUE, WIN_CLIENT_DATA, ob2, 0); xv_set(canvas_paint_window(canvas), WIN_CONSUME_EVENTS, LOC_DRAG, WIN_IN_TRANSIT_EVENTS, LOC_MOVE, LOC_WINEXIT, LOC_WINENTER, WIN_ASCII_EVENTS, 0, WIN_IGNORE_EVENTS, KBD_USE, KBD_DONE, 0, WIN_EVENT_PROC, doit, WIN_BIT_GRAVITY, ForgetGravity, 0); window_wash(canvas ); window_fit(frame); notify_interpose_destroy_func(frame, kill_signal_view); cmap(canvas); ob2->next = objlist; objlist = ob2; ob2->canvas = canvas; /* When these were set in the xv_create above, XViews would bomb calling repaint within xv_create (in 1.0 beta at least). */ xv_set(canvas, CANVAS_REPAINT_PROC, repaint, CANVAS_RESIZE_PROC, resize, 0); window_fit(frame); xv_set(frame, XV_SHOW,TRUE, 0); } else { /* couldn't allocate a new_object() */ fprintf(stderr, "meth_make_object: Allocation failure in new_object()\n."); return(Null); } update_object_panel(ob2); } /* completed new Objects creation */ if(!have_all_display_attributes(ob2)) get_display_attributes(ob2); if(*inputname || *chartname) { install_signal_name(ob2,signame); set_display_size(ob2); initial_setup(); if((lf = ob2->labels)) { if(*fontfile && strcmp(fontfile,lf->fontfile)) { strcpy(lf->fontfile, fontfile); lf->font = xv_pf_open(lf->fontfile); xv_set(lf->menu,XV_FONT,lf->font,0); if(lf->first_label) plot_labels(lf); } if((! lf->first_label) && (color >= 0)) lf->color = color; if(m_time >= 0.0) { /* was time specified in make command? */ if(color < 0) color = lf->color; if(! do_label_menu(lf, m_time, 0, color, NULL, 0)) { return(Null); } } } return(Ok); } } return(Null);}/*********************************************************************/update_menu_panel(menu) char *menu;{ xv_set(menu_item, PANEL_VALUE, menu, 0); strcpy(menufile,menu); return;}/*********************************************************************/update_object_panel(ob) Objects *ob;{ xv_set(object_item, PANEL_VALUE, ob->name, 0); strcpy(objectname,ob->name); return;}/*********************************************************************/update_file_panel(lf) Labelfile *lf;{ xv_set(file_item, PANEL_VALUE, lf->label_name, 0); strcpy(inputname,lf->label_name); return;}/*********************************************************************/send_all_marks(lf) Labelfile *lf;{ Label *l; Objects *ob; if(lf && (ob = lf->obj)) { l = lf->first_label; while(l) { waves_send(ob->name,"mark",l->color,l->time); l = l->next; } return(TRUE); } return(FALSE);}char *meth_print(ob,str) Objects *ob; char *str;{ Display *printer, *theDisp; XColor *colorcell_defs; int cells, i; int theScreen; Colormap theCmap; char command[MAXPATHLEN]; XpOrientation_t graphic_orientation; static char file[NAMELEN],object[NAMELEN], chart[NAMELEN]; static Selector a0 = {"file","%s",file,NULL}, a1 = {"name","%s",object,&a0}, a2 = {"chart","%s",chart,&a1}; Labelfile *lf; Frame fr; Objects *o; int got, sendit; *file = 0; *object = 0; *chart = 0; sendit = 0; got = get_args(str,&a2); if(ob == program) { /* Was this a message to the program? */ if(!(got && (o = (Objects*)get_receiver(object)))) return(Null); ob = o; } if(!ob) return(Null); printer = setup_xp_from_globals(ob->canvas); if (!printer) return Null; start_xp(printer, ob->canvas);/* re-render image here */ redo_display(ob);/**/ finish_xp(printer, ob->canvas); return(Ok);}/*********************************************************************/char *meth_print_EPS_temp(ob, str) Objects *ob; char *str;{ static char filename[NAMELEN]; static int id; static Selector s1 = {"output", "#qstr", filename, NULL}, s0 = {"return_id", "%d", (char *) &id, &s1}; Frame frame; int x, y; char reply[200]; Display *printer; Rect rect; *filename = '\0'; id = 0; get_args(str, &s0); if (ob && ob->canvas) { if (debug_level) fprintf(stderr, "meth_print_EPS_temp(%s, \"%s\")\n", (ob->name) ? ob->name : "<NULL>", (str) ? str : "<NULL>"); frame = xv_get(ob->canvas, XV_OWNER); if (*filename && id && frame) { if (!xv_get(frame, FRAME_CLOSED)) { frame_get_rect(frame, &rect); x = rect.r_left; y = rect.r_top; sprintf(reply, "%s completion %d loc_x %d loc_y %d", host, id, x, y); printer = setup_xp_EPS_temp(ob->canvas, filename, NULL, 0); if (!printer) return; start_xp(printer, ob->canvas); redo_display(ob); finish_xp(printer, ob->canvas); mess_write(reply); return Ok; } } } sprintf(reply, "%s completion %d", host, id); if (debug_level) fprintf(stderr, "meth_print_EPS_temp: Null return.\n"); mess_write(reply); return Null;}/*********************************************************************/char *meth_redisplay(ob,str) Objects *ob; char *str;{ if(ob && ob_exists(ob) && str && ob->canvas) { initial_bad_values(); if(get_args(str,&a0) && have_all_display_attributes(ob)) { set_display_size(ob); redo_display(ob); return(Ok); } else get_display_attributes(ob); } else if(debug_level) fprintf(stderr,"Null object or arg list to meth_redisplay()\n"); return(Null);}/*********************************************************************/get_display_attributes(ob) Objects *ob;{ char mes[MES_BUF_SIZE]; int n, id; if(ob && ob_exists(ob) && ob->name) { start = sec_cm = -1.0; width = height = loc_x = loc_y = -1; id = set_return_value_callback(meth_redisplay,ob); if(ob->signal_name && *(ob->signal_name)) { sprintf(mes,"%s get attributes display function %s file %s return_id %d\n", ob->name, thisprog, ob->signal_name, id); } else { sprintf(mes,"%s get attributes display function %s return_id %d\n",ob->name, thisprog, id); } mess_write(mes); return(TRUE); } return(FALSE);}/*********************************************************************/have_all_display_attributes(ob) Objects *ob;{ if(ob) {/* if(!(ob->signal_name && *ob->signal_name)) install_signal_name(ob,signame); */ if((width > 0) && (height > 0) && (start != -1.0) && (sec_cm > 0) && (loc_x != -123) && (loc_y != -123)) { ob->width = width; ob->height = height; ob->start = start; ob->sec_cm = sec_cm; ob->xloc = loc_x; ob->yloc = loc_y; if(debug_level) fprintf(stderr, "have_disp_attr: x:%d y:%d height:%d width:%d\n", loc_x,loc_y,height,width); return(TRUE); } } return(FALSE);}ob_exists(ob) Objects *ob;{ extern Objects *objlist; Objects *op = objlist; while(op) { if(op == ob) return(TRUE); op = op->next; } if(debug_level) fprintf(stderr,"Object no longer exists!\n"); return(FALSE);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -