From: Jim Evins Date: Sat, 5 Oct 2002 03:29:54 +0000 (+0000) Subject: Template origins are now the upper left corner rather than the lower left. X-Git-Tag: glabels-2_3_0~742 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9be7b598f26a14fcca23836449a9e57c7222e0b2;p=glabels Template origins are now the upper left corner rather than the lower left. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@144 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/data/predefined-labels.template b/glabels2/data/predefined-labels.template index 97675d46..5276bc79 100644 --- a/glabels2/data/predefined-labels.template +++ b/glabels2/data/predefined-labels.template @@ -125,7 +125,7 @@ @@ -227,7 +227,7 @@ description="VCR Face Labels"> @@ -382,7 +382,7 @@ @@ -452,7 +452,7 @@ @@ -492,7 +492,7 @@ @@ -539,7 +539,7 @@ description="CD/DVD Labels (2 Pass)"> @@ -561,7 +561,7 @@ description="PRO CD Labels 2-up (face only, 2 Pass)"> @@ -569,7 +569,7 @@ description="PRO CD Labels 2-up (Face only, 2 Pass)"> @@ -577,7 +577,7 @@ description="PRO CD Labels 2-up (CD spine only)"> @@ -588,7 +588,7 @@ description="Mini-CD Labels, outer 4"> @@ -597,7 +597,7 @@ description="Mini-CD Labels, center 1"> @@ -611,14 +611,14 @@ description="Slimline CD Case (rightside up)"> @@ -705,27 +705,17 @@ - - - - - - - @@ -735,7 +725,7 @@ @@ -755,7 +745,7 @@ @@ -822,7 +812,7 @@ @@ -885,6 +875,21 @@ + + + + + + + + + + + + diff --git a/glabels2/src/print.c b/glabels2/src/print.c index 5b1bee86..e98fdba4 100644 --- a/glabels2/src/print.c +++ b/glabels2/src/print.c @@ -44,9 +44,10 @@ #define GL_PRINT_DEFAULT_PAPER "US Letter" -/*===========================================*/ -/* Private types. */ -/*===========================================*/ +/*=========================================================================*/ +/* Private types. */ +/*=========================================================================*/ + typedef struct _PrintInfo { /* gnome print context */ GnomePrintContext *pc; @@ -58,58 +59,103 @@ typedef struct _PrintInfo { glTemplate *template; gboolean label_rotate_flag; + /* page size */ + gdouble page_width; + gdouble page_height; + + /* page counter */ + gint sheet; } PrintInfo; -/*===========================================*/ -/* Private function prototypes. */ -/*===========================================*/ -static PrintInfo *print_info_new (GnomePrintMaster * master, glLabel * label); -static void print_info_free (PrintInfo ** pi); - -static void print_label (PrintInfo * pi, glLabel * label, gdouble x, gdouble y, - glMergeRecord * record, gboolean outline_flag, - gboolean reverse_flag); - -static void draw_label (PrintInfo * pi, glLabel * label, - glMergeRecord * record); - -static void draw_text_object (PrintInfo * pi, glLabelText * object, - glMergeRecord * record); -static void draw_box_object (PrintInfo * pi, glLabelBox * object); -static void draw_line_object (PrintInfo * pi, glLabelLine * object); -static void draw_ellipse_object (PrintInfo * pi, glLabelEllipse * object); -static void draw_image_object (PrintInfo * pi, glLabelImage * object); -static void draw_barcode_object (PrintInfo * pi, glLabelBarcode * object, - glMergeRecord * record); - -static void draw_outline (PrintInfo * pi, glLabel * label); -static void clip_to_outline (PrintInfo * pi, glLabel * label); - -static void create_rectangle_path (GnomePrintContext * pc, - gdouble x0, gdouble y0, - gdouble w, gdouble h); -static void create_ellipse_path (GnomePrintContext * pc, - gdouble x0, gdouble y0, - gdouble rx, gdouble ry); -static void create_rounded_rectangle_path (GnomePrintContext * pc, - gdouble x0, gdouble y0, - gdouble w, gdouble h, gdouble r); + +/*=========================================================================*/ +/* Private function prototypes. */ +/*=========================================================================*/ +static PrintInfo *print_info_new (GnomePrintMaster *master, + glLabel *label); + +static void print_info_free (PrintInfo **pi); + + +static void print_page_begin (PrintInfo *pi); + +static void print_page_end (PrintInfo *pi); + +static void print_label (PrintInfo *pi, + glLabel *label, + gdouble x, + gdouble y, + glMergeRecord *record, + gboolean outline_flag, + gboolean reverse_flag); + + +static void draw_label (PrintInfo *pi, + glLabel *label, + glMergeRecord *record); + + +static void draw_text_object (PrintInfo *pi, + glLabelText *object, + glMergeRecord *record); + +static void draw_box_object (PrintInfo *pi, + glLabelBox *object); + +static void draw_line_object (PrintInfo *pi, + glLabelLine *object); + +static void draw_ellipse_object (PrintInfo *pi, + glLabelEllipse *object); + +static void draw_image_object (PrintInfo *pi, + glLabelImage *object); + +static void draw_barcode_object (PrintInfo *pi, + glLabelBarcode *object, + glMergeRecord *record); + + +static void draw_outline (PrintInfo *pi, + glLabel *label); + +static void clip_to_outline (PrintInfo *pi, + glLabel *label); + + +static void create_rectangle_path (GnomePrintContext *pc, + gdouble x0, + gdouble y0, + gdouble w, + gdouble h); + +static void create_ellipse_path (GnomePrintContext *pc, + gdouble x0, + gdouble y0, + gdouble rx, + gdouble ry); + +static void create_rounded_rectangle_path (GnomePrintContext *pc, + gdouble x0, + gdouble y0, + gdouble w, + gdouble h, + gdouble r); /*****************************************************************************/ /* Simple (no merge data) print command. */ /*****************************************************************************/ void -gl_print_simple (GnomePrintMaster * master, - glLabel * label, - gint n_sheets, - gint first, - gint last, - gboolean outline_flag, - gboolean reverse_flag) +gl_print_simple (GnomePrintMaster *master, + glLabel *label, + gint n_sheets, + gint first, + gint last, + gboolean outline_flag, + gboolean reverse_flag) { PrintInfo *pi; gint i_sheet, i_label; - gchar *page_str = NULL; glTemplateOrigin *origins; gl_debug (DEBUG_PRINT, "START"); @@ -120,9 +166,7 @@ gl_print_simple (GnomePrintMaster * master, for (i_sheet = 0; i_sheet < n_sheets; i_sheet++) { - page_str = g_strdup_printf ("sheet %d", i_sheet + 1); - gnome_print_beginpage (pi->pc, page_str); - g_free (page_str); + print_page_begin (pi); for (i_label = first - 1; i_label < last; i_label++) { @@ -132,7 +176,7 @@ gl_print_simple (GnomePrintMaster * master, } - gnome_print_showpage (pi->pc); + print_page_end (pi); } g_free (origins); @@ -146,17 +190,16 @@ gl_print_simple (GnomePrintMaster * master, /* Merge print command (collated copies) */ /*****************************************************************************/ void -gl_print_merge_collated (GnomePrintMaster * master, - glLabel * label, - GList * record_list, - gint n_copies, - gint first, - gboolean outline_flag, - gboolean reverse_flag) +gl_print_merge_collated (GnomePrintMaster *master, + glLabel *label, + GList *record_list, + gint n_copies, + gint first, + gboolean outline_flag, + gboolean reverse_flag) { PrintInfo *pi; gint i_sheet, i_label, n_labels_per_page, i_copy; - gchar *str = NULL; glMergeRecord *record; GList *p; glTemplateOrigin *origins; @@ -178,10 +221,7 @@ gl_print_merge_collated (GnomePrintMaster * master, for (i_copy = 0; i_copy < n_copies; i_copy++) { if ((i_label == 0) || (i_sheet == 0)) { - str = g_strdup_printf ("sheet %d", - ++i_sheet); - gnome_print_beginpage (pi->pc, str); - g_free (str); + print_page_begin (pi); } print_label (pi, label, @@ -192,14 +232,14 @@ gl_print_merge_collated (GnomePrintMaster * master, i_label = (i_label + 1) % n_labels_per_page; if (i_label == 0) { - gnome_print_showpage (pi->pc); + print_page_end (pi); } } } } if (i_label != 0) { - gnome_print_showpage (pi->pc); + print_page_end (pi); } g_free (origins); @@ -213,17 +253,16 @@ gl_print_merge_collated (GnomePrintMaster * master, /* Merge print command (uncollated copies) */ /*****************************************************************************/ void -gl_print_merge_uncollated (GnomePrintMaster * master, - glLabel * label, - GList * record_list, - gint n_copies, - gint first, - gboolean outline_flag, - gboolean reverse_flag) +gl_print_merge_uncollated (GnomePrintMaster *master, + glLabel *label, + GList *record_list, + gint n_copies, + gint first, + gboolean outline_flag, + gboolean reverse_flag) { PrintInfo *pi; gint i_sheet, i_label, n_labels_per_page, i_copy; - gchar *str = NULL; glMergeRecord *record; GList *p; glTemplateOrigin *origins; @@ -247,10 +286,7 @@ gl_print_merge_uncollated (GnomePrintMaster * master, if ((i_label == 0) || (i_sheet == 0)) { - str = g_strdup_printf ("sheet %d", - ++i_sheet); - gnome_print_beginpage (pi->pc, str); - g_free (str); + print_page_begin (pi); } print_label (pi, label, @@ -261,14 +297,14 @@ gl_print_merge_uncollated (GnomePrintMaster * master, i_label = (i_label + 1) % n_labels_per_page; if (i_label == 0) { - gnome_print_showpage (pi->pc); + print_page_end (pi); } } } } if (i_label != 0) { - gnome_print_showpage (pi->pc); + print_page_end (pi); } g_free (origins); @@ -282,9 +318,12 @@ gl_print_merge_uncollated (GnomePrintMaster * master, /* Batch print. Call appropriate function above. */ /*****************************************************************************/ void -gl_print_batch (GnomePrintMaster * master, glLabel * label, - gint n_sheets, gint n_copies, - gboolean outline_flag, gboolean reverse_flag) +gl_print_batch (GnomePrintMaster *master, + glLabel *label, + gint n_sheets, + gint n_copies, + gboolean outline_flag, + gboolean reverse_flag) { gint n_per_page; GList *record_list = NULL; @@ -320,11 +359,12 @@ gl_print_batch (GnomePrintMaster * master, glLabel * label, /* PRIVATE. new print info structure */ /*---------------------------------------------------------------------------*/ static PrintInfo * -print_info_new (GnomePrintMaster * master, - glLabel * label) +print_info_new (GnomePrintMaster *master, + glLabel *label) { PrintInfo *pi = g_new0 (PrintInfo, 1); glTemplate *template; + const GnomePrintPaper *paper = NULL; gl_debug (DEBUG_PRINT, "START"); @@ -339,7 +379,6 @@ print_info_new (GnomePrintMaster * master, pi->config = gnome_print_master_get_config (master); if ((template != NULL) && (template->page_size != NULL)) { - const GnomePrintPaper *paper = NULL; gl_debug (DEBUG_PRINT, "setting page size = \"%s\"", template->page_size); @@ -364,14 +403,20 @@ print_info_new (GnomePrintMaster * master, paper->height, GNOME_PRINT_PS_UNIT); } else { + g_warning ("Cannot determine correct page size."); + paper = gnome_print_paper_get_by_name (GL_PRINT_DEFAULT_PAPER); gnome_print_config_set (pi->config, GNOME_PRINT_KEY_PAPER_SIZE, GL_PRINT_DEFAULT_PAPER); } + pi->page_width = paper->width; + pi->page_height = paper->height; pi->template = template; pi->label_rotate_flag = gl_label_get_rotate_flag (label); + pi->sheet = 0; + gl_debug (DEBUG_PRINT, "END"); return pi; @@ -381,7 +426,7 @@ print_info_new (GnomePrintMaster * master, /* PRIVATE. free print info structure */ /*---------------------------------------------------------------------------*/ static void -print_info_free (PrintInfo ** pi) +print_info_free (PrintInfo **pi) { gl_debug (DEBUG_PRINT, "START"); @@ -395,6 +440,34 @@ print_info_free (PrintInfo ** pi) gl_debug (DEBUG_PRINT, "END"); } +/*---------------------------------------------------------------------------*/ +/* PRIVATE. Begin a new page. */ +/*---------------------------------------------------------------------------*/ +static void +print_page_begin (PrintInfo *pi) +{ + gchar *str; + + pi->sheet++; + + str = g_strdup_printf ("sheet%02d", pi->sheet); + gnome_print_beginpage (pi->pc, str); + g_free (str); + + /* Translate and scale, so that our origin is at the upper left. */ + gnome_print_translate (pi->pc, 0.0, pi->page_height); + gnome_print_scale (pi->pc, 1.0, -1.0); +} + +/*---------------------------------------------------------------------------*/ +/* PRIVATE. End a page. */ +/*---------------------------------------------------------------------------*/ +static void +print_page_end (PrintInfo *pi) +{ + gnome_print_showpage (pi->pc); +} + /*---------------------------------------------------------------------------*/ /* PRIVATE. Print i'th label. */ /*---------------------------------------------------------------------------*/ @@ -407,7 +480,6 @@ print_label (PrintInfo *pi, gboolean outline_flag, gboolean reverse_flag) { - gdouble a[6]; gdouble width, height; glTemplate *template; @@ -425,17 +497,10 @@ print_label (PrintInfo *pi, if (gl_label_get_rotate_flag (label)) { gl_debug (DEBUG_PRINT, "Rotate flag set"); gnome_print_rotate (pi->pc, 90.0); - gnome_print_scale (pi->pc, 1.0, -1.0); - } else { - gl_debug (DEBUG_PRINT, "Rotate flag NOT set"); - art_affine_scale (a, 1.0, -1.0); - a[5] = height; - gnome_print_concat (pi->pc, a); } if ( reverse_flag ) { gnome_print_translate (pi->pc, width, 0.0); - art_affine_scale (a, -1.0, 1.0); - gnome_print_concat (pi->pc, a); + gnome_print_scale (pi->pc, -1.0, 1.0); } if (outline_flag) { draw_outline (pi, label); @@ -454,9 +519,9 @@ print_label (PrintInfo *pi, /* PRIVATE. Draw label. */ /*---------------------------------------------------------------------------*/ static void -draw_label (PrintInfo * pi, - glLabel * label, - glMergeRecord * record) +draw_label (PrintInfo *pi, + glLabel *label, + glMergeRecord *record) { GList *p_obj; glLabelObject *object; @@ -490,9 +555,9 @@ draw_label (PrintInfo * pi, /* PRIVATE. Draw text object. */ /*---------------------------------------------------------------------------*/ static void -draw_text_object (PrintInfo * pi, - glLabelText * object, - glMergeRecord * record) +draw_text_object (PrintInfo *pi, + glLabelText *object, + glMergeRecord *record) { GnomeFont *font; gchar **line; @@ -591,8 +656,8 @@ draw_text_object (PrintInfo * pi, /* PRIVATE. Draw box object. */ /*---------------------------------------------------------------------------*/ static void -draw_box_object (PrintInfo * pi, - glLabelBox * object) +draw_box_object (PrintInfo *pi, + glLabelBox *object) { gdouble x, y, w, h; gdouble line_width; @@ -632,8 +697,8 @@ draw_box_object (PrintInfo * pi, /* PRIVATE. Draw line object. */ /*---------------------------------------------------------------------------*/ static void -draw_line_object (PrintInfo * pi, - glLabelLine * object) +draw_line_object (PrintInfo *pi, + glLabelLine *object) { gdouble x, y, w, h; gdouble line_width; @@ -663,8 +728,8 @@ draw_line_object (PrintInfo * pi, /* PRIVATE. Draw ellipse object. */ /*---------------------------------------------------------------------------*/ static void -draw_ellipse_object (PrintInfo * pi, - glLabelEllipse * object) +draw_ellipse_object (PrintInfo *pi, + glLabelEllipse *object) { gdouble x, y, x0, y0, rx, ry, w, h; gdouble line_width; @@ -709,8 +774,8 @@ draw_ellipse_object (PrintInfo * pi, /* PRIVATE. Draw image object. */ /*---------------------------------------------------------------------------*/ static void -draw_image_object (PrintInfo * pi, - glLabelImage * object) +draw_image_object (PrintInfo *pi, + glLabelImage *object) { gdouble x, y, w, h; const GdkPixbuf *pixbuf; @@ -752,9 +817,9 @@ draw_image_object (PrintInfo * pi, /* PRIVATE. Draw box object. */ /*---------------------------------------------------------------------------*/ static void -draw_barcode_object (PrintInfo * pi, - glLabelBarcode * object, - glMergeRecord * record) +draw_barcode_object (PrintInfo *pi, + glLabelBarcode *object, + glMergeRecord *record) { glBarcode *gbc; glBarcodeLine *line; @@ -863,8 +928,8 @@ draw_barcode_object (PrintInfo * pi, /* PRIVATE. Draw outline. */ /*---------------------------------------------------------------------------*/ static void -draw_outline (PrintInfo * pi, - glLabel * label) +draw_outline (PrintInfo *pi, + glLabel *label) { gdouble w, h, r; gdouble r1, r2; @@ -925,8 +990,8 @@ draw_outline (PrintInfo * pi, /* PRIVATE. Clip to outline. */ /*---------------------------------------------------------------------------*/ static void -clip_to_outline (PrintInfo * pi, - glLabel * label) +clip_to_outline (PrintInfo *pi, + glLabel *label) { gdouble w, h, r; gdouble r1; @@ -978,11 +1043,11 @@ clip_to_outline (PrintInfo * pi, /* PRIVATE. Path creation utilities. */ /*---------------------------------------------------------------------------*/ static void -create_rectangle_path (GnomePrintContext * pc, - gdouble x0, - gdouble y0, - gdouble w, - gdouble h) +create_rectangle_path (GnomePrintContext *pc, + gdouble x0, + gdouble y0, + gdouble w, + gdouble h) { gl_debug (DEBUG_PRINT, "START"); @@ -998,11 +1063,11 @@ create_rectangle_path (GnomePrintContext * pc, } static void -create_ellipse_path (GnomePrintContext * pc, - gdouble x0, - gdouble y0, - gdouble rx, - gdouble ry) +create_ellipse_path (GnomePrintContext *pc, + gdouble x0, + gdouble y0, + gdouble rx, + gdouble ry) { gdouble x, y; gint i_theta; @@ -1022,12 +1087,12 @@ create_ellipse_path (GnomePrintContext * pc, } static void -create_rounded_rectangle_path (GnomePrintContext * pc, - gdouble x0, - gdouble y0, - gdouble w, - gdouble h, - gdouble r) +create_rounded_rectangle_path (GnomePrintContext *pc, + gdouble x0, + gdouble y0, + gdouble w, + gdouble h, + gdouble r) { gdouble x, y; gint i_theta; diff --git a/glabels2/src/print.h b/glabels2/src/print.h index b79e5c55..a6e6d589 100644 --- a/glabels2/src/print.h +++ b/glabels2/src/print.h @@ -27,27 +27,39 @@ #include #include "label.h" -extern void gl_print_simple (GnomePrintMaster * master, glLabel * label, - gint n_sheets, gint first, gint last, - gboolean outline_flag, gboolean reverse_flag); - -extern void gl_print_merge_collated (GnomePrintMaster * master, - glLabel * label, - GList *record_list, - gint n_copies, gint first, - gboolean outline_flag, - gboolean reverse_flag); - -extern void gl_print_merge_uncollated (GnomePrintMaster * master, - glLabel * label, - GList *record_list, - gint n_copies, gint first, - gboolean outline_flag, - gboolean reverse_flag); - -extern void gl_print_batch (GnomePrintMaster * master, glLabel * label, - gint n_sheets, gint n_copies, - gboolean outline_flag, gboolean reverse_flag); +G_BEGIN_DECLS +void gl_print_simple (GnomePrintMaster *master, + glLabel *label, + gint n_sheets, + gint first, + gint last, + gboolean outline_flag, + gboolean reverse_flag); + +void gl_print_merge_collated (GnomePrintMaster *master, + glLabel *label, + GList *record_list, + gint n_copies, + gint first, + gboolean outline_flag, + gboolean reverse_flag); + +void gl_print_merge_uncollated (GnomePrintMaster *master, + glLabel *label, + GList *record_list, + gint n_copies, + gint first, + gboolean outline_flag, + gboolean reverse_flag); + +void gl_print_batch (GnomePrintMaster *master, + glLabel *label, + gint n_sheets, + gint n_bcopies, + gboolean outline_flag, + gboolean reverse_flag); + +G_END_DECLS #endif diff --git a/glabels2/src/template.c b/glabels2/src/template.c index f625681f..0402afd6 100644 --- a/glabels2/src/template.c +++ b/glabels2/src/template.c @@ -1051,9 +1051,9 @@ compare_origins (gconstpointer a, const glTemplateOrigin *a_origin = a, *b_origin = b; if ( a_origin->y < b_origin->y ) { - return +1; - } else if ( a_origin->y > b_origin->y ) { return -1; + } else if ( a_origin->y > b_origin->y ) { + return +1; } else { if ( a_origin->x < b_origin->x ) { return -1; diff --git a/glabels2/src/wdgt-mini-preview.c b/glabels2/src/wdgt-mini-preview.c index 51a97d38..b6c99772 100644 --- a/glabels2/src/wdgt-mini-preview.c +++ b/glabels2/src/wdgt-mini-preview.c @@ -329,7 +329,7 @@ mini_outline_list_new (GnomeCanvas *canvas, GList *list = NULL; gint i, n_labels; glTemplateOrigin *origins; - gdouble x1, y1, x2, y2, y_temp, w, h; + gdouble x1, y1, x2, y2, w, h; const GnomePrintPaper *paper = NULL; gdouble paper_height; @@ -352,12 +352,6 @@ mini_outline_list_new (GnomeCanvas *canvas, x2 = x1 + w; y2 = y1 + h; - /* 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->label.style) { case GL_TEMPLATE_STYLE_RECT: item = gnome_canvas_item_new (group,