예제 #1
0
파일: gtkrender.c 프로젝트: Vort/gtk
/**
 * gtk_render_frame:
 * @context: a #GtkStyleContext
 * @cr: a #cairo_t
 * @x: X origin of the rectangle
 * @y: Y origin of the rectangle
 * @width: rectangle width
 * @height: rectangle height
 *
 * Renders a frame around the rectangle defined by @x, @y, @width, @height.
 *
 * Examples of frame rendering, showing the effect of `border-image`,
 * `border-color`, `border-width`, `border-radius` and junctions:
 *
 * ![](frames.png)
 *
 * Since: 3.0
 **/
void
gtk_render_frame (GtkStyleContext *context,
                  cairo_t         *cr,
                  gdouble          x,
                  gdouble          y,
                  gdouble          width,
                  gdouble          height)
{
  g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
  g_return_if_fail (cr != NULL);

  if (width <= 0 || height <= 0)
    return;

  cairo_save (cr);
  cairo_new_path (cr);

  gtk_css_style_render_border (gtk_style_context_lookup_style (context),
                               cr,
                               x, y, width, height,
                               0,
                               gtk_style_context_get_junction_sides (context));


  cairo_restore (cr);
}
예제 #2
0
파일: gtkrender.c 프로젝트: Vort/gtk
static void
gtk_do_render_slider (GtkStyleContext *context,
                      cairo_t         *cr,
                      gdouble          x,
                      gdouble          y,
                      gdouble          width,
                      gdouble          height,
                      GtkOrientation   orientation)
{
  GtkCssStyle *style;
  GtkJunctionSides junction;

  style = gtk_style_context_lookup_style (context);
  junction = gtk_style_context_get_junction_sides (context);

  gtk_css_style_render_background (style,
                                   cr,
                                   x, y, width, height,
                                   junction);
  gtk_css_style_render_border (style,
                               cr,
                               x, y, width, height,
                               0,
                               junction);
}
예제 #3
0
JNIEXPORT jint JNICALL
Java_org_gnome_gtk_GtkStyleContext_gtk_1style_1context_1get_1junction_1sides
(
	JNIEnv* env,
	jclass cls,
	jlong _self
)
{
	GtkJunctionSides result;
	jint _result;
	GtkStyleContext* self;

	// convert parameter self
	self = (GtkStyleContext*) _self;

	// call function
	result = gtk_style_context_get_junction_sides(self);

	// cleanup parameter self

	// translate return value to JNI type
	_result = (jint) result;

	// and finally
	return _result;
}
예제 #4
0
파일: gtkrender.c 프로젝트: Vort/gtk
static void
gtk_do_render_handle (GtkStyleContext *context,
                      cairo_t         *cr,
                      gdouble          x,
                      gdouble          y,
                      gdouble          width,
                      gdouble          height)
{
  GtkCssImageBuiltinType type;

  gtk_render_background (context, cr, x, y, width, height);
  gtk_render_frame (context, cr, x, y, width, height);

  if (gtk_style_context_has_class (context, GTK_STYLE_CLASS_GRIP))
    {
      GtkJunctionSides sides = gtk_style_context_get_junction_sides (context);

      /* order is important here for when too many (or too few) sides are set */
      if ((sides & GTK_JUNCTION_CORNER_BOTTOMRIGHT) == GTK_JUNCTION_CORNER_BOTTOMRIGHT)
        type = GTK_CSS_IMAGE_BUILTIN_GRIP_BOTTOMRIGHT;
      else if ((sides & GTK_JUNCTION_CORNER_TOPRIGHT) == GTK_JUNCTION_CORNER_TOPRIGHT)
        type = GTK_CSS_IMAGE_BUILTIN_GRIP_TOPRIGHT;
      else if ((sides & GTK_JUNCTION_CORNER_BOTTOMLEFT) == GTK_JUNCTION_CORNER_BOTTOMLEFT)
        type = GTK_CSS_IMAGE_BUILTIN_GRIP_BOTTOMLEFT;
      else if ((sides & GTK_JUNCTION_CORNER_TOPLEFT) == GTK_JUNCTION_CORNER_TOPLEFT)
        type = GTK_CSS_IMAGE_BUILTIN_GRIP_TOPLEFT;
      else if (sides & GTK_JUNCTION_RIGHT)
        type = GTK_CSS_IMAGE_BUILTIN_GRIP_RIGHT;
      else if (sides & GTK_JUNCTION_BOTTOM)
        type = GTK_CSS_IMAGE_BUILTIN_GRIP_BOTTOM;
      else if (sides & GTK_JUNCTION_TOP)
        type = GTK_CSS_IMAGE_BUILTIN_GRIP_TOP;
      else if (sides & GTK_JUNCTION_LEFT)
        type = GTK_CSS_IMAGE_BUILTIN_GRIP_LEFT;
      else
        type = GTK_CSS_IMAGE_BUILTIN_GRIP_BOTTOMRIGHT;
    }
  else if (gtk_style_context_has_class (context, GTK_STYLE_CLASS_PANE_SEPARATOR))
    {
      type = GTK_CSS_IMAGE_BUILTIN_PANE_SEPARATOR;
    }
  else
    {
      type = GTK_CSS_IMAGE_BUILTIN_HANDLE;
    }

  gtk_css_style_render_icon (gtk_style_context_lookup_style (context), cr, x, y, width, height, type);
}
예제 #5
0
파일: gtkrender.c 프로젝트: Vort/gtk
/**
 * gtk_render_frame_gap:
 * @context: a #GtkStyleContext
 * @cr: a #cairo_t
 * @x: X origin of the rectangle
 * @y: Y origin of the rectangle
 * @width: rectangle width
 * @height: rectangle height
 * @gap_side: side where the gap is
 * @xy0_gap: initial coordinate (X or Y depending on @gap_side) for the gap
 * @xy1_gap: end coordinate (X or Y depending on @gap_side) for the gap
 *
 * Renders a frame around the rectangle defined by (@x, @y, @width, @height),
 * leaving a gap on one side. @xy0_gap and @xy1_gap will mean X coordinates
 * for %GTK_POS_TOP and %GTK_POS_BOTTOM gap sides, and Y coordinates for
 * %GTK_POS_LEFT and %GTK_POS_RIGHT.
 *
 * Typical rendering of a frame with a gap:
 *
 * ![](frame-gap.png)
 *
 * Since: 3.0
 **/
void
gtk_render_frame_gap (GtkStyleContext *context,
                      cairo_t         *cr,
                      gdouble          x,
                      gdouble          y,
                      gdouble          width,
                      gdouble          height,
                      GtkPositionType  gap_side,
                      gdouble          xy0_gap,
                      gdouble          xy1_gap)
{
  g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
  g_return_if_fail (cr != NULL);
  g_return_if_fail (xy0_gap <= xy1_gap);
  g_return_if_fail (xy0_gap >= 0);

  if (width <= 0 || height <= 0)
    return;

  if (gap_side == GTK_POS_LEFT ||
      gap_side == GTK_POS_RIGHT)
    g_return_if_fail (xy1_gap <= height);
  else
    g_return_if_fail (xy1_gap <= width);

  cairo_save (cr);
  cairo_new_path (cr);

  gtk_css_style_render_frame_gap (gtk_style_context_lookup_style (context),
                                  cr,
                                  x, y, width, height, gap_side,
                                  xy0_gap, xy1_gap,
                                  gtk_style_context_get_junction_sides (context));


  cairo_restore (cr);
}