[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: gaf.git: branch: master updated (1.5.1-20081221-112-gfef99d7)



The branch, master has been updated
       via  fef99d7912ebc1feb4890e5babff1772f6b20703 (commit)
      from  9784a9117e42632527601faef9a3ed937b718208 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 gschem/src/a_zoom.c    |   13 ++----
 gschem/src/o_arc.c     |   49 ++++++++++++++--------
 gschem/src/o_box.c     |   29 ++++---------
 gschem/src/o_bus.c     |   50 +++++++++-------------
 gschem/src/o_circle.c  |   39 +++++++++++++----
 gschem/src/o_grips.c   |   31 +++++---------
 gschem/src/o_line.c    |   11 ++---
 gschem/src/o_net.c     |   62 +++++++++++----------------
 gschem/src/o_path.c    |  109 ++++++++++++++++++++++++++++++++++--------------
 gschem/src/o_picture.c |   36 +++++-----------
 gschem/src/o_pin.c     |   26 ++++--------
 gschem/src/o_place.c   |   10 ++--
 gschem/src/o_select.c  |   13 ++----
 13 files changed, 241 insertions(+), 237 deletions(-)


=================
 Commit Messages
=================

commit fef99d7912ebc1feb4890e5babff1772f6b20703
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Fri Jan 2 04:35:49 2009 +0000

    gschem: Draw using cairo when rubberbanding objects
    
    Migrates to cairo drawing in *_draw_rubber() and *_draw_stretch().

:100644 100644 9ba733a... 1afabde... M	gschem/src/a_zoom.c
:100644 100644 646946c... c7d00ce... M	gschem/src/o_arc.c
:100644 100644 9cbf626... 72dddb8... M	gschem/src/o_box.c
:100644 100644 791cc6f... ddd254a... M	gschem/src/o_bus.c
:100644 100644 e8e0786... 88d686b... M	gschem/src/o_circle.c
:100644 100644 253dbb3... c764ddf... M	gschem/src/o_grips.c
:100644 100644 ac76a1d... 3ac4058... M	gschem/src/o_line.c
:100644 100644 a29867c... 50595d3... M	gschem/src/o_net.c
:100644 100644 4f5c7d1... 50d0971... M	gschem/src/o_path.c
:100644 100644 387dcff... 755eb5d... M	gschem/src/o_picture.c
:100644 100644 9fe86c4... b4e6c45... M	gschem/src/o_pin.c
:100644 100644 370c770... 0ea715b... M	gschem/src/o_place.c
:100644 100644 a98f0f4... 0bd4046... M	gschem/src/o_select.c

=========
 Changes
=========

commit fef99d7912ebc1feb4890e5babff1772f6b20703
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Fri Jan 2 04:35:49 2009 +0000

    gschem: Draw using cairo when rubberbanding objects
    
    Migrates to cairo drawing in *_draw_rubber() and *_draw_stretch().

diff --git a/gschem/src/a_zoom.c b/gschem/src/a_zoom.c
index 9ba733a..1afabde 100644
--- a/gschem/src/a_zoom.c
+++ b/gschem/src/a_zoom.c
@@ -302,20 +302,15 @@ void a_zoom_box_draw_rubber (GSCHEM_TOPLEVEL *w_current)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
   int x1, y1, x2, y2;
-  int box_width, box_height;
-  int box_left, box_top;
 
   WORLDtoSCREEN(toplevel, w_current->first_wx, w_current->first_wy, &x1, &y1);
   WORLDtoSCREEN(toplevel, w_current->second_wx, w_current->second_wy, &x2, &y2);
 
-  box_width  = abs(x1 - x2);
-  box_height = abs(y1 - y2);
-  box_left   = min(x1, x2);
-  box_top    = min(y1, y2);
+  gschem_cairo_box (w_current->cr, 1, x1, y1, x2, y2);
 
-  gdk_gc_set_foreground (w_current->gc, x_get_darkcolor (ZOOM_BOX_COLOR));
-  gdk_draw_rectangle (w_current->drawable, w_current->gc, FALSE,
-                      box_left, box_top, box_width, box_height);
+  gschem_cairo_set_source_color (w_current->cr,
+                                 x_color_lookup_dark (ZOOM_BOX_COLOR));
+  gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
 }
 
 /*! \todo Finish function documentation!!!
diff --git a/gschem/src/o_arc.c b/gschem/src/o_arc.c
index 646946c..c7d00ce 100644
--- a/gschem/src/o_arc.c
+++ b/gschem/src/o_arc.c
@@ -398,28 +398,41 @@ void o_arc_draw_rubber (GSCHEM_TOPLEVEL *w_current)
   TOPLEVEL *toplevel = w_current->toplevel;
 
   double rad_angle;
-  int cx, cy, x1, y1, radius;
+  double radius;
+  double cx, cy;
+  int sx1, sy1, sx2, sy2, rx, ry;
 
-  WORLDtoSCREEN(toplevel, w_current->first_wx, w_current->first_wy, &cx, &cy);
-  radius = SCREENabs(toplevel, w_current->distance);
-  
-  gdk_gc_set_foreground (w_current->gc, x_get_darkcolor (SELECT_COLOR));
-  gdk_gc_set_line_attributes (w_current->gc, 0,
-                              GDK_LINE_SOLID, GDK_CAP_NOT_LAST,
-                              GDK_JOIN_MITER);
-
-  /* draw the arc from the w_current variables */
-  gdk_draw_arc (w_current->drawable, w_current->gc, FALSE,
-                cx - radius, cy - radius,
-                radius * 2, radius * 2,
-                w_current->second_wx * 64,
-                w_current->second_wy * 64);
+  WORLDtoSCREEN (toplevel, w_current->first_wx - w_current->distance,
+                           w_current->first_wy + w_current->distance,
+                           &sx1, &sy1);
+  WORLDtoSCREEN (toplevel, w_current->first_wx + w_current->distance,
+                           w_current->first_wy - w_current->distance,
+                           &sx2, &sy2);
+
+  radius = (double)(sy2 - sy1) / 2.;
+  cx = (double)(sx1 + sx2) / 2.;
+  cy = (double)(sy1 + sy2) / 2.;
+
+  cairo_translate (w_current->cr, cx, cy);
+
+  /* Adjust for non-uniform X/Y scale factor. Note that the + 1
+     allows for the case where sx2 == sx1 or sy2 == sy1 */
+  cairo_scale (w_current->cr, (double)(sx2 - sx1 + 1) /
+                              (double)(sy2 - sy1 + 1), 1.);
+  gschem_cairo_arc (w_current->cr, 1, 0., 0., radius,
+                    w_current->second_wx, w_current->second_wy);
+  cairo_identity_matrix (w_current->cr);
+
+  gschem_cairo_set_source_color (w_current->cr,
+                                 x_color_lookup_dark (SELECT_COLOR));
 
   /* draw the radius segment from the w_current variables */
   rad_angle = ((double) w_current->second_wx) * M_PI / 180;
