]> git.sur5r.net Git - glabels/commitdiff
Fixed layout of labels so that they are layed out in the proper coordinate system:
authorJim Evins <evins@snaught.com>
Mon, 29 Apr 2002 03:12:54 +0000 (03:12 +0000)
committerJim Evins <evins@snaught.com>
Mon, 29 Apr 2002 03:12:54 +0000 (03:12 +0000)
The canvas origin is at the upper left, while the origin on paper is at the lower left.
This was not apparent until a non-symetric (vertical) layout was used.

git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@8 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels1/src/mini_preview.c

index b5b434ee1e9a7c8ee9ecefd370d7410d48974afe..21e61fa4a28ce4d1200da19d7d08adf5dcdcd7f8 100644 (file)
@@ -269,13 +269,19 @@ mini_outline_list_new (GnomeCanvas * canvas,
        GnomeCanvasItem *item = NULL;
        GList *list = NULL;
        gint i, ix, iy;
-       gdouble x1, y1, x2, y2;
+       gdouble x1, y1, x2, y2, y_temp;
+       const GnomePaper *paper = NULL;
+       gdouble paper_height;
+
+       /* get paper height */
+       paper = gnome_paper_with_name (template->page_size);
+       paper_height = gnome_paper_psheight (paper);
 
        group = gnome_canvas_root (canvas);
 
        /* draw mini label outlines */
        i = 1;
-       for (iy = 0; iy < template->ny; iy++) {
+       for (iy = (template->ny - 1); iy >= 0; iy--) {
                for (ix = 0; ix < template->nx; ix++, i++) {
 
                        x1 = ix * (template->dx) + template->x0;
@@ -283,6 +289,12 @@ mini_outline_list_new (GnomeCanvas * canvas,
                        x2 = x1 + template->label_width;
                        y2 = y1 + template->label_height;
 
+                       /* transform origin from lower left to upper left */
+                       /* and swap y's so that (y1 < y2) */
+                       y_temp = y2;
+                       y2 = paper_height - y1;
+                       y1 = paper_height - y_temp;
+
                        switch (template->style) {
                        case GL_TEMPLATE_STYLE_RECT:
                                item = gnome_canvas_item_new (group,