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