Re: function to resize a UML class object's extent?
From: "Andrew S . Halper" <ashalper acm org>
To: dia-list gnome org
Subject: Re: function to resize a UML class object's extent?
Date: Wed, 28 Nov 2001 21:17:29 -0700
On 2001.11.28 11:54 Lars Clausen wrote:
> On Wed, 28 Nov 2001, Andrew S. wrote:
>
> > On 2001.11.28 08:28 Lars Clausen wrote:
> >> On Wed, 28 Nov 2001, Andrew S. wrote:
> >>
> >> > Anyone know which function I should call (or property to set) to
> >> > resize a class object's borders around the text inside? I took a look
> >> > at umlclass_create() in objects/UML/class.c, but I didn't see anything
> >> > obvious.
> >> >
> >> > My problem is I'm creating UML class objects on a diagram, and most of
> >> > the time the string in the class name is too big for the default
> >> > extent of the class box, so it winds up looking like:
> >> >
> >> > +-------+
> >> > A_lon|g_class|_name
> >> > +-------+
> >> >
> >> > and generally leaves a mess when the object is dragged around the
> >> > diagram.
> >> >
> >> > I'm doing all this from a plug-in.
> >>
> >> The standard function to call is objet_update_data(). How are you
> >> currently changing the text?
> >
> > Like this:
> >
> > /* the {persistent} tag should be made optional (or at least
> > concealable) eventually */
> > nameprop->string_data =
> > g_strdup_printf("%s {persistent}",
> > gschema_element->base_table_def_sql->table_sql->str);
> > /* this compulsory capitalization of class-names-as-table-names
> > should be made optional eventually */
> > nameprop->string_data[0] =
> > (char) toupper((int)
> > gschema_element->base_table_def_sql->table_sql->str[0]);
> > g_strdown(nameprop->string_data + 1);
> >
> > umlclass_obj->ops->set_props(umlclass_obj, props);
> >
> > /* need some code here to fit the size of the class box to the
> > size of the class name (which doesn't happen automatically) a
> > la Properties->Apply button */
>
> Well, it should happen automatically when set_props is called. That it
> doesn't is a problem in object.c, or possibly deeper, in the properties.
> The text is a sub-object, and its width doesn't get updated after
> set_props. The update_data function doesn't update the width of the text
> object, obviously that object is expected to handle it itself. But somehow
> the text change is propagated to the text object without the width being
> set? I'm a little confused about this. Your code looks good to me.
> Cyrille, do you have any comments on the property updates?
Dinking around in gdb in a feeble attempt to understand the code, I find, on the
last line of lib/boundingbox.c:
/* TODO: text_bbox ? */
after which I said "Chepelov!" in the way Jerry used to say "Newman!" on
Seinfeld.
Seriously, I don't know if this is the problem or not, but it was quite funny to
see at the end of that tedious gdb stepping. Could it be it was just never
written?
Thanks,
Andy