aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Abad <oabad@noos.fr>2003-03-01 17:39:53 +0000
committerOlivier Abad <oabad@noos.fr>2003-03-01 17:39:53 +0000
commitf0f7ae02804da0da621195ce581b44aa58527467 (patch)
treeec23fb23da8245d21a033a958f254689ef95f6f9
parent06c3a3ab5efe54d32c8588ffbbc10b7b400b989b (diff)
Replace gdk_string_width and gdk_string_height with
pango_layout_get_pixel_size in gtk2 code. svn path=/trunk/; revision=7245
-rw-r--r--gtk/tcp_graph.c89
1 files changed, 50 insertions, 39 deletions
diff --git a/gtk/tcp_graph.c b/gtk/tcp_graph.c
index 4c55d656b9..e1a6b54268 100644
--- a/gtk/tcp_graph.c
+++ b/gtk/tcp_graph.c
@@ -3,7 +3,7 @@
* By Pavel Mores <pvl@uh.cz>
* Win32 port: rwh@unifiedtech.com
*
- * $Id: tcp_graph.c,v 1.29 2003/02/14 05:00:05 guy Exp $
+ * $Id: tcp_graph.c,v 1.30 2003/03/01 17:39:53 oabad Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1982,14 +1982,13 @@ static void graph_title_pixmap_draw (struct graph *g)
g->wp.width/2 - w/2, 20+h + i*(h+3),
g->title[i]);
#else
- w = gdk_string_width(gdk_font_from_description(g->font),
- g->title[i]);
- h = gdk_string_height(gdk_font_from_description(g->font),
- g->title[i]);
- gdk_draw_string(g->title_pixmap,
- gdk_font_from_description(g->font), g->fg_gc,
- g->wp.width/2 - w/2, 20+h + i*(h+3),
- g->title[i]);
+ PangoLayout *layout;
+ layout = gtk_widget_create_pango_layout(g->drawing_area,
+ g->title[i]);
+ pango_layout_get_pixel_size(layout, &w, &h);
+ gdk_draw_layout(g->title_pixmap, g->fg_gc,
+ g->wp.width/2 - w/2, 20 + i*(h+3), layout);
+ g_object_unref(G_OBJECT(layout));
#endif
}
}
@@ -2162,6 +2161,9 @@ static void v_axis_pixmap_draw (struct axis *axis)
double major_tick;
int not_disp, rdigits, offset, imin, imax;
double bottom, top, j, fl, corr;
+#if GTK_MAJOR_VERSION >= 2
+ PangoLayout *layout;
+#endif
debug(DBS_FENTRY) puts ("v_axis_pixmap_draw()");
bottom = (g->geom.height - (g->wp.height + g->wp.y + (-g->geom.y))) /
@@ -2215,11 +2217,11 @@ static void v_axis_pixmap_draw (struct axis *axis)
gdk_draw_string(axis->pixmap[not_disp], g->font, g->fg_gc,
axis->s.width-15-4-w, y + h/2, desc);
#else
- w = gdk_string_width(gdk_font_from_description(g->font), desc);
- h = gdk_string_height(gdk_font_from_description(g->font), desc);
- gdk_draw_string(axis->pixmap[not_disp],
- gdk_font_from_description(g->font), g->fg_gc,
- axis->s.width-15-4-w, y + h/2, desc);
+ layout = gtk_widget_create_pango_layout(g->drawing_area, desc);
+ pango_layout_get_pixel_size(layout, &w, &h);
+ gdk_draw_layout(axis->pixmap[not_disp], g->fg_gc,
+ axis->s.width-14-4-w, y - h/2, layout);
+ g_object_unref(G_OBJECT(layout));
#endif
}
/* minor ticks */
@@ -2247,14 +2249,14 @@ static void v_axis_pixmap_draw (struct axis *axis)
(axis->p.width - w)/2 ,
TITLEBAR_HEIGHT-15 - i*(h+3), axis->label[i]);
#else
- w = gdk_string_width(gdk_font_from_description(g->font),
- axis->label[i]);
- h = gdk_string_height(gdk_font_from_description(g->font),
- axis->label[i]);
- gdk_draw_string(axis->pixmap[not_disp],
- gdk_font_from_description(g->font), g->fg_gc,
- (axis->p.width - w)/2 ,
- TITLEBAR_HEIGHT-15 - i*(h+3), axis->label[i]);
+ layout = gtk_widget_create_pango_layout(g->drawing_area,
+ axis->label[i]);
+ pango_layout_get_pixel_size(layout, &w, &h);
+ gdk_draw_layout(axis->pixmap[not_disp], g->fg_gc,
+ (axis->p.width - w)/2,
+ TITLEBAR_HEIGHT-10 - i*(h+3) - h,
+ layout);
+ g_object_unref(G_OBJECT(layout));
#endif
}
}
@@ -2266,6 +2268,9 @@ static void h_axis_pixmap_draw (struct axis *axis)
double major_tick, minor_tick;
int not_disp, rdigits, offset, imin, imax;
double left, right, j, fl, corr;
+#if GTK_MAJOR_VERSION >= 2
+ PangoLayout *layout;
+#endif
debug(DBS_FENTRY) puts ("h_axis_pixmap_draw()");
left = (g->wp.x-g->geom.x) /
@@ -2315,11 +2320,11 @@ static void h_axis_pixmap_draw (struct axis *axis)
gdk_draw_string (axis->pixmap[not_disp], g->font, g->fg_gc,
x - w/2, 15+h+4, desc);
#else
- w = gdk_string_width(gdk_font_from_description(g->font), desc);
- h = gdk_string_height(gdk_font_from_description(g->font), desc);
- gdk_draw_string(axis->pixmap[not_disp],
- gdk_font_from_description(g->font), g->fg_gc,
- x - w/2, 15+h+4, desc);
+ layout = gtk_widget_create_pango_layout(g->drawing_area, desc);
+ pango_layout_get_pixel_size(layout, &w, &h);
+ gdk_draw_layout(axis->pixmap[not_disp], g->fg_gc,
+ x - w/2, 15+4, layout);
+ g_object_unref(G_OBJECT(layout));
#endif
}
if (axis->minor > 0) {
@@ -2342,14 +2347,13 @@ static void h_axis_pixmap_draw (struct axis *axis)
axis->s.width - w - 50, 15+2*h+15 + i*(h+3),
axis->label[i]);
#else
- w = gdk_string_width(gdk_font_from_description(g->font),
- axis->label[i]);
- h = gdk_string_height(gdk_font_from_description(g->font),
- axis->label[i]);
- gdk_draw_string(axis->pixmap[not_disp],
- gdk_font_from_description(g->font), g->fg_gc,
- axis->s.width - w - 50, 15+2*h+15 + i*(h+3),
- axis->label[i]);
+ layout = gtk_widget_create_pango_layout(g->drawing_area,
+ axis->label[i]);
+ pango_layout_get_pixel_size(layout, &w, &h);
+ gdk_draw_layout(axis->pixmap[not_disp], g->fg_gc,
+ axis->s.width - w - 50, 15+h+15 + i*(h+3),
+ layout);
+ g_object_unref(G_OBJECT(layout));
#endif
}
}
@@ -2480,6 +2484,9 @@ static int get_label_dim (struct axis *axis, int dir, double label)
double y;
char str[32];
int rdigits, dim;
+#if GTK_MAJOR_VERSION >= 2
+ PangoLayout *layout;
+#endif
/* First, let's compute how many digits to the right of radix
* we need to print */
@@ -2496,16 +2503,20 @@ static int get_label_dim (struct axis *axis, int dir, double label)
#if GTK_MAJOR_VERSION < 2
dim = gdk_string_width(axis->g->font, str);
#else
- dim = gdk_string_width(gdk_font_from_description(axis->g->font),
- str);
+ layout = gtk_widget_create_pango_layout(axis->g->drawing_area,
+ str);
+ pango_layout_get_pixel_size(layout, &dim, NULL);
+ g_object_unref(G_OBJECT(layout));
#endif
break;
case AXIS_VERTICAL:
#if GTK_MAJOR_VERSION < 2
dim = gdk_string_height(axis->g->font, str);
#else
- dim = gdk_string_height(gdk_font_from_description(axis->g->font),
- str);
+ layout = gtk_widget_create_pango_layout(axis->g->drawing_area,
+ str);
+ pango_layout_get_pixel_size(layout, NULL, &dim);
+ g_object_unref(G_OBJECT(layout));
#endif
break;
default: