Add config.h support : will fix the LARGEFILE problem
[lttv.git] / ltt / branches / poly / lttv / modules / gui / controlflow / drawing.c
index b31549d713946a4bbda1511d0836465d797a4567..b4411bc422b1eb15bcfe14a5ef264bf3e01f3532 100644 (file)
  * MA 02111-1307, USA.
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <gtk/gtk.h>
 #include <gdk/gdk.h>
 #include <string.h>
@@ -68,8 +72,8 @@ GdkColor drawing_colors[NUM_COLORS] =
   { 0, 0x0000, 0xFF00, 0x0000 }, /* COL_RUN_USER_MODE : green */
   { 0, 0x0100, 0x9E00, 0xFFFF }, /* COL_RUN_SYSCALL : pale blue */
   { 0, 0xFF00, 0xFF00, 0x0100 }, /* COL_RUN_TRAP : yellow */
-  { 0, 0xFFFF, 0x0000, 0x0000 }, /* COL_RUN_IRQ : red */
-  { 0, 0xA3FF, 0x0000, 0x0000 }, /* COL_WAIT : dark red */
+  { 0, 0xFFFF, 0x5E00, 0x0000 }, /* COL_RUN_IRQ : red */
+  { 0, 0x6600, 0x0000, 0x0000 }, /* COL_WAIT : dark red */
   { 0, 0x7700, 0x7700, 0x0000 }, /* COL_WAIT_CPU : dark yellow */
   { 0, 0x6400, 0x0000, 0x5D00 }, /* COL_ZOMBIE : dark purple */
   { 0, 0x0700, 0x6400, 0x0000 }, /* COL_WAIT_FORK : dark green */
@@ -111,7 +115,6 @@ motion_notify_ruler(GtkWidget *widget, GdkEventMotion *event, gpointer user_data
  * erase drawing already present (SAFETY).
  */
 void drawing_data_request(Drawing_t *drawing,
-      GdkPixmap **pixmap,
       gint x, gint y,
       gint width,
       gint height)
@@ -466,9 +469,10 @@ void drawing_request_expose(EventsRequest *events_request,
 
   drawing->damage_begin = x+width;
 
+  // FIXME ?
   gtk_widget_queue_draw_area ( drawing->drawing_area,
                                x, 0,
-                               width, drawing->height);
+                               width, drawing->drawing_area->allocation.height);
  
 }
 
