]> git.sur5r.net Git - glabels/blob - glabels2/src/mini-preview.c
2009-09-17 Jim Evins <evins@snaught.com>
[glabels] / glabels2 / src / mini-preview.c
1 /*
2  *  mini-preview.c
3  *  Copyright (C) 2001-2009  Jim Evins <evins@snaught.com>.
4  *
5  *  This file is part of gLabels.
6  *
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.
11  *
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.
16  *
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/>.
19  */
20
21 #include <config.h>
22
23 #include "mini-preview.h"
24
25 #include <math.h>
26
27 #include "libglabels/db.h"
28 #include "cairo-label-path.h"
29 #include "marshal.h"
30 #include "color.h"
31
32 #include "debug.h"
33
34
35 /*===========================================*/
36 /* Private macros and constants.             */
37 /*===========================================*/
38
39 #define MARGIN 2
40 #define SHADOW_OFFSET 3
41
42
43 /*===========================================*/
44 /* Private types                             */
45 /*===========================================*/
46
47 enum {
48         CLICKED,
49         PRESSED,
50         LAST_SIGNAL
51 };
52
53 typedef struct {
54         gdouble x;
55         gdouble y;
56 } LabelCenter;
57
58 struct _glMiniPreviewPrivate {
59
60         GtkWidget      *canvas;
61
62         lglTemplate    *template;
63         gint            labels_per_sheet;
64         LabelCenter    *centers;
65
66         gint            highlight_first;
67         gint            highlight_last;
68
69         gboolean        dragging;
70         gint            first_i;
71         gint            last_i;
72         gint            prev_i;
73 };
74
75
76 /*===========================================*/
77 /* Private globals                           */
78 /*===========================================*/
79
80 static gint mini_preview_signals[LAST_SIGNAL] = { 0 };
81
82
83 /*===========================================*/
84 /* Local function prototypes                 */
85 /*===========================================*/
86
87 static void     gl_mini_preview_finalize       (GObject                *object);
88
89 static void     gl_mini_preview_construct      (glMiniPreview          *this,
90                                                 gint                    height,
91                                                 gint                    width);
92
93 static gboolean button_press_event_cb          (GtkWidget              *widget,
94                                                 GdkEventButton         *event);
95 static gboolean motion_notify_event_cb         (GtkWidget              *widget,
96                                                 GdkEventMotion         *event);
97 static gboolean button_release_event_cb        (GtkWidget              *widget,
98                                                 GdkEventButton         *event);
99
100
101 static gboolean expose_event_cb                (GtkWidget              *widget,
102                                                 GdkEventExpose         *event,
103                                                 glMiniPreview          *this);
104 static void     style_set_cb                   (GtkWidget              *widget,
105                                                 GtkStyle               *previous_style,
106                                                 glMiniPreview          *this);
107
108 static void     redraw                         (glMiniPreview          *this);
109 static void     draw                           (glMiniPreview          *this,
110                                                 cairo_t                *cr);
111
112 static void     draw_shadow                    (glMiniPreview          *this,
113                                                 cairo_t                *cr,
114                                                 gdouble                 x,
115                                                 gdouble                 y,
116                                                 gdouble                 width,
117                                                 gdouble                 height);
118 static void     draw_paper                     (glMiniPreview          *this,
119                                                 cairo_t                *cr,
120                                                 gdouble                 width,
121                                                 gdouble                 height,
122                                                 gdouble                 line_width);
123 static void     draw_labels                    (glMiniPreview          *this,
124                                                 cairo_t                *cr,
125                                                 lglTemplate            *template,
126                                                 gdouble                 line_width);
127
128 static gint     find_closest_label             (glMiniPreview          *this,
129                                                 gdouble                 x,
130                                                 gdouble                 y);
131
132 static gdouble  set_transform_and_get_scale    (glMiniPreview          *this,
133                                                 cairo_t                *cr);
134
135
136 /****************************************************************************/
137 /* Object infrastructure.                                                   */
138 /****************************************************************************/
139 G_DEFINE_TYPE (glMiniPreview, gl_mini_preview, GTK_TYPE_EVENT_BOX);
140
141
142 /*****************************************************************************/
143 /* Class Init Function.                                                      */
144 /*****************************************************************************/
145 static void
146 gl_mini_preview_class_init (glMiniPreviewClass *class)
147 {
148         GObjectClass   *object_class = G_OBJECT_CLASS (class);
149         GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
150
151         gl_debug (DEBUG_MINI_PREVIEW, "START");
152
153         gl_mini_preview_parent_class = g_type_class_peek_parent (class);
154
155         object_class->finalize = gl_mini_preview_finalize;
156
157         widget_class->button_press_event   = button_press_event_cb;
158         widget_class->motion_notify_event  = motion_notify_event_cb;
159         widget_class->button_release_event = button_release_event_cb;
160
161         mini_preview_signals[CLICKED] =
162             g_signal_new ("clicked",
163                           G_OBJECT_CLASS_TYPE(object_class),
164                           G_SIGNAL_RUN_LAST,
165                           G_STRUCT_OFFSET (glMiniPreviewClass, clicked),
166                           NULL, NULL,
167                           gl_marshal_VOID__INT,
168                           G_TYPE_NONE, 1, G_TYPE_INT);
169
170         mini_preview_signals[PRESSED] =
171             g_signal_new ("pressed",
172                           G_OBJECT_CLASS_TYPE(object_class),
173                           G_SIGNAL_RUN_LAST,
174                           G_STRUCT_OFFSET (glMiniPreviewClass, pressed),
175                           NULL, NULL,
176                           gl_marshal_VOID__INT_INT,
177                           G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
178
179         gl_debug (DEBUG_MINI_PREVIEW, "END");
180 }
181
182
183 /*****************************************************************************/
184 /* Object Instance Init Function.                                            */
185 /*****************************************************************************/
186 static void
187 gl_mini_preview_init (glMiniPreview *this)
188 {
189         gl_debug (DEBUG_MINI_PREVIEW, "START");
190
191         this->priv = g_new0 (glMiniPreviewPrivate, 1);
192
193         gtk_widget_add_events (GTK_WIDGET (this),
194                                GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
195                                GDK_POINTER_MOTION_MASK);
196
197         gtk_event_box_set_visible_window (GTK_EVENT_BOX (this), FALSE);
198
199         this->priv->canvas = gtk_drawing_area_new ();
200         GTK_WIDGET_SET_FLAGS (this->priv->canvas, GTK_NO_WINDOW);
201         gtk_container_add (GTK_CONTAINER (this), this->priv->canvas);
202
203         g_signal_connect (G_OBJECT (this->priv->canvas), "expose-event",
204                           G_CALLBACK (expose_event_cb), this);
205         g_signal_connect (G_OBJECT (this->priv->canvas), "style-set",
206                           G_CALLBACK (style_set_cb), this);
207
208         gl_debug (DEBUG_MINI_PREVIEW, "END");
209 }
210
211
212 /*****************************************************************************/
213 /* Finalize Method.                                                          */
214 /*****************************************************************************/
215 static void
216 gl_mini_preview_finalize (GObject *object)
217 {
218         glMiniPreview *this = GL_MINI_PREVIEW (object);
219
220         gl_debug (DEBUG_MINI_PREVIEW, "START");
221
222         g_return_if_fail (object != NULL);
223         g_return_if_fail (GL_IS_MINI_PREVIEW (object));
224
225         lgl_template_free (this->priv->template);
226         g_free (this->priv->centers);
227         g_free (this->priv);
228
229         G_OBJECT_CLASS (gl_mini_preview_parent_class)->finalize (object);
230
231         gl_debug (DEBUG_MINI_PREVIEW, "END");
232 }
233
234
235 /*****************************************************************************/
236 /** New Object Generator.                                                    */
237 /*****************************************************************************/
238 GtkWidget *
239 gl_mini_preview_new (gint height,
240                      gint width)
241 {
242         glMiniPreview *this;
243
244         gl_debug (DEBUG_MINI_PREVIEW, "START");
245
246         this = g_object_new (gl_mini_preview_get_type (), NULL);
247
248         gl_mini_preview_construct (this, height, width);
249
250         gl_debug (DEBUG_MINI_PREVIEW, "END");
251
252         return GTK_WIDGET (this);
253 }
254
255
256 /*--------------------------------------------------------------------------*/
257 /* Construct composite widget.                                              */
258 /*--------------------------------------------------------------------------*/
259 static void
260 gl_mini_preview_construct (glMiniPreview *this,
261                            gint           height,
262                            gint           width)
263 {
264         gl_debug (DEBUG_MINI_PREVIEW, "START");
265
266         gtk_widget_set_size_request (GTK_WIDGET (this->priv->canvas), width, height);
267
268         gl_debug (DEBUG_MINI_PREVIEW, "END");
269 }
270
271
272 /****************************************************************************/
273 /* Set label for mini-preview to determine geometry.                        */
274 /****************************************************************************/
275 void
276 gl_mini_preview_set_label_by_name (glMiniPreview *this,
277                                    const gchar   *name)
278 {
279         lglTemplate *template;
280
281         gl_debug (DEBUG_MINI_PREVIEW, "START");
282
283         /* Fetch template */
284         template = lgl_db_lookup_template_from_name (name);
285
286         gl_mini_preview_set_template (this, template);
287
288         lgl_template_free (template);
289
290         gl_debug (DEBUG_MINI_PREVIEW, "END");
291 }
292
293
294 /****************************************************************************/
295 /* Set label for mini-preview to determine geometry.                        */
296 /****************************************************************************/
297 void
298 gl_mini_preview_set_template (glMiniPreview     *this,
299                               const lglTemplate *template)
300 {
301         const lglTemplateFrame    *frame;
302         lglTemplateOrigin         *origins;
303         gdouble                    w, h;
304         gint                       i;
305
306         gl_debug (DEBUG_MINI_PREVIEW, "START");
307
308         frame = (lglTemplateFrame *)template->frames->data;
309
310         /*
311          * Set template
312          */
313         lgl_template_free (this->priv->template);
314         this->priv->template = lgl_template_dup (template);
315
316         /*
317          * Set labels per sheet
318          */
319         this->priv->labels_per_sheet = lgl_template_frame_get_n_labels (frame);
320
321         /*
322          * Initialize centers
323          */
324         g_free (this->priv->centers);
325         this->priv->centers = g_new0 (LabelCenter, this->priv->labels_per_sheet);
326         origins = lgl_template_frame_get_origins (frame);
327         lgl_template_frame_get_size (frame, &w, &h);
328         for ( i=0; i<this->priv->labels_per_sheet; i++ )
329         {
330                 this->priv->centers[i].x = origins[i].x + w/2.0;
331                 this->priv->centers[i].y = origins[i].y + h/2.0;
332         }
333         g_free (origins);
334
335         /*
336          * Redraw modified preview
337          */
338         redraw (this);
339
340         gl_debug (DEBUG_MINI_PREVIEW, "END");
341 }
342
343
344 /****************************************************************************/
345 /* Highlight given label outlines.                                          */
346 /****************************************************************************/
347 void
348 gl_mini_preview_highlight_range (glMiniPreview *this,
349                                  gint           first_label,
350                                  gint           last_label)
351 {
352         gl_debug (DEBUG_MINI_PREVIEW, "START");
353
354         this->priv->highlight_first = first_label;
355         this->priv->highlight_last =  last_label;
356
357         redraw (this);
358
359         gl_debug (DEBUG_MINI_PREVIEW, "END");
360 }
361
362
363 /*--------------------------------------------------------------------------*/
364 /* Set transformation and return scale.                                     */
365 /*--------------------------------------------------------------------------*/
366 static gdouble
367 set_transform_and_get_scale (glMiniPreview *this,
368                              cairo_t       *cr)
369 {
370         lglTemplate *template = this->priv->template;
371         gdouble      w, h;
372         gdouble      scale;
373         gdouble      offset_x, offset_y;
374
375         /* Establish scale and origin. */
376         w = GTK_WIDGET (this)->allocation.width;
377         h = GTK_WIDGET (this)->allocation.height;
378
379         /* establish scale. */
380         scale = MIN( (w - 2*MARGIN - 2*SHADOW_OFFSET)/template->page_width,
381                      (h - 2*MARGIN - 2*SHADOW_OFFSET)/template->page_height );
382
383         /* Find offset to center preview. */
384         offset_x = (w/scale - template->page_width) / 2.0;
385         offset_y = (h/scale - template->page_height) / 2.0;
386
387         /* Set transformation. */
388         cairo_scale (cr, scale, scale);
389         cairo_translate (cr, offset_x, offset_y);
390
391         return scale;
392 }
393
394
395 /*--------------------------------------------------------------------------*/
396 /* Button press event handler                                               */
397 /*--------------------------------------------------------------------------*/
398 static gboolean
399 button_press_event_cb (GtkWidget      *widget,
400                        GdkEventButton *event)
401 {
402         glMiniPreview     *this = GL_MINI_PREVIEW (widget);
403         cairo_t           *cr;
404         gdouble            scale;
405         gdouble            x, y;
406         gint               i;
407
408         gl_debug (DEBUG_MINI_PREVIEW, "START");
409
410         if ( event->button == 1 )
411         {
412                 cr = gdk_cairo_create (GTK_WIDGET (this->priv->canvas)->window);
413
414                 scale = set_transform_and_get_scale (this, cr);
415
416                 x = event->x;
417                 y = event->y;
418                 cairo_device_to_user (cr, &x, &y);
419
420                 i = find_closest_label (this, x, y);
421
422                 g_signal_emit (G_OBJECT(this),
423                                mini_preview_signals[CLICKED],
424                                0, i);
425
426                 this->priv->first_i = i;
427                 this->priv->last_i  = i;
428                 g_signal_emit (G_OBJECT(this),
429                                mini_preview_signals[PRESSED],
430                                0, this->priv->first_i, this->priv->last_i);
431
432                 this->priv->dragging = TRUE;
433                 this->priv->prev_i   = i;
434
435                 cairo_destroy (cr);
436         }
437
438         gl_debug (DEBUG_MINI_PREVIEW, "END");
439         return FALSE;
440 }
441
442
443 /*--------------------------------------------------------------------------*/
444 /* Motion notify event handler                                              */
445 /*--------------------------------------------------------------------------*/
446 static gboolean
447 motion_notify_event_cb (GtkWidget      *widget,
448                         GdkEventMotion *event)
449 {
450         glMiniPreview *this = GL_MINI_PREVIEW (widget);
451         cairo_t           *cr;
452         gdouble            scale;
453         gdouble            x, y;
454         gint               i;
455
456         gl_debug (DEBUG_MINI_PREVIEW, "START");
457
458         if (this->priv->dragging)
459         {
460                 cr = gdk_cairo_create (GTK_WIDGET (this->priv->canvas)->window);
461
462                 scale = set_transform_and_get_scale (this, cr);
463
464                 x = event->x;
465                 y = event->y;
466                 cairo_device_to_user (cr, &x, &y);
467
468                 i = find_closest_label (this, x, y);
469
470                 if ( i != this->priv->prev_i )
471                 {
472                         this->priv->last_i = i;
473
474                         g_signal_emit (G_OBJECT(this),
475                                        mini_preview_signals[PRESSED],
476                                        0,
477                                        MIN (this->priv->first_i, this->priv->last_i),
478                                        MAX (this->priv->first_i, this->priv->last_i));
479
480                         this->priv->prev_i = i;
481                 }
482                 cairo_destroy (cr);
483         }
484
485         gl_debug (DEBUG_MINI_PREVIEW, "END");
486         return FALSE;
487 }
488
489
490 /*--------------------------------------------------------------------------*/
491 /* Button release event handler                                             */
492 /*--------------------------------------------------------------------------*/
493 static gboolean
494 button_release_event_cb (GtkWidget      *widget,
495                          GdkEventButton *event)
496 {
497         glMiniPreview *this = GL_MINI_PREVIEW (widget);
498         
499         gl_debug (DEBUG_MINI_PREVIEW, "START");
500
501         if ( event->button == 1 )
502         {
503                 this->priv->dragging = FALSE;
504
505         }
506
507         gl_debug (DEBUG_MINI_PREVIEW, "END");
508         return FALSE;
509 }
510
511
512 /*--------------------------------------------------------------------------*/
513 /* Find index+1 of label closest to given coordinates.                      */
514 /*--------------------------------------------------------------------------*/
515 static gint
516 find_closest_label (glMiniPreview      *this,
517                     gdouble             x,
518                     gdouble             y)
519 {
520         gint    i;
521         gint    min_i;
522         gdouble dx, dy, d2, min_d2;
523
524         dx = x - this->priv->centers[0].x;
525         dy = y - this->priv->centers[0].y;
526         min_d2 = dx*dx + dy*dy;
527         min_i = 0;
528
529         for ( i=1; i<this->priv->labels_per_sheet; i++ )
530         {
531                 dx = x - this->priv->centers[i].x;
532                 dy = y - this->priv->centers[i].y;
533                 d2 = dx*dx + dy*dy;
534
535                 if ( d2 < min_d2 )
536                 {
537                         min_d2 = d2;
538                         min_i  = i;
539                 }
540         }
541
542         return min_i + 1;
543 }
544
545
546 /*--------------------------------------------------------------------------*/
547 /* Expose event handler.                                                    */
548 /*--------------------------------------------------------------------------*/
549 static gboolean
550 expose_event_cb (GtkWidget       *widget,
551                  GdkEventExpose  *event,
552                  glMiniPreview   *this)
553 {
554         cairo_t       *cr;
555
556         gl_debug (DEBUG_MINI_PREVIEW, "START");
557
558         cr = gdk_cairo_create (widget->window);
559
560         cairo_rectangle (cr,
561                         event->area.x, event->area.y,
562                         event->area.width, event->area.height);
563         cairo_clip (cr);
564         cairo_translate (cr, widget->allocation.x, widget->allocation.y);
565         
566         draw (this, cr);
567
568         cairo_destroy (cr);
569
570         gl_debug (DEBUG_MINI_PREVIEW, "END");
571         return FALSE;
572 }
573
574
575 /*--------------------------------------------------------------------------*/
576 /* Style set handler (updates colors when style/theme changes).             */
577 /*--------------------------------------------------------------------------*/
578 static void
579 style_set_cb (GtkWidget        *widget,
580               GtkStyle         *previous_style,
581               glMiniPreview    *this)
582 {
583         gl_debug (DEBUG_MINI_PREVIEW, "START");
584
585         redraw (this);
586
587         gl_debug (DEBUG_MINI_PREVIEW, "END");
588 }
589
590
591 /*--------------------------------------------------------------------------*/
592 /* Redraw.                                                                  */
593 /*--------------------------------------------------------------------------*/
594 static void
595 redraw (glMiniPreview      *this)
596 {
597         GdkRegion *region;
598         
599         gl_debug (DEBUG_MINI_PREVIEW, "START");
600
601         if (GTK_WIDGET (this->priv->canvas)->window)
602         {
603
604                 region = gdk_drawable_get_clip_region (GTK_WIDGET (this->priv->canvas)->window);
605
606                 gdk_window_invalidate_region (GTK_WIDGET (this->priv->canvas)->window, region, TRUE);
607                 gdk_window_process_updates (GTK_WIDGET (this->priv->canvas)->window, TRUE);
608
609                 gdk_region_destroy (region);
610         }
611
612         gl_debug (DEBUG_MINI_PREVIEW, "END");
613 }
614
615
616 /*--------------------------------------------------------------------------*/
617 /* Draw mini preview.                                                       */
618 /*--------------------------------------------------------------------------*/
619 static void
620 draw (glMiniPreview  *this,
621       cairo_t        *cr)
622 {
623         lglTemplate *template = this->priv->template;
624         gdouble      scale;
625         gdouble      shadow_x, shadow_y;
626
627
628         gl_debug (DEBUG_MINI_PREVIEW, "START");
629
630         if (template)
631         {
632
633                 scale = set_transform_and_get_scale (this, cr);
634
635                 /* update shadow */
636                 shadow_x = SHADOW_OFFSET/scale;
637                 shadow_y = SHADOW_OFFSET/scale;
638
639                 draw_shadow (this, cr,
640                              shadow_x, shadow_y,
641                              template->page_width, template->page_height);
642
643                 draw_paper (this, cr,
644                             template->page_width, template->page_height,
645                             1.0/scale);
646
647                 draw_labels (this, cr, template, 1.0/scale);
648                              
649         }
650
651         gl_debug (DEBUG_MINI_PREVIEW, "END");
652
653 }
654
655
656 /*--------------------------------------------------------------------------*/
657 /* Draw page shadow                                                         */
658 /*--------------------------------------------------------------------------*/
659 static void
660 draw_shadow (glMiniPreview      *this,
661              cairo_t            *cr,
662              gdouble             x,
663              gdouble             y,
664              gdouble             width,
665              gdouble             height)
666 {
667         GtkStyle *style;
668         guint     shadow_color;
669
670         gl_debug (DEBUG_MINI_PREVIEW, "START");
671
672         cairo_save (cr);
673
674         cairo_rectangle (cr, x, y, width, height);
675
676         style = gtk_widget_get_style (GTK_WIDGET(this));
677         shadow_color = gl_color_from_gdk_color (&style->dark[GTK_STATE_NORMAL]);
678         cairo_set_source_rgb (cr, GL_COLOR_RGB_ARGS (shadow_color));
679
680         cairo_fill (cr);
681
682         cairo_restore (cr);
683
684         gl_debug (DEBUG_MINI_PREVIEW, "END");
685 }
686
687
688 /*--------------------------------------------------------------------------*/
689 /* Draw page                                                                */
690 /*--------------------------------------------------------------------------*/
691 static void
692 draw_paper (glMiniPreview      *this,
693             cairo_t            *cr,
694             gdouble             width,
695             gdouble             height,
696             gdouble             line_width)
697 {
698         GtkStyle                  *style;
699         guint                      paper_color, outline_color;
700
701         gl_debug (DEBUG_MINI_PREVIEW, "START");
702
703         cairo_save (cr);
704
705         style = gtk_widget_get_style (GTK_WIDGET(this));
706         paper_color   = gl_color_from_gdk_color (&style->light[GTK_STATE_NORMAL]);
707         outline_color = gl_color_from_gdk_color (&style->fg[GTK_STATE_NORMAL]);
708
709         cairo_rectangle (cr, 0.0, 0.0, width, height);
710
711         cairo_set_source_rgb (cr, GL_COLOR_RGB_ARGS (paper_color));
712         cairo_fill_preserve (cr);
713
714         cairo_set_source_rgb (cr, GL_COLOR_RGB_ARGS (outline_color));
715         cairo_set_line_width (cr, line_width);
716         cairo_stroke (cr);
717
718         cairo_restore (cr);
719
720         gl_debug (DEBUG_MINI_PREVIEW, "END");
721 }
722
723
724 /*--------------------------------------------------------------------------*/
725 /* Draw labels                                                              */
726 /*--------------------------------------------------------------------------*/
727 static void
728 draw_labels (glMiniPreview *this,
729              cairo_t       *cr,
730              lglTemplate   *template,
731              gdouble        line_width)
732 {
733         const lglTemplateFrame    *frame;
734         gint                       i, n_labels;
735         lglTemplateOrigin         *origins;
736         GtkStyle                  *style;
737         guint                      highlight_color, paper_color, outline_color;
738
739         gl_debug (DEBUG_MINI_PREVIEW, "START");
740
741         frame = (lglTemplateFrame *)template->frames->data;
742
743         n_labels = lgl_template_frame_get_n_labels (frame);
744         origins  = lgl_template_frame_get_origins (frame);
745
746         style = gtk_widget_get_style (GTK_WIDGET(this));
747         highlight_color = gl_color_from_gdk_color (&style->base[GTK_STATE_SELECTED]);
748         paper_color     = gl_color_from_gdk_color (&style->light[GTK_STATE_NORMAL]);
749         outline_color   = gl_color_from_gdk_color (&style->fg[GTK_STATE_NORMAL]);
750
751         for ( i=0; i < n_labels; i++ ) {
752
753                 cairo_save (cr);
754
755                 cairo_translate (cr, origins[i].x, origins[i].y);
756                 gl_cairo_label_path (cr, template, FALSE, FALSE);
757
758                 if ( ((i+1) >= this->priv->highlight_first) &&
759                      ((i+1) <= this->priv->highlight_last) )
760                 {
761                         cairo_set_source_rgb (cr, GL_COLOR_RGB_ARGS (highlight_color));
762                 }
763                 else
764                 {
765                         cairo_set_source_rgb (cr, GL_COLOR_RGB_ARGS (paper_color));
766                 }
767                 cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
768                 cairo_fill_preserve (cr);
769
770                 cairo_set_line_width (cr, line_width);
771                 cairo_set_source_rgb (cr, GL_COLOR_RGB_ARGS (outline_color));
772                 cairo_stroke (cr);
773
774                 cairo_restore (cr);
775
776         }
777
778         g_free (origins);
779
780         gl_debug (DEBUG_MINI_PREVIEW, "END");
781 }
782
783
784
785 /*
786  * Local Variables:       -- emacs
787  * mode: C                -- emacs
788  * c-basic-offset: 8      -- emacs
789  * tab-width: 8           -- emacs
790  * indent-tabs-mode: nil  -- emacs
791  * End:                   -- emacs
792  */