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