Beispiel #1
0
// addParent is responsible for adding new abstract nodes to the cluster and
// creating intra-edges that connect the new node to existing abstract nodes. 
void 
AbstractCluster::addParent(node* _p) throw(std::invalid_argument)
{
	Timer t;
	t.startTimer();
	ClusterNode* p = dynamic_cast<ClusterNode*>(_p);

	if(p == 0)
		throw std::invalid_argument(
				"AbstractCluster::addParent: arg not of type AbstractClusterNode");

	if(p->getParentClusterId() != this->getId())
		throw std::invalid_argument(
				"AbstractCluster::addParent: arg not assigned to this cluster");

	if(parents.find(p->getUniqueID()) != parents.end())
		return; // node already in parents collection

	if(p->getLabelL(kAbstractionLevel) == 0)
	{
		ClusterNode* p2 = dynamic_cast<ClusterNode*>(
				map->getNodeFactory()->newNode(p));
		p2->setLabelL(kAbstractionLevel, 1);
		p2->setLabelL(kParent, -1);
		map->getAbstractGraph(1)->addNode(p2);
		p->setLabelL(kParent, p2->getNum());
		p = p2;
	}
	
	if(getVerbose())
	{
		std::cout << "AbstractCluster::addParent ";
		p->Print(std::cout);
		std::cout << std::endl;
	}

	p->setParentClusterId(this->getId());
	parents.insert(std::pair<int, node*>(p->getUniqueID(), p));
	connectParent(p);
	searchTime = t.endTimer();
}
Beispiel #2
0
void gMainWindow::reparent(gContainer *newpr, int x, int y)
{
	GtkWidget *new_border;
	int w, h;
	gColor fg, bg;
	
	if (_xembed)
		return;
	
	bg = background();
	fg = foreground();
	
	if (isTopLevel() && newpr)
	{
		gtk_window_remove_accel_group(GTK_WINDOW(topLevel()->border), accel);
		
		new_border = gtk_event_box_new();
		gtk_widget_reparent(widget, new_border);
		embedMenuBar(new_border);
		_no_delete = true;
		gtk_widget_destroy(border);
		_no_delete = false;
		
		border = new_border;
		registerControl();
		setCanFocus(false);

		setParent(newpr);
		connectParent();
		borderSignals();
		initWindow();	
		
		setBackground(bg);
		setForeground(fg);
		setFont(font());
		
		checkMenuBar();
		
		bufX = bufY = 0;
		move(x, y);
		gtk_widget_set_size_request(border, width(), height());
		
		// Hidden children are incorrectly shown. Fix that!
		hideHiddenChildren();
	}
	else if ((!isTopLevel() && !newpr)
	         || (isTopLevel() && isPopup()))
	         //|| (isTopLevel() && (isPopup() ^ (type == GTK_WINDOW_POPUP))))
	{
		gtk_window_remove_accel_group(GTK_WINDOW(topLevel()->border), accel);
		// TODO: test that
		new_border = gtk_window_new(GTK_WINDOW_TOPLEVEL);
		gtk_widget_reparent(widget, new_border);
		embedMenuBar(new_border);
		_no_delete = true;
		gtk_widget_destroy(border);
		_no_delete = false;

		border = new_border;
		registerControl();
		setCanFocus(true);

		if (parent())
		{
			parent()->remove(this);
			parent()->arrange();
			setParent(NULL);
		}
		initWindow();	
		borderSignals();
		setBackground(bg);
		setForeground(fg);
		setFont(font());
		
		move(x, y);
		w = width();
		h = height();
		bufW = bufH = -1;
		gtk_widget_set_size_request(border, 1, 1);
		resize(w, h);
		
		hideHiddenChildren();
		_popup = false; //type == GTK_WINDOW_POPUP;
	}
	else
	{
		gContainer::reparent(newpr, x, y);	
	}
}