-  x1 = cx + radius*cos(rad_angle);
-  y1 = cy - radius*sin(rad_angle);
-  gdk_draw_line (w_current->drawable, w_current->gc, cx, cy, x1, y1);
+  rx = cx + radius * cos (rad_angle);
+  ry = cy - radius * sin (rad_angle);
+  gschem_cairo_line (w_current->cr, END_NONE, 1, cx, cy, rx, ry);
+
+  gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
 }
 
 /*! \brief Draw grip marks on arc.
diff --git a/gschem/src/o_box.c b/gschem/src/o_box.c
index 9cbf626..72dddb8 100644
--- a/gschem/src/o_box.c
+++ b/gschem/src/o_box.c
@@ -585,26 +585,15 @@ void o_box_draw_rubber (GSCHEM_TOPLEVEL *w_current)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
   int x1, y1, x2, y2;
-  int box_width, box_height, box_left, box_top;
-  
-  WORLDtoSCREEN(toplevel, w_current->first_wx, w_current->first_wy,
-		&x1, &y1);
-  WORLDtoSCREEN(toplevel, w_current->second_wx, w_current->second_wy, 
-		&x2, &y2);
-
-  /* get the width/height and the upper left corner of the box */
-  box_width  = abs(x2 - x1);
-  box_height = abs(y2 - y1);
-  box_left   = min(x1, x2);
-  box_top    = min(y1, y2);
-  
-  /* draw the box from the previous variables */
-  gdk_gc_set_foreground (w_current->gc, x_get_darkcolor (SELECT_COLOR));
-  gdk_gc_set_line_attributes (w_current->gc, 0,
-                              GDK_LINE_SOLID, GDK_CAP_NOT_LAST,
-                              GDK_JOIN_MITER);
-  gdk_draw_rectangle (w_current->drawable, w_current->gc,
-                      FALSE, box_left, box_top, box_width, box_height);
+
+  WORLDtoSCREEN(toplevel, w_current->first_wx, w_current->first_wy, &x1, &y1);
+  WORLDtoSCREEN(toplevel, w_current->second_wx, w_current->second_wy, &x2, &y2);
+
+  gschem_cairo_box (w_current->cr, 1, x1, y1, x2, y2);
+
+  gschem_cairo_set_source_color (w_current->cr,
+                                 x_color_lookup_dark (SELECT_COLOR));
+  gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
 }
 
 /*! \brief Draw grip marks on box.
diff --git a/gschem/src/o_bus.c b/gschem/src/o_bus.c
index 791cc6f..ddd254a 100644
--- a/gschem/src/o_bus.c
+++ b/gschem/src/o_bus.c
@@ -135,7 +135,7 @@ void o_bus_draw_stretch (GSCHEM_TOPLEVEL *w_current,
   TOPLEVEL *toplevel = w_current->toplevel;
   int color;
   int dx1= - 1, dy1 = - 1, dx2 = -1, dy2 = -1;
-  int sx[2], sy[2];
+  int x1, y1, x2, y2;
 
   if (o_current->line == NULL) {
     return;
@@ -147,27 +147,27 @@ void o_bus_draw_stretch (GSCHEM_TOPLEVEL *w_current,
     color = o_current->color;
   }
 
-  gdk_gc_set_foreground (w_current->gc, x_get_darkcolor (color));
-
   if (whichone == 0) {
     dx1 = dx;
     dy1 = dy;
-    dx2 = 0;
-    dy2 = 0;
+    dx2 = dy2 = 0;
   } else if (whichone == 1) {
+    dx1 = dy1 = 0;
     dx2 = dx;
     dy2 = dy;
-    dx1 = 0;
-    dy1 = 0;
   } else {
     fprintf(stderr, _("Got an invalid which one in o_bus_draw_stretch\n"));
   }
 
-  WORLDtoSCREEN(toplevel, o_current->line->x[0] + dx1, o_current->line->y[0] + dy1, &sx[0], &sy[0]);
-  WORLDtoSCREEN(toplevel, o_current->line->x[1] + dx2, o_current->line->y[1] + dy2, &sx[1], &sy[1]);
+  WORLDtoSCREEN (toplevel, o_current->line->x[0] + dx1,
+                           o_current->line->y[0] + dy1, &x1, &y1);
+  WORLDtoSCREEN (toplevel, o_current->line->x[1] + dx2,
+                           o_current->line->y[1] + dy2, &x2, &y2);
 
-  gdk_draw_line (w_current->drawable, w_current->gc,
-                 sx[0], sy[0], sx[1], sy[1]);
+  gschem_cairo_line (w_current->cr, END_NONE, 1, x1, y1, x2, y2);
+
+  gschem_cairo_set_source_color (w_current->cr, x_color_lookup_dark (color));
+  gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
 }
 
 /*! \brief set the start point of a new bus
@@ -331,30 +331,20 @@ void o_bus_invalidate_rubber (GSCHEM_TOPLEVEL *w_current)
 void o_bus_draw_rubber (GSCHEM_TOPLEVEL *w_current)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
-  int x1, y1, x2, y2, size=0;
+  int x1, y1, x2, y2, size = 0;
 
   WORLDtoSCREEN(toplevel, w_current->first_wx, w_current->first_wy, &x1, &y1);
   WORLDtoSCREEN(toplevel, w_current->second_wx, w_current->second_wy, &x2, &y2);
 
-  if (toplevel->bus_style == THICK ) {
+  if (toplevel->bus_style == THICK)
     size = SCREENabs(toplevel, BUS_WIDTH);
-    
-    if (size < 0)
-      size=0;
-
-    gdk_gc_set_line_attributes(w_current->gc, size,
-                               GDK_LINE_SOLID,
-                               GDK_CAP_NOT_LAST,
-                               GDK_JOIN_MITER);
-  }
 
-  gdk_gc_set_foreground (w_current->gc, x_get_darkcolor (SELECT_COLOR));
-  gdk_draw_line (w_current->drawable, w_current->gc, x1, y1, x2, y2);
+  if (size < 1)
+    size = 1;
 
-  if (toplevel->bus_style == THICK ) {
-    gdk_gc_set_line_attributes(w_current->gc, 0,
-                               GDK_LINE_SOLID,
-                               GDK_CAP_NOT_LAST,
-                               GDK_JOIN_MITER);
-  }
+  gschem_cairo_line (w_current->cr, END_NONE, size, x1, y1, x2, y2);
+
+  gschem_cairo_set_source_color (w_current->cr,
+                                 x_color_lookup_dark (SELECT_COLOR));
+  gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, size, -1, -1);
 }
diff --git a/gschem/src/o_circle.c b/gschem/src/o_circle.c
index e8e0786..88d686b 100644
--- a/gschem/src/o_circle.c
+++ b/gschem/src/o_circle.c
@@ -594,18 +594,37 @@ void o_circle_motion (GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
 void o_circle_draw_rubber (GSCHEM_TOPLEVEL *w_current)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
-  int cx, cy, radius;
-
-  WORLDtoSCREEN(toplevel, w_current->first_wx, w_current->first_wy, &cx, &cy);
-  radius = SCREENabs(toplevel, w_current->distance);
+  int sx1, sy1, sx2, sy2;
+  double cx, cy;
+  double radius;
 
   /* draw the circle from the w_current variables */
