~ubuntu-branches/ubuntu/trusty/goocanvas/trusty-proposed

« back to all changes in this revision

Viewing changes to src/goocanvaspolyline.c

  • Committer: Bazaar Package Importer
  • Author(s): Jose Carlos Garcia Sogo
  • Date: 2007-05-14 22:49:11 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070514224911-vyv39khpicv46oe2
Tags: 0.8-2
Link gtk-doc to /usr/share/doc/libgoocanvas-dev (Closes: #423410)

Show diffs side-by-side

added added

removed removed

Lines of Context:
205
205
  GooCanvasItemSimple *simple = (GooCanvasItemSimple*) object;
206
206
  GooCanvasPolyline *polyline = (GooCanvasPolyline*) object;
207
207
 
208
 
  if (!simple->model)
 
208
  /* Free our data if we didn't have a model. (If we had a model it would
 
209
     have been reset in dispose() and simple_data will be NULL.) */
 
210
  if (simple->simple_data)
209
211
    {
210
212
      g_slice_free1 (polyline->polyline_data->num_points * 2 * sizeof (gdouble),
211
213
                     polyline->polyline_data->coords);
761
763
}
762
764
 
763
765
 
764
 
static GooCanvasItem*
765
 
goo_canvas_polyline_get_item_at (GooCanvasItemSimple *simple,
766
 
                                 gdouble              x,
767
 
                                 gdouble              y,
768
 
                                 cairo_t             *cr,
769
 
                                 gboolean             is_pointer_event)
 
766
static gboolean
 
767
goo_canvas_polyline_is_item_at (GooCanvasItemSimple *simple,
 
768
                                gdouble              x,
 
769
                                gdouble              y,
 
770
                                cairo_t             *cr,
 
771
                                gboolean             is_pointer_event)
770
772
{
771
773
  GooCanvasItemSimpleData *simple_data = simple->simple_data;
772
774
  GooCanvasPolyline *polyline = (GooCanvasPolyline*) simple;
773
775
  GooCanvasPolylineData *polyline_data = polyline->polyline_data;
774
 
  GooCanvasItem *found_item = NULL;
775
776
  GooCanvasPointerEvents pointer_events = GOO_CANVAS_EVENTS_ALL;
776
777
  gboolean do_stroke;
777
 
  cairo_matrix_t matrix;
778
778
 
779
779
  if (polyline_data->num_points == 0)
780
 
    return NULL;
 
780
    return FALSE;
781
781
 
782
782
  /* Check if the item should receive events. */
783
783
  if (is_pointer_event)
784
784
    pointer_events = simple_data->pointer_events;
785
785
 
786
 
  /* Remove any current translation, to avoid the 16-bit cairo limit. */
787
 
  cairo_get_matrix (cr, &matrix);
788
 
  matrix.x0 = matrix.y0 = 0.0;
789
 
  cairo_set_matrix (cr, &matrix);
790
 
 
791
786
  goo_canvas_polyline_create_path (polyline, cr);
792
787
  if (goo_canvas_item_simple_check_in_path (simple, x, y, cr, pointer_events))
793
 
    found_item = (GooCanvasItem*) simple;
 
788
    return TRUE;
794
789
 
795
790
  /* Check the arrows, if the polyline has them. */
796
 
  if (!found_item && (polyline_data->start_arrow || polyline_data->end_arrow)
 
791
  if ((polyline_data->start_arrow || polyline_data->end_arrow)
797
792
      && polyline_data->num_points >= 2
798
793
      && (pointer_events & GOO_CANVAS_EVENTS_STROKE_MASK))
799
794
    {
805
800
            {
806
801
              goo_canvas_polyline_create_start_arrow_path (polyline, cr);
807
802
              if (cairo_in_fill (cr, x, y))
808
 
                found_item = (GooCanvasItem*) simple;
 
803
                return TRUE;
809
804
            }
810
805
 
811
 
          if (!found_item && polyline_data->end_arrow)
 
806
          if (polyline_data->end_arrow)
812
807
            {
813
808
              goo_canvas_polyline_create_end_arrow_path (polyline, cr);
814
809
              if (cairo_in_fill (cr, x, y))
815
 
                found_item = (GooCanvasItem*) simple;
 
810
                return TRUE;
816
811
            }
817
812
        }
818
813
    }
819
814
 
820
 
  return found_item;
 
815
  return FALSE;
821
816
}
822
817
 
823
818
 
895
890
 
896
891
 
897
892
static void
898
 
goo_canvas_polyline_paint (GooCanvasItemSimple *simple,
899
 
                           cairo_t             *cr,
900
 
                           GooCanvasBounds     *bounds)
 
893
goo_canvas_polyline_paint (GooCanvasItemSimple   *simple,
 
894
                           cairo_t               *cr,
 
895
                           const GooCanvasBounds *bounds)
901
896
{
902
897
  GooCanvasItemSimpleData *simple_data = simple->simple_data;
903
898
  GooCanvasPolyline *polyline = (GooCanvasPolyline*) simple;
964
959
  GObjectClass *gobject_class = (GObjectClass*) klass;
965
960
  GooCanvasItemSimpleClass *simple_class = (GooCanvasItemSimpleClass*) klass;
966
961
 
967
 
  gobject_class->finalize = goo_canvas_polyline_finalize;
 
962
  gobject_class->finalize  = goo_canvas_polyline_finalize;
968
963
 
969
964
  gobject_class->get_property = goo_canvas_polyline_get_property;
970
965
  gobject_class->set_property = goo_canvas_polyline_set_property;
971
966
 
972
967
  simple_class->simple_update        = goo_canvas_polyline_update;
973
968
  simple_class->simple_paint         = goo_canvas_polyline_paint;
974
 
  simple_class->simple_get_item_at   = goo_canvas_polyline_get_item_at;
 
969
  simple_class->simple_is_item_at    = goo_canvas_polyline_is_item_at;
975
970
 
976
971
  goo_canvas_polyline_install_common_properties (gobject_class);
977
972
}