basic time bar
[lttv.git] / ltt / branches / poly / lttv / modules / gui / controlflow / drawing.c
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 */
18
19 #include <gtk/gtk.h>
20 #include <gdk/gdk.h>
21
22 #include <lttv/processTrace.h>
23 #include <lttv/gtktraceset.h>
24 #include <lttv/hook.h>
25
26 #include "drawing.h"
27 #include "cfv.h"
28 #include "cfv-private.h"
29 #include "eventhooks.h"
30
31 #define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
32 #define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
33
34 /*****************************************************************************
35 * drawing functions *
36 *****************************************************************************/
37
38 static gboolean
39 expose_ruler( GtkWidget *widget, GdkEventExpose *event, gpointer user_data );
40
41
42
43 //FIXME Colors will need to be dynamic. Graphic context part not done so far.
44 typedef enum
45 {
46 RED,
47 GREEN,
48 BLUE,
49 WHITE,
50 BLACK
51
52 } ControlFlowColors;
53
54 /* Vector of unallocated colors */
55 static GdkColor CF_Colors [] =
56 {
57 { 0, 0xffff, 0x0000, 0x0000 }, // RED
58 { 0, 0x0000, 0xffff, 0x0000 }, // GREEN
59 { 0, 0x0000, 0x0000, 0xffff }, // BLUE
60 { 0, 0xffff, 0xffff, 0xffff }, // WHITE
61 { 0, 0x0000, 0x0000, 0x0000 } // BLACK
62 };
63
64
65 /* Function responsible for updating the exposed area.
66 * It must call processTrace() to ask for this update.
67 * Note : this function cannot clear the background, because it may
68 * erase drawing already present (SAFETY).
69 */
70 void drawing_data_request(Drawing_t *drawing,
71 GdkPixmap **pixmap,
72 gint x, gint y,
73 gint width,
74 gint height)
75 {
76 if(width < 0) return ;
77 if(height < 0) return ;
78 ControlFlowData *control_flow_data =
79 (ControlFlowData*)g_object_get_data(
80 G_OBJECT(
81 drawing->drawing_area),
82 "control_flow_data");
83
84 LttTime start, end;
85 LttTime window_end = ltt_time_add(control_flow_data->time_window.time_width,
86 control_flow_data->time_window.start_time);
87
88 g_critical("req : window_end : %u, %u", window_end.tv_sec,
89 window_end.tv_nsec);
90
91 g_critical("req : time width : %u, %u", control_flow_data->time_window.time_width.tv_sec,
92 control_flow_data->time_window.time_width.tv_nsec);
93
94 g_critical("x is : %i, x+width is : %i", x, x+width);
95
96 convert_pixels_to_time(drawing->drawing_area->allocation.width, x,
97 &control_flow_data->time_window.start_time,
98 &window_end,
99 &start);
100
101 convert_pixels_to_time(drawing->drawing_area->allocation.width, x + width,
102 &control_flow_data->time_window.start_time,
103 &window_end,
104 &end);
105
106 LttvTracesetContext * tsc =
107 get_traceset_context(control_flow_data->mw);
108
109 //send_test_process(
110 //guicontrolflow_get_process_list(drawing->control_flow_data),
111 //drawing);
112 //send_test_drawing(
113 //guicontrolflow_get_process_list(drawing->control_flow_data),
114 //drawing, *pixmap, x, y, width, height);
115
116 // Let's call processTrace() !!
117 EventRequest event_request; // Variable freed at the end of the function.
118 event_request.control_flow_data = control_flow_data;
119 event_request.time_begin = start;
120 event_request.time_end = end;
121 event_request.x_begin = x;
122 event_request.x_end = x+width;
123
124 g_critical("req : start : %u, %u", event_request.time_begin.tv_sec,
125 event_request.time_begin.tv_nsec);
126
127 g_critical("req : end : %u, %u", event_request.time_end.tv_sec,
128 event_request.time_end.tv_nsec);
129
130 LttvHooks *event = lttv_hooks_new();
131 LttvHooks *after_event = lttv_hooks_new();
132 LttvHooks *after_traceset = lttv_hooks_new();
133 lttv_hooks_add(after_traceset, after_data_request, &event_request);
134 lttv_hooks_add(event, draw_event_hook, &event_request);
135 //Modified by xiangxiu: state update hooks are added by the main window
136 //state_add_event_hooks_api(control_flow_data->mw);
137 lttv_hooks_add(after_event, draw_after_hook, &event_request);
138
139 lttv_process_traceset_seek_time(tsc, start);
140 // FIXME : would like to place the after_traceset hook after the traceset,
141 // but the traceset context state is not valid anymore.
142 lttv_traceset_context_add_hooks(tsc,
143 // NULL, after_traceset, NULL, NULL, NULL, NULL,
144 NULL, NULL, NULL, NULL, NULL, NULL,
145 NULL, after_traceset, NULL, event, after_event);
146 lttv_process_traceset(tsc, end, G_MAXULONG);
147 //after_data_request((void*)&event_request,(void*)tsc);
148 lttv_traceset_context_remove_hooks(tsc,
149 //NULL, after_traceset, NULL, NULL, NULL, NULL,
150 NULL, NULL, NULL, NULL, NULL, NULL,
151 NULL, after_traceset, NULL, event, after_event);
152 //Modified by xiangxiu: state update hooks are removed by the main window
153 //state_remove_event_hooks_api(control_flow_data->mw);
154
155 lttv_hooks_destroy(after_traceset);
156 lttv_hooks_destroy(event);
157 lttv_hooks_destroy(after_event);
158
159
160 }
161
162 /* Callbacks */
163
164
165 /* Create a new backing pixmap of the appropriate size */
166 /* As the scaling will always change, it's of no use to copy old
167 * pixmap.
168 */
169 static gboolean
170 configure_event( GtkWidget *widget, GdkEventConfigure *event,
171 gpointer user_data)
172 {
173 Drawing_t *drawing = (Drawing_t*)user_data;
174
175
176 /* First, get the new time interval of the main window */
177 /* we assume (see documentation) that the main window
178 * has updated the time interval before this configure gets
179 * executed.
180 */
181 get_time_window(drawing->control_flow_data->mw,
182 &drawing->control_flow_data->time_window);
183
184 /* New pixmap, size of the configure event */
185 //GdkPixmap *pixmap = gdk_pixmap_new(widget->window,
186 // widget->allocation.width + SAFETY,
187 // widget->allocation.height + SAFETY,
188 // -1);
189
190 g_critical("drawing configure event");
191 g_critical("New draw size : %i by %i",widget->allocation.width, widget->allocation.height);
192
193
194 if (drawing->pixmap)
195 gdk_pixmap_unref(drawing->pixmap);
196
197 /* If no old pixmap present */
198 //if(drawing->pixmap == NULL)
199 {
200 drawing->pixmap = gdk_pixmap_new(
201 widget->window,
202 widget->allocation.width + SAFETY,
203 widget->allocation.height + SAFETY,
204 //ProcessList_get_height
205 // (GuiControlFlow_get_process_list(drawing->control_flow_data)),
206 -1);
207 drawing->width = widget->allocation.width;
208 drawing->height = widget->allocation.height;
209
210
211 // Clear the image
212 gdk_draw_rectangle (drawing->pixmap,
213 widget->style->black_gc,
214 TRUE,
215 0, 0,
216 widget->allocation.width+SAFETY,
217 widget->allocation.height+SAFETY);
218
219 //g_info("init data request");
220
221
222 /* Initial data request */
223 // Do not need to ask for data of 1 pixel : not synchronized with
224 // main window time at this moment.
225 drawing_data_request(drawing, &drawing->pixmap, 0, 0,
226 widget->allocation.width,
227 widget->allocation.height);
228
229 drawing->width = widget->allocation.width;
230 drawing->height = widget->allocation.height;
231
232 return TRUE;
233
234
235
236 }
237 #ifdef NOTUSE
238 // /* Draw empty background */
239 // gdk_draw_rectangle (pixmap,
240 // widget->style->black_gc,
241 // TRUE,
242 // 0, 0,
243 // widget->allocation.width,
244 // widget->allocation.height);
245
246 /* Copy old data to new pixmap */
247 gdk_draw_drawable (pixmap,
248 widget->style->black_gc,
249 drawing->pixmap,
250 0, 0,
251 0, 0,
252 -1, -1);
253
254 if (drawing->pixmap)
255 gdk_pixmap_unref(drawing->pixmap);
256
257 drawing->pixmap = pixmap;
258
259 // Clear the bottom part of the image (SAFETY)
260 gdk_draw_rectangle (pixmap,
261 widget->style->black_gc,
262 TRUE,
263 0, drawing->height+SAFETY,
264 drawing->width+SAFETY, // do not overlap
265 (widget->allocation.height) - drawing->height);
266
267 // Clear the right part of the image (SAFETY)
268 gdk_draw_rectangle (pixmap,
269 widget->style->black_gc,
270 TRUE,
271 drawing->width+SAFETY, 0,
272 (widget->allocation.width) - drawing->width, // do not overlap
273 drawing->height+SAFETY);
274
275 /* Clear the backgound for data request, but not SAFETY */
276 gdk_draw_rectangle (pixmap,
277 drawing->drawing_area->style->black_gc,
278 TRUE,
279 drawing->width + SAFETY, 0,
280 widget->allocation.width - drawing->width, // do not overlap
281 widget->allocation.height+SAFETY);
282
283 /* Request data for missing space */
284 g_info("missing data request");
285 drawing_data_request(drawing, &pixmap, drawing->width, 0,
286 widget->allocation.width - drawing->width,
287 widget->allocation.height);
288
289 drawing->width = widget->allocation.width;
290 drawing->height = widget->allocation.height;
291
292 return TRUE;
293 #endif //NOTUSE
294 }
295
296
297 /* Redraw the screen from the backing pixmap */
298 static gboolean
299 expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
300 {
301 Drawing_t *drawing = (Drawing_t*)user_data;
302 ControlFlowData *control_flow_data =
303 (ControlFlowData*)g_object_get_data(
304 G_OBJECT(widget),
305 "control_flow_data");
306
307 g_critical("drawing expose event");
308
309 guint x=0;
310 LttTime* current_time =
311 guicontrolflow_get_current_time(control_flow_data);
312
313 LttTime window_end = ltt_time_add(control_flow_data->time_window.time_width,
314 control_flow_data->time_window.start_time);
315
316 convert_time_to_pixels(
317 control_flow_data->time_window.start_time,
318 window_end,
319 *current_time,
320 widget->allocation.width,
321 &x);
322
323 gdk_draw_pixmap(widget->window,
324 widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
325 drawing->pixmap,
326 event->area.x, event->area.y,
327 event->area.x, event->area.y,
328 event->area.width, event->area.height);
329
330 if(x >= event->area.x && x <= event->area.x+event->area.width)
331 {
332 gint8 dash_list[] = { 1, 2 };
333 GdkGC *gc = gdk_gc_new(control_flow_data->drawing->pixmap);
334 gdk_gc_copy(gc, widget->style->white_gc);
335 gdk_gc_set_line_attributes(gc,
336 1,
337 GDK_LINE_ON_OFF_DASH,
338 GDK_CAP_BUTT,
339 GDK_JOIN_MITER);
340 gdk_gc_set_dashes(gc,
341 0,
342 dash_list,
343 2);
344 drawing_draw_line(NULL, widget->window,
345 x, event->area.y,
346 x, event->area.y+event->area.height,
347 gc);
348 gdk_gc_unref(gc);
349 }
350 return FALSE;
351 }
352
353 /* mouse click */
354 static gboolean
355 button_press_event( GtkWidget *widget, GdkEventButton *event, gpointer user_data )
356 {
357 ControlFlowData *control_flow_data =
358 (ControlFlowData*)g_object_get_data(
359 G_OBJECT(widget),
360 "control_flow_data");
361 Drawing_t *drawing = control_flow_data->drawing;
362
363
364 g_critical("click");
365 if(event->button == 1)
366 {
367 LttTime time;
368
369 LttTime window_end = ltt_time_add(control_flow_data->time_window.time_width,
370 control_flow_data->time_window.start_time);
371
372
373 /* left mouse button click */
374 g_critical("x click is : %f", event->x);
375
376 convert_pixels_to_time(widget->allocation.width, (guint)event->x,
377 &control_flow_data->time_window.start_time,
378 &window_end,
379 &time);
380
381 set_current_time(control_flow_data->mw, &time);
382
383 }
384
385 return FALSE;
386 }
387
388
389
390
391 Drawing_t *drawing_construct(ControlFlowData *control_flow_data)
392 {
393 Drawing_t *drawing = g_new(Drawing_t, 1);
394
395 drawing->control_flow_data = control_flow_data;
396
397 drawing->vbox = gtk_vbox_new(FALSE, 1);
398
399 drawing->ruler = gtk_drawing_area_new ();
400 gtk_widget_set_size_request(drawing->ruler, -1, 27);
401
402
403 drawing->drawing_area = gtk_drawing_area_new ();
404
405 gtk_box_pack_start(GTK_BOX(drawing->vbox), drawing->ruler,
406 FALSE, FALSE, 0);
407 //g_object_unref(G_OBJECT(drawing->ruler));
408 gtk_box_pack_end(GTK_BOX(drawing->vbox), drawing->drawing_area,
409 TRUE, TRUE, 0);
410 //g_object_unref(G_OBJECT(drawing->drawing_area));
411
412 drawing->pango_layout =
413 gtk_widget_create_pango_layout(drawing->drawing_area, NULL);
414
415 //gtk_widget_set_size_request(drawing->drawing_area->window, 50, 50);
416 g_object_set_data_full(
417 G_OBJECT(drawing->drawing_area),
418 "Link_drawing_Data",
419 drawing,
420 (GDestroyNotify)drawing_destroy);
421
422 g_object_set_data(
423 G_OBJECT(drawing->ruler),
424 "drawing",
425 drawing);
426
427
428 //gtk_widget_modify_bg( drawing->drawing_area,
429 // GTK_STATE_NORMAL,
430 // &CF_Colors[BLACK]);
431
432 //gdk_window_get_geometry(drawing->drawing_area->window,
433 // NULL, NULL,
434 // &(drawing->width),
435 // &(drawing->height),
436 // -1);
437
438 //drawing->pixmap = gdk_pixmap_new(
439 // drawing->drawing_area->window,
440 // drawing->width,
441 // drawing->height,
442 // drawing->depth);
443
444 drawing->pixmap = NULL;
445
446 // drawing->pixmap = gdk_pixmap_new(drawing->drawing_area->window,
447 // drawing->drawing_area->allocation.width,
448 // drawing->drawing_area->allocation.height,
449 // -1);
450
451 gtk_widget_add_events(drawing->drawing_area, GDK_BUTTON_PRESS_MASK);
452
453 g_signal_connect (G_OBJECT(drawing->drawing_area),
454 "configure_event",
455 G_CALLBACK (configure_event),
456 (gpointer)drawing);
457
458 g_signal_connect (G_OBJECT(drawing->ruler),
459 "expose_event",
460 G_CALLBACK(expose_ruler),
461 (gpointer)drawing);
462
463 g_signal_connect (G_OBJECT(drawing->drawing_area),
464 "expose_event",
465 G_CALLBACK (expose_event),
466 (gpointer)drawing);
467
468 g_signal_connect (G_OBJECT(drawing->drawing_area),
469 "button-press-event",
470 G_CALLBACK (button_press_event),
471 (gpointer)drawing);
472
473 gtk_widget_show(drawing->ruler);
474 gtk_widget_show(drawing->drawing_area);
475
476
477 return drawing;
478 }
479
480 void drawing_destroy(Drawing_t *drawing)
481 {
482
483 // Do not unref here, Drawing_t destroyed by it's widget.
484 //g_object_unref( G_OBJECT(drawing->drawing_area));
485
486 g_free(drawing->pango_layout);
487 g_free(drawing);
488 }
489
490 GtkWidget *drawing_get_drawing_area(Drawing_t *drawing)
491 {
492 return drawing->drawing_area;
493 }
494
495 GtkWidget *drawing_get_widget(Drawing_t *drawing)
496 {
497 return drawing->vbox;
498 }
499
500 /* convert_pixels_to_time
501 *
502 * Convert from window pixel and time interval to an absolute time.
503 */
504 void convert_pixels_to_time(
505 gint width,
506 guint x,
507 LttTime *window_time_begin,
508 LttTime *window_time_end,
509 LttTime *time)
510 {
511 LttTime window_time_interval;
512
513 window_time_interval = ltt_time_sub(*window_time_end,
514 *window_time_begin);
515 *time = ltt_time_mul(window_time_interval, (x/(float)width));
516 *time = ltt_time_add(*window_time_begin, *time);
517 }
518
519
520
521 void convert_time_to_pixels(
522 LttTime window_time_begin,
523 LttTime window_time_end,
524 LttTime time,
525 int width,
526 guint *x)
527 {
528 LttTime window_time_interval;
529 float interval_float, time_float;
530
531 window_time_interval = ltt_time_sub(window_time_end,window_time_begin);
532
533 time = ltt_time_sub(time, window_time_begin);
534
535 interval_float = ltt_time_to_double(window_time_interval);
536 time_float = ltt_time_to_double(time);
537
538 *x = (guint)(time_float/interval_float * width);
539
540 }
541
542 void drawing_refresh ( Drawing_t *drawing,
543 guint x, guint y,
544 guint width, guint height)
545 {
546 g_info("Drawing.c : drawing_refresh %u, %u, %u, %u", x, y, width, height);
547 GdkRectangle update_rect;
548
549 gdk_draw_drawable(
550 drawing->drawing_area->window,
551 drawing->drawing_area->
552 style->fg_gc[GTK_WIDGET_STATE (drawing->drawing_area)],
553 GDK_DRAWABLE(drawing->pixmap),
554 x, y,
555 x, y,
556 width, height);
557
558 update_rect.x = 0 ;
559 update_rect.y = 0 ;
560 update_rect.width = drawing->width;
561 update_rect.height = drawing->height ;
562 gtk_widget_draw( drawing->drawing_area, &update_rect);
563
564 }
565
566
567 void drawing_draw_line( Drawing_t *drawing,
568 GdkPixmap *pixmap,
569 guint x1, guint y1,
570 guint x2, guint y2,
571 GdkGC *GC)
572 {
573 gdk_draw_line (pixmap,
574 GC,
575 x1, y1, x2, y2);
576 }
577
578
579
580
581 void drawing_resize(Drawing_t *drawing, guint h, guint w)
582 {
583 drawing->height = h ;
584 drawing->width = w ;
585
586 gtk_widget_set_size_request ( drawing->drawing_area,
587 drawing->width,
588 drawing->height);
589
590
591 }
592
593
594 /* Insert a square corresponding to a new process in the list */
595 /* Applies to whole drawing->width */
596 void drawing_insert_square(Drawing_t *drawing,
597 guint y,
598 guint height)
599 {
600 //GdkRectangle update_rect;
601
602 /* Allocate a new pixmap with new height */
603 GdkPixmap *pixmap = gdk_pixmap_new(drawing->drawing_area->window,
604 drawing->width + SAFETY,
605 drawing->height + height + SAFETY,
606 -1);
607
608 /* Copy the high region */
609 gdk_draw_drawable (pixmap,
610 drawing->drawing_area->style->black_gc,
611 drawing->pixmap,
612 0, 0,
613 0, 0,
614 drawing->width + SAFETY, y);
615
616
617
618
619 /* add an empty square */
620 gdk_draw_rectangle (pixmap,
621 drawing->drawing_area->style->black_gc,
622 TRUE,
623 0, y,
624 drawing->width + SAFETY, // do not overlap
625 height);
626
627
628
629 /* copy the bottom of the region */
630 gdk_draw_drawable (pixmap,
631 drawing->drawing_area->style->black_gc,
632 drawing->pixmap,
633 0, y,
634 0, y + height,
635 drawing->width+SAFETY, drawing->height - y + SAFETY);
636
637
638
639
640 if (drawing->pixmap)
641 gdk_pixmap_unref(drawing->pixmap);
642
643 drawing->pixmap = pixmap;
644
645 drawing->height+=height;
646
647 /* Rectangle to update, from new drawing dimensions */
648 //update_rect.x = 0 ;
649 //update_rect.y = y ;
650 //update_rect.width = drawing->width;
651 //update_rect.height = drawing->height - y ;
652 //gtk_widget_draw( drawing->drawing_area, &update_rect);
653 }
654
655
656 /* Remove a square corresponding to a removed process in the list */
657 void drawing_remove_square(Drawing_t *drawing,
658 guint y,
659 guint height)
660 {
661 //GdkRectangle update_rect;
662
663 /* Allocate a new pixmap with new height */
664 GdkPixmap *pixmap = gdk_pixmap_new(
665 drawing->drawing_area->window,
666 drawing->width + SAFETY,
667 drawing->height - height + SAFETY,
668 -1);
669
670 /* Copy the high region */
671 gdk_draw_drawable (pixmap,
672 drawing->drawing_area->style->black_gc,
673 drawing->pixmap,
674 0, 0,
675 0, 0,
676 drawing->width + SAFETY, y);
677
678
679
680 /* Copy up the bottom of the region */
681 gdk_draw_drawable (pixmap,
682 drawing->drawing_area->style->black_gc,
683 drawing->pixmap,
684 0, y + height,
685 0, y,
686 drawing->width, drawing->height - y - height + SAFETY);
687
688
689 if (drawing->pixmap)
690 gdk_pixmap_unref(drawing->pixmap);
691
692 drawing->pixmap = pixmap;
693
694 drawing->height-=height;
695
696 /* Rectangle to update, from new drawing dimensions */
697 //update_rect.x = 0 ;
698 //update_rect.y = y ;
699 //update_rect.width = drawing->width;
700 //update_rect.height = drawing->height - y ;
701 //gtk_widget_draw( drawing->drawing_area, &update_rect);
702 }
703
704 void drawing_update_ruler(Drawing_t *drawing, TimeWindow *time_window)
705 {
706 GtkRequisition req;
707 GdkRectangle rect;
708
709 req.width = drawing->ruler->allocation.width;
710 req.height = drawing->ruler->allocation.height;
711
712
713 rect.x = 0;
714 rect.y = 0;
715 rect.width = req.width;
716 rect.height = req.height;
717
718 gtk_widget_queue_draw(drawing->ruler);
719 //gtk_widget_draw( drawing->ruler, &rect);
720 }
721
722 /* Redraw the ruler */
723 static gboolean
724 expose_ruler( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
725 {
726 Drawing_t *drawing = (Drawing_t*)user_data;
727
728 gchar text[255];
729
730 PangoContext *context;
731 PangoLayout *layout;
732 PangoAttribute *attribute;
733 PangoFontDescription *FontDesc;
734 gint Font_Size;
735 PangoRectangle ink_rect;
736 guint global_width=0;
737 GdkColor foreground = { 0, 0, 0, 0 };
738 GdkColor background = { 0, 0xffff, 0xffff, 0xffff };
739
740 LttTime window_end =
741 ltt_time_add(drawing->control_flow_data->time_window.time_width,
742 drawing->control_flow_data->time_window.start_time);
743 LttTime half_width =
744 ltt_time_div(drawing->control_flow_data->time_window.time_width,2.0);
745 LttTime window_middle =
746 ltt_time_add(half_width,
747 drawing->control_flow_data->time_window.start_time);
748 g_critical("ruler expose event");
749
750 gdk_draw_rectangle (drawing->ruler->window,
751 drawing->ruler->style->white_gc,
752 TRUE,
753 event->area.x, event->area.y,
754 event->area.width,
755 event->area.height);
756
757 GdkGC *gc = gdk_gc_new(drawing->ruler->window);
758 gdk_gc_copy(gc, drawing->ruler->style->black_gc);
759 gdk_gc_set_line_attributes(gc,
760 2,
761 GDK_LINE_SOLID,
762 GDK_CAP_BUTT,
763 GDK_JOIN_MITER);
764 gdk_draw_line (drawing->ruler->window,
765 gc,
766 event->area.x, 1,
767 event->area.x + event->area.width, 1);
768
769
770 snprintf(text, 255, "%lus\n%luns",
771 drawing->control_flow_data->time_window.start_time.tv_sec,
772 drawing->control_flow_data->time_window.start_time.tv_nsec);
773
774 layout = gtk_widget_create_pango_layout(drawing->drawing_area, NULL);
775
776 context = pango_layout_get_context(layout);
777 FontDesc = pango_context_get_font_description(context);
778
779 pango_font_description_set_size(FontDesc, 6*PANGO_SCALE);
780 pango_layout_context_changed(layout);
781
782 pango_layout_set_text(layout, text, -1);
783 pango_layout_get_pixel_extents(layout, &ink_rect, NULL);
784 global_width += ink_rect.width;
785
786 gdk_draw_layout_with_colors(drawing->ruler->window,
787 gc,
788 0,
789 6,
790 layout, &foreground, &background);
791
792 gdk_gc_set_line_attributes(gc,
793 2,
794 GDK_LINE_SOLID,
795 GDK_CAP_ROUND,
796 GDK_JOIN_ROUND);
797
798 gdk_draw_line (drawing->ruler->window,
799 gc,
800 1, 1,
801 1, 7);
802
803
804 snprintf(text, 255, "%lus\n%luns", window_end.tv_sec,
805 window_end.tv_nsec);
806
807 pango_layout_set_text(layout, text, -1);
808 pango_layout_get_pixel_extents(layout, &ink_rect, NULL);
809 global_width += ink_rect.width;
810
811 if(global_width <= drawing->ruler->allocation.width)
812 {
813 gdk_draw_layout_with_colors(drawing->ruler->window,
814 gc,
815 drawing->ruler->allocation.width - ink_rect.width,
816 6,
817 layout, &foreground, &background);
818
819 gdk_gc_set_line_attributes(gc,
820 2,
821 GDK_LINE_SOLID,
822 GDK_CAP_ROUND,
823 GDK_JOIN_ROUND);
824
825 gdk_draw_line (drawing->ruler->window,
826 gc,
827 drawing->ruler->allocation.width-1, 1,
828 drawing->ruler->allocation.width-1, 7);
829 }
830
831
832 snprintf(text, 255, "%lus\n%luns", window_middle.tv_sec,
833 window_middle.tv_nsec);
834
835 pango_layout_set_text(layout, text, -1);
836 pango_layout_get_pixel_extents(layout, &ink_rect, NULL);
837 global_width += ink_rect.width;
838
839 if(global_width <= drawing->ruler->allocation.width)
840 {
841 gdk_draw_layout_with_colors(drawing->ruler->window,
842 gc,
843 (drawing->ruler->allocation.width - ink_rect.width)/2,
844 6,
845 layout, &foreground, &background);
846
847 gdk_gc_set_line_attributes(gc,
848 2,
849 GDK_LINE_SOLID,
850 GDK_CAP_ROUND,
851 GDK_JOIN_ROUND);
852
853 gdk_draw_line (drawing->ruler->window,
854 gc,
855 drawing->ruler->allocation.width/2, 1,
856 drawing->ruler->allocation.width/2, 7);
857
858
859
860
861 }
862
863 gdk_gc_unref(gc);
864 g_object_unref(layout);
865
866 return FALSE;
867 }
868
869
This page took 0.047674 seconds and 4 git commands to generate.