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