/* ***************************************************************************** * Draw Text (lat/lon) into Grid */ void draw_grid_text (GtkWidget * widget, gdouble posx, gdouble posy, gchar * txt) { /* prints in pango */ PangoFontDescription *pfd; PangoLayout *grid_label_layout; gint width, height; grid_label_layout = gtk_widget_create_pango_layout (map_drawingarea, txt); pfd = pango_font_description_from_string ("Sans 8"); pango_layout_set_font_description (grid_label_layout, pfd); pango_layout_get_pixel_size (grid_label_layout, &width, &height); gdk_gc_set_function (kontext_map, GDK_XOR); gdk_gc_set_background (kontext_map, &colors.white); gdk_gc_set_foreground (kontext_map, &colors.mygray); gdk_draw_layout_with_colors (drawable, kontext_map, posx - width / 2, posy - height / 2, grid_label_layout, &colors.black, NULL); if (grid_label_layout != NULL) g_object_unref (G_OBJECT (grid_label_layout)); /* freeing PangoFontDescription, cause it has been copied by prev. call */ pango_font_description_free (pfd); }
/* ***************************************************************************** */ void display_dsc (void) { GdkGC *kontext; gint len; gchar *text; PangoFontDescription *pfd; PangoLayout *wplabellayout; if (!do_display_dsc) return; if ((textcount >= (int) strlen (displaytext))) { do_display_dsc = FALSE; free (displaytext); displaytext = NULL; return; } if (textcount > 20) text = displaytext + textcount; else text = displaytext; kontext = gdk_gc_new (drawable); len = strlen (text); /* if (len>10) */ /* len=10; */ /* gdk_gc_set_function (kontext, GDK_OR); */ gdk_gc_set_foreground (kontext, &colors.mygray); gdk_draw_rectangle (drawable, kontext, 1, 0, gui_status.mapview_y - 40, gui_status.mapview_x, 40); gdk_gc_set_function (kontext, GDK_COPY); /* gdk_gc_set_foreground (kontext, &blue); */ /* prints in pango */ wplabellayout = gtk_widget_create_pango_layout (map_drawingarea, text); //KCFX if (local_config.guimode == GUI_PDA) pfd = pango_font_description_from_string ("Sans 8"); else pfd = pango_font_description_from_string ("Sans bold 14"); pango_layout_set_font_description (wplabellayout, pfd); /* pango_layout_get_pixel_size (wplabellayout, &width, &height); */ gdk_draw_layout_with_colors (drawable, kontext, 11, gui_status.mapview_y - 30, wplabellayout, &colors.blue, NULL); if (wplabellayout != NULL) g_object_unref (G_OBJECT (wplabellayout)); /* freeing PangoFontDescription, cause it has been copied by prev. call */ pango_font_description_free (pfd); textcount += 2; }
static VALUE rg_draw_layout(int argc, VALUE *argv, VALUE self) { VALUE gc, x, y, layout, fg, bg; rb_scan_args(argc, argv, "42", &gc, &x, &y, &layout, &fg, &bg); gdk_draw_layout_with_colors(_SELF(self), GDK_GC(RVAL2GOBJ(gc)), NUM2INT(x), NUM2INT(y), PANGO_LAYOUT(RVAL2GOBJ(layout)), RVAL2GDKCOLOR(fg), RVAL2GDKCOLOR(bg)); return self; }
static void clearlooks_style_draw_layout (GtkStyle * style, GdkWindow * window, GtkStateType state_type, gboolean use_text, GdkRectangle * area, GtkWidget * widget, const gchar * detail, gint x, gint y, PangoLayout * layout) { (void) detail; GdkGC *gc; g_return_if_fail (GTK_IS_STYLE (style)); g_return_if_fail (window != NULL); gc = use_text ? style->text_gc[state_type] : style->fg_gc[state_type]; if (area) gdk_gc_set_clip_rectangle (gc, area); if (state_type == GTK_STATE_INSENSITIVE) { ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); ClearlooksColors *colors = &clearlooks_style->colors; WidgetParameters params; GdkColor etched; CairoColor temp; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); if (GTK_WIDGET_NO_WINDOW (widget)) ge_shade_color (¶ms.parentbg, 1.2, &temp); else ge_shade_color (&colors->bg[widget->state], 1.2, &temp); etched.red = (int) (temp.r * 65535); etched.green = (int) (temp.g * 65535); etched.blue = (int) (temp.b * 65535); gdk_draw_layout_with_colors (window, gc, x + 1, y + 1, layout, &etched, NULL); gdk_draw_layout (window, gc, x, y, layout); } else gdk_draw_layout (window, gc, x, y, layout); if (area) gdk_gc_set_clip_rectangle (gc, NULL); }
static gboolean label_exposed(GtkWidget *label, GdkEventExpose *event, gpointer data) { UIMCandWinHorizontalGtk *horizontal_cwin = data; struct index_button *selected; GtkWidget *selected_label = NULL; selected = horizontal_cwin->selected; if (selected) selected_label = gtk_bin_get_child(GTK_BIN(selected->button)); if (label == selected_label) { gint x; get_layout_x(GTK_LABEL(label), &x); gdk_draw_layout_with_colors(label->window, label->style->black_gc, x, 0, GTK_LABEL(label)->layout, &label->style->text[GTK_STATE_SELECTED], &label->style->bg[GTK_STATE_SELECTED]); } return FALSE; }
static void draw_layout (GtkStyle *style, GdkWindow *window, GtkStateType state_type, gboolean use_text, GdkRectangle *area, GtkWidget *widget, const char *detail, gint x, gint y, PangoLayout *layout) { /* Simply draw the text, without any of the fancy effects for insensitive * state in the default theme engine */ GdkGC *gc; /* FIXME: memory leak */ LOG ("widget=%s, primitive=layout, state=%s, detail='%s', name='%s'", G_OBJECT_TYPE_NAME (widget), enum_value_to_string (gtk_state_type_get_type (), state_type), detail, gtk_widget_get_name (widget)); gc = use_text ? style->text_gc[state_type] : style->fg_gc[state_type]; if (area) gdk_gc_set_clip_rectangle (gc, area); /* Draw the optional shadow */ if (SAPWOOD_RC_STYLE (style->rc_style)->has_shadow) gdk_draw_layout_with_colors (window, gc, x + 1, y + 1, layout, &SAPWOOD_RC_STYLE (style->rc_style)->shadowcolor, NULL); gdk_draw_layout (window, gc, x, y, layout); if (area) gdk_gc_set_clip_rectangle (gc, NULL); }
/* Draw method handler for the icon text item */ static void mate_icon_text_item_draw (MateCanvasItem *item, GdkDrawable *drawable, int x, int y, int width, int height) { GtkWidget *widget; GtkStyle *style; int xofs, yofs; int text_xofs, text_yofs; int w, h; MateIconTextItem *iti; MateIconTextItemPrivate *priv; GtkStateType state; widget = GTK_WIDGET (item->canvas); iti = MATE_ICON_TEXT_ITEM (item); priv = iti->_priv; style = GTK_WIDGET (MATE_CANVAS_ITEM (iti)->canvas)->style; w = priv->layout_width + 2 * MARGIN_X; h = priv->layout_height + 2 * MARGIN_Y; xofs = item->x1 - x; yofs = item->y1 - y; text_xofs = xofs - (iti->width - priv->layout_width - 2 * MARGIN_X) / 2; text_yofs = yofs + MARGIN_Y; if (iti->selected && GTK_WIDGET_HAS_FOCUS (widget)) state = GTK_STATE_SELECTED; else if (iti->selected) state = GTK_STATE_ACTIVE; else state = GTK_STATE_NORMAL; if (iti->selected && !iti->editing) gdk_draw_rectangle (drawable, style->base_gc[state], TRUE, xofs + 1, yofs + 1, w - 2, h - 2); if (GTK_WIDGET_HAS_FOCUS (widget) && iti->focused && ! iti->editing) { GdkRectangle r; r.x = xofs; r.y = yofs; r.width = w - 1; r.height = h - 1; gtk_paint_focus (style, drawable, iti->selected ? GTK_STATE_SELECTED: GTK_STATE_NORMAL, &r, widget, NULL, xofs, yofs, w - 1, h - 1); #if 0 gtk_draw_focus (style, drawable, xofs, yofs, w - 1, h - 1); #endif } if (iti->editing) { /* FIXME: are these the right graphics contexts? */ gdk_draw_rectangle (drawable, style->base_gc[GTK_STATE_NORMAL], TRUE, xofs, yofs, w - 1, h - 1); gdk_draw_rectangle (drawable, style->fg_gc[GTK_STATE_NORMAL], FALSE, xofs, yofs, w - 1, h - 1); } gdk_draw_layout (drawable, style->text_gc[iti->editing ? GTK_STATE_NORMAL : state], text_xofs, text_yofs, priv->layout); if (iti->editing) { int range[2]; if (gtk_editable_get_selection_bounds (GTK_EDITABLE (priv->entry), &range[0], &range[1])) { GdkRegion *clip_region; GdkColor *selection_color, *text_color; guint8 state; range[0] = g_utf8_offset_to_pointer (GTK_ENTRY (priv->entry)->text, range[0]) - GTK_ENTRY (priv->entry)->text; range[1] = g_utf8_offset_to_pointer (GTK_ENTRY (priv->entry)->text, range[1]) - GTK_ENTRY (priv->entry)->text; state = GTK_WIDGET_HAS_FOCUS (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE; selection_color = &widget->style->base[state]; text_color = &widget->style->text[state]; clip_region = gdk_pango_layout_get_clip_region (priv->layout, text_xofs, text_yofs, range, 1); gdk_gc_set_clip_region (widget->style->black_gc, clip_region); gdk_draw_layout_with_colors (drawable, widget->style->black_gc, text_xofs, text_yofs, priv->layout, text_color, selection_color); gdk_gc_set_clip_region (widget->style->black_gc, NULL); gdk_region_destroy (clip_region); } else { iti_draw_cursor (iti, drawable, text_xofs, text_yofs); } } }
/* Do the Pango text rendering. If called when pixmap is bg_text_layer, | it is a background draw. But if called from push_decal_pixmaps() it is | considered a push operation because it is being done whenever any panel | decals or krells are modified. In this case, Pango does the pixel pushing | instead of gkrellm as was done in pre 2.2.0. */ static void panel_draw_decal_text_list(GdkPixmap *pixmap, GkrellmDecal *d) { PangoLayout *layout; GdkRectangle rect; GList *list; GkrellmText *tx; GkrellmTextstyle *ts; gchar *s; gint x, y; layout = gtk_widget_create_pango_layout(gkrellm_get_top_window(), NULL); rect.x = d->x; rect.y = d->y; rect.width = d->w; rect.height = d->h; gdk_gc_set_clip_rectangle(_GK.text_GC, &rect); for (list = d->text_list; list; list = list->next) { tx = (GkrellmText *) list->data; if (!*tx->text) continue; ts = &tx->text_style; pango_layout_set_font_description(layout, ts->font); x = tx->x_off; y = tx->y_off; if (d->flags & DF_SCROLL_TEXT_DIVERTED) { if (d->flags & DF_SCROLL_TEXT_CENTER) pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); if (d->flags & DF_SCROLL_TEXT_H_LOOP) { x %= d->scroll_width; if (x > 0) x -= d->scroll_width; s = g_strconcat(tx->text, tx->text, NULL); if (d->flags & DF_TEXT_USE_MARKUP) pango_layout_set_markup(layout, s, strlen(s)); else pango_layout_set_text(layout, s, strlen(s)); g_free(s); } else if (d->flags & DF_SCROLL_TEXT_V_LOOP) { y %= d->scroll_height + d->y_ink; if (y > 0) y -= d->scroll_height + d->y_ink; s = g_strconcat(tx->text, "\n", tx->text, NULL); if (d->flags & DF_TEXT_USE_MARKUP) pango_layout_set_markup(layout, s, strlen(s)); else pango_layout_set_text(layout, s, strlen(s)); g_free(s); } else { if (d->flags & DF_TEXT_USE_MARKUP) pango_layout_set_markup(layout, tx->text,strlen(tx->text)); else pango_layout_set_text(layout, tx->text, strlen(tx->text)); } } else { if (d->flags & DF_TEXT_USE_MARKUP) pango_layout_set_markup(layout, tx->text, strlen(tx->text)); else pango_layout_set_text(layout, tx->text, strlen(tx->text)); } x += d->x; y += d->y; if (ts->effect) { gdk_gc_set_foreground(_GK.text_GC, &ts->shadow_color); gdk_draw_layout_with_colors(pixmap, _GK.text_GC, x + 1, y + 1, layout, &ts->shadow_color, NULL); } gdk_gc_set_foreground(_GK.text_GC, &ts->color); gdk_draw_layout(pixmap, _GK.text_GC, x, y, layout); } gdk_gc_set_clip_rectangle(_GK.text_GC, NULL); g_object_unref(layout); }
/* Redraw the ruler */ static gboolean histo_expose_ruler( GtkWidget *widget, GdkEventExpose *event, gpointer user_data ) { histoDrawing_t *drawing = (histoDrawing_t*)user_data; TimeWindow time_window = lttvwindow_get_time_window(drawing->histo_control_flow_data->tab); gchar text[255]; PangoContext *context; PangoLayout *layout; PangoFontDescription *FontDesc; PangoRectangle ink_rect; gint global_width=0; GdkColor foreground = { 0, 0, 0, 0 }; GdkColor background = { 0, 0xffff, 0xffff, 0xffff }; LttTime window_end = time_window.end_time; LttTime half_width = ltt_time_div(time_window.time_width,2.0); LttTime window_middle = ltt_time_add(half_width, time_window.start_time); g_debug("ruler expose event"); gdk_draw_rectangle (drawing->ruler->window, drawing->ruler->style->white_gc, TRUE, event->area.x, event->area.y, event->area.width, event->area.height); gdk_draw_line (drawing->ruler->window, drawing->ruler_gc_butt, event->area.x, 1, event->area.x + event->area.width, 1); snprintf(text, 255, "%lus\n%luns", time_window.start_time.tv_sec, time_window.start_time.tv_nsec); layout = gtk_widget_create_pango_layout(drawing->drawing_area, NULL); context = pango_layout_get_context(layout); FontDesc = pango_context_get_font_description(context); pango_font_description_set_size(FontDesc, 6*PANGO_SCALE); pango_layout_context_changed(layout); pango_layout_set_text(layout, text, -1); pango_layout_get_pixel_extents(layout, &ink_rect, NULL); global_width += ink_rect.width; gdk_draw_layout_with_colors(drawing->ruler->window, drawing->ruler_gc_butt, 0, 6, layout, &foreground, &background); gdk_draw_line (drawing->ruler->window, drawing->ruler_gc_round, 1, 1, 1, 7); snprintf(text, 255, "%lus\n%luns", window_end.tv_sec, window_end.tv_nsec); pango_layout_set_text(layout, text, -1); pango_layout_get_pixel_extents(layout, &ink_rect, NULL); global_width += ink_rect.width; if(global_width <= drawing->ruler->allocation.width) { gdk_draw_layout_with_colors(drawing->ruler->window, drawing->ruler_gc_butt, drawing->ruler->allocation.width - ink_rect.width, 6, layout, &foreground, &background); gdk_draw_line (drawing->ruler->window, drawing->ruler_gc_butt, drawing->ruler->allocation.width-1, 1, drawing->ruler->allocation.width-1, 7); } snprintf(text, 255, "%lus\n%luns", window_middle.tv_sec, window_middle.tv_nsec); pango_layout_set_text(layout, text, -1); pango_layout_get_pixel_extents(layout, &ink_rect, NULL); global_width += ink_rect.width; if(global_width <= drawing->ruler->allocation.width) { gdk_draw_layout_with_colors(drawing->ruler->window, drawing->ruler_gc_butt, (drawing->ruler->allocation.width - ink_rect.width)/2, 6, layout, &foreground, &background); gdk_draw_line (drawing->ruler->window, drawing->ruler_gc_butt, drawing->ruler->allocation.width/2, 1, drawing->ruler->allocation.width/2, 7); } g_object_unref(layout); return FALSE; }
/* Redraw the vertical ruler */ static gboolean histo_expose_vertical_ruler( GtkWidget *widget, GdkEventExpose *event, gpointer user_data ) { histoDrawing_t *drawing = (histoDrawing_t*)user_data; HistoControlFlowData *histo_cfv = drawing->histo_control_flow_data; gchar text[255]; PangoContext *context; PangoLayout *layout; PangoFontDescription *FontDesc; PangoRectangle ink_rect; gint global_height=0; GdkColor foreground = { 0, 0, 0, 0 }; GdkColor background = { 0, 0xffff, 0xffff, 0xffff }; GdkColor red ={ 0, 0xFFFF, 0x1E00, 0x1000 }; //GdkColor magneta ={ 0, 0x8900, 0x0000, 0x8400 }; g_debug("vertical ruler expose event"); gdk_draw_rectangle (drawing->vertical_ruler->window, drawing->vertical_ruler->style->white_gc, TRUE, event->area.x, event->area.y, event->area.width, event->area.height); gdk_draw_line (drawing->vertical_ruler->window, drawing->ruler_gc_butt, padding_width-1/*event->area.width-1*/,event->area.y, padding_width-1/*event->area.width-1*/,event->area.y + event->area.height); snprintf(text, 255, "%.1f", (float)histo_cfv->max_height); layout = gtk_widget_create_pango_layout(drawing->drawing_area, NULL); context = pango_layout_get_context(layout); FontDesc = pango_context_get_font_description(context); pango_font_description_set_size(FontDesc, 6*PANGO_SCALE); pango_layout_context_changed(layout); pango_layout_set_text(layout, text, -1); pango_layout_get_pixel_extents(layout, &ink_rect, NULL); global_height += ink_rect.height; gdk_draw_layout_with_colors(drawing->vertical_ruler->window, drawing->ruler_gc_butt, 1, 1, layout, &foreground, &background); gdk_draw_line (drawing->vertical_ruler->window, drawing->ruler_gc_round, drawing->vertical_ruler-> allocation.width-1, 1, drawing->vertical_ruler-> allocation.width-7, 1); snprintf(text, 255, "%d", 0); pango_layout_set_text(layout, text, -1); pango_layout_get_pixel_extents(layout, &ink_rect, NULL); global_height += ink_rect.height; if(global_height <= drawing->vertical_ruler->allocation.height) { gdk_draw_layout_with_colors(drawing->vertical_ruler->window, drawing->ruler_gc_butt, 1, drawing->vertical_ruler->allocation.height - ink_rect.height-2, layout, &foreground, &background); gdk_draw_line (drawing->vertical_ruler->window, drawing->ruler_gc_butt, drawing->vertical_ruler-> allocation.width-1, drawing->vertical_ruler->allocation.height-1, drawing->vertical_ruler-> allocation.width-7, drawing->vertical_ruler->allocation.height-1); } snprintf(text, 255, "%.1f",(float) histo_cfv->max_height/2.0); pango_layout_set_text(layout, text, -1); pango_layout_get_pixel_extents(layout, &ink_rect, NULL); global_height += ink_rect.height; if(global_height <= drawing->vertical_ruler->allocation.height) { gdk_draw_layout_with_colors(drawing->vertical_ruler->window, drawing->ruler_gc_butt, 1, (drawing->vertical_ruler->allocation.height - ink_rect.height)/2, layout, &foreground, &background); gdk_draw_line (drawing->vertical_ruler->window, drawing->ruler_gc_butt, drawing->vertical_ruler-> allocation.width-1, drawing->vertical_ruler-> allocation.height/2, drawing->vertical_ruler-> allocation.width-7, drawing->vertical_ruler->allocation.height/2); } //show number of events at current time: LttTime current_time = lttvwindow_get_current_time(histo_cfv->tab); TimeWindow time_window = lttvwindow_get_time_window(histo_cfv->tab); LttTime time_begin = time_window.start_time; LttTime time_width = time_window.time_width; LttTime time_end = ltt_time_add(time_begin, time_width); if((ltt_time_compare(current_time, time_begin) >= 0)&& (ltt_time_compare(current_time, time_end) <= 0)) { guint *events_at_currenttime; guint max_height=histo_cfv ->max_height; guint x; histo_convert_time_to_pixels( time_window, current_time, drawing->width, &x); // if(x_test<histo_cfv->number_of_process->len) { events_at_currenttime = &g_array_index(histo_cfv->number_of_process,guint,x); if((*events_at_currenttime) > max_height) { snprintf(text, 255, "OverFlow!"); pango_layout_set_text(layout, text, -1); pango_layout_get_pixel_extents(layout, &ink_rect, NULL); global_height += ink_rect.height; gdk_draw_layout_with_colors(drawing->vertical_ruler->window, drawing->ruler_gc_butt, 1, (drawing->vertical_ruler->allocation.height - ink_rect.height)/5, layout, &red, &background); }else // if((*events_at_currenttime) <= max_height) { snprintf(text, 255, "%.1f", (float) *events_at_currenttime); pango_layout_set_text(layout, text, -1); pango_layout_get_pixel_extents(layout, &ink_rect, NULL); global_height += ink_rect.height; if ((*events_at_currenttime) == 0) { gdk_draw_layout_with_colors(drawing->vertical_ruler->window, drawing->ruler_gc_butt, 1, (drawing->vertical_ruler->allocation.height - ink_rect.height)-2, layout, &red, &background); } else if ((*events_at_currenttime) == max_height) { gdk_draw_layout_with_colors(drawing->vertical_ruler->window, drawing->ruler_gc_butt, 1, 1, layout, &red, &background); } /*else if ((*events_at_currenttime) == max_height/2) { gdk_draw_layout_with_colors(drawing->vertical_ruler->window, drawing->ruler_gc_butt, 1, (drawing->vertical_ruler->allocation.height - ink_rect.height)/2, layout, &red, &background); }*/ else if ((*events_at_currenttime) > max_height/2) { gdk_draw_layout_with_colors(drawing->vertical_ruler->window, drawing->ruler_gc_butt, 1, (drawing->vertical_ruler->allocation.height - ink_rect.height)/4, layout, &red, &background); } else{ gdk_draw_layout_with_colors(drawing->vertical_ruler->window, drawing->ruler_gc_butt, 1, ((drawing->vertical_ruler->allocation.height - ink_rect.height)*3)/4, layout, &red, &background); } } } } g_object_unref(layout); return FALSE; }
void map_text(MapGC *mgc, MapSettings *settings, int x, int y, const char *text, int style) { if (FALSE); #ifdef HAVE_CAIRO else if (mgc->cairo_cr) { int xpos = x; int ypos = y; cairo_text_extents_t extents; cairo_select_font_face(mgc->cairo_cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); if (style & 0x800) { if (settings->pdamode) cairo_set_font_size(mgc->cairo_cr, 9); else cairo_set_font_size(mgc->cairo_cr, 14); } else { if (settings->pdamode) cairo_set_font_size(mgc->cairo_cr, 8); else cairo_set_font_size(mgc->cairo_cr, 11); } cairo_text_extents(mgc->cairo_cr, text, &extents); if ((style & 0x300) == 0x100) { xpos -= extents.width; } else if ((style & 0x300) == 0x200) { xpos -= extents.width / 2; } else if ((style & 0x300) == 0x300) { xpos -= extents.width / 2; ypos -= extents.height / 2; } if (style & 0x400) map_bkg_rectangle(mgc, settings, xpos, ypos, extents.width, extents.height); if (style & 1) cairo_set_source_rgb(mgc->cairo_cr, 0, 0, 1); else cairo_set_source_rgb(mgc->cairo_cr, 0, 0, 0); cairo_move_to(mgc->cairo_cr, xpos, ypos + extents.height); cairo_show_text(mgc->cairo_cr, text); } #endif #ifdef HAVE_GTK else if (mgc->gtk_drawable) { int xpos = x; int ypos = y; int width; int height; PangoFontDescription *fd; PangoLayout *layout = gtk_widget_create_pango_layout(mgc->gtk_widget, text); if (style & 0x800) { if (settings->pdamode) fd = pango_font_description_from_string("Sans 9"); else fd = pango_font_description_from_string("Sans 14"); } else { if (settings->pdamode) fd = pango_font_description_from_string("Sans 8"); else fd = pango_font_description_from_string("Sans 11"); } pango_layout_set_font_description(layout, fd); pango_layout_get_pixel_size(layout, &width, &height); if ((style & 0x300) == 0x100) { xpos -= width; } else if ((style & 0x300) == 0x200) { xpos -= width / 2; } else if ((style & 0x300) == 0x300) { xpos -= width / 2; ypos -= height / 2; } if (style & 0x400) map_bkg_rectangle(mgc, settings, xpos, ypos, width, height); if (style & 1) gdk_draw_layout_with_colors(mgc->gtk_drawable, mgc->gtk_gc, xpos, ypos, layout, &settings->blue, NULL); else gdk_draw_layout_with_colors(mgc->gtk_drawable, mgc->gtk_gc, xpos, ypos, layout, &settings->black, NULL); if (layout != NULL) g_object_unref(G_OBJECT(layout)); pango_font_description_free(fd); } #endif #ifdef HAVE_QT else if (mgc->qt_painter) { qt_text(mgc->qt_painter, settings, x, y, text, style); } #endif #ifdef HAVE_QUARTZ else if (mgc->quartz_gc) { int xpos = x; int ypos = y; int width; int height; CGContextSelectFont(mgc->quartz_gc, "Verdana", 8, kCGEncodingMacRoman); if (style & 0x800) { if (settings->pdamode) CGContextSetFontSize(mgc->quartz_gc, 9); else CGContextSetFontSize(mgc->quartz_gc, 14); } else { if (settings->pdamode) CGContextSetFontSize(mgc->quartz_gc, 8); else CGContextSetFontSize(mgc->quartz_gc, 11); } { CGPoint oldPos = CGContextGetTextPosition(mgc->quartz_gc); CGContextSetTextDrawingMode(mgc->quartz_gc, kCGTextInvisible); CGContextShowText(mgc->quartz_gc, text, strlen(text)); CGPoint newPos = CGContextGetTextPosition(mgc->quartz_gc); CGContextSetTextDrawingMode(mgc->quartz_gc, kCGTextFill); CGContextSetTextPosition(mgc->quartz_gc, oldPos.x, oldPos.y); width = newPos.x - oldPos.x; } if ((style & 0x300) == 0x100) { xpos -= width; } else if ((style & 0x300) == 0x200) { xpos -= width / 2; } else if ((style & 0x300) == 0x300) { xpos -= width / 2; ypos -= height / 2; } if (style & 0x400) map_bkg_rectangle(mgc, settings, xpos, ypos, width, height); if (style & 1) CGContextSetRGBStrokeColor(mgc->quartz_gc, 0, 0, 1, 1); else CGContextSetRGBStrokeColor(mgc->quartz_gc, 0, 0, 0, 1); CGContextSetTextPosition(mgc->quartz_gc, xpos, ypos); CGContextShowText(mgc->quartz_gc, text, strlen(text)); } #endif #ifdef WIN32 else if (mgc->win_dc) { int xpos = x; int ypos = y; int fontSize; HFONT oldFont; HFONT font; SIZE textSize; if (style & 0x800) { if (settings->pdamode) fontSize = 9; else fontSize = 14; } else { if (settings->pdamode) fontSize = 8; else fontSize = 11; } fontSize = fontSize * 3 / 2; font = CreateFont(fontSize, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "MSSansSerif"); oldFont = SelectObject(mgc->win_dc, font); GetTextExtentPoint32(mgc->win_dc, text, strlen(text), &textSize); if ((style & 0x300) == 0x100) { xpos -= textSize.cx; } else if ((style & 0x300) == 0x200) { xpos -= textSize.cx / 2; } else if ((style & 0x300) == 0x300) { xpos -= textSize.cx / 2; ypos -= textSize.cy / 2; } if (style & 0x400) map_bkg_rectangle(mgc, settings, xpos, ypos, textSize.cx, textSize.cy); if (style & 1) SetTextColor(mgc->win_dc, RGB(0x00, 0x00, 0xff)); else SetTextColor(mgc->win_dc, RGB(0x00, 0x00, 0x00)); SetBkMode(mgc->win_dc, TRANSPARENT); TextOut(mgc->win_dc, xpos, ypos, text, strlen(text)); SelectObject(mgc->win_dc, oldFont); DeleteObject(font); } #endif }