-  gdk_gc_set_foreground (w_current->gc, x_get_darkcolor (SELECT_COLOR));
-  gdk_draw_line (w_current->drawable, w_current->gc,
-                 cx, cy, cx + radius, cy);
-  gdk_draw_arc (w_current->drawable, w_current->gc, FALSE,
-                cx - radius, cy - radius, 2 * radius, 2* radius,
-                0, FULL_CIRCLE);
+
+  WORLDtoSCREEN (toplevel, w_current->first_wx - w_current->distance,
+                           w_current->first_wy + w_current->distance,
+                           &sx1, &sy1);
+  WORLDtoSCREEN (toplevel, w_current->first_wx + w_current->distance,
+                           w_current->first_wy - w_current->distance,
+                           &sx2, &sy2);
+
+  cx = (double)(sx1 + sx2) / 2.;
+  cy = (double)(sy1 + sy2) / 2.;
+  radius = (double)(sy2 - sy1) / 2.;
+
+  cairo_translate (w_current->cr, cx, cy);
+
+  /* Adjust for non-uniform X/Y scale factor. Note that the + 1
+     allows for the case where sx2 == sx1 or sy2 == sy1 */
+  cairo_scale (w_current->cr, (double)(sx2 - sx1 + 1) /
+                              (double)(sy2 - sy1 + 1), 1.);
+
+  gschem_cairo_line (w_current->cr, END_NONE, 1, 0., 0., radius, 0.);
+  gschem_cairo_arc (w_current->cr, 1, 0., 0., radius, 0., 360);
+  cairo_identity_matrix (w_current->cr);
+
+  gschem_cairo_set_source_color (w_current->cr,
+                                 x_color_lookup_dark (SELECT_COLOR));
+  gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
 }
 
 /*! \brief Draw grip marks on circle.
diff --git a/gschem/src/o_grips.c b/gschem/src/o_grips.c
index 253dbb3..c764ddf 100644
--- a/gschem/src/o_grips.c
+++ b/gschem/src/o_grips.c
@@ -1556,18 +1556,15 @@ int o_grips_size(GSCHEM_TOPLEVEL *w_current)
 void o_grips_draw(GSCHEM_TOPLEVEL *w_current, int x, int y)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
-  GdkColor *color;
-  int size, x2size;
+  int color;
+  int size;
 
   /*
    * Depending on the current zoom level, the size of the grip is
-   * determined. <B>size</B> is half the width and height of the grip
-   * and <B>x2size</B> is the full width and height of the grip.
+   * determined. <B>size</B> is half the width and height of the grip.
    */
   /* size is half the width of grip */
   size = o_grips_size(w_current);
