struct _ControlFlowData {
- GtkWidget *Drawing_Area_V;
GtkWidget *Scrolled_Window_VC;
ProcessList *Process_List;
ControlFlowData *
GuiControlFlow(void)
{
- GtkWidget *Process_List_Widget;
+ GtkWidget *Process_List_Widget, *Drawing_Widget;
ControlFlowData* Control_Flow_Data = g_new(ControlFlowData,1) ;
/* Create the Drawing */
- //Control_Flow_Data->Drawing = Drawing();
+ Control_Flow_Data->Drawing = Drawing_construct();
+
+ Drawing_Widget =
+ Drawing_getWidget(Control_Flow_Data->Drawing);
/* TEST DATA, TO BE READ FROM THE TRACE */
Control_Flow_Data->Number_Of_Events = 1000 ;
gtk_box_pack_start(
GTK_BOX(Control_Flow_Data->Inside_HBox_V),
- Process_List_Widget, TRUE, TRUE, 0); // FALSE TRUE
- //gtk_box_pack_start(
- // GTK_BOX(Control_Flow_Data->Inside_HBox_V),
- // Control_Flow_Data->Drawing_Area_V, TRUE, TRUE, 0);
+ Process_List_Widget, FALSE, TRUE, 0); // FALSE TRUE
+ gtk_box_pack_start(
+ GTK_BOX(Control_Flow_Data->Inside_HBox_V),
+ Drawing_Widget, TRUE, TRUE, 0);
Control_Flow_Data->VAdjust_C =
//Control_Flow_Data->Trace_Statistics = get_trace_statistics(Trace);
- //gtk_widget_show(Control_Flow_Data->Drawing_Area_V);
+ gtk_widget_show(Drawing_Widget);
gtk_widget_show(Process_List_Widget);
gtk_widget_show(Control_Flow_Data->Inside_HBox_V);
gtk_widget_show(Control_Flow_Data->Scrolled_Window_VC);
#include "Drawing.h"
+#include <gtk/gtk.h>
+#include <gdk/gdk.h>
/*****************************************************************************
* Drawing functions *
};
-typedef struct _Drawing_t {
- GtkWidget *Drawing_Area_V
+struct _Drawing_t {
+ GtkWidget *Drawing_Area_V;
+ GdkPixmap *Pixmap;
- guint height, width;
+ gint height, width, depth;
-} Drawing_t;
+};
-Drawing_t *Drawing(void)
+Drawing_t *Drawing_construct(void)
{
- Drawing_t Drawing = g_new(Drawing_t, 1);
+ Drawing_t *Drawing = g_new(Drawing_t, 1);
Drawing->Drawing_Area_V = gtk_drawing_area_new ();
g_object_set_data_full(
G_OBJECT(Drawing->Drawing_Area_V),
- "Drawing_Data",
+ "Link_Drawing_Data",
Drawing,
(GDestroyNotify)Drawing_destroy);
- gtk_widget_modify_bg( Control_Flow_Data->Drawing_Area_V,
+ gtk_widget_modify_bg( Drawing->Drawing_Area_V,
GTK_STATE_NORMAL,
&CF_Colors[BLACK]);
-
+ gdk_window_get_geometry(Drawing->Drawing_Area_V->window,
+ NULL, NULL,
+ &(Drawing->width),
+ &(Drawing->height),
+ &(Drawing->depth));
+
+ Drawing->Pixmap = gdk_pixmap_new(
+ Drawing->Drawing_Area_V->window,
+ Drawing->width,
+ Drawing->height,
+ Drawing->depth);
+
return Drawing;
}
void Drawing_destroy(Drawing_t *Drawing)
{
- g_object_unref( G_OBJECT(Drawing->Drawing_Area_V));
+ // Do not unref here, Drawing_t destroyed by it's widget.
+ //g_object_unref( G_OBJECT(Drawing->Drawing_Area_V));
g_free(Drawing);
}
+GtkWidget *Drawing_getWidget(Drawing_t *Drawing)
+{
+ return Drawing->Drawing_Area_V;
+}
+
/* get_time_from_pixels
*
* Get the time interval from window time and pixels, and pixels requested. This
guint x,
LttTime *window_time_begin,
LttTime *window_time_end,
- LttTime *time,
- );
+ LttTime *time)
{
LttTime window_time_interval;
- TimeSub(window_time_interval, *window_time_end, window_time_begin);
+ TimeSub(window_time_interval, *window_time_end, *window_time_begin);
TimeMul(*time, window_time_interval,
(x/(float)Drawing->width));
- TimeAdd(*time, window_time_begin, *time);
+ TimeAdd(*time, *window_time_begin, *time);
}
LttTime window_time_end,
LttTime time,
Drawing_t *Drawing,
- guint *x,
- )
+ guint *x)
{
LttTime window_time_interval;
+ float interval_float, time_float;
TimeSub(window_time_interval, window_time_end, window_time_begin);
- TimeSub(time, time, wimdow_time_begin);
+ TimeSub(time, time, window_time_begin);
- *x = (guint)((time/(float)window_time_interval) * Drawing->width);
+ interval_float = (window_time_interval.tv_sec * NANSECOND_CONST)
+ + window_time_interval.tv_nsec;
+ time_float = (time.tv_sec * NANSECOND_CONST)
+ + time.tv_nsec;
+
+ *x = (guint)(time_float/interval_float * Drawing->width);
}
-void Drawing_Resize(Drawing_t *Drawing, guint h, guint, w)
+void Drawing_Resize(Drawing_t *Drawing, guint h, guint w)
{
- guint w;
-
Drawing->height = h ;
- Drawing->weight = w ;
+ Drawing->width = w ;
- gtk_widget_set_size_request ( Control_Flow_Data->Drawing_Area_V,
- Drawing->weight,
+ gtk_widget_set_size_request ( Drawing->Drawing_Area_V,
+ Drawing->width,
Drawing->height);
}
-
-
-
#define _DRAWING_H
#include <glib.h>
+#include <gdk/gdk.h>
+#include <gtk/gtk.h>
#include <ltt/ltt.h>
/* This part of the viewer does :
- * Draw horizontal lines, getting line color and width as arguments.
+ * Draw horizontal lines, getting graphic context as arg.
* Copy region of the screen into another.
- * Modify the boundaries to reflect a scale change.
+ * Modify the boundaries to reflect a scale change. (resize)
*
* A helper function is provided here to convert from time and process
* identifier to pixels and the contrary (will be useful for mouse selection).
typedef struct _Drawing_t Drawing_t;
-Drawing_t *Drawing(void);
+Drawing_t *Drawing_construct(void);
void Drawing_destroy(Drawing_t *Drawing);
-void Drawing_Resize(Drawing_t *Drawing, guint h, guint w);
+GtkWidget *Drawing_getWidget(Drawing_t *Drawing);
+
+
+void Drawing_draw_line( guint x1, guint y1, guint x2, guint y2,
+ GdkGC *GC);
+
+void Drawing_copy(guint xsrc, guint ysrc,
+ guint xdest, guint ydest,
+ guint width, guint height);
+void Drawing_Resize(Drawing_t *Drawing, guint h, guint w);
+
void convert_pixels_to_time(
Drawing_t *Drawing,
guint x,
Drawing_t *Drawing,
guint *x);
-
#endif // _DRAWING_H