file names mod part 2
[lttv.git] / ltt / branches / poly / lttv / modules / gui / ControlFlow / drawitem.h
1 #ifndef _DRAW_ITEM_H
2 #define _DRAW_ITEM_H
3
4 #include <lttv/state.h>
5
6 typedef struct _DrawContext DrawContext;
7 typedef struct _DrawInfo DrawInfo;
8 typedef struct _ItemInfo ItemInfo;
9
10 typedef struct _IconStruct IconStruct;
11
12 typedef struct _DrawOperation DrawOperation;
13
14
15 typedef struct _PropertiesText PropertiesText;
16 typedef struct _PropertiesIcon PropertiesIcon;
17 typedef struct _PropertiesLine PropertiesLine;
18 typedef struct _PropertiesArc PropertiesArc;
19 typedef struct _PropertiesBG PropertiesBG;
20
21 typedef enum _DrawableItems DrawableItems;
22 enum _DrawableItems {
23 ITEM_TEXT, ITEM_ICON, ITEM_LINE, ITEM_POINT, ITEM_BACKGROUND
24 };
25
26
27 typedef enum _RelPos {
28 OVER, MIDDLE, UNDER
29 } RelPos;
30
31
32 /* The DrawContext keeps information about the current drawing position and
33 * the previous one, so we can use both to draw lines.
34 *
35 * over : position for drawing over the middle line.
36 * middle : middle line position.
37 * under : position for drawing under the middle line.
38 *
39 * the modify_* are used to take into account that we should go forward
40 * when we draw a text, an arc or an icon, while it's unneeded when we
41 * draw a line or background.
42 *
43 */
44
45
46 struct _DrawContext {
47 GdkDrawable *drawable;
48 GdkGC *gc;
49 PangoLayout *pango_layout;
50
51 DrawInfo *current;
52 DrawInfo *previous;
53 };
54
55 /* LttvExecutionState is accessible through the LttvTracefileState. Is has
56 * a pointer to the LttvProcessState which points to the top of stack
57 * execution state : LttvExecutionState *state.
58 *
59 * LttvExecutionState contains (useful here):
60 * LttvExecutionMode t,
61 * LttvExecutionSubmode n,
62 * LttvProcessStatus s
63 *
64 *
65 * LttvTraceState will be used in the case we need the string of the
66 * different processes, eventtype_names, syscall_names, trap_names, irq_names.
67 *
68 * LttvTracefileState also gives the cpu_name and, as it herits from
69 * LttvTracefileContext, it gives the LttEvent structure, which is needed
70 * to get facility name and event name.
71 */
72 struct _DrawInfo {
73 ItemInfo *over;
74 ItemInfo *middle;
75 ItemInfo *under;
76
77 ItemInfo *modify_over;
78 ItemInfo *modify_middle;
79 ItemInfo *modify_under;
80 LttvProcessStatus status;
81 };
82
83 struct _ItemInfo {
84 gint x, y;
85 };
86
87 /*
88 * Structure used to keep information about icons.
89 */
90 struct _IconStruct {
91 GdkPixmap *pixmap;
92 GdkBitmap *mask;
93 };
94
95
96 /*
97 * The Item element is only used so the DrawOperation is modifiable by users.
98 * During drawing, only the Hook is needed.
99 */
100 struct _DrawOperation {
101 DrawableItems item;
102 LttvHooks *hook;
103 };
104
105 /*
106 * We define here each items that can be drawn, together with their
107 * associated priority. Many item types can have the same priority,
108 * it's only used for quicksorting the operations when we add a new one
109 * to the array of operations to perform. Lower priorities are executed
110 * first. So, for example, we may want to give background color a value
111 * of 10 while a line would have 20, so the background color, which
112 * is in fact a rectangle, does not hide the line.
113 */
114
115 static int Items_Priorities[] = {
116 50, /* ITEM_TEXT */
117 40, /* ITEM_ICON */
118 20, /* ITEM_LINE */
119 30, /* ITEM_POINT */
120 10 /* ITEM_BACKGROUND */
121 };
122
123 /*
124 * Here are the different structures describing each item type that can be
125 * drawn. They contain the information necessary to draw the item : not the
126 * position (this is provided by the DrawContext), but the text, icon name,
127 * line width, color; all the properties of the specific items.
128 */
129
130 struct _PropertiesText {
131 GdkColor *foreground;
132 GdkColor *background;
133 gint size;
134 gchar *text;
135 RelPos position;
136 };
137
138
139 struct _PropertiesIcon {
140 gchar *icon_name;
141 gint width;
142 gint height;
143 RelPos position;
144 };
145
146 struct _PropertiesLine {
147 GdkColor *color;
148 gint line_width;
149 GdkLineStyle style;
150 RelPos position;
151 };
152
153 struct _PropertiesArc {
154 GdkColor *color;
155 gint size; /* We force circle by width = height */
156 gboolean filled;
157 RelPos position;
158 };
159
160 struct _PropertiesBG {
161 GdkColor *color;
162 };
163
164
165
166 void draw_item( GdkDrawable *drawable,
167 gint x,
168 gint y,
169 LttvTraceState *ts,
170 LttvTracefileState *tfs,
171 LttvIAttribute *attributes);
172
173 /*
174 * The tree of attributes used to store drawing operations goes like this :
175 *
176 * event_types/
177 * "facility-event_type"
178 * cpus/
179 * "cpu name"
180 * mode_types/
181 * "execution mode"/
182 * submodes/
183 * "submode"
184 * process_states/
185 * "state name"
186 *
187 * So if, for example, we want to add a hook to get called each time we
188 * receive an event that is in state LTTV_STATE_SYSCALL, we put the
189 * pointer to the GArray of DrawOperation in
190 * process_states/ "name associated with LTTV_STATE_SYSCALL"
191 */
192
193 /*
194 * The add_operation has to do a quick sort by priority to keep the operations
195 * in the right order.
196 */
197 void add_operation( LttvIAttribute *attributes,
198 gchar *pathname,
199 DrawOperation *operation);
200
201 /*
202 * The del_operation seeks the array present at pathname (if any) and
203 * removes the DrawOperation if present. It returns 0 on success, -1
204 * if it fails.
205 */
206 gint del_operation( LttvIAttribute *attributes,
207 gchar *pathname,
208 DrawOperation *operation);
209
210 /*
211 * The clean_operations removes all operations present at a pathname.
212 * returns 0 on success, -1 if it fails.
213 */
214 gint clean_operations( LttvIAttribute *attributes,
215 gchar *pathname );
216
217
218 /*
219 * The list_operations gives a pointer to the operation array associated
220 * with the pathname. It will be NULL if no operation is present.
221 */
222 void list_operations( LttvIAttribute *attributes,
223 gchar *pathname,
224 GArray **operation);
225
226
227
228 /*
229 * exec_operation executes the operations if present in the attributes, or
230 * do nothing if not present.
231 */
232 void exec_operations( LttvIAttribute *attributes,
233 gchar *pathname);
234
235
236 /*
237 * Functions to create Properties structures.
238 */
239
240 PropertiesText *properties_text_create(
241 GdkColor *foreground,
242 GdkColor *background,
243 gint size,
244 gchar *text,
245 RelPos position);
246
247 PropertiesIcon *properties_icon_create(
248 gchar *icon_name,
249 gint width,
250 gint height,
251 RelPos position);
252
253 PropertiesLine *properties_line_create(
254 GdkColor *color,
255 gint line_width,
256 GdkLineStyle style,
257 RelPos position);
258
259 PropertiesArc *properties_arc_create(
260 GdkColor *color,
261 gint size,
262 gboolean filled,
263 RelPos position);
264
265 PropertiesBG *properties_bg_create(
266 GdkColor *color);
267
268
269
270
271 /*
272 * Here follow the prototypes of the hook functions used to draw the
273 * different items.
274 */
275
276 gboolean draw_text( void *hook_data, void *call_data);
277 gboolean draw_icon( void *hook_data, void *call_data);
278 gboolean draw_line( void *hook_data, void *call_data);
279 gboolean draw_arc( void *hook_data, void *call_data);
280 gboolean draw_bg( void *hook_data, void *call_data);
281
282
283 #endif // _DRAW_ITEM_H
This page took 0.035046 seconds and 4 git commands to generate.