-  /* x2size is full width */
-  x2size = 2 * size;
 
   /*
    * The grip can be displayed or erased : if <B>toplevel->override_color</B>
@@ -1578,26 +1575,20 @@ void o_grips_draw(GSCHEM_TOPLEVEL *w_current, int x, int y)
    */
   if (toplevel->override_color != -1 ) {
     /* override : use the override_color instead */
-    color = x_get_color(toplevel->override_color);
+    color = toplevel->override_color;
   } else {
     /* use the normal selection color */
-    color = x_get_color (SELECT_COLOR);
+    color = SELECT_COLOR;
   }
-  /* set the color for the grip */
-  gdk_gc_set_foreground(w_current->gc, color);
-
-  /* set the line options for grip : solid, 1 pix wide */
-  gdk_gc_set_line_attributes(w_current->gc, 0, GDK_LINE_SOLID,
-                             GDK_CAP_BUTT, GDK_JOIN_MITER);
 
-  /*
-   * A grip is a hollow square centered at (<B>x</B>,<B>y</B>) with a
-   * width/height of <B>x2size</B>.
+  /* A grip is a hollow square centered at (<B>x</B>,<B>y</B>)
+   * with a  width / height of 2 * <B>size</B>.
    */
   if (toplevel->DONT_REDRAW == 0) {
-    /* draw the grip in backingstore */
-    gdk_draw_rectangle (w_current->drawable, w_current->gc, FALSE,
-                        x - size, y - size, x2size, x2size);
+    gschem_cairo_box (w_current->cr, 1, x - size, y - size, x + size, y + size);
+
+    gschem_cairo_set_source_color (w_current->cr, x_color_lookup (color));
+    gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
   }
 }
 
diff --git a/gschem/src/o_line.c b/gschem/src/o_line.c
index ac76a1d..3ac4058 100644
--- a/gschem/src/o_line.c
+++ b/gschem/src/o_line.c
@@ -300,12 +300,11 @@ void o_line_draw_rubber (GSCHEM_TOPLEVEL *w_current)
   WORLDtoSCREEN(toplevel, w_current->first_wx, w_current->first_wy, &x1, &y1);
   WORLDtoSCREEN(toplevel, w_current->second_wx, w_current->second_wy, &x2, &y2);
 
