retabulation 2 spaces
[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;
17 ControlFlowData *Control_Flow_Data;
18 guint ev_sel = 444 ;
19 /* Horizontal scrollbar and it's adjustment */
20 GtkWidget *VScroll_VC;
21 GtkAdjustment *VAdjust_C ;
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
4c69e0cc 47 Control_Flow_Data = guicontrolflow();
f0d936c0 48 CF_Viewer = Control_Flow_Data->Scrolled_Window_VC;
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
60 //Event_Selected_Hook(Control_Flow_Data, &ev_sel);
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
76void add_test_process(ControlFlowData *Control_Flow_Data)
77{
78 GtkTreeIter iter;
79 int i;
80 gchar *process[] = { "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" };
81
82 for(i=0; i<Control_Flow_Data->Number_Of_Process; i++)
83 {
84 /* Add a new row to the model */
85 gtk_list_store_append (Control_Flow_Data->Store_M, &iter);
fa2c4dbe 86 gtk_list_store_set ( Control_Flow_Data->Store_M, &iter,
87 PROCESS_COLUMN, process[i],
88 -1);
f0d936c0 89 }
90
91}
92
93
94
95
96
97
98void test_draw(ControlFlowData *Control_Flow_Data)
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
106 DrawingAreaInfo *Drawing_Area_Info = &Control_Flow_Data->Drawing_Area_Info;
107
108
109}
110
111#ifdef DEBUG
112void test_draw() {
113 gint cell_height = get_cell_height(GTK_TREE_VIEW(Control_Flow_Data->Process_List_VC));
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. */
123 Control_Flow_Data->Drawing_Area_Info.width = widget->allocation.width;
124
125 test_draw(Control_Flow_Data);
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,
135 // Control_Flow_Data->Drawing_Area_Info.height,
136 // 0, 64 * 360);
137
138
139 //Drawing_Area_Init(Control_Flow_Data);
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;
210 draw_context.gc = Drawing->Drawing_Area_V->style->black_gc;
211
212 draw_context.Current = &current;
213 draw_context.Previous = NULL;
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 */
232void send_test_drawing(ProcessList *Process_List,
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 */
257 layout = gtk_widget_create_pango_layout(Drawing->Drawing_Area_V,
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);
271 processlist_get_process_pixels(Process_List,
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),
281 Drawing->Drawing_Area_V->style->black_gc);
282
283 pango_layout_set_text(layout, "Test", -1);
284 gdk_draw_layout(Pixmap, Drawing->Drawing_Area_V->style->black_gc,
285 0, y+height, layout);
286
287 birth.tv_sec = 14000;
288 birth.tv_nsec = 55500;
289
290 processlist_get_process_pixels(Process_List,
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),
300 Drawing->Drawing_Area_V->style->black_gc);
301
302 g_info("y : %u, height : %u", y, height);
303
304
305
306 birth.tv_sec = 12000;
307 birth.tv_nsec = 55700;
308
309 processlist_get_process_pixels(Process_List,
310 10,
311 &birth,
312 &y,
313 &height);
314
315 /* Draw rectangle (background color) */
316 gdk_gc_copy(gc, Drawing->Drawing_Area_V->style->black_gc);
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),
325 Drawing->Drawing_Area_V->style->black_gc);
326
327
328 /* Draw arc */
329 gdk_draw_arc(Pixmap, Drawing->Drawing_Area_V->style->black_gc,
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
339 processlist_get_process_pixels(Process_List,
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),
349 Drawing->Drawing_Area_V->style->black_gc);
350
351 g_critical("y : %u, height : %u", y, height);
352
353 }
354
355 birth.tv_sec = 12000;
356 birth.tv_nsec = 55600;
357
358 processlist_get_process_pixels(Process_List,
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),
368 Drawing->Drawing_Area_V->style->black_gc);
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
378 // gdk_gc_set_clip_mask(Drawing->Drawing_Area_V->style->black_gc, mask);
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 */
386 //gdk_gc_copy(gc, Drawing->Drawing_Area_V->style->black_gc);
387// gdk_gc_set_clip_origin(Drawing->Drawing_Area_V->style->black_gc, i, j);
388// gdk_draw_drawable(Pixmap,
389// Drawing->Drawing_Area_V->style->black_gc,
390// icon_pixmap,
391// 0, 0, i, j, -1, -1);
392
393// }
394// }
395
396 test_draw_item(Drawing,Pixmap);
397
398 //gdk_gc_set_clip_origin(Drawing->Drawing_Area_V->style->black_gc, 0, 0);
399 //gdk_gc_set_clip_mask(Drawing->Drawing_Area_V->style->black_gc, NULL);
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
414void send_test_process(ProcessList *Process_List, Drawing_t *Drawing)
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
424 if(Process_List->Test_Process_Sent) return;
425
426 birth.tv_sec = 12000;
427 birth.tv_nsec = 55500;
428
429 processlist_add(Process_List,
430 1,
431 &birth,
432 &y);
433 processlist_get_process_pixels(Process_List,
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
445 processlist_add(Process_List,
446 156,
447 &birth,
448 &y);
449 processlist_get_process_pixels(Process_List,
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
461 processlist_add(Process_List,
462 10,
463 &birth,
464 &height);
465 processlist_get_process_pixels(Process_List,
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
481 processlist_add(Process_List,
482 i,
483 &birth,
484 &height);
485 processlist_get_process_pixels(Process_List,
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
500 processlist_add(Process_List,
501 10,
502 &birth,
503 &y);
504 processlist_get_process_pixels(Process_List,
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
513 processlist_add(Process_List,
514 10000,
515 &birth,
516 &height);
517 processlist_get_process_pixels(Process_List,
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
530 processlist_get_process_pixels(Process_List,
531 10000,
532 &birth,
533 &y, &height);
534 processlist_remove( Process_List,
535 10000,
536 &birth);
537
538 drawing_remove_square( Drawing, y, height);
539
540 if(got_RowRef =
541 (GtkTreeRowReference*)g_hash_table_lookup(
542 Process_List->Process_Hash,
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
554 Process_List->Test_Process_Sent = TRUE;
555
556}
557#endif//NOTUSE
558
This page took 0.043471 seconds and 4 git commands to generate.