continuous
[lttv.git] / ltt / branches / poly / lttv / modules / guiControlFlow / Draw_Item.c
index 70befcc4005a93308be4a29faefaa5d7cf41a4d3..c73aee01c26dadb26e7a64e8f081382d1ecb91f9 100644 (file)
 
 #define MAX_PATH_LEN 256
 
-/* The DrawContext keeps information about the current drawing position and
- * the previous one, so we can use both to draw lines.
- *
- * over : position for drawing over the middle line.
- * middle : middle line position.
- * under : position for drawing under the middle line.
- *
- * the modify_* are used to take into account that we should go forward
- * when we draw a text, an arc or an icon, while it's unneeded when we
- * draw a line or background.
- *
- */
-struct _DrawContext {
-       GdkDrawable     *drawable;
-       GdkGC           *gc;
-       
-
-       DrawInfo        *Current;
-       DrawInfo        *Previous;
-};
-
-struct _DrawInfo {
-       ItemInfo        *over;
-       ItemInfo        *middle;
-       ItemInfo        *under;
-       
-       ItemInfo        *modify_over;
-       ItemInfo        *modify_middle;
-       ItemInfo        *modify_under;
-};
-
-/* LttvExecutionState is accessible through the LttvTracefileState. Is has
- * a pointer to the LttvProcessState which points to the top of stack
- * execution state : LttvExecutionState *state.
- *
- * LttvExecutionState contains (useful here):
- * LttvExecutionMode t,
- * LttvExecutionSubmode n,
- * LttvProcessStatus s
- * 
- *
- * LttvTraceState will be used in the case we need the string of the
- * different processes, eventtype_names, syscall_names, trap_names, irq_names.
- *
- * LttvTracefileState also gives the cpu_name and, as it herits from
- * LttvTracefileContext, it gives the LttEvent structure, which is needed
- * to get facility name and event name.
- */
-struct _ItemInfo {
-       gint    x, y;
-       LttvTraceState          *ts;
-       LttvTracefileState      *tfs;
-};
-
-/*
- * Structure used to keep information about icons.
- */
-struct _IconStruct {
-       GdkPixmap *pixmap;
-       GdkBitmap *mask;
-};
-
-
-/*
- * The Item element is only used so the DrawOperation is modifiable by users.
- * During drawing, only the Hook is needed.
- */
-struct _DrawOperation {
-       DrawableItems   Item;
-       LttvHooks       *Hook;
-};
-
-/*
- * We define here each items that can be drawn, together with their
- * associated priority. Many item types can have the same priority,
- * it's only used for quicksorting the operations when we add a new one
- * to the array of operations to perform. Lower priorities are executed
- * first. So, for example, we may want to give background color a value
- * of 10 while a line would have 20, so the background color, which
- * is in fact a rectangle, does not hide the line.
- */
-
-static int Items_Priorities[] = {
-       50,     /* ITEM_TEXT */
-       40,     /* ITEM_ICON */
-       20,     /* ITEM_LINE */
-       30,     /* ITEM_POINT */
-       10      /* ITEM_BACKGROUND */
-};
-
-/*
- * Here are the different structures describing each item type that can be
- * drawn. They contain the information necessary to draw the item : not the
- * position (this is provided by the DrawContext), but the text, icon name,
- * line width, color; all the properties of the specific items.
- */
-
-struct _PropertiesText {
-       GdkColor        *foreground;
-       GdkColor        *background;
-       gint            size;
-       gchar           *Text;
-       RelPos          position;
-};
-
-
-struct _PropertiesIcon {
-       gchar           *icon_name;
-       gint            width;
-       gint            height;
-       RelPos          position;
-};
-
-struct _PropertiesLine {
-       GdkColor        *color;
-       gint            line_width;
-       GdkLineStyle    style;
-       RelPos          position;
-};
-
-struct _PropertiesArc {
-       GdkColor        *color;
-       gint            size;   /* We force circle by width = height */
-       gboolean        filled;
-       RelPos          position;
-};
-
-struct _PropertiesBG {
-       GdkColor        *color;
-};
-
-
 /* Drawing hook functions */
 gboolean draw_text( void *hook_data, void *call_data)
 {
@@ -230,51 +98,49 @@ gboolean draw_text( void *hook_data, void *call_data)
 
        PangoContext *context;
        PangoLayout *layout;
+       PangoAttribute *attribute;
        PangoFontDescription *FontDesc;// = pango_font_description_new();
        gint Font_Size;
        PangoRectangle ink_rect;
                
-       gdk_gc_set_foreground(Draw_Context->gc, Properties->foreground);
-       gdk_gc_set_background(Draw_Context->gc, Properties->background);
+       layout = Draw_Context->pango_layout;
 
-       layout = gtk_widget_create_pango_layout(GTK_WIDGET(Draw_Context->drawable), 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, Properties->size*PANGO_SCALE);
-       
-       
+       pango_layout_context_changed(layout);
+
        pango_layout_set_text(layout, Properties->Text, -1);
        pango_layout_get_pixel_extents(layout, &ink_rect, NULL);
        switch(Properties->position) {
                case OVER:
-                                                       gdk_draw_layout(Draw_Context->drawable, Draw_Context->gc,
+                                                       gdk_draw_layout_with_colors(Draw_Context->drawable,
+                                                               Draw_Context->gc,
                                                                Draw_Context->Current->modify_over->x,
                                                                Draw_Context->Current->modify_over->y,
-                                                               layout);
+                                                               layout, Properties->foreground, Properties->background);
                                                        Draw_Context->Current->modify_over->x += ink_rect.width;
 
                        break;
                case MIDDLE:
-                                                       gdk_draw_layout(Draw_Context->drawable, Draw_Context->gc,
+                                                       gdk_draw_layout_with_colors(Draw_Context->drawable,
+                                                               Draw_Context->gc,
                                                                Draw_Context->Current->modify_middle->x,
                                                                Draw_Context->Current->modify_middle->y,
-                                                               layout);
+                                                               layout, Properties->foreground, Properties->background);
                                                        Draw_Context->Current->modify_middle->x += ink_rect.width;
                        break;
                case UNDER:
-                                                       gdk_draw_layout(Draw_Context->drawable, Draw_Context->gc,
+                                                       gdk_draw_layout_with_colors(Draw_Context->drawable,
+                                                               Draw_Context->gc,
                                                                Draw_Context->Current->modify_under->x,
                                                                Draw_Context->Current->modify_under->y,
-                                                               layout);
+                                                               layout, Properties->foreground, Properties->background);
                                                        Draw_Context->Current->modify_under->x += ink_rect.width;
                        break;
        }
 
-
-       pango_font_description_set_size(FontDesc, Font_Size);
-       g_free(layout);
-       
        return 0;
 }
 
