gint wgra_configure(GtkWidget *widget,GdkEventConfigure *ee,gpointer data) { GdkGC *mygc; int x,y,cx,xs; int i,v; long max; float fac; GdkFont *fn; if (wcanvas!=NULL) gdk_pixmap_unref(wcanvas); mygc=gdk_gc_new(widget->window); wcanvas=gdk_pixmap_new(widget->window,x=widget->allocation.width, y=widget->allocation.height,-1); gdk_draw_rectangle(wcanvas,widget->style->white_gc,TRUE,0,0,x,y); gdk_draw_rectangle(wcanvas,widget->style->black_gc,FALSE,0,0,x-1,y-1); max=0; for(i=0;i<7;i++) if (weekly[i]>max) max=weekly[i]; if (!max) max=1; fac=((float)(y-18-16))/((float)max); cx=1; xs=(x-2)/7; fn=gdk_font_load("-*-helvetica-medium-r-*-*-8-*-*-*-*-*-*-*"); for (i=0;i<7;i++) { v=(int)(((float)weekly[i])*fac); gdk_rgb_gc_set_foreground(mygc,0xc0c0c0); gdk_draw_line(wcanvas,mygc,cx,1,cx,y-2); gdk_rgb_gc_set_foreground(mygc,0x004080); gdk_draw_rectangle(wcanvas,mygc,TRUE,cx,y-18-v,xs,v); gdk_rgb_gc_set_foreground(mygc,0x000000); gdk_draw_string(wcanvas,fn,mygc,cx,y-6,wdays[i]); cx+=xs; } gdk_draw_line(wcanvas,widget->style->black_gc,0,y-18,x-1,y-18); gdk_rgb_gc_set_foreground(mygc,0xffffff); gdk_draw_rectangle(wcanvas,mygc,TRUE,0,0,23*4,13); gdk_rgb_gc_set_foreground(mygc,0x000000); gdk_draw_rectangle(wcanvas,mygc,FALSE,0,0,23*4,13); gdk_font_unref(fn); fn=gdk_font_load("-*-helvetica-medium-r-*-*-10-*-*-*-*-*-*-*"); gdk_draw_string(wcanvas,fn,mygc,5,10,"weekday summary"); gdk_font_unref(fn); gdk_gc_destroy(mygc); return FALSE; }
/* drawCar * Draws a car * * @return void */ void drawCar (int colorCarro, gint xant, gint yant, gint x, gint y, gint width, gint height) { GdkRectangle car; GdkColor color; switch(colorCarro){ case 1: gdk_color_parse("#FF0000", &color); break; case 2: gdk_color_parse("#0000FF", &color); break; case 3: gdk_color_parse("#00FF00", &color); break; case 4: gdk_color_parse("#000000", &color); break; case 5: gdk_color_parse("#FFFFFF", &color); break; case 6: gdk_color_parse("#FFFF00", &color); break; case 7: gdk_color_parse("#FF6600", &color); break; case 8: gdk_color_parse("#FF33CC", &color); break; case 9: gdk_color_parse("#6699FF", &color); break; case 10: gdk_color_parse("#777777", &color); break; } GdkGC* gcont; gcont = gdk_gc_new(this.pixMap); gdk_gc_set_rgb_fg_color (gcont, &color); gtk_widget_queue_draw_area(this.drawingArea, xant, yant, width, height); car.x = x; car.y = y; car.width = width; car.height = height; gdk_draw_rectangle(this.pixMap, gcont, TRUE, car.x, car.y, car.width, car.height); if (colorCarro==4) gdk_draw_string(this.pixMap, gdk_font_load("-*-*-bold-r-normal--*-50-*-*-*-*-iso8859-1"), this.drawingArea->style->white_gc, (car.x+2), (car.y+10), "A1/5"); else gdk_draw_string(this.pixMap, gdk_font_load("-*-*-bold-r-normal--*-50-*-*-*-*-iso8859-1"), this.drawingArea->style->black_gc, (car.x+2), (car.y+10), "A1/5"); gtk_widget_queue_draw_area(this.drawingArea, car.x, car.y, car.width, car.height); }
/*-----------------------------------------------------------------------------------*/ void ctk_arch_draw_char(char c, unsigned char x, unsigned char y, unsigned char reversed, unsigned char color) { char str[2]; str[0] = c; str[1] = 0; if(reversed) { gdk_draw_rectangle(ctk_gtksim_pixmap, ctk_gtksim_drawing_area->style->black_gc, TRUE, x * FONT_WIDTH, y * FONT_HEIGHT, FONT_WIDTH, FONT_HEIGHT); gdk_draw_string(ctk_gtksim_pixmap, font, ctk_gtksim_drawing_area->style->white_gc, x * FONT_WIDTH, FONT_HEIGHT_BASELINE + y * FONT_HEIGHT, str); } else { gdk_draw_rectangle(ctk_gtksim_pixmap, ctk_gtksim_drawing_area->style->white_gc, TRUE, x * FONT_WIDTH, y * FONT_HEIGHT, FONT_WIDTH, FONT_HEIGHT); gdk_draw_string(ctk_gtksim_pixmap, font, ctk_gtksim_drawing_area->style->black_gc, x * FONT_WIDTH, FONT_HEIGHT_BASELINE + y * FONT_HEIGHT, str); } gdk_draw_pixmap(ctk_gtksim_drawing_area->window, ctk_gtksim_drawing_area->style->fg_gc[GTK_WIDGET_STATE (ctk_gtksim_drawing_area)], ctk_gtksim_pixmap, x * FONT_WIDTH, y * FONT_HEIGHT, x * FONT_WIDTH, y * FONT_HEIGHT, FONT_WIDTH, FONT_HEIGHT); }
/* Kreslicí funkce spoleèná pro gtk_ev_draw() a gtk_ev_expose(), která kreslí * vnitøní okno widgetu */ static void gtk_ev_paint_ev_win(GtkEv *ev, GdkRectangle *area) { GtkWidget *widget; gint width, x, y; const char *title = "Event Window"; GdkFont *font; g_return_if_fail(ev); g_return_if_fail(area); widget = GTK_WIDGET(ev); font = gtk_style_get_font(widget->style); if(!GTK_WIDGET_DRAWABLE(ev)) return; gdk_window_clear_area(ev->ev_win, area->x, area->y, area->width, area->height); gdk_gc_set_clip_rectangle(widget->style->black_gc, area); width = gdk_string_width(font, title); x = (ev->ev_win_rect.width - width)/2; y = font->ascent + 2; gdk_draw_string(ev->ev_win, font, widget->style->black_gc, x, y, title); gdk_gc_set_clip_rectangle(widget->style->black_gc, NULL); }
/** * Redraw portion of view defined by supplied region parameter. * * \param view pointer to generic view structure * \param region region of screen that need to be updated * \return OK on success */ RCode view_lsv_redraw(ViewGeneric *view, GdkRectangle *region) { ViewListStatus* lsv_data = NULL; GdkGC *gc = NULL; lsv_data = view_lsv_get_data_pointer(view); if ( NULL == lsv_data ) { return FAIL; } /// \todo move graphic context creation somewhere else gc = gdk_gc_new(view->window); gdk_gc_set_rgb_fg_color(gc, &(lsv_data->color.bg)); gdk_draw_rectangle(view->window, gc, TRUE, region->x, region->y, region->width, region->height); if ( NULL != lsv_data->buffer ) { gdk_gc_set_rgb_fg_color(gc, &(lsv_data->color.fg)); gdk_draw_string(view->window, lsv_data->font, gc, view->region.x + lsv_data->border_size.x, view->region.y + lsv_data->border_size.y + lsv_data->text_size.y, lsv_data->buffer ); } g_object_unref( (gpointer)gc ); return OK; }
static void service_hslider(GtkWidget *text, gpointer data) { GtkAdjustment *hadj; gint xsrc; if(signalpixmap) { hadj=GTK_ADJUSTMENT(signal_hslider); xsrc=(gint)hadj->value; DEBUG(printf("Signal HSlider Moved to %d\n",xsrc)); gdk_draw_rectangle(signalpixmap, signalarea->style->bg_gc[GTK_STATE_ACTIVE], TRUE, 0, -1, signal_fill_width, fontheight); gdk_draw_line(signalpixmap, signalarea->style->white_gc, 0, fontheight-1, signal_fill_width-1, fontheight-1); gdk_draw_string(signalpixmap, signalfont, signalarea->style->fg_gc[0], 3+xsrc, fontheight-4, "Time"); gdk_draw_pixmap(signalarea->window, signalarea->style->fg_gc[GTK_WIDGET_STATE(signalarea)], signalpixmap, xsrc, 0, 0, 0, signalarea->allocation.width, signalarea->allocation.height); } }
/*! Display a string at the image point \e ip location. To select the font used to display the string, use setFont(). \param ip : Upper left image point location of the string in the display. \param text : String to display in overlay. \param color : String color. \sa setFont() */ void vpDisplayGTK::displayCharString ( const vpImagePoint &ip, const char *text, const vpColor &color ) { if (displayHasBeenInitialized) { if (color.id < vpColor::id_unknown) gdk_gc_set_foreground(gc, col[color.id]); else { gdkcolor.red = 256 * color.R; gdkcolor.green = 256 * color.G; gdkcolor.blue = 256 * color.B; gdk_colormap_alloc_color(colormap,&gdkcolor,FALSE,TRUE); gdk_gc_set_foreground(gc, &gdkcolor); } if (font != NULL) gdk_draw_string(background, font, gc, vpMath::round( ip.get_u() ), vpMath::round( ip.get_v() ), (const gchar *)text); else std::cout << "Cannot draw string: no font is selected" << std::endl; } else { vpERROR_TRACE("GTK not initialized " ) ; throw(vpDisplayException(vpDisplayException::notInitializedError, "GTK not initialized")) ; } }
static void draw_string (GtkStyle *style, GdkWindow *window, GtkStateType state, GdkRectangle *area, GtkWidget *widget, const gchar *detail, gint x, gint y, const gchar *string) { g_return_if_fail (style != NULL); g_return_if_fail (window != NULL); /* FIXME: memory leak */ LOG ("widget=%s, primitive=string, state=%s, detail='%s', name='%s'", G_OBJECT_TYPE_NAME (widget), enum_value_to_string (gtk_state_type_get_type (), state), detail, gtk_widget_get_name (widget)); if (state == GTK_STATE_INSENSITIVE) { if (area) { gdk_gc_set_clip_rectangle (style->white_gc, area); gdk_gc_set_clip_rectangle (style->fg_gc[state], area); } gdk_draw_string (window, gtk_style_get_font (style), style->fg_gc[state], x, y, string); if (area) { gdk_gc_set_clip_rectangle (style->white_gc, NULL); gdk_gc_set_clip_rectangle (style->fg_gc[state], NULL); } } else { gdk_gc_set_clip_rectangle (style->fg_gc[state], area); gdk_draw_string (window, gtk_style_get_font (style), style->fg_gc[state], x, y, string); gdk_gc_set_clip_rectangle (style->fg_gc[state], NULL); } }
// Méthodes pour écrire du texte et des entiers dans une fenêtre void Fenetre::ecrit(int x, int y, const char * texte) { if (existe) { gdk_gc_set_rgb_fg_color(fenetre->style->fg_gc[GTK_STATE_NORMAL],&stylo); int lb,rb,w,as,de; gdk_string_extents (fonte, texte, &lb, &rb, &w, &as, &de); gdk_draw_string (dessin, fonte, fenetre->style->fg_gc[GTK_WIDGET_STATE (fenetre)],x,y-de,texte); gtk_widget_queue_draw(fenetre); // provoquer l'affichage traiteEvenements(); } }
static void draw_top_speed (C2NetworkTraffic *nt) { gint x1, x2, y1, y2; gint text_width, text_height; gint top_speed_kb; gint i; gfloat pixels_per_byte; GdkFont *font; gchar *string; GtkWidget *widget = GTK_WIDGET (nt); /* Allocate the font */ font = gdk_font_load ("-monotype-arial-bold-r-normal-*-*-110-*-*-p-*-iso8859-1"); /* Allocate the value that are static */ x1 = 1; /* Calculate which is the top_speed in Kb */ top_speed_kb = nt->top_speed/1024; /* Calculate how many pixels should be drown per byte */ pixels_per_byte = get_pixels_per_byte (nt); for (i = top_speed_kb; i > 0; i--) { string = g_strdup_printf ("(%d Kb/s)", i); if (i == top_speed_kb) { /* Calculate the dimensions of the text */ text_height = gdk_string_height (font, string); text_width = gdk_string_width (font, string); } else { text_height = gdk_string_height (font, string);; text_width = 0; } /* Allocate the dynamic value that we calculated */ x2 = widget->allocation.width - text_width - 20; y1 = y2 = (text_height/2)+TOP_MARGIN + (pixels_per_byte * ((top_speed_kb-i)*1024)); gdk_draw_line (nt->pixmap, widget->style->black_gc, x1, y1, x2, y2); if (i == top_speed_kb) gdk_draw_string (nt->pixmap, font, widget->style->black_gc, x2+10, y1+(text_height/2), string); g_free (string); } }
void DrawString(GdkWindow* window, GdkFont* font, GdkGC* gc, gint dstx, gint dsty, gchar* str) { GdkColor color; color.red = 0; color.green = 0; color.blue = 0; gdk_color_alloc(gdk_colormap_get_system(), &color); gdk_gc_set_fill(gc, GDK_SOLID); gdk_gc_set_foreground(gc, &color); gdk_draw_string(window, font, gc, dstx, dsty, str); }
static void draw_string (GtkStyle * style, GdkWindow * window, GtkStateType state, GdkRectangle * area, GtkWidget * widget, const gchar *detail, gint x, gint y, const gchar * string) { g_return_if_fail(style != NULL); g_return_if_fail(window != NULL); if (state == GTK_STATE_INSENSITIVE) { if (area) { gdk_gc_set_clip_rectangle(style->white_gc, area); gdk_gc_set_clip_rectangle(style->fg_gc[state], area); } gdk_draw_string(window, gtk_style_get_font (style), style->fg_gc[state], x, y, string); if (area) { gdk_gc_set_clip_rectangle(style->white_gc, NULL); gdk_gc_set_clip_rectangle(style->fg_gc[state], NULL); } } else { gdk_gc_set_clip_rectangle(style->fg_gc[state], area); gdk_draw_string(window, gtk_style_get_font (style), style->fg_gc[state], x, y, string); gdk_gc_set_clip_rectangle(style->fg_gc[state], NULL); } }
void dessiner_balise(balise* pt_balise,file_opener* donnees) { GdkDrawable* cartew=donnees->carte->window; if(pt_balise->affichage==1) { // printf("IF balise : Je change car affichage = %d\n", pt_balise->affichage); double x=conversion_longitude(pt_balise->longitude,donnees); double y=conversion_lat(pt_balise->latitude,donnees); gdk_draw_string(cartew,donnees->font,donnees->gc, donnees->xcarte*x+2,donnees->ycarte*y + 7, pt_balise->nom); gdk_draw_point(cartew,donnees->gc, donnees->xcarte*x,donnees->ycarte*y); } else { // printf("ELSE balise : Je change pas car affichage = %d\n", pt_balise->affichage); } }
void dessiner_aerodromes(aerodrome* pt_aero,file_opener* donnees) { GdkDrawable* cartew=donnees->carte->window; // Si l'affichage est autorisé if(pt_aero->affichage==1) { // On récupère on on converti les points double x=conversion_longitude(pt_aero->longitude,donnees); double y=conversion_lat(pt_aero->latitude,donnees); // On trace le point et le nom gdk_draw_string(cartew,donnees->font,donnees->gc, donnees->xcarte*x+2,donnees->ycarte*y + 7, pt_aero->oaci); gdk_draw_point(cartew,donnees->gc, donnees->xcarte*x,donnees->ycarte*y); } else { // printf("ELSE aero : Je change pas car affichage = %d\n", pt_aero->affichage); } }
void draw_place_name(int i, GdkPixmap *pixmap, GdkColor *draw_color) { int pix_x1, pix_y1; pix_x1 = map_x_to_pix(place_list->places[i].x/map->config.resolution); pix_y1 = map_y_to_pix(place_list->places[i].y/map->config.resolution); gdk_gc_set_foreground (drawing_gc, draw_color); gdk_draw_arc(pixmap, drawing_gc, 1, pix_x1-5, pix_y1-5, 10, 10, 0, 360*64); gdk_gc_set_foreground (drawing_gc, &carmen_black); gdk_draw_arc(pixmap, drawing_gc, 0, pix_x1-5, pix_y1-5, 10, 10, 0, 360*64); gdk_gc_set_foreground (drawing_gc, &carmen_black); gdk_draw_string(pixmap, place_font, drawing_gc, pix_x1, pix_y1-5, place_list->places[i].name); }
void font_engine_draw_string (GdkDrawable *drawable, struct font_engine_font_t *font, GdkGC *gc, gint x, gint y, const gchar *string) { if(!font->is_pango) { gdk_draw_string(drawable, font->gdkfont, gc, x, y, string); } #if defined(WAVE_USE_GTK2) && !defined(GTK_ENABLE_BROKEN) && GTK_CHECK_VERSION(2,8,0) else { PangoRectangle ink,logical; pango_layout_set_text(GLOBALS->fonts_layout, string, -1); pango_layout_set_font_description(GLOBALS->fonts_layout, font->desc); pango_layout_get_extents(GLOBALS->fonts_layout,&ink,&logical); gdk_draw_layout(drawable, gc, x, y-font->ascent, GLOBALS->fonts_layout); } #endif }
static void gtk_plot_gdk_draw_string (GtkPlotPC *pc, gint tx, gint ty, gint angle, const GdkColor *fg, const GdkColor *bg, gboolean transparent, gint border, gint border_space, gint border_width, gint shadow_width, const gchar *font_name, gint font_height, GtkJustification just, const gchar *text) { GdkBitmap *text_bitmap; GdkPixmap *text_pixmap; GdkBitmap *text_mask; GdkImage *image; GdkGC *gc, *bitmap_gc; GdkColormap *colormap; GdkColor white, black, mask_color; GList *family = NULL; gint y0; gint old_width, old_height; gboolean bold, italic; gint fontsize; gint ascent, descent; gint numf; gint xp = 0, yp = 0; gint width, height; gint x, y; gint i; GdkFont *font, *latin_font, *dfont; GtkPSFont *psfont, *base_psfont, *latin_psfont; gchar subs[2], insert_char; GdkWChar *aux, *wtext, *lastchar = NULL, *xaux; gchar num[4]; if(!GTK_PLOT_GDK(pc)->drawable) return; if(!GTK_PLOT_GDK(pc)->window) return; if(!GTK_PLOT_GDK(pc)->gc) return; if(!text || strlen(text) == 0) return; colormap = gdk_colormap_get_system (); gc = GTK_PLOT_GDK(pc)->gc; if(!gc) return; gtk_plot_text_get_size(text, angle, font_name, font_height, &width, &height, &ascent, &descent); if(height == 0 || width == 0) return; old_width = width; old_height = height; if(angle == 90 || angle == 270) { old_width = height; old_height = width; } gtk_psfont_get_families(&family, &numf); font = gtk_psfont_get_gdkfont(font_name, font_height); base_psfont = psfont = gtk_psfont_get_font(font_name); italic = psfont->italic; bold = psfont->bold; fontsize = font_height; x = 0; y0 = y = ascent; if (psfont->i18n_latinfamily) { latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily, italic, bold); latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname, fontsize); } else { latin_psfont = NULL; latin_font = NULL; } i = strlen(text) + 2; aux = wtext = g_malloc0(sizeof(GdkWChar) * i); gdk_mbstowcs(wtext, text, i - 1); /* initializing text bitmap - ajd */ text_bitmap = gdk_pixmap_new(GTK_PLOT_GDK(pc)->window, old_width, old_height, 1); bitmap_gc = gdk_gc_new(text_bitmap); gdk_color_white (colormap, &white); gdk_gc_set_foreground(bitmap_gc, &white); gdk_draw_rectangle(text_bitmap, bitmap_gc, TRUE, 0, 0, -1, -1); gdk_color_black (colormap, &black); gdk_gc_set_foreground(bitmap_gc, &black); while(aux && *aux != '\0' && *aux != '\n'){ if(*aux == '\\'){ aux++; switch(*aux){ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '9': psfont = gtk_psfont_find_by_family((gchar *)g_list_nth_data(family, *aux-'0'), italic, bold); gdk_font_unref(font); font = gtk_psfont_get_gdkfont(psfont->psname, fontsize); if (latin_font) { gdk_font_unref(latin_font); latin_font = NULL; } aux++; break; case '8': case 'g': psfont = gtk_psfont_find_by_family("Symbol", italic, bold); gdk_font_unref(font); font = gtk_psfont_get_gdkfont(psfont->psname, fontsize); if (latin_font) { gdk_font_unref(latin_font); latin_font = NULL; } aux++; break; case 'B': bold = TRUE; psfont = gtk_psfont_find_by_family(psfont->family, italic, bold); gdk_font_unref(font); font = gtk_psfont_get_gdkfont(psfont->psname, fontsize); if (latin_font) { gdk_font_unref(latin_font); latin_font = NULL; } if (psfont->i18n_latinfamily) { latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily, italic, bold); latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname, fontsize); } aux++; break; case 'x': xaux = aux + 1; for (i=0; i<3; i++){ if (xaux[i] >= '0' && xaux[i] <= '9') num[i] = xaux[i]; else break; } if (i < 3){ aux++; break; } num[3] = '\0'; insert_char = (gchar)atoi(num); subs[0] = insert_char; subs[1] = '\0'; /* \xNNN is always outputted with latin fonts. */ dfont = (psfont->i18n_latinfamily != NULL) ? latin_font : font; gdk_draw_string (text_bitmap, dfont, bitmap_gc, x, y, subs); x += gdk_char_width(font, insert_char); aux += 4; lastchar = aux - 1; break; case 'i': italic = TRUE; psfont = gtk_psfont_find_by_family(psfont->family, italic, bold); gdk_font_unref(font); font = gtk_psfont_get_gdkfont(psfont->psname, fontsize); if (latin_font) { gdk_font_unref(latin_font); latin_font = NULL; } if (psfont->i18n_latinfamily) { latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily, italic, bold); latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname, fontsize); } aux++; break; case 'S': case '^': fontsize = (int)((gdouble)fontsize * 0.6 + 0.5); gdk_font_unref(font); font = gtk_psfont_get_gdkfont(psfont->psname, fontsize); y -= font->ascent; if (latin_font) { gdk_font_unref(latin_font); latin_font = NULL; } if (psfont->i18n_latinfamily) { latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily, italic, bold); latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname, fontsize); } aux++; break; case 's': case '_': fontsize = (int)((gdouble)fontsize * 0.6 + 0.5); gdk_font_unref(font); font = gtk_psfont_get_gdkfont(psfont->psname, fontsize); y += font->descent; if (latin_font) { gdk_font_unref(latin_font); latin_font = NULL; } if (psfont->i18n_latinfamily) { latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily, italic, bold); latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname, fontsize); } aux++; break; case '+': fontsize += 3; gdk_font_unref(font); font = gtk_psfont_get_gdkfont(psfont->psname, fontsize); if (latin_font) { gdk_font_unref(latin_font); latin_font = NULL; } if (psfont->i18n_latinfamily) { latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily, italic, bold); latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname, fontsize); } aux++; break; case '-': fontsize -= 3; gdk_font_unref(font); font = gtk_psfont_get_gdkfont(psfont->psname, fontsize); if (latin_font) { gdk_font_unref(latin_font); latin_font = NULL; } if (psfont->i18n_latinfamily) { latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily, italic, bold); latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname, fontsize); } aux++; break; case 'N': psfont = base_psfont; gdk_font_unref(font); fontsize = font_height; font = gtk_psfont_get_gdkfont(psfont->psname, fontsize); y = y0; italic = psfont->italic; bold = psfont->bold; if (latin_font) { gdk_font_unref(latin_font); latin_font = NULL; } if (psfont->i18n_latinfamily) { latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily, italic, bold); latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname, fontsize); } aux++; break; case 'b': if (lastchar) { gtk_psfont_get_char_size(psfont, font, latin_font, *lastchar, &i, NULL, NULL); x -= i; if (lastchar == wtext) lastchar = NULL; else lastchar--; } else { gtk_psfont_get_char_size(psfont, font, latin_font, 'X', &i, NULL, NULL); x -= i; } aux++; break; default: if(aux && *aux != '\0' && *aux !='\n'){ x += drawstring(pc, text_bitmap, bitmap_gc, &black, &white, x, y, psfont, font, latin_font, *aux); lastchar = aux; aux++; } break; } } else { if(aux && *aux != '\0' && *aux !='\n'){ x += drawstring(pc, text_bitmap, bitmap_gc, &black, &white, x, y, psfont, font, latin_font, *aux); lastchar = aux; aux++; } } } g_free(wtext); /* initializing clip mask bitmap - ajd */ text_mask = gdk_pixmap_new(GTK_PLOT_GDK(pc)->window, width, height, 1); mask_color = white; mask_color.pixel = 0; gdk_gc_set_foreground(bitmap_gc, &mask_color); gdk_draw_rectangle(text_mask, bitmap_gc, TRUE, 0, 0, -1, -1); mask_color = black; mask_color.pixel = 1; gdk_gc_set_foreground(bitmap_gc, &mask_color); /* performing text rotation and saving it onto clip mask bitmap - ajd */ image = gdk_image_get(text_bitmap, 0, 0, old_width, old_height); for(y = 0; y < old_height; y++) for(x = 0; x < old_width; x++) { if( black.pixel == gdk_image_get_pixel(image, x, y) ){ switch(angle){ case 0: xp = x; yp = y; break; case 90: xp = y; yp = old_width - x; break; case 180: xp = old_width - x; yp = old_height - y; break; case 270: xp = old_height - y; yp = x; break; } gdk_draw_point(text_mask, bitmap_gc, xp, yp); } } gdk_image_destroy(image); /* initializing text pixmap - ajd */ text_pixmap = gdk_pixmap_new(GTK_PLOT_GDK(pc)->window, width, height, -1); gdk_gc_set_foreground(gc, (GdkColor *) bg); gdk_draw_rectangle(text_pixmap, gc, TRUE, 0, 0, -1, -1); gdk_gc_set_foreground(gc, (GdkColor *) fg); /* copying clip mask bitmap onto text pixmap - ajd */ gdk_gc_set_clip_mask(gc, text_mask); gdk_gc_set_clip_origin(gc, 0, 0); gdk_draw_rectangle(text_pixmap, gc, TRUE, 0, 0, -1, -1); gdk_gc_set_clip_mask(gc, NULL); gtk_plot_text_get_area(text, angle, just, font_name, font_height, &x, &y, &width, &height); tx += x; ty += y; if(transparent){ gdk_gc_set_clip_mask (gc, text_mask); gdk_gc_set_clip_origin (gc, tx, ty); } else { gdk_gc_set_foreground(gc, (GdkColor *) bg); gtk_plot_pc_draw_rectangle(pc, TRUE, tx - border_space, ty - border_space, width + 2*border_space, height + 2*border_space); } gdk_draw_pixmap(GTK_PLOT_GDK(pc)->drawable, gc, text_pixmap, 0, 0, tx, ty, -1, -1); gdk_gc_set_clip_mask(gc, NULL); gdk_pixmap_unref(text_pixmap); gdk_bitmap_unref(text_mask); gdk_font_unref(font); if (latin_font) gdk_font_unref(latin_font); gdk_gc_unref(bitmap_gc); gdk_pixmap_unref(text_bitmap); /* border */ gdk_gc_set_foreground(gc, (GdkColor *) fg); gtk_plot_pc_set_dash(pc, 0, NULL, 0); gtk_plot_pc_set_lineattr(pc, border_width, 0, 0, 0); switch(border){ case GTK_PLOT_BORDER_SHADOW: gtk_plot_pc_draw_rectangle(pc, TRUE, tx - border_space + shadow_width, ty + height + border_space, width + 2 * border_space, shadow_width); gtk_plot_pc_draw_rectangle(pc, TRUE, tx + width + border_space, ty - border_space + shadow_width, shadow_width, height + 2 * border_space); case GTK_PLOT_BORDER_LINE: gtk_plot_pc_draw_rectangle(pc, FALSE, tx - border_space, ty - border_space, width + 2*border_space, height + 2*border_space); case GTK_PLOT_BORDER_NONE: default: break; } return; }
void dessiner_pdv(pdv* pt_pdv_current, file_opener* donnees) { GdkDrawable* cartew=donnees->carte->window; if(pt_pdv_current->affichage==1) // Vérifie si le plan de vol doit être affiché { position* loc_avion=malloc(sizeof(position)); // Position_avion(donnees,pt_pdv_current,loc_avion); get_position_avion(loc_avion,pt_pdv_current,donnees->temps); loc_avion->y=conversion_lat(loc_avion->y,donnees)*donnees->ycarte; loc_avion->x=conversion_longitude(loc_avion->x,donnees)*donnees->xcarte; // On change la couleur du tracé pour le carré et le nom de l'avion couleur(donnees->gc,donnees->c,donnees->couleur_avion); gdk_draw_rectangle(cartew,donnees->gc,TRUE,loc_avion->x-2,loc_avion->y-2,5,5); gdk_draw_string(cartew,donnees->font,donnees->gc,loc_avion->x+3,loc_avion->y-2,pt_pdv_current->nom); couleur(donnees->gc,donnees->c,10); int x1=-9,x2=0,y1=0,y2=0; // Variables de stockage des coordonnées pour les points de passage pt_pass * pt_pass_current = pt_pdv_current->pass_debut; if(x1==-9 && pt_pass_current->ptsuiv!=NULL) // Cas du premier point { if(pt_pass_current->type_point==0) // Si le point est un aérodrome { aerodrome * pass_aerodrome = pt_pass_current->point; //printf("\n AERODROME 1 \n"); x1=conversion_longitude(pass_aerodrome->longitude,donnees)* donnees->xcarte; y1=conversion_lat(pass_aerodrome->latitude,donnees)* donnees->ycarte; // Affichage de l'aérodrome pass_aerodrome->affichage=1; dessiner_aerodromes(pass_aerodrome,donnees); } if(pt_pass_current->type_point==1) // Si le point est une balise { balise * pass_balise = pt_pass_current->point; // printf("\n BALISE 1 \n"); x1=conversion_longitude(pass_balise->longitude,donnees)* donnees->xcarte; y1=conversion_lat(pass_balise->latitude,donnees)* donnees->ycarte; // Affichage de la balise pass_balise->affichage=1; dessiner_balise(pass_balise,donnees); } if(pt_pass_current->type_point==2) // Si le point est une ptgpx { ptgpx * pass = pt_pass_current->point; // printf("\n BALISE 1 \n"); x1=conversion_longitude(pass->longitude,donnees)* donnees->xcarte; y1=conversion_lat(pass->latitude,donnees)* donnees->ycarte; // Affichage de la balise //gdk_draw_string(carte,font,gc, x1 + 2,y1 + 7, pass_balise->nom); gdk_draw_point(cartew,donnees->gc, x1,y1); } pt_pass_current = pt_pass_current->ptsuiv; } while(pt_pass_current->ptsuiv!=NULL) // Parcours de tous les autres points de passage { if(pt_pass_current->type_point==0) // Si le point est un aérodrome { aerodrome * pass_aerodrome = pt_pass_current->point; // printf("\n AERODROME \n"); x2=conversion_longitude(pass_aerodrome->longitude,donnees)* donnees->xcarte; y2=conversion_lat(pass_aerodrome->latitude,donnees)* donnees->ycarte; // Affichage de l'aerodrome pass_aerodrome->affichage=1; dessiner_aerodromes(pass_aerodrome,donnees); } if(pt_pass_current->type_point==1) // Si le point est une balise { balise * pass_balise = pt_pass_current->point; // printf("\n BALISE \n"); x2=conversion_longitude(pass_balise->longitude,donnees)* donnees->xcarte; y2=conversion_lat(pass_balise->latitude,donnees)* donnees->ycarte; // Affichage de la balise pass_balise->affichage=1; dessiner_balise(pass_balise,donnees); } if(pt_pass_current->type_point==2) // Si le point est un ptgpx { ptgpx * pass = pt_pass_current->point; x2=conversion_longitude(pass->longitude,donnees)* donnees->xcarte; y2=conversion_lat(pass->latitude,donnees)* donnees->ycarte; // Affichage de la balise int x=conversion_longitude(pass->longitude,donnees)* donnees->xcarte; int y=conversion_lat(pass->latitude,donnees)* donnees->ycarte; //gdk_draw_string(carte,font,gc, x + 2,y + 7, pass_balise->nom); gdk_draw_point(cartew,donnees->gc, x,y); } // Une couleur différente par avion couleur(donnees->gc,donnees->c,donnees->couleur_avion); // Trace la ligne et remet la couleur normalement. gdk_draw_line(cartew, donnees->gc, x1,y1,x2,y2); couleur(donnees->gc,donnees->c,10); // Le point 2 devient le point 1 x1=x2; y1=y2; pt_pass_current = pt_pass_current->ptsuiv; } free(loc_avion); } }
void dessiner(file_opener *donnees) { GdkDrawable* cartew=donnees->carte->window; donnees->gc = gdk_gc_new (cartew); // On initialise la police et la couleur donnees->font=gdk_font_load("6x9");//6x9 - 10x20 int j; char text[5]; couleur(donnees->gc,donnees->c,-2); // On trace les parallèles for(j=35;j<=60;j+=5) { sprintf(text,"%d",j); gdk_draw_line(cartew,donnees->gc,0,conversion_lat(j,donnees)*donnees->ycarte,donnees->xcarte*3,conversion_lat(j,donnees)*donnees->ycarte); gdk_draw_string(cartew,donnees->font,donnees->gc,3,conversion_lat(j,donnees)*donnees->ycarte-5,text); } // Puis les méridiens for(j=-15;j<=20;j+=5) { sprintf(text,"%d",j); gdk_draw_line(cartew,donnees->gc,conversion_longitude(j,donnees)*donnees->xcarte,0,conversion_longitude(j,donnees)*donnees->xcarte,donnees->ycarte*3); gdk_draw_string(cartew,donnees->font,donnees->gc,conversion_longitude(j,donnees)*donnees->xcarte+5,8,text); } couleur(donnees->gc,donnees->c,10); /* ---------------------------------- CONTOUR FRANCE -------------------------------------- */ { double x1,x2,y1,y2; // On ouvre le fichier contenant les points FILE *f = fopen("contour_france.csv", "rb"); //printf("f=%p\n", f); if(f) { char buffer[1024]; while(fgets(buffer, sizeof(buffer), f)) { // On charge et on converti les points. sscanf(buffer, "%lf;%lf", &x1, &y1); x1 = conversion_longitude(x1, donnees); y1 = conversion_lat(y1, donnees); while(fgets(buffer, sizeof(buffer), f)) { // Si la ligne est "BREAK" on empeche de tracer la ligne afin de retirer les traits entre les iles if(!strcmp(buffer, "BREAK\n")) { break; } sscanf(buffer, "%lf;%lf", &x2, &y2); x2=conversion_longitude(x2, donnees); y2=conversion_lat(y2, donnees); gdk_draw_line(cartew, donnees->gc, x1*donnees->xcarte,y1*donnees->ycarte,x2*donnees->xcarte,y2*donnees->ycarte); x1=x2; y1=y2; } } fclose(f); } } // ---------------------------------- AERODROMES -------------------------------------- // Si des aérodromes sont chargé on commence l'affichage if(donnees->debutaero!=NULL) { aerodrome* pt_aero=donnees->debutaero; // Boucle pour parcourir tous les aérodromes while(pt_aero->ptsuiv!=NULL) { dessiner_aerodromes(pt_aero,donnees); pt_aero = pt_aero->ptsuiv; } } // ---------------------------------- BALISES -------------------------------------- // La structure est semblable à celle des aérodromes if(donnees->debutbalises!=NULL) { balise* pt_balise=donnees->debutbalises; while(pt_balise->ptsuiv!=NULL) { dessiner_balise(pt_balise,donnees); pt_balise = pt_balise->ptsuiv; } } // ---------------------------------- PLAN DE VOL -------------------------------------- // On initialise la couleur à 0 pour donner une couleur à chaque plan de vol donnees->couleur_avion=0; if(donnees->debutpdv!=NULL) // Rentre si un plan de vol est chargé { pdv * pt_pdv_current=donnees->debutpdv; while(pt_pdv_current!=NULL) // Parcours tous les plans de vol { dessiner_pdv(pt_pdv_current,donnees); pt_pdv_current=pt_pdv_current->ptsuiv; donnees->couleur_avion+=1; } } /* ------------------------------------ CONFLITS ---------------------------------------- */ // Si il y a des conflits if(donnees->deb_conflits!=NULL) { // On passe en couleur rouge couleur(donnees->gc,donnees->c,-3); conflit* conflit_current = donnees->deb_conflits; // Variable d'affichage si reste nul à la fin de la boucle pas de conflit int conflit_affiche = 0; // On parcours les conflits while(conflit_current->ptsuiv != NULL) { pdv* avion1 = conflit_current->pdv1; pdv* avion2 = conflit_current->pdv2; // On se situe entre le temps de début et de fin de conflit if(donnees->temps > conflit_current->temps_deb && donnees->temps < conflit_current->temps_fin) { position c0; // position au temps t if(avion1->affichage && avion2->affichage) // Les deux avions sont affichés { // Conflits affiché conflit_affiche est différent de 0 conflit_affiche++; // On met un gros carré rouge sur la position de l'avion get_position_avion(&c0,avion1,donnees->temps); gdk_draw_rectangle(cartew,donnees->gc,TRUE,conversion_longitude(c0.x,donnees)*donnees->xcarte-3,conversion_lat(c0.y,donnees)*donnees->ycarte-3,7,7); get_position_avion(&c0,avion2,donnees->temps); gdk_draw_rectangle(cartew,donnees->gc,TRUE,conversion_longitude(c0.x,donnees)*donnees->xcarte-3,conversion_lat(c0.y,donnees)*donnees->ycarte-3,7,7); // On change le label de conflit char *markup; markup = g_markup_printf_escaped ("<span foreground=\"#A00000\">%s</span>", "Conflit."); gtk_label_set_markup (GTK_LABEL (donnees->Msg_conflit), markup); g_free (markup); } } conflit_current = conflit_current->ptsuiv; } // Si aucun conflit n'est affiché on passe au label pas de conflit if(conflit_affiche==0) { char *markup; markup = g_markup_printf_escaped ("<span foreground=\"#00A000\">%s</span>", "Pas de conflit\n actuellement."); gtk_label_set_markup (GTK_LABEL (donnees->Msg_conflit), markup); g_free (markup); } // On remet en noir couleur(donnees->gc,donnees->c,10); } gdk_font_unref(donnees->font); g_object_unref (donnees->gc); }
static void gtk_vruler_draw_ticks (GtkRuler *ruler) { GtkWidget *widget; GdkGC *gc, *bg_gc; GdkFont *font; gint i, j; gint width, height; gint xthickness; gint ythickness; gint length, ideal_length; gfloat lower, upper; /* Upper and lower limits, in ruler units */ gfloat increment; /* Number of pixels per unit */ gint scale; /* Number of units per major unit */ gfloat subd_incr; gfloat start, end, cur; gchar unit_str[32]; gchar digit_str[2] = { '\0', '\0' }; gint digit_height; gint text_height; gint pos; g_return_if_fail (ruler != NULL); g_return_if_fail (GTK_IS_VRULER (ruler)); if (!GTK_WIDGET_DRAWABLE (ruler)) return; widget = GTK_WIDGET (ruler); gc = widget->style->fg_gc[GTK_STATE_NORMAL]; bg_gc = widget->style->bg_gc[GTK_STATE_NORMAL]; font = widget->style->font; xthickness = widget->style->klass->xthickness; ythickness = widget->style->klass->ythickness; digit_height = font->ascent; /* assume descent == 0 ? */ width = widget->allocation.height; height = widget->allocation.width - ythickness * 2; gtk_paint_box (widget->style, ruler->backing_store, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, widget, "vruler", 0, 0, widget->allocation.width, widget->allocation.height); gdk_draw_line (ruler->backing_store, gc, height + xthickness, ythickness, height + xthickness, widget->allocation.height - ythickness); upper = ruler->upper / ruler->metric->pixels_per_unit; lower = ruler->lower / ruler->metric->pixels_per_unit; if ((upper - lower) == 0) return; increment = (gfloat) width / (upper - lower); /* determine the scale * use the maximum extents of the ruler to determine the largest * possible number to be displayed. Calculate the height in pixels * of this displayed text. Use this height to find a scale which * leaves sufficient room for drawing the ruler. */ scale = ceil (ruler->max_size / ruler->metric->pixels_per_unit); sprintf (unit_str, "%d", scale); text_height = strlen (unit_str) * digit_height + 1; for (scale = 0; scale < MAXIMUM_SCALES; scale++) if (ruler->metric->ruler_scale[scale] * fabs(increment) > 2 * text_height) break; if (scale == MAXIMUM_SCALES) scale = MAXIMUM_SCALES - 1; /* drawing starts here */ length = 0; for (i = MAXIMUM_SUBDIVIDE - 1; i >= 0; i--) { subd_incr = (gfloat) ruler->metric->ruler_scale[scale] / (gfloat) ruler->metric->subdivide[i]; if (subd_incr * fabs(increment) <= MINIMUM_INCR) continue; /* Calculate the length of the tickmarks. Make sure that * this length increases for each set of ticks */ ideal_length = height / (i + 1) - 1; if (ideal_length > ++length) length = ideal_length; if (lower < upper) { start = floor (lower / subd_incr) * subd_incr; end = ceil (upper / subd_incr) * subd_incr; } else { start = floor (upper / subd_incr) * subd_incr; end = ceil (lower / subd_incr) * subd_incr; } for (cur = start; cur <= end; cur += subd_incr) { pos = ROUND ((cur - lower) * increment); gdk_draw_line (ruler->backing_store, gc, height + xthickness - length, pos, height + xthickness, pos); /* draw label */ if (i == 0) { sprintf (unit_str, "%d", (int) cur); for (j = 0; j < (int) strlen (unit_str); j++) { digit_str[0] = unit_str[j]; gdk_draw_string (ruler->backing_store, font, gc, xthickness + 1, pos + digit_height * (j + 1) + 1, digit_str); } } } } }
static void gtk_ui_draw_string(const char *str, int x, int y) { gdk_draw_string(offscreen, font, stdgc, x, y, str); }
static void gtk_hruler_draw_ticks (GtkRuler *ruler) { GtkWidget *widget; GdkGC *gc, *bg_gc; GdkFont *font; gint i; gint width, height; gint xthickness; gint ythickness; gint length, ideal_length; gfloat lower, upper; /* Upper and lower limits, in ruler units */ gfloat increment; /* Number of pixels per unit */ gint scale; /* Number of units per major unit */ gfloat subd_incr; gfloat start, end, cur; gchar unit_str[32]; gint digit_height; gint text_width; gint pos; g_return_if_fail (ruler != NULL); g_return_if_fail (GTK_IS_HRULER (ruler)); if (!GTK_WIDGET_DRAWABLE (ruler)) return; widget = GTK_WIDGET (ruler); gc = widget->style->fg_gc[GTK_STATE_NORMAL]; bg_gc = widget->style->bg_gc[GTK_STATE_NORMAL]; font = widget->style->font; xthickness = widget->style->klass->xthickness; ythickness = widget->style->klass->ythickness; digit_height = font->ascent; /* assume descent == 0 ? */ width = widget->allocation.width; height = widget->allocation.height - ythickness * 2; gtk_paint_box (widget->style, ruler->backing_store, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, widget, "hruler", 0, 0, widget->allocation.width, widget->allocation.height); gdk_draw_line (ruler->backing_store, gc, xthickness, height + ythickness, widget->allocation.width - xthickness, height + ythickness); upper = ruler->upper / ruler->metric->pixels_per_unit; lower = ruler->lower / ruler->metric->pixels_per_unit; if ((upper - lower) == 0) return; increment = (gfloat) width / (upper - lower); /* determine the scale * We calculate the text size as for the vruler instead of using * text_width = gdk_string_width(font, unit_str), so that the result * for the scale looks consistent with an accompanying vruler */ scale = ceil (ruler->max_size / ruler->metric->pixels_per_unit); sprintf (unit_str, "%d", scale); text_width = strlen (unit_str) * digit_height + 1; for (scale = 0; scale < MAXIMUM_SCALES; scale++) if (ruler->metric->ruler_scale[scale] * fabs(increment) > 2 * text_width) break; if (scale == MAXIMUM_SCALES) scale = MAXIMUM_SCALES - 1; /* drawing starts here */ length = 0; for (i = MAXIMUM_SUBDIVIDE - 1; i >= 0; i--) { subd_incr = (gfloat) ruler->metric->ruler_scale[scale] / (gfloat) ruler->metric->subdivide[i]; if (subd_incr * fabs(increment) <= MINIMUM_INCR) continue; /* Calculate the length of the tickmarks. Make sure that * this length increases for each set of ticks */ ideal_length = height / (i + 1) - 1; if (ideal_length > ++length) length = ideal_length; if (lower < upper) { start = floor (lower / subd_incr) * subd_incr; end = ceil (upper / subd_incr) * subd_incr; } else { start = floor (upper / subd_incr) * subd_incr; end = ceil (lower / subd_incr) * subd_incr; } for (cur = start; cur <= end; cur += subd_incr) { pos = ROUND ((cur - lower) * increment); gdk_draw_line (ruler->backing_store, gc, pos, height + ythickness, pos, height - length + ythickness); /* draw label */ if (i == 0) { sprintf (unit_str, "%d", (int) cur); gdk_draw_string (ruler->backing_store, font, gc, pos + 2, ythickness + font->ascent - 1, unit_str); } } } }
/* drawBlock * Draws a block with the specified x,y and letter * * @return void */ void drawBlock (GtkWidget *widget, gint x, gint y, short int lower, short int upper, const gchar* string) { x = x + border_width; gdk_draw_rectangle(this.pixMap, widget->style->fg_gc[0], TRUE, x, y, 120, 120); // Upper left if (upper) { gdk_draw_rectangle(this.pixMap, widget->style->white_gc, TRUE, (x+20), y, 20, 20); gdk_draw_string(this.pixMap, gdk_font_load("-*-*-bold-r-normal--*-100-*-*-*-*-iso8859-1"), widget->style->black_gc, (x+28), (y+16), "1"); } gdk_draw_rectangle(this.pixMap, widget->style->white_gc, TRUE, x, (y+20), 20, 20); if (!lower) { gdk_draw_string(this.pixMap, gdk_font_load("-*-*-bold-r-normal--*-100-*-*-*-*-iso8859-1"), widget->style->black_gc, (x+8), (y+36), "6"); } else if (!upper) { gdk_draw_string(this.pixMap, gdk_font_load("-*-*-bold-r-normal--*-100-*-*-*-*-iso8859-1"), widget->style->black_gc, (x+8), (y+36), "1"); } else { gdk_draw_string(this.pixMap, gdk_font_load("-*-*-bold-r-normal--*-100-*-*-*-*-iso8859-1"), widget->style->black_gc, (x+8), (y+36), "8"); } // Lower left gdk_draw_rectangle(this.pixMap, widget->style->white_gc, TRUE, x, (y+80), 20, 20); if (!lower) { gdk_draw_string(this.pixMap, gdk_font_load("-*-*-bold-r-normal--*-100-*-*-*-*-iso8859-1"), widget->style->black_gc, (x+8), (y+96), "5"); } else if (!upper) { gdk_draw_string(this.pixMap, gdk_font_load("-*-*-bold-r-normal--*-100-*-*-*-*-iso8859-1"), widget->style->black_gc, (x+8), (y+96), "6"); } else { gdk_draw_string(this.pixMap, gdk_font_load("-*-*-bold-r-normal--*-100-*-*-*-*-iso8859-1"), widget->style->black_gc, (x+8), (y+96), "7"); } if (lower) { gdk_draw_rectangle(this.pixMap, widget->style->white_gc, TRUE, (x+20), (y+100), 20, 20); if (!upper) { gdk_draw_string(this.pixMap, gdk_font_load("-*-*-bold-r-normal--*-100-*-*-*-*-iso8859-1"), widget->style->black_gc, (x+28), (y+116), "5"); } else { gdk_draw_string(this.pixMap, gdk_font_load("-*-*-bold-r-normal--*-100-*-*-*-*-iso8859-1"), widget->style->black_gc, (x+28), (y+116), "6"); } } // Upper right if (upper) { gdk_draw_rectangle(this.pixMap, widget->style->white_gc, TRUE, (x+80), y, 20, 20); gdk_draw_string(this.pixMap, gdk_font_load("-*-*-bold-r-normal--*-100-*-*-*-*-iso8859-1"), widget->style->black_gc, (x+88), (y+16), "2"); } gdk_draw_rectangle(this.pixMap, widget->style->white_gc, TRUE, (x+100), (y+20), 20, 20); if (!upper) { gdk_draw_string(this.pixMap, gdk_font_load("-*-*-bold-r-normal--*-100-*-*-*-*-iso8859-1"), widget->style->black_gc, (x+108), (y+36), "2"); } else { gdk_draw_string(this.pixMap, gdk_font_load("-*-*-bold-r-normal--*-100-*-*-*-*-iso8859-1"), widget->style->black_gc, (x+108), (y+36), "3"); } // Lower right gdk_draw_rectangle(this.pixMap, widget->style->white_gc, TRUE, (x+100), (y+80), 20, 20); if (!upper) { gdk_draw_string(this.pixMap, gdk_font_load("-*-*-bold-r-normal--*-100-*-*-*-*-iso8859-1"), widget->style->black_gc, (x+108), (y+96), "3"); } else { gdk_draw_string(this.pixMap, gdk_font_load("-*-*-bold-r-normal--*-100-*-*-*-*-iso8859-1"), widget->style->black_gc, (x+108), (y+96), "4"); } if (lower) { gdk_draw_rectangle(this.pixMap, widget->style->white_gc, TRUE, (x+80), (y+100), 20, 20); if (!upper) { gdk_draw_string(this.pixMap, gdk_font_load("-*-*-bold-r-normal--*-100-*-*-*-*-iso8859-1"), widget->style->black_gc, (x+88), (y+116), "4"); } else { gdk_draw_string(this.pixMap, gdk_font_load("-*-*-bold-r-normal--*-100-*-*-*-*-iso8859-1"), widget->style->black_gc, (x+88), (y+116), "5"); } } gdk_draw_string(this.pixMap, gdk_font_load("-*-*-bold-r-normal--*-300-*-*-*-*-iso8859-1"), widget->style->black_gc, (x+50), (y+70), string); }
void vik_viewport_draw_string ( VikViewport *vvp, GdkFont *font, GdkGC *gc, gint x1, gint y1, const gchar *string ) { if ( x1 > -100 && x1 < vvp->width + 100 && y1 > -100 && y1 < vvp->height + 100 ) gdk_draw_string ( vvp->scr_buffer, font, gc, x1, y1, string ); }
/* drawThreadville * Draws the main scene * * @return void */ void drawThreadville (GtkWidget *widget) { GdkColor color; gdk_color_parse("#4C4C4C", &color); GdkGC *gc = gdk_gc_new(this.drawingArea->window); gdk_gc_set_rgb_fg_color(gc, &color); // Background gdk_draw_rectangle(this.pixMap, widget->style->bg_gc[0], TRUE, 0, 0, widget->allocation.width, widget->allocation.height); // Streets gdk_draw_rectangle(this.pixMap, gc, TRUE, border_width, 0, canvas_width, canvas_height); // Uptown Blocks - top drawBlock (widget, 20, 20, 1, 1, "A"); drawBlock (widget, 180, 20, 1, 1, "B"); drawBlock (widget, 340, 20, 1, 1, "C"); drawBlock (widget, 500, 20, 1, 1, "D"); drawBlock (widget, 660, 20, 1, 1, "E"); drawBlock (widget, 820, 20, 1, 1, "F"); // Uptown Blocks - bottom drawBlock (widget, 20, 160, 0, 1, "G"); drawBlock (widget, 180, 160, 0, 1, "H"); drawBlock (widget, 340, 160, 0, 1, "I"); drawBlock (widget, 500, 160, 0, 1, "J"); drawBlock (widget, 660, 160, 0, 1, "K"); drawBlock (widget, 820, 160, 0, 1, "L"); gdk_draw_rectangle(this.pixMap, widget->style->bg_gc[0], TRUE, border_width+unit, 280, 920, 20); // Central Lines gdk_draw_line(this.pixMap, widget->style->fg_gc[0], border_width+unit, 320, window_width-border_width-unit, 320); gdk_draw_line(this.pixMap, widget->style->bg_gc[0], border_width+unit, 340, window_width-border_width-unit, 340); gdk_draw_line(this.pixMap, widget->style->fg_gc[0], border_width+unit, 360, window_width-border_width-unit, 360); gdk_draw_rectangle(this.pixMap, widget->style->bg_gc[0], TRUE, border_width+unit, 380, 920, 20); // Downtonw Blocks - top drawBlock (widget, 20, 400, 1, 0, "M"); drawBlock (widget, 180, 400, 1, 0, "N"); drawBlock (widget, 340, 400, 1, 0, "O"); drawBlock (widget, 500, 400, 1, 0, "P"); drawBlock (widget, 660, 400, 1, 0, "Q"); drawBlock (widget, 820, 400, 1, 0, "R"); // Downtonw Blocks - bottom drawBlock (widget, 20, 540, 1, 1, "S"); drawBlock (widget, 180, 540, 1, 1, "T"); drawBlock (widget, 340, 540, 1, 1, "U"); drawBlock (widget, 500, 540, 1, 1, "V"); drawBlock (widget, 660, 540, 1, 1, "W"); drawBlock (widget, 820, 540, 1, 1, "X"); // Bridges gdk_color_parse("#C1C1C1", &color); GdkGC *gc_bridge = gdk_gc_new(this.drawingArea->window); gdk_gc_set_rgb_fg_color(gc_bridge, &color); gdk_draw_rectangle(this.pixMap, gc_bridge, TRUE, border_width+150, 280, 20, unit*6); gdk_draw_rectangle(this.pixMap, gc_bridge, TRUE, border_width+310, 280, 20, unit*6); gdk_draw_rectangle(this.pixMap, gc_bridge, TRUE, border_width+470, 280, 20, unit*6); gdk_draw_rectangle(this.pixMap, gc_bridge, TRUE, border_width+630, 280, 20, unit*6); gdk_draw_rectangle(this.pixMap, gc_bridge, TRUE, border_width+790, 280, 20, unit*6); // Vertical lines gdk_draw_line(this.pixMap, widget->style->fg_gc[0], border_width+160, 20, border_width+160, 280); gdk_draw_line(this.pixMap, widget->style->fg_gc[0], border_width+320, 20, border_width+320, 280); gdk_draw_line(this.pixMap, widget->style->fg_gc[0], border_width+480, 20, border_width+480, 280); gdk_draw_line(this.pixMap, widget->style->fg_gc[0], border_width+640, 20, border_width+640, 280); gdk_draw_line(this.pixMap, widget->style->fg_gc[0], border_width+800, 20, border_width+800, 280); gdk_draw_line(this.pixMap, widget->style->fg_gc[0], border_width+160, 400, border_width+160, 660); gdk_draw_line(this.pixMap, widget->style->fg_gc[0], border_width+320, 400, border_width+320, 660); gdk_draw_line(this.pixMap, widget->style->fg_gc[0], border_width+480, 400, border_width+480, 660); gdk_draw_line(this.pixMap, widget->style->fg_gc[0], border_width+640, 400, border_width+640, 660); gdk_draw_line(this.pixMap, widget->style->fg_gc[0], border_width+800, 400, border_width+800, 660); // Rotondas Y gdk_draw_arc(this.pixMap, gc, TRUE, 0, 280, 120, 120, 0, 360*64); gdk_draw_arc(this.pixMap, widget->style->bg_gc[0], TRUE, 20, 300, 80, 80, 0, 360*64); gdk_draw_string(this.pixMap, gdk_font_load("-*-*-bold-r-normal--*-300-*-*-*-*-iso8859-1"), widget->style->black_gc, 50, 355, "Y"); // Rotondas Z gdk_draw_arc(this.pixMap, gc, TRUE, border_width+canvas_width-unit*2, 280, 120, 120, 0, 360*64); gdk_draw_arc(this.pixMap, widget->style->bg_gc[0], TRUE, border_width+canvas_width-unit, 300, 80, 80, 0, 360*64); gdk_draw_string(this.pixMap, gdk_font_load("-*-*-bold-r-normal--*-300-*-*-*-*-iso8859-1"), widget->style->black_gc, border_width+canvas_width+10, 355, "Z"); }
void MdispGtkView::InitializeOverlay() { MIL_TEXT_CHAR chText[80]; // Initialize overlay if not already done if ((!m_isOverlayInitialized) && (m_MilDisplay)) { //Only do it on a valid windowed display [CALL TO MIL] if (m_MilImage && m_MilDisplay ) { // Prepare overlay buffer // //////////////////////////// // Enable display overlay annotations. MdispControl(m_MilDisplay, M_OVERLAY, M_ENABLE); // Inquire the Overlay buffer associated with the displayed buffer [CALL TO MIL] MdispInquire(m_MilDisplay, M_OVERLAY_ID, &m_MilOverlayImage); // Clear the overlay to transparent. MdispControl(m_MilDisplay, M_OVERLAY_CLEAR, M_DEFAULT); // Disable the overlay display update to accelerate annotations. MdispControl(m_MilDisplay, M_OVERLAY_SHOW, M_DISABLE); // Draw MIL monochrome overlay annotation * //***************************************** // Inquire MilOverlayImage size x and y [CALL TO MIL] long imageWidth = MbufInquire(m_MilOverlayImage,M_SIZE_X,M_NULL); long imageHeight = MbufInquire(m_MilOverlayImage,M_SIZE_Y,M_NULL); // Set graphic text to transparent background. [CALL TO MIL] MgraControl(M_DEFAULT, M_BACKGROUND_MODE, M_TRANSPARENT); // Set drawing color to white. [CALL TO MIL] MgraColor(M_DEFAULT, M_COLOR_WHITE); // Print a string in the overlay image buffer. [CALL TO MIL] MgraText(M_DEFAULT, m_MilOverlayImage, imageWidth/9, imageHeight/5, " -------------------- "); MgraText(M_DEFAULT, m_MilOverlayImage, imageWidth/9, imageHeight/5+25, " - MIL Overlay Text - "); MgraText(M_DEFAULT, m_MilOverlayImage, imageWidth/9, imageHeight/5+50, " -------------------- "); // Print a green string in the green component overlay image buffer. [CALL TO MIL] MgraColor(M_DEFAULT, M_COLOR_GREEN); MgraText(M_DEFAULT, m_MilOverlayImage, imageWidth*11/18, imageHeight/5, " -------------------- "); MgraText(M_DEFAULT, m_MilOverlayImage, imageWidth*11/18, imageHeight/5+25, " - MIL Overlay Text - "); MgraText(M_DEFAULT, m_MilOverlayImage, imageWidth*11/18, imageHeight/5+50, " -------------------- "); // Draw GDI color overlay annotation * //************************************ // Disable hook to MIL error because control might not be supported MappControl(M_ERROR_HOOKS, M_DISABLE); // Create a device context to draw in the overlay buffer with GDI. [CALL TO MIL] MbufControl(m_MilOverlayImage, M_XPIXMAP_ALLOC, M_COMPENSATION_ENABLE); // Reenable hook to MIL error MappControl(M_ERROR_HOOKS, M_ENABLE); // Retrieve the XPIXMAP of the overlay [CALL TO MIL] Pixmap XPixmap = (Pixmap)MbufInquire(m_MilOverlayImage, M_XPIXMAP_HANDLE, M_NULL); /* convert it to gdkpixmap */ GdkPixmap *gdkpixmap = gdk_pixmap_foreign_new(XPixmap); if(gdkpixmap) { GdkPoint Hor[2]; GdkPoint Ver[2]; GdkColor color[3]; GdkFont *font = NULL; font = gdk_font_load ("-misc-*-*-r-*-*-*-140-*-*-*-*-*-1"); int i; /* get graphic context from pixmap*/ GdkGC *gc = gdk_gc_new(gdkpixmap); /* allocate colors */ gdk_color_parse("blue",&color[0]); gdk_color_parse("red",&color[1]); gdk_color_parse("yellow",&color[2]); for(i=0;i<3;i++) gdk_color_alloc(gdk_colormap_get_system(), &color[i]); /* set the foreground to our color */ gdk_gc_set_foreground(gc, &color[0]); // Draw a blue cross in the overlay buffer. Hor[0].x = 0; Hor[0].y = imageHeight/2; Hor[1].x = imageWidth; Hor[1].y = imageHeight/2; gdk_draw_lines(gdkpixmap,gc,Hor,2); Ver[0].x = imageWidth/2; Ver[0].y = 0; Ver[1].x = imageWidth/2; Ver[1].y = imageHeight; gdk_draw_lines(gdkpixmap,gc,Ver,2); // Write Red text in the overlay buffer. MosStrcpy(chText, 80, "X Overlay Text "); gdk_gc_set_foreground(gc, &color[1]); gdk_draw_string(gdkpixmap, font, gc, imageWidth*3/18, imageHeight*4/6, chText); // Write Yellow text in the overlay buffer. gdk_gc_set_foreground(gc, &color[2]); gdk_draw_string(gdkpixmap, font, gc, imageWidth*12/18, imageHeight*4/6, chText); /* flush */ gdk_display_flush(gdk_display_get_default()); /* Free graphic context.*/ g_object_unref(gc); // Delete created Pixmap. [CALL TO MIL] MbufControl(m_MilOverlayImage, M_XPIXMAP_FREE, M_DEFAULT); // Signal MIL that the overlay buffer was modified. [CALL TO MIL] MbufControl(m_MilOverlayImage, M_MODIFIED, M_DEFAULT); } // Now that overlay buffer is correctly prepared, we can show it [CALL TO MIL] MdispControl(m_MilDisplay, M_OVERLAY_SHOW, M_ENABLE); // Overlay is now initialized m_isOverlayInitialized = true; } } }
static void gtk_hex_entry_paint (GtkWidget *widget, GdkRectangle *area) { GtkHexEntry *hex_entry; GdkRectangle def_area; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_HEX_ENTRY (widget)); hex_entry = GTK_HEX_ENTRY (widget); if (area == NULL) { area = &def_area; area->x = area->y = 0; area->width = widget->allocation.width; area->height = widget->allocation.height; } if (hex_entry->pixmap==NULL) hex_entry->pixmap = gdk_pixmap_new (widget->window, widget->allocation.width, widget->allocation.height, -1); if (GTK_WIDGET_DRAWABLE (widget)) { gint w,h; w = gdk_char_width (hex_entry->font,'0'); h = hex_entry->font->ascent + hex_entry->font->descent; if (hex_entry->selected) { gdk_draw_rectangle (hex_entry->pixmap,widget->style->white_gc,TRUE, 0,0,widget->allocation.width,widget->allocation.height); } else { gdk_draw_rectangle (hex_entry->pixmap,widget->style->bg_gc[GTK_WIDGET_STATE (widget)],TRUE, 0,0,widget->allocation.width,widget->allocation.height); } /* if (hex_entry->has_selection) { g_print ("%d, %d\n",hex_entry->selection_start_pos,hex_entry->selection_end_pos); gdk_draw_rectangle (hex_entry->pixmap,widget->style->black_gc,TRUE, (hex_entry->selection_start_pos*w),0, ((hex_entry->selection_end_pos-hex_entry->selection_start_pos)*w),h); } */ if (GTK_WIDGET_HAS_FOCUS(widget)) { if ( (hex_entry->cursor_position>=0) && (hex_entry->cursor_position<hex_entry->digits) ) { gdk_draw_rectangle (hex_entry->pixmap,hex_entry->gc,TRUE, (hex_entry->cursor_position*w), 0,w,h); } } gdk_draw_string (hex_entry->pixmap, hex_entry->font, widget->style->fg_gc[hex_entry->modified ? GTK_STATE_SELECTED : GTK_WIDGET_STATE (widget)], 0, hex_entry->font->ascent, hex_entry->buffer); gdk_draw_pixmap (widget->window, widget->style->fg_gc[GTK_WIDGET_STATE (widget)], hex_entry->pixmap, area->x, area->y, area->x, area->y, area->width, area->height); } }