[Bio] / ModelEditorGlade / ModelEditorImpl.cc Repository:
ViewVC logotype

View of /ModelEditorGlade/ModelEditorImpl.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (download) (as text) (annotate) (vendor branch)
Mon Oct 4 19:52:17 2004 UTC (15 years, 1 month ago) by efrank
Branch: MAIN, MigrateToNewPackage
CVS Tags: v0, HEAD
Changes since 1.1: +0 -0 lines
Migrating package name.  Used to be ModelEditor.  I want to use ModelEditor
name for what used to be PyGUI.  So
	o check out head of ModelEditor
	o tag it MigrateToNewPackage
	o import it as ModelEditorGlade
	o remove all files from ModelEditor
	o add everything from PyGUI

#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>

extern "C" {

#include <gnome.h>
#include "ModelEditor/Utils.h"
#include "ModelEditor/interface.h"
#include "ModelEditor/support.h"

}

#include <gtk/gtk.h>
#include "RecoReadout/RecoElem.hh"
#include "RecoReadout/Reaction.hh"
#include "RecoElemSBW/SbwFactory.hh"
#include "RecoReadoutOracle/OracleMgr.hh"
#include <string.h>

using namespace std;

void loadGtkTreeFromRecoElem( int topNode , GtkWidget* tree);
void recurse (GtkWidget *tree, RecoElem & elem);


//************************************************************************
void cb_itemsignal( GtkWidget *item,
                           gchar     *signame )
//************************************************************************
{
  gchar *name;
  GtkLabel *label;
  GtkButton *button;

  label = GTK_LABEL (GTK_BIN (item)->child);

  gtk_label_get (label, &name);

}

//************************************************************************
void
on_list_select_child                   (GtkWidget         *list,
                                       gpointer         user_data)
//************************************************************************
{

  g_print ("Selection cleared\n");
  cout << "select list " << endl;
  
}

//************************************************************************
void
on_tree_select_child                   (GtkTree         *tree,
			   	        gpointer         user_data)
//************************************************************************
{
 RecoElem *re = (RecoElem *) user_data;
 vector<Reaction>& rxns  = re->getReactions();

 
 int nrxns= rxns.size ();
   
 GtkWidget *list1;
 GtkWidget *newitem;

 GList *dlist=NULL;
 
 int i; 

 list1 = lookup_widget(GTK_WIDGET(tree), "list1");

 //do nothing if there's no reaction
 if (nrxns==0) {
   gtk_list_clear_items (GTK_LIST(list1), 0, -1); 
   return;
 }

 //clear the previous entries
 gtk_list_clear_items (GTK_LIST(list1), 0, -1); 


 for (i=0 ; i<nrxns ; i++){
   gchar *label;

   label= (gchar*) rxns[i].asString().c_str();
   newitem = gtk_list_item_new_with_label(label);
   gtk_signal_connect (GTK_OBJECT(newitem), "start-selection",
		       GTK_SIGNAL_FUNC(on_list_select_child), &label);
   dlist = g_list_append (dlist, newitem);
   gtk_widget_show(newitem);

 }

 gtk_list_append_items (GTK_LIST(list1), dlist);

 return;
}

//************************************************************************
void
on_tree_selection_changed              (GtkTree         *tree,
                                        gpointer         user_data)
//************************************************************************
{

GList *i;
  

  i = GTK_TREE_SELECTION(tree);
  while (i){
    gchar *name;
    GtkLabel *label;
    GtkWidget *item;

    /* Get a GtkWidget pointer from the list node */
    item = GTK_WIDGET (i->data);
    label = GTK_LABEL (GTK_BIN (item)->child);
    gtk_label_get (label, &name);
    i = i->next;
  }



}


//************************************************************************
void
on_tree_unselect_child                 (GtkTree         *tree,
                                        GtkWidget       *widget,
                                        gpointer         user_data)
//************************************************************************
{


}



/* for all the GtkItem:: and GtkTreeItem:: signals */



//************************************************************************
void
on_OK_clicked                          (GtkButton       *button,
                                        gpointer         user_data)
//************************************************************************
{

  gint  temp;
  int id;
   
  GtkWidget *tree  = lookup_widget(GTK_WIDGET(button), "tree");
  GtkWidget *entry  = lookup_widget(GTK_WIDGET(button), "entry1");  
 

  temp = atoi(gtk_entry_get_text(GTK_ENTRY(entry)));
  loadGtkTreeFromRecoElem(temp , tree);
 
}



//************************************************************************
void
loadGtkTreeFromRecoElem( int topNode,
			 GtkWidget* tree ) {
//************************************************************************

  SbwFactory  f;
  RecoElem* elem = f.getRecoElemById( topNode );
  recurse(tree, *elem);
  return;
}


//************************************************************************
void
recurse (GtkWidget *tree, RecoElem & elem)
//************************************************************************
{

    gtk_tree_set_selection_mode (GTK_TREE(tree),
				 GTK_SELECTION_SINGLE);


    GtkWidget *item, *subtree;
    vector<RecoElem>& subElem   = elem.getSubElements();
    vector<Reaction>& rxns      = elem.getReactions();
    
    int nrxns= rxns.size ();
    int nkids= subElem.size ();

    gchar *itemnames;
    itemnames=(gchar*)elem.getName().c_str();

    item = gtk_tree_item_new_with_label (itemnames);
    subtree= gtk_tree_new();
    
    /* Connect all GtkItem:: and GtkTreeItem:: signals */
    //the following can be used to find reactions or kids later

    char* select = "select";
    char* toggle = "toggle";
    char* expand =  "expand";
    char* collapse = "collapse";

   
    gtk_signal_connect (GTK_OBJECT(item), "select",
			GTK_SIGNAL_FUNC(on_tree_select_child), &elem);
   

    /* Add it to the parent tree */
    gtk_tree_append (GTK_TREE(tree), item);
    gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), subtree);

    for(int j=0; j<nkids ; j++) {
      recurse( subtree, subElem[j]); 
    }

    /* Show it - this can be done at any time */
    gtk_widget_show (item); 

}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3