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>
25 typedef struct _histo_DrawContext histo_DrawContext
;
26 typedef struct _histo_DrawInfo histo_DrawInfo
;
27 typedef struct _histo_ItemInfo histo_ItemInfo
;
29 typedef struct _histo_IconStruct histo_IconStruct
;
31 typedef struct _histo_DrawOperation histo_DrawOperation
;
34 typedef struct _histo_PropertiesText histo_PropertiesText
;
35 typedef struct _histo_PropertiesIcon histo_PropertiesIcon
;
36 typedef struct _histo_PropertiesLine histo_PropertiesLine
;
37 typedef struct _histo_PropertiesArc histo_PropertiesArc
;
38 typedef struct _histo_PropertiesBG histo_PropertiesBG
;
40 typedef enum _histo_DrawableItems histo_DrawableItems
;
41 enum _histo_DrawableItems
{
42 ITEM_TEXT
, ITEM_ICON
, ITEM_LINE
, ITEM_POINT
, ITEM_BACKGROUND
45 typedef enum _histo_RelPosX
{
49 typedef enum _histo_RelPosY
{
54 /* The DrawContext keeps information about the current drawing position and
55 * the previous one, so we can use both to draw lines.
57 * over : position for drawing over the middle line.
58 * middle : middle line position.
59 * under : position for drawing under the middle line.
61 * the modify_* are used to take into account that we should go forward
62 * when we draw a text, an arc or an icon, while it's unneeded when we
63 * draw a line or background.
65 * The modify_* positions are altered by the draw item functions.
70 struct _histo_DrawContext
{
71 GdkDrawable
*drawable
;
73 PangoLayout
*pango_layout
;
107 * Structure used to keep information about icons.
109 struct _histo_IconStruct
{
116 * The Item element is only used so the DrawOperation is modifiable by users.
117 * During drawing, only the Hook is needed.
119 struct _histo_DrawOperation
{
120 histo_DrawableItems item
;
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.
134 static int Items_Priorities
[] = {
139 10 /* ITEM_BACKGROUND */
144 * Here are the different structures describing each item type that can be
145 * drawn. They contain the information necessary to draw the item : not the
146 * position (this is provided by the DrawContext), but the text, icon name,
147 * line width, color; all the properties of the specific items.
150 struct _histo_PropertiesText
{
151 GdkColor
*foreground
;
152 GdkColor
*background
;
162 struct _histo_PropertiesIcon
{
172 struct _histo_PropertiesLine
{
179 struct _histo_PropertiesArc
{
181 gint size
; /* We force circle by width = height */
189 struct _histo_PropertiesBG
{
195 void histo_draw_item( GdkDrawable
*drawable
,
199 LttvTracefileState
*tfs
,
200 LttvIAttribute
*attributes
);
203 * The tree of attributes used to store drawing operations goes like this :
206 * "facility-event_type"
216 * So if, for example, we want to add a hook to get called each time we
217 * receive an event that is in state LTTV_STATE_SYSCALL, we put the
218 * pointer to the GArray of DrawOperation in
219 * process_states/ "name associated with LTTV_STATE_SYSCALL"
225 * The add_operation has to do a quick sort by priority to keep the operations
226 * in the right order.
228 void add_operation( LttvIAttribute
*attributes
,
230 DrawOperation
*operation
);
233 * The del_operation seeks the array present at pathname (if any) and
234 * removes the DrawOperation if present. It returns 0 on success, -1
237 gint
del_operation( LttvIAttribute
*attributes
,
239 DrawOperation
*operation
);
242 * The clean_operations removes all operations present at a pathname.
243 * returns 0 on success, -1 if it fails.
245 gint
clean_operations( LttvIAttribute
*attributes
,
250 * The list_operations gives a pointer to the operation array associated
251 * with the pathname. It will be NULL if no operation is present.
253 void list_operations( LttvIAttribute
*attributes
,
260 * exec_operation executes the operations if present in the attributes, or
261 * do nothing if not present.
263 void exec_operations( LttvIAttribute
*attributes
,
268 * Here follow the prototypes of the hook functions used to draw the
272 gboolean
histo_draw_text( void *hook_data
, void *call_data
);
273 gboolean
histo_draw_icon( void *hook_data
, void *call_data
);
274 gboolean
histo_draw_line( void *hook_data
, void *call_data
);
275 gboolean
histo_draw_arc( void *hook_data
, void *call_data
);
276 gboolean
histo_draw_bg( void *hook_data
, void *call_data
);
279 #endif // _DRAW_ITEM_H