Ejemplo n.º 1
0
void
ghid_invalidate_all ()
{
    int eleft, eright, etop, ebottom;
    BoxType region;

    if (!gport->pixmap)
        return;

    region.X1 = MIN(Px(0), Px(gport->width + 1));
    region.Y1 = MIN(Py(0), Py(gport->height + 1));
    region.X2 = MAX(Px(0), Px(gport->width + 1));
    region.Y2 = MAX(Py(0), Py(gport->height + 1));

    eleft = Vx (0);
    eright = Vx (PCB->MaxWidth);
    etop = Vy (0);
    ebottom = Vy (PCB->MaxHeight);
    if (eleft > eright)
    {
        int tmp = eleft;
        eleft = eright;
        eright = tmp;
    }
    if (etop > ebottom)
    {
        int tmp = etop;
        etop = ebottom;
        ebottom = tmp;
    }

    if (eleft > 0)
        gdk_draw_rectangle (gport->drawable, gport->offlimits_gc,
                            1, 0, 0, eleft, gport->height);
    else
        eleft = 0;
    if (eright < gport->width)
        gdk_draw_rectangle (gport->drawable, gport->offlimits_gc,
                            1, eright, 0, gport->width - eright, gport->height);
    else
        eright = gport->width;
    if (etop > 0)
        gdk_draw_rectangle (gport->drawable, gport->offlimits_gc,
                            1, eleft, 0, eright - eleft + 1, etop);
    else
        etop = 0;
    if (ebottom < gport->height)
        gdk_draw_rectangle (gport->drawable, gport->offlimits_gc,
                            1, eleft, ebottom, eright - eleft + 1,
                            gport->height - ebottom);
    else
        ebottom = gport->height;

    gdk_draw_rectangle (gport->drawable, gport->bg_gc, 1,
                        eleft, etop, eright - eleft + 1, ebottom - etop + 1);

    ghid_draw_bg_image();

    hid_expose_callback (&ghid_hid, &region, 0);
    ghid_draw_grid ();
    if (ghidgui->need_restore_crosshair)
        RestoreCrosshair (FALSE);
    ghidgui->need_restore_crosshair = FALSE;
    ghid_screen_update ();
}
Ejemplo n.º 2
0
static void
redraw_region (GdkRectangle *rect)
{
  int eleft, eright, etop, ebottom;
  BoxType region;
  render_priv *priv = gport->render_priv;

  if (!gport->pixmap)
    return;

  if (rect != NULL)
    {
      priv->clip_rect = *rect;
      priv->clip = true;
    }
  else
    {
      priv->clip_rect.x = 0;
      priv->clip_rect.y = 0;
      priv->clip_rect.width = gport->width;
      priv->clip_rect.height = gport->height;
      priv->clip = false;
    }

  set_clip (priv, priv->bg_gc);
  set_clip (priv, priv->offlimits_gc);
  set_clip (priv, priv->mask_gc);
  set_clip (priv, priv->grid_gc);

  region.X1 = MIN(Px(priv->clip_rect.x),
                  Px(priv->clip_rect.x + priv->clip_rect.width + 1));
  region.Y1 = MIN(Py(priv->clip_rect.y),
                  Py(priv->clip_rect.y + priv->clip_rect.height + 1));
  region.X2 = MAX(Px(priv->clip_rect.x),
                  Px(priv->clip_rect.x + priv->clip_rect.width + 1));
  region.Y2 = MAX(Py(priv->clip_rect.y),
                  Py(priv->clip_rect.y + priv->clip_rect.height + 1));

  region.X1 = MAX (0, MIN (PCB->MaxWidth,  region.X1));
  region.X2 = MAX (0, MIN (PCB->MaxWidth,  region.X2));
  region.Y1 = MAX (0, MIN (PCB->MaxHeight, region.Y1));
  region.Y2 = MAX (0, MIN (PCB->MaxHeight, region.Y2));

  eleft = Vx (0);
  eright = Vx (PCB->MaxWidth);
  etop = Vy (0);
  ebottom = Vy (PCB->MaxHeight);
  if (eleft > eright)
    {
      int tmp = eleft;
      eleft = eright;
      eright = tmp;
    }
  if (etop > ebottom)
    {
      int tmp = etop;
      etop = ebottom;
      ebottom = tmp;
    }

  if (eleft > 0)
    gdk_draw_rectangle (gport->drawable, priv->offlimits_gc,
                        1, 0, 0, eleft, gport->height);
  else
    eleft = 0;
  if (eright < gport->width)
    gdk_draw_rectangle (gport->drawable, priv->offlimits_gc,
                        1, eright, 0, gport->width - eright, gport->height);
  else
    eright = gport->width;
  if (etop > 0)
    gdk_draw_rectangle (gport->drawable, priv->offlimits_gc,
                        1, eleft, 0, eright - eleft + 1, etop);
  else
    etop = 0;
  if (ebottom < gport->height)
    gdk_draw_rectangle (gport->drawable, priv->offlimits_gc,
                        1, eleft, ebottom, eright - eleft + 1,
                        gport->height - ebottom);
  else
    ebottom = gport->height;

  gdk_draw_rectangle (gport->drawable, priv->bg_gc, 1,
                      eleft, etop, eright - eleft + 1, ebottom - etop + 1);

  ghid_draw_bg_image();

  hid_expose_callback (&ghid_hid, &region, 0);
  ghid_draw_grid ();

  /* In some cases we are called with the crosshair still off */
  if (priv->attached_invalidate_depth == 0)
    DrawAttached ();

  /* In some cases we are called with the mark still off */
  if (priv->mark_invalidate_depth == 0)
    DrawMark ();

  draw_lead_user (priv);

  priv->clip = false;

  /* Rest the clip for bg_gc, as it is used outside this function */
  gdk_gc_set_clip_mask (priv->bg_gc, NULL);
}