@@ -512,15 +516,17 @@ configure_event( GtkWidget *widget, GdkEventConfigure *event,
     drawing->width = widget->allocation.width;
     
     if(drawing->alloc_width < widget->allocation.width) {
-      if(drawing->pixmap)
-        gdk_pixmap_unref(drawing->pixmap);
+      //if(drawing->pixmap)
+      //  gdk_pixmap_unref(drawing->pixmap);
 
-      drawing->pixmap = gdk_pixmap_new(widget->window,
-                                       drawing->width + SAFETY + EXTRA_ALLOC,
-                                       drawing->height + EXTRA_ALLOC,
-                                       -1);
+      //drawing->pixmap = gdk_pixmap_new(widget->window,
+      //                                 drawing->width + SAFETY + EXTRA_ALLOC,
+      //                                 drawing->height + EXTRA_ALLOC,
+      //                                 -1);
       drawing->alloc_width = drawing->width + SAFETY + EXTRA_ALLOC;
       drawing->alloc_height = drawing->height + EXTRA_ALLOC;
+      update_pixmap_size(drawing->control_flow_data->process_list,
+                         drawing->alloc_width);
     }
     //drawing->height = widget->allocation.height;
 
@@ -529,12 +535,12 @@ configure_event( GtkWidget *widget, GdkEventConfigure *event,
     
 
     // Clear the image
-    gdk_draw_rectangle (drawing->pixmap,
-          widget->style->black_gc,
-          TRUE,
-          0, 0,
-          drawing->width+SAFETY,
-          drawing->height);
+    //gdk_draw_rectangle (drawing->pixmap,
+    //      widget->style->black_gc,
+    //      TRUE,
+    //      0, 0,
+    //      drawing->width+SAFETY,
+    //      drawing->height);
 
     //g_info("init data request");
 
@@ -553,10 +559,20 @@ configure_event( GtkWidget *widget, GdkEventConfigure *event,
     drawing->damage_begin = 0;
     drawing->damage_end = widget->allocation.width;
 
-    if(drawing->damage_begin < drawing->damage_end)
+    if((widget->allocation.width != 1 &&
+        widget->allocation.height != 1)
+        && drawing->damage_begin < drawing->damage_end)
     {
+
+      rectangle_pixmap (drawing->control_flow_data->process_list,
+        drawing->drawing_area->style->black_gc,
+        TRUE,
+        0, 0,
+        drawing->alloc_width, // do not overlap
+        -1);
+
+
       drawing_data_request(drawing,
-                           &drawing->pixmap,
                            drawing->damage_begin,
                            0,
                            drawing->damage_end - drawing->damage_begin,
@@ -592,13 +608,32 @@ expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
   LttTime window_end = time_window.end_time;
 
   /* update the screen from the pixmap buffer */
+#if 0
   gdk_draw_pixmap(widget->window,
       widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
       drawing->pixmap,
       event->area.x, event->area.y,
       event->area.x, event->area.y,
       event->area.width, event->area.height);
+#endif //0
+  drawing->height = processlist_get_height(control_flow_data->process_list);
+  copy_pixmap_to_screen(control_flow_data->process_list,
+                        widget->window,
+                        widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
+                        event->area.x, event->area.y,
+                        event->area.width, event->area.height);
+                        
   
+  /* Erase the dotted lines left.. */
+  if(widget->allocation.height > drawing->height)
+  {
+    gdk_draw_rectangle (widget->window,
+      drawing->drawing_area->style->black_gc,
+      TRUE,
+      event->area.x, drawing->height,
+      event->area.width,  // do not overlap
+      widget->allocation.height - drawing->height);
+  }
   if(ltt_time_compare(time_window.start_time, current_time) <= 0 &&
            ltt_time_compare(window_end, current_time) >= 0)
   {
@@ -626,11 +661,11 @@ expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
                         dash_list,
                         2);
     }
-
-    drawing_draw_line(NULL, widget->window,
+    gint height_tot = MAX(widget->allocation.height, drawing->height);
+    gdk_draw_line(widget->window,
+                  drawing->dotted_gc,
                   cursor_x, 0,
-                  cursor_x, drawing->height,
-                  drawing->dotted_gc);
+                  cursor_x, height_tot);
   }
   return FALSE;
 }
@@ -813,7 +848,7 @@ Drawing_t *drawing_construct(ControlFlowData *control_flow_data)
   //    drawing->height,
   //    drawing->depth);
   
-  drawing->pixmap = NULL;
+  //drawing->pixmap = NULL;
 
 //  drawing->pixmap = gdk_pixmap_new(drawing->drawing_area->window,
 //        drawing->drawing_area->allocation.width,
@@ -896,7 +931,7 @@ void drawing_destroy(Drawing_t *drawing)
     gdk_gc_unref(drawing->gc);
   
   g_free(drawing->pango_layout);
-  if(!drawing->dotted_gc) gdk_gc_unref(drawing->dotted_gc);
+  if(drawing->dotted_gc != NULL) gdk_gc_unref(drawing->dotted_gc);
   g_free(drawing);
   g_info("drawing_destroy end");
 }
@@ -924,30 +959,37 @@ void drawing_draw_line( Drawing_t *drawing,
 
 void drawing_clear(Drawing_t *drawing)
 { 
-  if (drawing->pixmap)
-    gdk_pixmap_unref(drawing->pixmap);
+  //if (drawing->pixmap)
+  //  gdk_pixmap_unref(drawing->pixmap);
+  ControlFlowData *cfd = drawing->control_flow_data;
 
-  drawing->height = 1;
+  
+  rectangle_pixmap(cfd->process_list,
+      drawing->drawing_area->style->black_gc,
+      TRUE,
+      0, 0,
+      drawing->alloc_width,  // do not overlap
+      -1);
+  
+  //drawing->height = 1;
   /* Allocate a new pixmap with new height */
-  drawing->pixmap = gdk_pixmap_new(drawing->drawing_area->window,
-                                   drawing->width + SAFETY + EXTRA_ALLOC,
-                                   drawing->height + EXTRA_ALLOC,
-                                     -1);
-  drawing->alloc_width = drawing->width + SAFETY + EXTRA_ALLOC;
-  drawing->alloc_height = drawing->height + EXTRA_ALLOC;
-
-  gtk_widget_set_size_request(drawing->drawing_area,
-                             -1,
-                             drawing->height);
-  gtk_widget_queue_resize_no_redraw(drawing->drawing_area);
+  //drawing->pixmap = gdk_pixmap_new(drawing->drawing_area->window,
+  //                                 drawing->width + SAFETY + EXTRA_ALLOC,
+  //                                 drawing->height + EXTRA_ALLOC,
+  //                                   -1);
+  //drawing->alloc_width = drawing->width + SAFETY + EXTRA_ALLOC;
+  //drawing->alloc_height = drawing->height + EXTRA_ALLOC;
+
+  //gtk_widget_set_size_request(drawing->drawing_area,
+  //                           -1,
+  //                           drawing->height);
+  //gtk_widget_queue_resize_no_redraw(drawing->drawing_area);
   
   /* ask for the buffer to be redrawn */
-  gtk_widget_queue_draw_area ( drawing->drawing_area,
-                               0, 0,
-                               drawing->width, drawing->height);
+  gtk_widget_queue_draw ( drawing->drawing_area);
 }
 
-
+#if 0
 /* Insert a square corresponding to a new process in the list */
 /* Applies to whole drawing->width */
 void drawing_insert_square(Drawing_t *drawing,
@@ -970,7 +1012,7 @@ void drawing_insert_square(Drawing_t *drawing,
     reallocate = TRUE;
 
     /* Copy the high region */
-    gdk_draw_drawable (new_pixmap,
+    gdk_draw_pixmap (new_pixmap,
       drawing->drawing_area->style->black_gc,
       drawing->pixmap,
       0, 0,
@@ -995,7 +1037,7 @@ void drawing_insert_square(Drawing_t *drawing,
     height);
 
   /* copy the bottom of the region */
-  gdk_draw_drawable (new_pixmap,
+  gdk_draw_pixmap (new_pixmap,
     drawing->drawing_area->style->black_gc,
     drawing->pixmap,
     0, y,
@@ -1049,7 +1091,7 @@ void drawing_remove_square(Drawing_t *drawing,
     pixmap = drawing->pixmap;
    
     /* Copy the high region */
-    gdk_draw_drawable (pixmap,
+    gdk_draw_pixmap (pixmap,
       drawing->drawing_area->style->black_gc,
       drawing->pixmap,
       0, 0,
@@ -1057,7 +1099,7 @@ void drawing_remove_square(Drawing_t *drawing,
       drawing->width + SAFETY, y);
 
     /* Copy up the bottom of the region */
-    gdk_draw_drawable (pixmap,
+    gdk_draw_pixmap (pixmap,
       drawing->drawing_area->style->black_gc,
       drawing->pixmap,
       0, y + height,
@@ -1081,6 +1123,7 @@ void drawing_remove_square(Drawing_t *drawing,
                                0, y,
                                drawing->width, MAX(drawing->height-y, 1));
 }
+#endif //0
 
 void drawing_update_ruler(Drawing_t *drawing, TimeWindow *time_window)
 {
This page took 0.027508 seconds and 4 git commands to generate.