#include <math.h>
#include <string.h>
+#if defined(GDK_DISABLE_DEPRECATED)
+# undef GDK_DISABLE_DEPRECATED
+#endif
+
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#if GTK_CHECK_VERSION(3,0,0)
ELMT_NONE=0,
ELMT_RECT=1,
ELMT_LINE=2,
- ELMT_ARC=3
+ ELMT_ELLIPSE=3
} ElementType;
struct rect_params {
struct line dim;
};
-struct arc_params {
+struct ellipse_params {
struct rect dim;
- gint filled;
- gint angle1, angle2;
};
struct element {
ElementType type;
GdkColor *elment_color_p;
- GdkGC *gc;
struct segment *parent;
union {
- struct arc_params arc;
+ struct ellipse_params ellipse;
struct rect_params rect;
struct line_params line;
} p;
struct axis {
struct graph *g; /* which graph we belong to */
GtkWidget *drawing_area;
+#if GTK_CHECK_VERSION(2,22,0)
+ cairo_surface_t *surface[2];
+#else
GdkPixmap *pixmap[2];
+#endif
int displayed;
#define AXIS_ORIENTATION 1 << 0
int flags;
struct style_tseq_tcptrace {
GdkColor seq_color;
GdkColor ack_color[2];
- GdkGC *gc_seq;
- GdkGC *gc_ack[2];
int flags;
};
int flags;
GtkWidget *toplevel; /* keypress handler needs this */
GtkWidget *drawing_area;
- GtkWidget *text; /* text widget for seg list - probably
- * temporary */
+ GtkWidget *text; /* text widget for seg list - probably
+ * temporary
+ */
PangoFontDescription *font; /* font used for annotations etc. */
+#if GTK_CHECK_VERSION(3,0,0)
+#else
GdkGC *fg_gc;
- GdkGC *bg_gc;
+#endif
+#if GTK_CHECK_VERSION(2,22,0)
+ cairo_surface_t *title_surface;
+ cairo_surface_t *surface[2];
+#else
GdkPixmap *title_pixmap;
GdkPixmap *pixmap[2];
+#endif
int displayed; /* which of both pixmaps is on screen right now */
struct {
GtkWidget *control_panel;
} gt;
};
+#if GTK_CHECK_VERSION(3,0,0)
+#else
static GdkGC *xor_gc = NULL;
+#endif
static int refnum=0;
#define debug(section) if (debugging & section)
static void graph_initialize_values (struct graph * );
static void graph_init_sequence (struct graph * );
static void draw_element_line (struct graph * , struct element * );
-static void draw_element_arc (struct graph * , struct element * );
+static void draw_element_ellipse (struct graph * , struct element * );
static void graph_display (struct graph * );
static void graph_pixmaps_create (struct graph * );
static void graph_pixmaps_switch (struct graph * );
static void graph_segment_list_free (struct graph * );
static void graph_select_segment (struct graph * , int , int );
static int line_detect_collision (struct element * , int , int );
-static int arc_detect_collision (struct element * , int , int );
+static int ellipse_detect_collision (struct element * , int , int );
static void axis_pixmaps_create (struct axis * );
static void axis_pixmaps_switch (struct axis * );
static void axis_display (struct axis * );
static void create_drawing_area (struct graph *g)
{
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkStyleContext *context;
+#else
GdkColormap *colormap;
GdkColor color;
+#endif
char window_title[WINDOW_TITLE_LENGTH];
struct segment current;
struct tcpheader *thdr;
GtkAllocation widget_alloc;
#if 0
/* Prep. to include the controls in the graph window */
- GtkWidget *frame;
+ GtkWidget *frame;
GtkWidget *vbox;
GtkWidget *hbox;
#endif
g->wp.width = widget_alloc.width - g->wp.x - RMARGIN_WIDTH;
g->wp.height = widget_alloc.height - g->wp.y - g->x_axis->s.height;
- g->font = gtk_widget_get_style(g->drawing_area)->font_desc;
-
+#if GTK_CHECK_VERSION(3,0,0)
+ context = gtk_widget_get_style_context (g->drawing_area);
+ gtk_style_context_get (context, GTK_STATE_NORMAL,
+ "font", &g->font,
+ NULL);
+#else
+ g->font = gtk_widget_get_style(g->drawing_area)->font_desc;
+#endif
+#if GTK_CHECK_VERSION(3,0,0)
+#else
colormap = gtk_widget_get_colormap(GTK_WIDGET(g->drawing_area));
if (!xor_gc) {
xor_gc = gdk_gc_new (gtk_widget_get_window(g->drawing_area));
gdk_gc_set_foreground (xor_gc, &color);
}
g->fg_gc = gdk_gc_new (gtk_widget_get_window(g->drawing_area));
- g->bg_gc = gdk_gc_new (gtk_widget_get_window(g->drawing_area));
- if (!gdk_color_parse ("white", &color)) {
- /*
- * XXX - do more than just warn.
- */
- simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "Could not parse color white.");
- }
- if (!gdk_colormap_alloc_color (colormap, &color, FALSE, TRUE)) {
- /*
- * XXX - do more than just warn.
- */
- simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "Could not allocate color white.");
- }
- gdk_gc_set_foreground (g->bg_gc, &color);
/* this is probably quite an ugly way to get rid of the first configure
* event
* !!! NEMLLO BY TO BYT NA KONCI graph_init_sequence()? !!!
*
*/
+#endif
g_signal_connect(g->drawing_area, "configure_event", G_CALLBACK(configure_event),
NULL);
window_destroy (g->gui.control_panel);
window_destroy (g->toplevel);
/* window_destroy (g->text); */
- g_object_unref (g->fg_gc);
- g_object_unref (g->bg_gc);
+#if GTK_CHECK_VERSION(2,22,0)
+ if(g->title_surface){
+ cairo_surface_destroy (g->title_surface);
+ }
+ if(g->surface[0]){
+ cairo_surface_destroy (g->surface[0]);
+ }
+ if(g->surface[1]){
+ cairo_surface_destroy (g->surface[1]);
+ }
+#else
g_object_unref (g->pixmap[0]);
g_object_unref (g->pixmap[1]);
+#endif /* GTK_CHECK_VERSION(2,22,0) */
g_free (g->x_axis);
g_free (g->y_axis);
g_free ( (gpointer) (g->title) );
static void graph_title_pixmap_create (struct graph *g)
{
+#if GTK_CHECK_VERSION(2,22,0)
+ if(g->title_surface){
+ cairo_surface_destroy (g->title_surface);
+ g->title_surface = NULL;
+ }
+
+ g->title_surface = gdk_window_create_similar_surface (gtk_widget_get_window(g->drawing_area),
+ CAIRO_CONTENT_COLOR,
+ g->x_axis->p.width,
+ g->wp.y);
+
+#else
if (g->title_pixmap)
g_object_unref (g->title_pixmap);
g->title_pixmap = gdk_pixmap_new (gtk_widget_get_window(g->drawing_area),
g->x_axis->p.width, g->wp.y, -1);
+#endif
}
static void graph_title_pixmap_draw (struct graph *g)
int i;
cairo_t *cr;
+#if GTK_CHECK_VERSION(2,22,0)
+ cr = cairo_create (g->title_surface);
+#else
cr = gdk_cairo_create (g->title_pixmap);
+#endif
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_rectangle (cr, 0, 0, g->x_axis->p.width, g->wp.y);
cairo_fill (cr);
layout = gtk_widget_create_pango_layout(g->drawing_area,
g->title[i]);
pango_layout_get_pixel_size(layout, &w, &h);
+#if GTK_CHECK_VERSION(2,22,0)
+ cr = cairo_create (g->title_surface);
+#else
cr = gdk_cairo_create (g->title_pixmap);
+#endif
cairo_move_to (cr, g->wp.width/2 - w/2, 20 + i*(h+3));
pango_cairo_show_layout (cr, layout);
cairo_destroy (cr);
cairo_t *cr;
cr = gdk_cairo_create (gtk_widget_get_window(g->drawing_area));
+#if GTK_CHECK_VERSION(2,22,0)
+ cairo_set_source_surface (cr, g->title_surface, g->wp.x, 0);
+#else
gdk_cairo_set_source_pixmap (cr, g->title_pixmap, g->wp.x, 0);
+#endif
cairo_rectangle (cr, g->wp.x, 0, g->x_axis->p.width, g->wp.y);
cairo_fill (cr);
cairo_destroy (cr);
static void graph_pixmaps_create (struct graph *g)
{
debug(DBS_FENTRY) puts ("graph_pixmaps_create()");
+#if GTK_CHECK_VERSION(2,22,0)
+ if(g->surface[0]){
+ cairo_surface_destroy (g->surface[0]);
+ g->surface[0] = NULL;
+ }
+
+ if(g->surface[1]){
+ cairo_surface_destroy (g->surface[1]);
+ g->surface[1] = NULL;
+ }
+
+ g->surface[0] = gdk_window_create_similar_surface (gtk_widget_get_window(g->drawing_area),
+ CAIRO_CONTENT_COLOR,
+ g->wp.width,
+ g->wp.height);
+
+ g->surface[1] = gdk_window_create_similar_surface (gtk_widget_get_window(g->drawing_area),
+ CAIRO_CONTENT_COLOR,
+ g->wp.width,
+ g->wp.height);
+ g->displayed = 0;
+#else
if (g->pixmap[0])
g_object_unref (g->pixmap[0]);
if (g->pixmap[1])
g->wp.width, g->wp.height, -1);
g->displayed = 0;
+#endif /* GTK_CHECK_VERSION(2,22,0) */
}
static void graph_display (struct graph *g)
cairo_t *cr;
cr = gdk_cairo_create (gtk_widget_get_window(g->drawing_area));
+#if GTK_CHECK_VERSION(2,22,0)
+ cairo_set_source_surface (cr, g->surface[g->displayed], g->wp.x, g->wp.y);
+#else
gdk_cairo_set_source_pixmap (cr, g->pixmap[g->displayed], g->wp.x, g->wp.y);
+#endif /* GTK_CHECK_VERSION(2,22,0) */
cairo_rectangle (cr, g->wp.x, g->wp.y, g->wp.width, g->wp.height);
cairo_fill (cr);
cairo_destroy (cr);
debug(DBS_FENTRY) puts ("graph_display()");
not_disp = 1 ^ g->displayed;
+#if GTK_CHECK_VERSION(2,22,0)
+ cr = cairo_create (g->surface[not_disp]);
+#else
cr = gdk_cairo_create (g->pixmap[not_disp]);
+#endif /* GTK_CHECK_VERSION(2,22,0) */
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_rectangle (cr, 0, 0, g->wp.width, g->wp.height);
cairo_fill (cr);
case ELMT_LINE:
draw_element_line (g, e);
break;
- case ELMT_ARC:
- draw_element_arc (g, e);
+ case ELMT_ELLIPSE:
+ draw_element_ellipse (g, e);
break;
default:
break;
debug(DBS_GRAPH_DRAWING) printf ("line: (%d,%d)->(%d,%d)\n", xx1, yy1, xx2,yy2);
g_assert(e->elment_color_p!=NULL);
+
+#if GTK_CHECK_VERSION(2,22,0)
+ cr = cairo_create (g->surface[1^g->displayed]);
+#else
cr = gdk_cairo_create (g->pixmap[1^g->displayed]);
+#endif
cairo_set_line_width (cr, 1.0);
if(e->elment_color_p!=NULL){
gdk_cairo_set_source_color (cr, e->elment_color_p);
cairo_destroy(cr);
}
-static void draw_element_arc (struct graph *g, struct element *e)
+static void draw_element_ellipse (struct graph *g, struct element *e)
{
+#if GTK_CHECK_VERSION(2,22,0)
+ cairo_t *cr;
+ gdouble w = e->p.ellipse.dim.width;
+ gdouble h = e->p.ellipse.dim.height;
+ gdouble x = e->p.ellipse.dim.x + g->geom.x - g->wp.x;
+ gdouble y = g->geom.height-1 - e->p.ellipse.dim.y + g->geom.y - g->wp.y;
+
+ debug(DBS_GRAPH_DRAWING) printf ("ellipse: (x, y) -> (w, h): (%f, %f) -> (%f, %f)\n", x, y, w, h);
+
+ cr = cairo_create (g->surface[1^g->displayed]);
+ cairo_translate (cr, x + w / 2., y + h / 2.);
+ cairo_scale (cr, w / 2., h / 2.);
+ cairo_arc (cr, 0., 0., 1., 0., 2 * G_PI);
+ cairo_fill(cr);
+ cairo_destroy(cr);
+#else
int xx1, xx2, yy1, yy2;
- /*cairo_t *cr;*/
- xx1 = (int )rint (e->p.arc.dim.x + g->geom.x - g->wp.x);
- xx2 = (int )e->p.arc.dim.width;
- yy1 = (int )rint (g->geom.height-1 - e->p.arc.dim.y + g->geom.y - g->wp.y);
- yy2 = (int )e->p.arc.dim.height;
+ xx1 = (int )rint (e->p.ellipse.dim.x + g->geom.x - g->wp.x);
+ xx2 = (int )e->p.ellipse.dim.width;
+ yy1 = (int )rint (g->geom.height-1 - e->p.ellipse.dim.y + g->geom.y - g->wp.y);
+ yy2 = (int )e->p.ellipse.dim.height;
if (xx1<-xx2 || xx1>=g->wp.width || yy1<-yy2 || yy1>=g->wp.height)
return;
- debug(DBS_GRAPH_DRAWING) printf ("arc: (%d,%d)->(%d,%d)\n", xx1, yy1, xx2, yy2);
- gdk_draw_arc (g->pixmap[1^g->displayed], e->gc, e->p.arc.filled, xx1,
- yy1, xx2, yy2, e->p.arc.angle1, e->p.arc.angle2);
-
-#if 0
- /* NOTE the coordinates and angels needs to be recalculated as cairo_arc works differently */
- cr = gdk_cairo_create (g->pixmap[1^g->displayed]);
- cairo_set_line_width (cr, 1.0);
- if(e->elment_color_p!=NULL){
- gdk_cairo_set_source_color (cr, e->elment_color_p);
- }
- /* The arc is centered at (xc, yc)
- * begins at angle1 and proceeds in the direction of increasing angles to end at angle2
- */
- cairo_arc(cr, xx1, yy1, e->p.arc.dim.width/2, /*e->p.arc.angle1*/0, /*e->p.arc.angle2*/2 * G_PI);
+ debug(DBS_GRAPH_DRAWING) printf ("ellipse: (%d,%d)->(%d,%d)\n", xx1, yy1, xx2, yy2);
- if(e->p.arc.filled){
- cairo_fill(cr);
- }else{
- cairo_stroke(cr);
- }
- cairo_destroy(cr);
-
- g_warning("Drawing arc");
+ gdk_draw_arc (g->pixmap[1^g->displayed], g->fg_gc, TRUE, xx1,
+ yy1, xx2, yy2, 0, 23040);
#endif
+ /* NOTE the coordinates and angels needs to be recalculated as cairo_arc works differently */
}
static void axis_pixmaps_create (struct axis *axis)
{
debug(DBS_FENTRY) puts ("axis_pixmaps_create()");
+#if GTK_CHECK_VERSION(2,22,0)
+ if(axis->surface[0]){
+ cairo_surface_destroy (axis->surface[0]);
+ axis->surface[0] = NULL;
+ }
+ if(axis->surface[1]){
+ cairo_surface_destroy (axis->surface[1]);
+ axis->surface[1] = NULL;
+ }
+ axis->surface[0] = gdk_window_create_similar_surface (gtk_widget_get_window(axis->drawing_area),
+ CAIRO_CONTENT_COLOR,
+ axis->p.width,
+ axis->p.height);
+
+ axis->surface[1] = gdk_window_create_similar_surface (gtk_widget_get_window(axis->drawing_area),
+ CAIRO_CONTENT_COLOR,
+ axis->p.width,
+ axis->p.height);
+
+ axis->displayed = 0;
+#else
if (axis->pixmap[0])
g_object_unref (axis->pixmap[0]);
if (axis->pixmap[1])
axis->p.width, axis->p.height, -1);
axis->displayed = 0;
+#endif
}
static void axis_destroy (struct axis *axis)
{
+#if GTK_CHECK_VERSION(2,22,0)
+ if(axis->surface[0]){
+ cairo_surface_destroy (axis->surface[0]);
+ axis->surface[0] = NULL;
+ }
+ if(axis->surface[1]){
+ cairo_surface_destroy (axis->surface[1]);
+ axis->surface[1] = NULL;
+ }
+#else
g_object_unref (axis->pixmap[0]);
g_object_unref (axis->pixmap[1]);
+#endif
g_free ( (gpointer) (axis->label) );
}
not_disp = 1 ^ axis->displayed;
+#if GTK_CHECK_VERSION(2,22,0)
+ cr = cairo_create (axis->surface[not_disp]);
+#else
cr = gdk_cairo_create (axis->pixmap[not_disp]);
+#endif
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_rectangle (cr, 0, 0, axis->p.width, axis->p.height);
cairo_fill (cr);
cr = NULL;
/* axis */
+#if GTK_CHECK_VERSION(2,22,0)
+ cr = cairo_create (axis->surface[not_disp]);
+#else
cr = gdk_cairo_create (axis->pixmap[not_disp]);
+#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr, axis->p.width - 1.5, (axis->p.height-axis->s.height)/2.0);
cairo_line_to(cr, axis->s.width - 1.5, axis->p.height);
if (y < 0 || y > axis->p.height)
continue;
+#if GTK_CHECK_VERSION(2,22,0)
+ cr = cairo_create (axis->surface[not_disp]);
+#else
cr = gdk_cairo_create (axis->pixmap[not_disp]);
+#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr, axis->p.width - 15, y+0.5);
cairo_line_to(cr, axis->s.width - 1, y+0.5);
g_snprintf (desc, sizeof(desc), "%.*f", rdigits, i*axis->major + fl);
layout = gtk_widget_create_pango_layout(g->drawing_area, desc);
pango_layout_get_pixel_size(layout, &w, &h);
+#if GTK_CHECK_VERSION(2,22,0)
+ cr = cairo_create (axis->surface[not_disp]);
+#else
cr = gdk_cairo_create (axis->pixmap[not_disp]);
+#endif
cairo_move_to (cr, axis->s.width-14-4-w, y - h/2);
pango_cairo_show_layout (cr, layout);
cairo_destroy (cr);
debug (DBS_AXES_DRAWING) printf ("%f @ %d\n", i*axis->minor+fl, y);
if (y > 0 && y < axis->p.height)
+#if GTK_CHECK_VERSION(2,22,0)
+ cr = cairo_create (axis->surface[not_disp]);
+#else
cr = gdk_cairo_create (axis->pixmap[not_disp]);
+#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr, axis->s.width - 8, y+0.5);
cairo_line_to(cr, axis->s.width - 1, y+0.5);
layout = gtk_widget_create_pango_layout(g->drawing_area,
axis->label[i]);
pango_layout_get_pixel_size(layout, &w, &h);
+#if GTK_CHECK_VERSION(2,22,0)
+ cr = cairo_create (axis->surface[not_disp]);
+#else
cr = gdk_cairo_create (axis->pixmap[not_disp]);
+#endif
cairo_move_to (cr, (axis->p.width - w)/2, TITLEBAR_HEIGHT-10 - i*(h+3) - h);
pango_cairo_show_layout (cr, layout);
cairo_destroy (cr);
not_disp = 1 ^ axis->displayed;
+#if GTK_CHECK_VERSION(2,22,0)
+ cr = cairo_create (axis->surface[not_disp]);
+#else
cr = gdk_cairo_create (axis->pixmap[not_disp]);
+#endif
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_rectangle (cr, 0, 0, axis->p.width, axis->p.height);
cairo_fill (cr);
cr = NULL;
/* axis */
+#if GTK_CHECK_VERSION(2,22,0)
+ cr = cairo_create (axis->surface[not_disp]);
+#else
cr = gdk_cairo_create (axis->pixmap[not_disp]);
+#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr, 0, 0.5);
cairo_line_to(cr, axis->s.width + (axis->p.width-axis->s.width)/2.0, 0.5);
/* printf ("%f @ %d\n", i*axis->major + fl, x); */
if (x < 0 || x > axis->s.width)
continue;
+#if GTK_CHECK_VERSION(2,22,0)
+ cr = cairo_create (axis->surface[not_disp]);
+#else
cr = gdk_cairo_create (axis->pixmap[not_disp]);
+#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr, x+0.5, 0);
cairo_line_to(cr, x+0.5, 15);
g_snprintf (desc, sizeof(desc), "%.*f", rdigits, i*axis->major + fl);
layout = gtk_widget_create_pango_layout(g->drawing_area, desc);
pango_layout_get_pixel_size(layout, &w, &h);
+#if GTK_CHECK_VERSION(2,22,0)
+ cr = cairo_create (axis->surface[not_disp]);
+#else
cr = gdk_cairo_create (axis->pixmap[not_disp]);
+#endif
cairo_move_to (cr, x - w/2, 15+4);
pango_cairo_show_layout (cr, layout);
cairo_destroy (cr);
for (i=imin; i <= imax; i++) {
int x = (int) (rint (i * minor_tick) - offset - corr);
if (x > 0 && x < axis->s.width){
+#if GTK_CHECK_VERSION(2,22,0)
+ cr = cairo_create (axis->surface[not_disp]);
+#else
cr = gdk_cairo_create (axis->pixmap[not_disp]);
+#endif
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr, x+0.5, 0);
cairo_line_to(cr, x+0.5, 8);
layout = gtk_widget_create_pango_layout(g->drawing_area,
axis->label[i]);
pango_layout_get_pixel_size(layout, &w, &h);
+#if GTK_CHECK_VERSION(2,22,0)
+ cr = cairo_create (axis->surface[not_disp]);
+#else
cr = gdk_cairo_create (axis->pixmap[not_disp]);
+#endif
cairo_move_to (cr, axis->s.width - w - 50, 15+h+15 + i*(h+3));
pango_cairo_show_layout (cr, layout);
cairo_destroy (cr);
cairo_t *cr;
cr = gdk_cairo_create (gtk_widget_get_window(axis->drawing_area));
+#if GTK_CHECK_VERSION(2,22,0)
+ cairo_set_source_surface (cr, axis->surface[axis->displayed], axis->p.x, axis->p.y);
+#else
gdk_cairo_set_source_pixmap (cr, axis->pixmap[axis->displayed], axis->p.x, axis->p.y);
+#endif
cairo_rectangle (cr, axis->p.x, axis->p.y, axis->p.width, axis->p.height);
cairo_fill (cr);
cairo_destroy (cr);
num = e->parent->num;
}
break;
- case ELMT_ARC:
- if (arc_detect_collision (e, x, y)) {
+ case ELMT_ELLIPSE:
+ if (ellipse_detect_collision (e, x, y)) {
num = e->parent->num;
}
break;
return FALSE;
}
-static int arc_detect_collision (struct element *e, int x, int y)
+static int ellipse_detect_collision (struct element *e, int x, int y)
{
int xx1, yy1, xx2, yy2;
- xx1 = (int )rint (e->p.arc.dim.x);
- xx2 = (int )rint (e->p.arc.dim.x + e->p.arc.dim.width);
- yy1 = (int )rint (e->p.arc.dim.y - e->p.arc.dim.height);
- yy2 = (int )rint (e->p.arc.dim.y);
+ xx1 = (int )rint (e->p.ellipse.dim.x);
+ xx2 = (int )rint (e->p.ellipse.dim.x + e->p.ellipse.dim.width);
+ yy1 = (int )rint (e->p.ellipse.dim.y - e->p.ellipse.dim.height);
+ yy2 = (int )rint (e->p.ellipse.dim.y);
/*
- printf ("arc: (%d,%d)->(%d,%d), clicked: (%d,%d)\n", xx1, yy1, xx2, yy2, x, y);
+ printf ("ellipse: (%d,%d)->(%d,%d), clicked: (%d,%d)\n", xx1, yy1, xx2, yy2, x, y);
*/
if (xx1<=x && x<=xx2 && yy1<=y && y<=yy2)
return TRUE;
static void cross_xor (struct graph *g, int x, int y)
{
-#if 0
+#if GTK_CHECK_VERSION(3,0,0)
GdkColor color_gray15 = {0x0, 0x2626, 0x2626, 0x2626};
cairo_t *cr;
-#endif
+ /* XXX Fix me: lines do not disapere */
if (x > g->wp.x && x < g->wp.x+g->wp.width &&
y >= g->wp.y && y < g->wp.y+g->wp.height) {
- gdk_draw_line (gtk_widget_get_window(g->drawing_area), xor_gc, g->wp.x,
- y, g->wp.x + g->wp.width, y);
- gdk_draw_line (gtk_widget_get_window(g->drawing_area), xor_gc, x,
- g->wp.y, x, g->wp.y + g->wp.height);
-#if 0
/* Draw horisontal line */
cr = gdk_cairo_create (gtk_widget_get_window(g->drawing_area));
cairo_set_operator (cr, CAIRO_OPERATOR_XOR);
- gdk_cairo_set_source_color (cr, &gray15);
+ gdk_cairo_set_source_color (cr, &color_gray15);
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr, g->wp.x, y);
cairo_line_to(cr, g->wp.x + g->wp.width, y);
cairo_stroke(cr);
cairo_destroy(cr);
-#endif
+ /* draw vertical line */
+ cr = gdk_cairo_create (gtk_widget_get_window(g->drawing_area));
+ cairo_set_operator (cr, CAIRO_OPERATOR_XOR);
+ gdk_cairo_set_source_color (cr, &color_gray15);
+ cairo_set_line_width (cr, 1.0);
+ cairo_move_to(cr, x, g->wp.y);
+ cairo_line_to(cr, x, g->wp.y + g->wp.height);
+ cairo_stroke(cr);
+ cairo_destroy(cr);
}
+
+#else
+
+ if (x > g->wp.x && x < g->wp.x+g->wp.width &&
+ y >= g->wp.y && y < g->wp.y+g->wp.height) {
+ gdk_draw_line (gtk_widget_get_window(g->drawing_area), xor_gc, g->wp.x,
+ y, g->wp.x + g->wp.width, y);
+ gdk_draw_line (gtk_widget_get_window(g->drawing_area), xor_gc, x,
+ g->wp.y, x, g->wp.y + g->wp.height);
+ }
+#endif
}
static void cross_draw (struct graph *g, int x, int y)
}
} while (e);
+#if GTK_CHECK_VERSION(2,22,0)
+ mg->surface[0] = mg->surface[1] = NULL;
+#else
mg->pixmap[0] = mg->pixmap[1] = NULL;
+#endif /* GTK_CHECK_VERSION(2,22,0) */
graph_pixmaps_create (mg);
magnify_draw (g);
g->magnify.active = 1;
struct graph *mg = g->magnify.g;
window_destroy (GTK_WIDGET (mg->drawing_area));
+
+#if GTK_CHECK_VERSION(2,22,0)
+ if(mg->surface[0]){
+ cairo_surface_destroy (mg->surface[0]);
+ }
+ if(mg->surface[1]){
+ cairo_surface_destroy (mg->surface[1]);
+ }
+#else
g_object_unref (mg->pixmap[0]);
g_object_unref (mg->pixmap[1]);
+#endif /* GTK_CHECK_VERSION(2,22,0) */
for (list=mg->elists; list; list=list->next)
g_free (list->elements);
graph_pixmap_draw (g->magnify.g);
/* graph pixmap is almost ready, just add border */
+#if GTK_CHECK_VERSION(2,22,0)
+ cr = cairo_create (g->magnify.g->surface[not_disp]);
+#else
cr = gdk_cairo_create (g->magnify.g->pixmap[not_disp]);
+#endif /* GTK_CHECK_VERSION(2,22,0) */
cairo_set_line_width (cr, 1.0);
cairo_move_to(cr, 0, 0);
cairo_line_to(cr, g->magnify.width - 1, 0);
secs = g->zoom.x * (tmp->rel_secs + tmp->rel_usecs / 1000000.0 - xx0);
seqno = g->zoom.y * seq_cur;
- e->type = ELMT_ARC;
+ e->type = ELMT_ELLIPSE;
e->parent = tmp;
- e->gc = g->fg_gc;
- e->p.arc.dim.width = g->s.tseq_stevens.seq_width;
- e->p.arc.dim.height = g->s.tseq_stevens.seq_height;
- e->p.arc.dim.x = secs - g->s.tseq_stevens.seq_width/2.0;
- e->p.arc.dim.y = seqno + g->s.tseq_stevens.seq_height/2.0;
- e->p.arc.filled = TRUE;
- e->p.arc.angle1 = 0;
- e->p.arc.angle2 = 23040;
+ e->p.ellipse.dim.width = g->s.tseq_stevens.seq_width;
+ e->p.ellipse.dim.height = g->s.tseq_stevens.seq_height;
+ e->p.ellipse.dim.x = secs - g->s.tseq_stevens.seq_width/2.0;
+ e->p.ellipse.dim.y = seqno + g->s.tseq_stevens.seq_height/2.0;
e++;
}
e->type = ELMT_NONE;
static void tseq_tcptrace_read_config (struct graph *g)
{
- GdkColormap *colormap;
- GdkColor color;
- GdkColor color_LightSlateGray = {0x0, 0x7777, 0x8888, 0x9999};
- GdkColor color_LightGray = {0x0, 0xd3d3, 0xd3d3, 0xd3d3};
/* Black */
g->s.tseq_tcptrace.seq_color.pixel=0;
g->s.tseq_tcptrace.ack_color[1].blue=0xd3d3;
g->s.tseq_tcptrace.flags = 0;
- g->s.tseq_tcptrace.gc_seq = gdk_gc_new (gtk_widget_get_window(g->drawing_area));
- g->s.tseq_tcptrace.gc_ack[0] = gdk_gc_new (gtk_widget_get_window(g->drawing_area));
- g->s.tseq_tcptrace.gc_ack[1] = gdk_gc_new (gtk_widget_get_window(g->drawing_area));
- colormap = gtk_widget_get_colormap (GTK_WIDGET(g->drawing_area));
- if (!gdk_color_parse ("black", &color)) {
- /*
- * XXX - do more than just warn.
- */
- simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "Could not parse color black.");
- }
- if (!gdk_colormap_alloc_color (colormap, &color, FALSE, TRUE)) {
- /*
- * XXX - do more than just warn.
- */
- simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "Could not allocate color black.");
- }
- gdk_gc_set_foreground (g->s.tseq_tcptrace.gc_seq, &color);
- if (!gdk_color_parse ("LightSlateGray", &color)) {
- /*
- * XXX - do more than just warn.
- */
- simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "Could not parse color LightSlateGray.");
- }
- if (!gdk_colormap_alloc_color (colormap, &color, FALSE, TRUE)) {
- /*
- * XXX - do more than just warn.
- */
- simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "Could not allocate color LightSlateGray.");
- }
- gdk_gc_set_foreground (g->s.tseq_tcptrace.gc_ack[0], &color);
- if (!gdk_color_parse ("LightGray", &color)) {
- /*
- * XXX - do more than just warn.
- */
- simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "Could not parse color LightGray.");
- }
- if (!gdk_colormap_alloc_color (colormap, &color, FALSE, TRUE)) {
- /*
- * XXX - do more than just warn.
- */
- simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "Could not allocate color LightGray.");
- }
- gdk_gc_set_foreground (g->s.tseq_tcptrace.gc_ack[1], &color);
g->elists->next = (struct element_list * )
g_malloc (sizeof (struct element_list));
yy2 = g->zoom.y * (seq_cur + data);
e1->type = ELMT_LINE;
e1->parent = tmp;
- e1->gc = g->s.tseq_tcptrace.gc_seq;
/* Set the drawing color */
e1->elment_color_p = &g->s.tseq_tcptrace.seq_color;
e1->p.line.dim.x1 = e1->p.line.dim.x2 = x;
e1++;
e1->type = ELMT_LINE;
e1->parent = tmp;
- e1->gc = g->s.tseq_tcptrace.gc_seq;
/* Set the drawing color */
e1->elment_color_p = &g->s.tseq_tcptrace.seq_color;
e1->p.line.dim.x1 = x - 1;
e1++;
e1->type = ELMT_LINE;
e1->parent = tmp;
- e1->gc = g->s.tseq_tcptrace.gc_seq;
/* Set the drawing color */
e1->elment_color_p = &g->s.tseq_tcptrace.seq_color;
e1->p.line.dim.x1 = x + 1;
if (ack_seen == TRUE) { /* don't plot the first ack */
e0->type = ELMT_LINE;
e0->parent = tmp;
- e0->gc = g->s.tseq_tcptrace.gc_ack[toggle];
/* Set the drawing color */
e0->elment_color_p = &g->s.tseq_tcptrace.ack_color[toggle];
e0->p.line.dim.x1 = p_t;
e0++;
e0->type = ELMT_LINE;
e0->parent = tmp;
- e0->gc = g->s.tseq_tcptrace.gc_ack[toggle];
/* Set the drawing color */
e0->elment_color_p = &g->s.tseq_tcptrace.ack_color[toggle];
e0->p.line.dim.x1 = x;
/* window line */
e0->type = ELMT_LINE;
e0->parent = tmp;
- e0->gc = g->s.tseq_tcptrace.gc_ack[toggle];
/* Set the drawing color */
e0->elment_color_p = &g->s.tseq_tcptrace.ack_color[toggle];
e0->p.line.dim.x1 = p_t;
e0++;
e0->type = ELMT_LINE;
e0->parent = tmp;
- e0->gc = g->s.tseq_tcptrace.gc_ack[toggle];
/* Set the drawing color */
e0->elment_color_p = &g->s.tseq_tcptrace.ack_color[toggle];
e0->p.line.dim.x1 = x;
tput = sum / dtime;
/* debug(DBS_TPUT_ELMTS) printf ("tput=%f\n", tput); */
- e->type = ELMT_ARC;
+ e->type = ELMT_ELLIPSE;
e->parent = tmp;
- e->gc = g->fg_gc;
- e->p.arc.dim.width = g->s.tput.width;
- e->p.arc.dim.height = g->s.tput.height;
- e->p.arc.dim.x = g->zoom.x*(time_val - g->bounds.x0) - g->s.tput.width/2.0;
- e->p.arc.dim.y = g->zoom.y*tput + g->s.tput.height/2.0;
- e->p.arc.filled = TRUE;
- e->p.arc.angle1 = 0;
- e->p.arc.angle2 = 23040;
+ e->p.ellipse.dim.width = g->s.tput.width;
+ e->p.ellipse.dim.height = g->s.tput.height;
+ e->p.ellipse.dim.x = g->zoom.x*(time_val - g->bounds.x0) - g->s.tput.width/2.0;
+ e->p.ellipse.dim.y = g->zoom.y*tput + g->s.tput.height/2.0;
e++;
}
e->type = ELMT_NONE;
if (ackno > u->seqno) {
double rtt = time_val - u->time;
- e->type = ELMT_ARC;
+ e->type = ELMT_ELLIPSE;
e->parent = tmp;
- e->gc = g->fg_gc;
- e->p.arc.dim.width = g->s.rtt.width;
- e->p.arc.dim.height = g->s.rtt.height;
- e->p.arc.dim.x = g->zoom.x * u->seqno - g->s.rtt.width/2.0;
- e->p.arc.dim.y = g->zoom.y * rtt + g->s.rtt.height/2.0;
- e->p.arc.filled = TRUE;
- e->p.arc.angle1 = 0;
- e->p.arc.angle2 = 23040;
+ e->p.ellipse.dim.width = g->s.rtt.width;
+ e->p.ellipse.dim.height = g->s.rtt.height;
+ e->p.ellipse.dim.x = g->zoom.x * u->seqno - g->s.rtt.width/2.0;
+ e->p.ellipse.dim.y = g->zoom.y * rtt + g->s.rtt.height/2.0;
e++;
v=u->next;
/* only data or ack segments */
if ( (flags & (TH_SYN|TH_RST)) == 0 )
{
- e->type = ELMT_ARC;
+ e->type = ELMT_ELLIPSE;
e->parent = segm;
- e->gc = g->fg_gc;
- e->p.arc.dim.width = g->s.wscale.win_width;
- e->p.arc.dim.height = g->s.wscale.win_height;
- e->p.arc.dim.x = g->zoom.x * (sec - sec_base) - g->s.wscale.win_width / 2.0;
- e->p.arc.dim.y = g->zoom.y * wsize - g->s.wscale.win_height / 2.0;
- e->p.arc.filled = TRUE;
- e->p.arc.angle1 = 0;
- e->p.arc.angle2 = 0x5A00;
+ e->p.ellipse.dim.width = g->s.wscale.win_width;
+ e->p.ellipse.dim.height = g->s.wscale.win_height;
+ e->p.ellipse.dim.x = g->zoom.x * (sec - sec_base) - g->s.wscale.win_width / 2.0;
+ e->p.ellipse.dim.y = g->zoom.y * wsize - g->s.wscale.win_height / 2.0;
e++;
}
}