TSP: The Transport Sample Protocol



Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

page.c

00001 #include <gtk/gtk.h>
00002 #include <glib.h>
00003 #include <assert.h>
00004 
00005 
00006 #include "page.h"
00007 #include "gview.h"
00008 #include "config.h"
00009 
00010 
00011 
00012 extern display_page* pages;
00013 
00014 
00015 void 
00016 page_variables_add (int page) {
00017   GtkWidget* var_widget;
00018   GtkWidget *event_box;
00019   variable *new_var;
00020   guint row, col;
00021   GtkTable *table;
00022   GtkWidget *draw;
00023   gchar *text;
00024   double val_double = 0.0;
00025 
00026 
00027 
00028   /* Get the table from the window (we know its the only container) */
00029   table = GTK_TABLE(GTK_BIN(pages[page].window)->child);
00030 
00031   /* Set up the label, justification seems to have problems ... */
00032   switch(widget_type)
00033     {
00034     case WIDGET_VIEW :
00035       var_widget = gtk_label_new("");
00036       gtk_misc_set_alignment(GTK_MISC(var_widget), 0.5f, 0.5f);
00037       break;
00038     case WIDGET_DRAW :
00039       var_widget = plotwindow_new ();
00040       set_title(PLOTWINDOW(var_widget),var_text );
00041       break;
00042     default:
00043       assert(0);
00044     }
00045 
00046   gtk_widget_show(var_widget);
00047 
00048   event_box = gtk_event_box_new ();
00049 
00050   gtk_container_add(GTK_CONTAINER(event_box), var_widget);
00051 
00052   /*gtk_misc_set_alignment(GTK_MISC(event_box), 0.0, 0.5);*/
00053   
00054   gtk_widget_show(GTK_WIDGET(event_box));
00055 
00056 
00057   /* Compute the cell where we're going to put the widget */
00058   row = pages[page].variables->len % pages[page].rows;
00059   col = floor(pages[page].variables->len / pages[page].rows);
00060 
00061   /* Add the widget. 
00062      FIXME : 3,3 = widget spacing, should be a const at least. 
00063   */
00064   /* FIXME : Il faudrait rajouter non pas le label, mais un conteneur contenant le label pour changer sa col Y.D */
00065 /*  vbox = gtk_vbox_new(TRUE, 3);
00066   gtk_box_pack_start_defaults(GTK_BOX(vbox), GTK_WIDGET(label));
00067   gtk_widget_show(vbox);*/
00068   gtk_table_attach (GTK_TABLE (table), GTK_WIDGET(event_box), col, col+1, row, row+1, 
00069                     (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
00070                     (GtkAttachOptions) (GTK_FILL | GTK_EXPAND), 3, 3);
00071 
00072   /*gtk_widget_show(GTK_WIDGET(table));*/
00073 
00074   /* Setup the variable attributes */
00075   new_var->type = type;
00076   new_var->widget = var_widget;
00077   new_var->text = g_strdup(var_text);
00078   new_var->legend = legend == NULL ? NULL : g_strdup(legend);
00079   new_var->widget_type = widget_type;
00080 
00081 }
00082 
Framework Home Page.

Beware !! TSP wave is coming...