Esempio n. 1
0
wxRegionContain wxRegion::DoContainsRect(const wxRect& r) const
{
    if (!m_refData)
        return wxOutRegion;

    GdkRectangle rect;
    rect.x = r.x;
    rect.y = r.y;
    rect.width = r.width;
    rect.height = r.height;
#ifdef __WXGTK3__
    switch (cairo_region_contains_rectangle(M_REGIONDATA->m_region, &rect))
    {
        case CAIRO_REGION_OVERLAP_IN:   return wxInRegion;
        case CAIRO_REGION_OVERLAP_PART: return wxPartRegion;
        default: break;
    }
#else
    GdkOverlapType res = gdk_region_rect_in( M_REGIONDATA->m_region, &rect );
    switch (res)
    {
        case GDK_OVERLAP_RECTANGLE_IN:   return wxInRegion;
        case GDK_OVERLAP_RECTANGLE_OUT:  return wxOutRegion;
        case GDK_OVERLAP_RECTANGLE_PART: return wxPartRegion;
    }
#endif
    return wxOutRegion;
}
Esempio n. 2
0
static gboolean
piano_keyboard_expose(GtkWidget *widget, GdkEventExpose *event)
{
	int i;
	PianoKeyboard *pk = PIANO_KEYBOARD(widget);
	cairo_t* cr = gdk_cairo_create (GDK_DRAWABLE (GTK_WIDGET(pk)->window));

	gdk_cairo_region (cr, event->region);
	cairo_clip (cr);

	for (i = 0; i < NNOTES; i++) {
		GdkRectangle r;

		r.x = pk->notes[i].x;
		r.y = 0;
		r.width = pk->notes[i].w;
		r.height = pk->notes[i].h;

		switch (gdk_region_rect_in (event->region, &r)) {
		case GDK_OVERLAP_RECTANGLE_PART:
		case GDK_OVERLAP_RECTANGLE_IN:
			draw_note (pk, cr, i);
			break;
		default:
			break;
		}
	}

	cairo_destroy (cr);

	return TRUE;
}
Esempio n. 3
0
static VALUE
rg_rect_in(VALUE self, VALUE rect)
{
    return GENUM2RVAL(gdk_region_rect_in(
                          _SELF(self),
                          (GdkRectangle*)RVAL2BOXED(rect, GDK_TYPE_RECTANGLE)),
                      GDK_TYPE_OVERLAP_TYPE);
}
Esempio n. 4
0
bool SystemDraw::IsPaintingOp(const Rect& r) const
{
	Rect cr = r.Offseted(GetOffset());
	cr.Intersect(GetClip());
	if(cr.IsEmpty())
		return false;
	return !invalid || gdk_region_rect_in(invalid, GdkRect(cr)) != GDK_OVERLAP_RECTANGLE_OUT;
}
Esempio n. 5
0
wxRegionContain wxRegion::DoContainsRect(const wxRect& r) const
{
    if (!m_refData)
        return wxOutRegion;

    GdkRectangle rect;
    rect.x = r.x;
    rect.y = r.y;
    rect.width = r.width;
    rect.height = r.height;
    GdkOverlapType res = gdk_region_rect_in( M_REGIONDATA->m_region, &rect );
    switch (res)
    {
        case GDK_OVERLAP_RECTANGLE_IN:   return wxInRegion;
        case GDK_OVERLAP_RECTANGLE_OUT:  return wxOutRegion;
        case GDK_OVERLAP_RECTANGLE_PART: return wxPartRegion;
    }
    return wxOutRegion;
}
Esempio n. 6
0
/* Tests whether a rectangle is within a region. */
int
clip_GDK_REGIONRECTIN(ClipMachine * ClipMachineMemory)
{
   C_object *creg = _fetch_co_arg(ClipMachineMemory);

   ClipVar  *crect = _clip_spar(ClipMachineMemory, 2);

   GdkRectangle rect;

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

   _map_get_gdk_rectangle(ClipMachineMemory, crect, &rect);
   _clip_retni(ClipMachineMemory, gdk_region_rect_in(GDK_REGION(creg), &rect));

   return 0;
 err:
   return 1;
}
Esempio n. 7
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);
  }

}
Esempio n. 8
0
screen_saver_on_expose_event (ScreenSaver    *screen_saver,
                              GdkEventExpose *event)
