1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| gboolean
cb_graph (gpointer data)
{
GtkWidget *drawingArea = (GtkWidget*) data ;
GdkDrawable *drawable1 ;
GdkColormap *colormap ;
GdkColor graph_color ;
static gboolean firstFrame = TRUE ;
static GdkPixbuf *pixbuf1 ;
static int plottingValue = 25 ; //TODO
int width ;
int height ;
width = drawingArea->allocation.width ;
height = drawingArea->allocation.height ;
drawable1 = drawingArea->window ;
//color around blue //TO BE ADDED TO THE COLORMAP
graph_color.red = 15872 ;
graph_color.green = 40056 ;
graph_color.blue = 49152 ;
if(GTK_WIDGET_DRAWABLE(drawingArea))
{
if (!firstFrame) //if not the first frame, draw the previous pixbuf in the drawable
{
gdk_draw_pixbuf ( drawable1,
drawingArea->style->fg_gc[GTK_WIDGET_STATE (drawingArea)],
pixbuf1,
0,0,
0,0,
-1,-1,
GDK_RGB_DITHER_NORMAL,
0,0) ;
g_object_unref (pixbuf1);
}
gdk_draw_rectangle (drawingArea->window,
drawingArea->style->fg_gc[GTK_WIDGET_STATE (drawingArea)],
TRUE,
width - KAMON_GRAPH_THICKNESS -1,
height -KAMON_GRAPH_THICKNESS -1 - plottingValue,
2*KAMON_GRAPH_THICKNESS+1,
2*KAMON_GRAPH_THICKNESS+1);
/* we copy the drawable into pixbuf but with width -1 pixel*/
pixbuf1 = gdk_pixbuf_get_from_drawable(NULL, drawable1, gdk_drawable_get_colormap (drawable1),
KAMON_GRAPH_THICKNESS,0,
0,0,
width,
height );
firstFrame = FALSE ;
}
else
{
firstFrame = TRUE ;
}
return TRUE ;
} |