~ubuntu-branches/ubuntu/quantal/gnumeric/quantal

« back to all changes in this revision

Viewing changes to src/gnm-so-polygon.c

  • Committer: Bazaar Package Importer
  • Author(s): Gauvain Pocentek
  • Date: 2009-06-07 11:10:47 UTC
  • mfrom: (1.1.19 upstream) (2.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090607111047-l3rtbzfjxvmi1kx0
Tags: 1.9.8-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Promoted gnumeric-doc to Recommends in gnumeric package for help to be
    installed automatically
  - gnumeric-gtk is a transitional package
  - gnumeric conflicts with gnumeric-gtk << 1.8.3-3ubuntu1
  - call initltool-update in po*
  - remove psiconv support (psiconv is in universe):
    o debian/control: remove B-D on libpsiconv-dev
    o debian/rules: don't pass --with-psiconv to ./configure

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include "gnm-so-polygon.h"
26
26
#include "sheet-object-impl.h"
27
27
#include "xml-io.h"
 
28
#include "parse-util.h"
28
29
 
 
30
#include <goffice/utils/go-persist.h>
29
31
#include <goffice/utils/go-libxml-extras.h>
30
 
#include <goffice/graph/gog-style.h>
31
32
#include <goffice/utils/go-color.h>
 
33
#include <goffice/utils/go-style.h>
32
34
#include <gsf/gsf-impl-utils.h>
33
35
#include <glib/gi18n-lib.h>
34
36
#include <string.h>
47
49
 
48
50
typedef struct {
49
51
        SheetObject base;
50
 
        GogStyle *style;
 
52
        GOStyle *style;
51
53
        GArray   *points;
52
54
} GnmSOPolygon;
53
55
typedef SheetObjectClass GnmSOPolygonClass;
78
80
                        return;
79
81
 
80
82
                i = sop->points->len / 2;
 
83
                if (i == 0)
 
84
                        return;
 
85
 
81
86
                pts = foo_canvas_points_new (i);
82
87
                x_scale = fabs (coords[2] - coords[0]);
83
88
                y_scale = fabs (coords[3] - coords[1]);
121
126
        SOP_PROP_POINTS
122
127
};
123
128
 
124
 
static GogStyle *
 
129
static GOStyle *
125
130
sop_default_style (void)
126
131
{
127
 
        GogStyle *res = gog_style_new ();
128
 
        res->interesting_fields = GOG_STYLE_OUTLINE | GOG_STYLE_FILL;
 
132
        GOStyle *res = go_style_new ();
 
133
        res->interesting_fields = GO_STYLE_OUTLINE | GO_STYLE_FILL;
129
134
        res->outline.width = 0; /* hairline */
130
135
        res->outline.color = RGBA_BLACK;
131
136
        res->outline.dash_type = GO_LINE_SOLID; /* anything but 0 */
132
 
        res->fill.type = GOG_FILL_STYLE_PATTERN;
 
137
        res->fill.type = GO_STYLE_FILL_PATTERN;
133
138
        go_pattern_set_solid (&res->fill.pattern, RGBA_WHITE);
134
139
        return res;
135
140
}
141
146
static void
142
147
cb_gnm_so_polygon_style_changed (FooCanvasItem *view, GnmSOPolygon const *sop)
143
148
{
144
 
        GogStyle const *style = sop->style;
 
149
        GOStyle const *style = sop->style;
145
150
        GdkColor outline_buf, *outline_gdk = NULL;
146
151
        GdkColor fill_buf, *fill_gdk = NULL;
147
152
 
150
155
            style->outline.dash_type != GO_LINE_NONE)
151
156
                outline_gdk = go_color_to_gdk (style->outline.color, &outline_buf);
152
157
 
153
 
        if (style->fill.type != GOG_FILL_STYLE_NONE)
 
158
        if (style->fill.type != GO_STYLE_FILL_NONE)
154
159
                fill_gdk = go_color_to_gdk (style->fill.pattern.back, &fill_buf);
155
160
 
156
161
        if (style->outline.width > 0.)  /* in pts */
