3 static void destroy_cb( GtkWidget
*widget
,
11 int main(int argc
, char **argv
)
16 GtkWidget
*HScroll_VC
;
17 ControlFlowData
*control_flow_data
;
19 /* Horizontal scrollbar and it's adjustment */
20 GtkWidget
*VScroll_VC
;
21 GtkAdjustment
*v_adjust
;
23 /* Initialize i18n support */
26 /* Initialize the widget set */
27 gtk_init (&argc
, &argv
);
31 Window
= gtk_window_new (GTK_WINDOW_TOPLEVEL
);
32 gtk_window_set_title (GTK_WINDOW (Window
), ("Test Window"));
34 g_signal_connect (G_OBJECT (Window
), "destroy",
35 G_CALLBACK (destroy_cb
), NULL
);
38 VBox_V
= gtk_vbox_new(0, 0);
39 gtk_container_add (GTK_CONTAINER (Window
), VBox_V
);
41 //ListViewer = hGuiEvents(Window);
42 //gtk_box_pack_start(GTK_BOX(VBox_V), ListViewer, TRUE, TRUE, 0);
44 //ListViewer = hGuiEvents(Window);
45 //gtk_box_pack_start(GTK_BOX(VBox_V), ListViewer, FALSE, TRUE, 0);
47 control_flow_data
= guicontrolflow();
48 CF_Viewer
= control_flow_data
->scrolled_window
;
49 gtk_box_pack_start(GTK_BOX(VBox_V
), CF_Viewer
, TRUE
, TRUE
, 0);
51 /* Create horizontal scrollbar and pack it */
52 HScroll_VC
= gtk_hscrollbar_new(NULL
);
53 gtk_box_pack_start(GTK_BOX(VBox_V
), HScroll_VC
, FALSE
, TRUE
, 0);
56 gtk_widget_show (HScroll_VC
);
57 gtk_widget_show (VBox_V
);
58 gtk_widget_show (Window
);
60 //Event_Selected_Hook(control_flow_data, &ev_sel);
64 g_critical("main loop finished");
66 //h_guievents_destructor(ListViewer);
68 //g_critical("GuiEvents Destructor finished");
76 void add_test_process(ControlFlowData
*control_flow_data
)
80 gchar
*process
[] = { "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" };
82 for(i
=0; i
<control_flow_data
->number_of_process
; i
++)
84 /* Add a new row to the model */
85 gtk_list_store_append (control_flow_data
->list_store
, &iter
);
86 gtk_list_store_set ( control_flow_data
->list_store
, &iter
,
87 PROCESS_COLUMN
, process
[i
],
98 void test_draw(ControlFlowData
*control_flow_data
)
100 /* Draw event states using available height, Number of process, cell height
101 * (don't forget to remove two pixels at beginning and end).
102 * For horizontal : use width, Time_Begin, Time_End.
103 * This function calls the reading library to get the draw_hook called
104 * for the desired period of time. */
106 drawingAreaInfo
*drawing_Area_Info
= &control_flow_data
->drawing_Area_Info
;
113 gint cell_height
= get_cell_height(GTK_TREE_VIEW(control_flow_data
->process_list_widget
));
114 GdkGC
*GC
= gdk_gc_new(widget
->window
);
115 GdkColor color
= CF_Colors
[GREEN
];
117 gdk_color_alloc (gdk_colormap_get_system () , &color
);
119 g_critical("expose");
121 /* When redrawing, use widget->allocation.width to get the width of
123 control_flow_data
->drawing_Area_Info
.width
= widget
->allocation
.width
;
125 test_draw(control_flow_data
);
127 gdk_gc_copy(GC
,widget
->style
->white_gc
);
128 gdk_gc_set_foreground(GC
,&color
);
130 //gdk_draw_arc (widget->window,
131 // widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
133 // //0, 0, widget->allocation.width, widget->allocation.height,
134 // 0, 0, widget->allocation.width,
135 // control_flow_data->drawing_Area_Info.height,
139 //drawing_Area_Init(control_flow_data);
141 // 2 pixels for the box around the drawing area, 1 pixel for off-by-one
143 //gdk_gc_copy (&GC, widget->style->fg_gc[GTK_WIDGET_STATE (widget)]);
145 gdk_gc_set_line_attributes(GC
,12, GDK_LINE_SOLID
, GDK_CAP_NOT_LAST
,GDK_JOIN_MITER
);
147 gdk_draw_line (widget
->window
,
149 0, (cell_height
-1)/2,
150 widget
->allocation
.width
, (cell_height
-1)/2);
152 color
= CF_Colors
[BLUE
];
154 gdk_color_alloc (gdk_colormap_get_system () , &color
);
156 gdk_gc_set_foreground(GC
,&color
);
159 gdk_gc_set_line_attributes(GC
,3, GDK_LINE_SOLID
, GDK_CAP_NOT_LAST
,GDK_JOIN_MITER
);
161 gdk_draw_line (widget
->window
,
163 0, (cell_height
-1)/2,
164 widget
->allocation
.width
,(cell_height
-1)/2);
173 //gdk_colormap_alloc_colors(gdk_colormap_get_system(), TRUE,
175 //gdk_gc_set_line_attributes(GC,5, GDK_LINE_SOLID, GDK_CAP_NOT_LAST,GDK_JOIN_MITER);
176 //gdk_gc_set_foreground(GC,
178 //gdk_draw_line (widget->window,
180 // 0, (2*cell_height)-2-1,
181 // 50, (2*cell_height)-2-1);
187 /* Event_Hook.c tests */
189 void test_draw_item(Drawing_t
*drawing
,
192 PropertiesIcon properties_icon
;
193 DrawContext draw_context
;
195 DrawInfo current
, previous
;
196 ItemInfo over
, middle
, under
, modify_over
, modify_middle
, modify_under
;
200 //for(i=0; i<1024;i=i+15)
202 // for(j=0;j<768;j=j+15)
207 current
.modify_over
= &over
;
209 draw_context
.drawable
= pixmap
;
210 draw_context
.gc
= drawing
->drawing_area
->style
->black_gc
;
212 draw_context
.current
= ¤t
;
213 draw_context
.previous
= NULL
;
215 properties_icon
.icon_name
= g_new(char, MAX_PATH_LEN
);
216 strncpy(properties_icon
.icon_name
,
217 "/home/compudj/local/share/LinuxTraceToolkit/pixmaps/mini-display.xpm",
219 properties_icon
.width
= -1;
220 properties_icon
.height
= -1;
221 properties_icon
.position
= OVER
;
222 draw_icon(&properties_icon
, &draw_context
);
223 g_free(properties_icon
.icon_name
);
230 /* NOTE : no drawing data should be sent there, since the drawing widget
231 * has not been initialized */
232 void send_test_drawing(ProcessList
*process_list
,
235 gint x
, gint y
, // y not used here?
237 gint height
) // height won't be used here ?
240 ProcessInfo Process_Info
= {10000, 12000, 55600};
241 //ProcessInfo Process_Info = {156, 14000, 55500};
242 GtkTreeRowReference
*row_ref
;
243 PangoContext
*context
;
245 PangoFontDescription
*FontDesc
;// = pango_font_description_new();
249 //GdkBitmap *mask = g_new(GdkBitmap, 1);
250 //GdkPixmap *icon_pixmap = g_new(GdkPixmap, 1);
253 GdkColor color
= { 0, 0xffff, 0x0000, 0x0000 };
255 gc
= gdk_gc_new(pixmap
);
257 layout
= gtk_widget_create_pango_layout(drawing
->drawing_area
,
259 context
= pango_layout_get_context(layout
);
260 FontDesc
= pango_context_get_font_description(context
);
261 Font_Size
= pango_font_description_get_size(FontDesc
);
262 pango_font_description_set_size(FontDesc
, Font_Size
-3*PANGO_SCALE
);
268 birth
.tv_sec
= 12000;
269 birth
.tv_nsec
= 55500;
270 g_info("we have : x : %u, y : %u, width : %u, height : %u", x
, y
, width
, height
);
271 processlist_get_process_pixels(process_list
,
277 g_info("we draw : x : %u, y : %u, width : %u, height : %u", x
, y
, width
, height
);
280 y
+(height
/2), x
+ width
, y
+(height
/2),
281 drawing
->drawing_area
->style
->black_gc
);
283 pango_layout_set_text(layout
, "Test", -1);
284 gdk_draw_layout(pixmap
, drawing
->drawing_area
->style
->black_gc
,
285 0, y
+height
, layout
);
287 birth
.tv_sec
= 14000;
288 birth
.tv_nsec
= 55500;
290 processlist_get_process_pixels(process_list
,
299 y
+(height
/2), x
+ width
, y
+(height
/2),
300 drawing
->drawing_area
->style
->black_gc
);
302 g_info("y : %u, height : %u", y
, height
);
306 birth
.tv_sec
= 12000;
307 birth
.tv_nsec
= 55700;
309 processlist_get_process_pixels(process_list
,
315 /* Draw rectangle (background color) */
316 gdk_gc_copy(gc
, drawing
->drawing_area
->style
->black_gc
);
317 gdk_gc_set_rgb_fg_color(gc
, &color
);
318 gdk_draw_rectangle(pixmap
, gc
,
320 x
, y
, width
, height
);
324 y
+(height
/2), x
+ width
, y
+(height
/2),
325 drawing
->drawing_area
->style
->black_gc
);
329 gdk_draw_arc(pixmap
, drawing
->drawing_area
->style
->black_gc
,
330 TRUE
, 100, y
, height
/2, height
/2, 0, 360*64);
332 g_info("y : %u, height : %u", y
, height
);
336 birth
.tv_sec
= i
*12000;
337 birth
.tv_nsec
= i
*55700;
339 processlist_get_process_pixels(process_list
,
348 y
+(height
/2), x
+ width
, y
+(height
/2),
349 drawing
->drawing_area
->style
->black_gc
);
351 g_critical("y : %u, height : %u", y
, height
);
355 birth
.tv_sec
= 12000;
356 birth
.tv_nsec
= 55600;
358 processlist_get_process_pixels(process_list
,
367 y
+(height
/2), x
+ width
, y
+(height
/2),
368 drawing
->drawing_area
->style
->black_gc
);
370 g_info("y : %u, height : %u", y
, height
);
373 /* IMPORTANT : This action uses the cpu heavily! */
374 //icon_pixmap = gdk_pixmap_create_from_xpm(pixmap, &mask, NULL,
375 // "/home/compudj/local/share/LinuxTraceToolkit/pixmaps/move_message.xpm");
376 // "/home/compudj/local/share/LinuxTraceToolkit/pixmaps/mini-display.xpm");
378 // gdk_gc_set_clip_mask(drawing->drawing_area->style->black_gc, mask);
380 // for(i=x;i<x+width;i=i+15)
382 // for(j=0;j<height*20;j=j+15)
386 //gdk_gc_copy(gc, drawing->drawing_area->style->black_gc);
387 // gdk_gc_set_clip_origin(drawing->drawing_area->style->black_gc, i, j);
388 // gdk_draw_drawable(pixmap,
389 // drawing->drawing_area->style->black_gc,
391 // 0, 0, i, j, -1, -1);
396 test_draw_item(drawing
,pixmap
);
398 //gdk_gc_set_clip_origin(drawing->drawing_area->style->black_gc, 0, 0);
399 //gdk_gc_set_clip_mask(drawing->drawing_area->style->black_gc, NULL);
401 //g_free(icon_pixmap);
409 pango_font_description_set_size(FontDesc
, Font_Size
);
410 g_object_unref(layout
);
414 void send_test_process(ProcessList
*process_list
, Drawing_t
*drawing
)
418 ProcessInfo Process_Info
= {10000, 12000, 55600};
419 //ProcessInfo Process_Info = {156, 14000, 55500};
420 GtkTreeRowReference
*row_ref
;
424 if(process_list
->Test_Process_Sent
) return;
426 birth
.tv_sec
= 12000;
427 birth
.tv_nsec
= 55500;
429 processlist_add(process_list
,
433 processlist_get_process_pixels(process_list
,
438 drawing_insert_square( drawing
, y
, height
);
440 //g_critical("y : %u, height : %u", y, height);
442 birth
.tv_sec
= 14000;
443 birth
.tv_nsec
= 55500;
445 processlist_add(process_list
,
449 processlist_get_process_pixels(process_list
,
454 drawing_insert_square( drawing
, y
, height
);
456 //g_critical("y : %u, height : %u", y, height);
458 birth
.tv_sec
= 12000;
459 birth
.tv_nsec
= 55700;
461 processlist_add(process_list
,
465 processlist_get_process_pixels(process_list
,
470 drawing_insert_square( drawing
, y
, height
);
472 //g_critical("y : %u, height : %u", y, height);
474 //drawing_insert_square( drawing, height, 5);
478 birth
.tv_sec
= i
*12000;
479 birth
.tv_nsec
= i
*55700;
481 processlist_add(process_list
,
485 processlist_get_process_pixels(process_list
,
490 drawing_insert_square( drawing
, y
, height
);
492 // g_critical("y : %u, height : %u", y, height);
495 //g_critical("height : %u", height);
497 birth
.tv_sec
= 12000;
498 birth
.tv_nsec
= 55600;
500 processlist_add(process_list
,
504 processlist_get_process_pixels(process_list
,
509 drawing_insert_square( drawing
, y
, height
);
511 //g_critical("y : %u, height : %u", y, height);
513 processlist_add(process_list
,
517 processlist_get_process_pixels(process_list
,
522 drawing_insert_square( drawing
, y
, height
);
524 //g_critical("y : %u, height : %u", y, height);
526 //drawing_insert_square( drawing, height, 5);
527 //g_critical("height : %u", height);
530 processlist_get_process_pixels(process_list
,
534 processlist_remove( process_list
,
538 drawing_remove_square( drawing
, y
, height
);
541 (GtkTreeRowReference
*)g_hash_table_lookup(
542 process_list
->process_hash
,
545 g_critical("key found");
546 g_critical("position in the list : %s",
547 gtk_tree_path_to_string (
548 gtk_tree_row_reference_get_path(
549 (GtkTreeRowReference
*)row_ref
)
554 process_list
->Test_Process_Sent
= TRUE
;