1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Mathieu Desnoyers
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;
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.
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,
23 #include <lttv/state.h>
24 #include <lttv/hook.h>
26 typedef struct _DrawContext DrawContext
;
27 typedef struct _DrawInfo DrawInfo
;
28 typedef struct _ItemInfo ItemInfo
;
30 typedef struct _IconStruct IconStruct
;
32 typedef struct _DrawOperation DrawOperation
;
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
;
41 typedef enum _DrawableItems DrawableItems
;
43 ITEM_TEXT
, ITEM_ICON
, ITEM_LINE
, ITEM_POINT
, ITEM_BACKGROUND
46 typedef enum _RelPosX
{
50 typedef enum _RelPosY
{
55 /* The DrawContext keeps information about the current drawing position and
56 * the previous one, so we can use both to draw lines.
58 * over : position for drawing over the middle line.
59 * middle : middle line position.
60 * under : position for drawing under the middle line.
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.
66 * The modify_* positions are altered by the draw item functions.
72 GdkDrawable
*drawable
;
74 PangoLayout
*pango_layout
;
108 * Structure used to keep information about icons.
117 * The Item element is only used so the DrawOperation is modifiable by users.
118 * During drawing, only the Hook is needed.
120 struct _DrawOperation
{
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.
135 static int Items_Priorities
[] = {
140 10 /* ITEM_BACKGROUND */
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.
151 struct _PropertiesText
{
152 GdkColor
*foreground
;
153 GdkColor
*background
;
163 struct _PropertiesIcon
{
173 struct _PropertiesLine
{
180 struct _PropertiesArc
{
182 gint size
; /* We force circle by width = height */
190 struct _PropertiesBG
{
196 void draw_item( GdkDrawable
*drawable
,
200 LttvTracefileState
*tfs
,
201 LttvIAttribute
*attributes
);
204 * The tree of attributes used to store drawing operations goes like this :
207 * "facility-event_type"
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"
226 * The add_operation has to do a quick sort by priority to keep the operations
227 * in the right order.
229 void add_operation( LttvIAttribute
*attributes
,
231 DrawOperation
*operation
);
234 * The del_operation seeks the array present at pathname (if any) and
235 * removes the DrawOperation if present. It returns 0 on success, -1
238 gint
del_operation( LttvIAttribute
*attributes
,
240 DrawOperation
*operation
);
243 * The clean_operations removes all operations present at a pathname.
244 * returns 0 on success, -1 if it fails.
246 gint
clean_operations( LttvIAttribute
*attributes
,
251 * The list_operations gives a pointer to the operation array associated
252 * with the pathname. It will be NULL if no operation is present.
254 void list_operations( LttvIAttribute
*attributes
,
261 * exec_operation executes the operations if present in the attributes, or
262 * do nothing if not present.
264 void exec_operations( LttvIAttribute
*attributes
,
269 * Here follow the prototypes of the hook functions used to draw the
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
);
280 #endif // _DRAW_ITEM_H