Exemplo n.º 1
0
void
draw_cairo_round_box (cairo_t      *cr,
                      GdkRectangle  rect,
                      gint          tl_radius,
                      gint          tr_radius,
                      gint          bl_radius,
                      gint          br_radius)
{
  gdouble right = rect.x + rect.width;
  gdouble bottom = rect.y + rect.height;

  cairo_new_sub_path (cr);
  cairo_move_to (cr, rect.x, rect.y + tl_radius);

  if (tl_radius > 0)
    draw_corner (cr, rect.x, rect.y, tl_radius, CORNER_TOP_LEFT);

  cairo_line_to (cr, right - tr_radius, rect.y);

  if (tr_radius > 0)
    draw_corner (cr, right, rect.y, tr_radius, CORNER_TOP_RIGHT);

  cairo_line_to (cr, right, bottom - br_radius);

  if (br_radius > 0)
    draw_corner (cr, right, bottom, br_radius, CORNER_BOTTOM_RIGHT);

  cairo_line_to (cr, rect.x + bl_radius, bottom);

  if (br_radius > 0)
    draw_corner (cr, rect.x, bottom, bl_radius, CORNER_BOTTOM_LEFT);

  cairo_close_path (cr);
}
Exemplo n.º 2
0
static void draw_hilite(GCanvas* canvas, Shape* shape) {
    canvas->save();
    shape->concat(canvas);

    GRect r = shape->getRect();
    const float size = CORNER_SIZE;
    GColor c = GColor::MakeARGB(1, 0, 0, 0);
    draw_corner(canvas, c, r.fLeft, r.fTop, size, size);
    draw_corner(canvas, c, r.fLeft, r.fBottom, size, -size);
    draw_corner(canvas, c, r.fRight, r.fTop, -size, size);
    draw_corner(canvas, c, r.fRight, r.fBottom, -size, -size);

    canvas->restore();
}