Beispiel #1
0
/* Returns the union of a region and a rectangle. */
int
clip_GDK_REGIONUNIONWITHRECT(ClipMachine * ClipMachineMemory)
{
   C_object *creg = _fetch_co_arg(ClipMachineMemory);

   ClipVar  *crect = _clip_spar(ClipMachineMemory, 2);

   C_object *cdest;

   GdkRectangle rect;

   CHECKCOBJ(creg, GDK_IS_REGION(creg->object));
   CHECKARG(2, MAP_type_of_ClipVarType);

   _map_get_gdk_rectangle(ClipMachineMemory, crect, &rect);
   gdk_region_union_with_rect(GDK_REGION(creg), &rect);

   if (creg)
    {
       cdest = _register_object(ClipMachineMemory, GDK_REGION(creg), GDK_TYPE_REGION, NULL, NULL);
       if (cdest)
	  _clip_mclone(ClipMachineMemory, RETPTR(ClipMachineMemory), &cdest->obj);
    }

   return 0;
 err:
   return 1;
}
Beispiel #2
0
gboolean button_pressed_ACTION_ROTATE (GtkWidget *widget, GdkEventButton *event, gpointer data)
  {
  project_OP *project_options = (project_OP *)data ;
  QCADDesignObject *htobj = NULL ;
  GdkRegion *rgn = NULL ;

  if (NULL != (htobj = QCAD_DESIGN_OBJECT (design_hit_test (project_options->design, event->x, event->y))))
    if (QCAD_IS_CELL (htobj))
      {
      GdkRectangle rcReal ;
      selection_renderer_draw (project_options->srSelection, project_options->design, widget->window, GDK_XOR) ;
      qcad_cell_rotate_dots (QCAD_CELL (htobj), PI / 4.0) ;
      selection_renderer_update (project_options->srSelection, project_options->design) ;
      selection_renderer_draw (project_options->srSelection, project_options->design, widget->window, GDK_XOR) ;

      world_to_real_rect (&(htobj->bounding_box), &rcReal) ;

      rgn = gdk_region_new () ;
      gdk_region_union_with_rect (rgn, &rcReal) ;

      // redraw_async takes care of destroying rgn
      redraw_async (rgn) ;
      }

  return FALSE ;
  }
