⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xcursors.c

📁 speech signal process tools
💻 C
📖 第 1 页 / 共 2 页
字号:
{    Xv_Window	    *pw;    Rect	    *rec;    register int    x, y, w_msg, w_win,		    len = 20,		    step = 10,		    offset = (len + step) >> 1;    int		    y1, y2;    char	    mes[100];    double	    dur;    if(doing_print_graphic && print_only_plot)      return(TRUE);    which++;			/* make it easier to decode */    if(!v || !v->canvas)	return FALSE;      pw = (Xv_Window*)canvas_pixwin(v->canvas);    rec = (Rect *) xv_get((Xv_opaque)pw, WIN_RECT);    if (v->scrollbar && (v->scrollbar->height > 0) && v->scrollbar->is_on)     y1 = v->scrollbar->y + v->scrollbar->height;    else     y1 = 0;    y2 = rec->r_height - 1;    if (which & 2) {	x = v->time_to_x(v, v->lmarker_time);	/* left marker */	for (y = y2; y >= y1; y -= step+len) {	    pw_vector(pw, x, y, x, (y - len),		      PIX_COLOR(MARKER_COLOR)|(PIX_SRC^PIX_DST), MARKER_COLOR);	}    }    if (which & 1) {	x = v->time_to_x(v, v->rmarker_time);	/* right marker */	for (y=y2-offset; y >= y1; y -= step+len) {	    pw_vector(pw, x, y, x, (y - len),		      PIX_COLOR(MARKER_COLOR)|(PIX_SRC^PIX_DST), MARKER_COLOR);	}    }    dur = v->rmarker_time - v->lmarker_time;    if(dur > 0.0)	sprintf(mes, "D:%8.5f   L:%9.5f   R:%9.5f (F:%8.2f)",	    dur, v->lmarker_time, v->rmarker_time, 1.0/dur);    else	sprintf(mes, "D:%8.5f   L:%9.5f   R:%9.5f (F:--------)",	    dur, v->lmarker_time, v->rmarker_time);    w_win = rec->r_width;    w_msg = 38*def_font_width;	/* Part of mes thru R:%9.5f.  Try to keep				   visible in small windows while avoiding				   overlap with Time:... messages (see				   print_x in xplot_data.c and print_spect_x				   in xspect.c). */    x = (w_win/2 >= w_msg) ? w_win/2	: (w_win >= w_msg) ? w_win - w_msg	: 0;    pw_text(pw, x, 14,	    PIX_SRC|PIX_COLOR(FOREGROUND_COLOR), def_font, mes);    return TRUE;}/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/plot_hmarkers(v, which)    View	    *v;    int		    which;	/* 0=>bottom; 1=>top; 2=>both */{  Xv_Window	    *pw;  Rect	    *rec;  register int    x, y, w_msg, w_win,  len = 20,  step = 10,  offset = (len + step) >> 1;  int		    x1, x2, chanh;  char	    mes[100];  double	    dur;  if(doing_print_graphic && print_only_plot)    return(TRUE);  which++;			/* make it easier to decode */  if(!v || !v->canvas)    return FALSE;    pw = (Xv_Window*)canvas_pixwin(v->canvas);  rec = (Rect *) xv_get((Xv_opaque)pw, WIN_RECT);  x1 = 0;  x2 = rec->r_width - 1;  chanh = v->cursor_channel;  if (which & 2) {    v->cursor_channel = v->tmarker_chan;    y = v->yval_to_y(v, v->tmarker_yval); /* top marker */    for (x = x1; x < x2; x += step+len) {      pw_vector(pw, x, y, x + len, y,		PIX_COLOR(MARKER_COLOR)|(PIX_SRC^PIX_DST), MARKER_COLOR);    }  }  if (which & 1) {    v->cursor_channel = v->bmarker_chan;    y = v->yval_to_y(v, v->bmarker_yval); /* bottom marker */    for (x = x1+offset; x < x2; x += step+len) {      pw_vector(pw, x, y, x + len, y,		PIX_COLOR(MARKER_COLOR)|(PIX_SRC^PIX_DST), MARKER_COLOR);    }  }  v->cursor_channel = chanh;  return TRUE;}  /*********************************************************************/object_xor_mark(o, time, color)     Object *o;     double time;     int color;{  Signal *s;  View *v;  double tsave;  if(o && (s = o->signals)) {    while(s) {      v = s->views;      while(v) {	if(v->cursor_plot) {	  tsave = v->cursor_time;	  v->cursor_time = time;	  v->cursor_plot(v,color);	  v->cursor_time = tsave;	}	v = v->next;      }      s = s->others;    }  }}/*********************************************************************/view_xor_marks(v)     View *v;{  Signal *s = v->sig;  Object *o;  Marks *m;  double tsave;  int count, col;  if(s && (o = (Object*)s->obj) && (m = o->marks)) {    count = 0;			/* keep track of odd-even */    while(m) {      tsave = v->cursor_time;      v->cursor_time = m->time;      v->cursor_plot(v,(col = m->color));      v->cursor_time = tsave;      m = m->next;      count++;    }    if(count & 1) {		/* an odd number of marks? */      tsave = v->cursor_time;      v->cursor_time = ET(v);      v->cursor_plot(v,col);      v->cursor_time = tsave;    }  }}      /*********************************************************************//* HOMEBREW SCROLLING FACILITY:   The problem is that Sun doesn't have a generally useful scrollbar   object: the "slider" has limited capability and takes yet another   precious file descriptor; the Sun "scrollbar" is inextricably coupled   to the subwindow in which it appears and can't be used in a general way.      The homebrew scrolling facility looks like this:  There will be a   region near the top of the canvas which will be sensitive to scrolling   requests by the left, middle and right buttons.  Left will move the   waveform point at the cursor to the left edge of the window; right   will move the wafeform point at the left edge to the cursor position;   middle will center the display at the point in the file proportional   to the ratio of the cursor position re the left edge to the window   width.  A narrow bar indicating the location and proportion of the   file displayed will be plotted at the top edge of the window.   Waveform cursor motion will not occur when the pointer is in the   scroll-sensitive region (??).   *//*********************************************************************/plot_scrollbar(sb)    register S_bar *sb;{  Pixwin      *pw;  Rect        *rec;  extern int doing_print_graphic, print_only_plot;  /* do not draw scroll bar if doing print graphic and global    print_only_plot is non-zero */  if (doing_print_graphic && print_only_plot)	return;  if (sb && (sb->height > 0) && sb->is_on && sb->view &&      sb->view->canvas) {    pw = (Pixwin *) canvas_paint_window(sb->view->canvas);    rec = (Rect *) xv_get((Xv_opaque)pw, WIN_RECT);    pw_write(pw, sb->x, sb->y, sb->width, sb->height,	     PIX_COLOR(sb->color)|PIX_SRC, NULL, 0, 0);    pw_vector(pw, *(sb->view->x_offset), sb->height + sb->y,	      rec->r_left + rec->r_width - 1, sb->height + sb->y,              PIX_COLOR(sb->color)|PIX_SRC, sb->color);    pw_vector(pw, *(sb->view->x_offset), sb->y,	      rec->r_left + rec->r_width - 1, sb->y,              PIX_COLOR(RETICLE_COLOR)|PIX_SRC, RETICLE_COLOR);    if (*(sb->view->x_offset))         pw_vector(pw, *(sb->view->x_offset), sb->height + sb->y,		  *(sb->view->x_offset), 0,                  PIX_COLOR(RETICLE_COLOR)|PIX_SRC, RETICLE_COLOR);    sb->fresh = -1;    return(TRUE);  }  return(FALSE);}/*********************************************************************/S_bar *new_scrollbar(v)     register View *v;{  register S_bar *sb;  register double sig_dur;  extern int scrollbar_height, readout_bar_height;  if(!(sb = (S_bar*)malloc(sizeof(S_bar)))) {    printf("Allocation problems in new_scrollbar()\n");    return(NULL);  }  sb->height = 5;		/* about the width of the frame border */  if(v)    sb->y = v->readout_height;		/* at top of canvas */  else    sb->y = readout_bar_height;  sb->color = RETICLE_COLOR;	/* change this at will */  sb->view = v;  sb->is_on = TRUE;  sb->fresh = -1;  sb->height = scrollbar_height;  if(v && v->sig) {    sb->x = *v->x_offset + ((v->width - *v->x_offset) *			   (v->start_time - v->sig->start_time)/		       (sig_dur = SIG_DURATION(v->sig)));    sb->width = (v->width - *v->x_offset) * (ET(v) - v->start_time)/sig_dur;    if(! v->scrollbar) v->scrollbar = sb;  }  return(sb);}/*********************************************************************/set_scrollbar(v)     register View *v;{  register S_bar *sb;  register double sig_dur;    if(v && (sb = v->scrollbar)) {    sb->x = *v->x_offset + ((v->width - *v->x_offset) *			   (v->start_time - v->sig->start_time)/		       (sig_dur = SIG_DURATION(v->sig)));    sb->width = (v->width - *v->x_offset) * (ET(v) - v->start_time)/sig_dur;    return(TRUE);  }  return(FALSE);}/*********************************************************************/operate_scrollbar(but, x, view)     register int but, x;     register View *view;{  double page_time;  Signal *sig;  double sig_dur, wind_dur, whereto, fract;  register int id;  if(view && (sig = view->sig)) {    x -= *(view->x_offset);    if(x < 0) x = 0;    fract = ((double)x)/(view->width - *(view->x_offset));    sig_dur = SIG_DURATION(sig);    wind_dur = ET(view) - view->start_time;    switch(but) {    case MS_LEFT:      whereto = view->start_time + (wind_dur * fract);      break;    case MS_MIDDLE:      whereto = sig->start_time + ((sig_dur * fract) - (0.5 * wind_dur));      break;    case MS_RIGHT:      whereto = view->start_time - (wind_dur * fract);      break;    default:      return(FALSE);    }    page(view, view->sig, whereto);  }  return(FALSE);}void plot_time_bar(v,s,sample)     View *v;     Signal *s;     int sample;{  int x;  extern double play_time;  double fraction;  fraction = ((double)sample)/(SIG_DURATION(s) * s->freq);  x = *v->x_offset + ((v->width - *v->x_offset) * fraction);  if( v->scrollbar && v->scrollbar->is_on) {    S_bar *sb = v->scrollbar;    Pixwin      *pw;    Rect        *rec;    pw = (Pixwin *) canvas_paint_window(v->canvas);    rec = (Rect *) xv_get((Xv_opaque)pw, WIN_RECT);    if((x + 4) > v->width)      x = v->width - 4;    if(sb->fresh >= 0)		/* XOR off the old bar */      pw_write(pw, sb->fresh, sb->y, 4, sb->height,	       PIX_COLOR(sb->color)|(PIX_SRC^PIX_DST), NULL, 0, 0);    pw_write(pw, x, sb->y, 4, sb->height,	     PIX_COLOR(sb->color)|(PIX_SRC^PIX_DST), NULL, 0, 0);    sb->fresh = x;  }  play_time = s->start_time + (((double)sample)/s->freq);  if((play_time > v->start_time) &&     (play_time < ET(v))) {    if (v->cursor_plot)	v->cursor_plot(v, CURSOR_COLOR);    v->cursor_time = play_time;    if (v->cursor_plot)	v->cursor_plot(v, CURSOR_COLOR);    if (v->x_print)	v->x_print(v);  } else    file_print_x(v,x);  return;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -