示例#1
0
void setCellRendererCombo(string treeviewcolumn, string combolist, Gtk::TreeModelColumnBase& col, void (* fkt)(GtkCellRendererCombo*, gchar*, GtkTreeIter*, gpointer)) {
    Glib::RefPtr<Gtk::ListStore> combo_list = Glib::RefPtr<Gtk::ListStore>::cast_static(VRGuiBuilder()->get_object(combolist.c_str()));
    Gtk::CellRendererCombo* renderer = new Gtk::CellRendererCombo();
    renderer->property_has_entry() = false;
    renderer->property_model() = combo_list;
    renderer->property_text_column() = 0;
    renderer->property_editable() = true;

    Glib::RefPtr<Gtk::TreeView::Column> column = Glib::RefPtr<Gtk::TreeView::Column>::cast_static(VRGuiBuilder()->get_object(treeviewcolumn.c_str()));
    column->pack_start(*renderer);

    column->add_attribute(renderer->property_text(), col);
    g_signal_connect (renderer->gobj(), "changed", G_CALLBACK (fkt), NULL);
}
示例#2
0
void setCellRendererCombo(string treeviewcolumn, string combolist, Gtk::TreeModelColumnBase& col, sigc::slot<void, const Glib::ustring&, const Gtk::TreeModel::iterator& > sig) {
    Glib::RefPtr<Gtk::ListStore> combo_list = Glib::RefPtr<Gtk::ListStore>::cast_static(VRGuiBuilder()->get_object(combolist.c_str()));
    Gtk::CellRendererCombo* renderer = new Gtk::CellRendererCombo();
    renderer->property_has_entry() = false;
    renderer->property_model() = combo_list;
    renderer->property_text_column() = 0;
    renderer->property_editable() = true;

    Glib::RefPtr<Gtk::TreeView::Column> column = Glib::RefPtr<Gtk::TreeView::Column>::cast_static(VRGuiBuilder()->get_object(treeviewcolumn.c_str()));
    column->pack_start(*renderer);

    column->add_attribute(renderer->property_text(), col);
    renderer->signal_changed().connect(sig);
}
//------------------------------------------------------------------------------
const StringColumn&
ColumnsModel::append_combo_column(const int bec_tm_idx
                                     ,const std::string            &name
                                     ,Glib::RefPtr<Gtk::ListStore>  list_w
                                     ,const Editable                editable
                                     ,bool popup_only)
{
  Gtk::TreeModelColumn<Glib::ustring> *choosen = new Gtk::TreeModelColumn<Glib::ustring>;
  _columns.push_back(choosen);
  add(*choosen);
  add_bec_index_mapping(bec_tm_idx);

  Gtk::TreeView::Column   *col = Gtk::manage(new Gtk::TreeViewColumn(bec::replace_string(name, "_", "__")));
  Gtk::CellRendererCombo *cell = Gtk::manage(new Gtk::CellRendererCombo);
  col->pack_start(*cell);

  col->add_attribute(cell->property_text(), *choosen);
  cell->property_model() = list_w;
  cell->property_text_column() = 0;
  cell->property_editable() = editable;
  cell->property_has_entry() = !popup_only;
  
  Gtk::TreeModelColumn<Glib::RefPtr<Gtk::TreeModel> > *model_col = new Gtk::TreeModelColumn<Glib::RefPtr<Gtk::TreeModel> >();
  add_bec_index_mapping(bec_tm_idx);
  add(*model_col);
  const int nr_of_cols = _treeview->append_column(*col);

  _columns.push_back(model_col);

  _treeview->get_column(nr_of_cols-1)->set_resizable(true);

  if ( editable == EDITABLE )
  {
    Gtk::CellRendererText *cell = (Gtk::CellRendererText*)(_treeview->get_column_cell_renderer(nr_of_cols - 1));
    cell->signal_edited().connect(sigc::bind
                                    (sigc::mem_fun(*_tmw
                                                  ,&ListModelWrapper::after_cell_edit<Glib::ustring>
                                                  )
                                                  , sigc::ref(*choosen)
                                   )
                                 );
  }

  return *choosen;
}
示例#4
0
ModulePropertyWindow::ModulePropertyWindow(MainWindow* parent, 
                               Manager* manager, ApplicationWindow* appWnd) : m_pModule(NULL)
{   
    m_pParent = parent;
    m_pManager = manager;
    m_pModule = NULL;
    m_pAppWindow = appWnd;


    /* Create a new scrolled window, with scrollbars only if needed */
    set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
    add(m_TreeView);

    /* create tree store */
    m_refTreeModel = Gtk::TreeStore::create(m_Columns);
    m_TreeView.set_model(m_refTreeModel);

    //Add the Model’s column to the View’s columns: 
    Gtk::CellRendererText* itemRenderer = Gtk::manage(new Gtk::CellRendererText());
    itemRenderer->property_editable() = false;
    Gtk::TreeViewColumn* itemCol = Gtk::manage(new Gtk::TreeViewColumn("Property", *itemRenderer));
    itemCol->add_attribute(*itemRenderer, "foreground-gdk", m_Columns.m_col_color_item);
    itemCol->add_attribute(*itemRenderer, "text", m_Columns.m_col_name);
    itemCol->set_resizable(true);
    m_TreeView.append_column(*itemCol);


    Gtk::CellRendererCombo* valueRenderer = Gtk::manage(new Gtk::CellRendererCombo());
    Gtk::TreeView::Column* valueCol = Gtk::manage(new Gtk::TreeView::Column("Value"));
    valueCol->pack_start(*valueRenderer);
    valueCol->add_attribute(*valueRenderer, "foreground-gdk", m_Columns.m_col_color_value);
    //valueCol->set_resizable(true);
    valueCol->add_attribute(*valueRenderer, "editable", m_Columns.m_col_editable);   

  //Make this View column represent the m_col_itemchosen model column:
#ifdef GLIBMM_PROPERTIES_ENABLED
  valueCol->add_attribute(valueRenderer->property_text(), m_Columns.m_col_value);
#else
  pColumn->add_attribute(*valueRenderer, "text", m_Columns.m_col_value);
#endif

#ifdef GLIBMM_PROPERTIES_ENABLED
    valueCol->add_attribute(valueRenderer->property_model(), m_Columns.m_col_choices);
#else
    valueCol->add_attribute(*valueRenderer, "model", m_Columns.m_col_choices);
#endif 

#ifdef GLIBMM_PROPERTIES_ENABLED
    valueRenderer->property_text_column() = 0; 
#else
    valueRenderer->set_property("text_column", 0);
#endif
    valueRenderer->signal_edited().connect( sigc::mem_fun(*this,
              &ModulePropertyWindow::onCellEdited) );
    m_TreeView.append_column(*valueCol);

    m_TreeView.set_grid_lines(Gtk::TREE_VIEW_GRID_LINES_BOTH);
    m_TreeView.set_rules_hint(true);

    show_all_children();
}