3 * Copyright (C) 2001-2009 Jim Evins <evins@snaught.com>.
5 * This file is part of gLabels.
7 * gLabels is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * gLabels is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with gLabels. If not, see <http://www.gnu.org/licenses/>.
23 #include "mini-preview.h"
26 #include <glib/gi18n.h>
28 #include <libglabels.h>
29 #include "cairo-label-path.h"
37 /*===========================================*/
38 /* Private macros and constants. */
39 /*===========================================*/
42 #define SHADOW_OFFSET 3
44 #define ARROW_SCALE 0.35
45 #define UP_FONT_FAMILY "Sans"
48 /*===========================================*/
50 /*===========================================*/
64 struct _glMiniPreviewPrivate {
68 lglTemplate *template;
69 gint labels_per_sheet;
80 gboolean draw_arrow_flag;
83 gboolean update_scheduled_flag;
91 gboolean collate_flag;
92 gboolean outline_flag;
93 gboolean reverse_flag;
94 gboolean crop_marks_flag;
98 /*===========================================*/
100 /*===========================================*/
102 static gint mini_preview_signals[LAST_SIGNAL] = { 0 };
105 /*===========================================*/
106 /* Local function prototypes */
107 /*===========================================*/
109 static void gl_mini_preview_finalize (GObject *object);
111 static void gl_mini_preview_construct (glMiniPreview *this,
115 static gboolean button_press_event_cb (GtkWidget *widget,
116 GdkEventButton *event);
117 static gboolean motion_notify_event_cb (GtkWidget *widget,
118 GdkEventMotion *event);
119 static gboolean button_release_event_cb (GtkWidget *widget,
120 GdkEventButton *event);
123 static gboolean draw_cb (GtkWidget *widget,
125 glMiniPreview *this);
126 static void style_set_cb (GtkWidget *widget,
127 GtkStyle *previous_style,
128 glMiniPreview *this);
130 static void redraw (glMiniPreview *this);
131 static void draw (glMiniPreview *this,
134 static void draw_shadow (glMiniPreview *this,
140 static void draw_paper (glMiniPreview *this,
145 static void draw_labels (glMiniPreview *this,
147 lglTemplate *template,
149 static void draw_arrow (glMiniPreview *this,
152 static void draw_rich_preview (glMiniPreview *this,
156 static gint find_closest_label (glMiniPreview *this,
160 static gdouble set_transform_and_get_scale (glMiniPreview *this,
164 /****************************************************************************/
165 /* Object infrastructure. */
166 /****************************************************************************/
167 G_DEFINE_TYPE (glMiniPreview, gl_mini_preview, GTK_TYPE_EVENT_BOX)
170 /*****************************************************************************/
171 /* Class Init Function. */
172 /*****************************************************************************/
174 gl_mini_preview_class_init (glMiniPreviewClass *class)
176 GObjectClass *object_class = G_OBJECT_CLASS (class);
177 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
179 gl_debug (DEBUG_MINI_PREVIEW, "START");
181 gl_mini_preview_parent_class = g_type_class_peek_parent (class);
183 object_class->finalize = gl_mini_preview_finalize;
185 widget_class->button_press_event = button_press_event_cb;
186 widget_class->motion_notify_event = motion_notify_event_cb;
187 widget_class->button_release_event = button_release_event_cb;
189 mini_preview_signals[CLICKED] =
190 g_signal_new ("clicked",
191 G_OBJECT_CLASS_TYPE(object_class),
193 G_STRUCT_OFFSET (glMiniPreviewClass, clicked),
195 gl_marshal_VOID__INT,
196 G_TYPE_NONE, 1, G_TYPE_INT);
198 mini_preview_signals[PRESSED] =
199 g_signal_new ("pressed",
200 G_OBJECT_CLASS_TYPE(object_class),
202 G_STRUCT_OFFSET (glMiniPreviewClass, pressed),
204 gl_marshal_VOID__INT_INT,
205 G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
207 mini_preview_signals[RELEASED] =
208 g_signal_new ("released",
209 G_OBJECT_CLASS_TYPE(object_class),
211 G_STRUCT_OFFSET (glMiniPreviewClass, released),
213 gl_marshal_VOID__INT_INT,
214 G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
216 gl_debug (DEBUG_MINI_PREVIEW, "END");
220 /*****************************************************************************/
221 /* Object Instance Init Function. */
222 /*****************************************************************************/
224 gl_mini_preview_init (glMiniPreview *this)
226 gl_debug (DEBUG_MINI_PREVIEW, "START");
228 this->priv = g_new0 (glMiniPreviewPrivate, 1);
230 gtk_widget_add_events (GTK_WIDGET (this),
231 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
232 GDK_POINTER_MOTION_MASK);
234 gtk_event_box_set_visible_window (GTK_EVENT_BOX (this), FALSE);
236 this->priv->canvas = gtk_drawing_area_new ();
237 gtk_widget_set_has_window(this->priv->canvas, FALSE);
238 gtk_container_add (GTK_CONTAINER (this), this->priv->canvas);
240 g_signal_connect (G_OBJECT (this->priv->canvas), "draw",
241 G_CALLBACK (draw_cb), this);
242 g_signal_connect (G_OBJECT (this->priv->canvas), "style-set",
243 G_CALLBACK (style_set_cb), this);
245 gl_debug (DEBUG_MINI_PREVIEW, "END");
249 /*****************************************************************************/
250 /* Finalize Method. */
251 /*****************************************************************************/
253 gl_mini_preview_finalize (GObject *object)
255 glMiniPreview *this = GL_MINI_PREVIEW (object);
257 gl_debug (DEBUG_MINI_PREVIEW, "START");
259 g_return_if_fail (object != NULL);
260 g_return_if_fail (GL_IS_MINI_PREVIEW (object));
262 if (this->priv->label)
264 g_object_unref (this->priv->label);
266 lgl_template_free (this->priv->template);
267 g_free (this->priv->centers);
270 G_OBJECT_CLASS (gl_mini_preview_parent_class)->finalize (object);
272 gl_debug (DEBUG_MINI_PREVIEW, "END");
276 /*****************************************************************************/
277 /** New Object Generator. */
278 /*****************************************************************************/
280 gl_mini_preview_new (gint height,
285 gl_debug (DEBUG_MINI_PREVIEW, "START");
287 this = g_object_new (gl_mini_preview_get_type (), NULL);
289 gl_mini_preview_construct (this, height, width);
291 gl_debug (DEBUG_MINI_PREVIEW, "END");
293 return GTK_WIDGET (this);
297 /*--------------------------------------------------------------------------*/
298 /* Construct composite widget. */
299 /*--------------------------------------------------------------------------*/
301 gl_mini_preview_construct (glMiniPreview *this,
305 gl_debug (DEBUG_MINI_PREVIEW, "START");
307 gtk_widget_set_size_request (GTK_WIDGET (this->priv->canvas), width, height);
309 gl_debug (DEBUG_MINI_PREVIEW, "END");
313 /****************************************************************************/
314 /* Set template for mini-preview to determine geometry. */
315 /****************************************************************************/
317 gl_mini_preview_set_by_name (glMiniPreview *this,
320 lglTemplate *template;
322 gl_debug (DEBUG_MINI_PREVIEW, "START");
325 template = lgl_db_lookup_template_from_name (name);
327 gl_mini_preview_set_template (this, template);
329 lgl_template_free (template);
331 gl_debug (DEBUG_MINI_PREVIEW, "END");
335 /****************************************************************************/
336 /* Set template for mini-preview to determine geometry. */
337 /****************************************************************************/
339 gl_mini_preview_set_template (glMiniPreview *this,
340 const lglTemplate *template)
342 const lglTemplateFrame *frame;
343 lglTemplateOrigin *origins;
347 gl_debug (DEBUG_MINI_PREVIEW, "START");
349 frame = (lglTemplateFrame *)template->frames->data;
354 lgl_template_free (this->priv->template);
355 this->priv->template = lgl_template_dup (template);
358 * Set labels per sheet
360 this->priv->labels_per_sheet = lgl_template_frame_get_n_labels (frame);
365 g_free (this->priv->centers);
366 this->priv->centers = g_new0 (LabelCenter, this->priv->labels_per_sheet);
367 origins = lgl_template_frame_get_origins (frame);
368 lgl_template_frame_get_size (frame, &w, &h);
369 for ( i=0; i<this->priv->labels_per_sheet; i++ )
371 this->priv->centers[i].x = origins[i].x + w/2.0;
372 this->priv->centers[i].y = origins[i].y + h/2.0;
377 * Redraw modified preview
381 gl_debug (DEBUG_MINI_PREVIEW, "END");
385 /****************************************************************************/
386 /* Highlight given label outlines. */
387 /****************************************************************************/
389 gl_mini_preview_highlight_range (glMiniPreview *this,
393 gl_debug (DEBUG_MINI_PREVIEW, "START");
395 if ( (first_label != this->priv->highlight_first) ||
396 (last_label != this->priv->highlight_last) )
399 this->priv->highlight_first = first_label;
400 this->priv->highlight_last = last_label;
406 gl_debug (DEBUG_MINI_PREVIEW, "END");
410 /****************************************************************************/
411 /* Set draw arrow. */
412 /****************************************************************************/
414 gl_mini_preview_set_draw_arrow (glMiniPreview *this,
415 gboolean draw_arrow_flag)
417 if ( draw_arrow_flag != this->priv->draw_arrow_flag )
419 this->priv->draw_arrow_flag = draw_arrow_flag;
425 /****************************************************************************/
426 /* Set rotate flag. */
427 /****************************************************************************/
429 gl_mini_preview_set_rotate (glMiniPreview *this,
430 gboolean rotate_flag)
432 if ( rotate_flag != this->priv->rotate_flag )
434 this->priv->rotate_flag = rotate_flag;
440 /****************************************************************************/
442 /****************************************************************************/
444 gl_mini_preview_set_label (glMiniPreview *this,
447 if ( this->priv->label )
449 g_object_unref (this->priv->label);
451 this->priv->label = g_object_ref (label);
456 /****************************************************************************/
457 /* Set page number. */
458 /****************************************************************************/
460 gl_mini_preview_set_page (glMiniPreview *this,
463 if ( page != this->priv->page )
465 this->priv->page = page;
471 /****************************************************************************/
472 /* Set number of sheets. */
473 /****************************************************************************/
475 gl_mini_preview_set_n_sheets (glMiniPreview *this,
478 if ( n_sheets != this->priv->n_sheets )
480 this->priv->n_sheets = n_sheets;
486 /****************************************************************************/
487 /* Set number of copies (merge only). */
488 /****************************************************************************/
490 gl_mini_preview_set_n_copies (glMiniPreview *this,
493 if ( n_copies != this->priv->n_copies )
495 this->priv->n_copies = n_copies;
501 /****************************************************************************/
502 /* Set first label number on first sheet. */
503 /****************************************************************************/
505 gl_mini_preview_set_first (glMiniPreview *this,
508 if ( first != this->priv->first )
510 this->priv->first = first;
516 /****************************************************************************/
517 /* Set last label number on first sheet (non-merge only). */
518 /****************************************************************************/
520 gl_mini_preview_set_last (glMiniPreview *this,
523 if ( last != this->priv->last )
525 this->priv->last = last;
531 /****************************************************************************/
532 /* Set collate flag (merge only). */
533 /****************************************************************************/
535 gl_mini_preview_set_collate_flag (glMiniPreview *this,
536 gboolean collate_flag)
538 if ( collate_flag != this->priv->collate_flag )
540 this->priv->collate_flag = collate_flag;
546 /****************************************************************************/
547 /* Set outline flag. */
548 /****************************************************************************/
550 gl_mini_preview_set_outline_flag (glMiniPreview *this,
551 gboolean outline_flag)
553 if ( outline_flag != this->priv->outline_flag )
555 this->priv->outline_flag = outline_flag;
561 /****************************************************************************/
562 /* Set reverse flag. */
563 /****************************************************************************/
565 gl_mini_preview_set_reverse_flag (glMiniPreview *this,
566 gboolean reverse_flag)
568 if ( reverse_flag != this->priv->reverse_flag )
570 this->priv->reverse_flag = reverse_flag;
576 /****************************************************************************/
577 /* Set crop marks flag. */
578 /****************************************************************************/
580 gl_mini_preview_set_crop_marks_flag (glMiniPreview *this,
581 gboolean crop_marks_flag)
583 if ( crop_marks_flag != this->priv->crop_marks_flag )
585 this->priv->crop_marks_flag = crop_marks_flag;
591 /*--------------------------------------------------------------------------*/
592 /* Set transformation and return scale. */
593 /*--------------------------------------------------------------------------*/
595 set_transform_and_get_scale (glMiniPreview *this,
598 lglTemplate *template = this->priv->template;
599 GtkAllocation allocation;
602 gdouble offset_x, offset_y;
604 /* Establish scale and origin. */
605 gtk_widget_get_allocation (GTK_WIDGET (this), &allocation);
606 w = allocation.width;
607 h = allocation.height;
609 /* establish scale. */
610 scale = MIN( (w - 2*MARGIN - 2*SHADOW_OFFSET)/template->page_width,
611 (h - 2*MARGIN - 2*SHADOW_OFFSET)/template->page_height );
613 /* Find offset to center preview. */
614 offset_x = (w/scale - template->page_width) / 2.0;
615 offset_y = (h/scale - template->page_height) / 2.0;
617 /* Set transformation. */
618 cairo_scale (cr, scale, scale);
619 cairo_translate (cr, offset_x, offset_y);
625 /*--------------------------------------------------------------------------*/
626 /* Button press event handler */
627 /*--------------------------------------------------------------------------*/
629 button_press_event_cb (GtkWidget *widget,
630 GdkEventButton *event)
632 glMiniPreview *this = GL_MINI_PREVIEW (widget);
638 gl_debug (DEBUG_MINI_PREVIEW, "START");
640 if ( event->button == 1 )
643 window = gtk_widget_get_window (this->priv->canvas);
645 cr = gdk_cairo_create (window);
647 set_transform_and_get_scale (this, cr);
651 cairo_device_to_user (cr, &x, &y);
653 i = find_closest_label (this, x, y);
655 g_signal_emit (G_OBJECT(this),
656 mini_preview_signals[CLICKED],
659 this->priv->first_i = i;
660 this->priv->last_i = i;
661 g_signal_emit (G_OBJECT(this),
662 mini_preview_signals[PRESSED],
663 0, this->priv->first_i, this->priv->last_i);
665 this->priv->dragging = TRUE;
666 this->priv->prev_i = i;
671 gl_debug (DEBUG_MINI_PREVIEW, "END");
676 /*--------------------------------------------------------------------------*/
677 /* Motion notify event handler */
678 /*--------------------------------------------------------------------------*/
680 motion_notify_event_cb (GtkWidget *widget,
681 GdkEventMotion *event)
683 glMiniPreview *this = GL_MINI_PREVIEW (widget);
689 gl_debug (DEBUG_MINI_PREVIEW, "START");
691 if (this->priv->dragging)
693 window = gtk_widget_get_window (this->priv->canvas);
695 cr = gdk_cairo_create (window);
697 set_transform_and_get_scale (this, cr);
701 cairo_device_to_user (cr, &x, &y);
703 i = find_closest_label (this, x, y);
705 if ( i != this->priv->prev_i )
707 this->priv->last_i = i;
709 g_signal_emit (G_OBJECT(this),
710 mini_preview_signals[PRESSED],
712 MIN (this->priv->first_i, this->priv->last_i),
713 MAX (this->priv->first_i, this->priv->last_i));
715 this->priv->prev_i = i;
720 gl_debug (DEBUG_MINI_PREVIEW, "END");
725 /*--------------------------------------------------------------------------*/
726 /* Button release event handler */
727 /*--------------------------------------------------------------------------*/
729 button_release_event_cb (GtkWidget *widget,
730 GdkEventButton *event)
732 glMiniPreview *this = GL_MINI_PREVIEW (widget);
734 gl_debug (DEBUG_MINI_PREVIEW, "START");
736 if ( event->button == 1 )
738 this->priv->dragging = FALSE;
742 g_signal_emit (G_OBJECT(this),
743 mini_preview_signals[RELEASED],
744 0, this->priv->first_i, this->priv->last_i);
746 gl_debug (DEBUG_MINI_PREVIEW, "END");
751 /*--------------------------------------------------------------------------*/
752 /* Find index+1 of label closest to given coordinates. */
753 /*--------------------------------------------------------------------------*/
755 find_closest_label (glMiniPreview *this,
761 gdouble dx, dy, d2, min_d2;
763 dx = x - this->priv->centers[0].x;
764 dy = y - this->priv->centers[0].y;
765 min_d2 = dx*dx + dy*dy;
768 for ( i=1; i<this->priv->labels_per_sheet; i++ )
770 dx = x - this->priv->centers[i].x;
771 dy = y - this->priv->centers[i].y;
785 /*--------------------------------------------------------------------------*/
786 /* Expose event handler. */
787 /*--------------------------------------------------------------------------*/
789 draw_cb (GtkWidget *widget,
793 gl_debug (DEBUG_MINI_PREVIEW, "START");
795 this->priv->update_scheduled_flag = FALSE;
798 gl_debug (DEBUG_MINI_PREVIEW, "END");
803 /*--------------------------------------------------------------------------*/
804 /* Style set handler (updates colors when style/theme changes). */
805 /*--------------------------------------------------------------------------*/
807 style_set_cb (GtkWidget *widget,
808 GtkStyle *previous_style,
811 gl_debug (DEBUG_MINI_PREVIEW, "START");
815 gl_debug (DEBUG_MINI_PREVIEW, "END");
819 /*--------------------------------------------------------------------------*/
821 /*--------------------------------------------------------------------------*/
823 redraw (glMiniPreview *this)
826 GtkAllocation allocation;
828 gl_debug (DEBUG_MINI_PREVIEW, "START");
830 window = gtk_widget_get_window (this->priv->canvas);
835 if ( !this->priv->update_scheduled_flag )
837 this->priv->update_scheduled_flag = TRUE;
839 gtk_widget_get_allocation (GTK_WIDGET (this), &allocation);
840 gdk_window_invalidate_rect (window, &allocation, FALSE);
844 gl_debug (DEBUG_MINI_PREVIEW, "END");
848 /*--------------------------------------------------------------------------*/
849 /* Draw mini preview. */
850 /*--------------------------------------------------------------------------*/
852 draw (glMiniPreview *this,
855 lglTemplate *template = this->priv->template;
857 gdouble shadow_x, shadow_y;
860 gl_debug (DEBUG_MINI_PREVIEW, "START");
865 scale = set_transform_and_get_scale (this, cr);
868 shadow_x = SHADOW_OFFSET/scale;
869 shadow_y = SHADOW_OFFSET/scale;
871 draw_shadow (this, cr,
873 template->page_width, template->page_height);
875 draw_paper (this, cr,
876 template->page_width, template->page_height,
879 draw_labels (this, cr, template, 2.0/scale);
881 if (this->priv->draw_arrow_flag)
883 draw_arrow (this, cr);
886 if (this->priv->label)
888 draw_rich_preview (this, cr);
893 gl_debug (DEBUG_MINI_PREVIEW, "END");
898 /*--------------------------------------------------------------------------*/
899 /* Draw page shadow */
900 /*--------------------------------------------------------------------------*/
902 draw_shadow (glMiniPreview *this,
912 gl_debug (DEBUG_MINI_PREVIEW, "START");
916 cairo_rectangle (cr, x, y, width, height);
918 style = gtk_widget_get_style (GTK_WIDGET(this));
919 shadow_color = gl_color_from_gdk_color (&style->dark[GTK_STATE_NORMAL]);
920 cairo_set_source_rgb (cr, GL_COLOR_RGB_ARGS (shadow_color));
926 gl_debug (DEBUG_MINI_PREVIEW, "END");
930 /*--------------------------------------------------------------------------*/
932 /*--------------------------------------------------------------------------*/
934 draw_paper (glMiniPreview *this,
941 guint paper_color, outline_color;
943 gl_debug (DEBUG_MINI_PREVIEW, "START");
947 style = gtk_widget_get_style (GTK_WIDGET(this));
948 paper_color = gl_color_from_gdk_color (&style->light[GTK_STATE_NORMAL]);
949 outline_color = gl_color_from_gdk_color (&style->fg[GTK_STATE_NORMAL]);
951 cairo_rectangle (cr, 0.0, 0.0, width, height);
953 cairo_set_source_rgb (cr, GL_COLOR_RGB_ARGS (paper_color));
954 cairo_fill_preserve (cr);
956 cairo_set_source_rgb (cr, GL_COLOR_RGB_ARGS (outline_color));
957 cairo_set_line_width (cr, line_width);
962 gl_debug (DEBUG_MINI_PREVIEW, "END");
966 /*--------------------------------------------------------------------------*/
968 /*--------------------------------------------------------------------------*/
970 draw_labels (glMiniPreview *this,
972 lglTemplate *template,
975 const lglTemplateFrame *frame;
977 lglTemplateOrigin *origins;
980 guint highlight_color, outline_color;
982 gl_debug (DEBUG_MINI_PREVIEW, "START");
984 frame = (lglTemplateFrame *)template->frames->data;
986 n_labels = lgl_template_frame_get_n_labels (frame);
987 origins = lgl_template_frame_get_origins (frame);
989 style = gtk_widget_get_style (GTK_WIDGET(this));
990 base_color = gl_color_from_gdk_color (&style->base[GTK_STATE_SELECTED]);
992 highlight_color = gl_color_set_opacity (base_color, 0.10);
993 if (this->priv->label)
995 /* Outlines are more subtle when doing a rich preview. */
996 outline_color = gl_color_set_opacity (base_color, 0.25);
1000 outline_color = gl_color_set_opacity (base_color, 1.00);
1003 for ( i=0; i < n_labels; i++ ) {
1007 cairo_translate (cr, origins[i].x, origins[i].y);
1008 gl_cairo_label_path (cr, template, FALSE, FALSE);
1010 if ( ((i+1) >= this->priv->highlight_first) &&
1011 ((i+1) <= this->priv->highlight_last) )
1013 cairo_set_source_rgba (cr, GL_COLOR_RGBA_ARGS (highlight_color));
1014 cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
1015 cairo_fill_preserve (cr);
1018 cairo_set_line_width (cr, line_width);
1019 cairo_set_source_rgba (cr, GL_COLOR_RGBA_ARGS (outline_color));
1028 gl_debug (DEBUG_MINI_PREVIEW, "END");
1032 /*--------------------------------------------------------------------------*/
1033 /* Draw arrow to indicate top of labels. */
1034 /*--------------------------------------------------------------------------*/
1036 draw_arrow (glMiniPreview *this,
1039 lglTemplateFrame *frame;
1040 lglTemplateOrigin *origins;
1041 gdouble width, height, min;
1044 guint base_color, arrow_color;
1046 PangoLayout *layout;
1047 PangoFontDescription *desc;
1048 PangoRectangle rect;
1050 /* Translators: "Up" refers to the direction towards the top of a label. */
1051 const gchar *up = _("Up");
1053 frame = (lglTemplateFrame *)this->priv->template->frames->data;
1055 lgl_template_frame_get_size (frame, &width, &height);
1057 if ( width != height )
1060 origins = lgl_template_frame_get_origins (frame);
1063 min = MIN (width, height);
1068 style = gtk_widget_get_style (GTK_WIDGET(this));
1069 base_color = gl_color_from_gdk_color (&style->base[GTK_STATE_SELECTED]);
1070 arrow_color = gl_color_set_opacity (base_color, 0.25);
1071 cairo_set_source_rgba (cr, GL_COLOR_RGBA_ARGS (arrow_color));
1073 cairo_translate (cr, x0 + width/2, y0 + height/2);
1074 cairo_scale (cr, 1, -1);
1075 if ( this->priv->rotate_flag )
1077 cairo_rotate (cr, -G_PI/2.0);
1080 cairo_new_path (cr);
1081 cairo_move_to (cr, 0, -min*ARROW_SCALE/3);
1082 cairo_line_to (cr, 0, min*ARROW_SCALE);
1084 cairo_new_sub_path (cr);
1085 cairo_move_to (cr, -min*ARROW_SCALE/2, min*ARROW_SCALE/2);
1086 cairo_line_to (cr, 0, min*ARROW_SCALE);
1087 cairo_line_to (cr, min*ARROW_SCALE/2, min*ARROW_SCALE/2);
1089 cairo_set_line_width (cr, 0.25*min*ARROW_SCALE);
1093 layout = pango_cairo_create_layout (cr);
1095 desc = pango_font_description_new ();
1096 pango_font_description_set_family (desc, UP_FONT_FAMILY);
1097 pango_font_description_set_weight (desc, PANGO_WEIGHT_BOLD);
1098 pango_font_description_set_size (desc, min*UP_SCALE*PANGO_SCALE);
1099 pango_layout_set_font_description (layout, desc);
1100 pango_font_description_free (desc);
1102 pango_layout_set_text (layout, up, -1);
1103 pango_layout_set_width (layout, -1);
1104 pango_layout_get_pixel_extents (layout, NULL, &rect);
1106 cairo_move_to (cr, -rect.width/2, -min/4+rect.height/2);
1108 cairo_scale (cr, 1, -1);
1109 pango_cairo_show_layout (cr, layout);
1117 /*--------------------------------------------------------------------------*/
1118 /* Draw rich preview using print renderers. */
1119 /*--------------------------------------------------------------------------*/
1121 draw_rich_preview (glMiniPreview *this,
1127 merge = gl_label_get_merge (this->priv->label);
1131 gl_print_simple_sheet (this->priv->label,
1134 this->priv->n_sheets,
1137 this->priv->outline_flag,
1138 this->priv->reverse_flag,
1139 this->priv->crop_marks_flag);
1143 /* FIXME: maybe the renderers should be more self contained.
1144 * This will only work for the first page, since
1145 * previous pages must be rendered to establish
1149 state.p_record = (GList *)gl_merge_get_record_list (merge);
1151 if (this->priv->collate_flag)
1153 gl_print_collated_merge_sheet (this->priv->label,
1156 this->priv->n_copies,
1158 this->priv->outline_flag,
1159 this->priv->reverse_flag,
1160 this->priv->crop_marks_flag,
1165 gl_print_uncollated_merge_sheet (this->priv->label,
1168 this->priv->n_copies,
1170 this->priv->outline_flag,
1171 this->priv->reverse_flag,
1172 this->priv->crop_marks_flag,
1181 * Local Variables: -- emacs
1183 * c-basic-offset: 8 -- emacs
1184 * tab-width: 8 -- emacs
1185 * indent-tabs-mode: nil -- emacs