#endif
{
    GList *tmp;
#if !GTK_CHECK_VERSION (3, 0, 0)
    cairo_t *context;
#endif

    if (screen_saver->floaters == NULL)
        screen_saver_create_floaters (screen_saver);

#if !GTK_CHECK_VERSION (3, 0, 0)
    context = gdk_cairo_create (screen_saver->drawing_area->window);

    cairo_rectangle (context,
                     (double) event->area.x,
                     (double) event->area.y,
                     (double) event->area.width,
                     (double) event->area.height);
    cairo_clip (context);
#endif

    screen_saver->floaters = g_list_sort (screen_saver->floaters,
                                          (GCompareFunc)compare_floaters);

    for (tmp = screen_saver->floaters; tmp != NULL; tmp = tmp->next)
    {
        ScreenSaverFloater *floater;
#if !GTK_CHECK_VERSION (3, 0, 0)
        GdkRectangle rect;
        gint size;
#endif

        floater = (ScreenSaverFloater *) tmp->data;

#if !GTK_CHECK_VERSION (3, 0, 0)
        size = CLAMP ((int) (FLOATER_MAX_SIZE * floater->scale),
                      FLOATER_MIN_SIZE, FLOATER_MAX_SIZE);

        rect.x = (int) (floater->position.x - .5 * G_SQRT2 * size);
        rect.y = (int) (floater->position.y - .5 * G_SQRT2 * size);
        rect.width = G_SQRT2 * size;
        rect.height = G_SQRT2 * size;

        if (!gdk_region_rect_in (event->region, &rect))
            continue;
#endif

        if (!screen_saver_floater_do_draw (screen_saver, floater, context))
        {
            gtk_main_quit ();
            break;
        }
    }

#if !GTK_CHECK_VERSION (3, 0, 0)
    cairo_destroy (context);
#endif

    screen_saver->draw_ops_pending = TRUE;
    screen_saver->frame_count++;
}
inf_text_gtk_viewport_scrollbar_expose_event_cb(GtkWidget* scrollbar,
                                                GdkEventExpose* event,
                                                gpointer user_data)
#endif
{
  InfTextGtkViewport* viewport;
  InfTextGtkViewportPrivate* priv;
  InfTextGtkViewportUser* viewport_user;
  GdkRectangle* rectangle;
  GdkColor* color;
  double h,s,v;
  double r,g,b;
  GSList* item;
  double line_width;

#if GTK_CHECK_VERSION(2, 91, 0)
  GdkRectangle clip_area;
#else
  cairo_t* cr;
#endif

  viewport = INF_TEXT_GTK_VIEWPORT(user_data);
  priv = INF_TEXT_GTK_VIEWPORT_PRIVATE(viewport);

  /* Can this happen? */
#if GTK_CHECK_VERSION(2, 91, 0)
  if(!gtk_cairo_should_draw_window(cr, gtk_widget_get_window(scrollbar)))
#elif GTK_CHECK_VERSION(2,14,0)
  if(event->window != gtk_widget_get_window(scrollbar))
#else
  if(event->window != GTK_WIDGET(scrollbar)->window)
#endif
    return FALSE;

  if(priv->show_user_markers)
  {
    color = &gtk_widget_get_style(scrollbar)->bg[GTK_STATE_NORMAL];
    h = color->red / 65535.0;
    s = color->green / 65535.0;
    v = color->blue / 65535.0;
    rgb_to_hsv(&h, &s, &v);
    s = MIN(MAX(s, 0.5), 0.8);
    v = MAX(v, 0.5);

#if GTK_CHECK_VERSION(2, 91, 0)
    gtk_cairo_transform_to_window(
      cr,
      GTK_WIDGET(scrollbar),
      gtk_widget_get_window(scrollbar)
    );

    gdk_cairo_get_clip_rectangle(cr, &clip_area);
#else
    cr = gdk_cairo_create(event->window);
#endif

    line_width = cairo_get_line_width(cr);
    for(item = priv->users; item != NULL; item = item->next)
    {
      viewport_user = (InfTextGtkViewportUser*)item->data;
      rectangle = &viewport_user->rectangle;

#if GTK_CHECK_VERSION(2, 91, 0)
      if(gdk_rectangle_intersect(&clip_area, rectangle, NULL))
#elif GTK_CHECK_VERSION(2,90,5)
      if(cairo_region_contains_rectangle(event->region, rectangle) !=
         CAIRO_REGION_OVERLAP_OUT)
#else
      if(gdk_region_rect_in(event->region, rectangle) !=
         GDK_OVERLAP_RECTANGLE_OUT)
#endif
      {
        h = inf_text_user_get_hue(viewport_user->user);

        cairo_rectangle(
          cr,
          rectangle->x + line_width/2,
          rectangle->y + line_width/2,
          rectangle->width - line_width,
          rectangle->height - line_width
        );

        r = h; g = s; b = v/2.0;
        hsv_to_rgb(&r, &g, &b);
        cairo_set_source_rgba(cr, r, g, b, 0.6);
        cairo_stroke_preserve(cr);

        r = h; g = s; b = v;
        hsv_to_rgb(&r, &g, &b);
        cairo_set_source_rgba(cr, r, g, b, 0.6);
        cairo_fill(cr);
      }
    }

#if ! GTK_CHECK_VERSION(2, 91, 0)
    cairo_destroy(cr);
#endif
  }

  return FALSE;
}