作図ソフト dia の改良版
修订版 | 5b764705d89ff165f9d2eed22cfe0c55b740947e (tree) |
---|---|
时间 | 2002-05-19 08:39:18 |
作者 | Lars Clausen <lclausen@src....> |
Commiter | Lars Clausen |
Text size change.
@@ -1,3 +1,10 @@ | ||
1 | +2002-05-18 Lars Clausen <lrclause@cs.uiuc.edu> | |
2 | + | |
3 | + * objects/ER/entity.c: | |
4 | + * objects/ER/attribute.c: | |
5 | + * objects/ER/relationship.c: Patch to allow text size change from | |
6 | + Celso Tetsuo Nagase Suzuki. | |
7 | + | |
1 | 8 | 2002-05-18 Steffen Macke <sdteffen@web.de> |
2 | 9 | |
3 | 10 | * app/app_procs.c: #ifdef'd xmlerror.h (comes with |
@@ -66,6 +66,7 @@ struct _Attribute { | ||
66 | 66 | Element element; |
67 | 67 | |
68 | 68 | DiaFont *font; |
69 | + real font_height; | |
69 | 70 | utfchar *name; |
70 | 71 | real name_width; |
71 | 72 |
@@ -158,6 +159,7 @@ static PropDescription attribute_props[] = { | ||
158 | 159 | PROP_STD_LINE_COLOUR, |
159 | 160 | PROP_STD_FILL_COLOUR, |
160 | 161 | PROP_STD_TEXT_FONT, |
162 | + PROP_STD_TEXT_HEIGHT, | |
161 | 163 | PROP_DESC_END |
162 | 164 | }; |
163 | 165 |
@@ -180,6 +182,7 @@ static PropOffset attribute_offsets[] = { | ||
180 | 182 | { "line_colour", PROP_TYPE_COLOUR, offsetof(Attribute, border_color) }, |
181 | 183 | { "fill_colour", PROP_TYPE_COLOUR, offsetof(Attribute, inner_color) }, |
182 | 184 | { "text_font", PROP_TYPE_FONT, offsetof(Attribute, font) }, |
185 | + { "text_height", PROP_TYPE_REAL, offsetof(Attribute, font_height) }, | |
183 | 186 | { NULL, 0, 0} |
184 | 187 | }; |
185 | 188 |
@@ -276,10 +279,10 @@ attribute_draw(Attribute *attribute, Renderer *renderer) | ||
276 | 279 | } |
277 | 280 | |
278 | 281 | p.x = elem->corner.x + elem->width / 2.0; |
279 | - p.y = elem->corner.y + (elem->height - FONT_HEIGHT)/2.0 + | |
280 | - font_ascent(attribute->font, FONT_HEIGHT); | |
282 | + p.y = elem->corner.y + (elem->height - attribute->font_height)/2.0 + | |
283 | + font_ascent(attribute->font, attribute->font_height); | |
281 | 284 | |
282 | - renderer->ops->set_font(renderer, attribute->font, FONT_HEIGHT); | |
285 | + renderer->ops->set_font(renderer, attribute->font, attribute->font_height); | |
283 | 286 | renderer->ops->draw_string(renderer, attribute->name, |
284 | 287 | &p, ALIGN_CENTER, |
285 | 288 | &color_black); |
@@ -291,7 +294,7 @@ attribute_draw(Attribute *attribute, Renderer *renderer) | ||
291 | 294 | } else { |
292 | 295 | renderer->ops->set_linestyle(renderer, LINESTYLE_SOLID); |
293 | 296 | } |
294 | - width = font_string_width(attribute->name, attribute->font, FONT_HEIGHT); | |
297 | + width = font_string_width(attribute->name, attribute->font, attribute->font_height); | |
295 | 298 | start.x = center.x - width / 2; |
296 | 299 | start.y = center.y + 0.4; |
297 | 300 | end.x = center.x + width / 2; |
@@ -310,10 +313,10 @@ attribute_update_data(Attribute *attribute) | ||
310 | 313 | real half_x, half_y; |
311 | 314 | |
312 | 315 | attribute->name_width = |
313 | - font_string_width(attribute->name, attribute->font, FONT_HEIGHT); | |
316 | + font_string_width(attribute->name, attribute->font, attribute->font_height); | |
314 | 317 | |
315 | 318 | elem->width = attribute->name_width + 2*TEXT_BORDER_WIDTH_X; |
316 | - elem->height = FONT_HEIGHT + 2*TEXT_BORDER_WIDTH_Y; | |
319 | + elem->height = attribute->font_height + 2*TEXT_BORDER_WIDTH_Y; | |
317 | 320 | |
318 | 321 | center.x = elem->corner.x + elem->width / 2.0; |
319 | 322 | center.y = elem->corner.y + elem->height / 2.0; |
@@ -389,6 +392,7 @@ attribute_create(Point *startpoint, | ||
389 | 392 | /* choose default font name for your locale. see also font_data structure |
390 | 393 | in lib/font.c. if "Courier" works for you, it would be better. */ |
391 | 394 | attribute->font = font_getfont(_("Courier")); |
395 | + attribute->font_height = FONT_HEIGHT; | |
392 | 396 | #ifdef GTK_DOESNT_TALK_UTF8_WE_DO |
393 | 397 | attribute->name = charconv_local8_to_utf8 (_("Attribute")); |
394 | 398 | #else |
@@ -396,7 +400,7 @@ attribute_create(Point *startpoint, | ||
396 | 400 | #endif |
397 | 401 | |
398 | 402 | attribute->name_width = |
399 | - font_string_width(attribute->name, attribute->font, FONT_HEIGHT); | |
403 | + font_string_width(attribute->name, attribute->font, attribute->font_height); | |
400 | 404 | |
401 | 405 | attribute_update_data(attribute); |
402 | 406 |
@@ -445,6 +449,7 @@ attribute_copy(Attribute *attribute) | ||
445 | 449 | } |
446 | 450 | |
447 | 451 | newattribute->font = attribute->font; |
452 | + newattribute->font_height = attribute->font_height; | |
448 | 453 | newattribute->name = strdup(attribute->name); |
449 | 454 | newattribute->name_width = attribute->name_width; |
450 | 455 |
@@ -481,6 +486,8 @@ attribute_save(Attribute *attribute, ObjectNode obj_node, | ||
481 | 486 | attribute->multivalue); |
482 | 487 | data_add_font (new_attribute (obj_node, "font"), |
483 | 488 | attribute->font); |
489 | + data_add_real(new_attribute(obj_node, "font_height"), | |
490 | + attribute->font_height); | |
484 | 491 | } |
485 | 492 | |
486 | 493 | static Object *attribute_load(ObjectNode obj_node, int version, |
@@ -542,6 +549,11 @@ static Object *attribute_load(ObjectNode obj_node, int version, | ||
542 | 549 | if (attr != NULL) |
543 | 550 | attribute->font = data_font (attribute_first_data (attr)); |
544 | 551 | |
552 | + attribute->font_height = FONT_HEIGHT; | |
553 | + attr = object_find_attribute (obj_node, "font_height"); | |
554 | + if (attr != NULL) | |
555 | + attribute->font_height = data_real( attribute_first_data(attr) ); | |
556 | + | |
545 | 557 | element_init(elem, 8, 8); |
546 | 558 | |
547 | 559 | for (i=0;i<8;i++) { |
@@ -556,8 +568,7 @@ static Object *attribute_load(ObjectNode obj_node, int version, | ||
556 | 568 | attribute->font = font_getfont(_("Courier")); |
557 | 569 | } |
558 | 570 | |
559 | - attribute->name_width = font_string_width(attribute->name, attribute->font, FONT_HEIGHT); | |
560 | - | |
571 | + attribute->name_width = font_string_width(attribute->name, attribute->font, attribute->font_height); | |
561 | 572 | attribute_update_data(attribute); |
562 | 573 | |
563 | 574 | for (i=0;i<8;i++) { |
@@ -55,6 +55,7 @@ struct _Entity { | ||
55 | 55 | Color inner_color; |
56 | 56 | |
57 | 57 | DiaFont *font; |
58 | + real font_height; | |
58 | 59 | utfchar *name; |
59 | 60 | real name_width; |
60 | 61 |
@@ -130,6 +131,7 @@ static PropDescription entity_props[] = { | ||
130 | 131 | PROP_STD_LINE_COLOUR, |
131 | 132 | PROP_STD_FILL_COLOUR, |
132 | 133 | PROP_STD_TEXT_FONT, |
134 | + PROP_STD_TEXT_HEIGHT, | |
133 | 135 | PROP_DESC_END |
134 | 136 | }; |
135 | 137 |
@@ -149,6 +151,7 @@ static PropOffset entity_offsets[] = { | ||
149 | 151 | { "line_colour", PROP_TYPE_COLOUR, offsetof(Entity, border_color) }, |
150 | 152 | { "fill_colour", PROP_TYPE_COLOUR, offsetof(Entity, inner_color) }, |
151 | 153 | { "text_font", PROP_TYPE_FONT, offsetof (Entity, font) }, |
154 | + { "text_height", PROP_TYPE_REAL, offsetof(Entity, font_height) }, | |
152 | 155 | { NULL, 0, 0} |
153 | 156 | }; |
154 | 157 |
@@ -255,9 +258,9 @@ entity_draw(Entity *entity, Renderer *renderer) | ||
255 | 258 | } |
256 | 259 | |
257 | 260 | p.x = elem->corner.x + elem->width / 2.0; |
258 | - p.y = elem->corner.y + (elem->height - FONT_HEIGHT)/2.0 + font_ascent(entity->font, FONT_HEIGHT); | |
261 | + p.y = elem->corner.y + (elem->height - entity->font_height)/2.0 + font_ascent(entity->font, entity->font_height); | |
259 | 262 | renderer->ops->set_font(renderer, |
260 | - entity->font, FONT_HEIGHT); | |
263 | + entity->font, entity->font_height); | |
261 | 264 | renderer->ops->draw_string(renderer, |
262 | 265 | entity->name, |
263 | 266 | &p, ALIGN_CENTER, |
@@ -272,10 +275,10 @@ entity_update_data(Entity *entity) | ||
272 | 275 | ElementBBExtras *extra = &elem->extra_spacing; |
273 | 276 | |
274 | 277 | entity->name_width = |
275 | - font_string_width(entity->name, entity->font, FONT_HEIGHT); | |
278 | + font_string_width(entity->name, entity->font, entity->font_height); | |
276 | 279 | |
277 | 280 | elem->width = entity->name_width + 2*TEXT_BORDER_WIDTH_X; |
278 | - elem->height = FONT_HEIGHT + 2*TEXT_BORDER_WIDTH_Y; | |
281 | + elem->height = entity->font_height + 2*TEXT_BORDER_WIDTH_Y; | |
279 | 282 | |
280 | 283 | /* Update connections: */ |
281 | 284 | entity->connections[0].pos = elem->corner; |
@@ -341,6 +344,7 @@ entity_create(Point *startpoint, | ||
341 | 344 | /* choose default font name for your locale. see also font_data structure |
342 | 345 | in lib/font.c. if "Courier" works for you, it would be better. */ |
343 | 346 | entity->font = font_getfont(_("Courier")); |
347 | + entity->font_height = FONT_HEIGHT; | |
344 | 348 | #ifdef GTK_DOESNT_TALK_UTF8_WE_DO |
345 | 349 | entity->name = charconv_local8_to_utf8 (_("Entity")); |
346 | 350 | #else |
@@ -348,7 +352,7 @@ entity_create(Point *startpoint, | ||
348 | 352 | #endif |
349 | 353 | |
350 | 354 | entity->name_width = |
351 | - font_string_width(entity->name, entity->font, FONT_HEIGHT); | |
355 | + font_string_width(entity->name, entity->font, entity->font_height); | |
352 | 356 | |
353 | 357 | entity_update_data(entity); |
354 | 358 |
@@ -397,6 +401,7 @@ entity_copy(Entity *entity) | ||
397 | 401 | } |
398 | 402 | |
399 | 403 | newentity->font = entity->font; |
404 | + newentity->font_height = entity->font_height; | |
400 | 405 | newentity->name = strdup(entity->name); |
401 | 406 | newentity->name_width = entity->name_width; |
402 | 407 |
@@ -422,6 +427,8 @@ entity_save(Entity *entity, ObjectNode obj_node, const char *filename) | ||
422 | 427 | entity->weak); |
423 | 428 | data_add_font (new_attribute (obj_node, "font"), |
424 | 429 | entity->font); |
430 | + data_add_real(new_attribute(obj_node, "font_height"), | |
431 | + entity->font_height); | |
425 | 432 | } |
426 | 433 | |
427 | 434 | static Object * |
@@ -471,6 +478,11 @@ entity_load(ObjectNode obj_node, int version, const char *filename) | ||
471 | 478 | if (attr != NULL) |
472 | 479 | entity->font = data_font (attribute_first_data (attr)); |
473 | 480 | |
481 | + entity->font_height = FONT_HEIGHT; | |
482 | + attr = object_find_attribute(obj_node, "font_height"); | |
483 | + if (attr != NULL) | |
484 | + entity->font_height = data_real(attribute_first_data(attr)); | |
485 | + | |
474 | 486 | element_init(elem, 8, 8); |
475 | 487 | |
476 | 488 | for (i=0;i<8;i++) { |
@@ -486,7 +498,7 @@ entity_load(ObjectNode obj_node, int version, const char *filename) | ||
486 | 498 | } |
487 | 499 | |
488 | 500 | entity->name_width = |
489 | - font_string_width(entity->name, entity->font, FONT_HEIGHT); | |
501 | + font_string_width(entity->name, entity->font, entity->font_height); | |
490 | 502 | |
491 | 503 | entity_update_data(entity); |
492 | 504 |
@@ -50,6 +50,7 @@ struct _Relationship { | ||
50 | 50 | Element element; |
51 | 51 | |
52 | 52 | DiaFont *font; |
53 | + real font_height; | |
53 | 54 | utfchar *name; |
54 | 55 | utfchar *left_cardinality; |
55 | 56 | utfchar *right_cardinality; |
@@ -145,6 +146,7 @@ static PropDescription relationship_props[] = { | ||
145 | 146 | PROP_STD_LINE_COLOUR, |
146 | 147 | PROP_STD_FILL_COLOUR, |
147 | 148 | PROP_STD_TEXT_FONT, |
149 | + PROP_STD_TEXT_HEIGHT, | |
148 | 150 | PROP_DESC_END |
149 | 151 | }; |
150 | 152 |
@@ -167,6 +169,7 @@ static PropOffset relationship_offsets[] = { | ||
167 | 169 | { "line_colour", PROP_TYPE_COLOUR, offsetof(Relationship, border_color) }, |
168 | 170 | { "fill_colour", PROP_TYPE_COLOUR, offsetof(Relationship, inner_color) }, |
169 | 171 | { "text_font", PROP_TYPE_FONT, offsetof (Relationship, font) }, |
172 | + { "text_height", PROP_TYPE_REAL, offsetof(Relationship, font_height) }, | |
170 | 173 | { NULL, 0, 0} |
171 | 174 | }; |
172 | 175 |
@@ -268,7 +271,7 @@ relationship_draw(Relationship *relationship, Renderer *renderer) | ||
268 | 271 | lc.x = corners[1].x + 0.2; |
269 | 272 | lc.y = corners[1].y - 0.3; |
270 | 273 | rc.x = corners[3].x + 0.2; |
271 | - rc.y = corners[3].y + 0.3 + FONT_HEIGHT; | |
274 | + rc.y = corners[3].y + 0.3 + relationship->font_height; | |
272 | 275 | left_align = ALIGN_LEFT; |
273 | 276 | } else { |
274 | 277 | lc.x = corners[0].x - CARDINALITY_DISTANCE; |
@@ -289,7 +292,7 @@ relationship_draw(Relationship *relationship, Renderer *renderer) | ||
289 | 292 | &relationship->border_color); |
290 | 293 | } |
291 | 294 | |
292 | - renderer->ops->set_font(renderer, relationship->font, FONT_HEIGHT); | |
295 | + renderer->ops->set_font(renderer, relationship->font, relationship->font_height); | |
293 | 296 | renderer->ops->draw_string(renderer, |
294 | 297 | relationship->left_cardinality, |
295 | 298 | &lc, left_align, |
@@ -300,8 +303,8 @@ relationship_draw(Relationship *relationship, Renderer *renderer) | ||
300 | 303 | &color_black); |
301 | 304 | |
302 | 305 | p.x = elem->corner.x + elem->width / 2.0; |
303 | - p.y = elem->corner.y + (elem->height - FONT_HEIGHT)/2.0 + | |
304 | - font_ascent(relationship->font, FONT_HEIGHT); | |
306 | + p.y = elem->corner.y + (elem->height - relationship->font_height)/2.0 + | |
307 | + font_ascent(relationship->font, relationship->font_height); | |
305 | 308 | |
306 | 309 | renderer->ops->draw_string(renderer, |
307 | 310 | relationship->name, |
@@ -317,11 +320,11 @@ relationship_update_data(Relationship *relationship) | ||
317 | 320 | ElementBBExtras *extra = &elem->extra_spacing; |
318 | 321 | |
319 | 322 | relationship->name_width = |
320 | - font_string_width(relationship->name, relationship->font, FONT_HEIGHT); | |
323 | + font_string_width(relationship->name, relationship->font, relationship->font_height); | |
321 | 324 | relationship->left_card_width = |
322 | - font_string_width(relationship->left_cardinality, relationship->font, FONT_HEIGHT); | |
325 | + font_string_width(relationship->left_cardinality, relationship->font, relationship->font_height); | |
323 | 326 | relationship->right_card_width = |
324 | - font_string_width(relationship->right_cardinality, relationship->font, FONT_HEIGHT); | |
327 | + font_string_width(relationship->right_cardinality, relationship->font, relationship->font_height); | |
325 | 328 | |
326 | 329 | elem->width = relationship->name_width + 2*TEXT_BORDER_WIDTH_X; |
327 | 330 | elem->height = elem->width * DIAMOND_RATIO; |
@@ -370,8 +373,8 @@ relationship_update_data(Relationship *relationship) | ||
370 | 373 | |
371 | 374 | /* fix boundingrelationship for line_width: */ |
372 | 375 | if(relationship->rotate) { |
373 | - obj->bounding_box.top -= FONT_HEIGHT + CARDINALITY_DISTANCE; | |
374 | - obj->bounding_box.bottom += FONT_HEIGHT + CARDINALITY_DISTANCE; | |
376 | + obj->bounding_box.top -= relationship->font_height + CARDINALITY_DISTANCE; | |
377 | + obj->bounding_box.bottom += relationship->font_height + CARDINALITY_DISTANCE; | |
375 | 378 | } |
376 | 379 | else { |
377 | 380 | obj->bounding_box.left -= CARDINALITY_DISTANCE + relationship->left_card_width; |
@@ -419,6 +422,7 @@ relationship_create(Point *startpoint, | ||
419 | 422 | /* choose default font name for your locale. see also font_data structure |
420 | 423 | in lib/font.c. if "Courier" works for you, it would be better. */ |
421 | 424 | relationship->font = font_getfont(_("Courier")); |
425 | + relationship->font_height = FONT_HEIGHT; | |
422 | 426 | #ifdef GTK_DOESNT_TALK_UTF8_WE_DO |
423 | 427 | relationship->name = charconv_local8_to_utf8 (_("Relationship")); |
424 | 428 | #else |
@@ -430,11 +434,11 @@ relationship_create(Point *startpoint, | ||
430 | 434 | relationship->rotate = FALSE; |
431 | 435 | |
432 | 436 | relationship->name_width = |
433 | - font_string_width(relationship->name, relationship->font, FONT_HEIGHT); | |
437 | + font_string_width(relationship->name, relationship->font, relationship->font_height); | |
434 | 438 | relationship->left_card_width = |
435 | - font_string_width(relationship->left_cardinality, relationship->font, FONT_HEIGHT); | |
439 | + font_string_width(relationship->left_cardinality, relationship->font, relationship->font_height); | |
436 | 440 | relationship->right_card_width = |
437 | - font_string_width(relationship->right_cardinality, relationship->font, FONT_HEIGHT); | |
441 | + font_string_width(relationship->right_cardinality, relationship->font, relationship->font_height); | |
438 | 442 | |
439 | 443 | relationship_update_data(relationship); |
440 | 444 |
@@ -485,6 +489,7 @@ relationship_copy(Relationship *relationship) | ||
485 | 489 | } |
486 | 490 | |
487 | 491 | newrelationship->font = relationship->font; |
492 | + newrelationship->font_height = relationship->font_height; | |
488 | 493 | newrelationship->name = strdup(relationship->name); |
489 | 494 | newrelationship->left_cardinality = |
490 | 495 | strdup(relationship->left_cardinality); |
@@ -524,6 +529,8 @@ relationship_save(Relationship *relationship, ObjectNode obj_node, | ||
524 | 529 | relationship->rotate); |
525 | 530 | data_add_font (new_attribute (obj_node, "font"), |
526 | 531 | relationship->font); |
532 | + data_add_real(new_attribute(obj_node, "font_height"), | |
533 | + relationship->font_height); | |
527 | 534 | } |
528 | 535 | |
529 | 536 | static Object * |
@@ -587,6 +594,11 @@ relationship_load(ObjectNode obj_node, int version, const char *filename) | ||
587 | 594 | if (attr != NULL) |
588 | 595 | relationship->font = data_font (attribute_first_data (attr)); |
589 | 596 | |
597 | + relationship->font_height = FONT_HEIGHT; | |
598 | + attr = object_find_attribute(obj_node, "font_height"); | |
599 | + if (attr != NULL) | |
600 | + relationship->font_height = data_real(attribute_first_data(attr)); | |
601 | + | |
590 | 602 | element_init(elem, 8, 8); |
591 | 603 | |
592 | 604 | for (i=0;i<8;i++) { |
@@ -602,11 +614,11 @@ relationship_load(ObjectNode obj_node, int version, const char *filename) | ||
602 | 614 | } |
603 | 615 | |
604 | 616 | relationship->name_width = |
605 | - font_string_width(relationship->name, relationship->font, FONT_HEIGHT); | |
617 | + font_string_width(relationship->name, relationship->font, relationship->font_height); | |
606 | 618 | relationship->left_card_width = |
607 | - font_string_width(relationship->left_cardinality, relationship->font, FONT_HEIGHT); | |
619 | + font_string_width(relationship->left_cardinality, relationship->font, relationship->font_height); | |
608 | 620 | relationship->right_card_width = |
609 | - font_string_width(relationship->right_cardinality, relationship->font, FONT_HEIGHT); | |
621 | + font_string_width(relationship->right_cardinality, relationship->font, relationship->font_height); | |
610 | 622 | |
611 | 623 | relationship_update_data(relationship); |
612 | 624 |