作図ソフト dia の改良版
修訂 | 79426dc815202dd2c06d8b31c22178675f314026 (tree) |
---|---|
時間 | 2004-04-01 23:17:36 |
作者 | Lars Clausen <lclausen@src....> |
Commiter | Lars Clausen |
Color and linewidth.
@@ -1,3 +1,11 @@ | ||
1 | +2004-04-01 Lars Clausen <lc@pc770.sb.statsbiblioteket.dk> | |
2 | + | |
3 | + * app/color_area.c (color_area_create): | |
4 | + * lib/attributes.c: | |
5 | + * app/linewidth_area.c: Also persistent colors and line width. | |
6 | + That was easy. Arrows and line style will take a bit more work, | |
7 | + but not much. | |
8 | + | |
1 | 9 | 2004-04-01 Lars Clausen <lars@raeder.dk> |
2 | 10 | |
3 | 11 | * app/preferences.c: All preferences are now |
@@ -27,6 +27,7 @@ | ||
27 | 27 | |
28 | 28 | #include "color_area.h" |
29 | 29 | #include "attributes.h" |
30 | +#include "persistence.h" | |
30 | 31 | |
31 | 32 | #define FORE_AREA 0 |
32 | 33 | #define BACK_AREA 1 |
@@ -453,6 +454,10 @@ color_area_create (int width, | ||
453 | 454 | { |
454 | 455 | GtkWidget *event_box; |
455 | 456 | |
457 | + // Won't work on Win32, as color_{black,white} aren't defined. Why not? | |
458 | + attributes_set_foreground(persistence_register_color("fg_color", &color_black)); | |
459 | + attributes_set_background(persistence_register_color("bg_color", &color_white)); | |
460 | + | |
456 | 461 | event_box = gtk_event_box_new(); |
457 | 462 | color_area = gtk_drawing_area_new (); |
458 | 463 | gtk_widget_set_size_request (color_area, width, height); |
@@ -168,12 +168,26 @@ linewidth_area_events (GtkWidget *widget, | ||
168 | 168 | } |
169 | 169 | |
170 | 170 | |
171 | +static int | |
172 | +linewidth_number_from_width(real width) | |
173 | +{ | |
174 | + if (fabs(width/BASE_WIDTH-rint(width/BASE_WIDTH)) > 0.0005 || | |
175 | + (width/BASE_WIDTH > NUMLINES)) { | |
176 | + return 0; | |
177 | + } else { | |
178 | + return width/BASE_WIDTH+1.0005; | |
179 | + } | |
180 | +} | |
181 | + | |
171 | 182 | GtkWidget * |
172 | 183 | linewidth_area_create (void) |
173 | 184 | { |
174 | 185 | GtkWidget *linewidth_area; |
175 | 186 | GtkWidget *event_box; |
176 | 187 | |
188 | + attributes_set_default_linewidth(persistence_register_real("linewidth", 0.1)); | |
189 | + active_linewidth = linewidth_number_from_width(attributes_get_default_linewidth()); | |
190 | + | |
177 | 191 | event_box = gtk_event_box_new(); |
178 | 192 | linewidth_area = gtk_drawing_area_new (); |
179 | 193 | gtk_drawing_area_size (GTK_DRAWING_AREA (linewidth_area), |
@@ -183,7 +197,7 @@ linewidth_area_create (void) | ||
183 | 197 | G_CALLBACK(linewidth_area_events), |
184 | 198 | NULL); |
185 | 199 | |
186 | - attributes_set_default_linewidth(BASE_WIDTH*active_linewidth); | |
200 | + // attributes_set_default_linewidth(BASE_WIDTH*active_linewidth); | |
187 | 201 | |
188 | 202 | linewidth_area_widget = linewidth_area; |
189 | 203 |
@@ -195,12 +209,7 @@ linewidth_area_create (void) | ||
195 | 209 | static void |
196 | 210 | get_current_line_width() { |
197 | 211 | float newvalue = gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(linewidth_button)); |
198 | - if (fabs(newvalue/BASE_WIDTH-rint(newvalue/BASE_WIDTH)) > 0.0005 || | |
199 | - (newvalue/BASE_WIDTH > NUMLINES)) { | |
200 | - active_linewidth = 0; | |
201 | - } else { | |
202 | - active_linewidth = newvalue/BASE_WIDTH+1.0005; | |
203 | - } | |
212 | + active_linewidth = linewidth_number_from_width(newvalue); | |
204 | 213 | linewidth_area_draw(GTK_WIDGET(linewidth_area_widget)); |
205 | 214 | attributes_set_default_linewidth(newvalue); |
206 | 215 | } |
@@ -19,6 +19,7 @@ | ||
19 | 19 | |
20 | 20 | #include "attributes.h" |
21 | 21 | #include "intl.h" |
22 | +#include "persistence.h" | |
22 | 23 | |
23 | 24 | static Color attributes_foreground = { 0.0f, 0.0f, 0.0f }; |
24 | 25 | static Color attributes_background = { 1.0f, 1.0f, 1.0f }; |
@@ -52,12 +53,14 @@ void | ||
52 | 53 | attributes_set_foreground(Color *color) |
53 | 54 | { |
54 | 55 | attributes_foreground = *color; |
56 | + persistence_set_color("fg_color", color); | |
55 | 57 | } |
56 | 58 | |
57 | 59 | void |
58 | 60 | attributes_set_background(Color *color) |
59 | 61 | { |
60 | 62 | attributes_background = *color; |
63 | + persistence_set_color("bg_color", color); | |
61 | 64 | } |
62 | 65 | |
63 | 66 | void |
@@ -65,15 +68,15 @@ attributes_swap_fgbg(void) | ||
65 | 68 | { |
66 | 69 | Color temp; |
67 | 70 | temp = attributes_foreground; |
68 | - attributes_foreground = attributes_background; | |
69 | - attributes_background = temp; | |
71 | + attributes_set_foreground(&attributes_background); | |
72 | + attributes_set_background(&temp); | |
70 | 73 | } |
71 | 74 | |
72 | 75 | void |
73 | 76 | attributes_default_fgbg(void) |
74 | 77 | { |
75 | - attributes_foreground = color_black; | |
76 | - attributes_background = color_white; | |
78 | + attributes_set_foreground(&color_black); | |
79 | + attributes_set_background(&color_white); | |
77 | 80 | } |
78 | 81 | |
79 | 82 | real |
@@ -86,6 +89,7 @@ void | ||
86 | 89 | attributes_set_default_linewidth(real width) |
87 | 90 | { |
88 | 91 | attributes_default_linewidth = width; |
92 | + persistence_set_real("linewidth", width); | |
89 | 93 | } |
90 | 94 | |
91 | 95 | Arrow |