📄 xaw_i.c
字号:
if (currdir[0] == '/' && currdir[1] == '\0' && filename[0] == '.' && filename[1] == '.' && filename[2] == '\0') continue; if(S_ISDIR(st.st_mode)) { strcat(filename, "/"); d_num++; } else { f_num++; } put_string_table(&strtab, filename, strlen(filename)); i++; } dirlist = (String *)make_string_array(&strtab); dirlist_top = (String)dirlist[0]; /* Marking for free() */ qsort (dirlist, i, sizeof (char *), dirlist_cmp); snprintf(local_buf, sizeof(local_buf), "%d Directories, %d Files", d_num, f_num); XawListChange(list,dirlist,0,0,True); } else strcpy(local_buf, "Can't read directry"); XtVaSetValues(load_info,XtNlabel,local_buf,NULL);#ifdef ORIGINAL XtVaSetValues(label,XtNlabel,currdir,NULL);#else /* RAKK/HIOENS */ XtVaSetValues(label,XtNlabel,strsav(currdir),NULL);#endif /* RAKK/HIOENS */ strcpy(basepath, currdir); if(currdir[strlen(currdir) - 1] != '/') strcat(currdir, "/");#ifdef ORIGINAL XtVaSetValues(load_d,XtNvalue,currdir,NULL);#else /* RAKK/HIOENS */ XtVaSetValues(load_d,XtNvalue,strsav(currdir),NULL);#endif /* RAKK/HIOENS */}static int Red_depth,Green_depth,Blue_depth;static int Red_sft,Green_sft,Blue_sft;static int bitcount( int d ){ int rt=0; while( (d & 0x01)==0x01 ){ d>>=1; rt++; } return(rt);}static int sftcount( int *mask ){ int rt=0; while( (*mask & 0x01)==0 ){ (*mask)>>=1; rt++; } return(rt);}static int getdisplayinfo(){ XWindowAttributes xvi; XGetWindowAttributes( disp, XtWindow(trace), &xvi ); if( 16 <= xvi.depth ){ Red_depth=(xvi.visual)->red_mask; Green_depth=(xvi.visual)->green_mask; Blue_depth=(xvi.visual)->blue_mask; Red_sft=sftcount(&(Red_depth)); Green_sft=sftcount(&(Green_depth)); Blue_sft=sftcount(&(Blue_depth)); Red_depth=bitcount(Red_depth); Green_depth=bitcount(Green_depth); Blue_depth=bitcount(Blue_depth); } return(xvi.depth);}static void drawBar(int ch,int len, int xofs, int column, Pixel color) { static Pixel column1color0; static GC gradient_gc[T2COLUMN]; static Pixmap gradient_pixmap[T2COLUMN]; static int gradient_set[T2COLUMN]; static int depth,init=1; static XColor x_boxcolor; static XGCValues gv; int i; int col; XColor x_color; if( init ){ for(i=0;i<T2COLUMN;i++) gradient_set[i]=0; depth=getdisplayinfo(); if( 16 <= depth && app_resources.gradient_bar != 0 ){ x_boxcolor.pixel=boxcolor; XQueryColor(disp,DefaultColormap(disp,0),&x_boxcolor); gv.fill_style = FillTiled; gv.fill_rule = WindingRule; } init=0; } if( 16 <= depth && app_resources.gradient_bar != 0 ){ if( column < T2COLUMN ){ col=column; if( column==1 ){ if( gradient_set[0]==0 ){ column1color0=color; col=0; } else if(gradient_set[1]==0 && column1color0!=color){ col=1; } else{ if( column1color0==color ) col=0; else col=1; } } if( gradient_set[col]==0 ){ unsigned long pxl; gradient_pixmap[col]=XCreatePixmap(disp,XtWindow(trace),BARH2_SPACE[column],1, DefaultDepth(disp,screen)); x_color.pixel=color; XQueryColor(disp,DefaultColormap(disp,0),&x_color); for(i=0;i<BARH2_SPACE[column];i++){ int r,g,b; r=(x_boxcolor.red)+(x_color.red-x_boxcolor.red)*i/BARH2_SPACE[column]; g=(x_boxcolor.green)+(x_color.green-x_boxcolor.green)*i/BARH2_SPACE[column]; b=(x_boxcolor.blue)+(x_color.blue-x_boxcolor.blue)*i/BARH2_SPACE[column]; if(r<0) r=0; if(g<0) g=0; if(b<0) b=0; r >>= 8; g >>= 8; b >>= 8; if(255<r) r=255; if(255<g) g=255; if(255<b) b=255; pxl = (r>>(8-Red_depth))<<Red_sft; pxl |= (g>>(8-Green_depth))<<Green_sft; pxl |= (b>>(8-Blue_depth))<<Blue_sft; XSetForeground(disp, gct, pxl); XDrawPoint(disp,gradient_pixmap[col],gct,i,0); } gv.tile = gradient_pixmap[col]; gradient_gc[col] = XCreateGC( disp,XtWindow(trace),GCFillStyle|GCFillRule|GCTile,&gv ); gradient_set[col]=1; } XSetForeground(disp, gct, boxcolor); XFillRectangle(XtDisplay(trace),XtWindow(trace),gct, xofs+len+2,TRACEV_OFS+BAR_SPACE*ch+2, pl[plane].w[column] -len -4,BAR_HEIGHT); gv.ts_x_origin=xofs+2 - BARH2_SPACE[column]+len; XChangeGC(disp,gradient_gc[col],GCTileStipXOrigin,&gv); XFillRectangle(XtDisplay(trace),XtWindow(trace),gradient_gc[col], xofs+2,TRACEV_OFS+BAR_SPACE*ch+2, len,BAR_HEIGHT); } } else{ /* XSetForeground(disp, gct, bgcolor); */ /* ?? */ XSetForeground(disp, gct, boxcolor); XFillRectangle(XtDisplay(trace),XtWindow(trace),gct, xofs+len+2,TRACEV_OFS+BAR_SPACE*ch+2, pl[plane].w[column] -len -4,BAR_HEIGHT); XSetForeground(disp, gct, color); XFillRectangle(XtDisplay(trace),XtWindow(trace),gct, xofs+2,TRACEV_OFS+BAR_SPACE*ch+2, len,BAR_HEIGHT); }}static void drawProg(int ch,int val,int column,int xofs, Boolean do_clean) { char s[4]; if(do_clean) { XSetForeground(disp, gct, boxcolor); XFillRectangle(XtDisplay(trace),XtWindow(trace),gct, xofs+2,TRACEV_OFS+BAR_SPACE*ch+2, pl[plane].w[4]-4,BAR_HEIGHT); } XSetForeground(disp, gct, black); sprintf(s, "%3d", val); XDrawString(XtDisplay(trace), XtWindow(trace), gct, xofs+5,TRACEV_OFS+BAR_SPACE*ch+16,s,3);}static void drawPan(int ch,int val,Boolean setcolor) { int ap,bp; int x; static XPoint pp[3]; if (val < 0) return; if (setcolor) { XSetForeground(disp, gct, boxcolor); XFillRectangle(XtDisplay(trace),XtWindow(trace),gct, pl[plane].ofs[CL_PA]+2,TRACEV_OFS+BAR_SPACE*ch+2, pl[plane].w[CL_PA]-4,BAR_HEIGHT); XSetForeground(disp, gct, pancolor); } x= pl[plane].ofs[CL_PA]+3; ap= 31 * val/127; bp= 31 -ap -1; pp[0].x= ap+ x; pp[0].y= 12 +BAR_SPACE*(ch+1); pp[1].x= bp+ x; pp[1].y= 8 +BAR_SPACE*(ch+1); pp[2].x= bp+ x; pp[2].y= 16 +BAR_SPACE*(ch+1); XFillPolygon(XtDisplay(trace),XtWindow(trace),gct,pp,3, (int)Nonconvex,(int)CoordModeOrigin);}static void draw1Chan(int ch,int val,char cmd) { if (cmd == '*' || cmd == '&') drawBar(ch, (int)(val*BARSCALE2), pl[plane].ofs[CL_VE], CL_VE, barcol[ch]);}static void drawVol(int ch,int val) { drawBar(ch, (int)(val*BARSCALE3), pl[plane].ofs[CL_VO], CL_VO, volcolor);}static void drawExp(int ch,int val) { drawBar(ch, (int)(val*BARSCALE4), pl[plane].ofs[CL_EX], CL_EX, expcolor);}static void drawReverb(int ch,int val) { drawBar(ch, (int)(val*BARSCALE5), pl[plane].ofs[CL_RE], CL_RE, revcolor);}static void drawChorus(int ch,int val) { drawBar(ch, (int)(val*BARSCALE5), pl[plane].ofs[CL_CH], CL_CH, chocolor);}static void drawPitch(int ch,int val) { char s[3]; XSetForeground(disp, gct, boxcolor); XFillRectangle(XtDisplay(trace),XtWindow(trace),gct, pl[plane].ofs[CL_PI]+2,TRACEV_OFS+BAR_SPACE*ch+2, pl[plane].w[CL_PI] -4,BAR_HEIGHT); XSetForeground(disp, gct, barcol[9]); if (val != 0) { if (val<0) { sprintf(s, "="); } else { if (val == 0x2000) sprintf(s, "*"); else if (val>0x3000) sprintf(s, ">>"); else if (val>0x2000) sprintf(s, ">"); else if (val>0x1000) sprintf(s, "<"); else sprintf(s, "<<"); } XDrawString(XtDisplay(trace), XtWindow(trace), gct, pl[plane].ofs[CL_PI]+4,TRACEV_OFS+BAR_SPACE*ch+16,s,strlen(s)); }}static void drawInstname(int ch, char *name) { int len; if(!ctl->trace_playing) return; if(plane!=0) return; XSetForeground(disp, gct, boxcolor); XFillRectangle(XtDisplay(trace),XtWindow(trace),gct, pl[plane].ofs[CL_IN]+2,TRACEV_OFS+BAR_SPACE*ch+2, pl[plane].w[CL_IN] -4,BAR_HEIGHT); XSetForeground(disp, gct, ((Panel->is_drum[ch])? capcolor:black)); len = strlen(name); XDrawString(XtDisplay(trace), XtWindow(trace), gct, pl[plane].ofs[CL_IN]+4,TRACEV_OFS+BAR_SPACE*ch+15, name,(len>disp_inst_name_len)? disp_inst_name_len:len);}static void drawDrumPart(int ch, int is_drum) { if(!ctl->trace_playing) return; if(plane!=0) return; if (is_drum) barcol[ch]=app_resources.drumvelocity_color; else barcol[ch]=app_resources.velocity_color;}static void draw1Note(int ch,int note,int flag) { int i, j; XSegment dot[3]; j = note -9; if (j<0) return; if (flag == '*') { XSetForeground(disp, gct, playcolor); } else if (flag == '&') { XSetForeground(disp, gct, ((keyG[j].col == black)? suscolor:barcol[0])); } else { XSetForeground(disp, gct, keyG[j].col); } for(i= 0; i<3; i++) { dot[i].x1 = keyG[j].xofs +i; dot[i].y1 = TRACEV_OFS+ keyG[j].k[i].y+ ch*BAR_SPACE; dot[i].x2 = dot[i].x1; dot[i].y2 = dot[i].y1 + keyG[j].k[i].l; } XDrawSegments(XtDisplay(trace),XtWindow(trace),gct,dot,3);}static void drawKeyboardAll(Display *disp,Drawable pix) { int i, j; XSegment dot[3]; XSetForeground(disp, gc, tracecolor); XFillRectangle(disp,pix,gc,0,0,BARH_OFS8,BAR_SPACE); XSetForeground(disp, gc, boxcolor); XFillRectangle(disp,pix,gc,BARH_OFS8,0,TRACE_WIDTH-BARH_OFS8+1,BAR_SPACE); for(i= 0; i<KEY_NUM; i++) { XSetForeground(disp, gc, keyG[i].col); for(j= 0; j<3; j++) { dot[j].x1 = keyG[i].xofs +j; dot[j].y1 = keyG[i].k[j].y; dot[j].x2 = dot[j].x1; dot[j].y2 = dot[j].y1 + keyG[i].k[j].l; } XDrawSegments(disp,pix,gc,dot,3); }}static void drawBank(int ch,int val) { char s[4]; XSetForeground(disp, gct, black); sprintf(s, "%3d", (int)val); XDrawString(disp,XtWindow(trace),gct, pl[plane].ofs[CL_BA],TRACEV_OFS+BAR_SPACE*ch+15, s,strlen(s));}#define VOICENUM_WIDTH 56static void drawVoices(void) { XSetForeground(disp, gct, tracecolor); XFillRectangle(disp,XtWindow(trace),gct,voices_num_width +4, MAX_XAW_MIDI_CHANNELS*BAR_SPACE+TRACEV_OFS+1,VOICENUM_WIDTH,TRACE_FOOT); sprintf(local_buf, "%3d/%d", last_voice, voices); XSetForeground(disp, gct, capcolor); XDrawString(disp, XtWindow(trace),gct,voices_num_width+6, MAX_XAW_MIDI_CHANNELS*BAR_SPACE+TRACEV_OFS+16,local_buf,strlen(local_buf));}static void drawTitle(char *str) { char *p = str; if(ctl->trace_playing) { if (!strcmp(p, "(null)")) p = UNTITLED_STR; XSetForeground(disp, gcs, capcolor);#ifdef I18N XmbDrawString(XtDisplay(trace), XtWindow(trace),ttitlefont,gcs, VOICES_NUM_OFS+TTITLE_OFS, MAX_XAW_MIDI_CHANNELS*BAR_SPACE+TRACEV_OFS+ ttitlefont0->ascent +3, p,strlen(p));#else XDrawString(XtDisplay(trace), XtWindow(trace),gcs, VOICES_NUM_OFS+TTITLE_OFS, MAX_XAW_MIDI_CHANNELS*BAR_SPACE+TRACEV_OFS+ ttitlefont->ascent +3, p,strlen(p));#endif }}static void toggletrace(Widget w,XEvent *e,String *v,Cardinal *n) { if((e->xbutton.button == 1) || e->type == KeyPress) { plane ^= 1; redrawTrace(True); }}/*ARGSUSED*/static void exchgWidth(Widget w,XEvent *e,String *v,Cardinal *n) { Dimension w1,h1,w2,h2; XtVaGetValues(toplevel,XtNheight,&h1,NULL); ++currwidth; currwidth %= 3; /* number of rotatewidth */ w1 = rotatewidth[currwidth]; XtMakeResizeRequest(toplevel,w1,h1,&w2,&h2); resizeAction(w,NULL,NULL,NULL); }/*ARGSUSED*/static void redrawAction(Widget w,XEvent *e,String *v,Cardinal *n) { if(e->xexpose.count == 0) redrawTrace(True);}/*ARGSUSED*/static Boolean cursor_is_in = False;static void redrawCaption(Widget w,XEvent *e,String *v,Cardinal *n) { char *p; int i; if(e->type == EnterNotify) { cursor_is_in = True; XSetForeground(disp, gct, capcolor); } else { cursor_is_in = False; XSetForeground(disp, gct, tracecolor); } XFillRectangle(disp,XtWindow(trace),gct, 0,0,TRACE_WIDTH,TRACEV_OFS); XSetBackground(disp, gct, (e->type == EnterNotify)? expcolor:tracecolor); XSetForeground(disp, gct, (e->type == EnterNotify)? tracecolor:capcolor); for(i=0; i<pl[plane].col; i++) { p = pl[plane].cap[i]; XDrawString(disp,XtWindow(trace),gct,pl[plane].ofs[i]+4,16,p,strlen(p)); }}static void redrawTrace(Boolean draw) { int i; /* Dimension w1, h1; */ char s[3]; if(!ctl->trace_playing) return; if(!XtIsRealized(trace)) return; /* XtVaGetValues(trace,XtNheight,&h1,XtNwidth,&w1,NULL); */ /* XSetForeground(disp, gct, tracecolor); */ /* XFillRectangle(disp,XtWindow(trace),gct, 0,0,w1,h1); */ /* XSetForeground(disp, gct, boxcolor); */ /* XFillRectangle(disp,XtWindow(trace),gct, BARH_OFS8 -1,TRACEV_OFS, TRACE_WIDTH-BARH_OFS8+1, BAR_SPACE*MAX_XAW_MIDI_CHANNELS); */ for(i= 0; i<MAX_XAW_MIDI_CHANNELS; i++) { XGCValues gv; gv.tile = layer[plane]; gv.ts_x_origin = 0; gv.ts_y_origin = TRACEV_OFS+i*BAR_SPACE; XChangeGC(disp,gc_xcopy,GCTile|GCTileStipXOrigin|GCTileStipYOrigin,&gv); XFillRectangle(disp,XtWindow(trace),gc_xcopy, 0, TRACEV_OFS+i*BAR_SPACE, TRACE_WIDTH,BAR_SPACE); /* XCopyArea(disp, layer[plane], XtWindow(trace), gct, 0,0, TRACE_WIDTH,BAR_SPACE, 0, TRACEV_OFS+i*BAR_SPACE); */ } XSetForeground(disp, gct, capcolor); XDrawLine(disp,XtWindow(trace),gct,BARH_OFS0,TRACEV_OFS+BAR_SPACE*MAX_XAW_MIDI_CHANNELS, TRACE_WIDTH-1,TRACEV_OFS+BAR_SPACE*MAX_XAW_MIDI_CHANNELS); XSetForeground(disp, gct, black); for(i= 1; i<MAX_XAW_MIDI_CHANNELS+1; i++) { sprintf(s, "%2d", i); XDrawString(disp, XtWindow(trace), gct, pl[plane].ofs[CL_C]+2,TRACE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -