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