void playlist_list_draw_string(PlayList_List *pl, GdkFont *font, gint line, gint width, gchar *text) { int len; char *tmp; if (cfg.convert_underscore) while ((tmp = strchr(text, '_')) != NULL) *tmp = ' '; if (cfg.convert_twenty) while ((tmp = strstr(text, "%20")) != NULL) { char *tmp2 = tmp + 3; *(tmp++) = ' '; while (*tmp2) *(tmp++) = *(tmp2++); *tmp = '\0'; } len = strlen(text); while (gdk_text_width(font, text, len) > width && len > 4) { len--; text[len - 3] = '.'; text[len - 2] = '.'; text[len - 1] = '.'; text[len] = '\0'; } gdk_draw_text(pl->pl_widget.parent, font, pl->pl_widget.gc, pl->pl_widget.x, pl->pl_widget.y + line * pl->pl_fheight + font->ascent, text, len); }
/* gdk_draw_string * * Modified by Li-Da Lho to draw 16 bits and Multibyte strings * * Interface changed: add "GdkFont *font" to specify font or fontset explicitely */ void gdk_draw_string (GdkDrawable *drawable, GdkFont *font, GdkGC *gc, gint x, gint y, const gchar *string) { gdk_draw_text(drawable, font, gc, x, y, string, strlen(string)); }
void gpk_graph_draw(GtkWidget *widget, /* plot on this widged */ int n, /* number of data points */ gdouble *xcord, gdouble *ycord, /* data */ gdouble xmn,gdouble ymn, /* coordinates of corners */ gdouble xmx,gdouble ymx, int clear, /* clear old plot first */ char *title, /* add a title (only if clear=1) */ GdkColor *color) { GdkPixmap **ppixmap; GdkPoint *points; int i; gint16 width,height; GdkFont *fixed_font; GdkGC *gc; gc = gdk_gc_new(widget->window); gdk_gc_set_foreground(gc, color); if ((ppixmap=findpixmap(widget))) { width = widget->allocation.width; height = widget->allocation.height; if (clear) { /* white background */ gdk_draw_rectangle (*ppixmap, widget->style->white_gc, TRUE,0, 0,width,height); /* title */ #ifdef _WIN32 fixed_font = gdk_font_load ("-misc-fixed-large-r-*-*-*-100-*-*-*-*-*-*"); #else fixed_font = gdk_font_load ("-misc-fixed-medium-r-*-*-*-100-*-*-*-*-iso8859-1"); #endif gdk_draw_text (*ppixmap,fixed_font, widget->style->fg_gc[GTK_WIDGET_STATE (widget)], 0,10,title,strlen(title)); } points = g_malloc(n*sizeof(GdkPoint)); for (i=0; i<n ; i++) { points[i].x =.5+ ((xcord[i]-xmn)*(width-1)/(xmx-xmn)); points[i].y =.5+ ((ycord[i]-ymx)*(height-1)/(ymn-ymx)); } gdk_draw_lines(*ppixmap,gc,points,n); g_free(points); gpk_redraw(*ppixmap,widget); } gdk_gc_destroy(gc); }
gint draw_callback(GtkWidget *widget, GdkEvent *event, Data *data) { int i; for (i = 0; i < NTEXT_COLORS; i++){ char text[20]; int len; sprintf (text, "颜色(Color)是%s色", text_colors[i].name); len = strlen (text); gdk_draw_text (widget->window, data->font1, data->gc[i], 12, 25*(i+1), text, len); gdk_draw_text (widget->window, data->font2, data->gc[i], 140, 25*(i+1), text, len); gdk_draw_text (widget->window, data->font3, data->gc[i], 300, 25*(i+1), "中文字符串", 10); } gdk_draw_rectangle(widget->window, data->gc[0], FALSE, 5, 5, 520, 130); return TRUE; }
void DrawColorText_Raw (GdkPixmap * pixmap, int fontsize, GdkGC * colorGC, gdouble x, gdouble y, char *text, int alignX, int alignY, int textLength) { if (!text) return; if (textLength == -1) textLength = strlen (text); GdkFont *font = GetFontForSize (fontsize); if (!font) return; int sizeX = gdk_text_width (font, text, textLength); int sizeY = gdk_text_height (font, text, textLength); switch (alignX) { case 0: break; case 1: x -= sizeX / 2; break; case 2: x -= sizeX; break; } switch (alignY) { case 0: break; case 1: y += sizeY / 2; break; case 2: y += sizeY; break; case 2 + 1: y += sizeY + 1; break; } gdk_draw_text (pixmap, font, colorGC, x, y, text, textLength); }
/* Draws a number of characters in the given font or fontset. */ int clip_GDK_DRAWTEXT(ClipMachine * ClipMachineMemory) { C_widget *cwid = _fetch_cw_arg(ClipMachineMemory); C_object *cgc = _fetch_cobject(ClipMachineMemory, _clip_spar(ClipMachineMemory, 2)); C_object *font = _fetch_cobject(ClipMachineMemory, _clip_spar(ClipMachineMemory, 3)); gint x = _clip_parni(ClipMachineMemory, 4); gint y = _clip_parni(ClipMachineMemory, 5); gchar *text = _clip_parc(ClipMachineMemory, 6); gint length = _clip_parni(ClipMachineMemory, 7); GdkDrawable *drw = NULL; CHECKCWID(cwid, GTK_IS_WIDGET); CHECKOPT2(2, NUMERIC_type_of_ClipVarType, MAP_type_of_ClipVarType); CHECKCOBJ(cgc, GDK_IS_GC(cgc)); CHECKOPT2(3, NUMERIC_type_of_ClipVarType, MAP_type_of_ClipVarType); CHECKCOBJ(cgc, GDK_IS_FONT(font)); CHECKOPT(4, NUMERIC_type_of_ClipVarType); CHECKOPT(5, NUMERIC_type_of_ClipVarType); CHECKOPT(6, CHARACTER_type_of_ClipVarType); CHECKOPT(7, NUMERIC_type_of_ClipVarType); drw = cwid->widget->window; if (GTK_IS_PIXMAP(cwid->widget)) drw = GTK_PIXMAP(cwid->widget)->pixmap; LOCALE_TO_UTF(text); gdk_draw_text(drw, GDK_FONT(font->object), GDK_GC(cgc->object), x, y, text, length); FREE_TEXT(text); return 0; err: return 1; }
double cmdfile(void) // reads command file /* drives the schedule with stop time yyyy:ddd:hh:mm:ss or LST:hh:mm:ss or just : for immediate scheduling or :n for scheduling for n secs - will wait for source to be within limits followed by keywords: sourcename (any name in catalog) stow calibrate quit clearint // clears intergation record (turns on data file if not already on) [filename] [recmode] roff (turns off data file) freq fcenter_MHz [bandwidth_MHz] mode n for 25 point b for beamswitch */ { double secs, secnow, lst, freq, bw; int i, j, n, line, yr, day, hr, min, se, ss; int da, mn, sc; int ix, iy; char str[256], txt[256]; char *p, *k; FILE *file1; GdkColor color; if ((file1 = fopen(d1.cmdfnam, "r")) == NULL) { printf(" Unable to open %s\n", d1.cmdfnam); return 0.0; } secs = secnow = d1.secs; i = 1; line = 0; ss = 0; k = 0; str[255] = 0; while ((k = fgets(str, 80, file1)) != 0 && i == 1) { line++; // printf("line %d %s",line,str); if (str[0] != '*' && str[0] != ' ' && str[0] != '#' && strlen(str) > 2 && line > d1.cmdfline) { if (str[0] != 'L' && str[0] != ':') { // yyyy:ddd:hh:mm:ss sscanf(str, "%d:%d:%d:%d:%d", &yr, &day, &hr, &min, &se); secs = tosecs(yr, day, hr, min, se); } // d.dtext(440.0, ylim + 40.0, gg, Color.red, "cmd err " + str); if (str[0] == 'L' && strstr(str, "LST")) { // "LST:%2d:%2d:%2d",&hr,&min,&sec hr = min = se = 0; sscanf(str, "LST:%d:%d:%d", &hr, &min, &se); lst = gst(secnow) - d1.lon; secs = hr * 3600.0 + min * 60.0 + se - lst * 86400.0 / (PI * 2.0); if (secs < 0) secs += 86400.0; if (secs > 86400.0) secs -= 86400.0; if (secs < 0) secs += 86400.0; if (secs > 86400.0) secs -= 86400.0; secs += secnow; } // d.dtext(440.0, ylim + 40.0, gg, Color.red, "cmd err " + str); if (str[0] == ':' && str[1] != ' ') { ss = 0; sscanf(str, ":%d", &ss); secs += ss; } // d.dtext(440.0, ylim + 40.0, gg, Color.red, "cmd err " + str); for (n = 0; n < (int) strlen(str); n++) if (str[n] == '\n') str[n] = ' '; if (secs >= secnow) { // System.out.println("secs "+secs+" secnow "+secnow); for (j = 0; j < d1.nsou; j++) { if ((p = strstr(str, sounam[j]))) { strncpy(soutrack, sounam[j], sizeof(soutrack) - 1); if (ss < 2) secs += 2; // add time d1.track = 1; d1.bsw = 0; d1.azoff = 0; d1.eloff = 0; // check for mode if (p && *p) { // note p before *p p = strchr(p, ' '); if (p && *p) { if (strchr(p, 'n')) { d1.scan = 1; } if (strchr(p, 'b')) { d1.bsw = 1; } } } } } if (strstr(str, "azel")) { j = sscanf(str, "%*s %*s %lf %lf", &d1.azcmd, &d1.elcmd); if (j == 2) { if (d1.printout) { toyrday(d1.secs, &yr, &da, &hr, &mn, &sc); printf("%4d:%03d:%02d:%02d:%02d %3s ", yr, da, hr, mn, sc, d1.timsource); printf("cmdf %s", str); } if (ss < 2) secs += 2; // add time d1.track = 0; soutrack[0] = 0; } } if (strstr(str, "offset")) { sscanf(str, "%*s %*s %lf %lf", &d1.azoff, &d1.eloff); } if (strstr(str, "stow")) { d1.azcmd = d1.azlim1; d1.elcmd = d1.ellim1; soutrack[0] = 0; d1.stow = 1; } if (strstr(str, "calibrate")) d1.docal = 1; if (strstr(str, "record")) { d1.record = 1; if (sscanf(str, "%*s %*s %255s", d1.filname) == 1) d1.foutstatus = 1; } if (strstr(str, "quit") && d1.stow == -1) { d1.run = 0; gtk_exit(0); } if (strstr(str, "roff")) d1.record = 0; if (strstr(str, "clearint")) d1.clearint = 1; if (strstr(str, "freq")) { bw = 4.0; sscanf(str, "%*s %*s %lf %lf", &freq, &bw); if (bw > 0 && bw <= 10.0) d1.fbw = bw / d1.bw; if (freq > 1200.0 && freq < 1800.0) { d1.freq = freq; d1.iffreq = d1.freq - d1.lofreq; d1.f1 = d1.iffreq / d1.bw - d1.fbw * 0.5; d1.f2 = d1.iffreq / d1.bw + d1.fbw * 0.5; d1.fc = (d1.f1 + d1.f2) * 0.5; if (d1.printout) { toyrday(d1.secs, &yr, &da, &hr, &mn, &sc); printf("%4d:%03d:%02d:%02d:%02d %3s ", yr, da, hr, mn, sc, d1.timsource); printf("new freq %f %f\n", d1.freq, d1.iffreq); } d1.freqchng = 1; } } } i = 0; ix = midx * 1.05; iy = midy * 0.99; if (d1.displ && str[0]) { color.red = 0; color.green = 0xffff; color.blue = 0; gdk_color_parse("green", &color); gtk_widget_modify_fg(drawing_area, GTK_STATE_NORMAL, &color); gdk_draw_rectangle(pixmap, drawing_area->style->white_gc, TRUE, ix, iy - midy * 0.04, midx * 0.4, midy * 0.05); sprintf(txt, "line %2d %s", line, str); gdk_draw_text(pixmap, fixed_font, drawing_area->style->fg_gc[GTK_STATE_NORMAL], ix, iy, txt, strlen(txt) - 1); } if (d1.printout) { toyrday(d1.secs, &yr, &da, &hr, &mn, &sc); printf("%4d:%03d:%02d:%02d:%02d %3s ", yr, da, hr, mn, sc, d1.timsource); printf("line %2d %s\n", line, str); } } } d1.cmdfline = line; fclose(file1); if (k == 0) { if (d1.displ) { ix = midx * 1.05; iy = midy * 0.99; color.red = 0; color.green = 0xffff; color.blue = 0; gdk_color_parse("green", &color); gtk_widget_modify_fg(drawing_area, GTK_STATE_NORMAL, &color); gdk_draw_rectangle(pixmap, drawing_area->style->white_gc, TRUE, ix, iy - midy * 0.04, midx * 0.4, midy * 0.05); sprintf(txt, "line %2d : end_of_file", line); gdk_draw_text(pixmap, fixed_font, drawing_area->style->fg_gc[GTK_STATE_NORMAL], ix, iy, txt, strlen(txt) - 1); } d1.cmdfl = 0; d1.cmdfline = 0; } return secs; }
void cal(int mode) // command cal { int k; int ix, iy, midxr, ixe; char txt[80]; double av, max, maxf, p, a; float wtt[NSPEC]; GdkColor color; if (mode == 0) { for (k = 0; k < d1.nfreq; k++) bbspec[k] = 0; zerospectra(0); d1.calon = 1; d1.integ3 = 0; } if (mode == 1) { for (k = 0; k < d1.nfreq; k++) bbspec[k] += spec[k]; d1.integ3++; } if (mode == 2) { d1.calon = 0; max = -1e99; maxf = 0; for (k = 0; k < d1.nfreq; k++) { if (k > d1.f1 * d1.nfreq && k < d1.f2 * d1.nfreq) wtt[k] = 1; else wtt[k] = 0; if (spec[k] > max) { max = spec[k]; maxf = k * d1.bw / d1.nfreq + d1.efflofreq; } } if (d1.npoly > NPOLY) d1.npoly = NPOLY; polyfitr(d1.npoly, d1.nfreq, bbspec, wtt, bspec); // for(k=0;k<d1.nfreq;k+=10) printf("k %d wtt %f bbspec %f\n",k,wtt[k],bbspec[k]); if (d1.npoly == 1) for (k = 0; k < d1.nfreq; k++) bspec[k] = bbspec[k]; p = a = 0; for (k = 0; k < d1.nfreq; k++) { if (wtt[k]) { p += bspec[k]; a++; } } av = p / a; for (k = 0; k < d1.nfreq; k++) bspec[k] = bspec[k] / av; d1.calpwr = p / (a * d1.integ3); if (d1.yfac > 1.5 && d1.calmode == 20) d1.tsys = (d1.tcal - d1.yfac * 3.0) / (d1.yfac - 1.0); // put in Tsys assumes CMB of 3 K if (d1.calmode == 0) printf("yfac %f Tsys %f\n", d1.yfac, 290.0 / (d1.yfac - 1.0)); if (d1.caldone == 0 && d1.calmode != 2 && d1.calmode != 3) printf("yfac %f tsys %f pwr %f pwrprev %f calmode %d max_pwr %8.3f MHz\n", d1.yfac, d1.tsys, pwr, pwrprev, d1.calmode, maxf); d1.yfac = 0; // for next cal d1.caldone = 1; if (d1.displ) { color.green = 0xffff; color.red = 0; color.blue = 0; gdk_color_parse("green", &color); gtk_widget_modify_bg(button_cal, GTK_STATE_NORMAL, &color); } } ix = midx * 1.55; ixe = midx * 0.4; midxr = midx * 2 - ix; sprintf(txt, "calibration in progress"); iy = midy * 0.1; if (d1.displ && mode) gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ix, iy, txt, strlen(txt)); iy = midy * 0.1; if (d1.displ && !mode) { gdk_draw_rectangle(pixmap, drawing_area->style->white_gc, TRUE, ix, iy - midy * 0.04, midxr, midy * 0.05); gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ix, iy, txt, strlen(txt)); } if (d1.debug) printf("incal mode %d\n", mode); return; }
/* Redraw the contents of the lcd display. * note: start BORDER pixels down and to the right. * TODO: we could be smart and only redraw what has changed. * This does this work correctly with varriable sized fonts. */ void drawStackLCD(){ int i; int curPos; int strt, stop; GdkGC *drawgc; #ifdef USE_PANGO PangoRectangle rect; int pango_pos; #endif /* draw the stack */ for(i=0; i<lcdHeight; i++){ /* draw the first unhighlighted section of the line */ strt = 0; if(dataSelected == DATA_SELECTED && i>=hiY1 && i<=hiY2){ stop = hiX1; if(stop > lcdWidth) stop = lcdWidth; } else { stop = lcdWidth; } if(stop-strt){ #ifdef USE_PANGO pango_layout_index_to_pos(pango_layout, strt, &rect); pango_pos = rect.x / PANGO_SCALE; gdk_window_clear_area(lcdDA->window, pango_pos + BORDER, i*fontH + BORDER, 2*fontW*(stop-strt), fontH); pango_layout_set_text(pango_layout, &lcdText[i][strt], stop-strt); gdk_draw_layout(lcdDA->window, lcdGC, pango_pos + BORDER + SHIFT, i*fontH + BORDER, pango_layout); #else gdk_window_clear_area(lcdDA->window, strt*fontW + BORDER, i*fontH + BORDER, fontW*(stop-strt), fontH); gdk_draw_text(lcdDA->window, lcdFont, lcdGC, strt*fontW + BORDER, (i+1)*fontH - fontD + BORDER, &lcdText[i][strt], stop-strt); #endif } /* draw the highlighted section of the line */ if(dataSelected == DATA_SELECTED && i>=hiY1 && i<=hiY2){ strt = hiX1; if(strt > lcdWidth) strt = lcdWidth; stop = hiX2+1; if(stop > lcdWidth) stop = lcdWidth; if(stop-strt){ #ifdef USE_PANGO pango_layout_index_to_pos(pango_layout, strt, &rect); pango_pos = rect.x / PANGO_SCALE; gdk_window_clear_area(lcdDA->window, pango_pos + BORDER, i*fontH + BORDER, 2*fontW*(stop-strt), fontH); gdk_draw_rectangle(lcdDA->window, lcdGC, TRUE, pango_pos + BORDER + SHIFT, i*fontH + BORDER, fontW*(stop-strt), fontH); pango_layout_set_text(pango_layout, &lcdText[i][strt], stop-strt); gdk_draw_layout(lcdDA->window, lcdHighlightGC, strt*fontW + BORDER + SHIFT, i*fontH + BORDER, pango_layout); #else gdk_draw_rectangle(lcdDA->window, lcdGC, TRUE, strt*fontW + BORDER, i*fontH + BORDER, fontW*(stop-strt), fontH); gdk_draw_text(lcdDA->window, lcdFont, lcdHighlightGC, strt*fontW + BORDER, (i+1)*fontH - fontD + BORDER, &lcdText[i][strt], stop-strt); #endif } } /* draw the last unhighlighted section of the line */ stop = lcdWidth; if(dataSelected == DATA_SELECTED && i>=hiY1 && i<=hiY2){ strt = hiX2+1; if(strt > lcdWidth) strt = lcdWidth; } else { strt = lcdWidth; } if(stop-strt){ #ifdef USE_PANGO pango_layout_index_to_pos(pango_layout, strt, &rect); pango_pos = rect.x / PANGO_SCALE; gdk_window_clear_area(lcdDA->window, pango_pos + BORDER, i*fontH + BORDER, 2*fontW*(stop-strt), fontH); pango_layout_set_text(pango_layout, &lcdText[i][strt], stop-strt); gdk_draw_layout(lcdDA->window, lcdGC, pango_pos + BORDER + SHIFT, i*fontH + BORDER, pango_layout); #else gdk_window_clear_area(lcdDA->window, strt*fontW + BORDER, i*fontH + BORDER, fontW*(stop-strt), fontH); gdk_draw_text(lcdDA->window, lcdFont, lcdGC, strt*fontW + BORDER, (i+1)*fontH - fontD + BORDER, &lcdText[i][strt], stop-strt); #endif } } /* draw the cursor */ if(isEditingEditor()){ curPos = cursorPosEditor(); if(curPos > lcdWidth){ curPos = lcdWidth; } if(dataSelected == DATA_SELECTED && curPos>=hiX1 && curPos<=hiX2 && lcdHeight-1>=hiY1 && lcdHeight-1<=hiY2) { drawgc = lcdHighlightGC; } else { drawgc = lcdGC; } /* hack: draw a white line to erase any old cursor in position 0. XDrawImageString dosen't cover this up like it does with an old cursor in any other position */ if(!(dataSelected == DATA_SELECTED && 0==hiX1 && lcdHeight-1>=hiY1 && lcdHeight-1<=hiY2)) { gdk_draw_line(lcdDA->window, lcdHighlightGC, BORDER + SHIFT, (lcdHeight-1) * fontH + BORDER, BORDER + SHIFT, lcdHeight * fontH - 1 + BORDER); } /* draw the cursor */ #ifdef USE_PANGO pango_layout_index_to_pos(pango_layout, curPos, &rect); pango_pos = rect.x / PANGO_SCALE + SHIFT + BORDER; gdk_draw_line(lcdDA->window, drawgc, pango_pos, (lcdHeight-1) * fontH + BORDER, pango_pos, lcdHeight * fontH - 1 + BORDER); /* Flush GDK display, seems to be needed in certain environments */ gdk_flush(); } else { pango_layout_index_to_pos(pango_layout, strt, &rect); pango_pos = rect.x / PANGO_SCALE + SHIFT + BORDER; if (pango_pos > lcdDA->allocation.width - BORDER && lcdWidth > 6) { lcdWidth -= 1; clearLCDwindow(); calcStackLCD(); drawStackLCD(); } } #else gdk_draw_line(lcdDA->window, drawgc, fontW * curPos + SHIFT + BORDER, (lcdHeight-1) * fontH + BORDER, fontW * curPos + SHIFT + BORDER, lcdHeight * fontH - 1 + BORDER); }
void gpk_bargraph_draw(GtkWidget * widget, /* plot on this widged */ int n, /* number of data points */ gdouble * xcord, gdouble * ycord, /* data */ gdouble xmn, gdouble ymn, /* coordinates of corners */ gdouble xmx, gdouble ymx, int clear, /* clear old plot first */ char *title, /* add a title (only if clear=1) */ int barwidth, /* bar width. 0=compute based on window size */ GdkColor * color) { GdkPixmap **ppixmap; GdkPoint points[2]; int i; gint16 width, height, x, y, barheight; GdkFont *fixed_font; GdkGC *gc; int titleSplit; gc = gdk_gc_new(widget->window); gdk_gc_set_foreground(gc, color); if ((ppixmap = findpixmap(widget))) { width = widget->allocation.width; height = widget->allocation.height; if (clear) { /* white background */ gdk_draw_rectangle(*ppixmap, widget->style->white_gc, TRUE, 0, 0, width, height); /* title */ #ifdef _WIN32 fixed_font = gdk_font_load("-misc-fixed-large-r-*-*-*-100-*-*-*-*-*-*"); #else fixed_font = gdk_font_load("-misc-fixed-medium-r-*-*-*-100-*-*-*-*-iso8859-1"); #endif titleSplit = strcspn(title, "\n"); if (titleSplit && (titleSplit != strlen(title))) { gdk_draw_text(*ppixmap, fixed_font, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], 0, 10, title, titleSplit); gdk_draw_text(*ppixmap, fixed_font, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], 0, 22, title + titleSplit + 1, (strlen(title) - titleSplit) - 1); } else { gdk_draw_text(*ppixmap, fixed_font, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], 0, 10, title, strlen(title)); } } for (i = 0; i < n; i++) { points[1].x = .5 + ((xcord[i] - xmn) * (width - 1) / (xmx - xmn)); points[1].y = .5 + ((ycord[i] - ymx) * (height - 1) / (ymn - ymx)); points[0].x = points[1].x; points[0].y = height - 1; x = .5 + ((xcord[i] - xmn) * (width - 1) / (xmx - xmn)); y = .5 + ((ycord[i] - ymx) * (height - 1) / (ymn - ymx)); if (!barwidth) barwidth = (width / (n + 1)) - 1; barwidth = barwidth > 5 ? 5 : barwidth; barwidth = barwidth < 1 ? 1 : barwidth; barheight = height - 1 - y; /* gdk_draw_lines(*ppixmap,gc,points,2); */ gdk_draw_rectangle(*ppixmap, gc, TRUE, x, y, barwidth, barheight); } gpk_redraw(*ppixmap, widget); } gdk_gc_destroy(gc); }
void azel(double az, double el) // command antenna movement { int kk, n, mm, ax, axis, count, ccount, rcount, flip; int ix, iy, midxr, ixe; int yr, da, hr, mn, sc; int region1, region2, region3; unsigned int base; double azscale, elscale, azz, ell, ra, dec, x, y; double elnow, lenzero, elcount; GdkColor color; int azatstow = 0; int elatstow = 0; char m[80], recv[80], str[80], str2[80], txt[80]; mm = count = 0; d1.slew = 0; lenzero = 0; ix = midx * 1.55; ixe = midx * 0.25; midxr = midx * 2 - ix; if (d1.lat >= 0.0) sprintf(txt, "%s %4.1fN %5.1fW", d1.statnam, d1.lat * 180.0 / PI, d1.lon * 180.0 / PI); else sprintf(txt, "%s %4.1fS %5.1fW", d1.statnam, -d1.lat * 180.0 / PI, d1.lon * 180.0 / PI); iy = midy * 0.05; if (d1.displ) { gdk_draw_rectangle(pixmap, drawing_area->style->white_gc, TRUE, ix, iy - midy * 0.04, midxr, midy * 0.05); gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ix, iy, txt, strlen(txt)); } sprintf(txt, "cmd %5.1f %4.1f deg", d1.azcmd, d1.elcmd); iy = midy * 0.15; if (d1.displ) gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ix, iy, txt, strlen(txt)); else if (d1.debug) { toyrday(d1.secs, &yr, &da, &hr, &mn, &sc); printf("%4d:%03d:%02d:%02d:%02d %3s ", yr, da, hr, mn, sc, d1.timsource); printf("%s\n", txt); } sprintf(txt, "offsets %5.1f %4.1f deg", d1.azoff, d1.eloff); iy = midy * 0.25; if (d1.displ) gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ix, iy, txt, strlen(txt)); base = d1.azelport; if (d1.azelsim == 0) { outb(128 + 3, base + 3); outb(0x30, base); outb(0, base + 1); // 2400 8 data 1 stop noparity outb(3, base + 3); outb(7, base + 1); outb(1, base + 2); outb(3, base + 4); sprintf(str, "antenna drive status:"); if (d1.comerr > 0) { sprintf(txt, " comerr= %d", d1.comerr); iy = midy * 0.1; if (d1.displ) { gdk_draw_rectangle(pixmap, drawing_area->style->white_gc, TRUE, ixe, iy - midy * 0.04, midxr, midy * 0.05); gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ixe, iy, txt, strlen(txt)); } } } else { sprintf(txt, "antenna simulated"); iy = midy * 0.1; if (d1.displ) { gdk_draw_rectangle(pixmap, drawing_area->style->white_gc, TRUE, ix, iy - midy * 0.04, midxr, midy * 0.05); gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ix, iy, txt, strlen(txt)); } } if (az > 360.0) az -= 360.0; /* Fold into reasonable range */ if (d1.south == 0) { az = az + 360.0; /* put az in range 180 to 540 */ if (az > 540.0) az -= 360.0; if (az < 180.0) az += 360.0; } region1 = region2 = region3 = 0; if (az >= d1.azlim1 && az < d1.azlim2 && el >= d1.ellim1 && el <= d1.ellim2) region1 = 1; if (az > d1.azlim1 + 180.0 && el > (180.0 - d1.ellim2)) region2 = 1; if (az < d1.azlim2 - 180.0 && el > (180.0 - d1.ellim2)) region3 = 1; if (!region1 && !region2 && !region3) { sprintf(txt, "cmd out of limits"); iy = midy * 0.10; if (d1.displ) { color.red = 0xffff; color.green = color.blue = 0; gdk_color_parse("red", &color); gtk_widget_modify_fg(drawing_area, GTK_STATE_NORMAL, &color); gdk_draw_rectangle(pixmap, drawing_area->style->white_gc, TRUE, ix, iy - midy * 0.04, midxr, midy * 0.05); gdk_draw_text(pixmap, fixed_font, drawing_area->style->fg_gc[GTK_STATE_NORMAL], ix, iy, txt, strlen(txt)); } d1.track = 0; if (d1.printout) { toyrday(d1.secs, &yr, &da, &hr, &mn, &sc); printf("%4d:%03d:%02d:%02d:%02d %3s ", yr, da, hr, mn, sc, d1.timsource); printf("cmd out of limits az %f el %f\n", az, el); } if (d1.stow != -1) { d1.stow = 1; d1.elcmd = d1.ellim1; d1.azcmd = d1.azlim1; } return; } flip = 0; if (az > d1.azlim2) { az -= 180.0; el = 180.0 - el; flip = 1; } if (az < d1.azlim1 && flip == 0) { az += 180.0; el = 180.0 - el; flip = 1; } azz = az - d1.azlim1; ell = el - d1.ellim1; // scale = 52.0 * 27.0 / 120.0; azscale = d1.azcounts_per_deg; elscale = d1.elcounts_per_deg; if (!d1.rod) elcount = ell * elscale; else { lenzero = d1.rod1 * d1.rod1 + d1.rod2 * d1.rod2 - 2.0 * d1.rod1 * d1.rod2 * cos((d1.rod4 - d1.ellim1) * PI / 180.0) - d1.rod3 * d1.rod3; if (lenzero >= 0.0) lenzero = sqrt(lenzero); else lenzero = 0; elcount = d1.rod1 * d1.rod1 + d1.rod2 * d1.rod2 - 2.0 * d1.rod1 * d1.rod2 * cos((d1.rod4 - el) * PI / 180.0) - d1.rod3 * d1.rod3; if (elcount >= 0.0) elcount = (-sqrt(elcount) + lenzero) * d1.rod5; else elcount = 0; // increase in length drives to horizon } /* mm=1=clockwize incr.az mm=0=ccw mm=2= down when pointed south */ if ((int) elcount > d1.elcount) axis = 1; // move in elevation first else axis = 0; for (ax = 0; ax < 2; ax++) { if (axis == 0) { if (azz * azscale > d1.azcount - 0.5) { mm = 1; count = (int) (azz * azscale - d1.azcount + 0.5); } if (azz * azscale <= d1.azcount + 0.5) { mm = 0; count = (int) (d1.azcount - azz * azscale + 0.5); } } else { if (elcount > d1.elcount - 0.5) { mm = 3; count = (int) (elcount - d1.elcount + 0.5); } if (elcount <= d1.elcount + 0.5) { mm = 2; count = (int) (d1.elcount - elcount + 0.5); } } ccount = count; if (d1.stow == 1 && d1.azcmd == d1.azlim1 && d1.elcmd == d1.ellim1) // drive to stow { count = 5000; if (axis == 0) { mm = 0; if (azatstow == 1) count = 0; } if (axis == 1) { mm = 2; // complete azimuth motion to stow before completely drop in elevation if (elatstow == 1 || (ccount <= 2.0 * d1.countperstep && azatstow == 0)) count = 0; } flip = 0; } if (count > d1.countperstep && ccount > d1.countperstep) count = d1.countperstep; if (count >= d1.ptoler && d1.track != -1) { if (count > d1.ptoler && d1.stow != -1) { d1.slew = 1; sprintf(txt, "ant slewing"); if (d1.printout) { toyrday(d1.secs, &yr, &da, &hr, &mn, &sc); printf("%4d:%03d:%02d:%02d:%02d %3s ", yr, da, hr, mn, sc, d1.timsource); if (soutrack[0]) { if (axis) printf("ant slewing in el to %s\n", soutrack); else printf("ant slewing in az to %s\n", soutrack); } if (d1.stow == 1) { if (axis) printf("ant slewing in el to stow\n"); else printf("ant slewing in az to stow\n"); } } iy = midy * 0.1; if (d1.displ) { gdk_draw_rectangle(pixmap, drawing_area->style->white_gc, TRUE, ix, iy - midy * 0.04, midxr, midy * 0.05); gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ix, iy, txt, strlen(txt)); } } if (d1.displ) { x = d1.azcmd * midx / 180.0; if (d1.south == 0) x -= midx; if (x < 0) x += midx * 2; if (x > midx * 2) x -= midx * 2; y = midy * 2 - d1.elcmd * midy * 2.0 / 180.0; color.red = 0; color.green = 0; color.blue = 0xffff; gdk_color_parse("blue", &color); gtk_widget_modify_fg(drawing_area, GTK_STATE_NORMAL, &color); gdk_draw_line(pixmap, drawing_area->style->fg_gc[GTK_STATE_NORMAL], x - 4, y, x + 4, y); gdk_draw_line(pixmap, drawing_area->style->fg_gc[GTK_STATE_NORMAL], x, y - 4, x, y + 4); } sprintf(str, " move %d %d \n", mm, count); /* need space at start and end */ n = 0; if (d1.azelsim != 0) { if (count < 5000) sprintf(str2, "M %d \n", count); else sprintf(str2, "T %d \n", count); strcpy(recv, str2); // n = str2.length(); } // d.dtext(16.0, 64.0, gg, Color.black, // "trans " + str.substring(0, str.length() - 1) + " "); kk = 0; { if (d1.azelsim == 0) { while ((inb(base + 2) & 1) == 0 && kk < KKTIMEOUT) { inb(base); kk++; } strcpy(m, str); // printf("sending\n"); for (n = 0; (unsigned) n < strlen(m); n++) { outb(m[n], base); while ((inb(base + 5) & 32) != 32); } if (d1.debug) printf("sent %s", m); for (n = 0; n < 80; n++) recv[n] = 0; kk = 0; n = 0; rcount = 0; } while (kk < KKTIMEOUT && kk >= 0) { if (d1.azelsim == 0) { while ((inb(base + 5) & 1) != 0) { recv[n] = inb(base); // printf("n=%d recv=%1c val=%d\n",n,recv[n],recv[n]); if (d1.displ == 0) printf("waiting %d\n", kk); if (recv[n] == 13) { kk = -99; break; } // if (d1.displ == 0) // printf ("n=%d ch=%1c\n", n, recv[n]); n++; } } else if (kk > 1) kk = -99; if (kk > 0) { if (axis == 0) sprintf(txt, "waiting on azimuth %d ", kk); else sprintf(txt, "waiting on elevation %d ", kk); iy = midy * 0.1; d1.slew = 1; if (d1.displ) { ix = midx * 1.55; midxr = midx * 2 - ix; // cleararea(); x = d1.azcmd * midx / 180.0; if (d1.south == 0) x -= midx; if (x < 0) x += midx * 2; if (x > midx * 2) x -= midx * 2; y = midy * 2 - d1.elcmd * midy * 2.0 / 180.0; color.red = 0; color.green = 0; color.blue = 0xffff; gdk_color_parse("blue", &color); gtk_widget_modify_fg(drawing_area, GTK_STATE_NORMAL, &color); gdk_draw_line(pixmap, drawing_area->style->fg_gc[GTK_STATE_NORMAL], x - 4, y, x + 4, y); gdk_draw_line(pixmap, drawing_area->style->fg_gc[GTK_STATE_NORMAL], x, y - 4, x, y + 4); gdk_draw_rectangle(pixmap, drawing_area->style->white_gc, TRUE, ix, iy - midy * 0.04, midxr, midy * 0.05); gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ix, iy, txt, strlen(txt)); sprintf(txt, "cmd %5.1f %4.1f deg", d1.azcmd, d1.elcmd); iy = midy * 0.15; gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ix, iy, txt, strlen(txt)); sprintf(txt, "azel %5.1f %4.1f deg", d1.aznow, d1.elnow); iy = midy * 0.20; gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ix, iy, txt, strlen(txt)); sprintf(txt, "offsets %5.1f %4.1f deg", d1.azoff, d1.eloff); iy = midy * 0.25; gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ix, iy, txt, strlen(txt)); azel_to_radec(d1.secs, d1.aznow, d1.elnow, &ra, &dec); sprintf(txt, "ra %5.1f hr %4.1f deg", ra * 12.0 / PI, dec * 180.0 / PI); iy = midy * 0.30; gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ix, iy, txt, strlen(txt)); color.green = color.red = color.blue = 0xffff; gtk_widget_modify_bg(button_stow, GTK_STATE_NORMAL, &color); if (!d1.plot) { Repaint(); } // cleararea(); while (gtk_events_pending() || d1.stopproc) { gtk_main_iteration(); // d1.plot = 0; } } else if (d1.debug) printf("%s\n", txt); sleep(1); } kk++; } if (d1.debug) printf("recv %s\n", recv); } // printf(" axis %d\n",axis); if (recv[0] != 'M' && recv[0] != 'T') { sprintf(txt, "comerr kk=%d n=%d mm%d", kk, n, count); iy = midy * 0.1; if (d1.displ) { gdk_draw_rectangle(pixmap, drawing_area->style->white_gc, TRUE, ixe, iy - midy * 0.04, midxr, midy * 0.05); gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ixe, iy, txt, strlen(txt)); } d1.comerr++; // if (d1.fstatus == 1) // o.stroutfile(g, "* ERROR comerr"); if (d1.mainten == 0) d1.stow = 1; return; } // if (d1.azelsim != 0 && d1.azelsim < 10) sleep(1); sprintf(txt, "recv %s", str); iy = midy * 0.05; if (d1.displ) { gdk_draw_rectangle(pixmap, drawing_area->style->white_gc, TRUE, ix, iy - midy * 0.04, midxr, midy * 0.05); gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ix, iy, txt, strlen(txt) - 1); } rcount = 0; sscanf(recv, "%*s %d", &rcount); if (rcount != count && ((axis == 0 && d1.azcmd != d1.azlim1) || (axis == 1 && d1.elcmd != d1.ellim1))) { // printf("lost count\n"); sprintf(txt, "lost count goto Stow"); d1.limiterr = 1; soutrack[0] = 0; iy = midy * 0.1; if (d1.displ) { gdk_draw_rectangle(pixmap, drawing_area->style->white_gc, TRUE, ixe, iy - midy * 0.04, midxr, midy * 0.05); gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ixe, iy, txt, strlen(txt)); sprintf(txt, "ERROR: received %d counts out of %d counts expected", rcount, count); iy = midy * 0.15; gdk_draw_rectangle(pixmap, drawing_area->style->white_gc, TRUE, ixe, iy - midy * 0.04, midxr, midy * 0.05); gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ixe, iy, txt, strlen(txt)); if (mm == 1) sprintf(txt, "while going clockwise in azimuth"); if (mm == 0) sprintf(txt, "while going counter-clockwise in azimuth"); if (mm == 3) sprintf(txt, "while going clockwise in elevation"); if (mm == 2) sprintf(txt, "while going counter-clockwise in elevation"); iy = midy * 0.20; gdk_draw_rectangle(pixmap, drawing_area->style->white_gc, TRUE, ixe, iy - midy * 0.04, midxr, midy * 0.05); gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ixe, iy, txt, strlen(txt)); sprintf(txt, "motor stalled or limit prematurely reached"); iy = midy * 0.25; gdk_draw_rectangle(pixmap, drawing_area->style->white_gc, TRUE, ixe, iy - midy * 0.04, midxr, midy * 0.05); gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ixe, iy, txt, strlen(txt)); } // if (d1.fstatus == 1) // stroutfile("* ERROR lost count"); if (d1.mainten == 0) { if (mm == 2 && recv[0] == 'T') // could hit limit at source set { d1.elcount = 0; d1.elnow = d1.ellim1; } elatstow = azatstow = 0; d1.stow = 1; d1.azcmd = d1.azlim1; d1.elcmd = d1.ellim1; } return; } if (mm == 2 && recv[0] == 'T') { elatstow = 1; d1.elcount = 0; d1.elnow = d1.ellim1; } if (mm == 0 && recv[0] == 'T') { azatstow = 1; d1.azcount = 0; d1.aznow = d1.azlim1; } if (recv[0] == 'T' && d1.stow == 0) { // printf("timeout from antenna\n"); sprintf(txt, "timeout from antenna"); iy = midy * 0.1; if (d1.displ) { gdk_draw_rectangle(pixmap, drawing_area->style->white_gc, TRUE, ix, iy - midy * 0.04, midxr, midy * 0.05); gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ix, iy, txt, strlen(txt)); } } if (recv[0] == 'M') { if (axis == 0) { azatstow = 0; if (mm == 1) d1.azcount = d1.azcount + count; else d1.azcount = d1.azcount - count; } if (axis == 1) { elatstow = 0; if (mm == 3) d1.elcount = d1.elcount + count; else d1.elcount = d1.elcount - count; } } if (d1.azelsim == 0 && d1.slew) sleep(1); } axis++; if (axis > 1) axis = 0; } if (d1.track != -1) { if (d1.slew == 1) d1.track = 0; else d1.track = 1; } d1.aznow = d1.azlim1 + d1.azcount / azscale; if (d1.aznow > 360.0) d1.aznow = d1.aznow - 360.0; if (!d1.rod) elnow = d1.elcount / elscale; else { elnow = -d1.elcount / d1.rod5 + lenzero; elnow = d1.rod1 * d1.rod1 + d1.rod2 * d1.rod2 - d1.rod3 * d1.rod3 - elnow * elnow; elnow = elnow / (2.0 * d1.rod1 * d1.rod2); elnow = -acos(elnow) * 180.0 / PI + d1.rod4 - d1.ellim1; } d1.elnow = d1.ellim1 + elnow; if (d1.elnow > 90.0) { if (d1.aznow >= 180.0) d1.aznow = d1.aznow - 180.0; else d1.aznow = d1.aznow + 180.0; d1.elnow = 180.0 - d1.elnow; } // d.dtext(670.0, 40.0, gg, Color.black, // "azel " + d.dc(d1.aznow(), 5, 1) + " " + d.dc(d1.elnow(), 5, 1) + // " deg"); x = (int) (d1.aznow * 640.0 / 360.0); if (d1.south == 0) { x -= 320; if (x < 0) x += 640; } if (fabs(d1.aznow - d1.azlim1) < 1e-6 && fabs(d1.elnow - d1.ellim1) < 1e-6) { if (d1.displ) { color.green = 0xffff; color.red = color.blue = 0; gdk_color_parse("green", &color); gtk_widget_modify_bg(button_stow, GTK_STATE_NORMAL, &color); gtk_tooltips_set_tip(tooltips, button_stow, "antenna at stow", NULL); gtk_tooltips_set_tip(tooltips, button_exit, "click to exit program", NULL); // printf("in green\n"); } d1.stow = -1; // at stow } else { if (d1.displ) { color.green = color.red = color.blue = 0xffff; gtk_widget_modify_bg(button_stow, GTK_STATE_NORMAL, &color); gtk_tooltips_set_tip(tooltips, button_stow, "click to stow antenna", NULL); if (d1.track != -1) gtk_tooltips_set_tip(tooltips, button_exit, "go to stow first", NULL); } if (d1.stow == -1) d1.stow = 0; } if (d1.stow != 0) { d1.track = 0; } if (d1.displ) { sprintf(txt, "azel %5.1f %4.1f deg", d1.aznow, d1.elnow); iy = midy * 0.20; gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ix, iy, txt, strlen(txt)); azel_to_radec(d1.secs, d1.aznow, d1.elnow, &ra, &dec); sprintf(txt, "ra %5.1f hr %4.1f deg", ra * 12.0 / PI, dec * 180.0 / PI); iy = midy * 0.30; gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ix, iy, txt, strlen(txt)); sprintf(txt, "cmd %5.1f %4.1f deg", d1.azcmd, d1.elcmd); iy = midy * 0.15; gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ix, iy, txt, strlen(txt)); sprintf(txt, "offsets %5.1f %4.1f deg", d1.azoff, d1.eloff); iy = midy * 0.25; gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ix, iy, txt, strlen(txt)); } else if (d1.debug) { toyrday(d1.secs, &yr, &da, &hr, &mn, &sc); printf("%4d:%03d:%02d:%02d:%02d %3s ", yr, da, hr, mn, sc, d1.timsource); printf("now %s tant %5.1f Source: %s\n", txt, d1.tant, soutrack); } return; }
int GCtext(Gwidget_t * widget, Gtextline_t * tlp, int n, Gpoint_t go, char *fn, double fs, char *justs, Ggattr_t * ap) { Gsize_t gs; PIXpoint_t po; PIXsize_t ps; PIXrect_t pr; Grect_t gr; GdkFont *font; int dir, asc, des, x = 0, y, w, h, i; int lbearing, rbearing, width; po = pdrawtopix(widget, go); gs.x = 0, gs.y = fs; ps = sdrawtopix(widget, gs); if (!(font = findfont(fn, ps.y))) { printf("NO FONT\n"); gdk_draw_rectangle(widget->w, GC, FALSE, po.x, po.y, 1, 1); return 0; } setgattr(widget, ap); SETFONT(font); for (w = h = 0, i = 0; i < n; i++) { gdk_text_extents(font, tlp[i].p, tlp[i].n, &lbearing, &rbearing, &width, &asc, &des); tlp[i].w = width, tlp[i].h = asc + des; w = max(w, width), h += asc + des; } switch (justs[0]) { case 'l': po.x += w / 2; break; case 'r': po.x -= w / 2; break; } switch (justs[1]) { case 'd': po.y -= h; break; case 'c': po.y -= h / 2; break; } pr.o.x = po.x - w / 2, pr.o.y = po.y; pr.c.x = po.x + w / 2, pr.c.y = po.y + h; gr = rpixtodraw(widget, pr); /* if(!ISVISIBLE(gr)) return 1; */ for (i = 0; i < n; i++) { switch (tlp[i].j) { case 'l': x = po.x - w / 2; break; case 'n': x = po.x - tlp[i].w / 2; break; case 'r': x = po.x - (tlp[i].w - w / 2); break; } y = po.y + (i + 1) * tlp[i].h - des; gdk_draw_text(widget->w->window, font, GC, x, y, tlp[i].p, tlp[i].n); } return 0; }
static void *font_gtk_get_glyph(unsigned char *str) { agsurface_t *dst; int h, w, l; BYTE *conv; GdkPixmap *pix_gdk; GdkGC *gc_gdk; GdkImage *img_gdk; GdkColor col_gdk; /* convert string code from sjis to euc (or LANG) */ conv = sjis2lang(str); l = strlen(conv); w = gdk_text_width(fontset, conv, l); if (w == 0) { free(conv); return NULL; } #ifdef GTKV12 h = gdk_text_height(fontset, conv, l); #else h = font_ascent + fontset->ascent; #endif if (w > GLYPH_PIXMAP_WIDTH) w = GLYPH_PIXMAP_WIDTH; if (h > GLYPH_PIXMAP_HEIGHT) h = GLYPH_PIXMAP_HEIGHT; pix_gdk = gdk_pixmap_new(mainwin->window, w, h, gdk_depth); gc_gdk = gdk_gc_new(pix_gdk); /* color */ col_gdk.pixel = 0; gdk_gc_set_foreground(gc_gdk, &col_gdk); // gdk_gc_set_background(gc_gdk, &col_gdk); gdk_draw_rectangle(pix_gdk, gc_gdk, TRUE, 0, 0, w, h); col_gdk.pixel = 1; gdk_gc_set_foreground(gc_gdk, &col_gdk); gdk_draw_text(pix_gdk, fontset, gc_gdk, 0, fontset->ascent, conv, l); gdk_gc_destroy(gc_gdk); img_gdk = gdk_image_get(&((GdkWindowPrivate *)pix_gdk)->window, 0, 0, w, h); gdk_pixmap_unref(pix_gdk); dst = g_new(agsurface_t, 1); dst->width = w; dst->height = h; dst->bytes_per_pixel = (img_gdk->bpp+1)/8; /* むーん */ dst->bytes_per_line = img_gdk->bpl; dst->pixel = img_gdk->mem; image_get_glyph(dst, &img_glyph); if (this->antialiase_on) { aa_make(img_glyph.pixel, w, dst->height, img_glyph.bytes_per_line); } img_glyph.width = w; img_glyph.height = h; g_free(dst); g_free(conv); gdk_image_destroy(img_gdk); return &img_glyph; }
void cal(int mode) // command cal { int k; int ix, iy, midxr, ixe; char txt[80]; double av; float wtt[NSPEC]; GdkColor color; if (mode == 0) { for (k = 0; k < d1.nfreq; k++) bbspec[k] = 0; zerospectra(0); d1.calon = 1; } if (mode == 1) for (k = 0; k < d1.nfreq; k++) bbspec[k] += spec[k]; if (mode == 2) { d1.calon = 0; for (k = 0; k < d1.nfreq; k++) { if (k > d1.f1 * d1.nfreq && k < d1.f2 * d1.nfreq) wtt[k] = 1; else wtt[k] = 0; } polyfitr(NPOLY, d1.nfreq, bbspec, wtt, bspec); // for(k=0;k < d1.nfreq; k++) bspec[k] = bbspec[k]; k = d1.fc * d1.nfreq; av = bspec[k]; for (k = 0; k < d1.nfreq; k++) bspec[k] = bspec[k] / av; d1.calpwr = av / d1.integ; // if(d1.yfac > 2) d1.tsys = 290.0 /(d1.yfac - 1.0); // put in manually d1.caldone = 1; printf("yfac %f tsys %f pwr %f pwrprev %f\n", d1.yfac, d1.tsys, pwr, pwrprev); if (d1.displ) { color.green = 0xffff; color.red = 0; color.blue = 0; gdk_color_parse("green", &color); gtk_widget_modify_bg(button_cal, GTK_STATE_NORMAL, &color); } } ix = midx * 1.55; ixe = midx * 0.4; midxr = midx * 2 - ix; sprintf(txt, "calibration in progress"); iy = midy * 0.1; if (d1.displ && mode) gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ix, iy, txt, strlen(txt)); iy = midy * 0.1; if (d1.displ && !mode) { gdk_draw_rectangle(pixmap, drawing_area->style->white_gc, TRUE, ix, iy - midy * 0.04, midxr, midy * 0.05); gdk_draw_text(pixmap, fixed_font, drawing_area->style->black_gc, ix, iy, txt, strlen(txt)); } if (d1.debug) printf("incal mode %d\n", mode); return; }
void playlist_list_draw(Widget * w) { PlayList_List *pl = (PlayList_List *) w; GList *list; GdkGC *gc; GdkPixmap *obj; int width, height; char *text, *title; int i, tw, max_first; gc = pl->pl_widget.gc; width = pl->pl_widget.width; height = pl->pl_widget.height; obj = pl->pl_widget.parent; gdk_gc_set_foreground(gc, get_skin_color(SKIN_PLEDIT_NORMALBG)); gdk_draw_rectangle(obj, gc, TRUE, pl->pl_widget.x, pl->pl_widget.y, width, height); if (playlist_list_font == NULL) { g_log(NULL, G_LOG_LEVEL_CRITICAL, "Couldn't open playlist font"); return; } PL_LOCK(); list = get_playlist(); pl->pl_fheight = playlist_list_font->ascent + playlist_list_font->descent + 1; pl->pl_num_visible = height / pl->pl_fheight; max_first = g_list_length(list) - pl->pl_num_visible; if (max_first < 0) max_first = 0; if (pl->pl_first >= max_first) pl->pl_first = max_first; if (pl->pl_first < 0) pl->pl_first = 0; for (i = 0; i < pl->pl_first; i++) list = g_list_next(list); for (i = pl->pl_first; list && i < pl->pl_first + pl->pl_num_visible; list = list->next, i++) { char qstr[20] = "", length[40] = ""; int pos; PlaylistEntry *entry = (PlaylistEntry *) list->data; if (entry->selected) { gdk_gc_set_foreground(gc, get_skin_color(SKIN_PLEDIT_SELECTEDBG)); gdk_draw_rectangle(obj, gc, TRUE, pl->pl_widget.x, pl->pl_widget.y + ((i - pl->pl_first) * pl->pl_fheight), width, pl->pl_fheight); } if (i == __get_playlist_position()) gdk_gc_set_foreground(gc, get_skin_color(SKIN_PLEDIT_CURRENT)); else gdk_gc_set_foreground(gc, get_skin_color(SKIN_PLEDIT_NORMAL)); if (entry->title) title = entry->title; else title = g_basename(entry->filename); pos = playlist_get_queue_position(entry); if (pos != -1) sprintf(qstr, "|%d|%s", pos + 1, entry->length != -1 ? " " : ""); if (entry->length != -1) sprintf(length, "%d:%-2.2d", entry->length / 60000, (entry->length / 1000) % 60); if (pos != -1 || entry->length != -1) { int x, y; char tail[60]; sprintf(tail, "%s%s", qstr, length); x = pl->pl_widget.x + width - gdk_text_width(playlist_list_font, tail, strlen(tail)) - 2; y = pl->pl_widget.y + (i - pl->pl_first) * pl->pl_fheight + playlist_list_font->ascent; gdk_draw_text(obj, playlist_list_font, gc, x, y, tail, strlen(tail)); tw = width - gdk_text_width(playlist_list_font, tail, strlen(tail)) - 5; } else tw = width; if (cfg.show_numbers_in_pl) text = g_strdup_printf("%d. %s", i + 1, title); else text = g_strdup_printf("%s", title); if (cfg.use_fontsets) playlist_list_draw_string_wc(pl, playlist_list_font, i - pl->pl_first, tw, text); else playlist_list_draw_string(pl, playlist_list_font, i - pl->pl_first, tw, text); g_free(text); } PL_UNLOCK(); }