SCTP graphs:

- Use cairo_surface_t
- rename variables refering to the surface.
IOgraph
- rename variables refering to the surface.

svn path=/trunk/; revision=38493
This commit is contained in:
Anders Broman 2011-08-12 09:11:16 +00:00
parent f8034556e5
commit 60495e3e64
4 changed files with 385 additions and 130 deletions

View File

@ -175,8 +175,8 @@ typedef struct _io_stat_t {
GtkWidget *scrollbar;
guint first_frame_num[NUM_IO_ITEMS];
guint last_frame_num;
int pixmap_width;
int pixmap_height;
int surface_width;
int surface_height;
int pixels_per_tick;
int max_y_units;
int count_type;
@ -854,8 +854,8 @@ io_stat_draw(io_stat_t *io)
/*
* Calculate the size of the drawing area for the actual plot
*/
draw_width=io->pixmap_width-io->right_x_border-io->left_x_border;
draw_height=io->pixmap_height-top_y_border-bottom_y_border;
draw_width=io->surface_width-io->right_x_border-io->left_x_border;
draw_height=io->surface_height-top_y_border-bottom_y_border;
/*
@ -870,7 +870,7 @@ io_stat_draw(io_stat_t *io)
#else
cr = gdk_cairo_create (io->pixmap);
#endif
cairo_move_to (cr, 5, io->pixmap_height-bottom_y_border-draw_height-label_height/2);
cairo_move_to (cr, 5, io->surface_height-bottom_y_border-draw_height-label_height/2);
pango_cairo_show_layout (cr, layout);
cairo_destroy (cr);
cr = NULL;
@ -886,8 +886,8 @@ io_stat_draw(io_stat_t *io)
cr = gdk_cairo_create (io->pixmap);
#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr, io->pixmap_width-io->right_x_border+1.5, top_y_border+0.5);
cairo_line_to(cr, io->pixmap_width-io->right_x_border+1.5, io->pixmap_height-bottom_y_border+0.5);
cairo_move_to(cr, io->surface_width-io->right_x_border+1.5, top_y_border+0.5);
cairo_line_to(cr, io->surface_width-io->right_x_border+1.5, io->surface_height-bottom_y_border+0.5);
cairo_stroke(cr);
cairo_destroy(cr);
if(io->max_y_units==LOGARITHMIC_YSCALE){
@ -906,15 +906,15 @@ io_stat_draw(io_stat_t *io)
if(io->max_y_units==LOGARITHMIC_YSCALE){
if(i==ys) {
/* position for the 0 value */
ypos=io->pixmap_height-bottom_y_border;
ypos=io->surface_height-bottom_y_border;
} else if(i==tics) {
/* position for the top value, do not draw logarithmic tics above graph */
ypos=io->pixmap_height-bottom_y_border-draw_height;
ypos=io->surface_height-bottom_y_border-draw_height;
} else {
int j;
/* draw the logarithmic tics */
for(j=2;j<10;j++) {
ypos=(int)(io->pixmap_height-bottom_y_border-(draw_height-ystart)*(i+log10((double)j))/tics-ystart);
ypos=(int)(io->surface_height-bottom_y_border-(draw_height-ystart)*(i+log10((double)j))/tics-ystart);
/* draw the tick */
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (io->surface);
@ -922,12 +922,12 @@ io_stat_draw(io_stat_t *io)
cr = gdk_cairo_create (io->pixmap);
#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr, io->pixmap_width-io->right_x_border+1.5, ypos+0.5);
cairo_line_to(cr, io->pixmap_width-io->right_x_border+1.5+xwidth,ypos+0.5);
cairo_move_to(cr, io->surface_width-io->right_x_border+1.5, ypos+0.5);
cairo_line_to(cr, io->surface_width-io->right_x_border+1.5+xwidth,ypos+0.5);
cairo_stroke(cr);
cairo_destroy(cr);
}
ypos=io->pixmap_height-bottom_y_border-(draw_height-ystart)*i/tics-ystart;
ypos=io->surface_height-bottom_y_border-(draw_height-ystart)*i/tics-ystart;
}
/* all "main" logarithmic lines are slightly longer */
xwidth=10;
@ -936,7 +936,7 @@ io_stat_draw(io_stat_t *io)
/* first, middle and last tick are slightly longer */
xwidth=10;
}
ypos=io->pixmap_height-bottom_y_border-draw_height*i/10;
ypos=io->surface_height-bottom_y_border-draw_height*i/10;
}
/* draw the tick */
#if GTK_CHECK_VERSION(2,22,0)
@ -945,8 +945,8 @@ io_stat_draw(io_stat_t *io)
cr = gdk_cairo_create (io->pixmap);
#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr, io->pixmap_width-io->right_x_border+1.5, ypos+0.5);
cairo_line_to(cr, io->pixmap_width-io->right_x_border+1.5+xwidth,ypos+0.5);
cairo_move_to(cr, io->surface_width-io->right_x_border+1.5, ypos+0.5);
cairo_line_to(cr, io->surface_width-io->right_x_border+1.5+xwidth,ypos+0.5);
cairo_stroke(cr);
cairo_destroy(cr);
/* draw the labels */
@ -976,7 +976,7 @@ io_stat_draw(io_stat_t *io)
#else
cr = gdk_cairo_create (io->pixmap);
#endif
cairo_move_to (cr, io->pixmap_width-io->right_x_border+15+label_width-lwidth, ypos-label_height/2);
cairo_move_to (cr, io->surface_width-io->right_x_border+15+label_width-lwidth, ypos-label_height/2);
pango_cairo_show_layout (cr, layout);
cairo_destroy (cr);
cr = NULL;
@ -1006,8 +1006,8 @@ io_stat_draw(io_stat_t *io)
cr = gdk_cairo_create (io->pixmap);
#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr, io->left_x_border+0.5, io->pixmap_height-bottom_y_border+1.5);
cairo_line_to(cr, io->pixmap_width-io->right_x_border+1.5,io->pixmap_height-bottom_y_border+1.5);
cairo_move_to(cr, io->left_x_border+0.5, io->surface_height-bottom_y_border+1.5);
cairo_line_to(cr, io->surface_width-io->right_x_border+1.5,io->surface_height-bottom_y_border+1.5);
cairo_stroke(cr);
cairo_destroy(cr);
if((last_interval/io->interval)>=draw_width/io->pixels_per_tick){
@ -1042,8 +1042,8 @@ io_stat_draw(io_stat_t *io)
cr = gdk_cairo_create (io->pixmap);
#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr, x-1-io->pixels_per_tick/2+0.5, io->pixmap_height-bottom_y_border+1.5);
cairo_line_to(cr, x-1-io->pixels_per_tick/2+0.5, io->pixmap_height-bottom_y_border+xlen+1.5);
cairo_move_to(cr, x-1-io->pixels_per_tick/2+0.5, io->surface_height-bottom_y_border+1.5);
cairo_line_to(cr, x-1-io->pixels_per_tick/2+0.5, io->surface_height-bottom_y_border+xlen+1.5);
cairo_stroke(cr);
cairo_destroy(cr);
if(xlen==10){
@ -1054,8 +1054,8 @@ io_stat_draw(io_stat_t *io)
if ((x-1-io->pixels_per_tick/2-lwidth/2) < 5) {
x_pos=5;
} else if ((x-1-io->pixels_per_tick/2+lwidth/2) > (io->pixmap_width-5)) {
x_pos=io->pixmap_width-lwidth-5;
} else if ((x-1-io->pixels_per_tick/2+lwidth/2) > (io->surface_width-5)) {
x_pos=io->surface_width-lwidth-5;
} else {
x_pos=x-1-io->pixels_per_tick/2-lwidth/2;
}
@ -1064,7 +1064,7 @@ io_stat_draw(io_stat_t *io)
#else
cr = gdk_cairo_create (io->pixmap);
#endif
cairo_move_to (cr, x_pos, io->pixmap_height-bottom_y_border+15);
cairo_move_to (cr, x_pos, io->surface_height-bottom_y_border+15);
pango_cairo_show_layout (cr, layout);
cairo_destroy (cr);
cr = NULL;
@ -1199,7 +1199,7 @@ io_stat_draw(io_stat_t *io)
#else
gdk_cairo_set_source_pixmap (cr, io->pixmap, 0, 0);
#endif
cairo_rectangle (cr, 0, 0, io->pixmap_width, io->pixmap_height);
cairo_rectangle (cr, 0, 0, io->surface_width, io->surface_height);
cairo_fill (cr);
cairo_destroy (cr);
@ -1333,8 +1333,8 @@ iostat_init(const char *optarg _U_, void* userdata _U_)
#endif
io->scrollbar=NULL;
io->scrollbar_adjustment=NULL;
io->pixmap_width=500;
io->pixmap_height=200;
io->surface_width=500;
io->surface_height=200;
io->pixels_per_tick=pixels_per_tick[DEFAULT_PIXELS_PER_TICK_INDEX];
io->max_y_units=AUTO_MAX_YSCALE;
io->count_type=0;
@ -1422,7 +1422,7 @@ pixmap_clicked_event(GtkWidget *widget _U_, GdkEventButton *event, gpointer user
guint32 draw_width, interval, last_interval;
guint frame_num;
draw_width=io->pixmap_width-io->right_x_border-io->left_x_border;
draw_width=io->surface_width-io->right_x_border-io->left_x_border;
if ((event->x <= (draw_width+io->left_x_border+1-(draw_width/io->pixels_per_tick)*io->pixels_per_tick)) ||
(event->x >= (draw_width+io->left_x_border-io->pixels_per_tick/2))) {
@ -1489,8 +1489,8 @@ draw_area_configure_event(GtkWidget *widget, GdkEventConfigure *event _U_, gpoin
widget_alloc.height,
-1);
#endif
io->pixmap_width=widget_alloc.width;
io->pixmap_height=widget_alloc.height;
io->surface_width=widget_alloc.width;
io->surface_height=widget_alloc.height;
save_bt = g_object_get_data(G_OBJECT(io->window), "save_bt");
#if GTK_CHECK_VERSION(2,22,0)
@ -1560,7 +1560,7 @@ create_draw_area(io_stat_t *io, GtkWidget *box)
io->draw_area=gtk_drawing_area_new();
g_signal_connect(io->draw_area, "destroy", G_CALLBACK(draw_area_destroy_cb), io);
gtk_widget_set_size_request(io->draw_area, io->pixmap_width, io->pixmap_height);
gtk_widget_set_size_request(io->draw_area, io->surface_width, io->surface_height);
/* signals needed to handle backing pixmap */
g_signal_connect(io->draw_area, "expose-event", G_CALLBACK(draw_area_expose_event), io);

View File

@ -173,28 +173,36 @@ static void draw_sack_graph(struct sctp_udata *u_data)
if (start >= min_tsn && diff > 0 && diff <= width)
{
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
gdk_cairo_set_source_color (cr, &red_color);
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr,
LEFT_BORDER+u_data->io->offset+u_data->io->x_interval*diff+0.5,
u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset-((SUB_32(start,min_tsn))*u_data->io->y_interval)+0.5);
u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset-((SUB_32(start,min_tsn))*u_data->io->y_interval)+0.5);
cairo_line_to(cr,
LEFT_BORDER+u_data->io->offset+u_data->io->x_interval*diff+0.5,
u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset-((SUB_32(end,min_tsn))*u_data->io->y_interval)+0.5);
u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset-((SUB_32(end,min_tsn))*u_data->io->y_interval)+0.5);
cairo_stroke(cr);
cairo_destroy(cr);
if (more == TRUE)
{
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
gdk_cairo_set_source_color (cr, &green_color);
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr,
LEFT_BORDER+u_data->io->offset+u_data->io->x_interval*diff+0.5,
u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset-((SUB_32(end,min_tsn))*u_data->io->y_interval)+0.5);
u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset-((SUB_32(end,min_tsn))*u_data->io->y_interval)+0.5);
cairo_line_to(cr,
LEFT_BORDER+u_data->io->offset+u_data->io->x_interval*diff,
u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset-((SUB_32(end+10,min_tsn))*u_data->io->y_interval)+0.5);
u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset-((SUB_32(end+10,min_tsn))*u_data->io->y_interval)+0.5);
cairo_stroke(cr);
cairo_destroy(cr);
more = FALSE;
@ -253,14 +261,18 @@ cairo_t *cr;
start = ((struct tsn_sort*)(g_ptr_array_index(array, i)))->offset;
end = start + ((struct tsn_sort*)(g_ptr_array_index(array, i)))->length;
if (start >= min_tsn && diff > 0 && diff <= width){
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr,
(LEFT_BORDER+u_data->io->offset+u_data->io->x_interval*diff)+0.5,
(u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset-((SUB_32(start,min_tsn))*u_data->io->y_interval))+0.5);
(u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset-((SUB_32(start,min_tsn))*u_data->io->y_interval))+0.5);
cairo_line_to(cr,
(LEFT_BORDER+u_data->io->offset+u_data->io->x_interval*diff)+0.5,
(u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset-((SUB_32(end,min_tsn))*u_data->io->y_interval))+0.5);
(u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset-((SUB_32(end,min_tsn))*u_data->io->y_interval))+0.5);
cairo_stroke(cr);
cairo_destroy(cr);
}
@ -334,7 +346,11 @@ static void sctp_graph_draw(struct sctp_udata *u_data)
}
}
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_set_source_rgb (cr, 1, 1, 1);
gtk_widget_get_allocation(u_data->io->draw_area, &widget_alloc);
cairo_rectangle (cr,
@ -347,20 +363,24 @@ static void sctp_graph_draw(struct sctp_udata *u_data)
distance = 5;
/* x_axis */
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr, LEFT_BORDER+u_data->io->offset+0.5, u_data->io->pixmap_height - BOTTOM_BORDER+0.5);
cairo_line_to(cr, u_data->io->pixmap_width - RIGHT_BORDER + u_data->io->offset+0.5, u_data->io->pixmap_height - BOTTOM_BORDER+0.5);
cairo_move_to(cr, LEFT_BORDER+u_data->io->offset+0.5, u_data->io->surface_height - BOTTOM_BORDER+0.5);
cairo_line_to(cr, u_data->io->surface_width - RIGHT_BORDER + u_data->io->offset+0.5, u_data->io->surface_height - BOTTOM_BORDER+0.5);
cairo_move_to(cr, u_data->io->pixmap_width - RIGHT_BORDER + u_data->io->offset+0.5, u_data->io->pixmap_height - BOTTOM_BORDER+0.5);
cairo_line_to(cr, u_data->io->pixmap_width - RIGHT_BORDER + u_data->io->offset - 5+0.5, u_data->io->pixmap_height - BOTTOM_BORDER - 5+0.5);
cairo_move_to(cr, u_data->io->surface_width - RIGHT_BORDER + u_data->io->offset+0.5, u_data->io->surface_height - BOTTOM_BORDER+0.5);
cairo_line_to(cr, u_data->io->surface_width - RIGHT_BORDER + u_data->io->offset - 5+0.5, u_data->io->surface_height - BOTTOM_BORDER - 5+0.5);
cairo_move_to(cr, u_data->io->pixmap_width - RIGHT_BORDER + u_data->io->offset + 0.5, u_data->io->pixmap_height - BOTTOM_BORDER + 0.5);
cairo_line_to(cr, u_data->io->pixmap_width - RIGHT_BORDER + u_data->io->offset - 5.5, u_data->io->pixmap_height - BOTTOM_BORDER + 5.5);
cairo_move_to(cr, u_data->io->surface_width - RIGHT_BORDER + u_data->io->offset + 0.5, u_data->io->surface_height - BOTTOM_BORDER + 0.5);
cairo_line_to(cr, u_data->io->surface_width - RIGHT_BORDER + u_data->io->offset - 5.5, u_data->io->surface_height - BOTTOM_BORDER + 5.5);
cairo_stroke(cr);
cairo_destroy(cr);
u_data->io->axis_width = u_data->io->pixmap_width - LEFT_BORDER - RIGHT_BORDER - u_data->io->offset;
u_data->io->axis_width = u_data->io->surface_width - LEFT_BORDER - RIGHT_BORDER - u_data->io->offset;
if(u_data->io->tmp_width>0){
u_data->io->x_interval = (float)((u_data->io->axis_width*1.0)/u_data->io->tmp_width); /*distance in pixels between 2 data points*/
@ -401,8 +421,12 @@ static void sctp_graph_draw(struct sctp_udata *u_data)
pango_layout_set_text(layout, label_string, -1);
pango_layout_get_pixel_size(layout, &lwidth, NULL);
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
cairo_move_to (cr, LEFT_BORDER - 25, u_data->io->pixmap_height - BOTTOM_BORDER + 20);
#endif
cairo_move_to (cr, LEFT_BORDER - 25, u_data->io->surface_height - BOTTOM_BORDER + 20);
pango_cairo_show_layout (cr, layout);
cairo_destroy (cr);
cr = NULL;
@ -464,22 +488,30 @@ static void sctp_graph_draw(struct sctp_udata *u_data)
memcpy(label_string,(gchar *)g_locale_to_utf8(label_string, -1 , NULL, NULL, NULL), sizeof(label_string));
pango_layout_set_text(layout, label_string, -1);
pango_layout_get_pixel_size(layout, &lwidth, NULL);
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_move_to (cr,
LEFT_BORDER + u_data->io->offset + (i - u_data->io->min_x) * u_data->io->x_interval - lwidth / 2,
u_data->io->pixmap_height - BOTTOM_BORDER + 10);
u_data->io->surface_height - BOTTOM_BORDER + 10);
pango_cairo_show_layout (cr, layout);
cairo_destroy (cr);
cr = NULL;
}
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr,
LEFT_BORDER + u_data->io->offset + (i - u_data->io->min_x) * u_data->io->x_interval + 0.5,
u_data->io->pixmap_height - BOTTOM_BORDER + 0.5);
u_data->io->surface_height - BOTTOM_BORDER + 0.5);
cairo_line_to(cr,
LEFT_BORDER + u_data->io->offset + (i - u_data->io->min_x) * u_data->io->x_interval + 0.5,
u_data->io->pixmap_height - BOTTOM_BORDER + length + 0.5);
u_data->io->surface_height - BOTTOM_BORDER + length + 0.5);
cairo_stroke(cr);
cairo_destroy(cr);
}
@ -502,14 +534,18 @@ static void sctp_graph_draw(struct sctp_udata *u_data)
}
if (write_label)
{
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr,
LEFT_BORDER + u_data->io->offset + (i - u_data->io->min_x) * u_data->io->x_interval + 0.5,
u_data->io->pixmap_height - BOTTOM_BORDER + 0.5);
u_data->io->surface_height - BOTTOM_BORDER + 0.5);
cairo_line_to(cr,
LEFT_BORDER + u_data->io->offset + (i - u_data->io->min_x) * u_data->io->x_interval + 0.5,
u_data->io->pixmap_height - BOTTOM_BORDER + 10 + 0.5);
u_data->io->surface_height - BOTTOM_BORDER + 10 + 0.5);
cairo_stroke(cr);
cairo_destroy(cr);
@ -517,10 +553,14 @@ static void sctp_graph_draw(struct sctp_udata *u_data)
memcpy(label_string,(gchar *)g_locale_to_utf8(label_string, -1 , NULL, NULL, NULL), sizeof(label_string));
pango_layout_set_text(layout, label_string, -1);
pango_layout_get_pixel_size(layout, &lwidth, NULL);
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_move_to (cr,
(LEFT_BORDER + u_data->io->offset + (i - u_data->io->min_x) * u_data->io->x_interval-10),
u_data->io->pixmap_height - BOTTOM_BORDER + 20);
u_data->io->surface_height - BOTTOM_BORDER + 20);
pango_cairo_show_layout (cr, layout);
cairo_destroy (cr);
cr = NULL;
@ -534,10 +574,14 @@ static void sctp_graph_draw(struct sctp_udata *u_data)
memcpy(label_string,(gchar *)g_locale_to_utf8(label_string, -1 , NULL, NULL, NULL), sizeof(label_string));
pango_layout_set_text(layout, label_string, -1);
pango_layout_get_pixel_size(layout, &lwidth, NULL);
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_move_to (cr,
u_data->io->pixmap_width - RIGHT_BORDER - 10,
u_data->io->pixmap_height - BOTTOM_BORDER + 30);
u_data->io->surface_width - RIGHT_BORDER - 10,
u_data->io->surface_height - BOTTOM_BORDER + 30);
pango_cairo_show_layout (cr, layout);
cairo_destroy (cr);
cr = NULL;
@ -545,10 +589,14 @@ static void sctp_graph_draw(struct sctp_udata *u_data)
distance = 5;
/* y-axis */
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr, LEFT_BORDER + 0.5, TOP_BORDER - u_data->io->offset + 0.5);
cairo_line_to(cr, LEFT_BORDER + 0.5, u_data->io->pixmap_height - BOTTOM_BORDER - u_data->io->offset + 0.5);
cairo_line_to(cr, LEFT_BORDER + 0.5, u_data->io->surface_height - BOTTOM_BORDER - u_data->io->offset + 0.5);
cairo_move_to(cr, LEFT_BORDER + 0.5, TOP_BORDER - u_data->io->offset + 0.5);
cairo_line_to(cr, LEFT_BORDER - 5 + 0.5, TOP_BORDER - u_data->io->offset + 5 + 0.5);
@ -558,7 +606,7 @@ static void sctp_graph_draw(struct sctp_udata *u_data)
cairo_stroke(cr);
cairo_destroy(cr);
u_data->io->y_interval = (float)(((u_data->io->pixmap_height - TOP_BORDER - BOTTOM_BORDER) * 1.0)/(u_data->io->max_y - u_data->io->min_y));
u_data->io->y_interval = (float)(((u_data->io->surface_height - TOP_BORDER - BOTTOM_BORDER) * 1.0)/(u_data->io->max_y - u_data->io->min_y));
e = 0;
if (u_data->io->y_interval < 1)
@ -592,22 +640,30 @@ static void sctp_graph_draw(struct sctp_udata *u_data)
memcpy(label_string,(gchar *)g_locale_to_utf8(label_string, -1 , NULL, NULL, NULL), sizeof(label_string));
pango_layout_set_text(layout, label_string, -1);
pango_layout_get_pixel_size(layout, &lwidth, NULL);
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_move_to (cr,
LEFT_BORDER - length - lwidth - 5,
u_data->io->pixmap_height - BOTTOM_BORDER - u_data->io->offset - (i - u_data->io->min_y) * u_data->io->y_interval - 3);
u_data->io->surface_height - BOTTOM_BORDER - u_data->io->offset - (i - u_data->io->min_y) * u_data->io->y_interval - 3);
pango_cairo_show_layout (cr, layout);
cairo_destroy (cr);
cr = NULL;
}
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr,
LEFT_BORDER - length + 0.5,
u_data->io->pixmap_height - BOTTOM_BORDER - u_data->io->offset - (i - u_data->io->min_y) * u_data->io->y_interval + 0.5);
u_data->io->surface_height - BOTTOM_BORDER - u_data->io->offset - (i - u_data->io->min_y) * u_data->io->y_interval + 0.5);
cairo_line_to(cr,
LEFT_BORDER + 0.5,
u_data->io->pixmap_height - BOTTOM_BORDER - u_data->io->offset - (i - u_data->io->min_y) * u_data->io->y_interval + 0.5);
u_data->io->surface_height - BOTTOM_BORDER - u_data->io->offset - (i - u_data->io->min_y) * u_data->io->y_interval + 0.5);
cairo_stroke(cr);
cairo_destroy(cr);
}
@ -648,7 +704,11 @@ static void sctp_graph_redraw(struct sctp_udata *u_data)
cr = gdk_cairo_create (gtk_widget_get_window(u_data->io->draw_area));
#if GTK_CHECK_VERSION(2,22,0)
cairo_set_source_surface (cr, ios->surface, 0, 0);
#else
gdk_cairo_set_source_pixmap (cr, ios->pixmap, 0, 0);
#endif
gtk_widget_get_allocation(u_data->io->draw_area, &widget_alloc);
cairo_rectangle (cr, 0, 0, widget_alloc.width, widget_alloc.height);
cairo_fill (cr);
@ -697,20 +757,35 @@ on_configure_event(GtkWidget *widget, GdkEventConfigure *event _U_, gpointer use
g_assert(u_data->io != NULL);
#if GTK_CHECK_VERSION(2,22,0)
if(u_data->io->surface){
cairo_surface_destroy (u_data->io->surface);
u_data->io->surface=NULL;
}
gtk_widget_get_allocation(widget, &widget_alloc);
u_data->io->surface = gdk_window_create_similar_surface (gtk_widget_get_window(widget),
CAIRO_CONTENT_COLOR,
widget_alloc.width,
widget_alloc.height);
#else
if(u_data->io->pixmap){
g_object_unref(u_data->io->pixmap);
u_data->io->pixmap = NULL;
}
gtk_widget_get_allocation(widget, &widget_alloc);
u_data->io->pixmap = gdk_pixmap_new(gtk_widget_get_window(widget),
widget_alloc.width,
widget_alloc.height,
-1);
u_data->io->pixmap_width = widget_alloc.width;
u_data->io->pixmap_height = widget_alloc.height;
#endif
u_data->io->surface_width = widget_alloc.width;
u_data->io->surface_height = widget_alloc.height;
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_rectangle (cr, 0, 0, widget_alloc.width, widget_alloc.height);
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_fill (cr);
@ -731,7 +806,11 @@ on_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer user_data _U_
cr = gdk_cairo_create (gtk_widget_get_window(widget));
#if GTK_CHECK_VERSION(2,22,0)
cairo_set_source_surface (cr, ios->surface, 0, 0);
#else
gdk_cairo_set_source_pixmap (cr, ios->pixmap, 0, 0);
#endif
cairo_rectangle (cr, event->area.x, event->area.y, event->area.width, event->area.height);
cairo_fill (cr);
@ -871,7 +950,11 @@ on_button_press_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer us
if (u_data->io->rectangle==TRUE)
{
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_rectangle (cr,
floor(MIN(u_data->io->x_old,u_data->io->x_new)),
floor(MIN(u_data->io->y_old,u_data->io->y_new)),
@ -887,7 +970,11 @@ on_button_press_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer us
cr = gdk_cairo_create (gtk_widget_get_window(u_data->io->draw_area));
#if GTK_CHECK_VERSION(2,22,0)
cairo_set_source_surface (cr, ios->surface, 0, 0);
#else
gdk_cairo_set_source_pixmap (cr, ios->pixmap, 0, 0);
#endif
cairo_rectangle (cr, 0, 0, abs((long)(u_data->io->x_new-u_data->io->x_old)), abs((long)(u_data->io->y_new-u_data->io->y_old)));
cairo_fill (cr);
@ -898,8 +985,8 @@ on_button_press_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer us
u_data->io->x_old=event->x;
u_data->io->y_old=event->y;
if (u_data->io->y_old>u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset)
u_data->io->y_old=u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset;
if (u_data->io->y_old>u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset)
u_data->io->y_old=u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset;
if (u_data->io->x_old<LEFT_BORDER+u_data->io->offset)
u_data->io->x_old=LEFT_BORDER+u_data->io->offset;
u_data->io->rectangle=FALSE;
@ -929,8 +1016,8 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
layout = gtk_widget_create_pango_layout(u_data->io->draw_area, label_string);
pango_layout_get_pixel_size(layout, &label_width, &label_height);
if (event->y > u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset)
event->y = u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset;
if (event->y > u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset)
event->y = u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset;
if (event->x < LEFT_BORDER+u_data->io->offset)
event->x = LEFT_BORDER+u_data->io->offset;
@ -941,7 +1028,11 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
u_data->io->rect_y_min = (guint32) floor(MIN(u_data->io->y_old,event->y));
u_data->io->rect_y_max = (guint32) ceil(MAX(u_data->io->y_old,event->y));
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_rectangle (cr,
u_data->io->rect_x_min+0.5,
u_data->io->rect_y_min+0.5,
@ -956,7 +1047,11 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
cr = gdk_cairo_create (gtk_widget_get_window(u_data->io->draw_area));
#if GTK_CHECK_VERSION(2,22,0)
cairo_set_source_surface (cr, ios->surface, 0, 0);
#else
gdk_cairo_set_source_pixmap (cr, ios->pixmap, 0, 0);
#endif
gtk_widget_get_allocation(u_data->io->draw_area, &widget_alloc);
cairo_rectangle (cr, 0, 0, widget_alloc.width, widget_alloc.height);
cairo_fill (cr);
@ -992,8 +1087,8 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
u_data->io->x2_akt_sec = u_data->io->x2_tmp_sec;
u_data->io->x2_akt_usec = u_data->io->x2_tmp_usec;
u_data->io->y1_tmp=(guint32)((u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset-u_data->io->y_old)/u_data->io->y_interval);
u_data->io->y2_tmp=(guint32)((u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset-event->y)/u_data->io->y_interval);
u_data->io->y1_tmp=(guint32)((u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset-u_data->io->y_old)/u_data->io->y_interval);
u_data->io->y2_tmp=(guint32)((u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset-event->y)/u_data->io->y_interval);
helpy = MIN(u_data->io->y1_tmp, u_data->io->y2_tmp);
u_data->io->y2_tmp = MAX(u_data->io->y1_tmp, u_data->io->y2_tmp);
u_data->io->y1_tmp = helpy;
@ -1026,8 +1121,8 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
}
else
{
x_value = ((event->x-LEFT_BORDER-u_data->io->offset) * ((u_data->io->x2_tmp_sec+u_data->io->x2_tmp_usec/1000000.0)-(u_data->io->x1_tmp_sec+u_data->io->x1_tmp_usec/1000000.0)) / (u_data->io->pixmap_width-LEFT_BORDER-RIGHT_BORDER-u_data->io->offset))+u_data->io->x1_tmp_sec+u_data->io->x1_tmp_usec/1000000.0;
y_value = (guint32) floor((u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset-event->y) * (max_tsn - min_tsn) / (u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset)) + min_tsn;
x_value = ((event->x-LEFT_BORDER-u_data->io->offset) * ((u_data->io->x2_tmp_sec+u_data->io->x2_tmp_usec/1000000.0)-(u_data->io->x1_tmp_sec+u_data->io->x1_tmp_usec/1000000.0)) / (u_data->io->surface_width-LEFT_BORDER-RIGHT_BORDER-u_data->io->offset))+u_data->io->x1_tmp_sec+u_data->io->x1_tmp_usec/1000000.0;
y_value = (guint32) floor((u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset-event->y) * (max_tsn - min_tsn) / (u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset)) + min_tsn;
if (u_data->dir == 1)
tsnlist = g_list_last(u_data->assoc->tsn1);
@ -1063,7 +1158,11 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
g_snprintf(label_string, sizeof(label_string), "(%.6f, %u)", x_value, y_value);
label_set = TRUE;
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr,
(event->x-2)+0.5,
@ -1074,7 +1173,11 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
cairo_stroke(cr);
cairo_destroy(cr);
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr,
(event->x)+0.5,
@ -1084,7 +1187,7 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
(event->y+2)+0.5);
cairo_stroke(cr);
cairo_destroy(cr);
if (event->x+150>=u_data->io->pixmap_width)
if (event->x+150>=u_data->io->surface_width)
position = event->x - 150;
else
position = event->x + 5;
@ -1093,7 +1196,11 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
pango_layout_set_text(layout, label_string, -1);
pango_layout_get_pixel_size(layout, &lwidth, NULL);
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_move_to (cr,
position,
event->y-10);
@ -1106,7 +1213,11 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
cr = gdk_cairo_create (gtk_widget_get_window(u_data->io->draw_area));
#if GTK_CHECK_VERSION(2,22,0)
cairo_set_source_surface (cr, ios->surface, 0, 0);
#else
gdk_cairo_set_source_pixmap (cr, ios->pixmap, 0, 0);
#endif
gtk_widget_get_allocation(u_data->io->draw_area, &widget_alloc);
cairo_rectangle (cr, 0, 0, widget_alloc.width, widget_alloc.height);
cairo_fill (cr);
@ -1214,9 +1325,13 @@ gtk_sctpgraph_init(struct sctp_udata *u_data)
io->x_interval=1000;
io->window=NULL;
io->draw_area=NULL;
#if GTK_CHECK_VERSION(2,22,0)
io->surface=NULL;
#else
io->pixmap=NULL;
io->pixmap_width=800;
io->pixmap_height=600;
#endif
io->surface_width=800;
io->surface_height=600;
io->graph_type=0;
u_data->io=io;
@ -1266,7 +1381,7 @@ static void create_draw_area(GtkWidget *box, struct sctp_udata *u_data)
g_signal_connect(u_data->io->draw_area, "destroy", G_CALLBACK(quit), u_data);
g_object_set_data(G_OBJECT(u_data->io->draw_area), "sctp_graph_t", u_data->io);
gtk_widget_set_size_request(u_data->io->draw_area, u_data->io->pixmap_width, u_data->io->pixmap_height);
gtk_widget_set_size_request(u_data->io->draw_area, u_data->io->surface_width, u_data->io->surface_height);
/* signals needed to handle backing pixmap */
g_signal_connect(u_data->io->draw_area, "expose_event", G_CALLBACK(on_expose_event), NULL);

View File

@ -220,12 +220,16 @@ draw_sack_graph(struct sctp_udata *u_data)
else
diff=sack->secs*1000000+sack->usecs-u_data->io->min_x;
xvalue = (guint32)(LEFT_BORDER+u_data->io->offset+u_data->io->x_interval*diff);
yvalue = (guint32)(u_data->io->pixmap_height-BOTTOM_BORDER-POINT_SIZE-u_data->io->offset-((SUB_32(j+tsnumber,min_tsn))*u_data->io->y_interval));
yvalue = (guint32)(u_data->io->surface_height-BOTTOM_BORDER-POINT_SIZE-u_data->io->offset-((SUB_32(j+tsnumber,min_tsn))*u_data->io->y_interval));
if (xvalue >= LEFT_BORDER+u_data->io->offset &&
xvalue <= u_data->io->pixmap_width-RIGHT_BORDER+u_data->io->offset &&
xvalue <= u_data->io->surface_width-RIGHT_BORDER+u_data->io->offset &&
yvalue >= TOP_BORDER-u_data->io->offset-POINT_SIZE &&
yvalue <= u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset)
yvalue <= u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset)
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
gdk_cairo_set_source_color (cr, &green_color);
cairo_arc(cr,
xvalue,
@ -251,13 +255,17 @@ draw_sack_graph(struct sctp_udata *u_data)
else
diff=sack->secs*1000000+sack->usecs-u_data->io->min_x;
xvalue = (guint32)(LEFT_BORDER+u_data->io->offset+u_data->io->x_interval*diff);
yvalue = (guint32)(u_data->io->pixmap_height-BOTTOM_BORDER-POINT_SIZE -u_data->io->offset-((SUB_32(tsnumber,min_tsn))*u_data->io->y_interval));
yvalue = (guint32)(u_data->io->surface_height-BOTTOM_BORDER-POINT_SIZE -u_data->io->offset-((SUB_32(tsnumber,min_tsn))*u_data->io->y_interval));
if (xvalue >= LEFT_BORDER+u_data->io->offset &&
xvalue <= u_data->io->pixmap_width-RIGHT_BORDER+u_data->io->offset &&
xvalue <= u_data->io->surface_width-RIGHT_BORDER+u_data->io->offset &&
yvalue >= TOP_BORDER-u_data->io->offset-POINT_SIZE &&
yvalue <= u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset)
yvalue <= u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset)
{
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
gdk_cairo_set_source_color (cr, &red_color);
cairo_arc(cr,
xvalue,
@ -283,12 +291,16 @@ draw_sack_graph(struct sctp_udata *u_data)
else
diff=sack->secs*1000000+sack->usecs-u_data->io->min_x;
xvalue = (guint32)(LEFT_BORDER+u_data->io->offset+u_data->io->x_interval*diff);
yvalue = (guint32)(u_data->io->pixmap_height-BOTTOM_BORDER-POINT_SIZE -u_data->io->offset-((SUB_32(dup,min_tsn))*u_data->io->y_interval));
yvalue = (guint32)(u_data->io->surface_height-BOTTOM_BORDER-POINT_SIZE -u_data->io->offset-((SUB_32(dup,min_tsn))*u_data->io->y_interval));
if (xvalue >= LEFT_BORDER+u_data->io->offset &&
xvalue <= u_data->io->pixmap_width-RIGHT_BORDER+u_data->io->offset &&
xvalue <= u_data->io->surface_width-RIGHT_BORDER+u_data->io->offset &&
yvalue >= TOP_BORDER-u_data->io->offset-POINT_SIZE &&
yvalue <= u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset)
yvalue <= u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset)
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
gdk_cairo_set_source_color (cr, &cyan_color);
cairo_arc(cr,
xvalue,
@ -401,17 +413,21 @@ draw_nr_sack_graph(struct sctp_udata *u_data)
else
diff=sack->secs*1000000+sack->usecs-u_data->io->min_x;
xvalue = (guint32)(LEFT_BORDER+u_data->io->offset+u_data->io->x_interval*diff);
yvalue = (guint32)(u_data->io->pixmap_height-BOTTOM_BORDER-POINT_SIZE-u_data->io->offset-((SUB_32(j+tsnumber,min_tsn))*u_data->io->y_interval));
yvalue = (guint32)(u_data->io->surface_height-BOTTOM_BORDER-POINT_SIZE-u_data->io->offset-((SUB_32(j+tsnumber,min_tsn))*u_data->io->y_interval));
if (xvalue >= LEFT_BORDER+u_data->io->offset &&
xvalue <= u_data->io->pixmap_width-RIGHT_BORDER+u_data->io->offset &&
xvalue <= u_data->io->surface_width-RIGHT_BORDER+u_data->io->offset &&
yvalue >= TOP_BORDER-u_data->io->offset-POINT_SIZE &&
yvalue <= u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset)
yvalue <= u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset)
{
/* Check if this is an GAP ACK or NR GAP ACK */
if ( i >= numberOf_gaps)
{
/* This is a nr gap ack */
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
gdk_cairo_set_source_color (cr, &blue_color);
cairo_arc(cr,
xvalue,
@ -428,7 +444,11 @@ draw_nr_sack_graph(struct sctp_udata *u_data)
* These will be shown as points with a green dot - GAP ACK
* surrounded by a blue circle - NR GAP ack
*/
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
gdk_cairo_set_source_color (cr, &green_color);
cairo_arc(cr,
xvalue,
@ -442,7 +462,11 @@ draw_nr_sack_graph(struct sctp_udata *u_data)
else
{
/* This is just a gap ack */
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
gdk_cairo_set_source_color (cr, &green_color);
cairo_arc(cr,
xvalue,
@ -470,12 +494,16 @@ draw_nr_sack_graph(struct sctp_udata *u_data)
else
diff=sack->secs*1000000+sack->usecs-u_data->io->min_x;
xvalue = (guint32)(LEFT_BORDER+u_data->io->offset+u_data->io->x_interval*diff);
yvalue = (guint32)(u_data->io->pixmap_height-BOTTOM_BORDER-POINT_SIZE -u_data->io->offset-((SUB_32(tsnumber,min_tsn))*u_data->io->y_interval));
yvalue = (guint32)(u_data->io->surface_height-BOTTOM_BORDER-POINT_SIZE -u_data->io->offset-((SUB_32(tsnumber,min_tsn))*u_data->io->y_interval));
if (xvalue >= LEFT_BORDER+u_data->io->offset &&
xvalue <= u_data->io->pixmap_width-RIGHT_BORDER+u_data->io->offset &&
xvalue <= u_data->io->surface_width-RIGHT_BORDER+u_data->io->offset &&
yvalue >= TOP_BORDER-u_data->io->offset-POINT_SIZE &&
yvalue <= u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset)
yvalue <= u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset)
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
gdk_cairo_set_source_color (cr, &red_color);
cairo_arc(cr,
xvalue,
@ -550,12 +578,16 @@ draw_tsn_graph(struct sctp_udata *u_data)
else
diff=tsn->secs*1000000+tsn->usecs-u_data->io->min_x;
xvalue = (guint32)(LEFT_BORDER+u_data->io->offset+u_data->io->x_interval*diff);
yvalue = (guint32)(u_data->io->pixmap_height-BOTTOM_BORDER-POINT_SIZE-u_data->io->offset-((SUB_32(tsnumber,min_tsn))*u_data->io->y_interval));
yvalue = (guint32)(u_data->io->surface_height-BOTTOM_BORDER-POINT_SIZE-u_data->io->offset-((SUB_32(tsnumber,min_tsn))*u_data->io->y_interval));
if (xvalue >= LEFT_BORDER+u_data->io->offset &&
xvalue <= u_data->io->pixmap_width-RIGHT_BORDER+u_data->io->offset &&
xvalue <= u_data->io->surface_width-RIGHT_BORDER+u_data->io->offset &&
yvalue >= TOP_BORDER-u_data->io->offset-POINT_SIZE &&
yvalue <= u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset)
yvalue <= u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset)
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_arc(cr,
xvalue,
yvalue,
@ -639,7 +671,11 @@ sctp_graph_draw(struct sctp_udata *u_data)
}
}
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_set_source_rgb (cr, 1, 1, 1);
gtk_widget_get_allocation(u_data->io->draw_area, &widget_alloc);
cairo_rectangle (cr,
@ -652,20 +688,24 @@ sctp_graph_draw(struct sctp_udata *u_data)
distance=5;
/* x_axis */
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr, LEFT_BORDER+u_data->io->offset+0.5, u_data->io->pixmap_height - BOTTOM_BORDER+0.5);
cairo_line_to(cr, u_data->io->pixmap_width - RIGHT_BORDER + u_data->io->offset+0.5, u_data->io->pixmap_height - BOTTOM_BORDER+0.5);
cairo_move_to(cr, LEFT_BORDER+u_data->io->offset+0.5, u_data->io->surface_height - BOTTOM_BORDER+0.5);
cairo_line_to(cr, u_data->io->surface_width - RIGHT_BORDER + u_data->io->offset+0.5, u_data->io->surface_height - BOTTOM_BORDER+0.5);
cairo_move_to(cr, u_data->io->pixmap_width - RIGHT_BORDER + u_data->io->offset+0.5, u_data->io->pixmap_height - BOTTOM_BORDER+0.5);
cairo_line_to(cr, u_data->io->pixmap_width - RIGHT_BORDER + u_data->io->offset - 5+0.5, u_data->io->pixmap_height - BOTTOM_BORDER - 5+0.5);
cairo_move_to(cr, u_data->io->surface_width - RIGHT_BORDER + u_data->io->offset+0.5, u_data->io->surface_height - BOTTOM_BORDER+0.5);
cairo_line_to(cr, u_data->io->surface_width - RIGHT_BORDER + u_data->io->offset - 5+0.5, u_data->io->surface_height - BOTTOM_BORDER - 5+0.5);
cairo_move_to(cr, u_data->io->pixmap_width - RIGHT_BORDER + u_data->io->offset + 0.5, u_data->io->pixmap_height - BOTTOM_BORDER + 0.5);
cairo_line_to(cr, u_data->io->pixmap_width - RIGHT_BORDER + u_data->io->offset - 5.5, u_data->io->pixmap_height - BOTTOM_BORDER + 5.5);
cairo_move_to(cr, u_data->io->surface_width - RIGHT_BORDER + u_data->io->offset + 0.5, u_data->io->surface_height - BOTTOM_BORDER + 0.5);
cairo_line_to(cr, u_data->io->surface_width - RIGHT_BORDER + u_data->io->offset - 5.5, u_data->io->surface_height - BOTTOM_BORDER + 5.5);
cairo_stroke(cr);
cairo_destroy(cr);
u_data->io->axis_width=u_data->io->pixmap_width-LEFT_BORDER-RIGHT_BORDER-u_data->io->offset;
u_data->io->axis_width=u_data->io->surface_width-LEFT_BORDER-RIGHT_BORDER-u_data->io->offset;
/* try to avoid dividing by zero */
if(u_data->io->tmp_width>0){
@ -709,10 +749,14 @@ sctp_graph_draw(struct sctp_udata *u_data)
pango_layout_set_text(layout, label_string, -1);
pango_layout_get_pixel_size(layout, &lwidth, NULL);
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_move_to (cr,
LEFT_BORDER-25,
u_data->io->pixmap_height-BOTTOM_BORDER+20);
u_data->io->surface_height-BOTTOM_BORDER+20);
pango_cairo_show_layout (cr, layout);
cairo_destroy (cr);
cr = NULL;
@ -776,23 +820,31 @@ sctp_graph_draw(struct sctp_udata *u_data)
memcpy(label_string,(gchar *)g_locale_to_utf8(label_string, -1 , NULL, NULL, NULL), sizeof(label_string));
pango_layout_set_text(layout, label_string, -1);
pango_layout_get_pixel_size(layout, &lwidth, NULL);
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_move_to (cr,
LEFT_BORDER+u_data->io->offset+(i-u_data->io->min_x)*u_data->io->x_interval-lwidth/2,
u_data->io->pixmap_height-BOTTOM_BORDER+10);
u_data->io->surface_height-BOTTOM_BORDER+10);
pango_cairo_show_layout (cr, layout);
cairo_destroy (cr);
cr = NULL;
}
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr,
LEFT_BORDER + u_data->io->offset + (i - u_data->io->min_x) * u_data->io->x_interval + 0.5,
u_data->io->pixmap_height - BOTTOM_BORDER + 0.5);
u_data->io->surface_height - BOTTOM_BORDER + 0.5);
cairo_line_to(cr,
LEFT_BORDER + u_data->io->offset + (i - u_data->io->min_x) * u_data->io->x_interval + 0.5,
u_data->io->pixmap_height - BOTTOM_BORDER + length + 0.5);
u_data->io->surface_height - BOTTOM_BORDER + length + 0.5);
cairo_stroke(cr);
cairo_destroy(cr);
}
@ -815,14 +867,18 @@ sctp_graph_draw(struct sctp_udata *u_data)
}
if (write_label)
{
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr,
LEFT_BORDER + u_data->io->offset + (i - u_data->io->min_x) * u_data->io->x_interval + 0.5,
u_data->io->pixmap_height - BOTTOM_BORDER + 0.5);
u_data->io->surface_height - BOTTOM_BORDER + 0.5);
cairo_line_to(cr,
LEFT_BORDER + u_data->io->offset + (i - u_data->io->min_x) * u_data->io->x_interval + 0.5,
u_data->io->pixmap_height - BOTTOM_BORDER + 10 + 0.5);
u_data->io->surface_height - BOTTOM_BORDER + 10 + 0.5);
cairo_stroke(cr);
cairo_destroy(cr);
@ -831,10 +887,14 @@ sctp_graph_draw(struct sctp_udata *u_data)
pango_layout_set_text(layout, label_string, -1);
pango_layout_get_pixel_size(layout, &lwidth, NULL);
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_move_to (cr,
LEFT_BORDER+u_data->io->offset+(i-u_data->io->min_x)*u_data->io->x_interval-10,
u_data->io->pixmap_height-BOTTOM_BORDER+20);
u_data->io->surface_height-BOTTOM_BORDER+20);
pango_cairo_show_layout (cr, layout);
cairo_destroy (cr);
cr = NULL;
@ -849,10 +909,14 @@ sctp_graph_draw(struct sctp_udata *u_data)
memcpy(label_string,(gchar *)g_locale_to_utf8(label_string, -1 , NULL, NULL, NULL), sizeof(label_string));
pango_layout_set_text(layout, label_string, -1);
pango_layout_get_pixel_size(layout, &lwidth, NULL);
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_move_to (cr,
u_data->io->pixmap_width-RIGHT_BORDER-10,
u_data->io->pixmap_height-BOTTOM_BORDER+30);
u_data->io->surface_width-RIGHT_BORDER-10,
u_data->io->surface_height-BOTTOM_BORDER+30);
pango_cairo_show_layout (cr, layout);
cairo_destroy (cr);
cr = NULL;
@ -861,10 +925,14 @@ sctp_graph_draw(struct sctp_udata *u_data)
distance=5;
/* y-axis */
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr, LEFT_BORDER + 0.5, TOP_BORDER - u_data->io->offset + 0.5);
cairo_line_to(cr, LEFT_BORDER + 0.5, u_data->io->pixmap_height - BOTTOM_BORDER - u_data->io->offset + 0.5);
cairo_line_to(cr, LEFT_BORDER + 0.5, u_data->io->surface_height - BOTTOM_BORDER - u_data->io->offset + 0.5);
cairo_move_to(cr, LEFT_BORDER + 0.5, TOP_BORDER - u_data->io->offset + 0.5);
cairo_line_to(cr, LEFT_BORDER - 5 + 0.5, TOP_BORDER - u_data->io->offset + 5 + 0.5);
@ -874,7 +942,7 @@ sctp_graph_draw(struct sctp_udata *u_data)
cairo_stroke(cr);
cairo_destroy(cr);
u_data->io->y_interval = (float)(((u_data->io->pixmap_height-TOP_BORDER-BOTTOM_BORDER)*1.0)/(u_data->io->max_y-u_data->io->min_y));
u_data->io->y_interval = (float)(((u_data->io->surface_height-TOP_BORDER-BOTTOM_BORDER)*1.0)/(u_data->io->max_y-u_data->io->min_y));
e=0;
if (u_data->io->y_interval<1)
@ -907,23 +975,31 @@ sctp_graph_draw(struct sctp_udata *u_data)
memcpy(label_string,(gchar *)g_locale_to_utf8(label_string, -1 , NULL, NULL, NULL), sizeof(label_string));
pango_layout_set_text(layout, label_string, -1);
pango_layout_get_pixel_size(layout, &lwidth, NULL);
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_move_to (cr,
LEFT_BORDER-length-lwidth-5,
u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset-(i-u_data->io->min_y)*u_data->io->y_interval-POINT_SIZE);
u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset-(i-u_data->io->min_y)*u_data->io->y_interval-POINT_SIZE);
pango_cairo_show_layout (cr, layout);
cairo_destroy (cr);
cr = NULL;
}
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr,
LEFT_BORDER - length + 0.5,
u_data->io->pixmap_height - BOTTOM_BORDER - u_data->io->offset - (i - u_data->io->min_y) * u_data->io->y_interval + 0.5);
u_data->io->surface_height - BOTTOM_BORDER - u_data->io->offset - (i - u_data->io->min_y) * u_data->io->y_interval + 0.5);
cairo_line_to(cr,
LEFT_BORDER + 0.5,
u_data->io->pixmap_height - BOTTOM_BORDER - u_data->io->offset - (i - u_data->io->min_y) * u_data->io->y_interval + 0.5);
u_data->io->surface_height - BOTTOM_BORDER - u_data->io->offset - (i - u_data->io->min_y) * u_data->io->y_interval + 0.5);
cairo_stroke(cr);
cairo_destroy(cr);
@ -1004,7 +1080,11 @@ sctp_graph_redraw(struct sctp_udata *u_data)
cr = gdk_cairo_create (gtk_widget_get_window(u_data->io->draw_area));
#if GTK_CHECK_VERSION(2,22,0)
cairo_set_source_surface (cr, ios->surface, 0, 0);
#else
gdk_cairo_set_source_pixmap (cr, ios->pixmap, 0, 0);
#endif
gtk_widget_get_allocation(u_data->io->draw_area, &widget_alloc);
cairo_rectangle (cr, 0, 0, widget_alloc.width, widget_alloc.height);
cairo_fill (cr);
@ -1059,20 +1139,36 @@ configure_event(GtkWidget *widget, GdkEventConfigure *event _U_, gpointer user_d
g_assert(u_data->io != NULL);
#if GTK_CHECK_VERSION(2,22,0)
if(u_data->io->surface){
cairo_surface_destroy (u_data->io->surface);
u_data->io->surface=NULL;
}
gtk_widget_get_allocation(widget, &widget_alloc);
u_data->io->surface = gdk_window_create_similar_surface (gtk_widget_get_window(widget),
CAIRO_CONTENT_COLOR,
widget_alloc.width,
widget_alloc.height);
#else
if(u_data->io->pixmap){
g_object_unref(u_data->io->pixmap);
u_data->io->pixmap=NULL;
}
gtk_widget_get_allocation(widget, &widget_alloc);
u_data->io->pixmap=gdk_pixmap_new(gtk_widget_get_window(widget),
widget_alloc.width,
widget_alloc.height,
-1);
u_data->io->pixmap_width=widget_alloc.width;
u_data->io->pixmap_height=widget_alloc.height;
#endif
u_data->io->surface_width=widget_alloc.width;
u_data->io->surface_height=widget_alloc.height;
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_rectangle (cr, 0, 0, widget_alloc.width, widget_alloc.height);
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_fill (cr);
@ -1093,7 +1189,11 @@ expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer user_data _U_)
cr = gdk_cairo_create (gtk_widget_get_window(widget));
#if GTK_CHECK_VERSION(2,22,0)
cairo_set_source_surface (cr, ios->surface, 0, 0);
#else
gdk_cairo_set_source_pixmap (cr, ios->pixmap, 0, 0);
#endif
cairo_rectangle (cr, event->area.x, event->area.y, event->area.width, event->area.height);
cairo_fill (cr);
@ -1236,7 +1336,11 @@ on_button_press_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer us
if (u_data->io->rectangle==TRUE)
{
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_rectangle (cr,
floor(MIN(u_data->io->x_old,u_data->io->x_new)),
floor(MIN(u_data->io->y_old,u_data->io->y_new)),
@ -1252,7 +1356,11 @@ on_button_press_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer us
cr = gdk_cairo_create (gtk_widget_get_window(u_data->io->draw_area));
#if GTK_CHECK_VERSION(2,22,0)
cairo_set_source_surface (cr, ios->surface, 0, 0);
#else
gdk_cairo_set_source_pixmap (cr, ios->pixmap, 0, 0);
#endif
cairo_rectangle (cr, 0, 0, abs((long)(u_data->io->x_new-u_data->io->x_old)), abs((long)(u_data->io->y_new-u_data->io->y_old)));
cairo_fill (cr);
@ -1262,8 +1370,8 @@ on_button_press_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer us
}
u_data->io->x_old=event->x;
u_data->io->y_old=event->y;
if (u_data->io->y_old>u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset-POINT_SIZE)
u_data->io->y_old=u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset-POINT_SIZE;
if (u_data->io->y_old>u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset-POINT_SIZE)
u_data->io->y_old=u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset-POINT_SIZE;
if (u_data->io->x_old<LEFT_BORDER+u_data->io->offset)
u_data->io->x_old=LEFT_BORDER+u_data->io->offset;
u_data->io->rectangle=FALSE;
@ -1294,8 +1402,8 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
layout = gtk_widget_create_pango_layout(u_data->io->draw_area, label_string);
pango_layout_get_pixel_size(layout, &label_width, &label_height);
if (event->y>u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset)
event->y = u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset;
if (event->y>u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset)
event->y = u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset;
if (event->x < LEFT_BORDER+u_data->io->offset)
event->x = LEFT_BORDER+u_data->io->offset;
if (abs((long)(event->x-u_data->io->x_old))>10 || abs((long)(event->y-u_data->io->y_old))>10)
@ -1304,7 +1412,11 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
u_data->io->rect_x_max = (gint)ceil(MAX(u_data->io->x_old,event->x));
u_data->io->rect_y_min = (gint)floor(MIN(u_data->io->y_old,event->y));
u_data->io->rect_y_max = (gint)ceil(MAX(u_data->io->y_old,event->y))+POINT_SIZE;
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_rectangle (cr,
u_data->io->rect_x_min+0.5,
u_data->io->rect_y_min+0.5,
@ -1320,7 +1432,11 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
cr = gdk_cairo_create (gtk_widget_get_window(u_data->io->draw_area));
#if GTK_CHECK_VERSION(2,22,0)
cairo_set_source_surface (cr, ios->surface, 0, 0);
#else
gdk_cairo_set_source_pixmap (cr, ios->pixmap, 0, 0);
#endif
gtk_widget_get_allocation(u_data->io->draw_area, &widget_alloc);
cairo_rectangle (cr, 0, 0, widget_alloc.width, widget_alloc.height);
cairo_fill (cr);
@ -1356,8 +1472,8 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
u_data->io->x2_akt_sec = u_data->io->x2_tmp_sec;
u_data->io->x2_akt_usec = u_data->io->x2_tmp_usec;
u_data->io->y1_tmp=(guint32)((u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset-u_data->io->y_old)/u_data->io->y_interval);
u_data->io->y2_tmp=(guint32)((u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset-event->y)/u_data->io->y_interval);
u_data->io->y1_tmp=(guint32)((u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset-u_data->io->y_old)/u_data->io->y_interval);
u_data->io->y2_tmp=(guint32)((u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset-event->y)/u_data->io->y_interval);
helpy = MIN(u_data->io->y1_tmp, u_data->io->y2_tmp);
u_data->io->y2_tmp = MAX(u_data->io->y1_tmp, u_data->io->y2_tmp);
u_data->io->y1_tmp = helpy;
@ -1390,8 +1506,8 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
}
else
{
x_value = ((event->x-LEFT_BORDER-u_data->io->offset) * ((u_data->io->x2_tmp_sec+u_data->io->x2_tmp_usec/1000000.0)-(u_data->io->x1_tmp_sec+u_data->io->x1_tmp_usec/1000000.0)) / (u_data->io->pixmap_width-LEFT_BORDER-RIGHT_BORDER-u_data->io->offset))+u_data->io->x1_tmp_sec+u_data->io->x1_tmp_usec/1000000.0;
y_value = (gint)rint((u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset-event->y) * (max_tsn - min_tsn) / (u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset)) + min_tsn;
x_value = ((event->x-LEFT_BORDER-u_data->io->offset) * ((u_data->io->x2_tmp_sec+u_data->io->x2_tmp_usec/1000000.0)-(u_data->io->x1_tmp_sec+u_data->io->x1_tmp_usec/1000000.0)) / (u_data->io->surface_width-LEFT_BORDER-RIGHT_BORDER-u_data->io->offset))+u_data->io->x1_tmp_sec+u_data->io->x1_tmp_usec/1000000.0;
y_value = (gint)rint((u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset-event->y) * (max_tsn - min_tsn) / (u_data->io->surface_height-BOTTOM_BORDER-u_data->io->offset)) + min_tsn;
if (u_data->dir == 1)
{
@ -1408,7 +1524,7 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
s_size = u_data->assoc->n_sack_chunks_ep2;
}
x_tolerance = (gdouble)((u_data->io->tmp_width / u_data->io->axis_width*1.0))*5/1000000.0;
y_tolerance = (guint32)(((u_data->io->max_y - u_data->io->min_y) / (u_data->io->pixmap_height-TOP_BORDER-BOTTOM_BORDER-u_data->io->offset)) * 2.0);
y_tolerance = (guint32)(((u_data->io->max_y - u_data->io->min_y) / (u_data->io->surface_height-TOP_BORDER-BOTTOM_BORDER-u_data->io->offset)) * 2.0);
if (y_tolerance==0)
y_tolerance = 2;
else if (y_tolerance > 5)
@ -1452,7 +1568,11 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
label_set = TRUE;
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr,
(event->x-2)+0.5,
@ -1463,7 +1583,11 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
cairo_stroke(cr);
cairo_destroy(cr);
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr,
(event->x)+0.5,
@ -1474,7 +1598,7 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
cairo_stroke(cr);
cairo_destroy(cr);
if (event->x+150>=u_data->io->pixmap_width)
if (event->x+150>=u_data->io->surface_width)
position = event->x - 150;
else
position = event->x + 5;
@ -1484,7 +1608,11 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
pango_layout_set_text(layout, label_string, -1);
pango_layout_get_pixel_size(layout, &lwidth, NULL);
#if GTK_CHECK_VERSION(2,22,0)
cr = cairo_create (u_data->io->surface);
#else
cr = gdk_cairo_create (u_data->io->pixmap);
#endif
cairo_move_to (cr,
position,
event->y-10);
@ -1497,7 +1625,11 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
cr = gdk_cairo_create (gtk_widget_get_window(u_data->io->draw_area));
#if GTK_CHECK_VERSION(2,22,0)
cairo_set_source_surface (cr, ios->surface, 0, 0);
#else
gdk_cairo_set_source_pixmap (cr, ios->pixmap, 0, 0);
#endif
gtk_widget_get_allocation(u_data->io->draw_area, &widget_alloc);
cairo_rectangle (cr, 0, 0, widget_alloc.width, widget_alloc.height);
cairo_fill (cr);
@ -1604,9 +1736,13 @@ gtk_sctpgraph_init(struct sctp_udata *u_data)
io->x_interval=1000;
io->window=NULL;
io->draw_area=NULL;
#if GTK_CHECK_VERSION(2,22,0)
io->surface=NULL;
#else
io->pixmap=NULL;
io->pixmap_width=800;
io->pixmap_height=600;
#endif
io->surface_width=800;
io->surface_height=600;
io->graph_type=0;
u_data->io=io;
u_data->io->x1_tmp_sec=u_data->assoc->min_secs;
@ -1660,7 +1796,7 @@ create_draw_area(GtkWidget *box, struct sctp_udata *u_data)
g_signal_connect(u_data->io->draw_area, "destroy", G_CALLBACK(quit), u_data);
g_object_set_data(G_OBJECT(u_data->io->draw_area), "sctp_graph_t", u_data->io);
gtk_widget_set_size_request(u_data->io->draw_area, u_data->io->pixmap_width, u_data->io->pixmap_height);
gtk_widget_set_size_request(u_data->io->draw_area, u_data->io->surface_width, u_data->io->surface_height);
/* signals needed to handle backing pixmap */
g_signal_connect(u_data->io->draw_area, "expose_event", G_CALLBACK(expose_event), NULL);

View File

@ -301,9 +301,13 @@ typedef struct _sctp_graph_t {
gfloat y_interval;
GtkWidget *window;
GtkWidget *draw_area;
#if GTK_CHECK_VERSION(2,22,0)
cairo_surface_t *surface;
#else
GdkPixmap *pixmap;
gint pixmap_width;
gint pixmap_height;
#endif
gint surface_width;
gint surface_height;
gint graph_type;
gdouble x_old;
gdouble y_old;