From cf6cb7e0d0462bba8b38d00adc593c0107b79f37 Mon Sep 17 00:00:00 2001 From: compudj Date: Mon, 13 Oct 2003 18:30:08 +0000 Subject: [PATCH] draw item : generic way to draw something on a drawable, architecture description git-svn-id: http://ltt.polymtl.ca/svn@301 04897980-b3bd-0310-b5e0-8ef037075253 --- .../lttv/modules/guiControlFlow/Draw_Item.c | 46 +++++++++++++++++++ .../lttv/modules/guiControlFlow/Drawing.h | 2 +- .../lttv/modules/guiControlFlow/Event_Hooks.c | 28 ++++++++++- 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.c diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.c b/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.c new file mode 100644 index 00000000..1c89f701 --- /dev/null +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.c @@ -0,0 +1,46 @@ +/****************************************************************************** + * Draw_Item.c + * + * This file contains methods responsible for drawing a generic type of data + * in a drawable. Doing this generically will permit user defined drawing + * behavior in a later time. + * + * We keep each data type in a hash table, as this container suits the + * best the information we receive (GQuark). + * (A hash table for facilities, pointing to an array per facility, containing + * event_number events.) + * (hash tables for cpus, for process state, for execution mode and submode). + * The goal is then to provide a generic way to print information on the + * screen for all this different information. + * + * Information can be printed as + * + * - text (text + color + size + position (over or under line) + * - icon (icon filename, corresponding to a loaded icon, accessible through + * a GQuark. Icons are loaded statically at the guiControlFlow level during + * module initialization and can be added on the fly if not present in the + * GQuark.) The habitual place for xpm icons is in + * ${prefix}/share/LinuxTraceToolkit.) + position (over or under line) + * - line (color, width, style) + * - point (color, size) + * - background color (color) + * + * Each item has an array of pointers to operation structures, which define + * the information type selector. We seek the array each time we want to + * draw an item. We execute each operation in order, casting to the right + * operation type corresponding to the information type selector. + * + * The array has to be sorted by priority each time we add a task in it. + * A priority is associated with each information type selector. It permits + * to perform background color selection before line or text drawing. We also + * draw lines before text, so the text appears over the lines. + * + * Executing all the arrays of operations for a specific event (which + * implies information for state, event, cpu, execution mode and submode) + * has to be done in a same DrawContext. The goal there is to keep the offset + * of the text and icons over and under the middle line, so a specific + * event could be printed as ( R Si 0 for running, scheduled in, cpu 0 ), + * text being easy to replace with icons. + * + * Author : Mathieu Desnoyers, October 2003 + */ diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h b/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h index 35402149..418f6885 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h @@ -23,7 +23,7 @@ typedef struct _Drawing_t Drawing_t; -//FIXME : TEMPORARILY FOR GC !! +//FIXME : TEMPORARILY PLACED HERE FOR GC !! struct _Drawing_t { GtkWidget *Drawing_Area_V; GdkPixmap *Pixmap; diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.c b/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.c index 12cf5c4d..3c0f6e81 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.c @@ -3,10 +3,13 @@ *****************************************************************************/ +//#define PANGO_ENABLE_BACKEND #include #include #include +//#include + #include #include @@ -30,7 +33,22 @@ void send_test_drawing(ProcessList *Process_List, ProcessInfo Process_Info = {10000, 12000, 55600}; //ProcessInfo Process_Info = {156, 14000, 55500}; GtkTreeRowReference *got_RowRef; + PangoContext *context; + PangoLayout *layout; + PangoFontDescription *FontDesc;// = pango_font_description_new(); + gint Font_Size; + + /* Sent text data */ + layout = gtk_widget_create_pango_layout(Drawing->Drawing_Area_V, + NULL); + context = pango_layout_get_context(layout); + FontDesc = pango_context_get_font_description(context); + Font_Size = pango_font_description_get_size(FontDesc); + pango_font_description_set_size(FontDesc, Font_Size-3*PANGO_SCALE); + + + LttTime birth; birth.tv_sec = 12000; birth.tv_nsec = 55500; @@ -47,6 +65,10 @@ void send_test_drawing(ProcessList *Process_List, y+(height/2), x + width, y+(height/2), Drawing->Drawing_Area_V->style->black_gc); + pango_layout_set_text(layout, "Test", -1); + gdk_draw_layout(Pixmap, Drawing->Drawing_Area_V->style->black_gc, + 0, y+height, layout); + birth.tv_sec = 14000; birth.tv_nsec = 55500; @@ -118,7 +140,11 @@ void send_test_drawing(ProcessList *Process_List, Drawing->Drawing_Area_V->style->black_gc); g_critical("y : %u, height : %u", y, height); - + + + pango_font_description_set_size(FontDesc, Font_Size); + g_free(layout); + //g_free(context); } void send_test_process(ProcessList *Process_List, Drawing_t *Drawing) -- 2.34.1