The association patch fixes the placement of role/multiplicity labels in
the UML association object when arrows or agregation adornments are
active.
The second patch, makes clicking the canvas give it focus. That is
convenient since there is now a "zoom" combo box which takes away focus
from the canvas.
I'm sending these two patches as attachments in the hope they're not
filtered out by the mailing-list software..
--
Gustavo J.A.M. Carneiro
[linuxdeec.fe.up.pt/~ee96090]
--- dia-orig/app/disp_callbacks.c Sat Nov 25 15:40:48 2000
+++ dia/app/disp_callbacks.c Sat Dec 9 20:58:57 2000
@@ -438,6 +438,7 @@
switch (bevent->button)
{
case 1:
+ gtk_widget_grab_focus(canvas);
if (*active_tool->button_press_func)
(*active_tool->button_press_func) (active_tool, bevent, ddisp);
break;
--- dia-orig/objects/UML/association.c Fri Mar 24 01:20:41 2000
+++ dia/objects/UML/association.c Fri Dec 8 14:05:36 2000
@@ -422,7 +422,7 @@
{
OrthConn *orth = &assoc->orth;
Object *obj = (Object *) assoc;
- int num_segm, i, n;
+ int num_segm, i, e;
Point *points;
Rectangle rect;
AssociationEnd *end;
@@ -472,60 +472,101 @@
/* Update the text-points of the ends: */
- /* END 1: */
- end = &assoc->end[0];
- end->text_pos = points[0];
- switch (assoc->orth.orientation[0]) {
- case HORIZONTAL:
- end->text_pos.y -= font_descent(assoc_font, ASSOCIATION_FONTHEIGHT);
- if (points[0].x < points[1].x)
- end->text_align = ALIGN_LEFT;
- else
- end->text_align = ALIGN_RIGHT;
- break;
- case VERTICAL:
- end->text_pos.y += font_ascent(assoc_font, ASSOCIATION_FONTHEIGHT);
- end->text_align = ALIGN_LEFT;
- break;
- }
- /* Add the text recangle to the bounding box: */
- rect.left = end->text_pos.x;
- rect.right = rect.left + end->text_width;
- rect.top = end->text_pos.y - font_ascent(assoc_font, ASSOCIATION_FONTHEIGHT);
- rect.bottom = rect.top + 2*ASSOCIATION_FONTHEIGHT;
-
- rectangle_union(&obj->bounding_box, &rect);
+ for (e = 0; e < 2; e++) {
+ int iep, inep; /* index of end point, index of next-to-end point */
+ Orientation orientation;
+ /* which end? */
+ if (e == 0) {
+ iep = 0;
+ inep = 1;
+ end = &assoc->end[0];
+ orientation = assoc->orth.orientation[0];
+ } else {
+ iep = assoc->orth.numpoints - 1;
+ inep = assoc->orth.numpoints - 2;
+ orientation = assoc->orth.orientation[inep];
+ end = &assoc->end[1];
+ }
+
+ end->text_pos = points[iep];
+
+ switch (orientation) {
+ case HORIZONTAL:
+ end->text_pos.y -= font_descent(assoc_font, ASSOCIATION_FONTHEIGHT);
+ if (points[iep].x < points[inep].x) {
+ end->text_align = ALIGN_LEFT;
+ if (end->arrow)
+ end->text_pos.x += ASSOCIATION_TRIANGLESIZE;
+ switch (end->aggregate) {
+ case AGGREGATE_NONE:
+ break;
+ case AGGREGATE_NORMAL:
+ case AGGREGATE_COMPOSITION:
+ end->text_pos.x += ASSOCIATION_DIAMONDLEN;
+ break;
+ }
+ } else {
+ end->text_align = ALIGN_RIGHT;
+ if (end->arrow)
+ end->text_pos.x -= ASSOCIATION_TRIANGLESIZE;
+ switch (end->aggregate) {
+ case AGGREGATE_NONE:
+ break;
+ case AGGREGATE_NORMAL:
+ case AGGREGATE_COMPOSITION:
+ end->text_pos.x -= ASSOCIATION_DIAMONDLEN;
+ break;
+ }
+ }
+ break;
+ case VERTICAL:
+ end->text_pos.y += font_ascent(assoc_font, ASSOCIATION_FONTHEIGHT);
+ if (points[iep].y > points[inep].y) {
+ if (end->role!=NULL)
+ end->text_pos.y -= ASSOCIATION_FONTHEIGHT;
+ if (end->multiplicity!=NULL)
+ end->text_pos.y -= ASSOCIATION_FONTHEIGHT;
+ }
- /* END 2: */
- end = &assoc->end[1];
- n = assoc->orth.numpoints - 1;
- end->text_pos = points[n];
- switch (assoc->orth.orientation[n-1]) {
- case HORIZONTAL:
- end->text_pos.y -= font_descent(assoc_font, ASSOCIATION_FONTHEIGHT);
- if (points[n].x < points[n-1].x)
end->text_align = ALIGN_LEFT;
- else
- end->text_align = ALIGN_RIGHT;
- break;
- case VERTICAL:
- end->text_pos.y += font_ascent(assoc_font, ASSOCIATION_FONTHEIGHT);
- if (points[n].y > points[n-1].y) {
- if (end->role!=NULL)
- end->text_pos.y -= ASSOCIATION_FONTHEIGHT;
- if (end->multiplicity!=NULL)
- end->text_pos.y -= ASSOCIATION_FONTHEIGHT;
+ if (points[iep].y < points[inep].y) {
+ if (end->arrow)
+ end->text_pos.y += ASSOCIATION_TRIANGLESIZE;
+ switch (end->aggregate) {
+ case AGGREGATE_NONE:
+ break;
+ case AGGREGATE_NORMAL:
+ case AGGREGATE_COMPOSITION:
+ end->text_pos.y += ASSOCIATION_DIAMONDLEN;
+ break;
+ }
+ } else {
+ if (end->arrow)
+ end->text_pos.y -= ASSOCIATION_TRIANGLESIZE;
+ switch (end->aggregate) {
+ case AGGREGATE_NONE:
+ break;
+ case AGGREGATE_NORMAL:
+ case AGGREGATE_COMPOSITION:
+ end->text_pos.y -= ASSOCIATION_DIAMONDLEN;
+ break;
+ }
+ }
+ break;
}
- end->text_align = ALIGN_LEFT;
- break;
- }
- /* Add the text recangle to the bounding box: */
- rect.left = end->text_pos.x;
- rect.right = rect.left + end->text_width;
- rect.top = end->text_pos.y - font_ascent(assoc_font, ASSOCIATION_FONTHEIGHT);
- rect.bottom = rect.top + 2*ASSOCIATION_FONTHEIGHT;
+ /* Add the text recangle to the bounding box: */
+ if (end->text_align == ALIGN_LEFT) {
+ rect.left = end->text_pos.x;
+ rect.right = rect.left + end->text_width;
+ } else {
+ rect.right = end->text_pos.x;
+ rect.left = rect.left + end->text_width;
+ }
+ rect.top = end->text_pos.y - font_ascent(assoc_font, ASSOCIATION_FONTHEIGHT);
+ rect.bottom = rect.top + 2*ASSOCIATION_FONTHEIGHT;
- rectangle_union(&obj->bounding_box, &rect);
+ rectangle_union(&obj->bounding_box, &rect);
+ } /* for (e = 0; e < 2; e++) { */
}
static Object *