@@ -291,7 +157,7 @@ gboolean draw_icon( void *hook_data, void *call_data)
        LttvAttributeValue value;
        gchar icon_name[MAX_PATH_LEN] = "icons/";
        IconStruct *icon_info;
-       
+
        strcat(icon_name, Properties->icon_name);
        
   g_assert(lttv_iattribute_find_by_path(attributes, icon_name,
@@ -369,8 +235,11 @@ gboolean draw_line( void *hook_data, void *call_data)
 {
        PropertiesLine *Properties = (PropertiesLine*)hook_data;
        DrawContext *Draw_Context = (DrawContext*)call_data;
-
-       gdk_gc_set_foreground(Draw_Context->gc, Properties->color);
+       //GdkGC *gc = gdk_gc_new(Draw_Context->drawable);
+       
+       //gdk_gc_set_foreground(Draw_Context->gc, Properties->color);
+       gdk_gc_set_rgb_fg_color(Draw_Context->gc, Properties->color);
+       //gdk_gc_set_foreground(gc, Properties->color);
        gdk_gc_set_line_attributes(     Draw_Context->gc,
                                                                                                                        Properties->line_width,
                                                                                                                        Properties->style,
@@ -407,7 +276,9 @@ gboolean draw_line( void *hook_data, void *call_data)
 
                        break;
        }
-
+       
+       //gdk_gc_unref(gc);
+       
        return 0;
 }
 
@@ -416,7 +287,8 @@ gboolean draw_arc( void *hook_data, void *call_data)
        PropertiesArc *Properties = (PropertiesArc*)hook_data;
        DrawContext *Draw_Context = (DrawContext*)call_data;
 
-       gdk_gc_set_foreground(Draw_Context->gc, Properties->color);
+       //gdk_gc_set_foreground(Draw_Context->gc, Properties->color);
+       gdk_gc_set_rgb_fg_color(Draw_Context->gc, Properties->color);
 
        switch(Properties->position) {
                case OVER:
@@ -426,7 +298,6 @@ gboolean draw_arc( void *hook_data, void *call_data)
                                                        Draw_Context->Current->modify_over->y,
                                                        Properties->size, Properties->size, 0, 360*64);
                        Draw_Context->Current->modify_over->x += Properties->size;
-               
                        break;
                case MIDDLE:
                        gdk_draw_arc(Draw_Context->drawable, Draw_Context->gc,
@@ -457,7 +328,8 @@ gboolean draw_bg( void *hook_data, void *call_data)
        PropertiesBG *Properties = (PropertiesBG*)hook_data;
        DrawContext *Draw_Context = (DrawContext*)call_data;
 
-       gdk_gc_set_foreground(Draw_Context->gc, Properties->color);
+       //gdk_gc_set_foreground(Draw_Context->gc, Properties->color);
+       gdk_gc_set_rgb_fg_color(Draw_Context->gc, Properties->color);
 
 
        gdk_draw_rectangle(Draw_Context->drawable, Draw_Context->gc,
This page took 0.025919 seconds and 4 git commands to generate.