-  /* draw the circle from the w_current variables */
-  gdk_gc_set_foreground (w_current->gc, x_get_darkcolor (SELECT_COLOR));
-  gdk_gc_set_line_attributes (w_current->gc, 0,
-                              GDK_LINE_SOLID, GDK_CAP_NOT_LAST,
-                              GDK_JOIN_MITER);
-  gdk_draw_line (w_current->drawable, w_current->gc, x1, y1, x2, y2);
+  gschem_cairo_line (w_current->cr, END_NONE, 1, x1, y1, x2, y2);
+
+  gschem_cairo_set_source_color (w_current->cr,
+                                 x_color_lookup_dark (SELECT_COLOR));
+  gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
 }
 
 /*! \brief Draw grip marks on line.
diff --git a/gschem/src/o_net.c b/gschem/src/o_net.c
index a29867c..50595d3 100644
--- a/gschem/src/o_net.c
+++ b/gschem/src/o_net.c
@@ -177,7 +177,7 @@ void o_net_draw_stretch (GSCHEM_TOPLEVEL *w_current,
   TOPLEVEL *toplevel = w_current->toplevel;
   int color;
   int dx1 = -1, dx2 = -1, dy1 = -1,dy2 = -1;
-  int sx[2], sy[2];
+  int x1, y1, x2, y2;
 
   if (o_current->line == NULL) {
     return;
@@ -189,27 +189,27 @@ void o_net_draw_stretch (GSCHEM_TOPLEVEL *w_current,
     color = o_current->color;
   }
 
-  gdk_gc_set_foreground (w_current->gc, x_get_darkcolor(color));
-
   if (whichone == 0) {
     dx1 = dx;
     dy1 = dy;
-    dx2 = 0;
-    dy2 = 0;
+    dx2 = dy2 = 0;
   } else if (whichone == 1) {
+    dx1 = dy1 = 0;
     dx2 = dx;
     dy2 = dy;
-    dx1 = 0;
-    dy1 = 0;
   } else {
     fprintf(stderr, _("Got an invalid which one in o_net_draw_stretch\n"));
   }
 
-  WORLDtoSCREEN( toplevel, o_current->line->x[0] + dx1, o_current->line->y[0] + dy1, &sx[0], &sy[0] );
-  WORLDtoSCREEN( toplevel, o_current->line->x[1] + dx2, o_current->line->y[1] + dy2, &sx[1], &sy[1] );
+  WORLDtoSCREEN (toplevel, o_current->line->x[0] + dx1,
+                           o_current->line->y[0] + dy1, &x1, &y1);
+  WORLDtoSCREEN (toplevel, o_current->line->x[1] + dx2,
+                           o_current->line->y[1] + dy2, &x2, &y2);
+
+  gschem_cairo_line (w_current->cr, END_NONE, 1, x1, y1, x2, y2);
 
-  gdk_draw_line (w_current->drawable, w_current->gc,
-                 sx[0], sy[0], sx[1], sy[1]);
+  gschem_cairo_set_source_color (w_current->cr, x_color_lookup_dark (color));
+  gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
 }
 
 
@@ -811,7 +811,7 @@ void o_net_motion (GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
 void o_net_draw_rubber(GSCHEM_TOPLEVEL *w_current)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
-  int size=0, magnetic_halfsize;
+  int size = 0, magnetic_halfsize;
   int magnetic_x, magnetic_y;
   int first_x, first_y, third_x, third_y, second_x, second_y;
 
@@ -824,40 +824,30 @@ void o_net_draw_rubber(GSCHEM_TOPLEVEL *w_current)
   WORLDtoSCREEN(toplevel, w_current->second_wx, w_current->second_wy,
 		&second_x, &second_y);
 
-  if (toplevel->net_style == THICK) {
+  if (toplevel->net_style == THICK)
     size = SCREENabs(toplevel, NET_WIDTH);
-    gdk_gc_set_line_attributes (w_current->gc, size,
-                                GDK_LINE_SOLID,
-                                GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
-  }
-  size = max(size, 0);
 
-  gdk_gc_set_foreground (w_current->gc, x_get_darkcolor (SELECT_COLOR));
+  size = max (size, 1);
+
+  gschem_cairo_set_source_color (w_current->cr,
+                                 x_color_lookup_dark (SELECT_COLOR));
 
   if (w_current->magneticnet_mode) {
     if (w_current->magnetic_wx != -1 && w_current->magnetic_wy != -1) {
       magnetic_halfsize = max(4*size, MAGNETIC_HALFSIZE);
-      gdk_draw_arc (w_current->drawable, w_current->gc, FALSE,
-                    magnetic_x - magnetic_halfsize,
-                    magnetic_y - magnetic_halfsize,
-                    2 * magnetic_halfsize, 2 * magnetic_halfsize,
-                    0, FULL_CIRCLE);
+      gschem_cairo_arc (w_current->cr, size, magnetic_x, magnetic_y,
+                        magnetic_halfsize, 0, 360);
     }
   }
 
-  /* draw primary line */
-  gdk_draw_line (w_current->drawable, w_current->gc,
-                 first_x, first_y, second_x, second_y);
-
-  /* Draw secondary line */
-  gdk_draw_line (w_current->drawable, w_current->gc,
-                 second_x, second_y, third_x, third_y);
+  /* Primary line */
+  gschem_cairo_line (w_current->cr, END_NONE, size,
+                     first_x, first_y, second_x, second_y);
+  /* Secondary line */
+  gschem_cairo_line (w_current->cr, END_NONE, size,
+                     second_x, second_y, third_x, third_y);
 