187
192
gnm_so_polygon_user_config (SheetObject *so, SheetControl *sc)
188
193
{
189
194
        dialog_so_styled (scg_wbcg (SHEET_CONTROL_GUI (sc)), G_OBJECT (so),
190
 
                GNM_SO_POLYGON (so)->style, sop_default_style (),
191
 
                _("Polygon Properties"));
 
195
                          GNM_SO_POLYGON (so)->style, sop_default_style (),
 
196
                          _("Polygon Properties"), SO_STYLED_STYLE_ONLY);
192
197
}
193
198
 
194
199
#endif /* GNM_WITH_GTK */
220
225
}
221
226
 
222
227
static void
223
 
gnm_so_polygon_write_xml_sax (SheetObject const *so, GsfXMLOut *output)
 
228
gnm_so_polygon_write_xml_sax (SheetObject const *so, GsfXMLOut *output,
 
229
                              GnmConventions const *convs)
224
230
{
225
 
        /* TODO */
226
 
        return gnm_so_polygon_parent_class->write_xml_sax (so, output);
 
231
        GnmSOPolygon const *sop = GNM_SO_POLYGON (so);
 
232
        unsigned int ui;
 
233
        int prec = convs ? convs->output.decimal_digits : -1;
 
234
 
 
235
        for (ui = 0; ui + 1 < (sop->points ? sop->points->len : 0); ui += 2) {
 
236
                double x = g_array_index (sop->points, double, ui);
 
237
                double y = g_array_index (sop->points, double, ui + 1);
 
238
                gsf_xml_out_start_element (output, "Point");
 
239
                gsf_xml_out_add_float (output, "x", x, prec);
 
240
                gsf_xml_out_add_float (output, "y", y, prec);
 
241
                gsf_xml_out_end_element (output); /* </Point> */
 
242
        }
 
243
 
 
244
        gsf_xml_out_start_element (output, "Style");
 
245
        go_persist_sax_save (GO_PERSIST (sop->style), output);
 
246
        gsf_xml_out_end_element (output); /* </Style> */
227
247
}
228
248
 
229
249
static void
246
266
{
247
267
        GnmSOPolygon *sop = GNM_SO_POLYGON (obj);
248
268
        GArray *points;
249
 
        GogStyle *style;
 
269
        GOStyle *style;
250
270
 
251
271
        switch (param_id) {
252
272
        case SOP_PROP_STYLE:
253
273
                style = sop->style;
254
274
                sop->style = g_object_ref (g_value_get_object (value));
255
 
                sop->style->interesting_fields = GOG_STYLE_OUTLINE | GOG_STYLE_FILL;
 
275
                sop->style->interesting_fields = GO_STYLE_OUTLINE | GO_STYLE_FILL;
256
276
                g_object_unref (style);
257
277
                break;
258
278
        case SOP_PROP_POINTS:
259
279
                points = g_value_get_pointer (value);
260
 
 
261
 
                g_return_if_fail (points != NULL);
 
280
                if (!points)
 
281
                        points = g_array_new (FALSE, TRUE, sizeof (double));
262
282
 
263
283
                if (sop->points != points) {
264
284
                        g_array_free (sop->points, TRUE);
327
347
        so_class->draw_cairo    = gnm_so_polygon_draw_cairo;
328
348
 
329
349
        g_object_class_install_property (gobject_class, SOP_PROP_STYLE,
330
 
                 g_param_spec_object ("style", NULL, NULL, GOG_STYLE_TYPE,
 
350
                 g_param_spec_object ("style", NULL, NULL, GO_TYPE_STYLE,
331
351
                        GSF_PARAM_STATIC | G_PARAM_READWRITE));
332
352
        g_object_class_install_property (gobject_class, SOP_PROP_POINTS,
333
353
                 g_param_spec_pointer ("points", NULL, NULL,
351
371
 
352
372
GSF_CLASS (GnmSOPolygon, gnm_so_polygon,
353
373
           gnm_so_polygon_class_init, gnm_so_polygon_init,
354
 
           SHEET_OBJECT_TYPE);
 
374
           SHEET_OBJECT_TYPE)