Drawing.h attribute name change
[lttv.git] / ltt / branches / poly / lttv / modules / guiControlFlow / test.c
CommitLineData
f0d936c0 1
2
3static void destroy_cb( GtkWidget *widget,
4 gpointer data )
5{
6 gtk_main_quit ();
7}
8
9
10
11int main(int argc, char **argv)
12{
13 GtkWidget *Window;
14 GtkWidget *CF_Viewer;
15 GtkWidget *VBox_V;
16 GtkWidget *HScroll_VC;
68997a22 17 ControlFlowData *control_flow_data;
f0d936c0 18 guint ev_sel = 444 ;
19 /* Horizontal scrollbar and it's adjustment */
20 GtkWidget *VScroll_VC;
ba90bc77 21 GtkAdjustment *v_adjust ;
f0d936c0 22
23 /* Initialize i18n support */
24 gtk_set_locale ();
25
26 /* Initialize the widget set */
27 gtk_init (&argc, &argv);
28
29 init();
30
31 Window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
32 gtk_window_set_title (GTK_WINDOW (Window), ("Test Window"));
33
34 g_signal_connect (G_OBJECT (Window), "destroy",
35 G_CALLBACK (destroy_cb), NULL);
36
37
38 VBox_V = gtk_vbox_new(0, 0);
39 gtk_container_add (GTK_CONTAINER (Window), VBox_V);
40
41 //ListViewer = hGuiEvents(Window);
42 //gtk_box_pack_start(GTK_BOX(VBox_V), ListViewer, TRUE, TRUE, 0);
43
44 //ListViewer = hGuiEvents(Window);
45 //gtk_box_pack_start(GTK_BOX(VBox_V), ListViewer, FALSE, TRUE, 0);
46
68997a22 47 control_flow_data = guicontrolflow();
48 CF_Viewer = control_flow_data->scrolled_window;
f0d936c0 49 gtk_box_pack_start(GTK_BOX(VBox_V), CF_Viewer, TRUE, TRUE, 0);
50
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);
54
55
56 gtk_widget_show (HScroll_VC);
57 gtk_widget_show (VBox_V);
58 gtk_widget_show (Window);
59
68997a22 60 //Event_Selected_Hook(control_flow_data, &ev_sel);
f0d936c0 61
62 gtk_main ();
63
64 g_critical("main loop finished");
65
4c69e0cc 66 //h_guievents_destructor(ListViewer);
f0d936c0 67
68 //g_critical("GuiEvents Destructor finished");
69 destroy();
70
71 return 0;
72}
73
74
75
68997a22 76void add_test_process(ControlFlowData *control_flow_data)
f0d936c0 77{
78 GtkTreeIter iter;
79 int i;
80 gchar *process[] = { "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" };
81
68997a22 82 for(i=0; i<control_flow_data->number_of_process; i++)
f0d936c0 83 {
84 /* Add a new row to the model */
68997a22 85 gtk_list_store_append (control_flow_data->Store_M, &iter);
86 gtk_list_store_set ( control_flow_data->Store_M, &iter,
fa2c4dbe 87 PROCESS_COLUMN, process[i],
88 -1);
f0d936c0 89 }
90
91}
92
93
94
95
96
97
68997a22 98void test_draw(ControlFlowData *control_flow_data)
f0d936c0 99{
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. */
105
68997a22 106 DrawingAreaInfo *Drawing_Area_Info = &control_flow_data->Drawing_Area_Info;
f0d936c0 107
108
109}
110
111#ifdef DEBUG
112void test_draw() {
68997a22 113 gint cell_height = get_cell_height(GTK_TREE_VIEW(control_flow_data->process_list_VC));
f0d936c0 114 GdkGC *GC = gdk_gc_new(widget->window);
115 GdkColor color = CF_Colors[GREEN];
116
117 gdk_color_alloc (gdk_colormap_get_system () , &color);
118
119 g_critical("expose");
120
121 /* When redrawing, use widget->allocation.width to get the width of
122 * drawable area. */
68997a22 123 control_flow_data->Drawing_Area_Info.width = widget->allocation.width;
f0d936c0 124
68997a22 125 test_draw(control_flow_data);
f0d936c0 126
127 gdk_gc_copy(GC,widget->style->white_gc);
128 gdk_gc_set_foreground(GC,&color);
129
130 //gdk_draw_arc (widget->window,
131 // widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
132 // TRUE,
133 // //0, 0, widget->allocation.width, widget->allocation.height,
134 // 0, 0, widget->allocation.width,
68997a22 135 // control_flow_data->Drawing_Area_Info.height,
f0d936c0 136 // 0, 64 * 360);
137
138
68997a22 139 //Drawing_Area_Init(control_flow_data);
f0d936c0 140
141 // 2 pixels for the box around the drawing area, 1 pixel for off-by-one
142 // (starting from 0)
143 //gdk_gc_copy (&GC, widget->style->fg_gc[GTK_WIDGET_STATE (widget)]);
144
145 gdk_gc_set_line_attributes(GC,12, GDK_LINE_SOLID, GDK_CAP_NOT_LAST,GDK_JOIN_MITER);
146
147 gdk_draw_line (widget->window,
148 GC,
149 0, (cell_height-1)/2,
150 widget->allocation.width, (cell_height-1)/2);
151
152 color = CF_Colors[BLUE];
153
154 gdk_color_alloc (gdk_colormap_get_system () , &color);
155
156 gdk_gc_set_foreground(GC,&color);
157
158
159 gdk_gc_set_line_attributes(GC,3, GDK_LINE_SOLID, GDK_CAP_NOT_LAST,GDK_JOIN_MITER);
160
161 gdk_draw_line (widget->window,
162 GC,
163 0, (cell_height-1)/2,
164 widget->allocation.width,(cell_height-1)/2);
165
166
167
168
169
170
171 g_object_unref(GC);
172
173 //gdk_colormap_alloc_colors(gdk_colormap_get_system(), TRUE,
174
175 //gdk_gc_set_line_attributes(GC,5, GDK_LINE_SOLID, GDK_CAP_NOT_LAST,GDK_JOIN_MITER);
176 //gdk_gc_set_foreground(GC,
177
178 //gdk_draw_line (widget->window,
179 // GC,
180 // 0, (2*cell_height)-2-1,
181 // 50, (2*cell_height)-2-1);
182
183}
184#endif //DEBUG
185
50439712 186
187/* Event_Hook.c tests */
188
189void test_draw_item(Drawing_t *Drawing,
190 GdkPixmap *Pixmap)
191{
192 PropertiesIcon properties_icon;
193 DrawContext draw_context;
194
195 DrawInfo current, previous;
196 ItemInfo over, middle, under, modify_over, modify_middle, modify_under;
197
198 int i=0,j=0;
199
200 //for(i=0; i<1024;i=i+15)
201 {
202 // for(j=0;j<768;j=j+15)
203 {
204 over.x = i;
205 over.y = j;
206
207 current.modify_over = &over;
208
209 draw_context.drawable = Pixmap;
14963be0 210 draw_context.gc = Drawing->drawing_area->style->black_gc;
50439712 211
68997a22 212 draw_context.current = &current;
213 draw_context.previous = NULL;
50439712 214
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",
218 MAX_PATH_LEN);
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);
224 }
225 }
226
227}
228
229#ifdef NOTUSE
230/* NOTE : no drawing data should be sent there, since the drawing widget
231 * has not been initialized */
ba90bc77 232void send_test_drawing(ProcessList *process_list,
50439712 233 Drawing_t *Drawing,
234 GdkPixmap *Pixmap,
235 gint x, gint y, // y not used here?
236 gint width,
237 gint height) // height won't be used here ?
238{
239 int i,j;
240 ProcessInfo Process_Info = {10000, 12000, 55600};
241 //ProcessInfo Process_Info = {156, 14000, 55500};
242 GtkTreeRowReference *got_RowRef;
243 PangoContext *context;
244 PangoLayout *layout;
245 PangoFontDescription *FontDesc;// = pango_font_description_new();
246 gint Font_Size;
247
248 //icon
249 //GdkBitmap *mask = g_new(GdkBitmap, 1);
250 //GdkPixmap *icon_pixmap = g_new(GdkPixmap, 1);
251 GdkGC * gc;
252 // rectangle
253 GdkColor color = { 0, 0xffff, 0x0000, 0x0000 };
254
255 gc = gdk_gc_new(Pixmap);
256 /* Sent text data */
14963be0 257 layout = gtk_widget_create_pango_layout(Drawing->drawing_area,
50439712 258 NULL);
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);
263
264
265
266
267 LttTime birth;
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);
ba90bc77 271 processlist_get_process_pixels(process_list,
50439712 272 1,
273 &birth,
274 &y,
275 &height);
276
277 g_info("we draw : x : %u, y : %u, width : %u, height : %u", x, y, width, height);
278 drawing_draw_line(
279 Drawing, Pixmap, x,
280 y+(height/2), x + width, y+(height/2),
14963be0 281 Drawing->drawing_area->style->black_gc);
50439712 282
283 pango_layout_set_text(layout, "Test", -1);
14963be0 284 gdk_draw_layout(Pixmap, Drawing->drawing_area->style->black_gc,
50439712 285 0, y+height, layout);
286
287 birth.tv_sec = 14000;
288 birth.tv_nsec = 55500;
289
ba90bc77 290 processlist_get_process_pixels(process_list,
50439712 291 156,
292 &birth,
293 &y,
294 &height);
295
296
297 drawing_draw_line(
298 Drawing, Pixmap, x,
299 y+(height/2), x + width, y+(height/2),
14963be0 300 Drawing->drawing_area->style->black_gc);
50439712 301
302 g_info("y : %u, height : %u", y, height);
303
304
305
306 birth.tv_sec = 12000;
307 birth.tv_nsec = 55700;
308
ba90bc77 309 processlist_get_process_pixels(process_list,
50439712 310 10,
311 &birth,
312 &y,
313 &height);
314
315 /* Draw rectangle (background color) */
14963be0 316 gdk_gc_copy(gc, Drawing->drawing_area->style->black_gc);
50439712 317 gdk_gc_set_rgb_fg_color(gc, &color);
318 gdk_draw_rectangle(Pixmap, gc,
319 TRUE,
320 x, y, width, height);
321
322 drawing_draw_line(
323 Drawing, Pixmap, x,
324 y+(height/2), x + width, y+(height/2),
14963be0 325 Drawing->drawing_area->style->black_gc);
50439712 326
327
328 /* Draw arc */
14963be0 329 gdk_draw_arc(Pixmap, Drawing->drawing_area->style->black_gc,
50439712 330 TRUE, 100, y, height/2, height/2, 0, 360*64);
331
332 g_info("y : %u, height : %u", y, height);
333
334 for(i=0; i<10; i++)
335 {
336 birth.tv_sec = i*12000;
337 birth.tv_nsec = i*55700;
338
ba90bc77 339 processlist_get_process_pixels(process_list,
50439712 340 i,
341 &birth,
342 &y,
343 &height);
344
345
346 drawing_draw_line(
347 Drawing, Pixmap, x,
348 y+(height/2), x + width, y+(height/2),
14963be0 349 Drawing->drawing_area->style->black_gc);
50439712 350
351 g_critical("y : %u, height : %u", y, height);
352
353 }
354
355 birth.tv_sec = 12000;
356 birth.tv_nsec = 55600;
357
ba90bc77 358 processlist_get_process_pixels(process_list,
50439712 359 10,
360 &birth,
361 &y,
362 &height);
363
364
365 drawing_draw_line(
366 Drawing, Pixmap, x,
367 y+(height/2), x + width, y+(height/2),
14963be0 368 Drawing->drawing_area->style->black_gc);
50439712 369
370 g_info("y : %u, height : %u", y, height);
371
372
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");
377
14963be0 378 // gdk_gc_set_clip_mask(Drawing->drawing_area->style->black_gc, mask);
50439712 379
380// for(i=x;i<x+width;i=i+15)
381// {
382// for(j=0;j<height*20;j=j+15)
383// {
384
385 /* Draw icon */
14963be0 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);
50439712 388// gdk_draw_drawable(Pixmap,
14963be0 389// Drawing->drawing_area->style->black_gc,
50439712 390// icon_pixmap,
391// 0, 0, i, j, -1, -1);
392
393// }
394// }
395
396 test_draw_item(Drawing,Pixmap);
397
14963be0 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);
50439712 400
401 //g_free(icon_pixmap);
402 //g_free(mask);
403
404
405
406
407
408
409 pango_font_description_set_size(FontDesc, Font_Size);
410 g_object_unref(layout);
411 g_free(gc);
412}
413
ba90bc77 414void send_test_process(ProcessList *process_list, Drawing_t *Drawing)
50439712 415{
416 guint height, y;
417 int i;
418 ProcessInfo Process_Info = {10000, 12000, 55600};
419 //ProcessInfo Process_Info = {156, 14000, 55500};
420 GtkTreeRowReference *got_RowRef;
421
422 LttTime birth;
423
ba90bc77 424 if(process_list->Test_Process_Sent) return;
50439712 425
426 birth.tv_sec = 12000;
427 birth.tv_nsec = 55500;
428
ba90bc77 429 processlist_add(process_list,
50439712 430 1,
431 &birth,
432 &y);
ba90bc77 433 processlist_get_process_pixels(process_list,
50439712 434 1,
435 &birth,
436 &y,
437 &height);
438 drawing_insert_square( Drawing, y, height);
439
440 //g_critical("y : %u, height : %u", y, height);
441
442 birth.tv_sec = 14000;
443 birth.tv_nsec = 55500;
444
ba90bc77 445 processlist_add(process_list,
50439712 446 156,
447 &birth,
448 &y);
ba90bc77 449 processlist_get_process_pixels(process_list,
50439712 450 156,
451 &birth,
452 &y,
453 &height);
454 drawing_insert_square( Drawing, y, height);
455
456 //g_critical("y : %u, height : %u", y, height);
457
458 birth.tv_sec = 12000;
459 birth.tv_nsec = 55700;
460
ba90bc77 461 processlist_add(process_list,
50439712 462 10,
463 &birth,
464 &height);
ba90bc77 465 processlist_get_process_pixels(process_list,
50439712 466 10,
467 &birth,
468 &y,
469 &height);
470 drawing_insert_square( Drawing, y, height);
471
472 //g_critical("y : %u, height : %u", y, height);
473
474 //drawing_insert_square( Drawing, height, 5);
475
476 for(i=0; i<10; i++)
477 {
478 birth.tv_sec = i*12000;
479 birth.tv_nsec = i*55700;
480
ba90bc77 481 processlist_add(process_list,
50439712 482 i,
483 &birth,
484 &height);
ba90bc77 485 processlist_get_process_pixels(process_list,
50439712 486 i,
487 &birth,
488 &y,
489 &height);
490 drawing_insert_square( Drawing, y, height);
491
492 // g_critical("y : %u, height : %u", y, height);
493
494 }
495 //g_critical("height : %u", height);
496
497 birth.tv_sec = 12000;
498 birth.tv_nsec = 55600;
499
ba90bc77 500 processlist_add(process_list,
50439712 501 10,
502 &birth,
503 &y);
ba90bc77 504 processlist_get_process_pixels(process_list,
50439712 505 10,
506 &birth,
507 &y,
508 &height);
509 drawing_insert_square( Drawing, y, height);
510
511 //g_critical("y : %u, height : %u", y, height);
512
ba90bc77 513 processlist_add(process_list,
50439712 514 10000,
515 &birth,
516 &height);
ba90bc77 517 processlist_get_process_pixels(process_list,
50439712 518 10000,
519 &birth,
520 &y,
521 &height);
522 drawing_insert_square( Drawing, y, height);
523
524 //g_critical("y : %u, height : %u", y, height);
525
526 //drawing_insert_square( Drawing, height, 5);
527 //g_critical("height : %u", height);
528
529
ba90bc77 530 processlist_get_process_pixels(process_list,
50439712 531 10000,
532 &birth,
533 &y, &height);
ba90bc77 534 processlist_remove( process_list,
50439712 535 10000,
536 &birth);
537
538 drawing_remove_square( Drawing, y, height);
539
540 if(got_RowRef =
541 (GtkTreeRowReference*)g_hash_table_lookup(
14963be0 542 process_list->process_hash,
50439712 543 &Process_Info))
544 {
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*)got_RowRef)
550 ));
551
552 }
553
ba90bc77 554 process_list->Test_Process_Sent = TRUE;
50439712 555
556}
557#endif//NOTUSE
558
This page took 0.046661 seconds and 4 git commands to generate.