Beispiel #1
0
/* Calculates the union of two rectangles. The union of rectangles
 * src1 and src2 is the smallest rectangle which includes both
 * src1 and src2 within it. */
int
clip_GDK_RECTANGLEUNION(ClipMachine * ClipMachineMemory)
{
   ClipVar  *creg1 = _clip_spar(ClipMachineMemory, 1);

   ClipVar  *creg2 = _clip_spar(ClipMachineMemory, 2);

   ClipVar  *cdest = RETPTR(ClipMachineMemory);

   GdkRectangle reg1, reg2, dest;

   CHECKARG(1, MAP_type_of_ClipVarType);
   CHECKARG(2, MAP_type_of_ClipVarType);
   CHECKARG(3, MAP_type_of_ClipVarType);

   _map_get_gdk_rectangle(ClipMachineMemory, creg1, &reg1);
   _map_get_gdk_rectangle(ClipMachineMemory, creg2, &reg2);

   gdk_rectangle_union(&reg1, &reg2, &dest);

   memset(cdest, 0, sizeof(*cdest));
   _clip_map(ClipMachineMemory, cdest);
   _map_put_gdk_rectangle(ClipMachineMemory, cdest, &dest);

   return 0;
 err:
   return 1;
}
Beispiel #2
0
static VALUE
rg_union(VALUE self, VALUE other)
{
    GdkRectangle dest;
    gdk_rectangle_union(_SELF(self), _SELF(other), &dest);
    return GDKRECTANGLE2RVAL(&dest);
}
Beispiel #3
0
static VALUE
rg_union(VALUE self, VALUE other)
{
    GdkRectangle dest;
    gdk_rectangle_union(_SELF(self), _SELF(other), &dest);
    return BOXED2RVAL(&dest, GDK_TYPE_RECTANGLE);
}
Beispiel #4
0
static VALUE
rg_union(VALUE self, VALUE other)
{
    GtkAllocation dest;
    gdk_rectangle_union(_SELF(self), _SELF(other), &dest);
    return GTKALLOCATION2RVAL(&dest);
}
static void union_with_clip (GtkWidget *widget,
                 gpointer   clip)
{
    GtkAllocation widget_clip;

    if (!gtk_widget_is_visible (widget) ||
            !gtk_widget_get_child_visible (widget))
        return;

    gtk_widget_get_clip (widget, &widget_clip);

    gdk_rectangle_union (&widget_clip, clip, clip);
}
Beispiel #6
0
/*#
    @method union GdkRectangle
    @brief Calculates the union of two rectangles.
    @param src a GdkRectangle.
    @return a GdkRectangle that is the smallest rectangle containing both this rectangle and the GdkRectangle specified by src.
 */
