X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Fmodules%2FguiControlFlow%2FDrawing.c;h=2f1312aad21c1fa7de4fa044ac8e24f5417ba94b;hb=1ab3d149f8c0f55b1f913df39b1f5e49b8f569b9;hp=8224030669a0f2a69cd8394bdc39a68576d0f85e;hpb=847b479de75182dfd3f90e4faeefa48c099713ad;p=lttv.git diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c b/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c index 82240306..2f1312aa 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c @@ -3,10 +3,13 @@ #include #include +#include + /***************************************************************************** * Drawing functions * *****************************************************************************/ +//FIXME Colors will need to be dynamic. Graphic context part not done so far. typedef enum { RED, @@ -36,42 +39,18 @@ struct _Drawing_t { }; -void test_draw(Drawing_t *Drawing) -{ - GdkRectangle update_rect; -// GdkColor color = { 0, 65535, 65535, 65535 }; - -// gdk_colormap_alloc_color(gdk_rgb_get_cmap(), &color, 0, 1); - -// GdkGC *gc = -// Drawing->Drawing_Area_V-> -// style->fg_gc[GTK_WIDGET_STATE (Drawing->Drawing_Area_V)]; -// gdk_gc_set_foreground(gc, &color); - update_rect.x = 50; - update_rect.y = 50; - update_rect.width = 1000; - update_rect.height = 1000; - gdk_draw_rectangle (Drawing->Pixmap, - Drawing->Drawing_Area_V->style->black_gc, - TRUE, - 50, 50, - 1000, - 1000); - - - //Drawing_draw_line(Drawing, 10, 10, 50, 10, - // Drawing->Drawing_Area_V->style->black_gc); - gtk_widget_draw (Drawing->Drawing_Area_V, &update_rect); - -// Drawing_Refresh( Drawing, 0, 0, 30, 30); -} - +/* Function responsible for updating the exposed area. + * It must call processTrace() to ask for this update. + */ void Drawing_Data_Request(Drawing_t *Drawing, GdkPixmap *Pixmap, gint x, gint y, gint width, gint height) { + if(width < 0) return ; + if(height < 0) return ; + gdk_draw_rectangle (Pixmap, Drawing->Drawing_Area_V->style->white_gc, TRUE, @@ -82,6 +61,7 @@ void Drawing_Data_Request(Drawing_t *Drawing, Drawing_draw_line(Drawing, Pixmap, 10, 10, 50, 10, Drawing->Drawing_Area_V->style->black_gc); + } /* Callbacks */ @@ -342,3 +322,112 @@ void Drawing_Resize(Drawing_t *Drawing, guint h, guint w) } +/* Insert a square corresponding to a new process in the list */ +/* Applies to whole Drawing->width */ +void Drawing_Insert_Square(Drawing_t *Drawing, + guint y, + guint height) +{ + GdkRectangle update_rect; + + /* Allocate a new pixmap with new height */ + GdkPixmap *Pixmap = gdk_pixmap_new(Drawing->Drawing_Area_V->window, + Drawing->width, + Drawing->height + height, + -1); + + /* Copy the high region */ + gdk_draw_drawable (Pixmap, + Drawing->Drawing_Area_V->style->black_gc, + Drawing->Pixmap, + 0, 0, + 0, 0, + Drawing->width, y); + + + + + /* add an empty square */ + gdk_draw_rectangle (Pixmap, + Drawing->Drawing_Area_V->style->black_gc, + TRUE, + 0, y, + Drawing->width, // do not overlap + height); + + + + /* copy the bottom of the region */ + gdk_draw_drawable (Pixmap, + Drawing->Drawing_Area_V->style->black_gc, + Drawing->Pixmap, + 0, y, + 0, y + height, + Drawing->width, Drawing->height - y); + + + + + if (Drawing->Pixmap) + gdk_pixmap_unref(Drawing->Pixmap); + + Drawing->Pixmap = Pixmap; + + Drawing->height+=height; + + /* Rectangle to update, from new Drawing dimensions */ + update_rect.x = 0 ; + update_rect.y = y ; + update_rect.width = Drawing->width; + update_rect.height = Drawing->height - y ; + gtk_widget_draw( Drawing->Drawing_Area_V, &update_rect); +} + + +/* Remove a square corresponding to a removed process in the list */ +void Drawing_Remove_Square(Drawing_t *Drawing, + guint y, + guint height) +{ + GdkRectangle update_rect; + + /* Allocate a new pixmap with new height */ + GdkPixmap *Pixmap = gdk_pixmap_new( + Drawing->Drawing_Area_V->window, + Drawing->width, + Drawing->height - height, + -1); + + /* Copy the high region */ + gdk_draw_drawable (Pixmap, + Drawing->Drawing_Area_V->style->black_gc, + Drawing->Pixmap, + 0, 0, + 0, 0, + Drawing->width, y); + + + + /* Copy up the bottom of the region */ + gdk_draw_drawable (Pixmap, + Drawing->Drawing_Area_V->style->black_gc, + Drawing->Pixmap, + 0, y + height, + 0, y, + Drawing->width, Drawing->height - y - height); + + + if (Drawing->Pixmap) + gdk_pixmap_unref(Drawing->Pixmap); + + Drawing->Pixmap = Pixmap; + + Drawing->height-=height; + + /* Rectangle to update, from new Drawing dimensions */ + update_rect.x = 0 ; + update_rect.y = y ; + update_rect.width = Drawing->width; + update_rect.height = Drawing->height - y ; + gtk_widget_draw( Drawing->Drawing_Area_V, &update_rect); +}