Exemple #1
0
void PluginDisplay::display_upper(Gtk::CellRenderer *cell, const Gtk::TreeIter& it) {
    PortDesc *q = it->get_value(port_liststore->col.port);
    Gtk::CellRendererText *tcell = dynamic_cast<Gtk::CellRendererText*>(cell);
    tcell->property_foreground_set().set_value(false);
    tcell->property_background_set().set_value(false);
    DisplayType tp = q->get_tp();
    if (tp == tp_toggle || tp == tp_display_toggle || tp == tp_none) {
        cell->property_visible().set_value(false);
        return;
    }
    cell->property_visible().set_value(true);
    if (q->is_set(ChangeableValues::up_set)) {
        tcell->property_foreground().set_value("red");
    } else if (q->fake_up) {
        tcell->property_background().set_value("grey");
    }
}
Exemple #2
0
int AutomataGui::init(){
	//CREATE REFBUILDER
	this->refBuilder = Gtk::Builder::create();
	const std::string gladepath = resourcelocator::findGladeFile("automatagui.glade");
	try{
		refBuilder->add_from_file(gladepath);
	}catch (const Glib::FileError& ex){
		std::cerr << "FileError: " << ex.what() << std::endl;
	  	return -1;
	}catch (const Glib::MarkupError& ex){
	  	std::cerr << "MarkupError: " << ex.what() << std::endl;
	  	return -1;
	}catch (const Gtk::BuilderError& ex){
		std::cerr << "BuilderError: " << ex.what() << std::endl;
		return -1;
	}

	//GETTING WIDGETS
	refBuilder->get_widget("scrolledwindow_schema", this->scrolledwindow_schema);
	refBuilder->get_widget("treeview", this->treeView);
	refBuilder->get_widget("up_button", this->pUpButton);
	refBuilder->get_widget("check_autofocus", this->checkAutofocus);
	refBuilder->get_widget("DialogDerived", guiDialog);
	if(!guiDialog){
		std::cerr << "Error: couldn't get DialogDerived" << std::endl;
		return -1;
	}

	this->pUpButton->signal_clicked().connect(sigc::mem_fun(*this,
										&AutomataGui::on_up_button_clicked));

	//INIT CANAVS
	this->canvas = Gtk::manage(new Goocanvas::Canvas());
	this->canvas->signal_item_created().connect(sigc::mem_fun(*this,
										&AutomataGui::on_item_created));
	this->root = Goocanvas::GroupModel::create();
	this->canvas->set_root_item_model(root);
	this->canvas->set_visible(true);
	this->scrolledwindow_schema->add(*(this->canvas));

	//INIT TREEVIEW
	this->lastExpanded = "";
	this->refTreeModel = Gtk::TreeStore::create(this->m_Columns);
	this->treeView->set_model(this->refTreeModel);
	this->treeView->append_column("ID", this->m_Columns.m_col_id);
	Gtk::CellRendererText *cell = new Gtk::CellRendererText;
	int column_count = treeView->append_column("Name", *cell);
	Gtk::TreeViewColumn *column = treeView->get_column(column_count-1);
	if (column) {
	#ifdef GLIBMM_PROPERTIES_ENABLED
        column->add_attribute(cell->property_background(), this->m_Columns.m_col_color);
		column->add_attribute(cell->property_text(), this->m_Columns.m_col_name);
	#else
        column->add_attribute(*cell, "background", this->m_Columns.m_col_color);
        column->add_attribute(*cell, "text", this->m_Columns.m_col_name);
	#endif
    }
    this->treeView->signal_row_activated().connect(
    					sigc::mem_fun(*this, &AutomataGui::on_row_activated));

    //Atach handler to the dispatcher
    this->dispatcher.connect(sigc::mem_fun(*this, &AutomataGui::on_notify_received));

    //SETTING CANVAS BOUNDS
	Glib::RefPtr<Gdk::Screen> screen = this->guiDialog->get_screen();
    int width = screen->get_width();
    int height = screen->get_height();

    Goocanvas::Bounds bounds;
    this->canvas->get_bounds(bounds);
    bounds.set_x2(width);
    bounds.set_y2(height * 2);
    this->canvas->set_bounds(bounds);
    return 0;
}