f0d936c0 |
1 | #ifndef _DRAWING_H |
2 | #define _DRAWING_H |
3 | |
558aa013 |
4 | #include <glib.h> |
76a67e8a |
5 | #include <gdk/gdk.h> |
6 | #include <gtk/gtk.h> |
fa2c4dbe |
7 | #include <ltt/ltt.h> |
88feb618 |
8 | #include "CFV.h" |
9 | #include "Draw_Item.h" |
f0d936c0 |
10 | |
432a7065 |
11 | |
a56a1ba4 |
12 | #define SAFETY 50 // safety pixels at right and bottom of pixmap buffer |
432a7065 |
13 | |
fa2c4dbe |
14 | /* This part of the viewer does : |
76a67e8a |
15 | * Draw horizontal lines, getting graphic context as arg. |
fa2c4dbe |
16 | * Copy region of the screen into another. |
76a67e8a |
17 | * Modify the boundaries to reflect a scale change. (resize) |
847b479d |
18 | * Refresh the physical screen with the pixmap |
189a5d08 |
19 | * A helper function is provided here to convert from time to process |
fa2c4dbe |
20 | * identifier to pixels and the contrary (will be useful for mouse selection). |
5f16133f |
21 | * Insert an empty square in the drawing, moving the bottom part. |
22 | * |
189a5d08 |
23 | * Note: The last point is exactly why it would not be so easy to add the |
24 | * vertical line functionnality as in the original version of LTT. In order |
25 | * to do so, we should keep all processes in the list for the duration of |
26 | * all the trace instead of dynamically adding and removing them when we |
27 | * scroll. Another possibility is to redraw all the visible area when a new |
28 | * process is added to the list. The second solution seems more appropriate |
29 | * to me. |
30 | * |
31 | * |
5f16133f |
32 | * The pixmap used has the width of the physical window, but the height |
33 | * of the shown processes. |
fa2c4dbe |
34 | */ |
f0d936c0 |
35 | |
36 | typedef struct _Drawing_t Drawing_t; |
37 | |
f7afe191 |
38 | struct _Drawing_t { |
14963be0 |
39 | GtkWidget *drawing_area; |
b6db18f8 |
40 | GdkPixmap *pixmap; |
68997a22 |
41 | ControlFlowData *control_flow_data; |
a56a1ba4 |
42 | |
43 | PangoLayout *pango_layout; |
44 | |
45 | gint height, width, depth; |
46 | |
f7afe191 |
47 | }; |
48 | |
68997a22 |
49 | Drawing_t *drawing_construct(ControlFlowData *control_flow_data); |
501d5405 |
50 | void drawing_destroy(Drawing_t *drawing); |
f0d936c0 |
51 | |
501d5405 |
52 | GtkWidget *drawing_get_widget(Drawing_t *drawing); |
a56a1ba4 |
53 | |
501d5405 |
54 | //void drawing_Refresh ( Drawing_t *drawing, |
a56a1ba4 |
55 | // guint x, guint y, |
56 | // guint width, guint height); |
847b479d |
57 | |
501d5405 |
58 | void drawing_draw_line( Drawing_t *drawing, |
b6db18f8 |
59 | GdkPixmap *pixmap, |
a56a1ba4 |
60 | guint x1, guint y1, |
61 | guint x2, guint y2, |
62 | GdkGC *GC); |
76a67e8a |
63 | |
501d5405 |
64 | //void drawing_copy( Drawing_t *drawing, |
a56a1ba4 |
65 | // guint xsrc, guint ysrc, |
66 | // guint xdest, guint ydest, |
67 | // guint width, guint height); |
f0d936c0 |
68 | |
5f16133f |
69 | /* Insert a square corresponding to a new process in the list */ |
501d5405 |
70 | void drawing_insert_square(Drawing_t *drawing, |
a56a1ba4 |
71 | guint y, |
72 | guint height); |
5f16133f |
73 | |
74 | /* Remove a square corresponding to a removed process in the list */ |
501d5405 |
75 | void drawing_remove_square(Drawing_t *drawing, |
a56a1ba4 |
76 | guint y, |
77 | guint height); |
5f16133f |
78 | |
f0d936c0 |
79 | |
501d5405 |
80 | //void drawing_Resize(Drawing_t *drawing, guint h, guint w); |
76a67e8a |
81 | |
fa2c4dbe |
82 | void convert_pixels_to_time( |
a56a1ba4 |
83 | gint width, |
84 | guint x, |
85 | LttTime *window_time_begin, |
86 | LttTime *window_time_end, |
87 | LttTime *time); |
fa2c4dbe |
88 | |
89 | void convert_time_to_pixels( |
a56a1ba4 |
90 | LttTime window_time_begin, |
91 | LttTime window_time_end, |
92 | LttTime time, |
93 | gint width, |
94 | guint *x); |
f0d936c0 |
95 | |
f0d936c0 |
96 | #endif // _DRAWING_H |