作図ソフト dia の改良版
Révision | f4dc25cdb0a8e4f21037fb8d1561849c2b44410b (tree) |
---|---|
l'heure | 2001-06-11 06:11:16 |
Auteur | Cyrille Chepelov <cyrille@src....> |
Commiter | Cyrille Chepelov |
a NULL point can be given to connpointline_adjust_count(), in case there's
* lib/connpoint_line.c: a NULL point can be given to
connpointline_adjust_count(), in case there's not really a clicked
point.
* lib/properties.[ch]: added support for CONNPOINT_LINE properties.
* objects/GRAFCET/vergent.c: dropped lazyprops for standard
properties.
* objects/UML/lifeline.c: pruned some legacy stuff (now pure
standard properties code). Grafted a dynamic number of connection
points (heavily inspired from what Vergent does). This is the real
fix for #55863.
@@ -1,3 +1,18 @@ | ||
1 | +2001-06-10 Cyrille Chepelov <chepelov@calixo.net> | |
2 | + | |
3 | + * lib/connpoint_line.c: a NULL point can be given to | |
4 | + connpointline_adjust_count(), in case there's not really a clicked | |
5 | + point. | |
6 | + * lib/properties.[ch]: added support for CONNPOINT_LINE properties. | |
7 | + | |
8 | + * objects/GRAFCET/vergent.c: dropped lazyprops for standard | |
9 | + properties. | |
10 | + | |
11 | + * objects/UML/lifeline.c: pruned some legacy stuff (now pure | |
12 | + standard properties code). Grafted a dynamic number of connection | |
13 | + points (heavily inspired from what Vergent does). This is the real | |
14 | + fix for #55863. | |
15 | + | |
1 | 16 | 2001-06-09 Cyrille Chepelov <chepelov@calixo.net> |
2 | 17 | |
3 | 18 | * app/app_procs.c (app_init): added a call to |
@@ -363,6 +363,8 @@ cpl_get_pointbefore(ConnPointLine *cpl, Point *clickedpoint) | ||
363 | 363 | real dist = 65536.0; |
364 | 364 | real tmpdist; |
365 | 365 | |
366 | + if (!clickedpoint) return 0; | |
367 | + | |
366 | 368 | for (i=0,elem=cpl->connections; |
367 | 369 | i<cpl->num_connections; |
368 | 370 | i++,elem=g_slist_next(elem)) { |
@@ -1,5 +1,4 @@ | ||
1 | -/* | |
2 | - * SADT diagram support for dia | |
1 | +/* Dynamic container for connection points -*- c -*- | |
3 | 2 | * Copyright(C) 2000 Cyrille Chepelov |
4 | 3 | * |
5 | 4 | * Connection point line is a helper struct, to hold a few connection points |
@@ -34,6 +34,7 @@ | ||
34 | 34 | |
35 | 35 | #include "intl.h" |
36 | 36 | #include "widgets.h" |
37 | +#include "connpoint_line.h" | |
37 | 38 | |
38 | 39 | #define LIBDIA_COMPILATION |
39 | 40 | #undef G_INLINE_FUNC |
@@ -183,6 +184,7 @@ prop_copy(Property *dest, Property *src) | ||
183 | 184 | case PROP_TYPE_ARROW: |
184 | 185 | case PROP_TYPE_COLOUR: |
185 | 186 | case PROP_TYPE_FONT: |
187 | + case PROP_TYPE_CONNPOINT_LINE: | |
186 | 188 | case PROP_TYPE_ENDPOINTS: |
187 | 189 | dest->d = src->d; |
188 | 190 | break; |
@@ -243,6 +245,7 @@ prop_free(Property *prop) | ||
243 | 245 | case PROP_TYPE_ARROW: |
244 | 246 | case PROP_TYPE_COLOUR: |
245 | 247 | case PROP_TYPE_ENDPOINTS: |
248 | + case PROP_TYPE_CONNPOINT_LINE: | |
246 | 249 | case PROP_TYPE_FONT: |
247 | 250 | break; |
248 | 251 | case PROP_TYPE_STRING: |
@@ -378,6 +381,7 @@ prop_get_widget(Property *prop) | ||
378 | 381 | case PROP_TYPE_BEZPOINT: |
379 | 382 | case PROP_TYPE_BEZPOINTARRAY: |
380 | 383 | case PROP_TYPE_ENDPOINTS: |
384 | + case PROP_TYPE_CONNPOINT_LINE: | |
381 | 385 | case PROP_TYPE_RECT: |
382 | 386 | ret = gtk_label_new(_("No edit widget")); |
383 | 387 | break; |
@@ -457,6 +461,7 @@ prop_set_from_widget(Property *prop, GtkWidget *widget) | ||
457 | 461 | case PROP_TYPE_BEZPOINT: |
458 | 462 | case PROP_TYPE_BEZPOINTARRAY: |
459 | 463 | case PROP_TYPE_ENDPOINTS: |
464 | + case PROP_TYPE_CONNPOINT_LINE: | |
460 | 465 | case PROP_TYPE_RECT: |
461 | 466 | /* nothing */ |
462 | 467 | break; |
@@ -508,7 +513,13 @@ prop_load(Property *prop, ObjectNode obj_node) | ||
508 | 513 | if (!PROP_IS_OTHER(prop->type)) { |
509 | 514 | attr = object_find_attribute(obj_node, prop->name); |
510 | 515 | if (!attr) { |
511 | - g_warning("Could not find attribute %s", prop->name); | |
516 | + switch(prop->type) { | |
517 | + case PROP_TYPE_CONNPOINT_LINE: | |
518 | + PROP_VALUE_CONNPOINT_LINE(*prop) = 1; | |
519 | + break; | |
520 | + default: | |
521 | + g_warning("Could not find attribute %s", prop->name); | |
522 | + } | |
512 | 523 | return; |
513 | 524 | } |
514 | 525 | data = attribute_first_data(attr); |
@@ -622,6 +633,9 @@ prop_load(Property *prop, ObjectNode obj_node) | ||
622 | 633 | g_free(PROP_VALUE_FILE(*prop)); |
623 | 634 | PROP_VALUE_FILE(*prop) = data_string(data); |
624 | 635 | break; |
636 | + case PROP_TYPE_CONNPOINT_LINE: | |
637 | + PROP_VALUE_CONNPOINT_LINE(*prop) = data_int(data); | |
638 | + break; | |
625 | 639 | default: |
626 | 640 | if (custom_props == NULL || prop->type - PROP_LAST >= custom_props->len) { |
627 | 641 | g_warning("prop type id %d out of range!!!", prop->type); |
@@ -675,6 +689,9 @@ prop_save(Property *prop, ObjectNode obj_node) | ||
675 | 689 | case PROP_TYPE_INT: |
676 | 690 | data_add_int(attr, PROP_VALUE_INT(*prop)); |
677 | 691 | break; |
692 | + case PROP_TYPE_CONNPOINT_LINE: | |
693 | + data_add_int(attr,PROP_VALUE_CONNPOINT_LINE(*prop)); | |
694 | + break; | |
678 | 695 | case PROP_TYPE_ENUM: |
679 | 696 | data_add_enum(attr, PROP_VALUE_ENUM(*prop)); |
680 | 697 | break; |
@@ -859,6 +876,10 @@ object_get_props_from_offsets(Object *obj, PropOffset *offsets, | ||
859 | 876 | PROP_VALUE_INT(props[i]) = |
860 | 877 | struct_member(obj, offsets[j].offset, gint); |
861 | 878 | break; |
879 | + case PROP_TYPE_CONNPOINT_LINE: | |
880 | + PROP_VALUE_CONNPOINT_LINE(props[i]) = | |
881 | + struct_member(obj,offsets[j].offset, ConnPointLine *)->num_connections; | |
882 | + break; | |
862 | 883 | case PROP_TYPE_REAL: |
863 | 884 | PROP_VALUE_REAL(props[i]) = |
864 | 885 | struct_member(obj, offsets[j].offset, real); |
@@ -968,6 +989,13 @@ object_set_props_from_offsets(Object *obj, PropOffset *offsets, | ||
968 | 989 | struct_member(obj, offsets[j].offset, gint) = |
969 | 990 | PROP_VALUE_INT(props[i]); |
970 | 991 | break; |
992 | + case PROP_TYPE_CONNPOINT_LINE: | |
993 | + connpointline_adjust_count(struct_member(obj,offsets[j].offset, | |
994 | + ConnPointLine *), | |
995 | + PROP_VALUE_CONNPOINT_LINE(props[i]), | |
996 | + &struct_member(obj,offsets[j].offset, | |
997 | + ConnPointLine *)->end); | |
998 | + break; | |
971 | 999 | case PROP_TYPE_REAL: |
972 | 1000 | struct_member(obj, offsets[j].offset, real) = |
973 | 1001 | PROP_VALUE_REAL(props[i]); |
@@ -1,4 +1,4 @@ | ||
1 | -/* Dia -- a diagram creation/manipulation program | |
1 | +/* Dia -- a diagram creation/manipulation program -*- c -*- | |
2 | 2 | * Copyright (C) 1998 Alexander Larsson |
3 | 3 | * |
4 | 4 | * properties.h: property system for dia objects/shapes. |
@@ -61,6 +61,7 @@ typedef enum { | ||
61 | 61 | PROP_TYPE_FONT, |
62 | 62 | PROP_TYPE_FILE, |
63 | 63 | PROP_TYPE_ENDPOINTS, |
64 | + PROP_TYPE_CONNPOINT_LINE, | |
64 | 65 | |
65 | 66 | PROP_LAST |
66 | 67 | } PropType; |
@@ -118,6 +119,7 @@ struct _Property { | ||
118 | 119 | struct { |
119 | 120 | Point endpoints[2]; |
120 | 121 | } endpoints_data; |
122 | + gint connpoint_line_data; | |
121 | 123 | gpointer other_data; |
122 | 124 | } d; |
123 | 125 | }; |
@@ -151,6 +153,7 @@ struct _PropEnumData { | ||
151 | 153 | #define PROP_VALUE_FILE(prop) ((prop).d.string_data) |
152 | 154 | #define PROP_VALUE_OTHER(prop) ((prop).d.other_data) |
153 | 155 | #define PROP_VALUE_ENDPOINTS(prop) ((prop).d.endpoints_data) |
156 | +#define PROP_VALUE_CONNPOINT_LINE(prop) ((prop).d.connpoint_line_data) | |
154 | 157 | |
155 | 158 | /* Copy the data member of the property |
156 | 159 | * If NULL, then just copy data member straight */ |
@@ -36,7 +36,7 @@ | ||
36 | 36 | #include "widgets.h" |
37 | 37 | #include "message.h" |
38 | 38 | #include "color.h" |
39 | -#include "lazyprops.h" | |
39 | +#include "properties.h" | |
40 | 40 | #include "geometry.h" |
41 | 41 | #include "connpoint_line.h" |
42 | 42 |
@@ -48,16 +48,6 @@ | ||
48 | 48 | |
49 | 49 | typedef enum { VERGENT_OR, VERGENT_AND } VergentType; |
50 | 50 | |
51 | -typedef struct _VergentPropertiesDialog VergentPropertiesDialog; | |
52 | -typedef struct _VergentDefaultsDialog VergentDefaultsDialog; | |
53 | -typedef struct _VergentState VergentState; | |
54 | - | |
55 | -struct _VergentState { | |
56 | - ObjectState obj_state; | |
57 | - | |
58 | - VergentType type; | |
59 | -}; | |
60 | - | |
61 | 51 | typedef struct _Vergent { |
62 | 52 | Connection connection; |
63 | 53 |
@@ -67,30 +57,9 @@ typedef struct _Vergent { | ||
67 | 57 | VergentType type; |
68 | 58 | } Vergent; |
69 | 59 | |
70 | -struct _VergentPropertiesDialog { | |
71 | - AttributeDialog dialog; | |
72 | - Vergent *parent; | |
73 | - | |
74 | - EnumAttribute type; | |
75 | -}; | |
76 | - | |
77 | -typedef struct _VergentDefaults { | |
78 | - VergentType type; | |
79 | -} VergentDefaults; | |
80 | - | |
81 | -struct _VergentDefaultsDialog { | |
82 | - AttributeDialog dialog; | |
83 | - VergentDefaults *parent; | |
84 | - | |
85 | - EnumAttribute type; | |
86 | -}; | |
87 | - | |
88 | -static VergentPropertiesDialog *vergent_properties_dialog; | |
89 | -static VergentDefaultsDialog *vergent_defaults_dialog; | |
90 | -static VergentDefaults defaults; | |
91 | - | |
92 | 60 | static void vergent_move_handle(Vergent *vergent, Handle *handle, |
93 | - Point *to, HandleMoveReason reason, ModifierKeys modifiers); | |
61 | + Point *to, HandleMoveReason reason, | |
62 | + ModifierKeys modifiers); | |
94 | 63 | static void vergent_move(Vergent *vergent, Point *to); |
95 | 64 | static void vergent_select(Vergent *vergent, Point *clicked_point, |
96 | 65 | Renderer *interactive_renderer); |
@@ -102,17 +71,13 @@ static Object *vergent_create(Point *startpoint, | ||
102 | 71 | static real vergent_distance_from(Vergent *vergent, Point *point); |
103 | 72 | static void vergent_update_data(Vergent *vergent); |
104 | 73 | static void vergent_destroy(Vergent *vergent); |
105 | -static Object *vergent_copy(Vergent *vergent); | |
106 | -static GtkWidget *vergent_get_properties(Vergent *vergent); | |
107 | -static ObjectChange *vergent_apply_properties(Vergent *vergent); | |
108 | - | |
109 | -static VergentState *vergent_get_state(Vergent *vergent); | |
110 | -static void vergent_set_state(Vergent *vergent, VergentState *state); | |
111 | - | |
112 | -static void vergent_save(Vergent *vergent, ObjectNode obj_node, | |
113 | - const char *filename); | |
114 | 74 | static Object *vergent_load(ObjectNode obj_node, int version, |
115 | - const char *filename); | |
75 | + const char *filename); | |
76 | +static PropDescription *vergent_describe_props(Vergent *vergent); | |
77 | +static void vergent_get_props(Vergent *vergent, | |
78 | + Property *props, guint nprops); | |
79 | +static void vergent_set_props(Vergent *vergent, | |
80 | + Property *props, guint nprops); | |
116 | 81 | |
117 | 82 | static DiaMenu *vergent_get_object_menu(Vergent *vergent, |
118 | 83 | Point *clickedpoint); |
@@ -120,8 +85,8 @@ static DiaMenu *vergent_get_object_menu(Vergent *vergent, | ||
120 | 85 | static ObjectTypeOps vergent_type_ops = |
121 | 86 | { |
122 | 87 | (CreateFunc)vergent_create, /* create */ |
123 | - (LoadFunc) vergent_load, /* load */ | |
124 | - (SaveFunc) vergent_save, /* save */ | |
88 | + (LoadFunc) vergent_load,/*using properties*/ /* load */ | |
89 | + (SaveFunc) object_save_using_properties, /* save */ | |
125 | 90 | (GetDefaultsFunc) NULL, |
126 | 91 | (ApplyDefaultsFunc) NULL |
127 | 92 | }; |
@@ -141,70 +106,68 @@ static ObjectOps vergent_ops = { | ||
141 | 106 | (DrawFunc) vergent_draw, |
142 | 107 | (DistanceFunc) vergent_distance_from, |
143 | 108 | (SelectFunc) vergent_select, |
144 | - (CopyFunc) vergent_copy, | |
109 | + (CopyFunc) object_copy_using_properties, | |
145 | 110 | (MoveFunc) vergent_move, |
146 | 111 | (MoveHandleFunc) vergent_move_handle, |
147 | - (GetPropertiesFunc) vergent_get_properties, | |
148 | - (ApplyPropertiesFunc) vergent_apply_properties, | |
149 | - (ObjectMenuFunc) vergent_get_object_menu | |
150 | -}; | |
112 | + (GetPropertiesFunc) object_create_props_dialog, | |
113 | + (ApplyPropertiesFunc) object_apply_props_from_dialog, | |
114 | + (ObjectMenuFunc) vergent_get_object_menu, | |
115 | + (DescribePropsFunc) vergent_describe_props, | |
116 | + (GetPropsFunc) vergent_get_props, | |
117 | + (SetPropsFunc) vergent_set_props | |
151 | 118 | |
152 | -static ObjectChange * | |
153 | -vergent_apply_properties(Vergent *vergent) | |
154 | -{ | |
155 | - ObjectState *old_state; | |
156 | - VergentPropertiesDialog *dlg = vergent_properties_dialog; | |
157 | - | |
158 | - PROPDLG_SANITY_CHECK(dlg,vergent); | |
159 | - | |
160 | - old_state = (ObjectState *)vergent_get_state(vergent); | |
119 | +}; | |
161 | 120 | |
162 | - PROPDLG_APPLY_ENUM(dlg,type); | |
163 | - | |
164 | - vergent_update_data(vergent); | |
165 | - return new_object_state_change(&vergent->connection.object, old_state, | |
166 | - (GetStateFunc)vergent_get_state, | |
167 | - (SetStateFunc)vergent_set_state); | |
168 | -} | |
121 | +static PropEnumData prop_vtype_data[] = { | |
122 | + { N_("OR"), VERGENT_OR }, | |
123 | + { N_("AND"), VERGENT_AND }, | |
124 | + { NULL, 0 } | |
125 | +}; | |
169 | 126 | |
170 | -PropDlgEnumEntry vergent_type_enum[] = { | |
171 | - { N_("OR"),VERGENT_OR,NULL }, | |
172 | - { N_("AND"),VERGENT_AND,NULL }, | |
173 | - { NULL } }; | |
127 | +static PropDescription vergent_props[] = { | |
128 | + CONNECTION_COMMON_PROPERTIES, | |
129 | + { "cpl_north",PROP_TYPE_CONNPOINT_LINE, 0, | |
130 | + "cpl_north","cpl_north"}, | |
131 | + { "cpl_south",PROP_TYPE_CONNPOINT_LINE, 0, | |
132 | + "cpl_south","cpl_south"}, | |
133 | + { "vtype", PROP_TYPE_ENUM, PROP_FLAG_VISIBLE, | |
134 | + N_("Vergent type:"),NULL, prop_vtype_data}, | |
135 | + PROP_DESC_END | |
136 | +}; | |
174 | 137 | |
175 | -static PROPDLG_TYPE | |
176 | -vergent_get_properties(Vergent *vergent) | |
138 | +static PropDescription * | |
139 | +vergent_describe_props(Vergent *vergent) | |
177 | 140 | { |
178 | - VergentPropertiesDialog *dlg = vergent_properties_dialog; | |
179 | - | |
180 | - PROPDLG_CREATE(dlg,vergent); | |
181 | - PROPDLG_SHOW_ENUM(dlg,type,_("Vergent type:"),vergent_type_enum); | |
182 | - PROPDLG_READY(dlg); | |
183 | - | |
184 | - vergent_properties_dialog = dlg; | |
185 | - | |
186 | - PROPDLG_RETURN(dlg); | |
141 | + if (vergent_props[0].quark == 0) { | |
142 | + prop_desc_list_calculate_quarks(vergent_props); | |
143 | + } | |
144 | + return vergent_props; | |
187 | 145 | } |
188 | 146 | |
189 | -static void | |
190 | -vergent_apply_defaults() | |
191 | -{ | |
192 | - VergentDefaultsDialog *dlg = vergent_defaults_dialog; | |
147 | +static PropOffset vergent_offsets[] = { | |
148 | + CONNECTION_COMMON_PROPERTIES_OFFSETS, | |
149 | + {"cpl_north",PROP_TYPE_CONNPOINT_LINE,offsetof(Vergent,north)}, | |
150 | + {"cpl_south",PROP_TYPE_CONNPOINT_LINE,offsetof(Vergent,south)}, | |
151 | + {"vtype",PROP_TYPE_ENUM,offsetof(Vergent,type)}, | |
152 | + { NULL,0,0 } | |
153 | +}; | |
193 | 154 | |
194 | - PROPDLG_APPLY_ENUM(dlg,type); | |
155 | +static void | |
156 | +vergent_get_props(Vergent *vergent, Property *props, guint nprops) | |
157 | +{ | |
158 | + object_get_props_from_offsets(&vergent->connection.object, | |
159 | + vergent_offsets,props,nprops); | |
195 | 160 | } |
196 | 161 | |
197 | 162 | static void |
198 | -init_default_values() { | |
199 | - static int defaults_initialized = 0; | |
200 | - | |
201 | - if (!defaults_initialized) { | |
202 | - defaults.type = VERGENT_OR; | |
203 | - | |
204 | - defaults_initialized = 1; | |
205 | - } | |
163 | +vergent_set_props(Vergent *vergent, Property *props, guint nprops) | |
164 | +{ | |
165 | + object_set_props_from_offsets(&vergent->connection.object, | |
166 | + vergent_offsets,props,nprops); | |
167 | + vergent_update_data(vergent); | |
206 | 168 | } |
207 | 169 | |
170 | + | |
208 | 171 | static real |
209 | 172 | vergent_distance_from(Vergent *vergent, Point *point) |
210 | 173 | { |
@@ -227,26 +190,6 @@ vergent_distance_from(Vergent *vergent, Point *point) | ||
227 | 190 | return distance_rectangle_point(&rectangle,point); |
228 | 191 | } |
229 | 192 | |
230 | -static VergentState * | |
231 | -vergent_get_state(Vergent *vergent) | |
232 | -{ | |
233 | - VergentState *state = g_new0(VergentState, 1); | |
234 | - | |
235 | - state->obj_state.free = NULL; | |
236 | - state->type = vergent->type; | |
237 | - | |
238 | - return state; | |
239 | -} | |
240 | - | |
241 | -static void | |
242 | -vergent_set_state(Vergent *vergent, VergentState *state) | |
243 | -{ | |
244 | - vergent->type = state->type; | |
245 | - | |
246 | - g_free(state); | |
247 | - vergent_update_data(vergent); | |
248 | -} | |
249 | - | |
250 | 193 | static void |
251 | 194 | vergent_select(Vergent *vergent, Point *clicked_point, |
252 | 195 | Renderer *interactive_renderer) |
@@ -382,6 +325,8 @@ vergent_update_data(Vergent *vergent) | ||
382 | 325 | connection_update_handles(conn); |
383 | 326 | } |
384 | 327 | |
328 | +/* Object menu handling */ | |
329 | + | |
385 | 330 | typedef struct { |
386 | 331 | ObjectChange obj_change; |
387 | 332 |
@@ -441,7 +386,6 @@ vergent_delete_cp_callback(Object *obj, Point *clicked, gpointer data) | ||
441 | 386 | return vergent_create_change((Vergent *)obj,0,clicked); |
442 | 387 | } |
443 | 388 | |
444 | - | |
445 | 389 | static DiaMenuItem object_menu_items[] = { |
446 | 390 | { N_("Add connection point"), vergent_add_cp_callback, NULL, 1 }, |
447 | 391 | { N_("Delete connection point"), vergent_delete_cp_callback, NULL, 1 }, |
@@ -466,9 +410,6 @@ vergent_get_object_menu(Vergent *vergent, Point *clickedpoint) | ||
466 | 410 | return &object_menu; |
467 | 411 | } |
468 | 412 | |
469 | - | |
470 | - | |
471 | - | |
472 | 413 | static Object * |
473 | 414 | vergent_create(Point *startpoint, |
474 | 415 | void *user_data, |
@@ -481,7 +422,6 @@ vergent_create(Point *startpoint, | ||
481 | 422 | int i; |
482 | 423 | Point defaultlen = {6.0,0.0}; |
483 | 424 | |
484 | - init_default_values(); | |
485 | 425 | vergent = g_malloc0(sizeof(Vergent)); |
486 | 426 | conn = &vergent->connection; |
487 | 427 | obj = &conn->object; |
@@ -506,7 +446,6 @@ vergent_create(Point *startpoint, | ||
506 | 446 | |
507 | 447 | vergent->north = connpointline_create(obj,1); |
508 | 448 | vergent->south = connpointline_create(obj,1); |
509 | - | |
510 | 449 | |
511 | 450 | switch(GPOINTER_TO_INT(user_data)) { |
512 | 451 | case VERGENT_OR: |
@@ -535,97 +474,10 @@ vergent_destroy(Vergent *vergent) | ||
535 | 474 | } |
536 | 475 | |
537 | 476 | static Object * |
538 | -vergent_copy(Vergent *vergent) | |
539 | -{ | |
540 | - Vergent *newvergent; | |
541 | - Connection *conn, *newconn; | |
542 | - Object *newobj; | |
543 | - int realconncount,i; | |
544 | - | |
545 | - conn = &vergent->connection; | |
546 | - | |
547 | - newvergent = g_malloc0(sizeof(Vergent)); | |
548 | - newconn = &newvergent->connection; | |
549 | - newobj = &newconn->object; | |
550 | - | |
551 | - connection_copy(conn, newconn); | |
552 | - | |
553 | - realconncount = 4; | |
554 | - newobj->connections[0] = &newvergent->northeast; | |
555 | - newobj->connections[1] = &newvergent->northwest; | |
556 | - newobj->connections[2] = &newvergent->southwest; | |
557 | - newobj->connections[3] = &newvergent->southeast; | |
558 | - for (i=0; i<4; i++) { | |
559 | - newobj->connections[i]->object = newobj; | |
560 | - newobj->connections[i]->connected = NULL; | |
561 | - } | |
562 | - | |
563 | - newvergent->north = connpointline_copy(newobj,vergent->north,&realconncount); | |
564 | - newvergent->south = connpointline_copy(newobj,vergent->south,&realconncount); | |
565 | - g_assert(realconncount == newobj->num_connections); | |
566 | - newvergent->type = vergent->type; | |
567 | - | |
568 | - vergent_update_data(newvergent); | |
569 | - | |
570 | - return &newvergent->connection.object; | |
571 | -} | |
572 | - | |
573 | - | |
574 | -static void | |
575 | -vergent_save(Vergent *vergent, ObjectNode obj_node, | |
576 | - const char *filename) | |
577 | -{ | |
578 | - connection_save(&vergent->connection, obj_node); | |
579 | - | |
580 | - save_enum(obj_node,"vtype",vergent->type); | |
581 | - connpointline_save(vergent->north,obj_node,"cpl_north"); | |
582 | - connpointline_save(vergent->south,obj_node,"cpl_south"); | |
583 | -} | |
584 | - | |
585 | -static Object * | |
586 | 477 | vergent_load(ObjectNode obj_node, int version, const char *filename) |
587 | 478 | { |
588 | - Vergent *vergent; | |
589 | - Connection *conn; | |
590 | - Object *obj; | |
591 | - int i,realconncount; | |
592 | - | |
593 | - init_default_values(); | |
594 | - vergent = g_malloc0(sizeof(Vergent)); | |
595 | - | |
596 | - conn = &vergent->connection; | |
597 | - obj = &conn->object; | |
598 | - | |
599 | - obj->type = &vergent_type; | |
600 | - obj->ops = &vergent_ops; | |
601 | - | |
602 | - connection_load(conn, obj_node); | |
603 | - connection_init(conn, 2, 4); | |
604 | - | |
605 | - obj->connections[0] = &vergent->northeast; | |
606 | - obj->connections[1] = &vergent->northwest; | |
607 | - obj->connections[2] = &vergent->southwest; | |
608 | - obj->connections[3] = &vergent->southeast; | |
609 | - for (i=0; i<4; i++) { | |
610 | - obj->connections[i]->object = obj; | |
611 | - obj->connections[i]->connected = NULL; | |
612 | - } | |
613 | - | |
614 | - realconncount = 4; | |
615 | - g_assert(realconncount == obj->num_connections); | |
616 | - | |
617 | - vergent->north = connpointline_load(obj,obj_node, | |
618 | - "cpl_north",2,&realconncount); | |
619 | - vergent->south = connpointline_load(obj,obj_node, | |
620 | - "cpl_south",2,&realconncount); | |
621 | - | |
622 | - g_assert(realconncount == obj->num_connections); | |
623 | - | |
624 | - vergent->type = load_enum(obj_node,"vtype",VERGENT_OR); | |
625 | - | |
626 | - vergent_update_data(vergent); | |
627 | - | |
628 | - return &vergent->connection.object; | |
479 | + return object_load_using_properties(&vergent_type, | |
480 | + obj_node,version,filename); | |
629 | 481 | } |
630 | 482 | |
631 | 483 |
@@ -32,26 +32,18 @@ | ||
32 | 32 | #include "render.h" |
33 | 33 | #include "handle.h" |
34 | 34 | #include "properties.h" |
35 | +#include "connpoint_line.h" | |
35 | 36 | |
36 | 37 | #include "pixmaps/lifeline.xpm" |
37 | 38 | |
38 | 39 | typedef struct _Lifeline Lifeline; |
39 | -typedef struct _LifelineState LifelineState; | |
40 | 40 | |
41 | -struct _LifelineState { | |
42 | - ObjectState obj_state; | |
43 | - | |
44 | - int draw_focuscontrol; | |
45 | - int draw_cross; | |
46 | -}; | |
47 | - | |
48 | -#define CONNECTIONS 6 /* must be even */ | |
49 | 41 | |
50 | 42 | struct _Lifeline { |
51 | 43 | Connection connection; |
52 | 44 | |
53 | - ConnectionPoint connections[CONNECTIONS]; | |
54 | - | |
45 | + ConnectionPoint connections[6]; /* the static ones. 6 is meant to | |
46 | + be hardcoded. */ | |
55 | 47 | Handle boxbot_handle; |
56 | 48 | Handle boxtop_handle; |
57 | 49 |
@@ -59,6 +51,15 @@ struct _Lifeline { | ||
59 | 51 | |
60 | 52 | int draw_focuscontrol; |
61 | 53 | int draw_cross; |
54 | + | |
55 | + ConnPointLine *northwest,*southwest,*northeast,*southeast; | |
56 | + | |
57 | + /* we're (almost) obliged to do this stupid gymnastic with twin | |
58 | + connpoint_lines, because we really do want to reload older objects | |
59 | + (those created before we had the CPLs) without funny side effects. And | |
60 | + we don't want to have two connection points (one static, one dynamic) in | |
61 | + the same place either. | |
62 | + */ | |
62 | 63 | }; |
63 | 64 | |
64 | 65 | #define LIFELINE_LINEWIDTH 0.05 |
@@ -74,10 +75,11 @@ struct _Lifeline { | ||
74 | 75 | #define HANDLE_BOXBOT (HANDLE_CUSTOM2) |
75 | 76 | |
76 | 77 | static void lifeline_move_handle(Lifeline *lifeline, Handle *handle, |
77 | - Point *to, HandleMoveReason reason, ModifierKeys modifiers); | |
78 | + Point *to, HandleMoveReason reason, | |
79 | + ModifierKeys modifiers); | |
78 | 80 | static void lifeline_move(Lifeline *lifeline, Point *to); |
79 | 81 | static void lifeline_select(Lifeline *lifeline, Point *clicked_point, |
80 | - Renderer *interactive_renderer); | |
82 | + Renderer *interactive_renderer); | |
81 | 83 | static void lifeline_draw(Lifeline *lifeline, Renderer *renderer); |
82 | 84 | static Object *lifeline_create(Point *startpoint, |
83 | 85 | void *user_data, |
@@ -86,28 +88,24 @@ static Object *lifeline_create(Point *startpoint, | ||
86 | 88 | static real lifeline_distance_from(Lifeline *lifeline, Point *point); |
87 | 89 | static void lifeline_update_data(Lifeline *lifeline); |
88 | 90 | static void lifeline_destroy(Lifeline *lifeline); |
89 | -static Object *lifeline_copy(Lifeline *lifeline); | |
90 | -static void lifeline_save(Lifeline *lifeline, ObjectNode obj_node, | |
91 | - const char *filename); | |
92 | 91 | static Object *lifeline_load(ObjectNode obj_node, int version, |
93 | 92 | const char *filename); |
94 | -static ObjectChange *lifeline_apply_properties(Lifeline *lif, GtkWidget *widget); | |
95 | 93 | static PropDescription *lifeline_describe_props(Lifeline *lifeline); |
96 | 94 | |
97 | -static LifelineState *lifeline_get_state(Lifeline *lif); | |
98 | -static void lifeline_set_state(Lifeline *lif, | |
99 | - LifelineState *state); | |
100 | 95 | static void lifeline_get_props(Lifeline * lifeline, Property *props, |
101 | 96 | guint nprops); |
102 | 97 | static void lifeline_set_props(Lifeline * lifeline, Property *props, |
103 | 98 | guint nprops); |
99 | +static DiaMenu *lifeline_get_object_menu(Lifeline *lifeline, | |
100 | + Point *clickedpoint); | |
101 | + | |
104 | 102 | |
105 | 103 | |
106 | 104 | static ObjectTypeOps lifeline_type_ops = |
107 | 105 | { |
108 | 106 | (CreateFunc) lifeline_create, |
109 | - (LoadFunc) lifeline_load, | |
110 | - (SaveFunc) lifeline_save | |
107 | + (LoadFunc) lifeline_load,/* using properties */ | |
108 | + (SaveFunc) object_save_using_properties | |
111 | 109 | }; |
112 | 110 | |
113 | 111 | ObjectType lifeline_type = |
@@ -123,24 +121,29 @@ static ObjectOps lifeline_ops = { | ||
123 | 121 | (DrawFunc) lifeline_draw, |
124 | 122 | (DistanceFunc) lifeline_distance_from, |
125 | 123 | (SelectFunc) lifeline_select, |
126 | - (CopyFunc) lifeline_copy, | |
124 | + (CopyFunc) object_copy_using_properties, | |
127 | 125 | (MoveFunc) lifeline_move, |
128 | 126 | (MoveHandleFunc) lifeline_move_handle, |
129 | 127 | (GetPropertiesFunc) object_create_props_dialog, |
130 | - (ApplyPropertiesFunc) lifeline_apply_properties, | |
131 | - (ObjectMenuFunc) NULL, | |
128 | + (ApplyPropertiesFunc) object_apply_props_from_dialog, | |
129 | + (ObjectMenuFunc) lifeline_get_object_menu, | |
132 | 130 | (DescribePropsFunc) lifeline_describe_props, |
133 | 131 | (GetPropsFunc) lifeline_get_props, |
134 | 132 | (SetPropsFunc) lifeline_set_props |
135 | 133 | }; |
136 | 134 | |
137 | 135 | static PropDescription lifeline_props[] = { |
138 | - OBJECT_COMMON_PROPERTIES, | |
139 | - { "focus_control", PROP_TYPE_BOOL, PROP_FLAG_VISIBLE, | |
136 | + CONNECTION_COMMON_PROPERTIES, | |
137 | + { "rtop", PROP_TYPE_REAL, 0, NULL,NULL,NULL}, | |
138 | + { "rbot", PROP_TYPE_REAL, 0, NULL,NULL,NULL}, | |
139 | + { "draw_focus", PROP_TYPE_BOOL, PROP_FLAG_VISIBLE, | |
140 | 140 | N_("Draw focus of control:"), NULL, NULL }, |
141 | - { "cross", PROP_TYPE_BOOL, PROP_FLAG_VISIBLE, | |
141 | + { "draw_cross", PROP_TYPE_BOOL, PROP_FLAG_VISIBLE, | |
142 | 142 | N_("Draw destruction mark:"), NULL, NULL }, |
143 | - | |
143 | + { "cpl_northwest",PROP_TYPE_CONNPOINT_LINE, 0, NULL, NULL }, | |
144 | + { "cpl_southwest",PROP_TYPE_CONNPOINT_LINE, 0, NULL, NULL }, | |
145 | + { "cpl_northeast",PROP_TYPE_CONNPOINT_LINE, 0, NULL, NULL }, | |
146 | + { "cpl_southeast",PROP_TYPE_CONNPOINT_LINE, 0, NULL, NULL }, | |
144 | 147 | PROP_DESC_END |
145 | 148 | }; |
146 | 149 |
@@ -153,9 +156,15 @@ lifeline_describe_props(Lifeline *lifeline) | ||
153 | 156 | } |
154 | 157 | |
155 | 158 | static PropOffset lifeline_offsets[] = { |
156 | - OBJECT_COMMON_PROPERTIES_OFFSETS, | |
157 | - { "focus_control", PROP_TYPE_BOOL, offsetof(Lifeline, draw_focuscontrol) }, | |
158 | - { "cross", PROP_TYPE_BOOL, offsetof(Lifeline, draw_cross) }, | |
159 | + CONNECTION_COMMON_PROPERTIES_OFFSETS, | |
160 | + { "draw_focus", PROP_TYPE_BOOL, offsetof(Lifeline, draw_focuscontrol) }, | |
161 | + { "draw_cross", PROP_TYPE_BOOL, offsetof(Lifeline, draw_cross) }, | |
162 | + { "rtop", PROP_TYPE_REAL, offsetof(Lifeline, rtop) }, | |
163 | + { "rbot", PROP_TYPE_REAL, offsetof(Lifeline, rbot) }, | |
164 | + { "cpl_northwest",PROP_TYPE_CONNPOINT_LINE,offsetof(Lifeline,northwest)}, | |
165 | + { "cpl_southwest",PROP_TYPE_CONNPOINT_LINE,offsetof(Lifeline,southwest)}, | |
166 | + { "cpl_northeast",PROP_TYPE_CONNPOINT_LINE,offsetof(Lifeline,northeast)}, | |
167 | + { "cpl_southeast",PROP_TYPE_CONNPOINT_LINE,offsetof(Lifeline,southeast)}, | |
159 | 168 | { NULL, 0, 0 }, |
160 | 169 | }; |
161 | 170 |
@@ -319,6 +328,108 @@ lifeline_draw(Lifeline *lifeline, Renderer *renderer) | ||
319 | 328 | } |
320 | 329 | } |
321 | 330 | |
331 | +/* Object menu handling */ | |
332 | + | |
333 | +typedef struct { | |
334 | + ObjectChange obj_change; | |
335 | + | |
336 | + ObjectChange *northeast,*southeast,*northwest,*southwest; | |
337 | +} LifelineChange; | |
338 | + | |
339 | +static void lifeline_change_apply(LifelineChange *change, Object *obj) | |
340 | +{ | |
341 | + change->northwest->apply(change->northwest,obj); | |
342 | + change->southwest->apply(change->southwest,obj); | |
343 | + change->northeast->apply(change->northeast,obj); | |
344 | + change->southeast->apply(change->southeast,obj); | |
345 | +} | |
346 | + | |
347 | +static void lifeline_change_revert(LifelineChange *change, Object *obj) | |
348 | +{ | |
349 | + change->northwest->revert(change->northwest,obj); | |
350 | + change->southwest->revert(change->southwest,obj); | |
351 | + change->northeast->revert(change->northeast,obj); | |
352 | + change->southeast->revert(change->southeast,obj); | |
353 | +} | |
354 | + | |
355 | +static void lifeline_change_free(LifelineChange *change) | |
356 | +{ | |
357 | + if (change->northeast->free) change->northeast->free(change->northeast); | |
358 | + g_free(change->northeast); | |
359 | + if (change->northwest->free) change->northwest->free(change->northwest); | |
360 | + g_free(change->northwest); | |
361 | + if (change->southeast->free) change->southeast->free(change->southeast); | |
362 | + g_free(change->southeast); | |
363 | + if (change->southwest->free) change->southwest->free(change->southwest); | |
364 | + g_free(change->southwest); | |
365 | +} | |
366 | + | |
367 | +static ObjectChange * | |
368 | +lifeline_create_change(Lifeline *lifeline, int add, Point *clicked) | |
369 | +{ | |
370 | + LifelineChange *vc; | |
371 | + | |
372 | + vc = g_new0(LifelineChange,1); | |
373 | + vc->obj_change.apply = (ObjectChangeApplyFunc)lifeline_change_apply; | |
374 | + vc->obj_change.revert = (ObjectChangeRevertFunc)lifeline_change_revert; | |
375 | + vc->obj_change.free = (ObjectChangeFreeFunc)lifeline_change_free; | |
376 | + | |
377 | + if (add) { | |
378 | + vc->northeast = connpointline_add_point(lifeline->northeast,clicked); | |
379 | + vc->northwest = connpointline_add_point(lifeline->northwest,clicked); | |
380 | + vc->southeast = connpointline_add_point(lifeline->southeast,clicked); | |
381 | + vc->southwest = connpointline_add_point(lifeline->southwest,clicked); | |
382 | + } else { | |
383 | + vc->northeast = connpointline_remove_point(lifeline->northeast,clicked); | |
384 | + vc->southwest = connpointline_remove_point(lifeline->southwest,clicked); | |
385 | + vc->southeast = connpointline_remove_point(lifeline->southeast,clicked); | |
386 | + vc->northwest = connpointline_remove_point(lifeline->northwest,clicked); | |
387 | + } | |
388 | + lifeline_update_data(lifeline); | |
389 | + return (ObjectChange *)vc; | |
390 | +} | |
391 | + | |
392 | +static ObjectChange * | |
393 | +lifeline_add_cp_callback(Object *obj, Point *clicked, gpointer data) | |
394 | +{ | |
395 | + return lifeline_create_change((Lifeline *)obj,1,clicked); | |
396 | +} | |
397 | + | |
398 | +static ObjectChange * | |
399 | +lifeline_delete_cp_callback(Object *obj, Point *clicked, gpointer data) | |
400 | +{ | |
401 | + return lifeline_create_change((Lifeline *)obj,0,clicked); | |
402 | +} | |
403 | + | |
404 | +static DiaMenuItem object_menu_items[] = { | |
405 | + { N_("Add connection points"), lifeline_add_cp_callback, NULL, 1 }, | |
406 | + { N_("Remove connection points"), lifeline_delete_cp_callback, NULL, 1 }, | |
407 | +}; | |
408 | + | |
409 | +static DiaMenu object_menu = { | |
410 | + N_("UML Lifeline"), | |
411 | + sizeof(object_menu_items)/sizeof(DiaMenuItem), | |
412 | + object_menu_items, | |
413 | + NULL | |
414 | +}; | |
415 | + | |
416 | +static DiaMenu * | |
417 | +lifeline_get_object_menu(Lifeline *lifeline, Point *clickedpoint) | |
418 | +{ | |
419 | + /* Set entries sensitive/selected etc here */ | |
420 | + g_assert( (lifeline->northwest->num_connections == | |
421 | + lifeline->northeast->num_connections) || | |
422 | + (lifeline->northwest->num_connections == | |
423 | + lifeline->southwest->num_connections) || | |
424 | + (lifeline->southwest->num_connections == | |
425 | + lifeline->southeast->num_connections) ); | |
426 | + | |
427 | + object_menu_items[0].active = 1; | |
428 | + object_menu_items[1].active = (lifeline->northeast->num_connections > 1); | |
429 | + | |
430 | + return &object_menu; | |
431 | +} | |
432 | + | |
322 | 433 | static Object * |
323 | 434 | lifeline_create(Point *startpoint, |
324 | 435 | void *user_data, |
@@ -343,7 +454,7 @@ lifeline_create(Point *startpoint, | ||
343 | 454 | obj->type = &lifeline_type; |
344 | 455 | obj->ops = &lifeline_ops; |
345 | 456 | |
346 | - connection_init(conn, 4, CONNECTIONS); | |
457 | + connection_init(conn, 4, 6); | |
347 | 458 | |
348 | 459 | lifeline->rtop = LIFELINE_HEIGHT/3; |
349 | 460 | lifeline->rbot = lifeline->rtop+0.7; |
@@ -366,12 +477,17 @@ lifeline_create(Point *startpoint, | ||
366 | 477 | obj->handles[1]->connect_type = HANDLE_NONCONNECTABLE; |
367 | 478 | |
368 | 479 | /* Connection points */ |
369 | - for (i=0;i<CONNECTIONS;i++) { | |
480 | + for (i=0;i<6;i++) { | |
370 | 481 | obj->connections[i] = &lifeline->connections[i]; |
371 | 482 | lifeline->connections[i].object = obj; |
372 | 483 | lifeline->connections[i].connected = NULL; |
373 | 484 | } |
374 | 485 | |
486 | + lifeline->northwest = connpointline_create(obj,1); | |
487 | + lifeline->southwest = connpointline_create(obj,1); | |
488 | + lifeline->northeast = connpointline_create(obj,1); | |
489 | + lifeline->southeast = connpointline_create(obj,1); | |
490 | + | |
375 | 491 | lifeline_update_data(lifeline); |
376 | 492 | |
377 | 493 | *handle1 = obj->handles[0]; |
@@ -380,84 +496,23 @@ lifeline_create(Point *startpoint, | ||
380 | 496 | return &lifeline->connection.object; |
381 | 497 | } |
382 | 498 | |
383 | - | |
384 | 499 | static void |
385 | 500 | lifeline_destroy(Lifeline *lifeline) |
386 | 501 | { |
502 | + connpointline_destroy(lifeline->southeast); | |
503 | + connpointline_destroy(lifeline->northwest); | |
504 | + connpointline_destroy(lifeline->northeast); | |
505 | + connpointline_destroy(lifeline->southwest); | |
387 | 506 | connection_destroy(&lifeline->connection); |
388 | 507 | } |
389 | 508 | |
390 | -static Object * | |
391 | -lifeline_copy(Lifeline *lifeline) | |
392 | -{ | |
393 | - int i; | |
394 | - Lifeline *newlifeline; | |
395 | - Connection *conn, *newconn; | |
396 | - Object *newobj; | |
397 | - | |
398 | - conn = &lifeline->connection; | |
399 | - | |
400 | - newlifeline = g_malloc0(sizeof(Lifeline)); | |
401 | - newconn = &newlifeline->connection; | |
402 | - newobj = &newconn->object; | |
403 | - | |
404 | - connection_copy(conn, newconn); | |
405 | - | |
406 | - for (i = 0; i < CONNECTIONS; i++) { | |
407 | - newobj->connections[i] = &newlifeline->connections[i]; | |
408 | - newlifeline->connections[i].object = newobj; | |
409 | - newlifeline->connections[i].connected = NULL; | |
410 | - newlifeline->connections[i].pos = lifeline->connections[i].pos; | |
411 | - newlifeline->connections[i].last_pos = lifeline->connections[i].last_pos; | |
412 | - } | |
413 | - | |
414 | - newlifeline->boxbot_handle = lifeline->boxbot_handle; | |
415 | - newobj->handles[2] = &newlifeline->boxbot_handle; | |
416 | - newlifeline->boxtop_handle = lifeline->boxtop_handle; | |
417 | - newobj->handles[3] = &newlifeline->boxtop_handle; | |
418 | - | |
419 | - newlifeline->rtop = lifeline->rtop; | |
420 | - newlifeline->rbot = lifeline->rbot; | |
421 | - | |
422 | - newlifeline->draw_focuscontrol = lifeline->draw_focuscontrol; | |
423 | - newlifeline->draw_cross = lifeline->draw_cross; | |
424 | - | |
425 | - return &newlifeline->connection.object; | |
426 | -} | |
427 | - | |
428 | -static LifelineState * | |
429 | -lifeline_get_state(Lifeline *lif) | |
430 | -{ | |
431 | - LifelineState *state = g_new0(LifelineState, 1); | |
432 | - | |
433 | - state->obj_state.free = NULL; | |
434 | - | |
435 | - state->draw_focuscontrol = lif->draw_focuscontrol; | |
436 | - state->draw_cross = lif->draw_cross; | |
437 | - | |
438 | - return state; | |
439 | -} | |
440 | - | |
441 | -static void | |
442 | -lifeline_set_state(Lifeline *lif, LifelineState *state) | |
443 | -{ | |
444 | - lif->draw_focuscontrol = state->draw_focuscontrol; | |
445 | - lif->draw_cross = state->draw_cross; | |
446 | - | |
447 | - g_free(state); | |
448 | - | |
449 | - lifeline_update_data(lif); | |
450 | -} | |
451 | - | |
452 | 509 | static void |
453 | 510 | lifeline_update_data(Lifeline *lifeline) |
454 | 511 | { |
455 | 512 | Connection *conn = &lifeline->connection; |
456 | 513 | Object *obj = &conn->object; |
457 | 514 | LineBBExtras *extra = &conn->extra_spacing; |
458 | - Point p1, p2; | |
459 | - real r; | |
460 | - int i; | |
515 | + Point p1, p2, pnw, psw, pne, pse, pmw,pme; | |
461 | 516 | |
462 | 517 | obj->position = conn->endpoints[0]; |
463 | 518 |
@@ -489,122 +544,46 @@ lifeline_update_data(Lifeline *lifeline) | ||
489 | 544 | if (lifeline->draw_focuscontrol) { |
490 | 545 | p1.x -= LIFELINE_WIDTH/2.0; |
491 | 546 | p2.x += LIFELINE_WIDTH/2.0; |
492 | - /* Update connections: */ | |
493 | - r = (p2.y - p1.y)/(float)(CONNECTIONS/2-1); | |
494 | - for (i = 0; i < CONNECTIONS/2; ++i) { | |
495 | - lifeline->connections[i*2].pos.x = p1.x; | |
496 | - lifeline->connections[i*2+1].pos.x = p2.x; | |
497 | - lifeline->connections[i*2+1].pos.y = | |
498 | - lifeline->connections[i*2].pos.y = p1.y + i*r; | |
499 | - } | |
500 | - } else { | |
501 | - /* without focus of control, the points are over the line */ | |
502 | - r = (p2.y - p1.y)/(float)(CONNECTIONS-1); | |
503 | - for (i = 0; i < CONNECTIONS; i++) { | |
504 | - lifeline->connections[i].pos.x = p1.x; | |
505 | - lifeline->connections[i].pos.y = p1.y + i*r; | |
506 | - } | |
507 | 547 | } |
508 | -} | |
509 | - | |
510 | - | |
511 | -static void | |
512 | -lifeline_save(Lifeline *lifeline, ObjectNode obj_node, | |
513 | - const char *filename) | |
514 | -{ | |
515 | - connection_save(&lifeline->connection, obj_node); | |
516 | - | |
517 | - data_add_real(new_attribute(obj_node, "rtop"), | |
518 | - lifeline->rtop); | |
519 | - data_add_real(new_attribute(obj_node, "rbot"), | |
520 | - lifeline->rbot); | |
521 | - data_add_boolean(new_attribute(obj_node, "draw_focus"), | |
522 | - lifeline->draw_focuscontrol); | |
523 | - data_add_boolean(new_attribute(obj_node, "draw_cross"), | |
524 | - lifeline->draw_cross); | |
548 | + /* Update connections: */ | |
549 | + | |
550 | + pnw.x = p1.x; pnw.y = p1.y; | |
551 | + psw.x = p1.x; psw.y = p2.y; | |
552 | + pne.x = p2.x; pne.y = p1.y; | |
553 | + pse.x = p2.x; pse.y = p2.y; | |
554 | + pmw.x = pnw.x; | |
555 | + pme.x = pne.x; | |
556 | + pmw.y = pme.y = (p1.y + p2.y)/2; | |
557 | + | |
558 | + lifeline->connections[0].pos = pnw; | |
559 | + lifeline->connections[1].pos = pne; | |
560 | + lifeline->connections[2].pos = pmw; | |
561 | + lifeline->connections[3].pos = pme; | |
562 | + lifeline->connections[4].pos = psw; | |
563 | + lifeline->connections[5].pos = pse; | |
564 | + | |
565 | + connpointline_update(lifeline->northwest); | |
566 | + connpointline_putonaline(lifeline->northwest,&pnw,&pmw); | |
567 | + connpointline_update(lifeline->southwest); | |
568 | + connpointline_putonaline(lifeline->southwest,&pmw,&psw); | |
569 | + connpointline_update(lifeline->northeast); | |
570 | + connpointline_putonaline(lifeline->northeast,&pne,&pme); | |
571 | + connpointline_update(lifeline->southeast); | |
572 | + connpointline_putonaline(lifeline->southeast,&pme,&pse); | |
525 | 573 | } |
526 | 574 | |
527 | 575 | static Object * |
528 | 576 | lifeline_load(ObjectNode obj_node, int version, const char *filename) |
529 | 577 | { |
530 | - Lifeline *lifeline; | |
531 | - AttributeNode attr; | |
532 | - Connection *conn; | |
533 | - Object *obj; | |
534 | - int i; | |
578 | + return object_load_using_properties(&lifeline_type, | |
579 | + obj_node,version,filename); | |
580 | +} | |
535 | 581 | |
536 | - lifeline = g_malloc0(sizeof(Lifeline)); | |
537 | 582 | |
538 | - conn = &lifeline->connection; | |
539 | - obj = &conn->object; | |
540 | 583 | |
541 | - obj->type = &lifeline_type; | |
542 | - obj->ops = &lifeline_ops; | |
543 | 584 | |
544 | - connection_load(conn, obj_node); | |
545 | - | |
546 | - connection_init(conn, 4, CONNECTIONS); | |
547 | - | |
548 | - attr = object_find_attribute(obj_node, "rtop"); | |
549 | - if (attr != NULL) | |
550 | - lifeline->rtop = data_real(attribute_first_data(attr)); | |
551 | - else | |
552 | - lifeline->rtop = LIFELINE_HEIGHT/3; | |
553 | - | |
554 | - attr = object_find_attribute(obj_node, "rbot"); | |
555 | - if (attr != NULL) | |
556 | - lifeline->rbot = data_real(attribute_first_data(attr)); | |
557 | - else | |
558 | - lifeline->rbot = lifeline->rtop+0.7; | |
559 | - | |
560 | - attr = object_find_attribute(obj_node, "draw_focus"); | |
561 | - if (attr != NULL) | |
562 | - lifeline->draw_focuscontrol = data_boolean(attribute_first_data(attr)); | |
563 | - else | |
564 | - lifeline->draw_focuscontrol = 1; | |
565 | - | |
566 | - attr = object_find_attribute(obj_node, "draw_cross"); | |
567 | - if (attr != NULL) | |
568 | - lifeline->draw_cross = data_boolean(attribute_first_data(attr)); | |
569 | - else | |
570 | - lifeline->draw_cross = 0; | |
571 | 585 | |
572 | - /* Connection points */ | |
573 | - for (i=0;i<CONNECTIONS;i++) { | |
574 | - obj->connections[i] = &lifeline->connections[i]; | |
575 | - lifeline->connections[i].object = obj; | |
576 | - lifeline->connections[i].connected = NULL; | |
577 | - } | |
578 | 586 | |
579 | - lifeline->boxbot_handle.id = HANDLE_BOXBOT; | |
580 | - lifeline->boxbot_handle.type = HANDLE_MINOR_CONTROL; | |
581 | - lifeline->boxbot_handle.connect_type = HANDLE_NONCONNECTABLE; | |
582 | - lifeline->boxbot_handle.connected_to = NULL; | |
583 | - obj->handles[2] = &lifeline->boxbot_handle; | |
584 | - | |
585 | - lifeline->boxtop_handle.id = HANDLE_BOXTOP; | |
586 | - lifeline->boxtop_handle.type = HANDLE_MINOR_CONTROL; | |
587 | - lifeline->boxtop_handle.connect_type = HANDLE_NONCONNECTABLE; | |
588 | - lifeline->boxtop_handle.connected_to = NULL; | |
589 | - obj->handles[3] = &lifeline->boxtop_handle; | |
590 | - | |
591 | - lifeline_update_data(lifeline); | |
592 | - | |
593 | - return &lifeline->connection.object; | |
594 | -} | |
595 | 587 | |
596 | 588 | |
597 | -static ObjectChange * | |
598 | -lifeline_apply_properties(Lifeline *lif, GtkWidget *widget) | |
599 | -{ | |
600 | - ObjectState *old_state; | |
601 | - | |
602 | - old_state = (ObjectState*) lifeline_get_state(lif); | |
603 | - | |
604 | - object_apply_props_from_dialog((Object *)lif, widget); | |
605 | - | |
606 | - lifeline_update_data(lif); | |
607 | - return new_object_state_change(&lif->connection.object, old_state, | |
608 | - (GetStateFunc)lifeline_get_state, | |
609 | - (SetStateFunc)lifeline_set_state); | |
610 | -} | |
589 | + |
@@ -10,7 +10,7 @@ | ||
10 | 10 | msgid "" |
11 | 11 | msgstr "" |
12 | 12 | "Project-Id-Version: dia 0.86\n" |
13 | -"POT-Creation-Date: 2001-06-08 06:57+0200\n" | |
13 | +"POT-Creation-Date: 2001-06-10 23:09+0200\n" | |
14 | 14 | "PO-Revision-Date: 2001-05-17 13:31+0200\n" |
15 | 15 | "Last-Translator: Christophe Merlet <redfox@eikonex.org>\n" |
16 | 16 | "Language-Team: Gnome French Team <gnomefr@gnomefr.traduc.org>\n" |
@@ -35,15 +35,15 @@ msgstr "Ne pas afficher l' | ||
35 | 35 | msgid "Show this help message" |
36 | 36 | msgstr "Afficher ce message d'aide" |
37 | 37 | |
38 | -#: app/app_procs.c:182 | |
38 | +#: app/app_procs.c:185 | |
39 | 39 | msgid "Can't connect to session manager!\n" |
40 | 40 | msgstr "Ne peut se connecter au gestionnaire de session !\n" |
41 | 41 | |
42 | -#: app/app_procs.c:193 | |
42 | +#: app/app_procs.c:196 | |
43 | 43 | msgid "[OPTION...] [FILE...]" |
44 | 44 | msgstr "[OPTION...] [FICHIER...]" |
45 | 45 | |
46 | -#: app/app_procs.c:196 | |
46 | +#: app/app_procs.c:199 | |
47 | 47 | #, c-format |
48 | 48 | msgid "" |
49 | 49 | "Error on option %s: %s.\n" |
@@ -53,20 +53,20 @@ msgstr "" | ||
53 | 53 | "Tapez ォ %s --help サ pour voir une liste compl鑼e des options en ligne de " |
54 | 54 | "commande.\n" |
55 | 55 | |
56 | -#: app/app_procs.c:245 app/app_procs.c:247 | |
56 | +#: app/app_procs.c:248 app/app_procs.c:250 | |
57 | 57 | msgid "" |
58 | 58 | "Couldn't find standard objects when looking for object-libs, exiting...\n" |
59 | 59 | msgstr "Ne peut trouver les objets standards dans object-libs, termin?..\n" |
60 | 60 | |
61 | -#: app/app_procs.c:272 | |
61 | +#: app/app_procs.c:275 | |
62 | 62 | msgid "Need valid input file\n" |
63 | 63 | msgstr "N馗essite un fichier d'entr馥 valide\n" |
64 | 64 | |
65 | -#: app/app_procs.c:338 app/app_procs.c:344 | |
65 | +#: app/app_procs.c:341 app/app_procs.c:347 | |
66 | 66 | msgid "Quit, are you sure?" |
67 | 67 | msgstr "ハtes-vous s? de vouloir quitter ?" |
68 | 68 | |
69 | -#: app/app_procs.c:351 | |
69 | +#: app/app_procs.c:354 | |
70 | 70 | msgid "" |
71 | 71 | "Modified diagrams exists.\n" |
72 | 72 | "Are you sure you want to quit?" |
@@ -74,21 +74,21 @@ msgstr "" | ||
74 | 74 | "Des diagrammes ont 騁 modifi駸.\n" |
75 | 75 | "Voulez-vous vraiment quitter ?" |
76 | 76 | |
77 | -#: app/app_procs.c:361 app/app_procs.c:366 | |
77 | +#: app/app_procs.c:364 app/app_procs.c:369 | |
78 | 78 | msgid "Quit" |
79 | 79 | msgstr "Quitter" |
80 | 80 | |
81 | -#: app/app_procs.c:378 app/display.c:958 app/layer_dialog.c:989 | |
81 | +#: app/app_procs.c:381 app/display.c:958 app/layer_dialog.c:989 | |
82 | 82 | #: app/lineprops_area.c:741 app/lineprops_area.c:941 app/linewidth_area.c:246 |
83 | 83 | #: app/paginate_psprint.c:264 |
84 | 84 | msgid "Cancel" |
85 | 85 | msgstr "Annuler" |
86 | 86 | |
87 | -#: app/app_procs.c:453 app/app_procs.c:460 | |
87 | +#: app/app_procs.c:456 app/app_procs.c:463 | |
88 | 88 | msgid "Could not create per-user Dia config directory" |
89 | 89 | msgstr "Ne peut cr馥r le r駱ertoire de configuration personnel de Dia" |
90 | 90 | |
91 | -#: app/app_procs.c:462 | |
91 | +#: app/app_procs.c:465 | |
92 | 92 | msgid "" |
93 | 93 | "Could not create per-user Dia config directory. Please make sure that the " |
94 | 94 | "environment variable HOME points to an existing directory." |
@@ -97,7 +97,7 @@ msgstr "" | ||
97 | 97 | "Veuillez v駻ifier que la variable d'environnement HOME pointe vers un \n" |
98 | 98 | "r駱ertoire existant." |
99 | 99 | |
100 | -#: app/app_procs.c:484 | |
100 | +#: app/app_procs.c:487 | |
101 | 101 | msgid "Objects and filters internal to dia" |
102 | 102 | msgstr "Objets et filtres internes de Dia" |
103 | 103 |
@@ -320,12 +320,12 @@ msgstr "" | ||
320 | 320 | "Enregistrer les changements maintenant ?" |
321 | 321 | |
322 | 322 | #: app/display.c:937 app/filedlg.c:246 app/filedlg.c:435 app/preferences.c:503 |
323 | -#: lib/properties.c:288 | |
323 | +#: lib/properties.c:291 | |
324 | 324 | msgid "Yes" |
325 | 325 | msgstr "Oui" |
326 | 326 | |
327 | 327 | #: app/display.c:947 app/filedlg.c:259 app/filedlg.c:448 app/preferences.c:503 |
328 | -#: app/preferences.c:514 lib/properties.c:290 lib/properties.c:311 | |
328 | +#: app/preferences.c:514 lib/properties.c:293 lib/properties.c:314 | |
329 | 329 | msgid "No" |
330 | 330 | msgstr "Non" |
331 | 331 |
@@ -429,8 +429,8 @@ msgstr "D | ||
429 | 429 | msgid "Create Text" |
430 | 430 | msgstr "Cr馥r du texte" |
431 | 431 | |
432 | -#: app/interface.c:58 app/menus.c:197 lib/properties.c:1262 | |
433 | -#: lib/properties.h:366 | |
432 | +#: app/interface.c:58 app/menus.c:197 lib/properties.c:1290 | |
433 | +#: lib/properties.h:369 | |
434 | 434 | msgid "Text" |
435 | 435 | msgstr "Texte" |
436 | 436 |
@@ -583,7 +583,7 @@ msgstr "D | ||
583 | 583 | msgid "Line Style Properties" |
584 | 584 | msgstr "Propri騁駸 du style de ligne" |
585 | 585 | |
586 | -#: app/linewidth_area.c:216 lib/properties.h:342 | |
586 | +#: app/linewidth_area.c:216 lib/properties.h:345 | |
587 | 587 | msgid "Line width" |
588 | 588 | msgstr "Largeur de ligne" |
589 | 589 |
@@ -793,17 +793,17 @@ msgstr "Transitif" | ||
793 | 793 | msgid "Same Type" |
794 | 794 | msgstr "M麥e type" |
795 | 795 | |
796 | -#: app/menus.c:164 lib/properties.c:1247 lib/properties.h:330 | |
796 | +#: app/menus.c:164 lib/properties.c:1275 lib/properties.h:333 | |
797 | 797 | #: lib/widgets.c:199 |
798 | 798 | msgid "Left" |
799 | 799 | msgstr "タ gauche" |
800 | 800 | |
801 | -#: app/menus.c:165 app/menus.c:174 lib/properties.c:1248 lib/properties.h:331 | |
801 | +#: app/menus.c:165 app/menus.c:174 lib/properties.c:1276 lib/properties.h:334 | |
802 | 802 | #: lib/widgets.c:205 |
803 | 803 | msgid "Center" |
804 | 804 | msgstr "Au centre" |
805 | 805 | |
806 | -#: app/menus.c:166 lib/properties.c:1249 lib/properties.h:332 | |
806 | +#: app/menus.c:166 lib/properties.c:1277 lib/properties.h:335 | |
807 | 807 | #: lib/widgets.c:211 |
808 | 808 | msgid "Right" |
809 | 809 | msgstr "タ droite" |
@@ -1505,19 +1505,19 @@ msgstr "Chargement..." | ||
1505 | 1505 | msgid "Dia v %s" |
1506 | 1506 | msgstr "Dia v %s" |
1507 | 1507 | |
1508 | -#: lib/properties.c:1256 lib/properties.h:345 | |
1508 | +#: lib/properties.c:1284 lib/properties.h:348 | |
1509 | 1509 | msgid "Line colour" |
1510 | 1510 | msgstr "Couleur de ligne :" |
1511 | 1511 | |
1512 | -#: lib/properties.c:1257 lib/properties.h:348 | |
1512 | +#: lib/properties.c:1285 lib/properties.h:351 | |
1513 | 1513 | msgid "Line style" |
1514 | 1514 | msgstr "Style de ligne" |
1515 | 1515 | |
1516 | -#: lib/properties.c:1258 lib/properties.h:352 | |
1516 | +#: lib/properties.c:1286 lib/properties.h:355 | |
1517 | 1517 | msgid "Fill colour" |
1518 | 1518 | msgstr "Couleur de remplissage" |
1519 | 1519 | |
1520 | -#: lib/properties.c:1259 lib/properties.h:355 | |
1520 | +#: lib/properties.c:1287 lib/properties.h:358 | |
1521 | 1521 | #: objects/custom/custom_object.c:362 objects/flowchart/box.c:317 |
1522 | 1522 | #: objects/flowchart/diamond.c:310 objects/flowchart/ellipse.c:310 |
1523 | 1523 | #: objects/flowchart/parallelogram.c:321 objects/standard/beziergon.c:222 |
@@ -1526,29 +1526,29 @@ msgstr "Couleur de remplissage" | ||
1526 | 1526 | msgid "Draw background" |
1527 | 1527 | msgstr "Dessiner le fond" |
1528 | 1528 | |
1529 | -#: lib/properties.c:1260 lib/properties.h:359 | |
1529 | +#: lib/properties.c:1288 lib/properties.h:362 | |
1530 | 1530 | msgid "Start arrow" |
1531 | 1531 | msgstr "Fl鐵he de d饕ut" |
1532 | 1532 | |
1533 | -#: lib/properties.c:1261 lib/properties.h:362 | |
1533 | +#: lib/properties.c:1289 lib/properties.h:365 | |
1534 | 1534 | msgid "End arrow" |
1535 | 1535 | msgstr "Fl鐵he de fin" |
1536 | 1536 | |
1537 | -#: lib/properties.c:1263 lib/properties.h:369 | |
1537 | +#: lib/properties.c:1291 lib/properties.h:372 | |
1538 | 1538 | msgid "Text alignment" |
1539 | 1539 | msgstr "Alignement" |
1540 | 1540 | |
1541 | -#: lib/properties.c:1264 lib/properties.h:372 objects/GRAFCET/condition.c:131 | |
1541 | +#: lib/properties.c:1292 lib/properties.h:375 objects/GRAFCET/condition.c:131 | |
1542 | 1542 | #: objects/GRAFCET/transition.c:140 |
1543 | 1543 | msgid "Font" |
1544 | 1544 | msgstr "Police" |
1545 | 1545 | |
1546 | -#: lib/properties.c:1265 lib/properties.h:375 objects/GRAFCET/condition.c:133 | |
1546 | +#: lib/properties.c:1293 lib/properties.h:378 objects/GRAFCET/condition.c:133 | |
1547 | 1547 | #: objects/GRAFCET/transition.c:142 |
1548 | 1548 | msgid "Font size" |
1549 | 1549 | msgstr "Taille de police" |
1550 | 1550 | |
1551 | -#: lib/properties.c:1266 lib/properties.h:378 | |
1551 | +#: lib/properties.c:1294 lib/properties.h:381 | |
1552 | 1552 | msgid "Text colour" |
1553 | 1553 | msgstr "Couleur du texte" |
1554 | 1554 |
@@ -1604,7 +1604,7 @@ msgstr "" | ||
1604 | 1604 | msgid "Font %s not found, using Courier instead.\n" |
1605 | 1605 | msgstr "Police %s non trouv馥, utilisation de la police Courier la place.\n" |
1606 | 1606 | |
1607 | -#: lib/properties.c:382 lib/properties.c:414 | |
1607 | +#: lib/properties.c:386 lib/properties.c:418 | |
1608 | 1608 | msgid "No edit widget" |
1609 | 1609 | msgstr "Pas de widget d'馘ition" |
1610 | 1610 |
@@ -2801,28 +2801,28 @@ msgstr "Point Sud" | ||
2801 | 2801 | msgid "Draw arrow heads on upward arcs:" |
2802 | 2802 | msgstr "Dessine les fl鐵hes sur les arcs montants :" |
2803 | 2803 | |
2804 | -#: objects/GRAFCET/vergent.c:171 | |
2804 | +#: objects/GRAFCET/vergent.c:122 | |
2805 | 2805 | msgid "OR" |
2806 | 2806 | msgstr "OU" |
2807 | 2807 | |
2808 | -#: objects/GRAFCET/vergent.c:172 | |
2808 | +#: objects/GRAFCET/vergent.c:123 | |
2809 | 2809 | msgid "AND" |
2810 | 2810 | msgstr "ET" |
2811 | 2811 | |
2812 | -#: objects/GRAFCET/vergent.c:181 | |
2812 | +#: objects/GRAFCET/vergent.c:134 | |
2813 | 2813 | msgid "Vergent type:" |
2814 | 2814 | msgstr "Type de vergence :" |
2815 | 2815 | |
2816 | -#: objects/GRAFCET/vergent.c:446 objects/SADT/box.c:539 | |
2816 | +#: objects/GRAFCET/vergent.c:390 objects/SADT/box.c:539 | |
2817 | 2817 | #: objects/standard/line.c:182 |
2818 | 2818 | msgid "Add connection point" |
2819 | 2819 | msgstr "Ajouter un point de connexion" |
2820 | 2820 | |
2821 | -#: objects/GRAFCET/vergent.c:447 | |
2821 | +#: objects/GRAFCET/vergent.c:391 | |
2822 | 2822 | msgid "Delete connection point" |
2823 | 2823 | msgstr "Supprimer un point de connexion" |
2824 | 2824 | |
2825 | -#: objects/GRAFCET/vergent.c:451 | |
2825 | +#: objects/GRAFCET/vergent.c:395 | |
2826 | 2826 | msgid "GRAFCET OR/AND vergent" |
2827 | 2827 | msgstr "Vergence ET/OU de GRAFCET" |
2828 | 2828 |
@@ -3119,14 +3119,26 @@ msgstr "Afficher la fl | ||
3119 | 3119 | msgid "Interface:" |
3120 | 3120 | msgstr "Interface :" |
3121 | 3121 | |
3122 | -#: objects/UML/lifeline.c:138 | |
3122 | +#: objects/UML/lifeline.c:140 | |
3123 | 3123 | msgid "Draw focus of control:" |
3124 | 3124 | msgstr "Afficher le focus du contr?e :" |
3125 | 3125 | |
3126 | -#: objects/UML/lifeline.c:140 | |
3126 | +#: objects/UML/lifeline.c:142 | |
3127 | 3127 | msgid "Draw destruction mark:" |
3128 | 3128 | msgstr "Montrer la marque de destruction :" |
3129 | 3129 | |
3130 | +#: objects/UML/lifeline.c:405 | |
3131 | +msgid "Add connection points" | |
3132 | +msgstr "Ajouter des points de connexion" | |
3133 | + | |
3134 | +#: objects/UML/lifeline.c:406 | |
3135 | +msgid "Remove connection points" | |
3136 | +msgstr "Supprimer des points de connexion" | |
3137 | + | |
3138 | +#: objects/UML/lifeline.c:410 | |
3139 | +msgid "UML Lifeline" | |
3140 | +msgstr "Ligne de vie UML" | |
3141 | + | |
3130 | 3142 | #: objects/UML/message.c:158 |
3131 | 3143 | msgid "Call" |
3132 | 3144 | msgstr "Appel" |
@@ -3526,8 +3538,8 @@ msgid "Fig Format import and export filter" | ||
3526 | 3538 | msgstr "Filtre d'import depuis le format Fig" |
3527 | 3539 | |
3528 | 3540 | #: plug-ins/xfig/xfig-import.c:73 |
3529 | -msgid "Polygon import is not implemented yes" | |
3530 | -msgstr "Type d'objet %d pas encore impl駑ent? | |
3541 | +msgid "Polygon import is not implemented yet" | |
3542 | +msgstr "Import de polygones pas encore impl駑ent? | |
3531 | 3543 | |
3532 | 3544 | #: plug-ins/xfig/xfig-import.c:74 |
3533 | 3545 | msgid "Patterns are not supported by Dia" |