static void merge_changed_cb (glLabel *label,
glLabelObject *object);
+static void set_size (glLabelObject *object,
+ gdouble w,
+ gdouble h);
+
+static void get_size (glLabelObject *object,
+ gdouble *w,
+ gdouble *h);
+
\f
/*****************************************************************************/
/* Boilerplate object stuff. */
static void
gl_label_object_class_init (glLabelObjectClass *klass)
{
- GObjectClass *object_class = (GObjectClass *) klass;
+ GObjectClass *gobject_class = (GObjectClass *) klass;
+ glLabelObjectClass *object_class = (glLabelObjectClass *) klass;
gl_debug (DEBUG_LABEL, "START");
parent_class = g_type_class_peek_parent (klass);
- object_class->finalize = gl_label_object_finalize;
+ gobject_class->finalize = gl_label_object_finalize;
+
+ object_class->set_size = set_size;
+ object_class->get_size = get_size;
signals[CHANGED] =
g_signal_new ("changed",
- G_OBJECT_CLASS_TYPE (object_class),
+ G_OBJECT_CLASS_TYPE (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (glLabelObjectClass, changed),
NULL, NULL,
signals[MOVED] =
g_signal_new ("moved",
- G_OBJECT_CLASS_TYPE (object_class),
+ G_OBJECT_CLASS_TYPE (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (glLabelObjectClass, moved),
NULL, NULL,
2, G_TYPE_DOUBLE, G_TYPE_DOUBLE);
signals[FLIP_ROTATE] =
g_signal_new ("flip_rotate",
- G_OBJECT_CLASS_TYPE (object_class),
+ G_OBJECT_CLASS_TYPE (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (glLabelObjectClass, flip_rotate),
NULL, NULL,
0);
signals[TOP] =
g_signal_new ("top",
- G_OBJECT_CLASS_TYPE (object_class),
+ G_OBJECT_CLASS_TYPE (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (glLabelObjectClass, top),
NULL, NULL,
signals[BOTTOM] =
g_signal_new ("bottom",
- G_OBJECT_CLASS_TYPE (object_class),
+ G_OBJECT_CLASS_TYPE (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (glLabelObjectClass, bottom),
NULL, NULL,
gl_debug (DEBUG_LABEL, "END");
}
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Default set size method. */
+/*---------------------------------------------------------------------------*/
+static void
+set_size (glLabelObject *object,
+ gdouble w,
+ gdouble h)
+{
+ g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
+
+ object->private->w = w;
+ object->private->h = h;
+}
+
/*****************************************************************************/
/* Set size of object. */
/*****************************************************************************/
} else {
- object->private->w = w;
- object->private->h = h;
+ set_size (object, w, h);
+
}
g_signal_emit (G_OBJECT(object), signals[CHANGED], 0);
gl_debug (DEBUG_LABEL, "END");
}
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Default get size method. */
+/*---------------------------------------------------------------------------*/
+static void
+get_size (glLabelObject *object,
+ gdouble *w,
+ gdouble *h)
+{
+ g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
+
+ *w = object->private->w;
+ *h = object->private->h;
+}
+
/*****************************************************************************/
/* Get size of object. */
/*****************************************************************************/
} else {
- *w = object->private->w;
- *h = object->private->h;
+ get_size (object, w, h);
+
}
gl_debug (DEBUG_LABEL, "END");
/* Private globals. */
/*========================================================*/
-static GObjectClass *parent_class = NULL;
+static glLabelObjectClass *parent_class = NULL;
static guint instance = 0;
gl_debug (DEBUG_LABEL, "just = %d", *just);
}
+void
+gl_label_text_get_box (glLabelText *ltext,
+ gdouble *w,
+ gdouble *h)
+{
+ g_return_if_fail (ltext && GL_IS_LABEL_TEXT (ltext));
+
+ /* peek at the parent size. */
+ (* parent_class->get_size) (GL_LABEL_OBJECT(ltext), w, h);
+}
+
/*---------------------------------------------------------------------------*/
/* PRIVATE. text buffer "changed" callback. */
/*---------------------------------------------------------------------------*/
GnomeGlyphList *glyphlist;
ArtDRect bbox;
gdouble affine[6];
+ gdouble w_parent, h_parent;
gl_debug (DEBUG_LABEL, "START");
g_return_if_fail (ltext && GL_IS_LABEL_TEXT (ltext));
+ (* parent_class->get_size) (object, &w_parent, &h_parent);
+
font = gnome_font_find_closest_from_weight_slant (
ltext->private->font_family,
ltext->private->font_weight,
}
+ if ( *h == 0.0 ) *h = ltext->private->font_size;
+
+ if ( *w < w_parent ) *w = w_parent;
+ if ( *h < h_parent ) *h = h_parent;
+
g_strfreev (line);
gl_debug (DEBUG_LABEL, "END");
gboolean *font_italic_flag,
guint *color,
GtkJustification *just);
+void gl_label_text_get_box (glLabelText *ltext,
+ gdouble *w,
+ gdouble *h);
G_END_DECLS
gl_view_object_set_view (GL_VIEW_OBJECT(view_text), view);
gl_view_object_set_object (GL_VIEW_OBJECT(view_text),
GL_LABEL_OBJECT(object),
- GL_VIEW_HIGHLIGHT_SIMPLE);
+ GL_VIEW_HIGHLIGHT_BOX_RESIZABLE);
group = gl_view_object_get_group (GL_VIEW_OBJECT(view_text));
{
GObject *object;
GList *lines;
+ gdouble w, h;
gchar *font_family;
gdouble font_size;
GnomeFontWeight font_weight;
object = gl_label_text_new (label);
+ w = gl_xml_get_prop_double (object_node, "w", 0);
+ h = gl_xml_get_prop_double (object_node, "h", 0);
+
font_family = xmlGetProp (object_node, "font_family");
font_size = gl_xml_get_prop_double (object_node, "font_size", 0.0);
}
- gl_label_text_set_lines (GL_LABEL_TEXT(object), lines);
- gl_label_text_set_props (GL_LABEL_TEXT(object),
- font_family, font_size, font_weight,
- font_italic_flag,
- color, just);
+ gl_label_object_set_size (GL_LABEL_OBJECT(object), w, h);
+ gl_label_text_set_lines (GL_LABEL_TEXT(object), lines);
+ gl_label_text_set_props (GL_LABEL_TEXT(object),
+ font_family, font_size, font_weight,
+ font_italic_flag,
+ color, just);
gl_text_node_lines_free (&lines);
g_free (font_family);
{
xmlNodePtr line_node, field_node, literal_node;
GList *lines;
+ gdouble w, h;
gchar *font_family;
gdouble font_size;
GnomeFontWeight font_weight;
xmlSetProp (object_node, "type", "Text");
+ gl_label_text_get_box ( GL_LABEL_TEXT(object), &w, &h);
lines = gl_label_text_get_lines (GL_LABEL_TEXT(object));
gl_label_text_get_props (GL_LABEL_TEXT(object),
&font_family, &font_size, &font_weight,
&font_italic_flag,
&color, &just);
+ string = g_strdup_printf ("%g", w);
+ xmlSetProp (object_node, "w", string);
+ g_free (string);
+ string = g_strdup_printf ("%g", h);
+ xmlSetProp (object_node, "h", string);
+ g_free (string);
+
xmlSetProp (object_node, "font_family", font_family);
string = g_strdup_printf ("%g", font_size);
xmlSetProp (object_node, "font_size", string);