示例#1
0
文件: text.c 项目: jbohren-forks/dia
Text *
new_text(const char *string, DiaFont *font, real height,
	 Point *pos, Color *color, Alignment align)
{
  Text *text;

  text = g_new(Text, 1);

  text->font = dia_font_ref(font);
  text->height = height;

  text->position = *pos;
  text->color = *color;
  text->alignment = align;

  text->cursor_pos = 0;
  text->cursor_row = 0;
  
  text->focus.obj = NULL;
  text->focus.has_focus = FALSE;
  text->focus.key_event = text_key_event;
  text->focus.text = text;
  
  set_string(text, string);

  calc_ascent_descent(text);

  return text;
}
示例#2
0
/** Set the default font.
 * Note that this is not currently stored persistently.
 * @param font The font to set as the new default.
 *        This object will be ref'd by this call.
 * @param font_height The font height to set as the new default.
 */
void
attributes_set_default_font(DiaFont *font, real font_height)
{
  if (attributes_font != NULL)
    dia_font_unref(attributes_font);  
  attributes_font = dia_font_ref(font);
  attributes_font_height = font_height;
}
示例#3
0
/** Get the default font.
 * Note that there is currently no way for the user to set these.
 * @param font A place to return the default font description set by the user
 * @param font_height A place to return the default font height set by the user
 */
