Esempio n. 1
0
static Object *
state_copy(State *state)
{
  int i;
  State *newstate;
  Element *elem, *newelem;
  Object *newobj;
  
  elem = &state->element;
  
  newstate = g_malloc(sizeof(State));
  newelem = &newstate->element;
  newobj = (Object *) newstate;

  element_copy(elem, newelem);

  newstate->text = text_copy(state->text);
  
  for (i=0;i<8;i++) {
    newobj->connections[i] = &newstate->connections[i];
    newstate->connections[i].object = newobj;
    newstate->connections[i].connected = NULL;
    newstate->connections[i].pos = state->connections[i].pos;
    newstate->connections[i].last_pos = state->connections[i].last_pos;
  }

  newstate->state_type = state->state_type;

  state_update_data(newstate);
  
  return (Object *)newstate;
}
Esempio n. 2
0
static void
state_set_props(State *state, GPtrArray *props)
{
  object_set_props_from_offsets(&state->element.object,
                                state_offsets,props);
  state_update_data(state);
}
Esempio n. 3
0
static ObjectChange*
state_move(State *state, Point *to)
{
  state->element.corner = *to;
  state_update_data(state);

  return NULL;
}
Esempio n. 4
0
static void
state_set_props(State *state, GPtrArray *props)
{
  object_set_props_from_offsets(&state->element.object,
                                state_offsets,props);
  apply_textattr_properties(props,state->text,"text",&state->attrs);
  state_update_data(state);
}
Esempio n. 5
0
static void
state_set_state(State *state, StateState *sstate)
{
  state->state_type = sstate->state_type;
  
  g_free(sstate);
  
  state_update_data(state);
}
Esempio n. 6
0
static DiaObject *
state_create_activity(Point *startpoint,
	       void *user_data,
  	       Handle **handle1,
	       Handle **handle2)
{
  State *state;
  Element *elem;
  DiaObject *obj;
  Point p;
  DiaFont *font;
  int i;
  
  state = g_malloc0(sizeof(State));
  elem = &state->element;
  obj = &elem->object;
  
  obj->type = &activity_type;
  obj->ops = &state_ops;
  elem->corner = *startpoint;
  elem->width = STATE_WIDTH;
  elem->height = STATE_HEIGHT;

  state->line_color = attributes_get_foreground();
  state->fill_color = attributes_get_background();

  font = dia_font_new_from_style (DIA_FONT_SANS, 0.8);
  p = *startpoint;
  p.x += STATE_WIDTH/2.0;
  p.y += STATE_HEIGHT/2.0;
  
  state->text = new_text("", font, 0.8, &p, &color_black, ALIGN_CENTER);
  text_get_attributes(state->text,&state->attrs);
  element_init(elem, 8, 8);
  
  for (i=0;i<8;i++) {
    obj->connections[i] = &state->connections[i];
    state->connections[i].object = obj;
    state->connections[i].connected = NULL;
  }
  elem->extra_spacing.border_trans = 0.0;
  state_update_data(state);

  for (i=0;i<8;i++) {
    obj->handles[i]->type = HANDLE_NON_MOVABLE;
  }

  *handle1 = NULL;
  *handle2 = NULL;
  return &state->element.object;;
}
Esempio n. 7
0
static DiaObject *
state_create(Point *startpoint,
	       void *user_data,
  	       Handle **handle1,
	       Handle **handle2)
{
  State *state;
  Element *elem;
  DiaObject *obj;
  Point p;
  int i;
  
  state = g_malloc0(sizeof(State));
  elem = &state->element;
  obj = &elem->object;
  
  obj->type = &state_term_type;
  obj->ops = &state_ops;
  elem->corner = *startpoint;
  elem->width = STATE_WIDTH;
  elem->height = STATE_HEIGHT;

  p = *startpoint;
  p.x += STATE_WIDTH/2.0;
  p.y += STATE_HEIGHT/2.0;
  
  state->line_color = attributes_get_foreground();
  state->fill_color = attributes_get_background();
  state->is_final = 0;
  element_init(elem, 8, NUM_CONNECTIONS);
  
  for (i=0;i<NUM_CONNECTIONS;i++) {
    obj->connections[i] = &state->connections[i];
    state->connections[i].object = obj;
    state->connections[i].connected = NULL;
  }
  state->connections[8].flags = CP_FLAGS_MAIN;
  elem->extra_spacing.border_trans = 0.0;
  state_update_data(state);

  for (i=0;i<8;i++) {
    obj->handles[i]->type = HANDLE_NON_MOVABLE;
  }

  *handle1 = NULL;
  *handle2 = NULL;
  return &state->element.object;
}
Esempio n. 8
0
static Object *
state_create(Point *startpoint,
	       void *user_data,
  	       Handle **handle1,
	       Handle **handle2)
{
  State *state;
  Element *elem;
  Object *obj;
  Point p;
  Font *font;
  int i;
  
  state = g_malloc(sizeof(State));
  elem = &state->element;
  obj = (Object *) state;
  
  obj->type = &state_type;
  obj->ops = &state_ops;
  elem->corner = *startpoint;
  elem->width = STATE_WIDTH;
  elem->height = STATE_HEIGHT;

  font = font_getfont("Helvetica");
  p = *startpoint;
  p.x += STATE_WIDTH/2.0;
  p.y += STATE_HEIGHT/2.0;
  
  state->text = new_text("", font, 0.8, &p, &color_black, ALIGN_CENTER);
  state->state_type = STATE_NORMAL;
  element_init(elem, 8, 8);
  
  for (i=0;i<8;i++) {
    obj->connections[i] = &state->connections[i];
    state->connections[i].object = obj;
    state->connections[i].connected = NULL;
  }
  state_update_data(state);

  for (i=0;i<8;i++) {
    obj->handles[i]->type = HANDLE_NON_MOVABLE;
  }

  *handle1 = NULL;
  *handle2 = NULL;
  return (Object *)state;
}
Esempio n. 9
0
static Object *
state_load(ObjectNode obj_node, int version, const char *filename)
{
  State *state;
  Element *elem;
  Object *obj;
  int i;
  AttributeNode attr;

  state = g_malloc(sizeof(State));
  elem = &state->element;
  obj = (Object *) state;
  
  obj->type = &state_type;
  obj->ops = &state_ops;

  element_load(elem, obj_node);
  attr = object_find_attribute(obj_node, "text");
  if (attr != NULL)
      state->text = data_text(attribute_first_data(attr));
  
  attr = object_find_attribute(obj_node, "type");
  if (attr != NULL)
      state->state_type = data_int(attribute_first_data(attr));

  element_init(elem, 8, 8);

  for (i=0;i<8;i++) {
    obj->connections[i] = &state->connections[i];
    state->connections[i].object = obj;
    state->connections[i].connected = NULL;
  }
  state_update_data(state);

  for (i=0;i<8;i++) {
    obj->handles[i]->type = HANDLE_NON_MOVABLE;
  }

  return (Object *)state;
}
Esempio n. 10
0
static ObjectChange *
state_apply_properties(State *state)
{
  StatePropertiesDialog *prop_dialog;
  ObjectState *old_state;

  prop_dialog = properties_dialog;

  old_state = (ObjectState *)state_get_state(state);

  if (GTK_TOGGLE_BUTTON(prop_dialog->normal)->active) 
      state->state_type = STATE_NORMAL;
  else if (GTK_TOGGLE_BUTTON(prop_dialog->begin)->active) 
      state->state_type = STATE_BEGIN;
  else if (GTK_TOGGLE_BUTTON(prop_dialog->end)->active) 
      state->state_type = STATE_END;

  state_update_data(state);
  return new_object_state_change((Object *)state, old_state, 
				 (GetStateFunc)state_get_state,
				 (SetStateFunc)state_set_state);
}
Esempio n. 11
0
static void
state_move(State *state, Point *to)
{
  state->element.corner = *to;
  state_update_data(state);
}