Example #1
0
File: aadlbox.c Project: UIKit0/dia
static void
aadlbox_add_port(Aadlbox *aadlbox, const Point *p, Aadlport *port)
{
  int i;

  aadlbox->num_ports++;

  if (aadlbox->ports == NULL)
    aadlbox->ports = g_malloc(sizeof(Aadlport*)*aadlbox->num_ports);

  else
    /* Allocate more ports */
    aadlbox->ports = g_realloc(aadlbox->ports,
         			       sizeof(Aadlport*)*aadlbox->num_ports);

  i = aadlbox->num_ports - 1;

  aadlbox->ports[i] = port;
  aadlbox->ports[i]->handle->id = PORT_HANDLE_AADLBOX;
  aadlbox->ports[i]->handle->type = HANDLE_MINOR_CONTROL;
  aadlbox->ports[i]->handle->connect_type = HANDLE_CONNECTABLE_NOBREAK;
  aadlbox->ports[i]->handle->connected_to = NULL;
  aadlbox->ports[i]->handle->pos = *p;
  object_add_handle(&aadlbox->element.object, aadlbox->ports[i]->handle);


  port->in.connected = NULL; port->in.object = &aadlbox->element.object;
  port->out.connected = NULL; port->out.object = &aadlbox->element.object;
  object_add_connectionpoint(&aadlbox->element.object, &port->in);
  object_add_connectionpoint(&aadlbox->element.object, &port->out);

}
Example #2
0
File: aadlbox.c Project: UIKit0/dia
static void
aadlbox_add_connection(Aadlbox *aadlbox, const Point *p, ConnectionPoint *connection)
{
  int i;

  connection->object = (DiaObject *) aadlbox;
  connection->connected = NULL;           /* FIXME: could be avoided ?? */
      
  aadlbox->num_connections++;
    
  if (aadlbox->connections == NULL)
    aadlbox->connections = 
      g_malloc(sizeof(ConnectionPoint*)*aadlbox->num_connections);

  else
    /* Allocate more connections */
    aadlbox->connections = g_realloc(aadlbox->connections,
			    sizeof(ConnectionPoint*)*aadlbox->num_connections);

  i = aadlbox->num_connections - 1;

  aadlbox->connections[i] = connection;
  aadlbox->connections[i]->pos = *p;
  
  object_add_connectionpoint(&aadlbox->element.object, connection);

}
Example #3
0
static DiaObject *
compfeat_create(Point *startpoint,
		void *user_data,
		Handle **handle1,
		Handle **handle2)
{
  Compfeat *compfeat;
  OrthConn *orth;
  DiaObject *obj;
  Point p;
  DiaFont *font;

  font = dia_font_new_from_style(DIA_FONT_MONOSPACE, 0.8);

  compfeat = g_new0(Compfeat, 1);
  compfeat->role = compfeat->roletmp = GPOINTER_TO_INT(user_data);
  compfeat->line_width = 0.1;

  orth = &compfeat->orth;
  obj = &orth->object;

  obj->type = &compfeat_type;
  obj->ops = &compfeat_ops;

  orthconn_init(orth, startpoint);

  p = *startpoint;
  p.y -= COMPPROP_TEXTOFFSET;

  compfeat->line_color = attributes_get_foreground();
  compfeat->text = new_text("", font,
			    COMPPROP_FONTHEIGHT, &p, &compfeat->line_color,
			    ALIGN_CENTER);
  dia_font_unref(font);

  compfeat->text_handle.id = HANDLE_MOVE_TEXT;
  compfeat->text_handle.type = HANDLE_MINOR_CONTROL;
  compfeat->text_handle.connect_type = HANDLE_NONCONNECTABLE;
  compfeat->text_handle.connected_to = NULL;
  compfeat->text_handle.pos = compfeat->text_pos = p;
  object_add_handle(obj, &compfeat->text_handle);

  if (compfeat->role == COMPPROP_FACET
      || compfeat->role == COMPPROP_EVENTSOURCE) {
    int pos = obj->num_connections;
    object_add_connectionpoint(&orth->object, &compfeat->cp);
    obj->connections[pos] = &compfeat->cp;
    compfeat->cp.object = obj;
    compfeat->cp.connected = NULL;
  }

  compfeat_update_data(compfeat);

  *handle1 = orth->handles[0];
  *handle2 = orth->handles[orth->numpoints-2];

  return &compfeat->orth.object;
}
Example #4
0
static void
cpl_add_connectionpoint_at(ConnPointLine *cpl, int pos,ConnectionPoint *cp) 
{
  if (pos == 0) {
    /* special case handling so that the order of CPL groups in 
       the parent's CP list is preserved. */
    int fpos,i;
    ConnectionPoint *fcp;
    g_assert(cpl->connections);
    fpos = -1;
    fcp = (ConnectionPoint *)(cpl->connections->data);
    g_assert(fcp);
    for (i=0; i<cpl->parent->num_connections; i++) {
      if (cpl->parent->connections[i] == fcp) {
	fpos = i;
	break;
      }
    }
    g_assert(fpos >= 0);
    object_add_connectionpoint_at(cpl->parent,cp,fpos);
  }else {
    /* XXX : make this a little better ; try to insert at the correct
       position right away to eliminate cpl_reorder_connection */
    object_add_connectionpoint(cpl->parent,cp);
  }
  if (pos < 0) {
    cpl->connections = g_slist_append(cpl->connections,(gpointer)cp);
  }
  else {
    cpl->connections = g_slist_insert(cpl->connections,(gpointer)cp,pos);
  }
  cpl->num_connections++;

  /* we should call
     cpl_reorder_connections(cpl);
     before we leave the object !! However, this is delayed, for the case
     several CP's are added at once (initialisation). */
}