void
attributes_get_default_font(DiaFont **font, real *font_height)
{
	if (!attributes_font) {
		attributes_font = dia_font_new_from_style(DIA_FONT_SANS,
                                              attributes_font_height);
	}
	if (font)
		*font = dia_font_ref(attributes_font);
	if (font_height)
		*font_height = attributes_font_height;
}
示例#4
0
文件: text.c 项目: jbohren-forks/dia
void
text_get_attributes(Text *text, TextAttributes *attr)
{    
  DiaFont *old_font;
  old_font = attr->font;
  attr->font = dia_font_ref(text->font);
  if (old_font != NULL) dia_font_unref(old_font);
  attr->height = text->height;
  attr->position = text->position;
  attr->color = text->color;
  attr->alignment = text->alignment;
}
示例#5
0
Boolequation *
boolequation_create(const gchar *value, DiaFont *font, real fontheight,
                    Color *color)
{
    Boolequation *booleq;

    booleq = g_new0(Boolequation,1);
    booleq->font = dia_font_ref(font);
    booleq->fontheight = fontheight;
    booleq->color = *color;
    boolequation_set_value(booleq,value);

    return booleq;
}
示例#6
0
文件: transition.c 项目: UIKit0/dia
static void
transition_set_props(Transition *transition, GPtrArray *props)
{
  object_set_props_from_offsets(&transition->element.object,
                                transition_offsets,props);

  boolequation_set_value(transition->receptivity,transition->rcep_value);
  dia_font_unref(transition->receptivity->font);
  transition->receptivity->font = dia_font_ref(transition->rcep_font);
  transition->receptivity->fontheight = transition->rcep_fontheight;
  transition->receptivity->color = transition->rcep_color;

  transition_update_data(transition);
}
示例#7
0
文件: text.c 项目: jbohren-forks/dia
void
text_set_font(Text *text, DiaFont *font)
{
  DiaFont *old_font = text->font;
  int i;

  text->font = dia_font_ref(font);
  dia_font_unref(old_font);

  for (i = 0; i < text->numlines; i++) {
    text_line_set_font(text->lines[i], font);
  }
  
  calc_width(text);
  calc_ascent_descent(text);
}
示例#8
0
static void
set_font(DiaRenderer *self, DiaFont *font, real height)
{
  DiaPsFt2Renderer *renderer = DIA_PS_FT2_RENDERER(self);

  if (renderer->current_font != font) {
    if (renderer->current_font != NULL) {
      dia_font_unref(renderer->current_font);
    }
    renderer->current_font = font;
    /* Dammit!  We have a random factor once again! 
     * And not only here but also in dia_font_scaled_build_layout() below ...
     */
    renderer->current_height = height/**4.3*/;
    dia_font_ref(font);
  }
  pango_context_set_font_description(dia_font_get_context(), 
				     dia_font_get_description(font));
}
示例#9
0
static void
set_font(DiaRenderer *self, DiaFont *font, real height)
{
  DiaCairoRenderer *renderer = DIA_CAIRO_RENDERER (self);
#ifndef HAVE_PANGOCAIRO_H
  DiaFontStyle style = dia_font_get_style (font);
  const char *family_name;
#endif
  /* pango/cairo wants the font size, not the (line-) height */
  real size = dia_font_get_size (font) * (height / dia_font_get_height (font));

  PangoFontDescription *pfd = pango_font_description_copy (dia_font_get_description (font));
  DIAG_NOTE(g_message("set_font %f %s", height, dia_font_get_family(font)));

#ifdef HAVE_PANGOCAIRO_H
  /* select font and size */
  pango_font_description_set_absolute_size (pfd, (int)(size * PANGO_SCALE));
  pango_layout_set_font_description (renderer->layout, pfd);
  pango_font_description_free (pfd);
#else
  family_name = dia_font_get_family(font);

  cairo_select_font_face (
      renderer->cr,
      family_name,
      DIA_FONT_STYLE_GET_SLANT(style) == DIA_FONT_NORMAL ? CAIRO_FONT_SLANT_NORMAL : CAIRO_FONT_SLANT_ITALIC,
      DIA_FONT_STYLE_GET_WEIGHT(style) < DIA_FONT_MEDIUM ? CAIRO_FONT_WEIGHT_NORMAL : CAIRO_FONT_WEIGHT_BOLD); 
  cairo_set_font_size (renderer->cr, size);
#endif

  DIAG_STATE(renderer->cr)
  
  /* for the interactive case we must maintain the font field in the base class */
  if (self->is_interactive) {
    dia_font_ref(font);
    if (self->font)
      dia_font_unref(self->font);
    self->font = font;
    self->font_height = height;
  }
}
示例#10
0
static DiaObject *
attribute_copy(Attribute *attribute)
{
  int i;
  Attribute *newattribute;
  Element *elem, *newelem;
  DiaObject *newobj;
  
  elem = &attribute->element;
  
  newattribute = g_malloc0(sizeof(Attribute));
  newelem = &newattribute->element;
  newobj = &newelem->object;

  element_copy(elem, newelem);

  newattribute->border_width = attribute->border_width;
  newattribute->border_color = attribute->border_color;
  newattribute->inner_color = attribute->inner_color;

  for (i=0;i<NUM_CONNECTIONS;i++) {
    newobj->connections[i] = &newattribute->connections[i];
    newattribute->connections[i].object = newobj;
    newattribute->connections[i].connected = NULL;
    newattribute->connections[i].pos = attribute->connections[i].pos;
    newattribute->connections[i].last_pos = attribute->connections[i].last_pos;
    newattribute->connections[i].flags = attribute->connections[i].flags;
  }
  
  newattribute->font = dia_font_ref(attribute->font);
  newattribute->font_height = attribute->font_height;
  newattribute->name = g_strdup(attribute->name);
  newattribute->name_width = attribute->name_width;

  newattribute->key = attribute->key;
  newattribute->weakkey = attribute->weakkey;
  newattribute->derived = attribute->derived;
  newattribute->multivalue = attribute->multivalue;

  return &newattribute->element.object;
}
示例#11
0
static void
set_font(DiaRenderer *self, DiaFont *font, real height)
{
  DiaPsRenderer *renderer = DIA_PS_RENDERER(self);
  gchar h_buf[DTOSTR_BUF_SIZE];

  if (font != self->font || height != self->font_height) {
    DiaFont *old_font;

    fprintf(renderer->file, "/%s-latin1 ff %s scf sf\n",
	    dia_font_get_psfontname(font),
	    psrenderer_dtostr(h_buf, (gdouble) height*0.7) );
    old_font = self->font;
    self->font = font;
    dia_font_ref(self->font);
    if (old_font != NULL) {
      dia_font_unref(old_font);
    }
    self->font_height = height;
  }
}
示例#12
0
文件: transition.c 项目: UIKit0/dia
static DiaObject *
transition_create(Point *startpoint,
		  void *user_data,
		  Handle **handle1,
		  Handle **handle2)
{
  Transition *transition;
  DiaObject *obj;
  int i;
  Element *elem;
  DiaFont *default_font = NULL; 
  real default_fontheight;
  Color fg_color;

  transition = g_malloc0(sizeof(Transition));
  elem = &transition->element;
  obj = &elem->object;
  
  obj->type = &transition_type;
  obj->ops = &transition_ops;
  
  elem->corner = *startpoint;
  elem->width = TRANSITION_DECLAREDWIDTH;
  elem->height = TRANSITION_DECLAREDHEIGHT;

  element_init(elem, 10,2);

  attributes_get_default_font(&default_font,&default_fontheight);
  fg_color = attributes_get_foreground();
  
  transition->receptivity = 
    boolequation_create("",
                        default_font,
                        default_fontheight,
                        &fg_color);

  transition->rcep_value = g_strdup("");
  transition->rcep_font = dia_font_ref(default_font);
  transition->rcep_fontheight = default_fontheight;
  transition->rcep_color = fg_color;

  dia_font_unref(default_font);
  

  for (i=0;i<8;i++) {
    obj->handles[i]->type = HANDLE_NON_MOVABLE;
  }
  obj->handles[8] = &transition->north;
  obj->handles[9] = &transition->south;
  transition->north.connect_type = HANDLE_CONNECTABLE;
  transition->north.type = HANDLE_MAJOR_CONTROL;
  transition->north.id = HANDLE_NORTH;
  transition->south.connect_type = HANDLE_CONNECTABLE;
  transition->south.type = HANDLE_MAJOR_CONTROL;
  transition->south.id = HANDLE_SOUTH;
  transition->north.pos.x = -65536.0; /* magic */

  for (i=0;i<2;i++) {
    obj->connections[i] = &transition->connections[i];
    obj->connections[i]->object = obj;
    obj->connections[i]->connected = NULL;
  }

  transition_update_data(transition);

  *handle1 = NULL;
  *handle2 = obj->handles[0];  

  return &transition->element.object;
}