guiControlFlow Process List completed
[lttv.git] / ltt / branches / poly / lttv / modules / guiControlFlow / Drawing.c
1
2 #include "Drawing.h"
3
4 /*****************************************************************************
5 * Drawing functions *
6 *****************************************************************************/
7
8 typedef enum
9 {
10 RED,
11 GREEN,
12 BLUE,
13 WHITE,
14 BLACK
15
16 } ControlFlowColors;
17
18 /* Vector of unallocated colors */
19 static GdkColor CF_Colors [] =
20 {
21 { 0, 0xffff, 0x0000, 0x0000 }, // RED
22 { 0, 0x0000, 0xffff, 0x0000 }, // GREEN
23 { 0, 0x0000, 0x0000, 0xffff }, // BLUE
24 { 0, 0xffff, 0xffff, 0xffff }, // WHITE
25 { 0, 0x0000, 0x0000, 0x0000 } // BLACK
26 };
27
28
29 typedef struct _Drawing_t {
30 GtkWidget *Drawing_Area_V
31
32 guint height, width;
33
34 } Drawing_t;
35
36
37 Drawing_t *Drawing(void)
38 {
39
40 Drawing_t Drawing = g_new(Drawing_t, 1);
41
42 Drawing->Drawing_Area_V = gtk_drawing_area_new ();
43
44 g_object_set_data_full(
45 G_OBJECT(Drawing->Drawing_Area_V),
46 "Drawing_Data",
47 Drawing,
48 (GDestroyNotify)Drawing_destroy);
49
50 gtk_widget_modify_bg( Control_Flow_Data->Drawing_Area_V,
51 GTK_STATE_NORMAL,
52 &CF_Colors[BLACK]);
53
54
55 return Drawing;
56 }
57
58 void Drawing_destroy(Drawing_t *Drawing)
59 {
60
61 g_object_unref( G_OBJECT(Drawing->Drawing_Area_V));
62
63 g_free(Drawing);
64 }
65
66 /* get_time_from_pixels
67 *
68 * Get the time interval from window time and pixels, and pixels requested. This
69 * function uses TimeMul, which should only be used if the float value is lower
70 * that 4, and here it's always lower than 1, so it's ok.
71 */
72 void convert_pixels_to_time(
73 Drawing_t *Drawing,
74 guint x,
75 LttTime *window_time_begin,
76 LttTime *window_time_end,
77 LttTime *time,
78 );
79 {
80 LttTime window_time_interval;
81
82 TimeSub(window_time_interval, *window_time_end, window_time_begin);
83
84
85 TimeMul(*time, window_time_interval,
86 (x/(float)Drawing->width));
87 TimeAdd(*time, window_time_begin, *time);
88
89 }
90
91
92
93 void convert_time_to_pixels(
94 LttTime window_time_begin,
95 LttTime window_time_end,
96 LttTime time,
97 Drawing_t *Drawing,
98 guint *x,
99 )
100 {
101 LttTime window_time_interval;
102
103 TimeSub(window_time_interval, window_time_end, window_time_begin);
104
105 TimeSub(time, time, wimdow_time_begin);
106
107 *x = (guint)((time/(float)window_time_interval) * Drawing->width);
108
109 }
110
111
112
113 void Drawing_Resize(Drawing_t *Drawing, guint h, guint, w)
114 {
115 guint w;
116
117 Drawing->height = h ;
118 Drawing->weight = w ;
119
120 gtk_widget_set_size_request ( Control_Flow_Data->Drawing_Area_V,
121 Drawing->weight,
122 Drawing->height);
123
124
125 }
126
127
128
This page took 0.032548 seconds and 4 git commands to generate.