remove old files
[lttv.git] / ltt / branches / poly / lttv / modules / gui / controlflow / test.c
CommitLineData
ce0214a6 1/* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Mathieu Desnoyers
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
16 * MA 02111-1307, USA.
17 */
f0d936c0 18
19
20static void destroy_cb( GtkWidget *widget,
21 gpointer data )
22{
23 gtk_main_quit ();
24}
25
26
27
28int main(int argc, char **argv)
29{
30 GtkWidget *Window;
31 GtkWidget *CF_Viewer;
32 GtkWidget *VBox_V;
33 GtkWidget *HScroll_VC;
68997a22 34 ControlFlowData *control_flow_data;
f0d936c0 35 guint ev_sel = 444 ;
36 /* Horizontal scrollbar and it's adjustment */
37 GtkWidget *VScroll_VC;
ba90bc77 38 GtkAdjustment *v_adjust ;
f0d936c0 39
40 /* Initialize i18n support */
41 gtk_set_locale ();
42
43 /* Initialize the widget set */
44 gtk_init (&argc, &argv);
45
46 init();
47
48 Window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
49 gtk_window_set_title (GTK_WINDOW (Window), ("Test Window"));
50
51 g_signal_connect (G_OBJECT (Window), "destroy",
52 G_CALLBACK (destroy_cb), NULL);
53
54
55 VBox_V = gtk_vbox_new(0, 0);
56 gtk_container_add (GTK_CONTAINER (Window), VBox_V);
57
58 //ListViewer = hGuiEvents(Window);
59 //gtk_box_pack_start(GTK_BOX(VBox_V), ListViewer, TRUE, TRUE, 0);
60
61 //ListViewer = hGuiEvents(Window);
62 //gtk_box_pack_start(GTK_BOX(VBox_V), ListViewer, FALSE, TRUE, 0);
63
68997a22 64 control_flow_data = guicontrolflow();
65 CF_Viewer = control_flow_data->scrolled_window;
f0d936c0 66 gtk_box_pack_start(GTK_BOX(VBox_V), CF_Viewer, TRUE, TRUE, 0);
67
68 /* Create horizontal scrollbar and pack it */
69 HScroll_VC = gtk_hscrollbar_new(NULL);
70 gtk_box_pack_start(GTK_BOX(VBox_V), HScroll_VC, FALSE, TRUE, 0);
71
72
73 gtk_widget_show (HScroll_VC);
74 gtk_widget_show (VBox_V);
75 gtk_widget_show (Window);
76
68997a22 77 //Event_Selected_Hook(control_flow_data, &ev_sel);
f0d936c0 78
79 gtk_main ();
80
81 g_critical("main loop finished");
82
4c69e0cc 83 //h_guievents_destructor(ListViewer);
f0d936c0 84
85 //g_critical("GuiEvents Destructor finished");
86 destroy();
87
88 return 0;
89}
90
91
92
68997a22 93void add_test_process(ControlFlowData *control_flow_data)
f0d936c0 94{
95 GtkTreeIter iter;
96 int i;
97 gchar *process[] = { "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" };
98
68997a22 99 for(i=0; i<control_flow_data->number_of_process; i++)
f0d936c0 100 {
101 /* Add a new row to the model */
f5d980bf 102 gtk_list_store_append (control_flow_data->list_store, &iter);
103 gtk_list_store_set ( control_flow_data->list_store, &iter,
fa2c4dbe 104 PROCESS_COLUMN, process[i],
105 -1);
f0d936c0 106 }
107
108}
109
110
111
112
113
114
68997a22 115void test_draw(ControlFlowData *control_flow_data)
f0d936c0 116{
117 /* Draw event states using available height, Number of process, cell height
118 * (don't forget to remove two pixels at beginning and end).
119 * For horizontal : use width, Time_Begin, Time_End.
120 * This function calls the reading library to get the draw_hook called
121 * for the desired period of time. */
122
501d5405 123 drawingAreaInfo *drawing_Area_Info = &control_flow_data->drawing_Area_Info;
f0d936c0 124
125
126}
127
128#ifdef DEBUG
129void test_draw() {
f5d980bf 130 gint cell_height = get_cell_height(GTK_TREE_VIEW(control_flow_data->process_list_widget));
f0d936c0 131 GdkGC *GC = gdk_gc_new(widget->window);
132 GdkColor color = CF_Colors[GREEN];
133
134 gdk_color_alloc (gdk_colormap_get_system () , &color);
135
136 g_critical("expose");
137
138 /* When redrawing, use widget->allocation.width to get the width of
139 * drawable area. */
501d5405 140 control_flow_data->drawing_Area_Info.width = widget->allocation.width;
f0d936c0 141
68997a22 142 test_draw(control_flow_data);
f0d936c0 143
144 gdk_gc_copy(GC,widget->style->white_gc);
145 gdk_gc_set_foreground(GC,&color);
146
147 //gdk_draw_arc (widget->window,
148 // widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
149 // TRUE,
150 // //0, 0, widget->allocation.width, widget->allocation.height,
151 // 0, 0, widget->allocation.width,
501d5405 152 // control_flow_data->drawing_Area_Info.height,
f0d936c0 153 // 0, 64 * 360);
154
155
501d5405 156 //drawing_Area_Init(control_flow_data);
f0d936c0 157
158 // 2 pixels for the box around the drawing area, 1 pixel for off-by-one
159 // (starting from 0)
160 //gdk_gc_copy (&GC, widget->style->fg_gc[GTK_WIDGET_STATE (widget)]);
161
162 gdk_gc_set_line_attributes(GC,12, GDK_LINE_SOLID, GDK_CAP_NOT_LAST,GDK_JOIN_MITER);
163
164 gdk_draw_line (widget->window,
165 GC,
166 0, (cell_height-1)/2,
167 widget->allocation.width, (cell_height-1)/2);
168
169 color = CF_Colors[BLUE];
170
171 gdk_color_alloc (gdk_colormap_get_system () , &color);
172
173 gdk_gc_set_foreground(GC,&color);
174
175
176 gdk_gc_set_line_attributes(GC,3, GDK_LINE_SOLID, GDK_CAP_NOT_LAST,GDK_JOIN_MITER);
177
178 gdk_draw_line (widget->window,
179 GC,
180 0, (cell_height-1)/2,
181 widget->allocation.width,(cell_height-1)/2);
182
183
184
185
186
187
188 g_object_unref(GC);
189
190 //gdk_colormap_alloc_colors(gdk_colormap_get_system(), TRUE,
191
192 //gdk_gc_set_line_attributes(GC,5, GDK_LINE_SOLID, GDK_CAP_NOT_LAST,GDK_JOIN_MITER);
193 //gdk_gc_set_foreground(GC,
194
195 //gdk_draw_line (widget->window,
196 // GC,
197 // 0, (2*cell_height)-2-1,
198 // 50, (2*cell_height)-2-1);
199
200}
201#endif //DEBUG
202
50439712 203
204/* Event_Hook.c tests */
205
501d5405 206void test_draw_item(Drawing_t *drawing,
b6db18f8 207 GdkPixmap *pixmap)
50439712 208{
209 PropertiesIcon properties_icon;
210 DrawContext draw_context;
211
212 DrawInfo current, previous;
213 ItemInfo over, middle, under, modify_over, modify_middle, modify_under;
214
215 int i=0,j=0;
216
217 //for(i=0; i<1024;i=i+15)
218 {
219 // for(j=0;j<768;j=j+15)
220 {
221 over.x = i;
222 over.y = j;
223
224 current.modify_over = &over;
225
b6db18f8 226 draw_context.drawable = pixmap;
501d5405 227 draw_context.gc = drawing->drawing_area->style->black_gc;
50439712 228
68997a22 229 draw_context.current = &current;
230 draw_context.previous = NULL;
50439712 231
232 properties_icon.icon_name = g_new(char, MAX_PATH_LEN);
233 strncpy(properties_icon.icon_name,
234 "/home/compudj/local/share/LinuxTraceToolkit/pixmaps/mini-display.xpm",
235 MAX_PATH_LEN);
236 properties_icon.width = -1;
237 properties_icon.height = -1;
238 properties_icon.position = OVER;
239 draw_icon(&properties_icon, &draw_context);
240 g_free(properties_icon.icon_name);
241 }
242 }
243
244}
245
246#ifdef NOTUSE
247/* NOTE : no drawing data should be sent there, since the drawing widget
248 * has not been initialized */
ba90bc77 249void send_test_drawing(ProcessList *process_list,
501d5405 250 Drawing_t *drawing,
b6db18f8 251 GdkPixmap *pixmap,
50439712 252 gint x, gint y, // y not used here?
253 gint width,
254 gint height) // height won't be used here ?
255{
256 int i,j;
257 ProcessInfo Process_Info = {10000, 12000, 55600};
258 //ProcessInfo Process_Info = {156, 14000, 55500};
f5d980bf 259 GtkTreeRowReference *row_ref;
50439712 260 PangoContext *context;
261 PangoLayout *layout;
262 PangoFontDescription *FontDesc;// = pango_font_description_new();
263 gint Font_Size;
264
265 //icon
266 //GdkBitmap *mask = g_new(GdkBitmap, 1);
267 //GdkPixmap *icon_pixmap = g_new(GdkPixmap, 1);
268 GdkGC * gc;
269 // rectangle
270 GdkColor color = { 0, 0xffff, 0x0000, 0x0000 };
271
b6db18f8 272 gc = gdk_gc_new(pixmap);
50439712 273 /* Sent text data */
501d5405 274 layout = gtk_widget_create_pango_layout(drawing->drawing_area,
50439712 275 NULL);
276 context = pango_layout_get_context(layout);
277 FontDesc = pango_context_get_font_description(context);
278 Font_Size = pango_font_description_get_size(FontDesc);
279 pango_font_description_set_size(FontDesc, Font_Size-3*PANGO_SCALE);
280
281
282
283
284 LttTime birth;
285 birth.tv_sec = 12000;
286 birth.tv_nsec = 55500;
287 g_info("we have : x : %u, y : %u, width : %u, height : %u", x, y, width, height);
ba90bc77 288 processlist_get_process_pixels(process_list,
50439712 289 1,
290 &birth,
291 &y,
292 &height);
293
294 g_info("we draw : x : %u, y : %u, width : %u, height : %u", x, y, width, height);
295 drawing_draw_line(
501d5405 296 drawing, pixmap, x,
50439712 297 y+(height/2), x + width, y+(height/2),
501d5405 298 drawing->drawing_area->style->black_gc);
50439712 299
300 pango_layout_set_text(layout, "Test", -1);
501d5405 301 gdk_draw_layout(pixmap, drawing->drawing_area->style->black_gc,
50439712 302 0, y+height, layout);
303
304 birth.tv_sec = 14000;
305 birth.tv_nsec = 55500;
306
ba90bc77 307 processlist_get_process_pixels(process_list,
50439712 308 156,
309 &birth,
310 &y,
311 &height);
312
313
314 drawing_draw_line(
501d5405 315 drawing, pixmap, x,
50439712 316 y+(height/2), x + width, y+(height/2),
501d5405 317 drawing->drawing_area->style->black_gc);
50439712 318
319 g_info("y : %u, height : %u", y, height);
320
321
322
323 birth.tv_sec = 12000;
324 birth.tv_nsec = 55700;
325
ba90bc77 326 processlist_get_process_pixels(process_list,
50439712 327 10,
328 &birth,
329 &y,
330 &height);
331
332 /* Draw rectangle (background color) */
501d5405 333 gdk_gc_copy(gc, drawing->drawing_area->style->black_gc);
50439712 334 gdk_gc_set_rgb_fg_color(gc, &color);
b6db18f8 335 gdk_draw_rectangle(pixmap, gc,
50439712 336 TRUE,
337 x, y, width, height);
338
339 drawing_draw_line(
501d5405 340 drawing, pixmap, x,
50439712 341 y+(height/2), x + width, y+(height/2),
501d5405 342 drawing->drawing_area->style->black_gc);
50439712 343
344
345 /* Draw arc */
501d5405 346 gdk_draw_arc(pixmap, drawing->drawing_area->style->black_gc,
50439712 347 TRUE, 100, y, height/2, height/2, 0, 360*64);
348
349 g_info("y : %u, height : %u", y, height);
350
351 for(i=0; i<10; i++)
352 {
353 birth.tv_sec = i*12000;
354 birth.tv_nsec = i*55700;
355
ba90bc77 356 processlist_get_process_pixels(process_list,
50439712 357 i,
358 &birth,
359 &y,
360 &height);
361
362
363 drawing_draw_line(
501d5405 364 drawing, pixmap, x,
50439712 365 y+(height/2), x + width, y+(height/2),
501d5405 366 drawing->drawing_area->style->black_gc);
50439712 367
368 g_critical("y : %u, height : %u", y, height);
369
370 }
371
372 birth.tv_sec = 12000;
373 birth.tv_nsec = 55600;
374
ba90bc77 375 processlist_get_process_pixels(process_list,
50439712 376 10,
377 &birth,
378 &y,
379 &height);
380
381
382 drawing_draw_line(
501d5405 383 drawing, pixmap, x,
50439712 384 y+(height/2), x + width, y+(height/2),
501d5405 385 drawing->drawing_area->style->black_gc);
50439712 386
387 g_info("y : %u, height : %u", y, height);
388
389
390 /* IMPORTANT : This action uses the cpu heavily! */
b6db18f8 391 //icon_pixmap = gdk_pixmap_create_from_xpm(pixmap, &mask, NULL,
50439712 392// "/home/compudj/local/share/LinuxTraceToolkit/pixmaps/move_message.xpm");
393 // "/home/compudj/local/share/LinuxTraceToolkit/pixmaps/mini-display.xpm");
394
501d5405 395 // gdk_gc_set_clip_mask(drawing->drawing_area->style->black_gc, mask);
50439712 396
397// for(i=x;i<x+width;i=i+15)
398// {
399// for(j=0;j<height*20;j=j+15)
400// {
401
402 /* Draw icon */
501d5405 403 //gdk_gc_copy(gc, drawing->drawing_area->style->black_gc);
404// gdk_gc_set_clip_origin(drawing->drawing_area->style->black_gc, i, j);
b6db18f8 405// gdk_draw_drawable(pixmap,
501d5405 406// drawing->drawing_area->style->black_gc,
50439712 407// icon_pixmap,
408// 0, 0, i, j, -1, -1);
409
410// }
411// }
412
501d5405 413 test_draw_item(drawing,pixmap);
50439712 414
501d5405 415 //gdk_gc_set_clip_origin(drawing->drawing_area->style->black_gc, 0, 0);
416 //gdk_gc_set_clip_mask(drawing->drawing_area->style->black_gc, NULL);
50439712 417
418 //g_free(icon_pixmap);
419 //g_free(mask);
420
421
422
423
424
425
426 pango_font_description_set_size(FontDesc, Font_Size);
427 g_object_unref(layout);
428 g_free(gc);
429}
430
501d5405 431void send_test_process(ProcessList *process_list, Drawing_t *drawing)
50439712 432{
433 guint height, y;
434 int i;
435 ProcessInfo Process_Info = {10000, 12000, 55600};
436 //ProcessInfo Process_Info = {156, 14000, 55500};
f5d980bf 437 GtkTreeRowReference *row_ref;
50439712 438
439 LttTime birth;
440
ba90bc77 441 if(process_list->Test_Process_Sent) return;
50439712 442
443 birth.tv_sec = 12000;
444 birth.tv_nsec = 55500;
445
ba90bc77 446 processlist_add(process_list,
50439712 447 1,
448 &birth,
449 &y);
ba90bc77 450 processlist_get_process_pixels(process_list,
50439712 451 1,
452 &birth,
453 &y,
454 &height);
501d5405 455 drawing_insert_square( drawing, y, height);
50439712 456
457 //g_critical("y : %u, height : %u", y, height);
458
459 birth.tv_sec = 14000;
460 birth.tv_nsec = 55500;
461
ba90bc77 462 processlist_add(process_list,
50439712 463 156,
464 &birth,
465 &y);
ba90bc77 466 processlist_get_process_pixels(process_list,
50439712 467 156,
468 &birth,
469 &y,
470 &height);
501d5405 471 drawing_insert_square( drawing, y, height);
50439712 472
473 //g_critical("y : %u, height : %u", y, height);
474
475 birth.tv_sec = 12000;
476 birth.tv_nsec = 55700;
477
ba90bc77 478 processlist_add(process_list,
50439712 479 10,
480 &birth,
481 &height);
ba90bc77 482 processlist_get_process_pixels(process_list,
50439712 483 10,
484 &birth,
485 &y,
486 &height);
501d5405 487 drawing_insert_square( drawing, y, height);
50439712 488
489 //g_critical("y : %u, height : %u", y, height);
490
501d5405 491 //drawing_insert_square( drawing, height, 5);
50439712 492
493 for(i=0; i<10; i++)
494 {
495 birth.tv_sec = i*12000;
496 birth.tv_nsec = i*55700;
497
ba90bc77 498 processlist_add(process_list,
50439712 499 i,
500 &birth,
501 &height);
ba90bc77 502 processlist_get_process_pixels(process_list,
50439712 503 i,
504 &birth,
505 &y,
506 &height);
501d5405 507 drawing_insert_square( drawing, y, height);
50439712 508
509 // g_critical("y : %u, height : %u", y, height);
510
511 }
512 //g_critical("height : %u", height);
513
514 birth.tv_sec = 12000;
515 birth.tv_nsec = 55600;
516
ba90bc77 517 processlist_add(process_list,
50439712 518 10,
519 &birth,
520 &y);
ba90bc77 521 processlist_get_process_pixels(process_list,
50439712 522 10,
523 &birth,
524 &y,
525 &height);
501d5405 526 drawing_insert_square( drawing, y, height);
50439712 527
528 //g_critical("y : %u, height : %u", y, height);
529
ba90bc77 530 processlist_add(process_list,
50439712 531 10000,
532 &birth,
533 &height);
ba90bc77 534 processlist_get_process_pixels(process_list,
50439712 535 10000,
536 &birth,
537 &y,
538 &height);
501d5405 539 drawing_insert_square( drawing, y, height);
50439712 540
541 //g_critical("y : %u, height : %u", y, height);
542
501d5405 543 //drawing_insert_square( drawing, height, 5);
50439712 544 //g_critical("height : %u", height);
545
546
ba90bc77 547 processlist_get_process_pixels(process_list,
50439712 548 10000,
549 &birth,
550 &y, &height);
ba90bc77 551 processlist_remove( process_list,
50439712 552 10000,
553 &birth);
554
501d5405 555 drawing_remove_square( drawing, y, height);
50439712 556
f5d980bf 557 if(row_ref =
50439712 558 (GtkTreeRowReference*)g_hash_table_lookup(
14963be0 559 process_list->process_hash,
50439712 560 &Process_Info))
561 {
562 g_critical("key found");
563 g_critical("position in the list : %s",
564 gtk_tree_path_to_string (
565 gtk_tree_row_reference_get_path(
f5d980bf 566 (GtkTreeRowReference*)row_ref)
50439712 567 ));
568
569 }
570
ba90bc77 571 process_list->Test_Process_Sent = TRUE;
50439712 572
573}
574#endif//NOTUSE
575
This page took 0.048252 seconds and 4 git commands to generate.