Ejemplo n.º 1
0
//------------------------------------------------------------------------------
void mforms::gtk::ToolBarImpl::set_selector_items(ToolBarItem *item, const std::vector<std::string> &values) {
  if (item->get_type() == mforms::SelectorItem || item->get_type() == mforms::FlatSelectorItem) {
    Gtk::ComboBoxText *w = cast<Gtk::ComboBoxText *>(item->get_data_ptr());
    if (w) {
      w->set_data("ignore_signal", (void *)1);
#if ((GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 24) || GTKMM_MAJOR_VERSION > 2)
      w->remove_all();
#else
      w->clear_items();
#endif
      const int size = values.size();
      for (int i = 0; i < size; ++i)
        w->append(values[i]);

      if (w->get_active_row_number() < 0 && !values.empty())
        w->set_active_text(values[0]);

      w->set_data("ignore_signal", 0);
    }
  } else if (item->get_type() == mforms::ColorSelectorItem) {
    Gtk::ComboBox *w = cast<Gtk::ComboBox *>(item->get_data_ptr());
    if (w) {
      w->set_data("ignore_signal", (void *)1);
      Glib::RefPtr<Gtk::ListStore> model = Gtk::ListStore::create(*color_combo_columns);
      const int size = values.size();
      for (int i = 0; i < size; ++i) {
        Gtk::TreeRow row = *model->append();
        Gdk::Color color(values[i]);
        Glib::RefPtr<Gdk::Pixbuf> pixbuf = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, false, 8, 16, 14);
        pixbuf->fill((guint32)color.get_red() << 24 | (guint32)color.get_green() << 16 | (guint32)color.get_blue() << 8);

        row[color_combo_columns->color] = values[i];
        row[color_combo_columns->image] = pixbuf;
      }

      w->set_model(model);

      if (w->get_active_row_number() < 0)
        w->set_active(0);

      w->set_data("ignore_signal", 0);
    }
  }
}
Ejemplo n.º 2
0
    inline virtual void updateGui()
    {
      _singleValueLabel.set_visible(false);
      for (size_t i(0); i < 4; ++i)
	_scalarvalues[i].hide();

      bool singlevalmode = singleValueMode();

      if (_components && singlevalmode)
	{
	  _singleValueLabel.set_visible(true);
	  for (size_t i(0); i < _components; ++i)
	    _scalarvalues[i].show();
	}

      _componentSelect.clear_items();
      if (singlevalmode || !_enableDataFiltering)
	_componentSelect.set_visible(false);
      else
	{
	  _componentSelect.set_visible(true);

	  Gtk::TreeModel::iterator iter = _comboBox.get_active();
	  std::tr1::shared_ptr<Attribute> ptr = (*iter)[_modelColumns.m_ptr];

	  _componentSelect.append_text("Raw Data");
	  _componentSelect.append_text("Magnitude");
	  _componentSelect.append_text("X");
	    
	  if (ptr->components() > 1)
	    _componentSelect.append_text("Y");
	  if (ptr->components() > 2)
	    _componentSelect.append_text("Z");
	  if (ptr->components() > 3)
	    _componentSelect.append_text("W");
	  
	  //Default to coloring using the magnitude
	  _componentSelect.set_active(1);
	}

      for (size_t i(0); i < _components; ++i)
	_scalarvalues[i].set_sensitive(singlevalmode);
    }