Hi,
the attached patch adds foreground and background colors to
UML classes. You'll find the two color selectors in the properties dialog.
If you think that this is useful and doesn't break anything, I'll commit
it to the CVS.
Steffen
diff -urN -x Makefile.in -x dia.pot -x configure -x CVS -x .cvsignore -x intl -x ABOUT-NLS -x COPYING -x aclocal.m4 -x config.guess -x config.h.in -x config.sub -x install-sh -x ltconfig -x ltmain.sh -x missing -x mkinstalldirs -x Makefile.in.in -x cat-id-tbl.c -x cat-id-tbl.c.orig -x dia.pot.orig -x *.gmo -x Makefile -x .deps -x .libs -x *.po -x *.s -x libtool -x *.proj -x po/* dia-cvs/objects/UML/class.c dia-mine/objects/UML/class.c
--- dia-cvs/objects/UML/class.c Fri Nov 12 00:32:08 1999
+++ dia-mine/objects/UML/class.c Thu Dec 21 23:47:57 2000
@@ -142,10 +142,10 @@
renderer->ops->fill_rect(renderer,
&p1, &p2,
- &color_white);
+ ¨class->color_background);
renderer->ops->draw_rect(renderer,
&p1, &p2,
- &color_black);
+ ¨class->color_foreground);
/* stereotype: */
font = umlclass->normal_font;
@@ -158,7 +158,7 @@
renderer->ops->draw_string(renderer,
umlclass->stereotype_string,
&p, ALIGN_CENTER,
- &color_black);
+ ¨class->color_foreground);
}
/* name: */
@@ -173,7 +173,7 @@
renderer->ops->draw_string(renderer,
umlclass->name,
&p, ALIGN_CENTER,
- &color_black);
+ ¨class->color_foreground);
if (umlclass->visible_attributes) {
p1.x = x;
@@ -183,10 +183,10 @@
renderer->ops->fill_rect(renderer,
&p1, &p2,
- &color_white);
+ ¨class->color_background);
renderer->ops->draw_rect(renderer,
&p1, &p2,
- &color_black);
+ ¨class->color_foreground);
if (!umlclass->suppress_attributes) {
p.x = x + UMLCLASS_BORDER/2.0 + 0.1;
@@ -205,7 +205,7 @@
renderer->ops->draw_string(renderer,
umlclass->attributes_strings[i],
&p, ALIGN_LEFT,
- &color_black);
+ ¨class->color_foreground);
if (attr->class_scope) {
p1 = p;
p1.y += umlclass->font_height*0.1;
@@ -213,7 +213,7 @@
p3.x += font_string_width(umlclass->attributes_strings[i],
font, umlclass->font_height);
renderer->ops->set_linewidth(renderer, UMLCLASS_UNDERLINEWIDTH);
- renderer->ops->draw_line(renderer, &p1, &p3, &color_black);
+ renderer->ops->draw_line(renderer, &p1, &p3, ¨class->color_foreground);
renderer->ops->set_linewidth(renderer, UMLCLASS_BORDER);
}
@@ -234,10 +234,10 @@
renderer->ops->fill_rect(renderer,
&p1, &p2,
- &color_white);
+ ¨class->color_background);
renderer->ops->draw_rect(renderer,
&p1, &p2,
- &color_black);
+ ¨class->color_foreground);
if (!umlclass->suppress_operations) {
p.x = x + UMLCLASS_BORDER/2.0 + 0.1;
p.y = p1.y + 0.1 + umlclass->font_ascent;
@@ -255,7 +255,7 @@
renderer->ops->draw_string(renderer,
umlclass->operations_strings[i],
&p, ALIGN_LEFT,
- &color_black);
+ ¨class->color_foreground);
if (op->class_scope) {
p1 = p;
@@ -264,7 +264,7 @@
p3.x += font_string_width(umlclass->operations_strings[i],
font, umlclass->font_height);
renderer->ops->set_linewidth(renderer, UMLCLASS_UNDERLINEWIDTH);
- renderer->ops->draw_line(renderer, &p1, &p3, &color_black);
+ renderer->ops->draw_line(renderer, &p1, &p3, ¨class->color_foreground);
renderer->ops->set_linewidth(renderer, UMLCLASS_BORDER);
}
@@ -287,14 +287,14 @@
renderer->ops->fill_rect(renderer,
&p1, &p2,
- &color_white);
+ ¨class->color_background);
renderer->ops->set_linestyle(renderer, LINESTYLE_DASHED);
renderer->ops->set_dashlength(renderer, 0.3);
renderer->ops->draw_rect(renderer,
&p1, &p2,
- &color_black);
+ ¨class->color_foreground);
p.x = x + 0.3;
p.y = y + 0.1 + font_ascent(umlclass->normal_font, umlclass->font_height);
@@ -309,7 +309,7 @@
renderer->ops->draw_string(renderer,
umlclass->templates_strings[i],
&p, ALIGN_LEFT,
- &color_black);
+ ¨class->color_foreground);
p.y += umlclass->font_height;
@@ -628,6 +628,9 @@
umlclass->operations_strings = NULL;
umlclass->templates_strings = NULL;
+ umlclass->color_foreground = color_black;
+ umlclass->color_background = color_white;
+
umlclass_calculate_data(umlclass);
for (i=0;i<8;i++) {
@@ -760,6 +763,8 @@
newumlclass->suppress_operations = umlclass->suppress_operations;
newumlclass->visible_attributes = umlclass->visible_attributes;
newumlclass->visible_operations = umlclass->visible_operations;
+ newumlclass->color_foreground = umlclass->color_foreground;
+ newumlclass->color_background = umlclass->color_background;
newumlclass->attributes = NULL;
list = umlclass->attributes;
@@ -889,6 +894,10 @@
umlclass->visible_attributes);
data_add_boolean(new_attribute(obj_node, "visible_operations"),
umlclass->visible_operations);
+ data_add_color(new_attribute(obj_node, "foreground_color"),
+ ¨class->color_foreground);
+ data_add_color(new_attribute(obj_node, "background_color"),
+ ¨class->color_background);
/* Attribute info: */
attr_node = new_attribute(obj_node, "attributes");
@@ -981,6 +990,16 @@
if (attr_node != NULL)
umlclass->visible_operations = data_boolean(attribute_first_data(attr_node));
+ umlclass->color_foreground = color_black;
+ attr_node = object_find_attribute(obj_node, "foreground_color");
+ if(attr_node != NULL)
+ data_color(attribute_first_data(attr_node), ¨class->color_foreground);
+
+ umlclass->color_background = color_white;
+ attr_node = object_find_attribute(obj_node, "background_color");
+ if(attr_node != NULL)
+ data_color(attribute_first_data(attr_node), ¨class->color_background);
+
/* Attribute info: */
attr_node = object_find_attribute(obj_node, "attributes");
num_attr = num = attribute_num_data(attr_node);
diff -urN -x Makefile.in -x dia.pot -x configure -x CVS -x .cvsignore -x intl -x ABOUT-NLS -x COPYING -x aclocal.m4 -x config.guess -x config.h.in -x config.sub -x install-sh -x ltconfig -x ltmain.sh -x missing -x mkinstalldirs -x Makefile.in.in -x cat-id-tbl.c -x cat-id-tbl.c.orig -x dia.pot.orig -x *.gmo -x Makefile -x .deps -x .libs -x *.po -x *.s -x libtool -x *.proj -x po/* dia-cvs/objects/UML/class.h dia-mine/objects/UML/class.h
--- dia-cvs/objects/UML/class.h Sat Oct 9 19:34:16 1999
+++ dia-mine/objects/UML/class.h Thu Dec 21 23:41:15 2000
@@ -21,6 +21,7 @@
#include "object.h"
#include "element.h"
#include "connectionpoint.h"
+#include "widgets.h"
#include "uml.h"
@@ -47,6 +48,8 @@
int suppress_operations; /* ie. don't draw strings. */
int visible_attributes;
int visible_operations;
+ Color color_foreground;
+ Color color_background;
/* Attributes: */
GList *attributes;
@@ -91,6 +94,8 @@
GtkToggleButton *attr_supp;
GtkToggleButton *op_vis;
GtkToggleButton *op_supp;
+ DiaColorSelector *fg_color;
+ DiaColorSelector *bg_color;
GList *disconnected_connections;
GList *added_connections;
diff -urN -x Makefile.in -x dia.pot -x configure -x CVS -x .cvsignore -x intl -x ABOUT-NLS -x COPYING -x aclocal.m4 -x config.guess -x config.h.in -x config.sub -x install-sh -x ltconfig -x ltmain.sh -x missing -x mkinstalldirs -x Makefile.in.in -x cat-id-tbl.c -x cat-id-tbl.c.orig -x dia.pot.orig -x *.gmo -x Makefile -x .deps -x .libs -x *.po -x *.s -x libtool -x *.proj -x po/* dia-cvs/objects/UML/class_dialog.c dia-mine/objects/UML/class_dialog.c
--- dia-cvs/objects/UML/class_dialog.c Thu Feb 3 06:15:38 2000
+++ dia-mine/objects/UML/class_dialog.c Sat Dec 23 18:42:46 2000
@@ -132,6 +132,8 @@
umlclass->visible_operations = prop_dialog->op_vis->active;
umlclass->suppress_attributes = prop_dialog->attr_supp->active;
umlclass->suppress_operations = prop_dialog->op_supp->active;
+ umlclass->color_foreground = prop_dialog->fg_color->col;
+ umlclass->color_background = prop_dialog->bg_color->col;
}
static void
@@ -152,6 +154,8 @@
gtk_toggle_button_set_active(prop_dialog->op_vis, umlclass->visible_operations);
gtk_toggle_button_set_active(prop_dialog->attr_supp, umlclass->suppress_attributes);
gtk_toggle_button_set_active(prop_dialog->op_supp, umlclass->suppress_operations);
+ dia_color_selector_set_color(prop_dialog->fg_color, ¨class->color_foreground);
+ dia_color_selector_set_color(prop_dialog->bg_color, ¨class->color_background);
}
static void
@@ -164,6 +168,8 @@
GtkWidget *vbox;
GtkWidget *entry;
GtkWidget *checkbox;
+ GtkWidget *color_background;
+ GtkWidget *color_foreground;
prop_dialog = umlclass->properties_dialog;
@@ -226,7 +232,27 @@
checkbox, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox),
hbox, FALSE, TRUE, 0);
+
+ hbox = gtk_hbox_new(FALSE, 5);
+ label = gtk_label_new(_("Foreground Color"));
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
+ gtk_box_pack_start( GTK_BOX(hbox), label, TRUE, TRUE, 0);
+ color_foreground = dia_color_selector_new();
+ dia_color_selector_set_color((DiaColorSelector *)color_foreground, ¨class->color_foreground);
+ prop_dialog->fg_color = (DiaColorSelector *)color_foreground;
+ gtk_box_pack_end( GTK_BOX(hbox), color_foreground, TRUE, TRUE,0);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
+ hbox = gtk_hbox_new(FALSE, 5);
+ label = gtk_label_new(_("Background Color"));
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
+ gtk_box_pack_start( GTK_BOX(hbox), label, TRUE, TRUE, 0);
+ color_background = dia_color_selector_new();
+ dia_color_selector_set_color((DiaColorSelector *)color_background, ¨class->color_background);
+ prop_dialog->bg_color = (DiaColorSelector *)color_background;
+ gtk_box_pack_end( GTK_BOX(hbox), color_background, TRUE, TRUE,0);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
+
gtk_widget_show_all (vbox);
gtk_widget_show (page_label);
gtk_notebook_append_page(notebook, vbox, page_label);