Beispiel #3
0
bool wxRegion::DoUnionWithRect(const wxRect& r)
{
    // workaround for a strange GTK/X11 bug: taking union with an empty
    // rectangle results in an empty region which is definitely not what we
    // want
    if ( r.IsEmpty() )
        return TRUE;

    if ( !m_refData )
    {
        InitRect(r.x, r.y, r.width, r.height);
    }
    else
    {
        AllocExclusive();

        GdkRectangle rect;
        rect.x = r.x;
        rect.y = r.y;
        rect.width = r.width;
        rect.height = r.height;

        GdkRegion *reg = gdk_region_union_with_rect( M_REGIONDATA->m_region, &rect );
        gdk_region_destroy( M_REGIONDATA->m_region );
        M_REGIONDATA->m_region = reg;
    }

    return TRUE;
}
static void
clip_region_add_rect(DiaRenderer *object,
		 Rectangle *rect)
{
  DiaCairoInteractiveRenderer *renderer = DIA_CAIRO_INTERACTIVE_RENDERER (object);
  GdkRectangle clip_rect;
  int x1,y1;
  int x2,y2;

  DiaTransform *transform;        /* Our link to the display settings */

  transform = dia_transform_new(renderer->visible,renderer->zoom_factor);
  dia_transform_coords(transform, rect->left, rect->top,  &x1, &y1);
  dia_transform_coords(transform, rect->right, rect->bottom,  &x2, &y2);
  g_object_unref(transform);
  
  clip_rect.x = x1;
  clip_rect.y = y1;
  clip_rect.width = x2 - x1 + 1;
  clip_rect.height = y2 - y1 + 1;

  gdk_region_union_with_rect( renderer->clip_region, &clip_rect );
  
  gdk_gc_set_clip_region(renderer->gc, renderer->clip_region);
}
void
gimp_display_shell_expose_region (GimpDisplayShell *shell,
                                  cairo_region_t   *region)
{
  GdkRegion *gdk_region;
  gint       n_rectangles;
  gint       i;

  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
  g_return_if_fail (region != NULL);

  if (! gtk_widget_get_realized (shell->canvas))
    return;

  gdk_region = gdk_region_new ();
  n_rectangles = cairo_region_num_rectangles (region);

  for (i = 0; i < n_rectangles; i++)
    {
      cairo_rectangle_int_t rectangle;

      cairo_region_get_rectangle (region, i, &rectangle);

      gdk_region_union_with_rect (gdk_region, (GdkRectangle *) &rectangle);
    }

  gdk_window_invalidate_region (gtk_widget_get_window (shell->canvas),
                                gdk_region, TRUE);
  gdk_region_destroy (gdk_region);
}
Beispiel #6
0
bool wxRegion::DoUnionWithRect(const wxRect& r)
{
    // workaround for a strange GTK/X11 bug: taking union with an empty
    // rectangle results in an empty region which is definitely not what we
    // want
    if ( r.IsEmpty() )
        return true;

    if ( !m_refData )
    {
        InitRect(r.x, r.y, r.width, r.height);
    }
    else
    {
        AllocExclusive();

        GdkRectangle rect;
        rect.x = r.x;
        rect.y = r.y;
        rect.width = r.width;
        rect.height = r.height;

#ifdef __WXGTK3__
        cairo_region_union_rectangle(M_REGIONDATA->m_region, &rect);
#else
        gdk_region_union_with_rect( M_REGIONDATA->m_region, &rect );
#endif
    }

    return true;
}
Beispiel #7
0
static void
box_sync_region(HosOrnament *self)
{
  HosCanvas *canvas = self->canvas;
  HosBox *box = HOS_BOX(self);
  gdouble x1 = box->x1;
  gdouble xn = box->xn;
  gdouble y1 = box->y1;
  gdouble yn = box->yn;
  gdouble tmp;

  GdkRectangle rect;

  ornament_invalidate_region(self);

  canvas_ppm2view(canvas, &x1, &y1);
  canvas_ppm2view(canvas, &xn, &yn);

  if (x1 > xn) {tmp = x1; x1 = xn; xn = tmp;}
  if (y1 > yn) {tmp = y1; y1 = yn; yn = tmp;}

  rect.x = x1 - box_click_radius;
  rect.y = y1 - box_click_radius;
  rect.width = xn - x1 + 2 * box_click_radius;
  rect.height = 2 * box_click_radius;

  ornament_set_region(self, gdk_region_rectangle(&rect));

  rect.y = yn - box_click_radius;
  gdk_region_union_with_rect(self->region, &rect);

  rect.width = 2 * box_click_radius;
  rect.y = y1 - box_click_radius;
  rect.height = yn - y1 + 2 * box_click_radius;
  gdk_region_union_with_rect(self->region, &rect);

  rect.x = xn - box_click_radius;
  gdk_region_union_with_rect(self->region, &rect);

  ornament_invalidate_region(self);

}
Beispiel #8
0
static VALUE
rg_union(VALUE self, VALUE other)
{
    if (RVAL2GTYPE(other) == GDK_TYPE_RECTANGLE){
        gdk_region_union_with_rect(_SELF(self),
                                   (GdkRectangle*)RVAL2BOXED(other, GDK_TYPE_RECTANGLE));
    } else {
        gdk_region_union(_SELF(self), _SELF(other));
    }
    return self;
}
Beispiel #9
0
void wxRegion::InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
{
    GdkRectangle rect;
    rect.x = x;
    rect.y = y;
    rect.width = w;
    rect.height = h;

    m_refData = new wxRegionRefData();

    M_REGIONDATA->m_region = gdk_region_union_with_rect( wxGdkRegion(), &rect );
}
void GraphicsContext::drawFocusRing(const Color& color)
{
    if (paintingDisabled())
        return;

    const Vector<IntRect>& rects = focusRingRects();
    unsigned rectCount = rects.size();

    cairo_t* cr = m_data->cr;
    cairo_save(cr);
    cairo_push_group(cr);
    cairo_new_path(cr);

#if PLATFORM(GTK)
    GdkRegion* reg = gdk_region_new();
    for (unsigned i = 0; i < rectCount; i++) {
        GdkRectangle rect = rects[i];
        gdk_region_union_with_rect(reg, &rect);
    }
    gdk_cairo_region(cr, reg);
    gdk_region_destroy(reg);

    setColor(cr, color);
    cairo_set_line_width(cr, 2.0f);
    setPlatformStrokeStyle(DottedStroke);
#else
    int radius = (focusRingWidth() - 1) / 2;
    for (unsigned i = 0; i < rectCount; i++)
        addPath(Path::createRoundedRectangle(rects[i], FloatSize(radius, radius)));

    // Force the alpha to 50%.  This matches what the Mac does with outline rings.
    Color ringColor(color.red(), color.green(), color.blue(), 127);
    setColor(cr, ringColor);
    cairo_set_line_width(cr, focusRingWidth());
    setPlatformStrokeStyle(SolidStroke);
#endif

    cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
    cairo_stroke_preserve(cr);

    cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
    cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING);
    cairo_fill(cr);

    cairo_pop_group_to_source(cr);
    cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
    cairo_paint(cr);
    cairo_restore(cr);
}
Beispiel #11
0
static void
cvw_set_dirty(CcViewWidget* self, CcDRect dirty) {
	if(G_UNLIKELY(!GTK_WIDGET_REALIZED(self))) {
		return;
	}

	if(G_UNLIKELY(!self->root)) {
		return;
	}

	{
		GtkWidget* widget = GTK_WIDGET(self);
		CcDRect visible = {
			0.0, 0.0,
			1.0 * widget->allocation.width, 1.0 * widget->allocation.height
		};

		cc_view_world_to_window(CC_VIEW(self), &dirty.x1, &dirty.y1);
		cc_view_world_to_window(CC_VIEW(self), &dirty.x2, &dirty.y2);

		dirty.x1 = floor(dirty.x1);
		dirty.y1 = floor(dirty.y1);
		dirty.x2 = ceil (dirty.x2);
		dirty.y2 = ceil (dirty.y2);

		if(cc_d_rect_intersect(dirty, visible)) {
			GdkRectangle rect = {((gint)dirty.x1),
					      ((gint)dirty.y1),
					      ((gint)dirty.x2 - dirty.x1),
					      ((gint)dirty.y2 - dirty.y1)};

			if(G_UNLIKELY(!self->priv->redraw_timeout)) {
				self->priv->dirty_region = gdk_region_new();
				self->priv->redraw_timeout = g_timeout_add(40, // ~25 FPS
									   (GSourceFunc)cvw_redraw_timeout,
									   self);
			}

			gdk_region_union_with_rect(self->priv->dirty_region, &rect);
#ifdef DEBUG_SAVED_FRAMES
			self->priv->requests++;
#endif
		}
	}
}
Beispiel #12
0
static void
clip_region_add_rect(DiaRenderer *object,
		 Rectangle *rect)
{
  DiaGdkRenderer *renderer = DIA_GDK_RENDERER (object);
  GdkRectangle clip_rect;
  int x1,y1;
  int x2,y2;

  dia_transform_coords(renderer->transform, rect->left, rect->top,  &x1, &y1);
  dia_transform_coords(renderer->transform, rect->right, rect->bottom,  &x2, &y2);
  
  clip_rect.x = x1;
  clip_rect.y = y1;
  clip_rect.width = x2 - x1 + 1;
  clip_rect.height = y2 - y1 + 1;

  gdk_region_union_with_rect( renderer->clip_region, &clip_rect );
  
  gdk_gc_set_clip_region(renderer->gc, renderer->clip_region);
}
Beispiel #13
0
static GdkRegion *
window_get_shape (GdkScreen       *screen,
                  GdkNativeWindow  window)
{
  GdkRegion  *shape = NULL;

#if defined(GDK_WINDOWING_X11) && defined(HAVE_X11_EXTENSIONS_SHAPE_H)
  XRectangle *rects;
  gint        rect_count;
  gint        rect_order;

  rects = XShapeGetRectangles (GDK_SCREEN_XDISPLAY (screen), window,
                               ShapeBounding,
                               &rect_count, &rect_order);

  if (rects)
    {
      if (rect_count > 1)
        {
          gint i;

          shape = gdk_region_new ();

          for (i = 0; i < rect_count; i++)
            {
              GdkRectangle rect = { rects[i].x,
                                    rects[i].y,
                                    rects[i].width,
                                    rects[i].height };

              gdk_region_union_with_rect (shape, &rect);
            }
        }

      XFree (rects);
    }
#endif

  return shape;
}
Beispiel #14
0
static GdkRegion *
get_selected_clip (GtkTextRenderState *render_state,
                   PangoLayout        *layout,
                   PangoLayoutLine    *line,
                   int                 x,
                   int                 y,
                   int                 height,
                   int                 start_index,
                   int                 end_index)
{
  gint *ranges;
  gint n_ranges, i;
  GdkRegion *clip_region = gdk_region_new ();
  GdkRegion *tmp_region;

  pango_layout_line_get_x_ranges (line, start_index, end_index, &ranges, &n_ranges);

  for (i=0; i < n_ranges; i++)
    {
      GdkRectangle rect;

      rect.x = x + PANGO_PIXELS (ranges[2*i]);
      rect.y = y;
      rect.width = PANGO_PIXELS (ranges[2*i + 1]) - PANGO_PIXELS (ranges[2*i]);
      rect.height = height;
      
      gdk_region_union_with_rect (clip_region, &rect);
    }

  tmp_region = gdk_region_rectangle (&render_state->clip_rect);
  gdk_region_intersect (clip_region, tmp_region);
  gdk_region_destroy (tmp_region);

  g_free (ranges);
  return clip_region;
}
void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int /* offset */, const Color& color)
{
    if (paintingDisabled())
        return;

    unsigned rectCount = rects.size();

    cairo_t* cr = platformContext()->cr();
    cairo_save(cr);
    cairo_push_group(cr);
    cairo_new_path(cr);

#if PLATFORM(GTK)
#ifdef GTK_API_VERSION_2
    GdkRegion* reg = gdk_region_new();
#else
    cairo_region_t* reg = cairo_region_create();
#endif

    for (unsigned i = 0; i < rectCount; i++) {
#ifdef GTK_API_VERSION_2
        GdkRectangle rect = rects[i];
        gdk_region_union_with_rect(reg, &rect);
#else
        cairo_rectangle_int_t rect = rects[i];
        cairo_region_union_rectangle(reg, &rect);
#endif
    }
    gdk_cairo_region(cr, reg);
#ifdef GTK_API_VERSION_2
    gdk_region_destroy(reg);
#else
    cairo_region_destroy(reg);
#endif
#else
    int radius = (width - 1) / 2;
    Path path;
    for (unsigned i = 0; i < rectCount; ++i) {
        if (i > 0)
            path.clear();
        path.addRoundedRect(rects[i], FloatSize(radius, radius));
        appendWebCorePathToCairoContext(cr, path);
    }
#endif
    Color ringColor = color;
    adjustFocusRingColor(ringColor);
    adjustFocusRingLineWidth(width);
    setSourceRGBAFromColor(cr, ringColor);
    cairo_set_line_width(cr, width);
    setPlatformStrokeStyle(focusRingStrokeStyle());

    cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
    cairo_stroke_preserve(cr);

    cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
    cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING);
    cairo_fill(cr);

    cairo_pop_group_to_source(cr);
    cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
    cairo_paint(cr);
    cairo_restore(cr);
}
void scenemanager_claim_rectangle(scenemanager_t* pSceneManager, GdkRectangle* pRect)
{
	// Add the area of the rectangle to the region
	gdk_region_union_with_rect(pSceneManager->pTakenRegion, pRect);
}
Beispiel #17
0
/* static */
void gdk_superwin_handle_expose (GdkSuperWin *superwin, XEvent *xevent,
                                 GdkRegion **region, gboolean dont_recurse)
{
  GSList *tmp_list;
  gboolean send_event = TRUE;
  unsigned long serial = xevent->xany.serial;
  XEvent extra_event;
  GdkRectangle rect;
  GdkRegion *tmp_region = NULL;
  gboolean   is_special = TRUE;

  /* set up our rect for the damaged area */
  rect.x = xevent->xexpose.x;
  rect.y = xevent->xexpose.y;
  rect.width = xevent->xexpose.width;
  rect.height = xevent->xexpose.height;

  /* try to see if this is a special event that matches an antiexpose */
  tmp_list = superwin->translate_queue;
  while (tmp_list) {
    GdkSuperWinTranslate *xlate = tmp_list->data;
    if (xlate->type == GDK_SUPERWIN_ANTIEXPOSE && serial == xlate->serial) {
      GdkRegion *antiexpose_region = gdk_region_new();
      tmp_region = gdk_region_union_with_rect(antiexpose_region, 
                                              &xlate->data.antiexpose.rect);
      gdk_region_destroy(antiexpose_region);
      antiexpose_region = tmp_region;
      /* if the rect of the expose event is contained in the
         antiexpose then we should just drop it on the floor. */
      if (gdk_region_rect_in(antiexpose_region, &rect) == GDK_OVERLAP_RECTANGLE_IN) {
        gdk_region_destroy(antiexpose_region);
        goto end;
      }
      gdk_region_destroy(antiexpose_region);

    }
    tmp_list = tmp_list->next;
  }

  /* we walk the list looking for any transformations */
  tmp_list = superwin->translate_queue;
  while (tmp_list) {
    GdkSuperWinTranslate *xlate = tmp_list->data;
    /* apply translations to this event if we can. */
    if (xlate->type == GDK_SUPERWIN_TRANSLATION && serial < xlate->serial ) {
      rect.x += xlate->data.translation.dx;
      rect.y += xlate->data.translation.dy;
    }
    tmp_list = tmp_list->next;
  }

  /* add this expose area to our damaged rect */

  tmp_region = gdk_region_union_with_rect(*region, &rect);
  gdk_region_destroy(*region);
  *region = tmp_region;

 end:

  /* remove any events from the queue that are old */
  tmp_list = superwin->translate_queue;
  while (tmp_list) {
    GdkSuperWinTranslate *xlate = tmp_list->data;
    if (serial > xlate->serial) {
      GSList *tmp_link = tmp_list;
      tmp_list = tmp_list->next;
      superwin->translate_queue = g_slist_remove_link(superwin->translate_queue,
                                                      tmp_link);
      g_free(tmp_link->data);
      g_slist_free_1(tmp_link);
    }
    else {
      tmp_list = tmp_list->next;
    }
  }

  /* if we're not supposed to recurse or paint then return now */
  if (dont_recurse)
    return;

  /* try to do any expose event compression we can */
  while (XCheckTypedWindowEvent(xevent->xany.display,
                                xevent->xany.window,
                                Expose,
                                &extra_event) == True) {
    gdk_superwin_handle_expose(superwin, &extra_event, region, TRUE);
  }

  /* if the region isn't empty, send the paint event */
  if (gdk_region_empty(*region) == FALSE) {
      GdkRectangle clip_box;
      gdk_region_get_clipbox(*region, &clip_box);
      if (superwin->paint_func)
        superwin->paint_func(clip_box.x, clip_box.y,
                             clip_box.width, clip_box.height,
                             superwin->func_data);
  }

}