-  if (toplevel->net_style == THICK) {
-    gdk_gc_set_line_attributes (w_current->gc, 0,
-                                GDK_LINE_SOLID,
-                                GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
-  }
+  gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, size, -1, -1);
 }
 
 
diff --git a/gschem/src/o_path.c b/gschem/src/o_path.c
index 4f5c7d1..50d0971 100644
--- a/gschem/src/o_path.c
+++ b/gschem/src/o_path.c
@@ -630,37 +630,79 @@ void o_path_motion (GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
  */
 void o_path_draw_rubber (GSCHEM_TOPLEVEL *w_current)
 {
-  PATH *path;
-  int num_points;
-  GdkPoint *points;
-
-  g_return_if_fail (w_current->which_object != NULL);
-  g_return_if_fail (w_current->which_object->path != NULL);
+  TOPLEVEL *toplevel = w_current->toplevel;
+  int whichone = w_current->which_grip;
+  PATH *path = w_current->which_object->path;
+  PATH_SECTION *section;
+  int i;
+  int grip_no = 0;
+  int line_width = 1;
+  int x, y;
+  int x1, y1, x2, y2, x3, y3;
+  double fx1 = 0.0, fy1 = 0.0;
+  double fx2 = 0.0, fy2 = 0.0;
+  double fx3 = 0.0, fy3 = 0.0;
 
-  path = w_current->which_object->path;
+  x = w_current->second_wx;
+  y = w_current->second_wy;
 
-  path_to_points_modify (w_current, path, 0, 0,
-                         w_current->second_wx, w_current->second_wy,
-                         w_current->which_grip, &points, &num_points);
+  for (i = 0; i <  path->num_sections; i++) {
+    section = &path->sections[i];
 
-  if (num_points == 0) {
-    g_free (points);
-    return;
-  }
+    x1 = section->x1;
+    y1 = section->y1;
+    x2 = section->x2;
+    y2 = section->y2;
+    x3 = section->x3;
+    y3 = section->y3;
 
-  gdk_gc_set_foreground (w_current->gc, x_get_darkcolor (SELECT_COLOR));
-  gdk_gc_set_line_attributes (w_current->gc, 0, GDK_LINE_SOLID,
-                              GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
+    switch (section->code) {
+      case PATH_CURVETO:
+        /* Two control point grips */
+        if (whichone == grip_no++) {
+          x1 = x; y1 = y;
+        }
+        if (whichone == grip_no++) {
+          x2 = x; y2 = y;
+        }
+        WORLDtoSCREEN (toplevel, x1, y1, &x1, &y1);
+        WORLDtoSCREEN (toplevel, x2, y2, &x2, &y2);
+        hint_coordinates (x1, y1, &fx1, &fy1, line_width);
+        hint_coordinates (x2, y2, &fx2, &fy2, line_width);
+        /* Fall through */
+      case PATH_MOVETO:
+      case PATH_MOVETO_OPEN:
+      case PATH_LINETO:
+        /* Destination point grip */
+        if (whichone == grip_no++) {
+          x3 = x; y3 = y;
+        }
+        WORLDtoSCREEN (toplevel, x3, y3, &x3, &y3);
+        hint_coordinates (x3, y3, &fx3, &fy3, line_width);
+      case PATH_END:
+        break;
+    }
 
-  /* Stroke only, no fill for rubberbanding */
-  if (path->sections[path->num_sections - 1].code == PATH_END)
-    gdk_draw_polygon (w_current->drawable, w_current->gc,
-                      FALSE, points, num_points);
-  else
-    gdk_draw_lines (w_current->drawable, w_current->gc,
-                    points, num_points);
+    switch (section->code) {
+      case PATH_MOVETO:
+        cairo_close_path (w_current->cr);
+        /* fall-through */
+      case PATH_MOVETO_OPEN:
+        cairo_move_to (w_current->cr, fx3, fy3);
+        break;
+      case PATH_CURVETO:
+        cairo_curve_to (w_current->cr, fx1, fy1, fx2, fy2, fx3, fy3);
+        break;
+      case PATH_LINETO:
+        cairo_line_to (w_current->cr, fx3, fy3);
+        break;
+      case PATH_END:
+        break;
+    }
+  }
 
-  g_free (points);
+  gschem_cairo_set_source_color (w_current->cr, x_color_lookup (SELECT_COLOR));
+  gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_SQUARE, line_width, -1, -1);
 }
 
 
@@ -682,18 +724,18 @@ static void draw_control_lines (GSCHEM_TOPLEVEL *w_current,
   int next_x, next_y;
   int last_x = 0, last_y = 0;
   PATH_SECTION *section;
-  GdkColor *color;
+  COLOR *color;
 
   if (toplevel->override_color != -1 ) {
     /* override : use the override_color instead */
-    color = x_get_color(toplevel->override_color);
+    color = x_color_lookup (toplevel->override_color);
   } else {
     /* use the normal selection color */
-    color = x_get_darkcolor (SELECT_COLOR);
+    color = x_color_lookup_dark (SELECT_COLOR);
   }
 
   /* set the color for the grip */
-  gdk_gc_set_foreground (w_current->gc, color);
+  gschem_cairo_set_source_color (w_current->cr, color);
 
   for (i = 0; i <  o_current->path->num_sections; i++) {
     section = &o_current->path->sections[i];
@@ -701,14 +743,17 @@ static void draw_control_lines (GSCHEM_TOPLEVEL *w_current,
     if (section->code != PATH_END)
       WORLDtoSCREEN (toplevel, section->x3, section->y3, &next_x, &next_y);
 
-
     switch (section->code) {
     case PATH_CURVETO:
       /* Two control point grips */
       WORLDtoSCREEN (toplevel, section->x1, section->y1, &x, &y);
-      gdk_draw_line (w_current->drawable, w_current->gc, last_x, last_y, x, y);
+      gschem_cairo_line (w_current->cr, END_NONE, 1, last_x, last_y, x, y);
+      gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
+
       WORLDtoSCREEN (toplevel, section->x2, section->y2, &x, &y);
-      gdk_draw_line (w_current->drawable, w_current->gc, next_x, next_y, x, y);
+      gschem_cairo_line (w_current->cr, END_NONE, 1, next_x, next_y, x, y);
+      gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
+
       /* Fall through */
     case PATH_MOVETO:
     case PATH_MOVETO_OPEN:
diff --git a/gschem/src/o_picture.c b/gschem/src/o_picture.c
index 387dcff..755eb5d 100644
--- a/gschem/src/o_picture.c
+++ b/gschem/src/o_picture.c
@@ -282,21 +282,11 @@ void o_picture_draw_rubber (GSCHEM_TOPLEVEL *w_current)
   width = SCREENabs(toplevel, GET_PICTURE_WIDTH (w_current));
   height = SCREENabs(toplevel, GET_PICTURE_HEIGHT(w_current));
 
-#if DEBUG
-  printf("o_picture_draw_rubber called:\n");
-  printf("pixbuf wh ratio: %i\n", w_current->pixbuf_wh_ratio);
-  printf("first: %i, %i\n", w_current->first_wx, w_current->first_wy);
-  printf("second: %i, %i\n", w_current->second_wx, w_current->second_wy);
-  printf("Left: %i\nTop: %i\nWidth: %i\nHeight: %i\n",
-	 picture_left, picture_top, picture_width, picture_height);
-#endif
-  /* draw the picture from the previous variables */
-  gdk_gc_set_foreground (w_current->gc, x_get_darkcolor (SELECT_COLOR));
-  gdk_gc_set_line_attributes (w_current->gc, 0,
-                              GDK_LINE_SOLID, GDK_CAP_NOT_LAST,
-                              GDK_JOIN_MITER);
-  gdk_draw_rectangle (w_current->drawable, w_current->gc,
-                      FALSE, left, top, width, height);
+  gschem_cairo_box (w_current->cr, 1, left, top, left + width, top + height);
+
+  gschem_cairo_set_source_color (w_current->cr,
+                                 x_color_lookup_dark (SELECT_COLOR));
+  gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
 }
 
 /*! \brief Draw a picture on the screen.
@@ -390,17 +380,13 @@ void o_picture_draw_grips(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
   TOPLEVEL *toplevel = w_current->toplevel;
   int s_upper_x, s_upper_y, s_lower_x, s_lower_y;
 
-#if DEBUG
-  printf("o_picture_draw_grips called\n");
-#endif
   if (w_current->draw_grips == FALSE)
-	  return;
+    return;
 
   WORLDtoSCREEN( toplevel, o_current->picture->upper_x, o_current->picture->upper_y,
                  &s_upper_x, &s_upper_y );
   WORLDtoSCREEN( toplevel, o_current->picture->lower_x, o_current->picture->lower_y,
                  &s_lower_x, &s_lower_y );
-  
 
   /* grip on upper left corner (whichone = PICTURE_UPPER_LEFT) */
   o_grips_draw(w_current, s_upper_x, s_upper_y);
@@ -415,10 +401,12 @@ void o_picture_draw_grips(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
   o_grips_draw(w_current, s_lower_x, s_lower_y);
   
   /* Box surrounding the picture */
-  gdk_draw_rectangle (w_current->drawable, w_current->gc, FALSE,
-                      s_upper_x, s_upper_y,
-                      abs(s_upper_x - s_lower_x),
-                      abs(s_upper_y - s_lower_y));
+  gschem_cairo_box (w_current->cr, 1, s_lower_x, s_lower_y,
+                                      s_upper_x, s_upper_y);
+
+  gschem_cairo_set_source_color (w_current->cr,
+                                 x_color_lookup_dark (SELECT_COLOR));
+  gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
 }
 
 
diff --git a/gschem/src/o_pin.c b/gschem/src/o_pin.c
index 9fe86c4..b4e6c45 100644
--- a/gschem/src/o_pin.c
+++ b/gschem/src/o_pin.c
@@ -259,30 +259,20 @@ void o_pin_draw_rubber (GSCHEM_TOPLEVEL *w_current)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
   int x1, y1, x2, y2;
-  int size = 0;
+  int size = 1;
 
   WORLDtoSCREEN(toplevel, w_current->first_wx, w_current->first_wy, &x1, &y1);
   WORLDtoSCREEN(toplevel, w_current->second_wx, w_current->second_wy, &x2, &y2);
 
-  if (toplevel->net_style == THICK ) {
+  if (toplevel->net_style == THICK )
     size = SCREENabs(toplevel, PIN_WIDTH);
 
-    if (size < 0)
-      size=0;
-
-    gdk_gc_set_line_attributes (w_current->gc, size,
-                                GDK_LINE_SOLID,
-                                GDK_CAP_NOT_LAST,
-                                GDK_JOIN_MITER);
-  }
+  if (size < 1)
+    size = 1;
 
-  gdk_gc_set_foreground (w_current->gc, x_get_darkcolor (SELECT_COLOR));
-  gdk_draw_line (w_current->drawable, w_current->gc, x1, y1, x2, y2);
+  gschem_cairo_line (w_current->cr, END_NONE, size, x1, y1, x2, y2);
 
-  if (toplevel->net_style == THICK ) {
-    gdk_gc_set_line_attributes (w_current->gc, 0,
-                                GDK_LINE_SOLID,
-                                GDK_CAP_NOT_LAST,
-                                GDK_JOIN_MITER);
-  }
+  gschem_cairo_set_source_color (w_current->cr,
+                                 x_color_lookup_dark (SELECT_COLOR));
+  gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, size, -1, -1);
 }
diff --git a/gschem/src/o_place.c b/gschem/src/o_place.c
index 370c770..0ea715b 100644
--- a/gschem/src/o_place.c
+++ b/gschem/src/o_place.c
@@ -294,11 +294,11 @@ void o_place_draw_rubber (GSCHEM_TOPLEVEL *w_current, int drawing)
     WORLDtoSCREEN(toplevel, left + diff_x, top + diff_y, &s_left, &s_top);
     WORLDtoSCREEN(toplevel, right + diff_x, bottom + diff_y, &s_right, &s_bottom);
 
-    gdk_gc_set_foreground (w_current->gc, x_get_darkcolor (BOUNDINGBOX_COLOR));
-    gdk_draw_rectangle (w_current->drawable,
-                        w_current->gc, FALSE,
-                        s_left, s_bottom,
-                        s_right - s_left, s_top - s_bottom);
+    gschem_cairo_box (w_current->cr, 1, s_left, s_top, s_right, s_bottom);
+
+    gschem_cairo_set_source_color (w_current->cr,
+                                   x_color_lookup_dark (BOUNDINGBOX_COLOR));
+    gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
   } else {
     o_glist_draw_place (w_current, diff_x, diff_y,
                         toplevel->page_current->place_list);
diff --git a/gschem/src/o_select.c b/gschem/src/o_select.c
index a98f0f4..0bd4046 100644
--- a/gschem/src/o_select.c
+++ b/gschem/src/o_select.c
@@ -315,21 +315,16 @@ void o_select_box_invalidate_rubber (GSCHEM_TOPLEVEL *w_current)
 void o_select_box_draw_rubber (GSCHEM_TOPLEVEL *w_current)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
-  int box_width, box_height, box_left, box_top;
   int x1, y1, x2, y2;
 
   WORLDtoSCREEN(toplevel, w_current->first_wx, w_current->first_wy, &x1, &y1);
   WORLDtoSCREEN(toplevel, w_current->second_wx, w_current->second_wy, &x2, &y2);
 
-  box_width = abs(x1 - x2);
-  box_height = abs(y1 - y2);
-  box_left = min(x1, x2);
-  box_top = min(y1, y2);
+  gschem_cairo_box (w_current->cr, 1, x1, y1, x2, y2);
 
-  gdk_gc_set_foreground (w_current->gc, x_get_darkcolor (SELECT_COLOR));
-  gdk_draw_rectangle (w_current->drawable, w_current->gc,
-                      FALSE,
-                      box_left, box_top, box_width, box_height);
+  gschem_cairo_set_source_color (w_current->cr,
+                                 x_color_lookup_dark (SELECT_COLOR));
+  gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
 }
 
 /*! \todo Finish function documentation!!!




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs