作図ソフト dia の改良版
Révision | 1a0e58590a2ca3414fbb82ab2564f3e44dc6d64b (tree) |
---|---|
l'heure | 2001-06-12 19:19:28 |
Auteur | Cyrille Chepelov <cyrille@src....> |
Commiter | Cyrille Chepelov |
removed lazyprops for standard props. removed lazyprops (phew !) ditto
* objects/SADT/box.c: removed lazyprops for standard props.
* objects/chronograms/chronoline.c: removed lazyprops (phew !)
* objects/chronograms/chronoref.c: ditto
* lib/lazyprops.[ch] (DELETED): good riddance.
* lib/properties.[ch]: new property types:
- PROP_TYPE_STATIC: static text to be displayed in the dialog.
- PROP_TYPE_MULTISTRING: same as string, but renders as a
multi-line entry box.
- PROP_TYPE_NOTEBOOK_BEGIN,_PAGE,_END: stuff to make dialogs
in a tabbed-notebook style (this is a bit complicated to use;
see objects/chronograms/chronoline.c for an example).
@@ -1,3 +1,19 @@ | ||
1 | +2001-06-12 Cyrille Chepelov <chepelov@calixo.net> | |
2 | + | |
3 | + * objects/SADT/box.c: removed lazyprops for standard props. | |
4 | + * objects/chronograms/chronoline.c: removed lazyprops (phew !) | |
5 | + * objects/chronograms/chronoref.c: ditto | |
6 | + | |
7 | + * lib/lazyprops.[ch] (DELETED): good riddance. | |
8 | + | |
9 | + * lib/properties.[ch]: new property types: | |
10 | + - PROP_TYPE_STATIC: static text to be displayed in the dialog. | |
11 | + - PROP_TYPE_MULTISTRING: same as string, but renders as a | |
12 | + multi-line entry box. | |
13 | + - PROP_TYPE_NOTEBOOK_BEGIN,_PAGE,_END: stuff to make dialogs | |
14 | + in a tabbed-notebook style (this is a bit complicated to use; | |
15 | + see objects/chronograms/chronoline.c for an example). | |
16 | + | |
1 | 17 | 2001-06-11 Cyrille Chepelov <chepelov@calixo.net> |
2 | 18 | |
3 | 19 | * objects/GRAFCET/boolequation.[ch]: zap lazyprops. Add standard props. |
@@ -1,265 +0,0 @@ | ||
1 | -/* | |
2 | - * Various laziness routines to minimise boilerplate code | |
3 | - * Copyright(C) 2000 Cyrille Chepelov | |
4 | - * | |
5 | - * I stole most of the gtk code here. | |
6 | - * | |
7 | - * WARNING: THIS CODE IS ROTTEN. IT WILL GO AWAY SOON. YOU HAVE BEEN WARNED. | |
8 | - * | |
9 | - * This program is free software; you can redistribute it and/or modify | |
10 | - * it under the terms of the GNU General Public License as published by | |
11 | - * the Free Software Foundation; either version 2 of the License, or | |
12 | - * (at your option) any later version. | |
13 | - * | |
14 | - * This program is distributed in the hope that it will be useful, | |
15 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | - * GNU General Public License for more details. | |
18 | - * | |
19 | - * You should have received a copy of the GNU General Public License | |
20 | - * along with this program; if not, write to the Free Software | |
21 | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
22 | - */ | |
23 | - | |
24 | -#define __LAZYPROPS_C | |
25 | -#ifndef HAVE_CONFIG_H | |
26 | -#include <config.h> | |
27 | -#endif | |
28 | -#include "lazyprops.h" | |
29 | -#include "intl.h" | |
30 | - | |
31 | -void | |
32 | -__propdlg_build_enum(GtkWidget *dialog, | |
33 | - const gchar *desc, | |
34 | - PropDlgEnumEntry *enumentries) | |
35 | -{ | |
36 | - GtkWidget *label,*vbox,*button; | |
37 | - GSList *group; | |
38 | - PropDlgEnumEntry *p; | |
39 | - | |
40 | - p = enumentries; | |
41 | - | |
42 | - vbox = gtk_vbox_new(FALSE,0); | |
43 | - | |
44 | - label = gtk_label_new((desc)); | |
45 | - gtk_box_pack_start(GTK_BOX(vbox),label,FALSE,TRUE,0); | |
46 | - | |
47 | - gtk_widget_show(label); | |
48 | - | |
49 | - group = NULL; | |
50 | - while (p->desc) { | |
51 | - button = gtk_radio_button_new_with_label(group, _(p->desc)); | |
52 | - gtk_box_pack_start(GTK_BOX(vbox),button,TRUE,TRUE,0); | |
53 | - gtk_widget_show(button); | |
54 | - p->button = GTK_TOGGLE_BUTTON(button); | |
55 | - if (!group) gtk_toggle_button_set_active(p->button,TRUE); /* first */ | |
56 | - group = gtk_radio_button_group(GTK_RADIO_BUTTON(button)); | |
57 | - p++; | |
58 | - } | |
59 | - gtk_box_pack_start(GTK_BOX(dialog),vbox,TRUE,TRUE,0); | |
60 | - gtk_widget_show(vbox); | |
61 | -} | |
62 | - | |
63 | -void | |
64 | -__propdlg_set_enum(PropDlgEnumEntry *enumentries, int value) | |
65 | -{ | |
66 | - PropDlgEnumEntry *p = enumentries; | |
67 | - while (p->desc) { | |
68 | - if (value == p->value) { | |
69 | - gtk_toggle_button_set_active(p->button,TRUE); | |
70 | - break; | |
71 | - } | |
72 | - p++; | |
73 | - } | |
74 | -} | |
75 | - | |
76 | -int | |
77 | -__propdlg_get_enum(PropDlgEnumEntry *enumentries) | |
78 | -{ | |
79 | - PropDlgEnumEntry *p = enumentries; | |
80 | - while (p->desc) { | |
81 | - if (gtk_toggle_button_get_active(p->button)) | |
82 | - return p->value; | |
83 | - p++; | |
84 | - } | |
85 | - g_assert_not_reached(); | |
86 | - return 0; | |
87 | -} | |
88 | - | |
89 | -StringAttribute | |
90 | -__propdlg_build_string(GtkWidget *dialog, const gchar *desc) | |
91 | -{ | |
92 | - GtkWidget *label,*entry,*hbox; | |
93 | - | |
94 | - hbox = gtk_hbox_new(FALSE, 5); | |
95 | - | |
96 | - label = gtk_label_new(desc); | |
97 | - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0); | |
98 | - entry = gtk_entry_new(); | |
99 | - gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0); | |
100 | - gtk_widget_show (label); | |
101 | - gtk_widget_show (entry); | |
102 | - gtk_box_pack_start (GTK_BOX (dialog), hbox, TRUE, TRUE, 0); | |
103 | - gtk_widget_show(hbox); | |
104 | - | |
105 | - return GTK_ENTRY(entry); | |
106 | -} | |
107 | - | |
108 | -MultiStringAttribute | |
109 | -__propdlg_build_multistring(GtkWidget *dialog, const gchar *desc, int numlines) | |
110 | -{ | |
111 | - GtkWidget *label,*entry,*hbox; | |
112 | - | |
113 | - hbox = gtk_hbox_new(FALSE, numlines); | |
114 | - | |
115 | - label = gtk_label_new(desc); | |
116 | - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0); | |
117 | - entry = gtk_text_new(NULL,NULL); | |
118 | - gtk_text_set_editable(GTK_TEXT(entry), TRUE); | |
119 | - gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0); | |
120 | - gtk_widget_show (label); | |
121 | - gtk_widget_show (entry); | |
122 | - gtk_box_pack_start (GTK_BOX (dialog), hbox, TRUE, TRUE, 0); | |
123 | - gtk_widget_show(hbox); | |
124 | - | |
125 | - return GTK_TEXT(entry); | |
126 | -} | |
127 | - | |
128 | -void | |
129 | -__propdlg_build_separator(GtkWidget *dialog) | |
130 | -{ | |
131 | - GtkWidget *label; | |
132 | - label = gtk_hseparator_new (); | |
133 | - gtk_box_pack_start (GTK_BOX (dialog), label, FALSE, TRUE, 0); | |
134 | - gtk_widget_show (label); | |
135 | -} | |
136 | - | |
137 | -void | |
138 | -__propdlg_build_static(GtkWidget *dialog, | |
139 | - const gchar *desc) | |
140 | -{ | |
141 | - GtkWidget *label; | |
142 | - | |
143 | - label = gtk_label_new((desc)); | |
144 | - gtk_label_set_justify(GTK_LABEL(label),GTK_JUSTIFY_LEFT); | |
145 | - gtk_widget_show (label); | |
146 | - gtk_box_pack_start(GTK_BOX(dialog), label, FALSE, TRUE, 0); | |
147 | - gtk_widget_show(label); | |
148 | -} | |
149 | - | |
150 | -ArrowAttribute | |
151 | -__propdlg_build_arrow(GtkWidget *dialog, const gchar *desc) | |
152 | -{ | |
153 | - GtkWidget *hbox, *label, *align, *arrow; | |
154 | - | |
155 | - hbox = gtk_hbox_new(FALSE, 5); | |
156 | - label = gtk_label_new((desc)); | |
157 | - align = gtk_alignment_new(0.0,0.0,0.0,0.0); | |
158 | - gtk_container_add(GTK_CONTAINER(align), label); | |
159 | - gtk_box_pack_start (GTK_BOX (hbox), align, FALSE, TRUE, 0); | |
160 | - gtk_widget_show (label); | |
161 | - gtk_widget_show(align); | |
162 | - arrow = dia_arrow_selector_new(); | |
163 | - gtk_box_pack_start (GTK_BOX (hbox), arrow, TRUE, TRUE, 0); | |
164 | - gtk_widget_show (arrow); | |
165 | - gtk_widget_show(hbox); | |
166 | - gtk_box_pack_start (GTK_BOX(dialog), hbox, TRUE, TRUE, 0); | |
167 | - | |
168 | - return DIAARROWSELECTOR(arrow); | |
169 | -} | |
170 | - | |
171 | -LineStyleAttribute | |
172 | -__propdlg_build_linestyle(GtkWidget *dialog, const gchar *desc) | |
173 | -{ | |
174 | - GtkWidget *hbox,*label,*linestyle; | |
175 | - hbox = gtk_hbox_new(FALSE, 5); | |
176 | - label = gtk_label_new((desc)); | |
177 | - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0); | |
178 | - gtk_widget_show (label); | |
179 | - linestyle = dia_line_style_selector_new(); | |
180 | - gtk_box_pack_start (GTK_BOX (hbox), linestyle, TRUE, TRUE, 0); | |
181 | - gtk_widget_show (linestyle); | |
182 | - gtk_widget_show(hbox); | |
183 | - gtk_box_pack_start (GTK_BOX(dialog), hbox, TRUE, TRUE, 0); | |
184 | - | |
185 | - return DIALINESTYLESELECTOR(linestyle); | |
186 | -} | |
187 | - | |
188 | - | |
189 | -ColorAttribute | |
190 | -__propdlg_build_color(GtkWidget *dialog, const gchar *desc) | |
191 | -{ | |
192 | - GtkWidget *hbox,*label,*color; | |
193 | - | |
194 | - hbox = gtk_hbox_new(FALSE, 5); | |
195 | - label = gtk_label_new((desc)); | |
196 | - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0); | |
197 | - gtk_widget_show (label); | |
198 | - color = dia_color_selector_new(); | |
199 | - gtk_box_pack_start (GTK_BOX (hbox), color, TRUE, TRUE, 0); | |
200 | - gtk_widget_show (color); | |
201 | - gtk_widget_show(hbox); | |
202 | - gtk_box_pack_start (GTK_BOX(dialog), hbox, TRUE, TRUE, 0); | |
203 | - | |
204 | - return DIACOLORSELECTOR(color); | |
205 | -} | |
206 | - | |
207 | -BoolAttribute | |
208 | -__propdlg_build_bool(GtkWidget *dialog, const gchar *desc) | |
209 | -{ | |
210 | - GtkWidget *hbox, *cb; | |
211 | - | |
212 | - hbox = gtk_hbox_new(FALSE,5); | |
213 | - cb = gtk_check_button_new_with_label((desc)); | |
214 | - gtk_box_pack_start(GTK_BOX(hbox),cb,TRUE,TRUE,0); | |
215 | - gtk_widget_show(cb); | |
216 | - gtk_widget_show(hbox); | |
217 | - gtk_box_pack_start(GTK_BOX(dialog), hbox, FALSE, TRUE, 0); | |
218 | - return GTK_TOGGLE_BUTTON(cb); | |
219 | -} | |
220 | - | |
221 | -FontAttribute | |
222 | -__propdlg_build_font(GtkWidget *dialog, const gchar *desc) | |
223 | -{ | |
224 | - GtkWidget *hbox, *label, *font; | |
225 | - | |
226 | - hbox = gtk_hbox_new(FALSE, 5); | |
227 | - label = gtk_label_new((desc)); | |
228 | - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0); | |
229 | - gtk_widget_show (label); | |
230 | - font = dia_font_selector_new(); | |
231 | - gtk_box_pack_start (GTK_BOX (hbox), font, TRUE, TRUE, 0); | |
232 | - gtk_widget_show (font); | |
233 | - gtk_widget_show(hbox); | |
234 | - gtk_box_pack_start (GTK_BOX(dialog), hbox, TRUE, TRUE, 0); | |
235 | - return DIAFONTSELECTOR(font); | |
236 | -} | |
237 | - | |
238 | - | |
239 | -RealAttribute | |
240 | -__propdlg_build_real(GtkWidget *dialog, const gchar *desc, | |
241 | - gfloat lower, gfloat upper, gfloat step_increment) | |
242 | -{ | |
243 | - GtkWidget *hbox, *label, *spin; | |
244 | - GtkAdjustment *adj; | |
245 | - | |
246 | - hbox = gtk_hbox_new(FALSE,5); | |
247 | - label = gtk_label_new( (desc) ); | |
248 | - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 0); | |
249 | - gtk_widget_show(label); | |
250 | - adj = (GtkAdjustment *) gtk_adjustment_new(0.1, lower, upper, | |
251 | - step_increment, 10.0 * step_increment, 0.0); | |
252 | - spin = gtk_spin_button_new(adj, 1.0, 2); | |
253 | - gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(spin), TRUE); | |
254 | - gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(spin), TRUE); | |
255 | - gtk_box_pack_start(GTK_BOX (hbox), spin, TRUE, TRUE, 0); | |
256 | - gtk_widget_show (spin); | |
257 | - gtk_widget_show(hbox); | |
258 | - gtk_box_pack_start (GTK_BOX(dialog), hbox, TRUE, TRUE, 0); | |
259 | - return GTK_SPIN_BUTTON(spin); | |
260 | -} | |
261 | - | |
262 | - | |
263 | - | |
264 | - | |
265 | - |
@@ -1,664 +0,0 @@ | ||
1 | -/* | |
2 | - * Various laziness support routines to reduce boilerplate code when | |
3 | - * dealing with properties. | |
4 | - * Copyright(C) 2000 Cyrille Chepelov | |
5 | - * | |
6 | - * WARNING: THIS CODE IS ROTTEN. IT WILL GO AWAY SOON. YOU HAVE BEEN WARNED. | |
7 | - * | |
8 | - * This program is free software; you can redistribute it and/or modify | |
9 | - * it under the terms of the GNU General Public License as published by | |
10 | - * the Free Software Foundation; either version 2 of the License, or | |
11 | - * (at your option) any later version. | |
12 | - * | |
13 | - * This program is distributed in the hope that it will be useful, | |
14 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | - * GNU General Public License for more details. | |
17 | - * | |
18 | - * You should have received a copy of the GNU General Public License | |
19 | - * along with this program; if not, write to the Free Software | |
20 | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
21 | - */ | |
22 | - | |
23 | -#ifndef __LAZYPROPS_H | |
24 | -#define __LAZYPROPS_H | |
25 | - | |
26 | -#include <stdlib.h> | |
27 | -#include <string.h> | |
28 | -#include <glib.h> | |
29 | -#include <gtk/gtk.h> | |
30 | -#include <libxml/parser.h> | |
31 | - | |
32 | -#include "geometry.h" | |
33 | -#include "font.h" | |
34 | -#include "text.h" | |
35 | -#include "dia_xml.h" | |
36 | -#include "widgets.h" | |
37 | -#include "message.h" | |
38 | - | |
39 | -/* I'm sorry, this header file turned out to be much uglier than I | |
40 | - had expected. */ | |
41 | - | |
42 | - | |
43 | -/* attribute load/save routines. I wish I had some templates. */ | |
44 | - | |
45 | -#define MAKE_SAVE_FOO(typename,type) \ | |
46 | - inline static void \ | |
47 | - save_##typename(ObjectNode *obj_node, const gchar *attrname, type value) { \ | |
48 | - data_add_##typename(new_attribute(obj_node,attrname),value); \ | |
49 | - } | |
50 | - | |
51 | -MAKE_SAVE_FOO(int,int) | |
52 | -MAKE_SAVE_FOO(enum,int) | |
53 | -MAKE_SAVE_FOO(real,real) | |
54 | -MAKE_SAVE_FOO(boolean,int) | |
55 | -MAKE_SAVE_FOO(color,Color *) | |
56 | -MAKE_SAVE_FOO(point,Point *) | |
57 | -MAKE_SAVE_FOO(rectangle,Rectangle *) | |
58 | -MAKE_SAVE_FOO(string,char *) | |
59 | -MAKE_SAVE_FOO(font,Font *) | |
60 | -MAKE_SAVE_FOO(text,Text *) | |
61 | - /* composites are to be handled the hard way */ | |
62 | -#undef MAKE_SAVE_FOO | |
63 | - | |
64 | -/* The load functions are a bit heavy for inlining | |
65 | -(processor cache pollution ; code size.) */ | |
66 | - | |
67 | -#ifndef __LAZYPROPS_C | |
68 | -#define MAKE_LOAD_FOO(typename,type) \ | |
69 | - type load_##typename(ObjectNode *obj_node, const gchar *attrname, \ | |
70 | - type defaultvalue); | |
71 | - | |
72 | -#define MAKE_LOAD_FOO2(typename,type) \ | |
73 | - void load_##typename(ObjectNode *obj_node, const gchar *attrname, \ | |
74 | - type *value, type *defaultvalue); | |
75 | -#else | |
76 | -#define MAKE_LOAD_FOO(typename,type) \ | |
77 | - type load_##typename(ObjectNode *obj_node, const gchar *attrname, \ | |
78 | - type defaultvalue); \ | |
79 | - type \ | |
80 | - load_##typename(ObjectNode *obj_node, const gchar *attrname, \ | |
81 | - type defaultvalue) { \ | |
82 | - AttributeNode attr; \ | |
83 | - attr = object_find_attribute(obj_node,attrname); \ | |
84 | - if (attr != NULL) \ | |
85 | - return data_##typename( attribute_first_data(attr) ); \ | |
86 | - else \ | |
87 | - return defaultvalue; \ | |
88 | - } | |
89 | -#define MAKE_LOAD_FOO2(typename,type) \ | |
90 | - void load_##typename(ObjectNode *obj_node, const gchar *attrname, \ | |
91 | - type *value, type *defaultvalue); \ | |
92 | - void \ | |
93 | - load_##typename(ObjectNode *obj_node, const gchar *attrname, type *value, \ | |
94 | - type *defaultvalue) { \ | |
95 | - AttributeNode attr; \ | |
96 | - attr = object_find_attribute(obj_node,attrname); \ | |
97 | - if (attr != NULL) \ | |
98 | - data_##typename( attribute_first_data(attr), value); \ | |
99 | - else \ | |
100 | - if (defaultvalue) *value = *defaultvalue; \ | |
101 | - } | |
102 | -#endif /* __LAZYPROPS_C */ | |
103 | - | |
104 | -MAKE_LOAD_FOO(int,int) | |
105 | -MAKE_LOAD_FOO(enum,int) | |
106 | -MAKE_LOAD_FOO(real,real) | |
107 | -MAKE_LOAD_FOO(boolean,int) | |
108 | -MAKE_LOAD_FOO2(color,Color) | |
109 | -MAKE_LOAD_FOO2(point,Point) | |
110 | -MAKE_LOAD_FOO2(rectangle,Rectangle) | |
111 | -MAKE_LOAD_FOO(string,char *) | |
112 | -MAKE_LOAD_FOO(font,Font *) | |
113 | -MAKE_LOAD_FOO(text,Text *) | |
114 | - | |
115 | -#undef MAKE_LOAD_FOO | |
116 | -#undef MAKE_LOAD_FOO2 | |
117 | - | |
118 | -/* More integrated load and save macros. The older one are still useful | |
119 | - when it comes to fine-tuning (esp. wrt to field names in the saved file) */ | |
120 | -#define SAVE_INT(obj_node,object,field) \ | |
121 | - save_int((obj_node),#field,(object)->field); | |
122 | -#define LOAD_INT(obj_node,object,defaults,field) \ | |
123 | - (object)->field = load_int(obj_node,#field,(defaults)->field); | |
124 | -#define SAVE_REAL(obj_node,object,field) \ | |
125 | - save_real((obj_node),#field,(object)->field); | |
126 | -#define LOAD_REAL(obj_node,object,defaults,field) \ | |
127 | - (object)->field = load_real(obj_node,#field,(defaults)->field); | |
128 | -#define SAVE_BOOL(obj_node,object,field) \ | |
129 | - save_boolean((obj_node),#field,(object)->field); | |
130 | -#define LOAD_BOOL(obj_node,object,defaults,field) \ | |
131 | - (object)->field = load_boolean(obj_node,#field,(defaults)->field); | |
132 | -#define SAVE_COLOR(obj_node,object,field) \ | |
133 | - save_color((obj_node),#field,&(object)->field); | |
134 | -#define LOAD_COLOR(obj_node,object,defaults,field) \ | |
135 | - load_color(obj_node,#field,&(object)->field,&(defaults)->field); | |
136 | -#define SAVE_POINT(obj_node,object,field) \ | |
137 | - save_point((obj_node),#field,&(object)->field); | |
138 | -#define LOAD_POINT(obj_node,object,defaults,field) \ | |
139 | - load_point(obj_node,#field,&(object)->field,&(defaults)->field); | |
140 | -#define SAVE_RECT(obj_node,object,field) \ | |
141 | - save_rectangle((obj_node),#field,&(object)->field); | |
142 | -#define LOAD_RECT(obj_node,object,defaults,field) \ | |
143 | - load_rectangle(obj_node,#field,&(object)->field,&(defaults)->field); | |
144 | -#define SAVE_STRING(obj_node,object,field) \ | |
145 | - save_string((obj_node),#field,(object)->field); | |
146 | -#define LOAD_STRING(obj_node,object,defaults,field) \ | |
147 | - (object)->field = load_string(obj_node,#field,NULL); \ | |
148 | - if (!(object)->field) (object)->field = g_strdup((defaults)->field); | |
149 | -#define SAVE_FONT(obj_node,object,field) \ | |
150 | - save_font((obj_node),#field,(object)->field); | |
151 | -#define LOAD_FONT(obj_node,object,defaults,field) \ | |
152 | - (object)->field = load_font(obj_node,#field,(defaults)->field); | |
153 | -#define SAVE_FONTHEIGHT(obj_node,object,field) \ | |
154 | - save_real((obj_node),#field,(object)->field); | |
155 | -#define LOAD_FONTHEIGHT(obj_node,object,defaults,field) \ | |
156 | - (object)->field = load_real(obj_node,#field,(defaults)->field); | |
157 | -#define SAVE_TEXT(obj_node,object,field) \ | |
158 | - save_text((obj_node),#field,(object)->field); | |
159 | -#define LOAD_TEXT(obj_node,object,defaults,field) \ | |
160 | - (object)->text = load_text(obj_node,#field,NULL); | |
161 | - | |
162 | - | |
163 | -/* Attribute editing dialog ("Properties.*" stuff) */ | |
164 | -/* Goal : no, or almost no gtk garb^Wstuff in an object's code. Or at worst, | |
165 | - really nicely hidden. */ | |
166 | - | |
167 | -/* contract : | |
168 | - - object type Foo has a single object properties dialog (FooProperties), | |
169 | - which will be pointed to by the first parameter "PropertiesDialog" | |
170 | - (or "propdlg", in short) of all the following macros. | |
171 | - - "propdlg" has a single AttributeDialog field, called "dialog", which | |
172 | - in fact is a gtk VBox. | |
173 | - - "propdlg" has a single Foo * pointer, called "parent", which traces back | |
174 | - to the Foo object structure being edited, or NULL. | |
175 | - | |
176 | - - All of (Foo *)'s fields which are to be edited by the property dialog | |
177 | - has a matching "propdlg" field of a related type. | |
178 | - - Description strings are to be passed with _( ) around it (i18n). | |
179 | - | |
180 | - - all type-specific macros take at least the following arguments : | |
181 | - * propdlg the name of the propdlg variable | |
182 | - * field the name of the field being changed (in both propdlg and | |
183 | - propdlg->parent) | |
184 | - * desc an i18n-able description string. | |
185 | - | |
186 | - For the text font, font height and color attributes, the fields in the | |
187 | - dialog structure must respectively be called foo_font, foo_fontheight and | |
188 | - foo_color (where "foo" is the name of the text field in the parent object). | |
189 | - | |
190 | -*/ | |
191 | - | |
192 | -#define PROPDLG_TYPE GtkWidget * | |
193 | -typedef struct { | |
194 | - GtkWidget *d; | |
195 | - GtkWidget *label; | |
196 | - gboolean ready; | |
197 | -} AttributeDialog; /* This is intended to be opaque */ | |
198 | - | |
199 | -/* to be called to create a new, empty dialog. */ | |
200 | -#define PROPDLG_CREATE(propdlg,parentvalue) \ | |
201 | - if (!propdlg) { \ | |
202 | - (propdlg) = g_malloc0(sizeof(*(propdlg)) ); \ | |
203 | - (propdlg)->dialog.d = gtk_vbox_new(FALSE,5); \ | |
204 | - gtk_object_ref(GTK_OBJECT((propdlg)->dialog.d)); \ | |
205 | - gtk_object_sink(GTK_OBJECT((propdlg)->dialog.d)); \ | |
206 | - gtk_container_set_border_width(GTK_CONTAINER((propdlg)->dialog.d), 10); \ | |
207 | - /* (propdlg)->dialog.ready = FALSE; */ \ | |
208 | - } \ | |
209 | - (propdlg)->parent = (parentvalue); | |
210 | - | |
211 | -/* to be called when the dialog is almost ready to show (bracket the rest with | |
212 | - PROPDLG_CREATE and PROPDLG_READY) */ | |
213 | -#define PROPDLG_READY(propdlg) \ | |
214 | - if (!(propdlg)->dialog.ready) { \ | |
215 | - gtk_widget_show((propdlg)->dialog.d); \ | |
216 | - (propdlg)->dialog.ready = TRUE; \ | |
217 | - } | |
218 | - | |
219 | -/* The return type of get_foo_properties() */ | |
220 | -#define PROPDLG_RETURN(propdlg) \ | |
221 | - return propdlg->dialog.d; | |
222 | -/* This defines a notebook inside a dialog. */ | |
223 | -typedef GtkWidget *AttributeNotebook; | |
224 | -#define PROPDLG_NOTEBOOK_CREATE(propdlg,field) \ | |
225 | - if (!(propdlg)->dialog.ready) {\ | |
226 | - (propdlg)->field = gtk_notebook_new (); \ | |
227 | - gtk_notebook_set_tab_pos (GTK_NOTEBOOK((propdlg)->field), GTK_POS_TOP); \ | |
228 | - gtk_box_pack_start (GTK_BOX ((propdlg)->dialog.d), \ | |
229 | - (propdlg)->field, TRUE, TRUE, 0); \ | |
230 | - gtk_container_set_border_width (GTK_CONTAINER((propdlg)->field), 10); \ | |
231 | - } | |
232 | -#define PROPDLG_NOTEBOOK_READY(propdlg,field) \ | |
233 | - if (!(propdlg)->dialog.ready) {\ | |
234 | - gtk_widget_show((propdlg)->field); \ | |
235 | - } | |
236 | - | |
237 | -/* This defines a notebook page. | |
238 | - The "field" must be a pointer to an ad-hoc struct similar to the normal | |
239 | - property dialog structs. */ | |
240 | -typedef AttributeDialog AttributePage; | |
241 | -#define PROPDLG_PAGE_CREATE(propdlg,notebook,field,desc) \ | |
242 | - if (!(propdlg)->dialog.ready) { \ | |
243 | - (propdlg)->field = g_malloc0(sizeof(*((propdlg)->field))); \ | |
244 | - (propdlg)->field->dialog.d = gtk_vbox_new(FALSE,5); \ | |
245 | - /*(propdlg)->field->dialog.ready = FALSE; */ \ | |
246 | - gtk_container_set_border_width(GTK_CONTAINER((propdlg)->field->dialog.d),\ | |
247 | - 10); \ | |
248 | - (propdlg)->field->dialog.label = gtk_label_new((desc)); \ | |
249 | - } \ | |
250 | - (propdlg)->field->parent = (propdlg)->parent; | |
251 | - | |
252 | -#define PROPDLG_PAGE_READY(propdlg,notebook,field) \ | |
253 | - if (!(propdlg)->field->dialog.ready) { \ | |
254 | - gtk_widget_show_all((propdlg)->field->dialog.d); \ | |
255 | - gtk_widget_show_all((propdlg)->field->dialog.label); \ | |
256 | - gtk_widget_show((propdlg)->field->dialog.d); \ | |
257 | - gtk_notebook_append_page(GTK_NOTEBOOK((propdlg)->notebook), \ | |
258 | - (propdlg)->field->dialog.d, \ | |
259 | - (propdlg)->field->dialog.label); \ | |
260 | - (propdlg)->field->dialog.ready = TRUE; \ | |
261 | - } | |
262 | - | |
263 | -/* This defines a real attribute. */ | |
264 | -typedef GtkSpinButton *RealAttribute; | |
265 | -RealAttribute __propdlg_build_real(GtkWidget *dialog, | |
266 | - const gchar *desc, | |
267 | - gfloat lower, | |
268 | - gfloat upper, | |
269 | - gfloat step_increment); | |
270 | - | |
271 | -#define __PROPDLG_BUILD_REAL(propdlg, field, desc, lower, upper, \ | |
272 | - step_increment)\ | |
273 | - (propdlg)->field = __propdlg_build_real((propdlg)->dialog.d,(desc), \ | |
274 | - (lower),(upper), \ | |
275 | - (step_increment)); | |
276 | -#define __PROPDLG_SHOW_REAL(propdlg,field) \ | |
277 | - gtk_spin_button_set_value((propdlg)->field, \ | |
278 | - (propdlg)->parent->field); | |
279 | -#define PROPDLG_SHOW_REAL(propdlg, field, desc, lower, upper, step_increment)\ | |
280 | - if (!(propdlg)->dialog.ready) {\ | |
281 | - __PROPDLG_BUILD_REAL((propdlg),field,(desc),(lower), \ | |
282 | - (upper),(step_increment)) ;} \ | |
283 | - __PROPDLG_SHOW_REAL((propdlg),field) | |
284 | - | |
285 | -#define PROPDLG_APPLY_REAL(propdlg, field) \ | |
286 | - (propdlg)->parent->field = \ | |
287 | - gtk_spin_button_get_value_as_float((propdlg)->field); | |
288 | - | |
289 | -/* This defines an int attribute. */ | |
290 | -typedef GtkSpinButton *IntAttribute; | |
291 | -#define __PROPDLG_BUILD_INT(propdlg, field, desc, lower, upper, step_increment)\ | |
292 | - (propdlg)->field = __propdlg_build_real((propdlg)->dialog.d,(desc), \ | |
293 | - (guint)(lower), \ | |
294 | - (guint)(upper), \ | |
295 | - (guint)(step_increment)); | |
296 | - | |
297 | -#define __PROPDLG_SHOW_INT(propdlg, field) \ | |
298 | - gtk_spin_button_set_value((propdlg)->field, \ | |
299 | - (propdlg)->parent->field); | |
300 | -#define PROPDLG_SHOW_INT(propdlg, field, desc, lower, upper, step_increment)\ | |
301 | - if (!(propdlg)->dialog.ready) {\ | |
302 | - __PROPDLG_BUILD_INT((propdlg),field,(desc),(lower), \ | |
303 | - (upper),(step_increment)) ;}\ | |
304 | - __PROPDLG_SHOW_INT((propdlg),field) | |
305 | - | |
306 | -#define PROPDLG_APPLY_INT(propdlg, field) \ | |
307 | - (propdlg)->parent->field = \ | |
308 | - gtk_spin_button_get_value_as_int((propdlg)->field); | |
309 | - | |
310 | - | |
311 | - | |
312 | -/* This defines a Boolean attribute : */ | |
313 | -typedef GtkToggleButton *BoolAttribute; | |
314 | -BoolAttribute __propdlg_build_bool(GtkWidget *dialog, | |
315 | - const gchar *desc); | |
316 | -#define __PROPDLG_BUILD_BOOL(propdlg, field, desc) \ | |
317 | - (propdlg)->field = __propdlg_build_bool((propdlg)->dialog.d,(desc)); | |
318 | -#define __PROPDLG_SHOW_BOOL(propdlg,field) \ | |
319 | - gtk_toggle_button_set_active((propdlg)->field, (propdlg)->parent->field); | |
320 | - | |
321 | -#define PROPDLG_SHOW_BOOL(propdlg, field, desc) \ | |
322 | - if (!(propdlg)->dialog.ready) {\ | |
323 | - __PROPDLG_BUILD_BOOL((propdlg),field,(desc)) ;}\ | |
324 | - __PROPDLG_SHOW_BOOL((propdlg),field) | |
325 | -#define PROPDLG_APPLY_BOOL(propdlg,field) \ | |
326 | - (propdlg)->parent->field = (propdlg)->field->active; | |
327 | - | |
328 | - | |
329 | -/* This defines a Font attribute : */ | |
330 | -typedef DiaFontSelector *FontAttribute; | |
331 | -typedef DiaFontSelector *TextFontAttribute; | |
332 | - | |
333 | -FontAttribute __propdlg_build_font(GtkWidget *dialog, | |
334 | - const gchar *desc); | |
335 | -#define __PROPDLG_BUILD_FONT(propdlg,field,desc) \ | |
336 | - (propdlg)->field = __propdlg_build_font((propdlg)->dialog.d,(desc)); | |
337 | -#define __PROPDLG_BUILD_TEXTFONT(propdlg,field,desc) \ | |
338 | - __PROPDLG_BUILD_FONT((propdlg),field##_font,(desc)) | |
339 | - | |
340 | -#define __PROPDLG_SHOW_FONT(propdlg,field) \ | |
341 | - dia_font_selector_set_font((propdlg)->field,(propdlg)->parent->field); | |
342 | -#define __PROPDLG_SHOW_TEXTFONT(propdlg,field) \ | |
343 | - dia_font_selector_set_font((propdlg)->field##_font, \ | |
344 | - (propdlg)->parent->field->font); | |
345 | - | |
346 | -#define PROPDLG_SHOW_FONT(propdlg, field, desc) \ | |
347 | - if (!(propdlg)->dialog.ready) {\ | |
348 | - __PROPDLG_BUILD_FONT((propdlg),field,(desc)) ;}\ | |
349 | - __PROPDLG_SHOW_FONT((propdlg),field) | |
350 | -#define PROPDLG_SHOW_TEXTFONT(propdlg, field, desc) \ | |
351 | - if (!(propdlg)->dialog.ready) {\ | |
352 | - __PROPDLG_BUILD_TEXTFONT((propdlg),field,(desc)) ;}\ | |
353 | - __PROPDLG_SHOW_TEXTFONT((propdlg),field) | |
354 | - | |
355 | -#define PROPDLG_APPLY_FONT(propdlg,field) \ | |
356 | - (propdlg)->parent->field = dia_font_selector_get_font((propdlg)->field); | |
357 | -#define PROPDLG_APPLY_TEXTFONT(propdlg,field) \ | |
358 | - text_set_font((propdlg)->parent->field, \ | |
359 | - dia_font_selector_get_font((propdlg)->field##_font)); | |
360 | - | |
361 | -/* This defines a Font Height attribute : */ | |
362 | -typedef RealAttribute FontHeightAttribute; | |
363 | -typedef RealAttribute TextFontHeightAttribute; | |
364 | - | |
365 | -#define __PROPDLG_BUILD_FONTHEIGHT(propdlg,field,desc) \ | |
366 | - __PROPDLG_BUILD_REAL((propdlg),field,(desc),0.0,10.0,0.1) | |
367 | -#define __PROPDLG_BUILD_TEXTFONTHEIGHT(propdlg,field,desc) \ | |
368 | - __PROPDLG_BUILD_REAL((propdlg),field##_fontheight,(desc),0.0,10.0,0.1) | |
369 | -#define __PROPDLG_SHOW_FONTHEIGHT(propdlg,field) \ | |
370 | - __PROPDLG_SHOW_REAL((propdlg),field) | |
371 | -#define __PROPDLG_SHOW_TEXTFONTHEIGHT(propdlg,field) \ | |
372 | - gtk_spin_button_set_value((propdlg)->field##_fontheight, \ | |
373 | - (propdlg)->parent->field->height); | |
374 | - | |
375 | -#define PROPDLG_SHOW_FONTHEIGHT(propdlg, field, desc) \ | |
376 | - if (!(propdlg)->dialog.ready) {\ | |
377 | - __PROPDLG_BUILD_FONTHEIGHT((propdlg),field,(desc)) ;}\ | |
378 | - __PROPDLG_SHOW_FONTHEIGHT((propdlg),field) | |
379 | -#define PROPDLG_SHOW_TEXTFONTHEIGHT(propdlg, field, desc) \ | |
380 | - if (!(propdlg)->dialog.ready) {\ | |
381 | - __PROPDLG_BUILD_TEXTFONTHEIGHT((propdlg),field,(desc)) ;}\ | |
382 | - __PROPDLG_SHOW_TEXTFONTHEIGHT((propdlg),field) | |
383 | - | |
384 | -#define PROPDLG_APPLY_FONTHEIGHT(propdlg,field) \ | |
385 | - PROPDLG_APPLY_REAL((propdlg),field) | |
386 | -#define PROPDLG_APPLY_TEXTFONTHEIGHT(propdlg,field) \ | |
387 | - text_set_height((propdlg)->parent->field, \ | |
388 | - gtk_spin_button_get_value_as_float( \ | |
389 | - (propdlg)->field##_fontheight)); | |
390 | - | |
391 | -/* This defines a Color attribute : */ | |
392 | -typedef DiaColorSelector *ColorAttribute; | |
393 | -typedef DiaColorSelector *TextColorAttribute; | |
394 | -ColorAttribute __propdlg_build_color(GtkWidget *dialog, | |
395 | - const gchar *desc); | |
396 | -#define __PROPDLG_BUILD_COLOR(propdlg,field,desc) \ | |
397 | - (propdlg)->field = __propdlg_build_color((propdlg)->dialog.d,(desc)); | |
398 | - | |
399 | -#define __PROPDLG_BUILD_TEXTCOLOR(propdlg,field,desc) \ | |
400 | - __PROPDLG_BUILD_COLOR((propdlg),field##_color,(desc)) | |
401 | - | |
402 | -#define __PROPDLG_SHOW_COLOR(propdlg,field) \ | |
403 | - dia_color_selector_set_color((propdlg)->field, \ | |
404 | - &((propdlg)->parent->field)); | |
405 | -#define __PROPDLG_SHOW_TEXTCOLOR(propdlg,field) \ | |
406 | - dia_color_selector_set_color((propdlg)->field##_color, \ | |
407 | - &((propdlg)->parent->field->color)); | |
408 | - | |
409 | -#define PROPDLG_SHOW_COLOR(propdlg, field, desc) \ | |
410 | - if (!(propdlg)->dialog.ready) \ | |
411 | - __PROPDLG_BUILD_COLOR((propdlg),field,(desc)) \ | |
412 | - __PROPDLG_SHOW_COLOR((propdlg),field) | |
413 | -#define PROPDLG_SHOW_TEXTCOLOR(propdlg, field, desc) \ | |
414 | - if (!(propdlg)->dialog.ready) {\ | |
415 | - __PROPDLG_BUILD_TEXTCOLOR((propdlg),field,(desc)) ;} \ | |
416 | - __PROPDLG_SHOW_TEXTCOLOR((propdlg),field) | |
417 | - | |
418 | -#define PROPDLG_APPLY_COLOR(propdlg,field) \ | |
419 | - dia_color_selector_get_color((propdlg)->field, \ | |
420 | - &((propdlg)->parent->field)); | |
421 | -#define PROPDLG_APPLY_TEXTCOLOR(propdlg,field) \ | |
422 | - G_STMT_START { \ | |
423 | - Color col; \ | |
424 | - dia_color_selector_get_color((propdlg)->field##_color, &col); \ | |
425 | - text_set_color((propdlg)->parent->field,&col); \ | |
426 | - } G_STMT_END | |
427 | - | |
428 | - | |
429 | -/* This defines a Line Width attribute : */ | |
430 | -typedef RealAttribute LineWidthAttribute; | |
431 | - | |
432 | -#define __PROPDLG_BUILD_LINEWIDTH(propdlg,field,desc) \ | |
433 | - __PROPDLG_BUILD_REAL((propdlg),field,(desc),0.00,10.00,0.01) | |
434 | -#define __PROPDLG_SHOW_LINEWIDTH(propdlg,field) \ | |
435 | - __PROPDLG_SHOW_REAL((propdlg),field) | |
436 | -#define PROPDLG_SHOW_LINEWIDTH(propdlg, field, desc) \ | |
437 | - if (!(propdlg)->dialog.ready) {\ | |
438 | - __PROPDLG_BUILD_LINEWIDTH((propdlg),field,(desc)) ;}\ | |
439 | - __PROPDLG_SHOW_LINEWIDTH((propdlg),field) | |
440 | -#define PROPDLG_APPLY_LINEWIDTH(propdlg,field,desc) \ | |
441 | - PROPDLG_APPLY_REAL(propdlg,field) | |
442 | - | |
443 | -/* This defines a Line Style attribute. If that field is named "foo", then | |
444 | - it will demand two fields in the parent object, foo_style and | |
445 | - foo_dashlength, of the correct types (LineStyle and real). | |
446 | - (I'm not really happy about this).*/ | |
447 | -typedef DiaLineStyleSelector *LineStyleAttribute; | |
448 | -LineStyleAttribute __propdlg_build_linestyle(GtkWidget *dialog, | |
449 | - const gchar *desc); | |
450 | -#define __PROPDLG_BUILD_LINESTYLE(propdlg,field,desc) \ | |
451 | - (propdlg)->field = __propdlg_build_linestyle((propdlg)->dialog.d,(desc)); | |
452 | - | |
453 | -#define __PROPDLG_SHOW_LINESTYLE(propdlg,field) \ | |
454 | - dia_line_style_selector_set_linestyle((propdlg)->field, \ | |
455 | - (propdlg)->parent->field##_style, \ | |
456 | - (propdlg)->parent->field##_dashlength); | |
457 | -#define PROPDLG_SHOW_LINESTYLE(propdlg, field, desc) \ | |
458 | - if (!(propdlg)->dialog.ready) {\ | |
459 | - __PROPDLG_BUILD_LINESTYLE((propdlg),field,(desc)) ;}\ | |
460 | - __PROPDLG_SHOW_LINESTYLE((propdlg),field) | |
461 | -#define PROPDLG_APPLY_LINESTYLE(propdlg,field) \ | |
462 | - dia_line_style_selector_get_linestyle((propdlg)->field, \ | |
463 | - &((propdlg)->parent->field##_style), \ | |
464 | - &((propdlg)->parent->field##_dashlength)); | |
465 | - | |
466 | -/* This defines an Arrow attribute. */ | |
467 | -typedef DiaArrowSelector *ArrowAttribute; | |
468 | -ArrowAttribute __propdlg_build_arrow(GtkWidget *dialog, | |
469 | - const gchar *desc); | |
470 | -#define __PROPDLG_BUILD_ARROW(propdlg,field,desc) \ | |
471 | - (propdlg)->field = __propdlg_build_arrow((propdlg)->dialog.d,(desc)); | |
472 | - | |
473 | -#define __PROPDLG_SHOW_ARROW(propdlg,field) \ | |
474 | - dia_arrow_selector_set_arrow((propdlg)->field, \ | |
475 | - (propdlg)->parent->field); | |
476 | -#define PROPDLG_SHOW_ARROW(propdlg, field, desc) \ | |
477 | - if (!(propdlg)->dialog.ready) {\ | |
478 | - __PROPDLG_BUILD_LINEWIDTH((propdlg),field,(desc)) ;}\ | |
479 | - __PROPDLG_SHOW_LINEWIDTH((propdlg),field) | |
480 | -#define PROPDLG_APPLY_ARROW(propdlg,field) \ | |
481 | - (propdlg)->parent->field = \ | |
482 | - dia_arrow_selector_get_arrow((propdlg)->field); | |
483 | - | |
484 | -/* Enum attributes are a bit trickier. They need to provide a way to tell | |
485 | - how to build them, ie the human description of all possible values. | |
486 | - To make things funnier, there's a variable number of possible values... | |
487 | - */ | |
488 | -typedef struct { | |
489 | - const gchar *desc; | |
490 | - int value; | |
491 | - GtkToggleButton *button; /* should be initialised as NULL */ | |
492 | -} PropDlgEnumEntry; | |
493 | -typedef PropDlgEnumEntry *EnumAttribute; | |
494 | - | |
495 | -/* enumentries is a pointer to a NULL-terminated array of PropDlgEnumEntry, | |
496 | - to which the _BUILD_ function has the right to write once (the button field) | |
497 | -*/ | |
498 | -void __propdlg_build_enum(GtkWidget *dialog, | |
499 | - const gchar *desc, | |
500 | - PropDlgEnumEntry *enumentries); | |
501 | -void __propdlg_set_enum(PropDlgEnumEntry *enumentries,int value); | |
502 | -int __propdlg_get_enum(PropDlgEnumEntry *enumentries); | |
503 | - | |
504 | -#define __PROPDLG_BUILD_ENUM(propdlg,field,desc,enumentries) \ | |
505 | - (propdlg)->field = (enumentries); \ | |
506 | - __propdlg_build_enum((propdlg)->dialog.d,(desc),(enumentries)); | |
507 | -#define __PROPDLG_SHOW_ENUM(propdlg,field) \ | |
508 | - __propdlg_set_enum((propdlg)->field,(propdlg)->parent->field); | |
509 | - | |
510 | -#define PROPDLG_SHOW_ENUM(propdlg, field, desc,enumentries) \ | |
511 | - if (!(propdlg)->dialog.ready) {\ | |
512 | - __PROPDLG_BUILD_ENUM((propdlg),field,(desc),(enumentries)) ;}\ | |
513 | - __PROPDLG_SHOW_ENUM((propdlg),field) | |
514 | -#define PROPDLG_APPLY_ENUM(propdlg,field) \ | |
515 | - (propdlg)->parent->field = __propdlg_get_enum((propdlg)->field); | |
516 | - | |
517 | -/* This defines a string (gchar *) attribute. */ | |
518 | -typedef GtkEntry *StringAttribute; | |
519 | -StringAttribute __propdlg_build_string(GtkWidget *dialog, | |
520 | - const gchar *desc); | |
521 | -#define __PROPDLG_BUILD_STRING(propdlg,field,desc) \ | |
522 | - (propdlg)->field = __propdlg_build_string((propdlg)->dialog.d,(desc)); | |
523 | -#define __PROPDLG_SHOW_STRING(propdlg,field) \ | |
524 | - gtk_entry_set_text((propdlg)->field,(propdlg)->parent->field); | |
525 | -#define PROPDLG_SHOW_STRING(propdlg, field, desc) \ | |
526 | - if (!(propdlg)->dialog.ready) {\ | |
527 | - __PROPDLG_BUILD_STRING((propdlg),field,(desc)) ;} \ | |
528 | - __PROPDLG_SHOW_STRING((propdlg),field) | |
529 | -#define PROPDLG_APPLY_STRING(propdlg,field) \ | |
530 | - g_free((propdlg)->parent->field); \ | |
531 | - (propdlg)->parent->field = strdup(gtk_entry_get_text((propdlg)->field)); | |
532 | - | |
533 | -/* This defines a string (gchar *) attribute. */ | |
534 | -typedef GtkText *MultiStringAttribute; | |
535 | -MultiStringAttribute __propdlg_build_multistring(GtkWidget *dialog, | |
536 | - const gchar *desc, | |
537 | - int numlines); | |
538 | -#define __PROPDLG_BUILD_MULTISTRING(propdlg,field,desc,numlines) \ | |
539 | - (propdlg)->field = __propdlg_build_multistring((propdlg)->dialog.d, \ | |
540 | - (desc),(numlines)); | |
541 | -#define __PROPDLG_SHOW_MULTISTRING(propdlg,field) \ | |
542 | - gtk_text_set_point((propdlg)->field, 0 ); \ | |
543 | - gtk_text_forward_delete((propdlg)->field, \ | |
544 | - gtk_text_get_length((propdlg)->field)); \ | |
545 | - gtk_text_insert((propdlg)->field, NULL, NULL, NULL, \ | |
546 | - g_strdup((propdlg)->parent->field), -1); | |
547 | - | |
548 | -#define PROPDLG_SHOW_MULTISTRING(propdlg, field, desc,numlines) \ | |
549 | - if (!(propdlg)->dialog.ready) {\ | |
550 | - __PROPDLG_BUILD_MULTISTRING((propdlg),field,(desc),(numlines)) ;} \ | |
551 | - __PROPDLG_SHOW_MULTISTRING((propdlg),field) | |
552 | -#define PROPDLG_APPLY_MULTISTRING(propdlg,field) \ | |
553 | - g_free((propdlg)->parent->field); \ | |
554 | - (propdlg)->parent->field = strdup(gtk_editable_get_chars( \ | |
555 | - GTK_EDITABLE((propdlg)->field),0, -1)); | |
556 | - | |
557 | -#define __PROPDLG_BUILD_TEXTTEXT(propdlg,field,desc,numlines) \ | |
558 | - __PROPDLG_BUILD_MULTISTRING((propdlg),field,(desc),(numlines)) | |
559 | -#define __PROPDLG_SHOW_TEXTTEXT(propdlg,field) \ | |
560 | - gtk_text_set_point((propdlg)->field, 0 ); \ | |
561 | - gtk_text_forward_delete((propdlg)->field, \ | |
562 | - gtk_text_get_length((propdlg)->field)); \ | |
563 | - gtk_text_insert((propdlg)->field, NULL, NULL, NULL, \ | |
564 | - text_get_string_copy((propdlg)->parent->field), -1); | |
565 | - | |
566 | -#define PROPDLG_SHOW_TEXTTEXT(propdlg, field, desc,numlines) \ | |
567 | - if (!(propdlg)->dialog.ready) {\ | |
568 | - __PROPDLG_BUILD_TEXTTEXT((propdlg),field,(desc),(numlines)) ;} \ | |
569 | - __PROPDLG_SHOW_TEXTTEXT((propdlg),field) | |
570 | -#define PROPDLG_APPLY_TEXTTEXT(propdlg,field) \ | |
571 | - text_set_string((propdlg)->parent->field, gtk_editable_get_chars( \ | |
572 | - GTK_EDITABLE((propdlg)->field),0, -1)); | |
573 | - | |
574 | -void __propdlg_build_static(GtkWidget *dialog, const gchar *desc); | |
575 | -#define __PROPDLG_BUILD_STATIC(propdlg,desc) \ | |
576 | - __propdlg_build_static((propdlg)->dialog.d,(desc)); | |
577 | -#define PROPDLG_SHOW_STATIC(propdlg,desc) \ | |
578 | - if (!(propdlg)->dialog.ready) {\ | |
579 | - __PROPDLG_BUILD_STATIC((propdlg),(desc)); \ | |
580 | - } | |
581 | - | |
582 | -/* This simply puts a separator line. */ | |
583 | -void __propdlg_build_separator(GtkWidget *dialog); | |
584 | - | |
585 | -#define __PROPDLG_BUILD_SEPARATOR(propdlg) \ | |
586 | - __propdlg_build_separator((propdlg)->dialog.d); | |
587 | -#define PROPDLG_SHOW_SEPARATOR(propdlg) \ | |
588 | - if (!(propdlg)->dialog.ready) {\ | |
589 | - __PROPDLG_BUILD_SEPARATOR((propdlg)); \ | |
590 | - } | |
591 | - | |
592 | - | |
593 | -/* This embeds a sanity check. Shouldn't that made a simple, rude and | |
594 | - brutal g_assert( (probableparent) == (propdlg)->parent ); ? */ | |
595 | -#define PROPDLG_SANITY_CHECK(propdlg, probableparent) \ | |
596 | - if ( (probableparent) != (propdlg)->parent) { \ | |
597 | - message_warning("%s/%s dialog problem: %p != %p\n", \ | |
598 | - ((probableparent)?((Object *)(probableparent))->type->name:NULL), \ | |
599 | - ((propdlg)->parent?((Object *)((propdlg)->parent))->type->name:NULL), \ | |
600 | - (probableparent), (propdlg)->parent); \ | |
601 | - (probableparent) = (propdlg)->parent; \ | |
602 | - } | |
603 | - | |
604 | -/* State load/save/free macros. Most of the free macros are intentionally | |
605 | - blank. This whole thing assumes the fields have the same names in the | |
606 | - object and state structures. | |
607 | - | |
608 | - These macros are designed to make writing the three foo_*_state() as | |
609 | - fast as possible (using a lot of cut'n'paste). | |
610 | -*/ | |
611 | - | |
612 | -#define OBJECT_SET_INT(object,state,field) (object)->field = (state)->field; | |
613 | -#define OBJECT_GET_INT(object,state,field) (state)->field = (object)->field; | |
614 | -#define OBJECT_FREE_INT(state,field) | |
615 | -#define OBJECT_SET_REAL(object,state,field) (object)->field = (state)->field; | |
616 | -#define OBJECT_GET_REAL(object,state,field) (state)->field = (object)->field; | |
617 | -#define OBJECT_FREE_REAL(state,field) | |
618 | -#define OBJECT_SET_BOOL(object,state,field) (object)->field = (state)->field; | |
619 | -#define OBJECT_GET_BOOL(object,state,field) (state)->field = (object)->field; | |
620 | -#define OBJECT_FREE_BOOL(state,field) | |
621 | -#define OBJECT_SET_COLOR(object,state,field) (object)->field = (state)->field; | |
622 | -#define OBJECT_GET_COLOR(object,state,field) (state)->field = (object)->field; | |
623 | -#define OBJECT_FREE_COLOR(state,field) | |
624 | -#define OBJECT_SET_POINT(object,state,field) (object)->field = (state)->field; | |
625 | -#define OBJECT_GET_POINT(object,state,field) (state)->field = (object)->field; | |
626 | -#define OBJECT_FREE_POINT(state,field) | |
627 | -#define OBJECT_SET_RECT(object,state,field) (object)->field = (state)->field; | |
628 | -#define OBJECT_GET_RECT(object,state,field) (state)->field = (object)->field; | |
629 | -#define OBJECT_FREE_RECT(state,field) | |
630 | -#define OBJECT_SET_STRING(object,state,field) \ | |
631 | - if ((object)->field) g_free((object)->field); \ | |
632 | - (object)->field = (state)->field; | |
633 | -#define OBJECT_GET_STRING(object,state,field) \ | |
634 | - (state)->field = g_strdup((object)->field); | |
635 | -#define OBJECT_FREE_STRING(state,field) g_free((state)->field); | |
636 | -#define OBJECT_SET_MULTISTRING(object,state,field) \ | |
637 | - OBJECT_SET_STRING(object,state,field) | |
638 | -#define OBJECT_GET_MULTISTRING(object,state,field) \ | |
639 | - OBJECT_GET_STRING(object,state,field) | |
640 | -#define OBJECT_FREE_MULTISTRING(state,field) \ | |
641 | - OBJECT_FREE_STRING(state,field) | |
642 | -#define OBJECT_SET_FONT(object,state,field) (object)->field = (state)->field; | |
643 | -#define OBJECT_GET_FONT(object,state,field) (state)->field = (object)->field; | |
644 | -#define OBJECT_FREE_FONT(state,field) | |
645 | -#define OBJECT_SET_FONTHEIGHT(object,state,field) \ | |
646 | - (object)->field = (state)->field; | |
647 | -#define OBJECT_GET_FONTHEIGHT(object,state,field) \ | |
648 | - (state)->field = (object)->field; | |
649 | -#define OBJECT_FREE_FONTHEIGHT(state,field) | |
650 | -#define OBJECT_SET_TEXTATTR(object,state,field) \ | |
651 | - text_set_attributes((object)->field, &(state)->field##_attrib); | |
652 | -#define OBJECT_GET_TEXTATTR(object,state,field) \ | |
653 | - text_get_attributes((object)->field, &(state)->field##_attrib); | |
654 | -#define OBJECT_FREE_TEXTATTR(state,field); | |
655 | - | |
656 | -#endif /* __LAZYPROPS_H */ | |
657 | - | |
658 | - | |
659 | - | |
660 | - | |
661 | - | |
662 | - | |
663 | - | |
664 | - |
@@ -3,6 +3,7 @@ | ||
3 | 3 | * |
4 | 4 | * properties.h: property system for dia objects/shapes. |
5 | 5 | * Copyright (C) 2000 James Henstridge |
6 | + * Copyright (C) 2001 Cyrille Chepelov | |
6 | 7 | * |
7 | 8 | * This program is free software; you can redistribute it and/or modify |
8 | 9 | * it under the terms of the GNU General Public License as published by |
@@ -189,6 +190,11 @@ prop_copy(Property *dest, Property *src) | ||
189 | 190 | case PROP_TYPE_ENDPOINTS: |
190 | 191 | dest->d = src->d; |
191 | 192 | break; |
193 | + case PROP_TYPE_NOTEBOOK_BEGIN: | |
194 | + case PROP_TYPE_NOTEBOOK_END: | |
195 | + case PROP_TYPE_NOTEBOOK_PAGE: | |
196 | + break; | |
197 | + case PROP_TYPE_MULTISTRING: | |
192 | 198 | case PROP_TYPE_STRING: |
193 | 199 | case PROP_TYPE_FILE: |
194 | 200 | g_free(PROP_VALUE_STRING(*dest)); |
@@ -197,6 +203,8 @@ prop_copy(Property *dest, Property *src) | ||
197 | 203 | else |
198 | 204 | PROP_VALUE_STRING(*dest) = NULL; |
199 | 205 | break; |
206 | + case PROP_TYPE_STATIC: | |
207 | + break; | |
200 | 208 | case PROP_TYPE_POINTARRAY: |
201 | 209 | g_free(PROP_VALUE_POINTARRAY(*dest).pts); |
202 | 210 | PROP_VALUE_POINTARRAY(*dest).npts = PROP_VALUE_POINTARRAY(*src).npts; |
@@ -266,7 +274,13 @@ prop_free(Property *prop) | ||
266 | 274 | case PROP_TYPE_ENDPOINTS: |
267 | 275 | case PROP_TYPE_CONNPOINT_LINE: |
268 | 276 | case PROP_TYPE_FONT: |
277 | + case PROP_TYPE_STATIC: | |
269 | 278 | break; |
279 | + case PROP_TYPE_NOTEBOOK_BEGIN: | |
280 | + case PROP_TYPE_NOTEBOOK_END: | |
281 | + case PROP_TYPE_NOTEBOOK_PAGE: | |
282 | + break; | |
283 | + case PROP_TYPE_MULTISTRING: | |
270 | 284 | case PROP_TYPE_STRING: |
271 | 285 | case PROP_TYPE_FILE: |
272 | 286 | g_free(PROP_VALUE_STRING(*prop)); |
@@ -397,11 +411,32 @@ prop_get_widget(Property *prop) | ||
397 | 411 | ret = gtk_spin_button_new(adj, 1.0, 2); |
398 | 412 | gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(ret), TRUE); |
399 | 413 | break; |
414 | + case PROP_TYPE_NOTEBOOK_BEGIN: | |
415 | + case PROP_TYPE_NOTEBOOK_END: | |
416 | + case PROP_TYPE_NOTEBOOK_PAGE: | |
417 | + g_assert_not_reached(); | |
418 | + break; | |
400 | 419 | case PROP_TYPE_STRING: |
401 | 420 | ret = gtk_entry_new(); |
402 | 421 | if (PROP_VALUE_STRING(*prop)) |
403 | 422 | gtk_entry_set_text(GTK_ENTRY(ret), PROP_VALUE_STRING(*prop)); |
404 | 423 | break; |
424 | + case PROP_TYPE_MULTISTRING: { | |
425 | + GtkWidget *text; | |
426 | + /* ret = gtk_hbox_new(FALSE,GPOINTER_TO_INT(prop->extra_data)); */ | |
427 | + text = gtk_text_new(NULL,NULL); | |
428 | + gtk_text_set_editable(GTK_TEXT(text),TRUE); | |
429 | + /* gtk_box_pack_start(GTK_BOX(ret),text,TRUE,TRUE); */ | |
430 | + if (PROP_VALUE_STRING(*prop)) { | |
431 | + gtk_text_set_point(GTK_TEXT(text), 0); | |
432 | + gtk_text_forward_delete(GTK_TEXT(text), | |
433 | + gtk_text_get_length(GTK_TEXT(text))); | |
434 | + gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL, | |
435 | + PROP_VALUE_STRING(*prop),-1); | |
436 | + } | |
437 | + ret = text; | |
438 | + break; | |
439 | + } | |
405 | 440 | case PROP_TYPE_POINT: |
406 | 441 | case PROP_TYPE_POINTARRAY: |
407 | 442 | case PROP_TYPE_INTARRAY: |
@@ -414,6 +449,12 @@ prop_get_widget(Property *prop) | ||
414 | 449 | case PROP_TYPE_RECT: |
415 | 450 | ret = gtk_label_new(_("No edit widget")); |
416 | 451 | break; |
452 | + case PROP_TYPE_STATIC: | |
453 | + if (prop->descr) { | |
454 | + ret = gtk_label_new(prop->descr->tooltip); | |
455 | + gtk_label_set_justify(GTK_LABEL(ret),GTK_JUSTIFY_LEFT); | |
456 | + } | |
457 | + break; | |
417 | 458 | case PROP_TYPE_LINESTYLE: |
418 | 459 | ret = dia_line_style_selector_new(); |
419 | 460 | dia_line_style_selector_set_linestyle(DIALINESTYLESELECTOR(ret), |
@@ -481,10 +522,19 @@ prop_set_from_widget(Property *prop, GtkWidget *widget) | ||
481 | 522 | PROP_VALUE_REAL(*prop) = gtk_spin_button_get_value_as_float( |
482 | 523 | GTK_SPIN_BUTTON(widget)); |
483 | 524 | break; |
525 | + case PROP_TYPE_MULTISTRING: | |
526 | + g_free(PROP_VALUE_STRING(*prop)); | |
527 | + PROP_VALUE_STRING(*prop) = | |
528 | + gtk_editable_get_chars(GTK_EDITABLE(widget),0, -1); | |
529 | + break; | |
484 | 530 | case PROP_TYPE_STRING: |
485 | 531 | g_free(PROP_VALUE_STRING(*prop)); |
486 | 532 | PROP_VALUE_STRING(*prop) = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); |
487 | 533 | break; |
534 | + case PROP_TYPE_NOTEBOOK_BEGIN: | |
535 | + case PROP_TYPE_NOTEBOOK_END: | |
536 | + case PROP_TYPE_NOTEBOOK_PAGE: | |
537 | + case PROP_TYPE_STATIC: | |
488 | 538 | case PROP_TYPE_POINT: |
489 | 539 | case PROP_TYPE_POINTARRAY: |
490 | 540 | case PROP_TYPE_INTARRAY: |
@@ -598,10 +648,17 @@ prop_load(Property *prop, ObjectNode obj_node) | ||
598 | 648 | case PROP_TYPE_REAL: |
599 | 649 | PROP_VALUE_REAL(*prop) = data_real(data); |
600 | 650 | break; |
651 | + case PROP_TYPE_MULTISTRING: | |
601 | 652 | case PROP_TYPE_STRING: |
602 | 653 | g_free(PROP_VALUE_STRING(*prop)); |
603 | 654 | PROP_VALUE_STRING(*prop) = data_string(data); |
604 | 655 | break; |
656 | + case PROP_TYPE_NOTEBOOK_BEGIN: | |
657 | + case PROP_TYPE_NOTEBOOK_END: | |
658 | + case PROP_TYPE_NOTEBOOK_PAGE: | |
659 | + break; | |
660 | + case PROP_TYPE_STATIC: | |
661 | + break; | |
605 | 662 | case PROP_TYPE_POINT: |
606 | 663 | data_point(data, &PROP_VALUE_POINT(*prop)); |
607 | 664 | break; |
@@ -773,6 +830,13 @@ prop_save(Property *prop, ObjectNode obj_node) | ||
773 | 830 | case PROP_TYPE_REAL: |
774 | 831 | data_add_real(attr, PROP_VALUE_REAL(*prop)); |
775 | 832 | break; |
833 | + case PROP_TYPE_STATIC: | |
834 | + break; | |
835 | + case PROP_TYPE_NOTEBOOK_BEGIN: | |
836 | + case PROP_TYPE_NOTEBOOK_END: | |
837 | + case PROP_TYPE_NOTEBOOK_PAGE: | |
838 | + break; | |
839 | + case PROP_TYPE_MULTISTRING: | |
776 | 840 | case PROP_TYPE_STRING: |
777 | 841 | data_add_string(attr, PROP_VALUE_STRING(*prop)); |
778 | 842 | break; |
@@ -967,6 +1031,13 @@ object_get_props_from_offsets(Object *obj, PropOffset *offsets, | ||
967 | 1031 | PROP_VALUE_REAL(props[i]) = |
968 | 1032 | struct_member(obj, offsets[j].offset, real); |
969 | 1033 | break; |
1034 | + case PROP_TYPE_STATIC: | |
1035 | + break; | |
1036 | + case PROP_TYPE_NOTEBOOK_BEGIN: | |
1037 | + case PROP_TYPE_NOTEBOOK_END: | |
1038 | + case PROP_TYPE_NOTEBOOK_PAGE: | |
1039 | + break; | |
1040 | + case PROP_TYPE_MULTISTRING: | |
970 | 1041 | case PROP_TYPE_STRING: |
971 | 1042 | g_free(PROP_VALUE_STRING(props[i])); |
972 | 1043 | PROP_VALUE_STRING(props[i]) = |
@@ -1100,6 +1171,13 @@ object_set_props_from_offsets(Object *obj, PropOffset *offsets, | ||
1100 | 1171 | struct_member(obj, offsets[j].offset, real) = |
1101 | 1172 | PROP_VALUE_REAL(props[i]); |
1102 | 1173 | break; |
1174 | + case PROP_TYPE_STATIC: | |
1175 | + break; | |
1176 | + case PROP_TYPE_NOTEBOOK_BEGIN: | |
1177 | + case PROP_TYPE_NOTEBOOK_END: | |
1178 | + case PROP_TYPE_NOTEBOOK_PAGE: | |
1179 | + break; | |
1180 | + case PROP_TYPE_MULTISTRING: | |
1103 | 1181 | case PROP_TYPE_STRING: |
1104 | 1182 | g_free(struct_member(obj, offsets[j].offset, gchar *)); |
1105 | 1183 | struct_member(obj, offsets[j].offset, gchar *) = |
@@ -1207,6 +1285,8 @@ object_props_dialog_destroy(GtkWidget *table) | ||
1207 | 1285 | g_free(widgets); |
1208 | 1286 | } |
1209 | 1287 | |
1288 | +#define MAXNEST 7 | |
1289 | + | |
1210 | 1290 | GtkWidget * |
1211 | 1291 | object_create_props_dialog(Object *obj) |
1212 | 1292 | { |
@@ -1214,8 +1294,12 @@ object_create_props_dialog(Object *obj) | ||
1214 | 1294 | Property *props; |
1215 | 1295 | guint nprops = 0, i, j; |
1216 | 1296 | GtkWidget **widgets; |
1217 | - | |
1218 | 1297 | GtkWidget *table, *label; |
1298 | + GtkWidget *mainvbox; | |
1299 | + | |
1300 | + GtkWidget *curcontainer[MAXNEST]; | |
1301 | + int nestlev = -1; | |
1302 | + gboolean haspage = FALSE; | |
1219 | 1303 | |
1220 | 1304 | g_return_val_if_fail(obj->ops->describe_props != NULL, NULL); |
1221 | 1305 | g_return_val_if_fail(obj->ops->get_props != NULL, NULL); |
@@ -1237,41 +1321,89 @@ object_create_props_dialog(Object *obj) | ||
1237 | 1321 | props[j].name = pdesc[i].name; |
1238 | 1322 | props[j].type = pdesc[i].type; |
1239 | 1323 | props[j].extra_data = pdesc[i].extra_data; |
1324 | + props[j].descr = &pdesc[i]; | |
1240 | 1325 | j++; |
1241 | 1326 | } |
1242 | 1327 | obj->ops->get_props(obj, props, nprops); |
1243 | 1328 | |
1244 | - table = gtk_table_new(1, 2, FALSE); | |
1329 | + mainvbox = gtk_vbox_new(FALSE,1); | |
1330 | + table = NULL; | |
1331 | + curcontainer[++nestlev] = mainvbox; | |
1245 | 1332 | |
1246 | 1333 | /* construct the widgets table */ |
1247 | 1334 | for (i = 0, j = 0; pdesc[i].name != NULL; i++) |
1248 | 1335 | if ((pdesc[i].flags & PROP_FLAG_VISIBLE) != 0) { |
1249 | - widgets[j] = prop_get_widget(&props[j]); | |
1250 | - | |
1251 | - label = gtk_label_new(_(pdesc[i].description)); | |
1252 | - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | |
1253 | - gtk_table_attach(GTK_TABLE(table), label, 0,1, j,j+1, | |
1254 | - GTK_FILL, GTK_FILL|GTK_EXPAND, 0, 0); | |
1255 | - gtk_table_attach(GTK_TABLE(table), widgets[j], 1,2, j,j+1, | |
1256 | - GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 0, 0); | |
1257 | - | |
1258 | - gtk_widget_show(label); | |
1259 | - gtk_widget_show(widgets[j]); | |
1260 | - | |
1336 | + switch(props[j].type) { | |
1337 | + case PROP_TYPE_NOTEBOOK_BEGIN: | |
1338 | + { | |
1339 | + GtkWidget *notebook = gtk_notebook_new(); | |
1340 | + gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook),GTK_POS_TOP); | |
1341 | + gtk_container_set_border_width (GTK_CONTAINER(notebook), 0); | |
1342 | + gtk_widget_show(notebook); | |
1343 | + gtk_box_pack_end_defaults(GTK_BOX(curcontainer[nestlev]),notebook); | |
1344 | + curcontainer[++nestlev] = notebook; | |
1345 | + table = NULL; | |
1346 | + /* note: there must be at least one page, immediately after this. */ | |
1347 | + g_assert(nestlev < MAXNEST); | |
1348 | + } break; | |
1349 | + case PROP_TYPE_NOTEBOOK_END: | |
1350 | + { | |
1351 | + if (haspage) nestlev--; | |
1352 | + nestlev--; | |
1353 | + table = NULL; | |
1354 | + g_assert(nestlev >= 0); | |
1355 | + } break; | |
1356 | + case PROP_TYPE_NOTEBOOK_PAGE: | |
1357 | + { | |
1358 | + /* this >must< happen inside a notebook */ | |
1359 | + GtkWidget *page = gtk_vbox_new(FALSE,1); | |
1360 | + GtkWidget *pagelabel = gtk_label_new(pdesc[i].description); | |
1361 | + gtk_container_set_border_width(GTK_CONTAINER(page),1); | |
1362 | + gtk_widget_show_all(page); | |
1363 | + gtk_widget_show_all(pagelabel); | |
1364 | + if (haspage) nestlev--; | |
1365 | + gtk_notebook_append_page(GTK_NOTEBOOK(curcontainer[nestlev]), | |
1366 | + page,pagelabel); | |
1367 | + haspage = TRUE; | |
1368 | + curcontainer[++nestlev] = page; | |
1369 | + table = NULL; | |
1370 | + | |
1371 | + g_assert(nestlev < MAXNEST); | |
1372 | + } break; | |
1373 | + default: | |
1374 | + widgets[j] = prop_get_widget(&props[j]); | |
1375 | + | |
1376 | + label = gtk_label_new(_(pdesc[i].description)); | |
1377 | + gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | |
1378 | + | |
1379 | + if (!table) { | |
1380 | + table = gtk_table_new(1, 2, FALSE); | |
1381 | + gtk_widget_show(table); | |
1382 | + gtk_box_pack_end_defaults(GTK_BOX(curcontainer[nestlev]),table); | |
1383 | + } | |
1384 | + gtk_table_attach(GTK_TABLE(table), label, 0,1, j,j+1, | |
1385 | + GTK_FILL, GTK_FILL|GTK_EXPAND, 0, 0); | |
1386 | + gtk_table_attach(GTK_TABLE(table), widgets[j], 1,2, j,j+1, | |
1387 | + GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 0, 0); | |
1388 | + | |
1389 | + gtk_widget_show(label); | |
1390 | + gtk_widget_show(widgets[j]); | |
1391 | + break; | |
1392 | + } | |
1261 | 1393 | j++; |
1262 | 1394 | } |
1263 | 1395 | gtk_table_set_row_spacings(GTK_TABLE(table), 2); |
1264 | 1396 | gtk_table_set_col_spacings(GTK_TABLE(table), 5); |
1265 | 1397 | |
1266 | - gtk_object_set_data(GTK_OBJECT(table), prop_array_key, props); | |
1267 | - gtk_object_set_data(GTK_OBJECT(table), prop_num_key, | |
1398 | + gtk_object_set_data(GTK_OBJECT(mainvbox), prop_array_key, props); | |
1399 | + gtk_object_set_data(GTK_OBJECT(mainvbox), prop_num_key, | |
1268 | 1400 | GUINT_TO_POINTER(nprops)); |
1269 | - gtk_object_set_data(GTK_OBJECT(table), prop_widgets_key, widgets); | |
1401 | + gtk_object_set_data(GTK_OBJECT(mainvbox), prop_widgets_key, widgets); | |
1270 | 1402 | |
1271 | 1403 | gtk_signal_connect(GTK_OBJECT(table), "destroy", |
1272 | 1404 | GTK_SIGNAL_FUNC(object_props_dialog_destroy), NULL); |
1273 | 1405 | |
1274 | - return table; | |
1406 | + return mainvbox; | |
1275 | 1407 | } |
1276 | 1408 | |
1277 | 1409 | ObjectChange * |
@@ -3,6 +3,7 @@ | ||
3 | 3 | * |
4 | 4 | * properties.h: property system for dia objects/shapes. |
5 | 5 | * Copyright (C) 2000 James Henstridge |
6 | + * Copyright (C) 2001 Cyrille Chepelov | |
6 | 7 | * |
7 | 8 | * This program is free software; you can redistribute it and/or modify |
8 | 9 | * it under the terms of the GNU General Public License as published by |
@@ -54,6 +55,7 @@ typedef enum { | ||
54 | 55 | PROP_TYPE_ENUMARRAY, |
55 | 56 | PROP_TYPE_HANDLEARRAY, |
56 | 57 | PROP_TYPE_REAL, |
58 | + PROP_TYPE_MULTISTRING, /* same as _STRING but with (gint)extra_data lines */ | |
57 | 59 | PROP_TYPE_STRING, |
58 | 60 | PROP_TYPE_POINT, |
59 | 61 | PROP_TYPE_POINTARRAY, |
@@ -68,7 +70,10 @@ typedef enum { | ||
68 | 70 | PROP_TYPE_ENDPOINTS, |
69 | 71 | PROP_TYPE_CONNPOINT_LINE, |
70 | 72 | PROP_TYPE_TEXT, /* can't be visible */ |
71 | - | |
73 | + PROP_TYPE_STATIC, /* tooltip is used as a (potentially big) static label */ | |
74 | + PROP_TYPE_NOTEBOOK_BEGIN, | |
75 | + PROP_TYPE_NOTEBOOK_END, | |
76 | + PROP_TYPE_NOTEBOOK_PAGE, | |
72 | 77 | PROP_LAST |
73 | 78 | } PropType; |
74 | 79 |
@@ -97,6 +102,7 @@ struct _PropDescription { | ||
97 | 102 | struct _Property { |
98 | 103 | const gchar *name; |
99 | 104 | PropType type; |
105 | + const PropDescription *descr; | |
100 | 106 | gpointer extra_data; |
101 | 107 | union { |
102 | 108 | gchar char_data; |
@@ -455,7 +455,7 @@ action_destroy(Action *action) | ||
455 | 455 | connpointline_destroy(action->cps); |
456 | 456 | connection_destroy(&action->connection); |
457 | 457 | } |
458 | - | |
458 | + | |
459 | 459 | static Object * |
460 | 460 | action_load(ObjectNode obj_node, int version, const char *filename) |
461 | 461 | { |
@@ -549,7 +549,7 @@ step_load(ObjectNode obj_node, int version, const char *filename) | ||
549 | 549 | return object_load_using_properties(&step_type, |
550 | 550 | obj_node,version,filename); |
551 | 551 | } |
552 | - | |
552 | + | |
553 | 553 | |
554 | 554 | |
555 | 555 |
@@ -145,7 +145,7 @@ static PropDescription transition_props[] = { | ||
145 | 145 | N_("Color"),N_("The receptivity's color")}, |
146 | 146 | { "north_pos",PROP_TYPE_POINT,0,N_("North point"),NULL }, |
147 | 147 | { "south_pos",PROP_TYPE_POINT,0,N_("South point"),NULL }, |
148 | - PROP_DESC_END | |
148 | + PROP_DESC_END | |
149 | 149 | }; |
150 | 150 | |
151 | 151 | static PropDescription * |
@@ -43,7 +43,7 @@ | ||
43 | 43 | #include "message.h" |
44 | 44 | #include "connpoint_line.h" |
45 | 45 | #include "color.h" |
46 | -#include "lazyprops.h" | |
46 | +#include "properties.h" | |
47 | 47 | |
48 | 48 | #include "pixmaps/sadtbox.xpm" |
49 | 49 |
@@ -60,21 +60,8 @@ typedef enum { | ||
60 | 60 | ANCHOR_END |
61 | 61 | } AnchorShape; |
62 | 62 | |
63 | -typedef struct _Box Box; | |
64 | -typedef struct _BoxPropertiesDialog BoxPropertiesDialog; | |
65 | -typedef struct _BoxDefaultsDialog BoxDefaultsDialog; | |
66 | -typedef struct _BoxState BoxState; | |
67 | -typedef struct _BoxDefaults BoxDefaults; | |
68 | 63 | |
69 | -struct _BoxState { | |
70 | - ObjectState obj_state; | |
71 | - | |
72 | - real padding; | |
73 | - TextAttributes text_attrib; | |
74 | - gchar *id; | |
75 | -}; | |
76 | - | |
77 | -struct _Box { | |
64 | +typedef struct _Box { | |
78 | 65 | Element element; |
79 | 66 | |
80 | 67 | ConnPointLine *north,*south,*east,*west; |
@@ -82,40 +69,9 @@ struct _Box { | ||
82 | 69 | Text *text; |
83 | 70 | gchar *id; |
84 | 71 | real padding; |
85 | -}; | |
86 | - | |
87 | -struct _BoxPropertiesDialog { | |
88 | - AttributeDialog dialog; | |
89 | - Box *parent; | |
90 | - | |
91 | - RealAttribute padding; | |
92 | - TextFontAttribute text_font; | |
93 | - TextFontHeightAttribute text_fontheight; | |
94 | - TextColorAttribute text_color; | |
95 | - StringAttribute id; | |
96 | -}; | |
97 | - | |
98 | -struct _BoxDefaults { | |
99 | - Font *font; | |
100 | - real font_size; | |
101 | - Color fontcolor; | |
102 | - real padding; | |
103 | -}; | |
104 | 72 | |
105 | -struct _BoxDefaultsDialog { | |
106 | - AttributeDialog dialog; | |
107 | - BoxDefaults *parent; | |
108 | - | |
109 | - RealAttribute padding; | |
110 | - FontAttribute font; | |
111 | - FontHeightAttribute font_size; | |
112 | - ColorAttribute fontcolor; | |
113 | -}; | |
114 | - | |
115 | - | |
116 | -static BoxPropertiesDialog *sadtbox_properties_dialog; | |
117 | -static BoxDefaultsDialog *sadtbox_defaults_dialog; | |
118 | -static BoxDefaults default_properties; | |
73 | + TextAttributes attrs; | |
74 | +} Box; | |
119 | 75 | |
120 | 76 | static real sadtbox_distance_from(Box *box, Point *point); |
121 | 77 | static void sadtbox_select(Box *box, Point *clicked_point, |
@@ -131,27 +87,23 @@ static Object *sadtbox_create(Point *startpoint, | ||
131 | 87 | Handle **handle1, |
132 | 88 | Handle **handle2); |
133 | 89 | static void sadtbox_destroy(Box *box); |
134 | -static Object *sadtbox_copy(Box *box); | |
135 | -static PROPDLG_TYPE sadtbox_get_properties(Box *box); | |
136 | -static ObjectChange *sadtbox_apply_properties(Box *box); | |
137 | - | |
138 | -static BoxState *sadtbox_get_state(Box *box); | |
139 | -static void sadtbox_set_state(Box *box, BoxState *state); | |
140 | - | |
141 | -static void sadtbox_save(Box *box, ObjectNode obj_node, const char *filename); | |
142 | -static Object *sadtbox_load(ObjectNode obj_node, int version, const char *filename); | |
143 | -static PROPDLG_TYPE sadtbox_get_defaults(void); | |
144 | -static void sadtbox_apply_defaults(void); | |
145 | - | |
90 | +static Object *sadtbox_load(ObjectNode obj_node, int version, | |
91 | + const char *filename); | |
146 | 92 | static DiaMenu *sadtbox_get_object_menu(Box *box, Point *clickedpoint); |
147 | 93 | |
94 | +static PropDescription *sadtbox_describe_props(Box *box); | |
95 | +static void sadtbox_get_props(Box *box, | |
96 | + Property *props, guint nprops); | |
97 | +static void sadtbox_set_props(Box *box, | |
98 | + Property *props, guint nprops); | |
99 | + | |
148 | 100 | static ObjectTypeOps sadtbox_type_ops = |
149 | 101 | { |
150 | 102 | (CreateFunc) sadtbox_create, |
151 | - (LoadFunc) sadtbox_load, | |
152 | - (SaveFunc) sadtbox_save, | |
153 | - (GetDefaultsFunc) sadtbox_get_defaults, | |
154 | - (ApplyDefaultsFunc) sadtbox_apply_defaults | |
103 | + (LoadFunc) sadtbox_load/*using_properties*/, | |
104 | + (SaveFunc) object_save_using_properties, | |
105 | + (GetDefaultsFunc) NULL, | |
106 | + (ApplyDefaultsFunc) NULL, | |
155 | 107 | }; |
156 | 108 | |
157 | 109 | ObjectType sadtbox_type = |
@@ -168,94 +120,92 @@ static ObjectOps sadtbox_ops = { | ||
168 | 120 | (DrawFunc) sadtbox_draw, |
169 | 121 | (DistanceFunc) sadtbox_distance_from, |
170 | 122 | (SelectFunc) sadtbox_select, |
171 | - (CopyFunc) sadtbox_copy, | |
123 | + (CopyFunc) object_copy_using_properties, | |
172 | 124 | (MoveFunc) sadtbox_move, |
173 | 125 | (MoveHandleFunc) sadtbox_move_handle, |
174 | - (GetPropertiesFunc) sadtbox_get_properties, | |
175 | - (ApplyPropertiesFunc) sadtbox_apply_properties, | |
176 | - (ObjectMenuFunc) sadtbox_get_object_menu | |
126 | + (GetPropertiesFunc) object_create_props_dialog, | |
127 | + (ApplyPropertiesFunc) object_apply_props_from_dialog, | |
128 | + (ObjectMenuFunc) sadtbox_get_object_menu, | |
129 | + (DescribePropsFunc) sadtbox_describe_props, | |
130 | + (GetPropsFunc) sadtbox_get_props, | |
131 | + (SetPropsFunc) sadtbox_set_props | |
177 | 132 | }; |
178 | 133 | |
179 | -static ObjectChange * | |
180 | -sadtbox_apply_properties(Box *box) | |
181 | -{ | |
182 | - ObjectState *old_state; | |
183 | - BoxPropertiesDialog *dlg = sadtbox_properties_dialog; | |
184 | - | |
185 | - PROPDLG_SANITY_CHECK(dlg,box); | |
186 | - | |
187 | - old_state = (ObjectState *)sadtbox_get_state(box); | |
188 | - | |
189 | - PROPDLG_APPLY_REAL(dlg, padding); | |
190 | - PROPDLG_APPLY_TEXTFONT(dlg,text); | |
191 | - PROPDLG_APPLY_TEXTFONTHEIGHT(dlg,text); | |
192 | - PROPDLG_APPLY_TEXTCOLOR(dlg,text); | |
193 | - PROPDLG_APPLY_STRING(dlg,id); | |
194 | - | |
195 | - sadtbox_update_data(box, ANCHOR_MIDDLE, ANCHOR_MIDDLE); | |
196 | - return new_object_state_change(&box->element.object, | |
197 | - old_state, | |
198 | - (GetStateFunc)sadtbox_get_state, | |
199 | - (SetStateFunc)sadtbox_set_state); | |
200 | -} | |
134 | +static PropNumData text_padding_data = { 0.0, 10.0, 0.1 }; | |
135 | + | |
136 | +static PropDescription box_props[] = { | |
137 | + ELEMENT_COMMON_PROPERTIES, | |
138 | + { "padding",PROP_TYPE_REAL,PROP_FLAG_VISIBLE, | |
139 | + N_("Text padding"), NULL, &text_padding_data}, | |
140 | + { "text", PROP_TYPE_TEXT, 0,NULL,NULL}, | |
141 | + PROP_STD_TEXT_ALIGNMENT, | |
142 | + PROP_STD_TEXT_FONT, | |
143 | + PROP_STD_TEXT_HEIGHT, | |
144 | + PROP_STD_TEXT_COLOUR, | |
145 | + { "id", PROP_TYPE_STRING, PROP_FLAG_VISIBLE, | |
146 | + N_("Activity/Data identifier"), | |
147 | + N_("The identifier which appears in the lower right corner of the Box")}, | |
148 | + { "cpl_north",PROP_TYPE_CONNPOINT_LINE, 0, NULL, NULL}, | |
149 | + { "cpl_west",PROP_TYPE_CONNPOINT_LINE, 0, NULL, NULL}, | |
150 | + { "cpl_south",PROP_TYPE_CONNPOINT_LINE, 0, NULL, NULL}, | |
151 | + { "cpl_east",PROP_TYPE_CONNPOINT_LINE, 0, NULL, NULL}, | |
152 | + PROP_DESC_END | |
153 | +}; | |
201 | 154 | |
202 | -static PROPDLG_TYPE | |
203 | -sadtbox_get_properties(Box *box) | |
155 | +static PropDescription * | |
156 | +sadtbox_describe_props(Box *box) | |
204 | 157 | { |
205 | - BoxPropertiesDialog *dlg = sadtbox_properties_dialog; | |
206 | - | |
207 | - PROPDLG_CREATE(dlg,box); | |
208 | - | |
209 | - PROPDLG_SHOW_REAL(dlg,padding,_("Text padding:"),0.0,10.0,0.1); | |
210 | - PROPDLG_SHOW_TEXTFONT(dlg,text,_("Font:")); | |
211 | - PROPDLG_SHOW_TEXTFONTHEIGHT(dlg,text,_("Font size:")); | |
212 | - PROPDLG_SHOW_TEXTCOLOR(dlg,text,_("Font color:")); | |
213 | - PROPDLG_SHOW_STRING(dlg,id,_("Activity/Data identifier")); | |
214 | - | |
215 | - PROPDLG_READY(dlg); | |
216 | - sadtbox_properties_dialog = dlg; | |
158 | + if (box_props[0].quark == 0) { | |
159 | + prop_desc_list_calculate_quarks(box_props); | |
160 | + } | |
161 | + return box_props; | |
162 | +} | |
163 | + | |
164 | +static PropOffset box_offsets[] = { | |
165 | + ELEMENT_COMMON_PROPERTIES_OFFSETS, | |
166 | + { "padding",PROP_TYPE_REAL,offsetof(Box,padding)}, | |
167 | + { "text", PROP_TYPE_TEXT, offsetof(Box,text)}, | |
168 | + { "text_alignment",PROP_TYPE_ENUM,offsetof(Box,attrs.alignment)}, | |
169 | + { "text_font",PROP_TYPE_FONT,offsetof(Box,attrs.font)}, | |
170 | + { "text_height",PROP_TYPE_REAL,offsetof(Box,attrs.height)}, | |
171 | + { "text_color",PROP_TYPE_COLOUR,offsetof(Box,attrs.color)}, | |
172 | + { "id", PROP_TYPE_STRING, offsetof(Box,id)}, | |
173 | + { "cpl_north",PROP_TYPE_CONNPOINT_LINE, offsetof(Box,north)}, | |
174 | + { "cpl_west",PROP_TYPE_CONNPOINT_LINE, offsetof(Box,west)}, | |
175 | + { "cpl_south",PROP_TYPE_CONNPOINT_LINE, offsetof(Box,south)}, | |
176 | + { "cpl_east",PROP_TYPE_CONNPOINT_LINE, offsetof(Box,east)}, | |
177 | + {NULL} | |
178 | +}; | |
217 | 179 | |
218 | - PROPDLG_RETURN(dlg); | |
219 | -} | |
220 | 180 | static void |
221 | -sadtbox_apply_defaults(void) | |
222 | -{ | |
223 | - BoxDefaultsDialog *dlg = sadtbox_defaults_dialog; | |
224 | - | |
225 | - PROPDLG_APPLY_REAL(dlg,padding); | |
226 | - PROPDLG_APPLY_FONT(dlg,font); | |
227 | - PROPDLG_APPLY_FONTHEIGHT(dlg,font_size); | |
228 | - PROPDLG_APPLY_COLOR(dlg,fontcolor); | |
181 | +sadtbox_get_props(Box *box, Property *props, guint nprops) | |
182 | +{ | |
183 | + text_get_attributes(box->text,&box->attrs); | |
184 | + object_get_props_from_offsets(&box->element.object, | |
185 | + box_offsets,props,nprops); | |
229 | 186 | } |
230 | 187 | |
231 | 188 | static void |
232 | -init_default_values(void) { | |
233 | - static int defaults_initialized = 0; | |
234 | - | |
235 | - if (!defaults_initialized) { | |
236 | - default_properties.padding = 0.5; | |
237 | - default_properties.font = font_getfont("Helvetica-Bold"); | |
238 | - default_properties.font_size = 0.8; | |
239 | - default_properties.fontcolor = color_black; | |
240 | - defaults_initialized = 1; | |
189 | +sadtbox_set_props(Box *box, Property *props, guint nprops) | |
190 | +{ | |
191 | + int i; | |
192 | + Property *textprop = NULL; | |
193 | + | |
194 | + object_set_props_from_offsets(&box->element.object, | |
195 | + box_offsets,props,nprops); | |
196 | + for (i=0;i<nprops;i++) { | |
197 | + if (0 == strcmp(props[i].name,"text")) { | |
198 | + textprop = &props[i]; | |
199 | + break; | |
200 | + } | |
241 | 201 | } |
242 | -} | |
243 | 202 | |
244 | -static GtkWidget * | |
245 | -sadtbox_get_defaults(void) | |
246 | -{ | |
247 | - BoxDefaultsDialog *dlg = sadtbox_defaults_dialog; | |
248 | - | |
249 | - init_default_values(); | |
250 | - PROPDLG_CREATE(dlg, &default_properties); | |
251 | - PROPDLG_SHOW_REAL(dlg,padding,_("Text padding:"),0.0,10.0,0.1); | |
252 | - PROPDLG_SHOW_FONT(dlg,font,_("Font:")); | |
253 | - PROPDLG_SHOW_FONTHEIGHT(dlg,font_size,_("Font size:")); | |
254 | - PROPDLG_SHOW_COLOR(dlg,fontcolor,_("Font color:")); | |
255 | - PROPDLG_READY(dlg); | |
256 | - sadtbox_defaults_dialog = dlg; | |
257 | - | |
258 | - PROPDLG_RETURN(dlg); | |
203 | + if ((!textprop) || (!PROP_VALUE_TEXT(*textprop).enabled)) { | |
204 | + /* most likely we're called after the dialog box has been applied */ | |
205 | + text_set_attributes(box->text,&box->attrs); | |
206 | + } | |
207 | + | |
208 | + sadtbox_update_data(box, ANCHOR_MIDDLE, ANCHOR_MIDDLE); | |
259 | 209 | } |
260 | 210 | |
261 | 211 | static real |
@@ -369,41 +319,6 @@ sadtbox_draw(Box *box, Renderer *renderer) | ||
369 | 319 | } |
370 | 320 | |
371 | 321 | static void |
372 | -sadtbox_free_state(ObjectState *objstate) | |
373 | -{ | |
374 | - BoxState *state = (BoxState *)objstate; | |
375 | - g_free(state->id); | |
376 | - /* g_free(state); */ /* huh ?? NOT HERE !!! */ | |
377 | -} | |
378 | - | |
379 | -static BoxState * | |
380 | -sadtbox_get_state(Box *box) | |
381 | -{ | |
382 | - BoxState *state = g_new0(BoxState, 1); | |
383 | - | |
384 | - state->obj_state.free = sadtbox_free_state; | |
385 | - | |
386 | - state->id = g_strdup(box->id); | |
387 | - state->padding = box->padding; | |
388 | - text_get_attributes(box->text, &state->text_attrib); | |
389 | - | |
390 | - return state; | |
391 | -} | |
392 | - | |
393 | -static void | |
394 | -sadtbox_set_state(Box *box, BoxState *state) | |
395 | -{ | |
396 | - box->padding = state->padding; | |
397 | - text_set_attributes(box->text, &state->text_attrib); | |
398 | - if (box->id) g_free(box->id); | |
399 | - box->id = state->id; | |
400 | - g_free(state); | |
401 | - | |
402 | - sadtbox_update_data(box, ANCHOR_MIDDLE, ANCHOR_MIDDLE); | |
403 | -} | |
404 | - | |
405 | - | |
406 | -static void | |
407 | 322 | sadtbox_update_data(Box *box, AnchorShape horiz, AnchorShape vert) |
408 | 323 | { |
409 | 324 | Element *elem = &box->element; |
@@ -572,8 +487,6 @@ sadtbox_create(Point *startpoint, | ||
572 | 487 | Object *obj; |
573 | 488 | Point p; |
574 | 489 | |
575 | - init_default_values(); | |
576 | - | |
577 | 490 | box = g_malloc0(sizeof(Box)); |
578 | 491 | elem = &box->element; |
579 | 492 | obj = &elem->object; |
@@ -586,15 +499,21 @@ sadtbox_create(Point *startpoint, | ||
586 | 499 | elem->width = DEFAULT_WIDTH; |
587 | 500 | elem->height = DEFAULT_HEIGHT; |
588 | 501 | |
589 | - box->padding = default_properties.padding; | |
502 | + box->padding = 0.5; /* default_values.padding; */ | |
590 | 503 | |
591 | 504 | p = *startpoint; |
592 | 505 | p.x += elem->width / 2.0; |
593 | - p.y += elem->height / 2.0 + default_properties.font_size / 2; | |
594 | - box->text = new_text("", default_properties.font, | |
506 | + p.y += elem->height / 2.0 + /*default_properties.font_size*/ 0.8 / 2; | |
507 | + | |
508 | + /* box->text = new_text("", default_properties.font, | |
595 | 509 | default_properties.font_size, &p, |
596 | 510 | &SADTBOX_FG_COLOR, |
597 | 511 | ALIGN_CENTER); |
512 | + */ | |
513 | + box->text = new_text("", font_getfont("Helvetica-Bold"), | |
514 | + 0.8, &p, | |
515 | + &color_black, | |
516 | + ALIGN_CENTER); | |
598 | 517 | box->id = g_strdup("A0"); /* should be made better. |
599 | 518 | Automatic counting ? */ |
600 | 519 |
@@ -628,91 +547,16 @@ sadtbox_destroy(Box *box) | ||
628 | 547 | element_destroy(&box->element); |
629 | 548 | } |
630 | 549 | |
631 | -static Object * | |
632 | -sadtbox_copy(Box *box) | |
633 | -{ | |
634 | - Box *newbox; | |
635 | - Element *elem, *newelem; | |
636 | - Object *newobj; | |
637 | - int rcc; | |
638 | - | |
639 | - elem = &box->element; | |
640 | - | |
641 | - newbox = g_malloc0(sizeof(Box)); | |
642 | - newelem = &newbox->element; | |
643 | - newobj = &newelem->object; | |
644 | - | |
645 | - element_copy(elem, newelem); | |
646 | - rcc = 0; | |
647 | - newbox->north = connpointline_copy(newobj,box->north,&rcc); | |
648 | - newbox->west = connpointline_copy(newobj,box->west,&rcc); | |
649 | - newbox->south = connpointline_copy(newobj,box->south,&rcc); | |
650 | - newbox->east = connpointline_copy(newobj,box->east,&rcc); | |
651 | - g_assert(rcc == newobj->num_connections); | |
652 | - | |
653 | - newbox->id = g_strdup(box->id); | |
654 | - newbox->padding = box->padding; | |
655 | - newbox->text = text_copy(box->text); | |
656 | - | |
657 | - return &newbox->element.object; | |
658 | -} | |
659 | - | |
660 | - | |
661 | -static void | |
662 | -sadtbox_save(Box *box, ObjectNode obj_node, const char *filename) | |
663 | -{ | |
664 | - element_save(&box->element, obj_node); | |
665 | - | |
666 | - save_real(obj_node,"padding",box->padding); | |
667 | - save_text(obj_node,"text",box->text); | |
668 | - save_int(obj_node,"cpl_north",box->north->num_connections); | |
669 | - save_int(obj_node,"cpl_west",box->west->num_connections); | |
670 | - save_int(obj_node,"cpl_south",box->south->num_connections); | |
671 | - save_int(obj_node,"cpl_east",box->east->num_connections); | |
672 | - save_string(obj_node,"id",box->id); | |
673 | -} | |
674 | 550 | |
675 | 551 | static Object * |
676 | 552 | sadtbox_load(ObjectNode obj_node, int version, const char *filename) |
677 | 553 | { |
678 | - Box *box; | |
679 | - Element *elem; | |
680 | - Object *obj; | |
681 | - int realconncount; | |
682 | - Point p = {0.0,0.0}; | |
683 | - | |
684 | - box = g_malloc0(sizeof(Box)); | |
685 | - elem = &box->element; | |
686 | - obj = &elem->object; | |
687 | - | |
688 | - obj->type = &sadtbox_type; | |
689 | - obj->ops = &sadtbox_ops; | |
690 | - | |
691 | - element_load(elem, obj_node); | |
554 | + return object_load_using_properties(&sadtbox_type, | |
555 | + obj_node,version,filename); | |
556 | +} | |
692 | 557 | |
693 | - box->padding = load_real(obj_node,"padding",default_properties.padding); | |
694 | - box->text = load_text(obj_node,"text",NULL); | |
695 | - if (!box->text) | |
696 | - box->text = new_text("", default_properties.font, | |
697 | - default_properties.font_size, &p, | |
698 | - &SADTBOX_FG_COLOR, | |
699 | - ALIGN_CENTER); | |
700 | 558 | |
701 | - element_init(elem, 8, 0); | |
702 | - realconncount = 0; | |
703 | 559 | |
704 | - box->north = connpointline_load(obj,obj_node,"cpl_north",4,&realconncount); | |
705 | - box->west = connpointline_load(obj,obj_node,"cpl_west",3,&realconncount); | |
706 | - box->south = connpointline_load(obj,obj_node,"cpl_south",1,&realconncount); | |
707 | - box->east = connpointline_load(obj,obj_node,"cpl_east",3,&realconncount); | |
708 | 560 | |
709 | - box->id = load_string(obj_node,"id",NULL); | |
710 | - if (!box->id) box->id = g_strdup("A0"); | |
711 | - | |
712 | - box->element.extra_spacing.border_trans = SADTBOX_LINE_WIDTH/2.0; | |
713 | - sadtbox_update_data(box, ANCHOR_MIDDLE, ANCHOR_MIDDLE); | |
714 | - | |
715 | - return &box->element.object; | |
716 | -} | |
717 | 561 | |
718 | 562 |
@@ -2,7 +2,7 @@ | ||
2 | 2 | * Copyright (C) 1998 Alexander Larsson |
3 | 3 | * |
4 | 4 | * Chronogram objects support |
5 | - * Copyright (C) 2000 Cyrille Chepelov | |
5 | + * Copyright (C) 2000, 2001 Cyrille Chepelov | |
6 | 6 | * |
7 | 7 | * Ultimately forked from Flowchart toolbox -- objects for drawing flowcharts. |
8 | 8 | * Copyright (C) 1999 James Henstridge. |
@@ -43,7 +43,7 @@ | ||
43 | 43 | #include "message.h" |
44 | 44 | #include "connpoint_line.h" |
45 | 45 | #include "color.h" |
46 | -#include "lazyprops.h" | |
46 | +#include "properties.h" | |
47 | 47 | |
48 | 48 | #include "chronogram.h" |
49 | 49 | #include "chronoline_event.h" |
@@ -53,33 +53,7 @@ | ||
53 | 53 | #define DEFAULT_WIDTH 7.0 |
54 | 54 | #define DEFAULT_HEIGHT 5.0 |
55 | 55 | |
56 | -typedef struct _Chronoline Chronoline; | |
57 | -typedef struct _ChronolinePropertiesDialog ChronolinePropertiesDialog; | |
58 | -typedef struct _ChronolineDefaultsDialog ChronolineDefaultsDialog; | |
59 | -typedef struct _ChronolineState ChronolineState; | |
60 | -typedef struct _ChronolineDefaults ChronolineDefaults; | |
61 | - | |
62 | -struct _ChronolineState { | |
63 | - ObjectState obj_state; | |
64 | - | |
65 | - real main_lwidth; | |
66 | - Color color; | |
67 | - real start_time; | |
68 | - real end_time; | |
69 | - real data_lwidth; | |
70 | - Color data_color; | |
71 | - char *events; | |
72 | - char *name; | |
73 | - real rise_time; | |
74 | - real fall_time; | |
75 | - gboolean multibit; | |
76 | - | |
77 | - Font *font; | |
78 | - real font_size; | |
79 | - Color font_color; | |
80 | -}; | |
81 | - | |
82 | -struct _Chronoline { | |
56 | +typedef struct _Chronoline { | |
83 | 57 | Element element; |
84 | 58 | |
85 | 59 | real main_lwidth; |
@@ -97,105 +71,17 @@ struct _Chronoline { | ||
97 | 71 | real font_size; |
98 | 72 | Color font_color; |
99 | 73 | |
74 | + /* computed values : */ | |
100 | 75 | ConnPointLine *snap; /* not saved ; num_connections derived from |
101 | 76 | the event string. */ |
102 | 77 | CLEventList *evtlist; |
103 | 78 | |
104 | 79 | int checksum; |
105 | - /* computed values : */ | |
106 | 80 | real labelwidth; |
107 | 81 | real y_down,y_up; |
108 | 82 | Color gray, datagray; |
109 | -}; | |
110 | - | |
111 | -struct _ChronolinePropertiesDialog { | |
112 | - AttributeDialog dialog; | |
113 | - Chronoline *parent; | |
114 | - AttributeNotebook notebook; | |
115 | - | |
116 | - struct { | |
117 | - AttributePage dialog; | |
118 | - Chronoline *parent; | |
119 | - | |
120 | - MultiStringAttribute events; | |
121 | - StringAttribute name; | |
122 | - } *data_page; | |
123 | - struct { | |
124 | - AttributePage dialog; | |
125 | - Chronoline *parent; | |
126 | - | |
127 | - BoolAttribute multibit; | |
128 | - RealAttribute start_time; | |
129 | - RealAttribute end_time; | |
130 | - RealAttribute rise_time; | |
131 | - RealAttribute fall_time; | |
132 | - } *parameter_page; | |
133 | - struct { | |
134 | - AttributePage dialog; | |
135 | - Chronoline *parent; | |
136 | - | |
137 | - RealAttribute main_lwidth; | |
138 | - RealAttribute data_lwidth; | |
139 | - ColorAttribute data_color; | |
140 | - ColorAttribute color; | |
141 | - FontAttribute font; | |
142 | - FontHeightAttribute font_size; | |
143 | - ColorAttribute font_color; | |
144 | - } *aspect_page; | |
145 | -}; | |
146 | - | |
147 | -struct _ChronolineDefaults { | |
148 | - char *name; /* not edited */ | |
149 | - char *events; /* not edited */ | |
150 | - | |
151 | - real main_lwidth; | |
152 | - real data_lwidth; | |
153 | - Color color; | |
154 | - Color data_color; | |
155 | - | |
156 | - real start_time; | |
157 | - real end_time; | |
158 | - real rise_time; | |
159 | - real fall_time; | |
160 | - gboolean multibit; | |
161 | - | |
162 | - Font *font; | |
163 | - real font_size; | |
164 | - Color font_color; | |
165 | -}; | |
166 | - | |
167 | -struct _ChronolineDefaultsDialog { | |
168 | - AttributeDialog dialog; | |
169 | - ChronolineDefaults *parent; | |
170 | - AttributeNotebook notebook; | |
171 | - | |
172 | - struct { | |
173 | - AttributePage dialog; | |
174 | - ChronolineDefaults *parent; | |
175 | - | |
176 | - BoolAttribute multibit; | |
177 | - RealAttribute start_time; | |
178 | - RealAttribute end_time; | |
179 | - RealAttribute rise_time; | |
180 | - RealAttribute fall_time; | |
181 | - } *parameter_page; | |
182 | - struct { | |
183 | - AttributePage dialog; | |
184 | - ChronolineDefaults *parent; | |
185 | - | |
186 | - RealAttribute main_lwidth; | |
187 | - RealAttribute data_lwidth; | |
188 | - ColorAttribute data_color; | |
189 | - ColorAttribute color; | |
190 | - FontAttribute font; | |
191 | - FontHeightAttribute font_size; | |
192 | - ColorAttribute font_color; | |
193 | - } *aspect_page; | |
194 | -}; | |
83 | +} Chronoline; | |
195 | 84 | |
196 | -static ChronolinePropertiesDialog *chronoline_properties_dialog; | |
197 | -static ChronolineDefaultsDialog *chronoline_defaults_dialog; | |
198 | -static ChronolineDefaults defaults; | |
199 | 85 | |
200 | 86 | static real chronoline_distance_from(Chronoline *chronoline, Point *point); |
201 | 87 | static void chronoline_select(Chronoline *chronoline, Point *clicked_point, |
@@ -211,28 +97,21 @@ static Object *chronoline_create(Point *startpoint, | ||
211 | 97 | Handle **handle1, |
212 | 98 | Handle **handle2); |
213 | 99 | static void chronoline_destroy(Chronoline *chronoline); |
214 | -static Object *chronoline_copy(Chronoline *chronoline); | |
215 | -static PROPDLG_TYPE chronoline_get_properties(Chronoline *chronoline); | |
216 | -static ObjectChange *chronoline_apply_properties(Chronoline *chronoline); | |
217 | - | |
218 | -static ChronolineState *chronoline_get_state(Chronoline *chronoline); | |
219 | -static void chronoline_set_state(Chronoline *chronoline, ChronolineState *state); | |
220 | - | |
221 | -static void chronoline_save(Chronoline *chronoline, ObjectNode obj_node, const char *filename); | |
222 | -static Object *chronoline_load(ObjectNode obj_node, int version, const char *filename); | |
223 | -static PROPDLG_TYPE chronoline_get_defaults(void); | |
224 | -static void chronoline_apply_defaults(void); | |
225 | -static void chronoline_free_state(ObjectState *objstate); | |
226 | - | |
227 | -/*static DiaMenu *chronoline_get_object_menu(Chronoline *chronoline, Point *clickedpoint); */ | |
100 | +static Object *chronoline_load(ObjectNode obj_node, int version, | |
101 | + const char *filename); | |
102 | +static PropDescription *chronoline_describe_props(Chronoline *chronoline); | |
103 | +static void chronoline_get_props(Chronoline *chronoline, | |
104 | + Property *props, guint nprops); | |
105 | +static void chronoline_set_props(Chronoline *chronoline, | |
106 | + Property *props, guint nprops); | |
228 | 107 | |
229 | 108 | static ObjectTypeOps chronoline_type_ops = |
230 | 109 | { |
231 | 110 | (CreateFunc) chronoline_create, |
232 | - (LoadFunc) chronoline_load, | |
233 | - (SaveFunc) chronoline_save, | |
234 | - (GetDefaultsFunc) chronoline_get_defaults, | |
235 | - (ApplyDefaultsFunc) chronoline_apply_defaults | |
111 | + (LoadFunc) chronoline_load/*using properties*/, | |
112 | + (SaveFunc) object_save_using_properties, | |
113 | + (GetDefaultsFunc) NULL, | |
114 | + (ApplyDefaultsFunc) NULL | |
236 | 115 | }; |
237 | 116 | |
238 | 117 | ObjectType chronoline_type = |
@@ -249,195 +128,125 @@ static ObjectOps chronoline_ops = { | ||
249 | 128 | (DrawFunc) chronoline_draw, |
250 | 129 | (DistanceFunc) chronoline_distance_from, |
251 | 130 | (SelectFunc) chronoline_select, |
252 | - (CopyFunc) chronoline_copy, | |
131 | + (CopyFunc) object_copy_using_properties, | |
253 | 132 | (MoveFunc) chronoline_move, |
254 | 133 | (MoveHandleFunc) chronoline_move_handle, |
255 | - (GetPropertiesFunc) chronoline_get_properties, | |
256 | - (ApplyPropertiesFunc) chronoline_apply_properties, | |
134 | + (GetPropertiesFunc) object_create_props_dialog, | |
135 | + (ApplyPropertiesFunc) object_apply_props_from_dialog, | |
257 | 136 | (ObjectMenuFunc) NULL, |
137 | + (DescribePropsFunc) chronoline_describe_props, | |
138 | + (GetPropsFunc) chronoline_get_props, | |
139 | + (SetPropsFunc) chronoline_set_props | |
258 | 140 | }; |
259 | 141 | |
260 | -static ObjectChange * | |
261 | -chronoline_apply_properties(Chronoline *chronoline) | |
262 | -{ | |
263 | - ObjectState *old_state; | |
264 | - ChronolinePropertiesDialog *dlg = chronoline_properties_dialog; | |
265 | - | |
266 | - PROPDLG_SANITY_CHECK(dlg,chronoline); | |
267 | - | |
268 | - old_state = (ObjectState *)chronoline_get_state(chronoline); | |
269 | - | |
270 | - PROPDLG_APPLY_STRING(dlg->data_page,name); | |
271 | - PROPDLG_APPLY_MULTISTRING(dlg->data_page,events); | |
272 | - | |
273 | - PROPDLG_APPLY_REAL(dlg->parameter_page,start_time); | |
274 | - PROPDLG_APPLY_REAL(dlg->parameter_page,end_time); | |
275 | - | |
276 | - PROPDLG_APPLY_REAL(dlg->parameter_page,rise_time); | |
277 | - PROPDLG_APPLY_REAL(dlg->parameter_page,fall_time); | |
278 | - | |
279 | - PROPDLG_APPLY_BOOL(dlg->parameter_page,multibit); | |
280 | - | |
281 | - PROPDLG_APPLY_REAL(dlg->aspect_page,data_lwidth); | |
282 | - PROPDLG_APPLY_COLOR(dlg->aspect_page,data_color); | |
283 | - PROPDLG_APPLY_REAL(dlg->aspect_page,main_lwidth); | |
284 | - PROPDLG_APPLY_COLOR(dlg->aspect_page,color); | |
285 | - | |
286 | - PROPDLG_APPLY_FONT(dlg->aspect_page,font); | |
287 | - PROPDLG_APPLY_FONTHEIGHT(dlg->aspect_page,font_size); | |
288 | - PROPDLG_APPLY_COLOR(dlg->aspect_page,font_color); | |
289 | - | |
290 | - /* time_lstep should probably be a multiplier of time_step, but the user | |
291 | - is sovereign. */ | |
292 | - chronoline_update_data(chronoline); | |
293 | - | |
294 | - return new_object_state_change(&chronoline->element.object, | |
295 | - old_state, | |
296 | - (GetStateFunc)chronoline_get_state, | |
297 | - (SetStateFunc)chronoline_set_state); | |
298 | -} | |
299 | - | |
300 | -static PROPDLG_TYPE | |
301 | -chronoline_get_properties(Chronoline *chronoline) | |
302 | -{ | |
303 | - ChronolinePropertiesDialog *dlg = chronoline_properties_dialog; | |
304 | - | |
305 | - PROPDLG_CREATE(dlg,chronoline); | |
306 | - PROPDLG_NOTEBOOK_CREATE(dlg,notebook); | |
307 | - PROPDLG_PAGE_CREATE(dlg,notebook,aspect_page,_("Aspect")); | |
308 | - PROPDLG_PAGE_CREATE(dlg,notebook,parameter_page,_("Parameters")); | |
309 | - PROPDLG_PAGE_CREATE(dlg,notebook,data_page,_("Data")); | |
310 | - | |
311 | - PROPDLG_SHOW_STRING(dlg->data_page,name,_("Data name:")); | |
312 | - PROPDLG_SHOW_SEPARATOR(dlg->data_page); | |
313 | - PROPDLG_SHOW_MULTISTRING(dlg->data_page,events,_("Events:"),5); | |
314 | - PROPDLG_SHOW_STATIC(dlg->data_page,_("Event specification:\n" | |
142 | +static PropNumData time_range = { -32767.0, 32768.0, 0.1}; | |
143 | +static PropNumData edge_range = { 0.0, 1000.0, 0.1}; | |
144 | + | |
145 | +static PropDescription chronoline_props[] = { | |
146 | + ELEMENT_COMMON_PROPERTIES, | |
147 | + { "nbook", PROP_TYPE_NOTEBOOK_BEGIN, | |
148 | + PROP_FLAG_VISIBLE|PROP_FLAG_DONT_SAVE, NULL, NULL}, | |
149 | + { "data", PROP_TYPE_NOTEBOOK_PAGE, | |
150 | + PROP_FLAG_VISIBLE|PROP_FLAG_DONT_SAVE, | |
151 | + N_("Data"), NULL}, | |
152 | + { "name", PROP_TYPE_STRING,PROP_FLAG_VISIBLE,N_("Data name"),NULL }, | |
153 | + { "events", PROP_TYPE_MULTISTRING,PROP_FLAG_VISIBLE,N_("Events"), | |
154 | + NULL,GINT_TO_POINTER(5) }, | |
155 | + { "help", PROP_TYPE_STATIC,PROP_FLAG_VISIBLE|PROP_FLAG_DONT_SAVE, | |
156 | + N_("Event specification"),N_( | |
315 | 157 | "@ time set the pointer at an absolute time.\n" |
316 | 158 | "( duration sets the signal up, then wait 'duration'.\n" |
317 | 159 | ") duration sets the signal down, then wait 'duration'.\n" |
318 | 160 | "u duration sets the signal to \"unknown\" state, then wait 'duration'.\n" |
319 | - "example : @ 1.0 (2.0)1.0(2.0)\n" )); | |
320 | - | |
321 | - PROPDLG_SHOW_REAL(dlg->parameter_page,start_time, | |
322 | - _("Start time:"),-32767.0,32768.0,0.1); | |
323 | - PROPDLG_SHOW_REAL(dlg->parameter_page,end_time, | |
324 | - _("End time:"),-32767.0,32768.0,0.1); | |
325 | - PROPDLG_SHOW_REAL(dlg->parameter_page,rise_time, | |
326 | - _("Rise time:"),0.0,1000.0,.1); | |
327 | - PROPDLG_SHOW_REAL(dlg->parameter_page,fall_time, | |
328 | - _("Fall time:"),0.0,1000.0,.1); | |
329 | - PROPDLG_SHOW_BOOL(dlg->parameter_page,multibit, | |
330 | - _("Multi-bit data")); | |
331 | - | |
332 | - PROPDLG_SHOW_COLOR(dlg->aspect_page,data_color,_("Data color:")); | |
333 | - PROPDLG_SHOW_REAL(dlg->aspect_page,data_lwidth, | |
334 | - _("Data line width:"),0.0,10.0,0.1); | |
335 | - PROPDLG_SHOW_COLOR(dlg->aspect_page,color,_("Line color:")); | |
336 | - PROPDLG_SHOW_REAL(dlg->aspect_page,main_lwidth, | |
337 | - _("Line width:"),0.0,10.0,0.1); | |
338 | - PROPDLG_SHOW_FONT(dlg->aspect_page,font,_("Font:")); | |
339 | - PROPDLG_SHOW_FONTHEIGHT(dlg->aspect_page,font_size,_("Font size:")); | |
340 | - PROPDLG_SHOW_COLOR(dlg->aspect_page,font_color,_("Font color:")); | |
341 | - | |
342 | - PROPDLG_PAGE_READY(dlg,notebook,data_page); | |
343 | - PROPDLG_PAGE_READY(dlg,notebook,parameter_page); | |
344 | - PROPDLG_PAGE_READY(dlg,notebook,aspect_page); | |
345 | - PROPDLG_NOTEBOOK_READY(dlg,notebook); | |
346 | - | |
347 | - PROPDLG_READY(dlg); | |
348 | - chronoline_properties_dialog = dlg; | |
349 | - | |
350 | - PROPDLG_RETURN(dlg); | |
351 | -} | |
352 | -static void | |
353 | -chronoline_apply_defaults(void) | |
354 | -{ | |
355 | - ChronolineDefaultsDialog *dlg = chronoline_defaults_dialog; | |
356 | - | |
357 | - PROPDLG_APPLY_REAL(dlg->parameter_page,start_time); | |
358 | - PROPDLG_APPLY_REAL(dlg->parameter_page,end_time); | |
359 | - | |
360 | - PROPDLG_APPLY_REAL(dlg->parameter_page,rise_time); | |
361 | - PROPDLG_APPLY_REAL(dlg->parameter_page,fall_time); | |
362 | - | |
363 | - PROPDLG_APPLY_BOOL(dlg->parameter_page,multibit); | |
364 | - | |
365 | - PROPDLG_APPLY_REAL(dlg->aspect_page,data_lwidth); | |
366 | - PROPDLG_APPLY_COLOR(dlg->aspect_page,data_color); | |
367 | - PROPDLG_APPLY_REAL(dlg->aspect_page,main_lwidth); | |
368 | - PROPDLG_APPLY_COLOR(dlg->aspect_page,color); | |
161 | + "example : @ 1.0 (2.0)1.0(2.0)\n" )}, | |
162 | + | |
163 | + { "parameters",PROP_TYPE_NOTEBOOK_PAGE, | |
164 | + PROP_FLAG_VISIBLE|PROP_FLAG_DONT_SAVE, | |
165 | + N_("Parameters"), NULL}, | |
166 | + { "start_time",PROP_TYPE_REAL,PROP_FLAG_VISIBLE, | |
167 | + N_("Start time"),NULL,&time_range}, | |
168 | + { "end_time",PROP_TYPE_REAL,PROP_FLAG_VISIBLE, | |
169 | + N_("End time"),NULL,&time_range}, | |
170 | + { "rise_time",PROP_TYPE_REAL,PROP_FLAG_VISIBLE, | |
171 | + N_("Rise time"),NULL,&edge_range}, | |
172 | + { "fall_time",PROP_TYPE_REAL,PROP_FLAG_VISIBLE, | |
173 | + N_("Fall time"),NULL,&edge_range}, | |
174 | + { "multibit",PROP_TYPE_BOOL,PROP_FLAG_VISIBLE, N_("Multi-bit data"),NULL}, | |
175 | + | |
176 | + { "aspect",PROP_TYPE_NOTEBOOK_PAGE, | |
177 | + PROP_FLAG_VISIBLE|PROP_FLAG_DONT_SAVE, | |
178 | + N_("Aspect"), NULL}, | |
179 | + { "data_color", PROP_TYPE_COLOUR, PROP_FLAG_VISIBLE, | |
180 | + N_("Data color"),NULL}, | |
181 | + { "data_lwidth", PROP_TYPE_REAL, PROP_FLAG_VISIBLE, | |
182 | + N_("Data line width"),NULL, &prop_std_line_width_data}, | |
183 | + { "color", PROP_TYPE_COLOUR, PROP_FLAG_VISIBLE, | |
184 | + N_("Line color"),NULL}, | |
185 | + { "main_lwidth", PROP_TYPE_REAL, PROP_FLAG_VISIBLE, | |
186 | + N_("Line width"),NULL, &prop_std_line_width_data}, | |
187 | + | |
188 | + { "font", PROP_TYPE_FONT, PROP_FLAG_VISIBLE, N_("Font"), NULL, NULL }, | |
189 | + { "font_size", PROP_TYPE_REAL, PROP_FLAG_VISIBLE, | |
190 | + N_("Font size"), NULL, &prop_std_text_height_data }, | |
191 | + { "font_color", PROP_TYPE_COLOUR, PROP_FLAG_VISIBLE, | |
192 | + N_("Text colour"), NULL, NULL }, | |
193 | + | |
194 | + { "nbook_end", PROP_TYPE_NOTEBOOK_END, | |
195 | + PROP_FLAG_VISIBLE|PROP_FLAG_DONT_SAVE, NULL, NULL}, | |
196 | + {NULL} | |
197 | +}; | |
369 | 198 | |
370 | - PROPDLG_APPLY_FONT(dlg->aspect_page,font); | |
371 | - PROPDLG_APPLY_FONTHEIGHT(dlg->aspect_page,font_size); | |
372 | - PROPDLG_APPLY_COLOR(dlg->aspect_page,font_color); | |
373 | -} | |
199 | +static PropDescription * | |
200 | +chronoline_describe_props(Chronoline *chronoline) | |
201 | +{ | |
202 | + if (chronoline_props[0].quark == 0) { | |
203 | + prop_desc_list_calculate_quarks(chronoline_props); | |
204 | + } | |
205 | + return chronoline_props; | |
206 | +} | |
207 | + | |
208 | +static PropOffset chronoline_offsets[] = { | |
209 | + ELEMENT_COMMON_PROPERTIES_OFFSETS, | |
210 | + { "nbook", PROP_TYPE_NOTEBOOK_BEGIN, 0}, | |
211 | + | |
212 | + { "data", PROP_TYPE_NOTEBOOK_PAGE, 0}, | |
213 | + { "name", PROP_TYPE_STRING, offsetof(Chronoline,name)}, | |
214 | + { "events", PROP_TYPE_MULTISTRING, offsetof(Chronoline,events)}, | |
215 | + { "help", PROP_TYPE_STATIC, 0}, | |
216 | + | |
217 | + { "parameters",PROP_TYPE_NOTEBOOK_PAGE, 0}, | |
218 | + { "start_time",PROP_TYPE_REAL, offsetof(Chronoline,start_time)}, | |
219 | + { "end_time",PROP_TYPE_REAL, offsetof(Chronoline,end_time)}, | |
220 | + { "rise_time",PROP_TYPE_REAL, offsetof(Chronoline,rise_time)}, | |
221 | + { "fall_time",PROP_TYPE_REAL, offsetof(Chronoline,fall_time)}, | |
222 | + { "multibit",PROP_TYPE_BOOL, offsetof(Chronoline,multibit)}, | |
223 | + | |
224 | + { "aspect",PROP_TYPE_NOTEBOOK_PAGE,0}, | |
225 | + { "data_color", PROP_TYPE_COLOUR, offsetof(Chronoline,data_color)}, | |
226 | + { "data_lwidth", PROP_TYPE_REAL, offsetof(Chronoline,data_lwidth)}, | |
227 | + { "color", PROP_TYPE_COLOUR, offsetof(Chronoline,color)}, | |
228 | + { "main_lwidth", PROP_TYPE_REAL, offsetof(Chronoline,main_lwidth)}, | |
229 | + { "font", PROP_TYPE_FONT, offsetof(Chronoline,font)}, | |
230 | + { "font_size", PROP_TYPE_REAL, offsetof(Chronoline,font_size)}, | |
231 | + { "font_color", PROP_TYPE_COLOUR, offsetof(Chronoline,font_color)}, | |
232 | + | |
233 | + { "nbook_end", PROP_TYPE_NOTEBOOK_END, 0}, | |
234 | + {NULL} | |
235 | +}; | |
374 | 236 | |
375 | 237 | static void |
376 | -chronoline_init_defaults(void) { | |
377 | - static int defaults_initialized = 0; | |
378 | - | |
379 | - if (!defaults_initialized) { | |
380 | - defaults.name = ""; | |
381 | - defaults.events = ""; | |
382 | - | |
383 | - defaults.font = font_getfont("Helvetica"); | |
384 | - defaults.font_size = 1.0; | |
385 | - defaults.font_color = color_black; | |
386 | - defaults.start_time = 0.0; | |
387 | - defaults.end_time = 20.0; | |
388 | - defaults.rise_time = .3; | |
389 | - defaults.fall_time = .3; | |
390 | - defaults.color = color_black; | |
391 | - defaults.main_lwidth = .1; | |
392 | - defaults.data_lwidth = .1; | |
393 | - defaults.data_color.red = 1.0; | |
394 | - defaults.data_color.green = 0.0; | |
395 | - defaults.data_color.blue = 0.0; | |
396 | - defaults.multibit = FALSE; | |
397 | - | |
398 | - defaults_initialized = 1; | |
399 | - } | |
238 | +chronoline_get_props(Chronoline *chronoline, Property *props, guint nprops) | |
239 | +{ | |
240 | + object_get_props_from_offsets(&chronoline->element.object, | |
241 | + chronoline_offsets,props,nprops); | |
400 | 242 | } |
401 | 243 | |
402 | -static GtkWidget * | |
403 | -chronoline_get_defaults(void) | |
244 | +static void | |
245 | +chronoline_set_props(Chronoline *chronoline, Property *props, guint nprops) | |
404 | 246 | { |
405 | - ChronolineDefaultsDialog *dlg = chronoline_defaults_dialog; | |
406 | - | |
407 | - chronoline_init_defaults(); | |
408 | - PROPDLG_CREATE(dlg, &defaults); | |
409 | - PROPDLG_NOTEBOOK_CREATE(dlg,notebook); | |
410 | - PROPDLG_PAGE_CREATE(dlg,notebook,aspect_page,_("Aspect")); | |
411 | - PROPDLG_PAGE_CREATE(dlg,notebook,parameter_page,_("Parameters")); | |
412 | - | |
413 | - PROPDLG_SHOW_REAL(dlg->parameter_page,start_time,_("Start time:"), | |
414 | - -32767.0,32768.0,0.1); | |
415 | - PROPDLG_SHOW_REAL(dlg->parameter_page,end_time,_("End time:"), | |
416 | - -32767.0,32768.0,0.1); | |
417 | - PROPDLG_SHOW_REAL(dlg->parameter_page,rise_time,_("Rise time:"), | |
418 | - 0.0,1000.0,.1); | |
419 | - PROPDLG_SHOW_REAL(dlg->parameter_page,fall_time,_("Fall time:"), | |
420 | - 0.0,1000.0,.1); | |
421 | - PROPDLG_SHOW_BOOL(dlg->parameter_page,multibit,_("Multi-bit data")); | |
422 | - | |
423 | - | |
424 | - PROPDLG_SHOW_COLOR(dlg->aspect_page,data_color,_("Data color:")); | |
425 | - PROPDLG_SHOW_REAL(dlg->aspect_page,data_lwidth,_("Data line width:"), | |
426 | - 0.0,10.0,0.1); | |
427 | - PROPDLG_SHOW_COLOR(dlg->aspect_page,color,_("Line color:")); | |
428 | - PROPDLG_SHOW_REAL(dlg->aspect_page,main_lwidth,_("Line width:"), | |
429 | - 0.0,10.0,0.1); | |
430 | - PROPDLG_SHOW_FONT(dlg->aspect_page,font,_("Font:")); | |
431 | - PROPDLG_SHOW_FONTHEIGHT(dlg->aspect_page,font_size,_("Font size:")); | |
432 | - PROPDLG_SHOW_COLOR(dlg->aspect_page,font_color,_("Font color:")); | |
433 | - | |
434 | - PROPDLG_PAGE_READY(dlg,notebook,parameter_page); | |
435 | - PROPDLG_PAGE_READY(dlg,notebook,aspect_page); | |
436 | - PROPDLG_NOTEBOOK_READY(dlg,notebook); | |
437 | - PROPDLG_READY(dlg); | |
438 | - chronoline_defaults_dialog = dlg; | |
439 | - | |
440 | - PROPDLG_RETURN(dlg); | |
247 | + object_set_props_from_offsets(&chronoline->element.object, | |
248 | + chronoline_offsets,props,nprops); | |
249 | + chronoline_update_data(chronoline); | |
441 | 250 | } |
442 | 251 | |
443 | 252 | static real |
@@ -658,89 +467,6 @@ chronoline_draw(Chronoline *chronoline, Renderer *renderer) | ||
658 | 467 | &chronoline->color); |
659 | 468 | } |
660 | 469 | |
661 | -static void | |
662 | -chronoline_free_state(ObjectState *objstate) | |
663 | -{ | |
664 | - ChronolineState *state G_GNUC_UNUSED= (ChronolineState *)objstate; | |
665 | - | |
666 | - OBJECT_FREE_STRING(state,name); | |
667 | - OBJECT_FREE_STRING(state,events); | |
668 | - | |
669 | - OBJECT_FREE_REAL(state,start_time); | |
670 | - OBJECT_FREE_REAL(state,end_time); | |
671 | - | |
672 | - OBJECT_FREE_REAL(state,rise_time); | |
673 | - OBJECT_FREE_REAL(state,fall_time); | |
674 | - | |
675 | - OBJECT_FREE_BOOL(state,multibit); | |
676 | - | |
677 | - OBJECT_FREE_REAL(state,data_lwidth); | |
678 | - OBJECT_FREE_COLOR(state,data_color); | |
679 | - OBJECT_FREE_REAL(state,main_lwidth); | |
680 | - OBJECT_FREE_COLOR(state,color); | |
681 | - | |
682 | - OBJECT_FREE_FONT(state,font); | |
683 | - OBJECT_FREE_FONTHEIGHT(state,font_size); | |
684 | - OBJECT_FREE_COLOR(state,font_color); | |
685 | -} | |
686 | - | |
687 | -static ChronolineState * | |
688 | -chronoline_get_state(Chronoline *chronoline) | |
689 | -{ | |
690 | - ChronolineState *state = g_new0(ChronolineState, 1); | |
691 | - | |
692 | - state->obj_state.free = chronoline_free_state; | |
693 | - | |
694 | - OBJECT_GET_STRING(chronoline,state,name); | |
695 | - OBJECT_GET_STRING(chronoline,state,events); | |
696 | - | |
697 | - OBJECT_GET_REAL(chronoline,state,start_time); | |
698 | - OBJECT_GET_REAL(chronoline,state,end_time); | |
699 | - | |
700 | - OBJECT_GET_REAL(chronoline,state,rise_time); | |
701 | - OBJECT_GET_REAL(chronoline,state,fall_time); | |
702 | - | |
703 | - OBJECT_GET_BOOL(chronoline,state,multibit); | |
704 | - | |
705 | - OBJECT_GET_REAL(chronoline,state,data_lwidth); | |
706 | - OBJECT_GET_COLOR(chronoline,state,data_color); | |
707 | - OBJECT_GET_REAL(chronoline,state,main_lwidth); | |
708 | - OBJECT_GET_COLOR(chronoline,state,color); | |
709 | - | |
710 | - OBJECT_GET_FONT(chronoline,state,font); | |
711 | - OBJECT_GET_FONTHEIGHT(chronoline,state,font_size); | |
712 | - OBJECT_GET_COLOR(chronoline,state,font_color); | |
713 | - | |
714 | - return state; | |
715 | -} | |
716 | - | |
717 | -static void | |
718 | -chronoline_set_state(Chronoline *chronoline, ChronolineState *state) | |
719 | -{ | |
720 | - OBJECT_SET_STRING(chronoline,state,name); | |
721 | - OBJECT_SET_STRING(chronoline,state,events); | |
722 | - | |
723 | - OBJECT_SET_REAL(chronoline,state,start_time); | |
724 | - OBJECT_SET_REAL(chronoline,state,end_time); | |
725 | - | |
726 | - OBJECT_SET_REAL(chronoline,state,rise_time); | |
727 | - OBJECT_SET_REAL(chronoline,state,fall_time); | |
728 | - | |
729 | - OBJECT_SET_BOOL(chronoline,state,multibit); | |
730 | - | |
731 | - OBJECT_SET_REAL(chronoline,state,data_lwidth); | |
732 | - OBJECT_SET_COLOR(chronoline,state,data_color); | |
733 | - OBJECT_SET_REAL(chronoline,state,main_lwidth); | |
734 | - OBJECT_SET_COLOR(chronoline,state,color); | |
735 | - | |
736 | - OBJECT_SET_FONT(chronoline,state,font); | |
737 | - OBJECT_SET_FONTHEIGHT(chronoline,state,font_size); | |
738 | - OBJECT_SET_COLOR(chronoline,state,font_color); | |
739 | - | |
740 | - chronoline_update_data(chronoline); | |
741 | -} | |
742 | - | |
743 | - | |
744 | 470 | inline static void grayify(Color *col,Color *src) |
745 | 471 | { |
746 | 472 | col->red = .5 * (src->red + color_white.red); |
@@ -859,20 +585,6 @@ chronoline_update_data(Chronoline *chronoline) | ||
859 | 585 | } |
860 | 586 | } |
861 | 587 | |
862 | -static void chronoline_alloc(Chronoline **chronoline, | |
863 | - Element **elem, | |
864 | - Object **obj) | |
865 | -{ | |
866 | - chronoline_init_defaults(); | |
867 | - | |
868 | - *chronoline = g_new0(Chronoline,1); | |
869 | - *elem = &((*chronoline)->element); | |
870 | - | |
871 | - *obj = &((*chronoline)->element.object); | |
872 | - (*obj)->type = &chronoline_type; | |
873 | - (*obj)->ops = &chronoline_ops; | |
874 | -} | |
875 | - | |
876 | 588 | static Object * |
877 | 589 | chronoline_create(Point *startpoint, |
878 | 590 | void *user_data, |
@@ -883,7 +595,12 @@ chronoline_create(Point *startpoint, | ||
883 | 595 | Element *elem; |
884 | 596 | Object *obj; |
885 | 597 | |
886 | - chronoline_alloc(&chronoline,&elem,&obj); | |
598 | + chronoline = g_new0(Chronoline,1); | |
599 | + elem = &(chronoline->element); | |
600 | + | |
601 | + obj = &(chronoline->element.object); | |
602 | + obj->type = &chronoline_type; | |
603 | + obj->ops = &chronoline_ops; | |
887 | 604 | |
888 | 605 | chronoline->snap = connpointline_create(obj,0); |
889 | 606 |
@@ -893,25 +610,22 @@ chronoline_create(Point *startpoint, | ||
893 | 610 | |
894 | 611 | element_init(elem, 8, 0); |
895 | 612 | |
896 | - OBJECT_GET_STRING(&defaults,chronoline,name); | |
897 | - OBJECT_GET_STRING(&defaults,chronoline,events); | |
898 | - | |
899 | - OBJECT_GET_REAL(&defaults,chronoline,start_time); | |
900 | - OBJECT_GET_REAL(&defaults,chronoline,end_time); | |
901 | - | |
902 | - OBJECT_GET_REAL(&defaults,chronoline,rise_time); | |
903 | - OBJECT_GET_REAL(&defaults,chronoline,fall_time); | |
904 | - | |
905 | - OBJECT_GET_BOOL(&defaults,chronoline,multibit); | |
906 | - | |
907 | - OBJECT_GET_REAL(&defaults,chronoline,data_lwidth); | |
908 | - OBJECT_GET_COLOR(&defaults,chronoline,data_color); | |
909 | - OBJECT_GET_REAL(&defaults,chronoline,main_lwidth); | |
910 | - OBJECT_GET_COLOR(&defaults,chronoline,color); | |
911 | - | |
912 | - OBJECT_GET_FONT(&defaults,chronoline,font); | |
913 | - OBJECT_GET_FONTHEIGHT(&defaults,chronoline,font_size); | |
914 | - OBJECT_GET_COLOR(&defaults,chronoline,font_color); | |
613 | + chronoline->name = g_strdup(""); | |
614 | + chronoline->events = g_strdup(""); | |
615 | + chronoline->font = font_getfont("Helvetica"); | |
616 | + chronoline->font_size = 1.0; | |
617 | + chronoline->font_color = color_black; | |
618 | + chronoline->start_time = 0.0; | |
619 | + chronoline->end_time = 20.0; | |
620 | + chronoline->rise_time = .3; | |
621 | + chronoline->fall_time = .3; | |
622 | + chronoline->color = color_black; | |
623 | + chronoline->main_lwidth = .1; | |
624 | + chronoline->data_lwidth = .1; | |
625 | + chronoline->data_color.red = 1.0; | |
626 | + chronoline->data_color.green = 0.0; | |
627 | + chronoline->data_color.blue = 0.0; | |
628 | + chronoline->multibit = FALSE; | |
915 | 629 | |
916 | 630 | chronoline->evtlist = NULL; |
917 | 631 | chronoline_update_data(chronoline); |
@@ -921,7 +635,7 @@ chronoline_create(Point *startpoint, | ||
921 | 635 | return &chronoline->element.object; |
922 | 636 | } |
923 | 637 | |
924 | -static void | |
638 | +static void | |
925 | 639 | chronoline_destroy(Chronoline *chronoline) |
926 | 640 | { |
927 | 641 | connpointline_destroy(chronoline->snap); |
@@ -930,110 +644,8 @@ chronoline_destroy(Chronoline *chronoline) | ||
930 | 644 | } |
931 | 645 | |
932 | 646 | static Object * |
933 | -chronoline_copy(Chronoline *chronoline) | |
934 | -{ | |
935 | - Chronoline *newchronoline; | |
936 | - Element *elem, *newelem; | |
937 | - Object *newobj, *obj; | |
938 | - int rcc = 0; | |
939 | - | |
940 | - elem = &chronoline->element; | |
941 | - obj = &elem->object; | |
942 | - chronoline_alloc(&newchronoline,&newelem,&newobj); | |
943 | - element_copy(elem, newelem); | |
944 | - | |
945 | - newchronoline->snap = connpointline_copy(newobj,chronoline->snap,&rcc); | |
946 | - g_assert(rcc == newobj->num_connections); | |
947 | - | |
948 | - | |
949 | - OBJECT_GET_STRING(chronoline,newchronoline,name); | |
950 | - OBJECT_GET_STRING(chronoline,newchronoline,events); | |
951 | - | |
952 | - OBJECT_GET_REAL(chronoline,newchronoline,start_time); | |
953 | - OBJECT_GET_REAL(chronoline,newchronoline,end_time); | |
954 | - | |
955 | - OBJECT_GET_REAL(chronoline,newchronoline,rise_time); | |
956 | - OBJECT_GET_REAL(chronoline,newchronoline,fall_time); | |
957 | - | |
958 | - OBJECT_GET_BOOL(chronoline,newchronoline,multibit); | |
959 | - | |
960 | - OBJECT_GET_REAL(chronoline,newchronoline,data_lwidth); | |
961 | - OBJECT_GET_COLOR(chronoline,newchronoline,data_color); | |
962 | - OBJECT_GET_REAL(chronoline,newchronoline,main_lwidth); | |
963 | - OBJECT_GET_COLOR(chronoline,newchronoline,color); | |
964 | - | |
965 | - OBJECT_GET_FONT(chronoline,newchronoline,font); | |
966 | - OBJECT_GET_FONTHEIGHT(chronoline,newchronoline,font_size); | |
967 | - OBJECT_GET_COLOR(chronoline,newchronoline,font_color); | |
968 | - | |
969 | - newchronoline->evtlist = NULL; | |
970 | - | |
971 | - chronoline_update_data(newchronoline); | |
972 | - | |
973 | - return &newchronoline->element.object; | |
974 | -} | |
975 | - | |
976 | - | |
977 | -static void | |
978 | -chronoline_save(Chronoline *chronoline, ObjectNode obj_node, const char *filename) | |
979 | -{ | |
980 | - element_save(&chronoline->element, obj_node); | |
981 | - | |
982 | - SAVE_STRING(obj_node,chronoline,name); | |
983 | - SAVE_STRING(obj_node,chronoline,events); | |
984 | - | |
985 | - SAVE_REAL(obj_node,chronoline,start_time); | |
986 | - SAVE_REAL(obj_node,chronoline,end_time); | |
987 | - | |
988 | - SAVE_REAL(obj_node,chronoline,rise_time); | |
989 | - SAVE_REAL(obj_node,chronoline,fall_time); | |
990 | - | |
991 | - SAVE_BOOL(obj_node,chronoline,multibit); | |
992 | - | |
993 | - SAVE_REAL(obj_node,chronoline,data_lwidth); | |
994 | - SAVE_COLOR(obj_node,chronoline,data_color); | |
995 | - SAVE_REAL(obj_node,chronoline,main_lwidth); | |
996 | - SAVE_COLOR(obj_node,chronoline,color); | |
997 | - | |
998 | - SAVE_FONT(obj_node,chronoline,font); | |
999 | - SAVE_FONTHEIGHT(obj_node,chronoline,font_size); | |
1000 | - SAVE_COLOR(obj_node,chronoline,font_color); | |
1001 | -} | |
1002 | - | |
1003 | -static Object * | |
1004 | 647 | chronoline_load(ObjectNode obj_node, int version, const char *filename) |
1005 | 648 | { |
1006 | - Chronoline *chronoline; | |
1007 | - Element *elem; | |
1008 | - Object *obj; | |
1009 | - | |
1010 | - chronoline_alloc(&chronoline,&elem,&obj); | |
1011 | - chronoline->snap = connpointline_create(obj,0); | |
1012 | - | |
1013 | - element_load(elem, obj_node); | |
1014 | - element_init(elem, 8, 0); | |
1015 | - | |
1016 | - LOAD_STRING(obj_node,chronoline,&defaults,name); | |
1017 | - LOAD_STRING(obj_node,chronoline,&defaults,events); | |
1018 | - | |
1019 | - LOAD_REAL(obj_node,chronoline,&defaults,start_time); | |
1020 | - LOAD_REAL(obj_node,chronoline,&defaults,end_time); | |
1021 | - | |
1022 | - LOAD_REAL(obj_node,chronoline,&defaults,rise_time); | |
1023 | - LOAD_REAL(obj_node,chronoline,&defaults,fall_time); | |
1024 | - | |
1025 | - LOAD_BOOL(obj_node,chronoline,&defaults,multibit); | |
1026 | - | |
1027 | - LOAD_REAL(obj_node,chronoline,&defaults,data_lwidth); | |
1028 | - LOAD_COLOR(obj_node,chronoline,&defaults,data_color); | |
1029 | - LOAD_REAL(obj_node,chronoline,&defaults,main_lwidth); | |
1030 | - LOAD_COLOR(obj_node,chronoline,&defaults,color); | |
1031 | - | |
1032 | - LOAD_FONT(obj_node,chronoline,&defaults,font); | |
1033 | - LOAD_FONTHEIGHT(obj_node,chronoline,&defaults,font_size); | |
1034 | - LOAD_COLOR(obj_node,chronoline,&defaults,font_color); | |
1035 | - | |
1036 | - chronoline_update_data(chronoline); | |
1037 | - | |
1038 | - return &chronoline->element.object; | |
649 | + return object_load_using_properties(&chronoline_type, | |
650 | + obj_node,version,filename); | |
1039 | 651 | } |
@@ -2,7 +2,7 @@ | ||
2 | 2 | * Copyright (C) 1998 Alexander Larsson |
3 | 3 | * |
4 | 4 | * Chronogram objects support |
5 | - * Copyright (C) 2000 Cyrille Chepelov | |
5 | + * Copyright (C) 2000, 2001 Cyrille Chepelov | |
6 | 6 | * |
7 | 7 | * Ultimately forked from Flowchart toolbox -- objects for drawing flowcharts. |
8 | 8 | * Copyright (C) 1999 James Henstridge. |
@@ -51,29 +51,7 @@ | ||
51 | 51 | #define DEFAULT_WIDTH 7.0 |
52 | 52 | #define DEFAULT_HEIGHT 5.0 |
53 | 53 | |
54 | -typedef struct _Chronoref Chronoref; | |
55 | -typedef struct _ChronorefPropertiesDialog ChronorefPropertiesDialog; | |
56 | -typedef struct _ChronorefDefaultsDialog ChronorefDefaultsDialog; | |
57 | -typedef struct _ChronorefState ChronorefState; | |
58 | -typedef struct _ChronorefDefaults ChronorefDefaults; | |
59 | - | |
60 | -struct _ChronorefState { | |
61 | - ObjectState obj_state; | |
62 | - | |
63 | - real main_lwidth; | |
64 | - real light_lwidth; | |
65 | - Color color; | |
66 | - real start_time; | |
67 | - real end_time; | |
68 | - real time_step; | |
69 | - real time_lstep; | |
70 | - | |
71 | - Font *font; | |
72 | - real font_size; | |
73 | - Color font_color; | |
74 | -}; | |
75 | - | |
76 | -struct _Chronoref { | |
54 | +typedef struct _Chronoref { | |
77 | 55 | Element element; |
78 | 56 | |
79 | 57 | real main_lwidth; |
@@ -94,59 +72,7 @@ struct _Chronoref { | ||
94 | 72 | real firstmaj,firstmin; /* in time units */ |
95 | 73 | real firstmaj_x,firstmin_x,majgrad,mingrad; /* in dia graphic units */ |
96 | 74 | char spec[10]; |
97 | -}; | |
98 | - | |
99 | -struct _ChronorefPropertiesDialog { | |
100 | - AttributeDialog dialog; | |
101 | - Chronoref *parent; | |
102 | - | |
103 | - RealAttribute main_lwidth; | |
104 | - RealAttribute light_lwidth; | |
105 | - ColorAttribute color; | |
106 | - RealAttribute start_time; | |
107 | - RealAttribute end_time; | |
108 | - RealAttribute time_step; | |
109 | - RealAttribute time_lstep; | |
110 | - | |
111 | - FontAttribute font; | |
112 | - FontHeightAttribute font_size; | |
113 | - ColorAttribute font_color; | |
114 | -}; | |
115 | - | |
116 | -struct _ChronorefDefaults { | |
117 | - real main_lwidth; | |
118 | - real light_lwidth; | |
119 | - Color color; | |
120 | - real start_time; | |
121 | - real end_time; | |
122 | - real time_step; | |
123 | - real time_lstep; | |
124 | - | |
125 | - Font *font; | |
126 | - real font_size; | |
127 | - Color font_color; | |
128 | -}; | |
129 | - | |
130 | -struct _ChronorefDefaultsDialog { | |
131 | - AttributeDialog dialog; | |
132 | - ChronorefDefaults *parent; | |
133 | - | |
134 | - RealAttribute main_lwidth; | |
135 | - RealAttribute light_lwidth; | |
136 | - ColorAttribute color; | |
137 | - RealAttribute start_time; | |
138 | - RealAttribute end_time; | |
139 | - RealAttribute time_step; | |
140 | - RealAttribute time_lstep; | |
141 | - | |
142 | - FontAttribute font; | |
143 | - FontHeightAttribute font_size; | |
144 | - ColorAttribute font_color; | |
145 | -}; | |
146 | - | |
147 | -static ChronorefPropertiesDialog *chronoref_properties_dialog; | |
148 | -static ChronorefDefaultsDialog *chronoref_defaults_dialog; | |
149 | -static ChronorefDefaults defaults; | |
75 | +} Chronoref; | |
150 | 76 | |
151 | 77 | static real chronoref_distance_from(Chronoref *chronoref, Point *point); |
152 | 78 | static void chronoref_select(Chronoref *chronoref, Point *clicked_point, |
@@ -162,27 +88,23 @@ static Object *chronoref_create(Point *startpoint, | ||
162 | 88 | Handle **handle1, |
163 | 89 | Handle **handle2); |
164 | 90 | static void chronoref_destroy(Chronoref *chronoref); |
165 | -static Object *chronoref_copy(Chronoref *chronoref); | |
166 | -static PROPDLG_TYPE chronoref_get_properties(Chronoref *chronoref); | |
167 | -static ObjectChange *chronoref_apply_properties(Chronoref *chronoref); | |
168 | - | |
169 | -static ChronorefState *chronoref_get_state(Chronoref *chronoref); | |
170 | -static void chronoref_set_state(Chronoref *chronoref, ChronorefState *state); | |
91 | +static Object *chronoref_load(ObjectNode obj_node, int version, | |
92 | + const char *filename); | |
93 | +static PropDescription *chronoref_describe_props(Chronoref *chronoref); | |
94 | +static void chronoref_get_props(Chronoref *chronoref, | |
95 | + Property *props, guint nprops); | |
96 | +static void chronoref_set_props(Chronoref *chronoref, | |
97 | + Property *props, guint nprops); | |
171 | 98 | |
172 | -static void chronoref_save(Chronoref *chronoref, ObjectNode obj_node, const char *filename); | |
173 | -static Object *chronoref_load(ObjectNode obj_node, int version, const char *filename); | |
174 | -static PROPDLG_TYPE chronoref_get_defaults(void); | |
175 | -static void chronoref_apply_defaults(void); | |
176 | -static void chronoref_free_state(ObjectState *objstate); | |
177 | 99 | |
178 | 100 | |
179 | 101 | static ObjectTypeOps chronoref_type_ops = |
180 | 102 | { |
181 | 103 | (CreateFunc) chronoref_create, |
182 | - (LoadFunc) chronoref_load, | |
183 | - (SaveFunc) chronoref_save, | |
184 | - (GetDefaultsFunc) chronoref_get_defaults, | |
185 | - (ApplyDefaultsFunc) chronoref_apply_defaults | |
104 | + (LoadFunc) chronoref_load/*using properties*/, | |
105 | + (SaveFunc) object_save_using_properties, | |
106 | + (GetDefaultsFunc) NULL, | |
107 | + (ApplyDefaultsFunc) NULL | |
186 | 108 | }; |
187 | 109 | |
188 | 110 | ObjectType chronoref_type = |
@@ -194,141 +116,92 @@ ObjectType chronoref_type = | ||
194 | 116 | &chronoref_type_ops /* ops */ |
195 | 117 | }; |
196 | 118 | |
119 | + | |
197 | 120 | static ObjectOps chronoref_ops = { |
198 | 121 | (DestroyFunc) chronoref_destroy, |
199 | 122 | (DrawFunc) chronoref_draw, |
200 | 123 | (DistanceFunc) chronoref_distance_from, |
201 | 124 | (SelectFunc) chronoref_select, |
202 | - (CopyFunc) chronoref_copy, | |
125 | + (CopyFunc) object_copy_using_properties, | |
203 | 126 | (MoveFunc) chronoref_move, |
204 | 127 | (MoveHandleFunc) chronoref_move_handle, |
205 | - (GetPropertiesFunc) chronoref_get_properties, | |
206 | - (ApplyPropertiesFunc) chronoref_apply_properties, | |
128 | + (GetPropertiesFunc) object_create_props_dialog, | |
129 | + (ApplyPropertiesFunc) object_apply_props_from_dialog, | |
207 | 130 | (ObjectMenuFunc) NULL, |
131 | + (DescribePropsFunc) chronoref_describe_props, | |
132 | + (GetPropsFunc) chronoref_get_props, | |
133 | + (SetPropsFunc) chronoref_set_props | |
208 | 134 | }; |
209 | 135 | |
210 | -static ObjectChange * | |
211 | -chronoref_apply_properties(Chronoref *chronoref) | |
212 | -{ | |
213 | - ObjectState *old_state; | |
214 | - ChronorefPropertiesDialog *dlg = chronoref_properties_dialog; | |
215 | - | |
216 | - PROPDLG_SANITY_CHECK(dlg,chronoref); | |
217 | - | |
218 | - old_state = (ObjectState *)chronoref_get_state(chronoref); | |
219 | - | |
220 | - PROPDLG_APPLY_REAL(dlg,start_time); | |
221 | - PROPDLG_APPLY_REAL(dlg,end_time); | |
222 | - | |
223 | - PROPDLG_APPLY_REAL(dlg,time_step); | |
224 | - PROPDLG_APPLY_REAL(dlg,time_lstep); | |
225 | - | |
226 | - PROPDLG_APPLY_COLOR(dlg,color); | |
227 | - PROPDLG_APPLY_REAL(dlg,main_lwidth); | |
228 | - PROPDLG_APPLY_REAL(dlg,light_lwidth); | |
229 | - PROPDLG_APPLY_FONT(dlg,font); | |
230 | - PROPDLG_APPLY_FONTHEIGHT(dlg,font_size); | |
231 | - PROPDLG_APPLY_COLOR(dlg,font_color); | |
232 | - | |
233 | - /* time_lstep should probably be a multiplier of time_step, but the user | |
234 | - is sovereign. */ | |
235 | - chronoref_update_data(chronoref); | |
236 | - return new_object_state_change(&chronoref->element.object, | |
237 | - old_state, | |
238 | - (GetStateFunc)chronoref_get_state, | |
239 | - (SetStateFunc)chronoref_set_state); | |
240 | -} | |
136 | +static PropNumData time_range = { -32767.0, 32768.0, 0.1}; | |
137 | +static PropNumData step_range = { 0.0, 1000.0, 0.1}; | |
138 | + | |
139 | +static PropDescription chronoref_props[] = { | |
140 | + ELEMENT_COMMON_PROPERTIES, | |
141 | + { "start_time",PROP_TYPE_REAL,PROP_FLAG_VISIBLE, | |
142 | + N_("Start time"),NULL,&time_range}, | |
143 | + { "end_time",PROP_TYPE_REAL,PROP_FLAG_VISIBLE, | |
144 | + N_("End time"),NULL,&time_range}, | |
145 | + { "time_step",PROP_TYPE_REAL,PROP_FLAG_VISIBLE, | |
146 | + N_("Major time step"),NULL,&step_range}, | |
147 | + { "time_lstep",PROP_TYPE_REAL,PROP_FLAG_VISIBLE, | |
148 | + N_("Minor time step"),NULL,&step_range}, | |
149 | + | |
150 | + { "color", PROP_TYPE_COLOUR, PROP_FLAG_VISIBLE, | |
151 | + N_("Line color"),NULL}, | |
152 | + { "main_lwidth", PROP_TYPE_REAL, PROP_FLAG_VISIBLE, | |
153 | + N_("Line width"),NULL, &prop_std_line_width_data}, | |
154 | + { "light_lwidth", PROP_TYPE_REAL, PROP_FLAG_VISIBLE, | |
155 | + N_("Minor step line width"),NULL, &prop_std_line_width_data}, | |
156 | + | |
157 | + { "font", PROP_TYPE_FONT, PROP_FLAG_VISIBLE, N_("Font"), NULL, NULL }, | |
158 | + { "font_size", PROP_TYPE_REAL, PROP_FLAG_VISIBLE, | |
159 | + N_("Font size"), NULL, &prop_std_text_height_data }, | |
160 | + { "font_color", PROP_TYPE_COLOUR, PROP_FLAG_VISIBLE, | |
161 | + N_("Text colour"), NULL, NULL }, | |
162 | + | |
163 | + {NULL} | |
164 | +}; | |
241 | 165 | |
242 | -static PROPDLG_TYPE | |
243 | -chronoref_get_properties(Chronoref *chronoref) | |
244 | -{ | |
245 | - ChronorefPropertiesDialog *dlg = chronoref_properties_dialog; | |
246 | - | |
247 | - PROPDLG_CREATE(dlg,chronoref); | |
248 | - | |
249 | - PROPDLG_SHOW_REAL(dlg,start_time,_("Start time:"),-32767.0,32768.0,0.1); | |
250 | - PROPDLG_SHOW_REAL(dlg,end_time,_("End time:"),-32767.0,32768.0,0.1); | |
251 | - PROPDLG_SHOW_SEPARATOR(dlg); | |
252 | - PROPDLG_SHOW_REAL(dlg,time_step,_("Major time step:"),0.1,1000.0,0.1); | |
253 | - PROPDLG_SHOW_REAL(dlg,time_lstep,_("Minor time step:"),0.1,1000.0,0.1); | |
254 | - PROPDLG_SHOW_SEPARATOR(dlg); | |
255 | - PROPDLG_SHOW_COLOR(dlg,color,_("Line color:")); | |
256 | - PROPDLG_SHOW_REAL(dlg,main_lwidth,_("Line width:"),0.0,10.0,0.1); | |
257 | - PROPDLG_SHOW_REAL(dlg,light_lwidth,_("Minor step line width:"), | |
258 | - 0.0,10.0,0.1); | |
259 | - PROPDLG_SHOW_FONT(dlg,font,_("Font:")); | |
260 | - PROPDLG_SHOW_FONTHEIGHT(dlg,font_size,_("Font size:")); | |
261 | - PROPDLG_SHOW_COLOR(dlg,font_color,_("Font color:")); | |
262 | - | |
263 | - PROPDLG_READY(dlg); | |
264 | - chronoref_properties_dialog = dlg; | |
265 | - | |
266 | - PROPDLG_RETURN(dlg); | |
267 | -} | |
268 | -static void | |
269 | -chronoref_apply_defaults(void) | |
166 | +static PropDescription * | |
167 | +chronoref_describe_props(Chronoref *chronoref) | |
270 | 168 | { |
271 | - ChronorefDefaultsDialog *dlg = chronoref_defaults_dialog; | |
272 | - PROPDLG_APPLY_REAL(dlg,start_time); | |
273 | - PROPDLG_APPLY_REAL(dlg,end_time); | |
274 | - | |
275 | - PROPDLG_APPLY_REAL(dlg,time_step); | |
276 | - PROPDLG_APPLY_REAL(dlg,time_lstep); | |
277 | - | |
278 | - PROPDLG_APPLY_COLOR(dlg,color); | |
279 | - PROPDLG_APPLY_REAL(dlg,main_lwidth); | |
280 | - PROPDLG_APPLY_REAL(dlg,light_lwidth); | |
281 | - PROPDLG_APPLY_FONT(dlg,font); | |
282 | - PROPDLG_APPLY_FONTHEIGHT(dlg,font_size); | |
283 | - PROPDLG_APPLY_COLOR(dlg,font_color); | |
284 | - | |
285 | -} | |
169 | + if (chronoref_props[0].quark == 0) { | |
170 | + prop_desc_list_calculate_quarks(chronoref_props); | |
171 | + } | |
172 | + return chronoref_props; | |
173 | +} | |
174 | + | |
175 | +static PropOffset chronoref_offsets[] = { | |
176 | + ELEMENT_COMMON_PROPERTIES_OFFSETS, | |
177 | + | |
178 | + { "start_time",PROP_TYPE_REAL, offsetof(Chronoref,start_time)}, | |
179 | + { "end_time",PROP_TYPE_REAL, offsetof(Chronoref,end_time)}, | |
180 | + { "time_step",PROP_TYPE_REAL, offsetof(Chronoref,time_step)}, | |
181 | + { "time_lstep",PROP_TYPE_REAL, offsetof(Chronoref,time_lstep)}, | |
182 | + { "color", PROP_TYPE_COLOUR, offsetof(Chronoref,color)}, | |
183 | + { "main_lwidth", PROP_TYPE_REAL, offsetof(Chronoref,main_lwidth)}, | |
184 | + { "light_lwidth", PROP_TYPE_REAL, offsetof(Chronoref,light_lwidth)}, | |
185 | + { "font", PROP_TYPE_FONT, offsetof(Chronoref,font)}, | |
186 | + { "font_size", PROP_TYPE_REAL, offsetof(Chronoref,font_size)}, | |
187 | + { "font_color", PROP_TYPE_COLOUR, offsetof(Chronoref,font_color)}, | |
188 | + | |
189 | + {NULL} | |
190 | +}; | |
286 | 191 | |
287 | 192 | static void |
288 | -chronoref_init_defaults() { | |
289 | - static int defaults_initialized = 0; | |
290 | - | |
291 | - if (!defaults_initialized) { | |
292 | - defaults.font = font_getfont("Helvetica"); | |
293 | - defaults.font_size = 1.0; | |
294 | - defaults.font_color = color_black; | |
295 | - defaults.start_time = 0.0; | |
296 | - defaults.end_time = 20.0; | |
297 | - defaults.time_step = 5.0; | |
298 | - defaults.time_lstep = 1.0; | |
299 | - defaults.color = color_black; | |
300 | - defaults.main_lwidth = .1; | |
301 | - defaults.light_lwidth = .05; | |
302 | - | |
303 | - defaults_initialized = 1; | |
304 | - } | |
193 | +chronoref_get_props(Chronoref *chronoref, Property *props, guint nprops) | |
194 | +{ | |
195 | + object_get_props_from_offsets(&chronoref->element.object, | |
196 | + chronoref_offsets,props,nprops); | |
305 | 197 | } |
306 | 198 | |
307 | -static GtkWidget * | |
308 | -chronoref_get_defaults(void) | |
199 | +static void | |
200 | +chronoref_set_props(Chronoref *chronoref, Property *props, guint nprops) | |
309 | 201 | { |
310 | - ChronorefDefaultsDialog *dlg = chronoref_defaults_dialog; | |
311 | - | |
312 | - chronoref_init_defaults(); | |
313 | - PROPDLG_CREATE(dlg, &defaults); | |
314 | - PROPDLG_SHOW_REAL(dlg,start_time,_("Start time:"),-32767.0,32768.0,0.1); | |
315 | - PROPDLG_SHOW_REAL(dlg,end_time,_("End time:"),-32767.0,32768.0,0.1); | |
316 | - PROPDLG_SHOW_SEPARATOR(dlg); | |
317 | - PROPDLG_SHOW_REAL(dlg,time_step,_("Major time step:"),0.1,1000.0,0.1); | |
318 | - PROPDLG_SHOW_REAL(dlg,time_lstep,_("Minor time step:"),0.1,1000.0,0.1); | |
319 | - PROPDLG_SHOW_SEPARATOR(dlg); | |
320 | - PROPDLG_SHOW_COLOR(dlg,color,_("Line color:")); | |
321 | - PROPDLG_SHOW_REAL(dlg,main_lwidth,_("Line width:"),0.0,10.0,0.1); | |
322 | - PROPDLG_SHOW_REAL(dlg,light_lwidth,_("Minor step line width:"), | |
323 | - 0.0,10.0,0.1); | |
324 | - PROPDLG_SHOW_FONT(dlg,font,_("Font:")); | |
325 | - PROPDLG_SHOW_FONTHEIGHT(dlg,font_size,_("Font size:")); | |
326 | - PROPDLG_SHOW_COLOR(dlg,font_color,_("Font color:")); | |
327 | - | |
328 | - PROPDLG_READY(dlg); | |
329 | - chronoref_defaults_dialog = dlg; | |
330 | - | |
331 | - PROPDLG_RETURN(dlg); | |
202 | + object_set_props_from_offsets(&chronoref->element.object, | |
203 | + chronoref_offsets,props,nprops); | |
204 | + chronoref_update_data(chronoref); | |
332 | 205 | } |
333 | 206 | |
334 | 207 | static real |
@@ -425,62 +298,6 @@ chronoref_draw(Chronoref *chronoref, Renderer *renderer) | ||
425 | 298 | } |
426 | 299 | |
427 | 300 | static void |
428 | -chronoref_free_state(ObjectState *objstate) | |
429 | -{ | |
430 | - ChronorefState *state G_GNUC_UNUSED= (ChronorefState *)objstate; | |
431 | - /* actually a useless function ; just a demonstrator. */ | |
432 | - OBJECT_FREE_REAL(state,main_lwidth); | |
433 | - OBJECT_FREE_REAL(state,light_lwidth); | |
434 | - OBJECT_FREE_COLOR(state,color); | |
435 | - OBJECT_FREE_REAL(state,start_time); | |
436 | - OBJECT_FREE_REAL(state,end_time); | |
437 | - OBJECT_FREE_REAL(state,time_step); | |
438 | - OBJECT_FREE_REAL(state,time_lstep); | |
439 | - OBJECT_FREE_FONT(state,font); | |
440 | - OBJECT_FREE_FONTHEIGHT(state,font_size); | |
441 | - OBJECT_FREE_COLOR(state,font_color); | |
442 | -} | |
443 | - | |
444 | -static ChronorefState * | |
445 | -chronoref_get_state(Chronoref *chronoref) | |
446 | -{ | |
447 | - ChronorefState *state = g_new0(ChronorefState, 1); | |
448 | - | |
449 | - state->obj_state.free = chronoref_free_state; | |
450 | - | |
451 | - OBJECT_GET_REAL(chronoref,state,main_lwidth); | |
452 | - OBJECT_GET_REAL(chronoref,state,light_lwidth); | |
453 | - OBJECT_GET_COLOR(chronoref,state,color); | |
454 | - OBJECT_GET_REAL(chronoref,state,start_time); | |
455 | - OBJECT_GET_REAL(chronoref,state,end_time); | |
456 | - OBJECT_GET_REAL(chronoref,state,time_step); | |
457 | - OBJECT_GET_REAL(chronoref,state,time_lstep); | |
458 | - OBJECT_GET_FONT(chronoref,state,font); | |
459 | - OBJECT_GET_FONTHEIGHT(chronoref,state,font_size); | |
460 | - OBJECT_GET_COLOR(chronoref,state,font_color); | |
461 | - | |
462 | - return state; | |
463 | -} | |
464 | - | |
465 | -static void | |
466 | -chronoref_set_state(Chronoref *chronoref, ChronorefState *state) | |
467 | -{ | |
468 | - OBJECT_SET_REAL(chronoref,state,main_lwidth); | |
469 | - OBJECT_SET_REAL(chronoref,state,light_lwidth); | |
470 | - OBJECT_SET_COLOR(chronoref,state,color); | |
471 | - OBJECT_SET_REAL(chronoref,state,start_time); | |
472 | - OBJECT_SET_REAL(chronoref,state,end_time); | |
473 | - OBJECT_SET_REAL(chronoref,state,time_step); | |
474 | - OBJECT_SET_REAL(chronoref,state,time_lstep); | |
475 | - OBJECT_SET_FONT(chronoref,state,font); | |
476 | - OBJECT_SET_FONTHEIGHT(chronoref,state,font_size); | |
477 | - OBJECT_SET_COLOR(chronoref,state,font_color); | |
478 | - | |
479 | - chronoref_update_data(chronoref); | |
480 | -} | |
481 | - | |
482 | - | |
483 | -static void | |
484 | 301 | chronoref_update_data(Chronoref *chronoref) |
485 | 302 | { |
486 | 303 | Element *elem = &chronoref->element; |
@@ -569,20 +386,6 @@ chronoref_update_data(Chronoref *chronoref) | ||
569 | 386 | connpointline_putonaline(chronoref->scale,&p1,&p2); |
570 | 387 | } |
571 | 388 | |
572 | -static void chronoref_alloc(Chronoref **chronoref, | |
573 | - Element **elem, | |
574 | - Object **obj) | |
575 | -{ | |
576 | - chronoref_init_defaults(); | |
577 | - | |
578 | - *chronoref = g_new0(Chronoref,1); | |
579 | - *elem = &((*chronoref)->element); | |
580 | - | |
581 | - *obj = &((*chronoref)->element.object); | |
582 | - (*obj)->type = &chronoref_type; | |
583 | - (*obj)->ops = &chronoref_ops; | |
584 | -} | |
585 | - | |
586 | 389 | static Object * |
587 | 390 | chronoref_create(Point *startpoint, |
588 | 391 | void *user_data, |
@@ -593,7 +396,12 @@ chronoref_create(Point *startpoint, | ||
593 | 396 | Element *elem; |
594 | 397 | Object *obj; |
595 | 398 | |
596 | - chronoref_alloc(&chronoref,&elem,&obj); | |
399 | + chronoref = g_new0(Chronoref,1); | |
400 | + elem = &(chronoref->element); | |
401 | + | |
402 | + obj = &(chronoref->element.object); | |
403 | + obj->type = &chronoref_type; | |
404 | + obj->ops = &chronoref_ops; | |
597 | 405 | |
598 | 406 | chronoref->scale = connpointline_create(obj,0); |
599 | 407 |
@@ -603,17 +411,17 @@ chronoref_create(Point *startpoint, | ||
603 | 411 | |
604 | 412 | element_init(elem, 8, 0); |
605 | 413 | |
606 | - OBJECT_GET_REAL(&defaults,chronoref,main_lwidth); | |
607 | - OBJECT_GET_REAL(&defaults,chronoref,light_lwidth); | |
608 | - OBJECT_GET_COLOR(&defaults,chronoref,color); | |
609 | - OBJECT_GET_REAL(&defaults,chronoref,start_time); | |
610 | - OBJECT_GET_REAL(&defaults,chronoref,end_time); | |
611 | - OBJECT_GET_REAL(&defaults,chronoref,time_step); | |
612 | - OBJECT_GET_REAL(&defaults,chronoref,time_lstep); | |
613 | - OBJECT_GET_FONT(&defaults,chronoref,font); | |
614 | - OBJECT_GET_FONTHEIGHT(&defaults,chronoref,font_size); | |
615 | - OBJECT_GET_COLOR(&defaults,chronoref,font_color); | |
616 | - | |
414 | + chronoref->font = font_getfont("Helvetica"); | |
415 | + chronoref->font_size = 1.0; | |
416 | + chronoref->font_color = color_black; | |
417 | + chronoref->start_time = 0.0; | |
418 | + chronoref->end_time = 20.0; | |
419 | + chronoref->time_step = 5.0; | |
420 | + chronoref->time_lstep = 1.0; | |
421 | + chronoref->color = color_black; | |
422 | + chronoref->main_lwidth = .1; | |
423 | + chronoref->light_lwidth = .05; | |
424 | + | |
617 | 425 | chronoref_update_data(chronoref); |
618 | 426 | |
619 | 427 | *handle1 = NULL; |
@@ -629,80 +437,8 @@ chronoref_destroy(Chronoref *chronoref) | ||
629 | 437 | } |
630 | 438 | |
631 | 439 | static Object * |
632 | -chronoref_copy(Chronoref *chronoref) | |
633 | -{ | |
634 | - Chronoref *newchronoref; | |
635 | - Element *elem, *newelem; | |
636 | - Object *newobj, *obj; | |
637 | - int rcc = 0; | |
638 | - | |
639 | - elem = &chronoref->element; | |
640 | - obj = &elem->object; | |
641 | - chronoref_alloc(&newchronoref,&newelem,&newobj); | |
642 | - element_copy(elem, newelem); | |
643 | - | |
644 | - newchronoref->scale = connpointline_copy(newobj,chronoref->scale,&rcc); | |
645 | - g_assert(rcc == newobj->num_connections); | |
646 | - | |
647 | - OBJECT_GET_REAL(chronoref,newchronoref,main_lwidth); | |
648 | - OBJECT_GET_REAL(chronoref,newchronoref,light_lwidth); | |
649 | - OBJECT_GET_COLOR(chronoref,newchronoref,color); | |
650 | - OBJECT_GET_REAL(chronoref,newchronoref,start_time); | |
651 | - OBJECT_GET_REAL(chronoref,newchronoref,end_time); | |
652 | - OBJECT_GET_REAL(chronoref,newchronoref,time_step); | |
653 | - OBJECT_GET_REAL(chronoref,newchronoref,time_lstep); | |
654 | - OBJECT_GET_FONT(chronoref,newchronoref,font); | |
655 | - OBJECT_GET_FONTHEIGHT(chronoref,newchronoref,font_size); | |
656 | - OBJECT_GET_COLOR(chronoref,newchronoref,font_color); | |
657 | - | |
658 | - chronoref_update_data(newchronoref); | |
659 | - | |
660 | - return &newchronoref->element.object; | |
661 | -} | |
662 | - | |
663 | - | |
664 | -static void | |
665 | -chronoref_save(Chronoref *chronoref, ObjectNode obj_node, const char *filename) | |
666 | -{ | |
667 | - element_save(&chronoref->element, obj_node); | |
668 | - | |
669 | - SAVE_REAL(obj_node,chronoref,main_lwidth); | |
670 | - SAVE_REAL(obj_node,chronoref,light_lwidth); | |
671 | - SAVE_COLOR(obj_node,chronoref,color); | |
672 | - SAVE_REAL(obj_node,chronoref,start_time); | |
673 | - SAVE_REAL(obj_node,chronoref,end_time); | |
674 | - SAVE_REAL(obj_node,chronoref,time_step); | |
675 | - SAVE_REAL(obj_node,chronoref,time_lstep); | |
676 | - SAVE_FONT(obj_node,chronoref,font); | |
677 | - SAVE_FONTHEIGHT(obj_node,chronoref,font_size); | |
678 | - SAVE_COLOR(obj_node,chronoref,font_color); | |
679 | -} | |
680 | - | |
681 | -static Object * | |
682 | 440 | chronoref_load(ObjectNode obj_node, int version, const char *filename) |
683 | 441 | { |
684 | - Chronoref *chronoref; | |
685 | - Element *elem; | |
686 | - Object *obj; | |
687 | - | |
688 | - chronoref_alloc(&chronoref,&elem,&obj); | |
689 | - chronoref->scale = connpointline_create(obj,0); | |
690 | - | |
691 | - element_load(elem, obj_node); | |
692 | - element_init(elem, 8, 0); | |
693 | - | |
694 | - LOAD_REAL(obj_node,chronoref,&defaults,main_lwidth); | |
695 | - LOAD_REAL(obj_node,chronoref,&defaults,light_lwidth); | |
696 | - LOAD_COLOR(obj_node,chronoref,&defaults,color); | |
697 | - LOAD_REAL(obj_node,chronoref,&defaults,start_time); | |
698 | - LOAD_REAL(obj_node,chronoref,&defaults,end_time); | |
699 | - LOAD_REAL(obj_node,chronoref,&defaults,time_step); | |
700 | - LOAD_REAL(obj_node,chronoref,&defaults,time_lstep); | |
701 | - LOAD_FONT(obj_node,chronoref,&defaults,font); | |
702 | - LOAD_FONTHEIGHT(obj_node,chronoref,&defaults,font_size); | |
703 | - LOAD_COLOR(obj_node,chronoref,&defaults,font_color); | |
704 | - | |
705 | - chronoref_update_data(chronoref); | |
706 | - | |
707 | - return &chronoref->element.object; | |
442 | + return object_load_using_properties(&chronoref_type, | |
443 | + obj_node,version,filename); | |
708 | 444 | } |