FALCON_FUNC Rectangle::union_( VMARG )
{
    Item* i_src = vm->param( 0 );
#ifndef NO_PARAMETER_CHECK
    if ( !i_src || !i_src->isObject() || !IS_DERIVED( i_src, GdkRectangle ) )
        throw_inv_params( "GdkRectangle" );
#endif
    GdkRectangle* src1 = GET_RECTANGLE( vm->self() );
    GdkRectangle* src2 = GET_RECTANGLE( *i_src );
    GdkRectangle dest;
    gdk_rectangle_union( src1, src2, &dest );
    vm->retval( new Gdk::Rectangle( vm->findWKI( "GdkRectangle" )->asClass(), &dest ) );
}
Beispiel #7
0
static void
splash_rectangle_union (GdkRectangle   *dest,
                        PangoRectangle *pango_rect,
                        gint            offset_x,
                        gint            offset_y)
{
  GdkRectangle  rect;

  rect.x      = pango_rect->x + offset_x;
  rect.y      = pango_rect->y + offset_y;
  rect.width  = pango_rect->width;
  rect.height = pango_rect->height;

  if (dest->width > 0 && dest->height > 0)
    gdk_rectangle_union (dest, &rect, dest);
  else
    *dest = rect;
}
static void
compute_size(GtkCellRenderer      *cell,
             GtkWidget            *widget,
             GdkRectangle         *cell_area,
             /* content rect relative to cell area */
             GdkRectangle         *content_rect_p,
             /* individual items relative to content_rect.x, content_rect.y */
             GdkRectangle         *photo_rect_p,
             GdkRectangle         *name_rect_p,
             GdkRectangle         *song_rect_p,
             GdkRectangle         *artist_rect_p,
             GdkRectangle         *note_rect_p)
{
    HippoPersonRenderer *renderer;
    PangoRectangle prect;
    GdkRectangle content_rect;
    GdkRectangle photo_rect;
    GdkRectangle name_rect;
    GdkRectangle song_rect;
    GdkRectangle artist_rect;
    GdkRectangle note_rect;
    int padded_width;
    int padded_height;
    int photo_margin;

    renderer = HIPPO_PERSON_RENDERER(cell);

    update_caches(renderer, widget);

    /* First get all the sizes, then compute positions */

    if (renderer->photo) {
        photo_rect.width = PHOTO_SIZE;
        photo_rect.height = PHOTO_SIZE;
        photo_margin = PHOTO_MARGIN_RIGHT;
    } else {
        photo_rect.width = 0;
        photo_rect.height = 0;
        photo_margin = 0;
    }
    
    note_rect.width = NOTE_SIZE;
    note_rect.height = NOTE_SIZE;

    pango_layout_get_pixel_extents(renderer->name_layout, NULL, &prect);
    name_rect.width = prect.width;
    name_rect.height = prect.height;
    
    pango_layout_get_pixel_extents(renderer->song_layout, NULL, &prect);
    song_rect.width = prect.width;
    song_rect.height = prect.height;    

    pango_layout_get_pixel_extents(renderer->artist_layout, NULL, &prect);
    artist_rect.width = prect.width;
    artist_rect.height = prect.height;    

    /* now positions */

    photo_rect.x = 0;
    photo_rect.y = 0;
    
    name_rect.x = photo_rect.x + photo_rect.width + photo_margin;
    name_rect.y = 0;
    
    note_rect.x = name_rect.x;
    note_rect.y = name_rect.y + name_rect.height + NAME_MARGIN_BOTTOM;
    
    song_rect.x = note_rect.x + note_rect.y + NOTE_MARGIN_RIGHT;
    song_rect.y = note_rect.y;
    
    artist_rect.x = song_rect.x;
    artist_rect.y = song_rect.y + song_rect.height + SONG_MARGIN_BOTTOM;

    /* Now compute content rect by union of all other rects, then 
     * translate to be relative to the cell
     */
    content_rect.x = 0;
    content_rect.y = 0;
    content_rect.width = 0;
    content_rect.height = 0;

    gdk_rectangle_union(&content_rect, &photo_rect, &content_rect);    
    gdk_rectangle_union(&content_rect, &name_rect, &content_rect);
    gdk_rectangle_union(&content_rect, &note_rect, &content_rect);
    gdk_rectangle_union(&content_rect, &song_rect, &content_rect);    
    gdk_rectangle_union(&content_rect, &artist_rect, &content_rect);

    if (photo_rect.height < content_rect.height) {
        /* center photo rect vertically */
        photo_rect.y = (content_rect.height - photo_rect.height) / 2;
    }

    padded_width  = (int) cell->xpad * 2 + content_rect.width;
    padded_height = (int) cell->ypad * 2 + content_rect.height;

    if (cell_area && content_rect.width > 0 && content_rect.height > 0) {
        content_rect.x = (((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ?
                            1.0 - cell->xalign : cell->xalign) * 
                            (cell_area->width - padded_width - cell->xpad * 2));
        content_rect.x = MAX (content_rect.x, 0) + cell->xpad;

        content_rect.y = (cell->yalign *
                           (cell_area->height - padded_height - 2 * cell->ypad));
        content_rect.y = MAX (content_rect.y, 0) + cell->ypad;
    }
    
    content_rect.width = padded_width;
    content_rect.height = padded_height;
    
#define OUT(what) do { if (what ## _p) { * what ## _p = what; }  } while(0)
    OUT(content_rect);
    OUT(photo_rect);
    OUT(name_rect);
    OUT(song_rect);
    OUT(artist_rect);
    OUT(note_rect);
}