From 34b048821159dd48a9c5eac32ad5333925da334d Mon Sep 17 00:00:00 2001 From: compudj Date: Sat, 10 Jan 2004 22:22:50 +0000 Subject: [PATCH] show text : running state git-svn-id: http://ltt.polymtl.ca/svn@372 04897980-b3bd-0310-b5e0-8ef037075253 --- .../lttv/modules/guiControlFlow/Draw_Item.c | 8 +---- .../lttv/modules/guiControlFlow/Draw_Item.h | 2 +- .../lttv/modules/guiControlFlow/Drawing.c | 4 +++ .../lttv/modules/guiControlFlow/Drawing.h | 4 ++- .../lttv/modules/guiControlFlow/Event_Hooks.c | 31 ++++++++++++++++++- .../modules/guiControlFlow/Process_List.c | 1 + 6 files changed, 40 insertions(+), 10 deletions(-) diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.c b/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.c index 72536e7f..eccfef0f 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.c @@ -105,13 +105,11 @@ gboolean draw_text( void *hook_data, void *call_data) gdk_gc_set_foreground(Draw_Context->gc, Properties->foreground); gdk_gc_set_background(Draw_Context->gc, Properties->background); - layout = gtk_widget_create_pango_layout(GTK_WIDGET(Draw_Context->drawable), NULL); + layout = Draw_Context->pango_layout; 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_set_text(layout, Properties->Text, -1); pango_layout_get_pixel_extents(layout, &ink_rect, NULL); switch(Properties->position) { @@ -139,10 +137,6 @@ gboolean draw_text( void *hook_data, void *call_data) break; } - - pango_font_description_set_size(FontDesc, Font_Size); - g_free(layout); - return 0; } diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.h b/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.h index de3a51c1..6c35e977 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.h +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.h @@ -44,7 +44,7 @@ typedef enum _RelPos { struct _DrawContext { GdkDrawable *drawable; GdkGC *gc; - + PangoLayout *pango_layout; DrawInfo *Current; DrawInfo *Previous; diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c b/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c index ea056ff0..8f35e071 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c @@ -278,6 +278,9 @@ Drawing_t *drawing_construct(ControlFlowData *Control_Flow_Data) Drawing->Drawing_Area_V = gtk_drawing_area_new (); Drawing->Control_Flow_Data = Control_Flow_Data; + Drawing->pango_layout = + gtk_widget_create_pango_layout(Drawing->Drawing_Area_V, NULL); + //gtk_widget_set_size_request(Drawing->Drawing_Area_V->window, 50, 50); g_object_set_data_full( G_OBJECT(Drawing->Drawing_Area_V), @@ -327,6 +330,7 @@ void drawing_destroy(Drawing_t *Drawing) // Do not unref here, Drawing_t destroyed by it's widget. //g_object_unref( G_OBJECT(Drawing->Drawing_Area_V)); + g_free(Drawing->pango_layout); g_free(Drawing); } diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h b/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h index f225e225..d2aa0a6a 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h @@ -39,9 +39,11 @@ struct _Drawing_t { GtkWidget *Drawing_Area_V; GdkPixmap *Pixmap; ControlFlowData *Control_Flow_Data; + + PangoLayout *pango_layout; gint height, width, depth; - + }; Drawing_t *drawing_construct(ControlFlowData *Control_Flow_Data); diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.c b/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.c index de41f0c6..0a103d66 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.c @@ -585,16 +585,45 @@ int draw_event_hook(void *hook_data, void *call_data) prop_arc.size = 10; prop_arc.filled = TRUE; prop_arc.position = OVER; + DrawContext *draw_context = Hashed_Process_Data->draw_context; draw_context->Current->modify_over->x = x; draw_context->Current->modify_over->y = y; draw_context->drawable = control_flow_data->Drawing->Pixmap; + draw_context->pango_layout = control_flow_data->Drawing->pango_layout; GtkWidget *widget = control_flow_data->Drawing->Drawing_Area_V; //draw_context->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; draw_context->gc = widget->style->black_gc; - draw_arc((void*)&prop_arc, (void*)draw_context); + //draw_arc((void*)&prop_arc, (void*)draw_context); //test_draw_item(control_flow_data->Drawing, control_flow_data->Drawing->Pixmap); + + GdkColor colorfg = { 0, 0x0000, 0x0000, 0x0000 }; + GdkColor colorbg = { 0, 0xffff, 0x0000, 0xffff }; + PropertiesText prop_text; + prop_text.foreground = &colorfg; + prop_text.background = &colorbg; + prop_text.size = 10; + prop_text.position = OVER; + + /* Print status of the process : U, WF, WC, E, W, R */ + if(tfs->process->state->s == LTTV_STATE_UNNAMED) + prop_text.Text = "U"; + else if(tfs->process->state->s == LTTV_STATE_WAIT_FORK) + prop_text.Text = "WF"; + else if(tfs->process->state->s == LTTV_STATE_WAIT_CPU) + prop_text.Text = "WC"; + else if(tfs->process->state->s == LTTV_STATE_EXIT) + prop_text.Text = "E"; + else if(tfs->process->state->s == LTTV_STATE_WAIT) + prop_text.Text = "W"; + else if(tfs->process->state->s == LTTV_STATE_RUN) + prop_text.Text = "R"; + else + prop_text.Text = "U"; + + draw_text((void*)&prop_text, (void*)draw_context); + return 0; } diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Process_List.c b/ltt/branches/poly/lttv/modules/guiControlFlow/Process_List.c index 37069b1a..93298c5e 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Process_List.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Process_List.c @@ -314,6 +314,7 @@ int processlist_add( ProcessList *Process_List, Hashed_Process_Data->draw_context = g_new(DrawContext, 1); Hashed_Process_Data->draw_context->drawable = NULL; Hashed_Process_Data->draw_context->gc = NULL; + Hashed_Process_Data->draw_context->pango_layout = NULL; Hashed_Process_Data->draw_context->Current = g_new(DrawInfo,1); Hashed_Process_Data->draw_context->Current->over = g_new(ItemInfo,1); Hashed_Process_Data->draw_context->Current->over->x = -1; -- 2.34.1