stylecontext: Split render functions out into gtkrender.[ch]

This commit is contained in:
Benjamin Otte 2014-06-15 17:57:59 +02:00
parent 763aa4db94
commit d3c147a62d
27 changed files with 1001 additions and 920 deletions

View File

@ -417,6 +417,7 @@ gtk_public_h_sources = \
gtkrecentchooserwidget.h \
gtkrecentfilter.h \
gtkrecentmanager.h \
gtkrender.h \
gtkrevealer.h \
gtkscale.h \
gtkscalebutton.h \
@ -1011,6 +1012,7 @@ gtk_base_c_sources = \
gtkrecentchooser.c \
gtkrecentfilter.c \
gtkrecentmanager.c \
gtkrender.c \
gtkresources.c \
gtkrevealer.c \
gtkroundedbox.c \

View File

@ -33,6 +33,7 @@
#include "gtkinvisible.h"
#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtkrender.h"
#include "gtkwindow.h"
#include "gtktypebuiltins.h"
#include "gtkprivate.h"

View File

@ -37,6 +37,7 @@
#include "gtkhsv.h"
#include "gtkbindings.h"
#include "gtkmarshalers.h"
#include "gtkrender.h"
#include "gtkstylecontext.h"
#include "gtktypebuiltins.h"
#include "gtkintl.h"

View File

@ -44,6 +44,7 @@
#include "gtktypebuiltins.h"
#include "gtkstyle.h"
#include "gtkstylecontextprivate.h"
#include "gtkrender.h"
/**
* SECTION:gtkiconfactory

View File

@ -41,7 +41,7 @@
#include "gtkiconfactory.h"
#include "gtkintl.h"
#include "gtkdebug.h"
#include "gtkspinner.h"
#include "gtkrender.h"
#include "gtkborder.h"
#include "gtkwidgetpath.h"

View File

@ -26,6 +26,7 @@
#include "gtkmenu.h"
#include "gtkmenuitemprivate.h"
#include "gtkrender.h"
#include "gtkstylecontext.h"
#include "gtktearoffmenuitem.h"
#include "gtkintl.h"

View File

@ -35,6 +35,7 @@
#include "gtktestutils.h"
#include "gtkdebug.h"
#include "gtktypebuiltins.h"
#include "gtkrender.h"
#define SYSTEM_TRAY_REQUEST_DOCK 0
#define SYSTEM_TRAY_BEGIN_MESSAGE 1

View File

@ -166,6 +166,7 @@
#include <gtk/gtkrecentchooserwidget.h>
#include <gtk/gtkrecentfilter.h>
#include <gtk/gtkrecentmanager.h>
#include <gtk/gtkrender.h>
#include <gtk/gtkrevealer.h>
#include <gtk/gtkscale.h>
#include <gtk/gtkscalebutton.h>

View File

@ -30,10 +30,11 @@
#include "gtkaccellabel.h"
#include "gtkaccelmap.h"
#include "gtkmain.h"
#include "gtksizerequest.h"
#include "gtkprivate.h"
#include "gtkintl.h"
#include "gtkmain.h"
#include "gtkprivate.h"
#include "gtkrender.h"
#include "gtksizerequest.h"
/**
* SECTION:gtkaccellabel

View File

@ -81,6 +81,7 @@
#include "gtkmarshalers.h"
#include "gtktooltip.h"
#include "gtkprivate.h"
#include "gtkrender.h"
#define TIMEOUT_INITIAL 500
#define TIMEOUT_REPEAT 50

View File

@ -351,6 +351,7 @@
#include "gtkcellareacontext.h"
#include "gtkmarshalers.h"
#include "gtkprivate.h"
#include "gtkrender.h"
#include <gobject/gvaluecollector.h>

View File

@ -27,9 +27,10 @@
#include <stdlib.h>
#include "gtkcellrendererprogress.h"
#include "gtkintl.h"
#include "gtkorientable.h"
#include "gtkprivate.h"
#include "gtkintl.h"
#include "gtkrender.h"
/**

View File

@ -31,6 +31,7 @@
#include "gtkintl.h"
#include "gtkprivate.h"
#include "gtkrender.h"
#include "gtkwidgetprivate.h"

View File

@ -32,13 +32,14 @@
#include "gtkcolorswatchprivate.h"
#include "gtkcolorutils.h"
#include "gtkgrid.h"
#include "gtkintl.h"
#include "gtkorientable.h"
#include "gtkentry.h"
#include "gtkoverlay.h"
#include "gtkadjustment.h"
#include "gtklabel.h"
#include "gtkrender.h"
#include "gtkspinbutton.h"
#include "gtkintl.h"
#include "gtkstylecontext.h"
#include <math.h>

View File

@ -26,10 +26,10 @@
#include "gtkeventbox.h"
#include "gtksizerequest.h"
#include "gtkprivate.h"
#include "gtkintl.h"
#include "gtkprivate.h"
#include "gtkrender.h"
#include "gtksizerequest.h"
/**

View File

@ -23,6 +23,7 @@
#include "gtkgrid.h"
#include "gtkorientableprivate.h"
#include "gtkrender.h"
#include "gtksizerequest.h"
#include "gtkwidgetprivate.h"
#include "gtkprivate.h"

View File

@ -45,6 +45,7 @@
#include "gtkintl.h"
#include "gtkprivate.h"
#include "gtkorientable.h"
#include "gtkrender.h"
#include "gtktypebuiltins.h"
#include "deprecated/gtkstock.h"

View File

@ -43,6 +43,7 @@
#include "gtkmenuitemprivate.h"
#include "gtkmenuprivate.h"
#include "gtkmenushellprivate.h"
#include "gtkrender.h"
#include "gtksettings.h"
#include "gtksizerequest.h"
#include "gtkwindow.h"

View File

@ -28,6 +28,7 @@
#include "gtkimage.h"
#include "gtklabel.h"
#include "gtkbox.h"
#include "gtkrender.h"
#include "gtkstylecontext.h"
#include "gtktypebuiltins.h"

809
gtk/gtkrender.c Normal file
View File

@ -0,0 +1,809 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkrender.h"
#include "gtkcssenginevalueprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkthemingengine.h"
#include "gtkthemingengineprivate.h"
/**
* gtk_render_check:
* @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 checkmark (as in a #GtkCheckButton).
*
* The %GTK_STATE_FLAG_ACTIVE state determines whether the check is
* on or off, and %GTK_STATE_FLAG_INCONSISTENT determines whether it
* should be marked as undefined.
*
* Typical checkmark rendering:
*
* ![](checks.png)
*
* Since: 3.0
**/
void
gtk_render_check (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
if (width <= 0 || height <= 0)
return;
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_check (engine, cr,
x, y, width, height);
cairo_restore (cr);
}
/**
* gtk_render_option:
* @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 an option mark (as in a #GtkRadioButton), the %GTK_STATE_FLAG_ACTIVE
* state will determine whether the option is on or off, and
* %GTK_STATE_FLAG_INCONSISTENT whether it should be marked as undefined.
*
* Typical option mark rendering:
*
* ![](options.png)
*
* Since: 3.0
**/
void
gtk_render_option (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
if (width <= 0 || height <= 0)
return;
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_option (engine, cr,
x, y, width, height);
cairo_restore (cr);
}
/**
* gtk_render_arrow:
* @context: a #GtkStyleContext
* @cr: a #cairo_t
* @angle: arrow angle from 0 to 2 * %G_PI, being 0 the arrow pointing to the north
* @x: X origin of the render area
* @y: Y origin of the render area
* @size: square side for render area
*
* Renders an arrow pointing to @angle.
*
* Typical arrow rendering at 0, 1&solidus;2 &pi;, &pi; and 3&solidus;2 &pi;:
*
* ![](arrows.png)
*
* Since: 3.0
**/
void
gtk_render_arrow (GtkStyleContext *context,
cairo_t *cr,
gdouble angle,
gdouble x,
gdouble y,
gdouble size)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
if (size <= 0)
return;
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
gtk_style_context_save (context);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_ARROW);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_arrow (engine, cr,
angle, x, y, size);
gtk_style_context_restore (context);
cairo_restore (cr);
}
/**
* gtk_render_background:
* @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 the background of an element.
*
* Typical background rendering, showing the effect of
* `background-image`, `border-width` and `border-radius`:
*
* ![](background.png)
*
* Since: 3.0.
**/
void
gtk_render_background (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
if (width <= 0 || height <= 0)
return;
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_background (engine, cr, x, y, width, height);
cairo_restore (cr);
}
/**
* 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)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
if (width <= 0 || height <= 0)
return;
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_frame (engine, cr, x, y, width, height);
cairo_restore (cr);
}
/**
* gtk_render_expander:
* @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 an expander (as used in #GtkTreeView and #GtkExpander) in the area
* defined by @x, @y, @width, @height. The state %GTK_STATE_FLAG_ACTIVE
* determines whether the expander is collapsed or expanded.
*
* Typical expander rendering:
*
* ![](expanders.png)
*
* Since: 3.0
**/
void
gtk_render_expander (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
if (width <= 0 || height <= 0)
return;
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_expander (engine, cr, x, y, width, height);
cairo_restore (cr);
}
/**
* gtk_render_focus:
* @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 focus indicator on the rectangle determined by @x, @y, @width, @height.
*
* Typical focus rendering:
*
* ![](focus.png)
*
* Since: 3.0
**/
void
gtk_render_focus (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
if (width <= 0 || height <= 0)
return;
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_focus (engine, cr, x, y, width, height);
cairo_restore (cr);
}
/**
* gtk_render_layout:
* @context: a #GtkStyleContext
* @cr: a #cairo_t
* @x: X origin
* @y: Y origin
* @layout: the #PangoLayout to render
*
* Renders @layout on the coordinates @x, @y
*
* Since: 3.0
**/
void
gtk_render_layout (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
PangoLayout *layout)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (PANGO_IS_LAYOUT (layout));
g_return_if_fail (cr != NULL);
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_layout (engine, cr, x, y, layout);
cairo_restore (cr);
}
/**
* gtk_render_line:
* @context: a #GtkStyleContext
* @cr: a #cairo_t
* @x0: X coordinate for the origin of the line
* @y0: Y coordinate for the origin of the line
* @x1: X coordinate for the end of the line
* @y1: Y coordinate for the end of the line
*
* Renders a line from (x0, y0) to (x1, y1).
*
* Since: 3.0
**/
void
gtk_render_line (GtkStyleContext *context,
cairo_t *cr,
gdouble x0,
gdouble y0,
gdouble x1,
gdouble y1)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_line (engine, cr, x0, y0, x1, y1);
cairo_restore (cr);
}
/**
* gtk_render_slider:
* @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
* @orientation: orientation of the slider
*
* Renders a slider (as in #GtkScale) in the rectangle defined by @x, @y,
* @width, @height. @orientation defines whether the slider is vertical
* or horizontal.
*
* Typical slider rendering:
*
* ![](sliders.png)
*
* Since: 3.0
**/
void
gtk_render_slider (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
GtkOrientation orientation)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
if (width <= 0 || height <= 0)
return;
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_slider (engine, cr, x, y, width, height, orientation);
cairo_restore (cr);
}
/**
* 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)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
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);
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_frame_gap (engine, cr,
x, y, width, height, gap_side,
xy0_gap, xy1_gap);
cairo_restore (cr);
}
/**
* gtk_render_extension:
* @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
*
* Renders a extension (as in a #GtkNotebook tab) in the rectangle
* defined by @x, @y, @width, @height. The side where the extension
* connects to is defined by @gap_side.
*
* Typical extension rendering:
*
* ![](extensions.png)
*
* Since: 3.0
**/
void
gtk_render_extension (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
GtkPositionType gap_side)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
if (width <= 0 || height <= 0)
return;
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_extension (engine, cr, x, y, width, height, gap_side);
cairo_restore (cr);
}
/**
* gtk_render_handle:
* @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 handle (as in #GtkHandleBox, #GtkPaned and
* #GtkWindows resize grip), in the rectangle
* determined by @x, @y, @width, @height.
*
* Handles rendered for the paned and grip classes:
*
* ![](handles.png)
*
* Since: 3.0
**/
void
gtk_render_handle (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
if (width <= 0 || height <= 0)
return;
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_handle (engine, cr, x, y, width, height);
cairo_restore (cr);
}
/**
* gtk_render_activity:
* @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 an activity indicator (such as in #GtkSpinner).
* The state %GTK_STATE_FLAG_ACTIVE determines whether there is
* activity going on.
*
* Since: 3.0
**/
void
gtk_render_activity (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
if (width <= 0 || height <= 0)
return;
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_activity (engine, cr, x, y, width, height);
cairo_restore (cr);
}
/**
* gtk_render_icon_pixbuf:
* @context: a #GtkStyleContext
* @source: the #GtkIconSource specifying the icon to render
* @size: (type int): the size to render the icon at. A size of (GtkIconSize) -1
* means render at the size of the source and dont scale.
*
* Renders the icon specified by @source at the given @size, returning the result
* in a pixbuf.
*
* Returns: (transfer full): a newly-created #GdkPixbuf containing the rendered icon
*
* Since: 3.0
*
* Deprecated: 3.10: Use gtk_icon_theme_load_icon() instead.
**/
GdkPixbuf *
gtk_render_icon_pixbuf (GtkStyleContext *context,
const GtkIconSource *source,
GtkIconSize size)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
g_return_val_if_fail (size > GTK_ICON_SIZE_INVALID || size == -1, NULL);
g_return_val_if_fail (source != NULL, NULL);
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
_gtk_theming_engine_set_context (engine, context);
return engine_class->render_icon_pixbuf (engine, source, size);
}
/**
* gtk_render_icon:
* @context: a #GtkStyleContext
* @cr: a #cairo_t
* @pixbuf: a #GdkPixbuf containing the icon to draw
* @x: X position for the @pixbuf
* @y: Y position for the @pixbuf
*
* Renders the icon in @pixbuf at the specified @x and @y coordinates.
*
* Since: 3.2
**/
void
gtk_render_icon (GtkStyleContext *context,
cairo_t *cr,
GdkPixbuf *pixbuf,
gdouble x,
gdouble y)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_icon (engine, cr, pixbuf, x, y);
cairo_restore (cr);
}
/**
* gtk_render_icon_surface:
* @context: a #GtkStyleContext
* @cr: a #cairo_t
* @surface: a #cairo_surface_t containing the icon to draw
* @x: X position for the @icon
* @y: Y position for the @incon
*
* Renders the icon in @surface at the specified @x and @y coordinates.
*
* Since: 3.10
**/
void
gtk_render_icon_surface (GtkStyleContext *context,
cairo_t *cr,
cairo_surface_t *surface,
gdouble x,
gdouble y)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_icon_surface (engine, cr, surface, x, y);
cairo_restore (cr);
}

155
gtk/gtkrender.h Normal file
View File

@ -0,0 +1,155 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_RENDER_H__
#define __GTK_RENDER_H__
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <cairo.h>
#include <pango/pango.h>
#include <gdk/gdk.h>
#include <gtk/gtkenums.h>
#include <gtk/gtktypes.h>
G_BEGIN_DECLS
GDK_AVAILABLE_IN_ALL
void gtk_render_check (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height);
GDK_AVAILABLE_IN_ALL
void gtk_render_option (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height);
GDK_AVAILABLE_IN_ALL
void gtk_render_arrow (GtkStyleContext *context,
cairo_t *cr,
gdouble angle,
gdouble x,
gdouble y,
gdouble size);
GDK_AVAILABLE_IN_ALL
void gtk_render_background (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height);
GDK_AVAILABLE_IN_ALL
void gtk_render_frame (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height);
GDK_AVAILABLE_IN_ALL
void gtk_render_expander (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height);
GDK_AVAILABLE_IN_ALL
void gtk_render_focus (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height);
GDK_AVAILABLE_IN_ALL
void gtk_render_layout (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
PangoLayout *layout);
GDK_AVAILABLE_IN_ALL
void gtk_render_line (GtkStyleContext *context,
cairo_t *cr,
gdouble x0,
gdouble y0,
gdouble x1,
gdouble y1);
GDK_AVAILABLE_IN_ALL
void gtk_render_slider (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
GtkOrientation orientation);
GDK_AVAILABLE_IN_ALL
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);
GDK_AVAILABLE_IN_ALL
void gtk_render_extension (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
GtkPositionType gap_side);
GDK_AVAILABLE_IN_ALL
void gtk_render_handle (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height);
GDK_AVAILABLE_IN_ALL
void gtk_render_activity (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height);
GDK_DEPRECATED_IN_3_10_FOR(gtk_icon_theme_load_icon)
GdkPixbuf * gtk_render_icon_pixbuf (GtkStyleContext *context,
const GtkIconSource *source,
GtkIconSize size);
GDK_AVAILABLE_IN_3_2
void gtk_render_icon (GtkStyleContext *context,
cairo_t *cr,
GdkPixbuf *pixbuf,
gdouble x,
gdouble y);
GDK_AVAILABLE_IN_3_10
void gtk_render_icon_surface (GtkStyleContext *context,
cairo_t *cr,
cairo_surface_t *surface,
gdouble x,
gdouble y);
G_END_DECLS
#endif /* __GTK_RENDER_H__ */

View File

@ -31,7 +31,7 @@
#include "gtkentryprivate.h"
#include "gtkintl.h"
#include "gtkprivate.h"
#include "gtkstylecontext.h"
#include "gtkrender.h"
#include "gtksearchbar.h"
/**

View File

@ -24,10 +24,12 @@
#include "config.h"
#include "gtkorientableprivate.h"
#include "gtkseparator.h"
#include "gtkprivate.h"
#include "gtkorientableprivate.h"
#include "gtkintl.h"
#include "gtkprivate.h"
#include "gtkrender.h"
/**
* SECTION:gtkseparator

View File

@ -26,7 +26,6 @@
#include "gtkcontainerprivate.h"
#include "gtkcsscolorvalueprivate.h"
#include "gtkcsscornervalueprivate.h"
#include "gtkcssenginevalueprivate.h"
#include "gtkcssenumvalueprivate.h"
#include "gtkcssimagevalueprivate.h"
#include "gtkcssnumbervalueprivate.h"
@ -3522,791 +3521,6 @@ _gtk_style_context_get_cursor_color (GtkStyleContext *context,
get_cursor_color (context, FALSE, secondary_color);
}
/* Paint methods */
/**
* gtk_render_check:
* @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 checkmark (as in a #GtkCheckButton).
*
* The %GTK_STATE_FLAG_ACTIVE state determines whether the check is
* on or off, and %GTK_STATE_FLAG_INCONSISTENT determines whether it
* should be marked as undefined.
*
* Typical checkmark rendering:
*
* ![](checks.png)
*
* Since: 3.0
**/
void
gtk_render_check (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
if (width <= 0 || height <= 0)
return;
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_check (engine, cr,
x, y, width, height);
cairo_restore (cr);
}
/**
* gtk_render_option:
* @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 an option mark (as in a #GtkRadioButton), the %GTK_STATE_FLAG_ACTIVE
* state will determine whether the option is on or off, and
* %GTK_STATE_FLAG_INCONSISTENT whether it should be marked as undefined.
*
* Typical option mark rendering:
*
* ![](options.png)
*
* Since: 3.0
**/
void
gtk_render_option (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
if (width <= 0 || height <= 0)
return;
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_option (engine, cr,
x, y, width, height);
cairo_restore (cr);
}
/**
* gtk_render_arrow:
* @context: a #GtkStyleContext
* @cr: a #cairo_t
* @angle: arrow angle from 0 to 2 * %G_PI, being 0 the arrow pointing to the north
* @x: X origin of the render area
* @y: Y origin of the render area
* @size: square side for render area
*
* Renders an arrow pointing to @angle.
*
* Typical arrow rendering at 0, 1&solidus;2 &pi;, &pi; and 3&solidus;2 &pi;:
*
* ![](arrows.png)
*
* Since: 3.0
**/
void
gtk_render_arrow (GtkStyleContext *context,
cairo_t *cr,
gdouble angle,
gdouble x,
gdouble y,
gdouble size)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
if (size <= 0)
return;
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
gtk_style_context_save (context);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_ARROW);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_arrow (engine, cr,
angle, x, y, size);
gtk_style_context_restore (context);
cairo_restore (cr);
}
/**
* gtk_render_background:
* @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 the background of an element.
*
* Typical background rendering, showing the effect of
* `background-image`, `border-width` and `border-radius`:
*
* ![](background.png)
*
* Since: 3.0.
**/
void
gtk_render_background (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
if (width <= 0 || height <= 0)
return;
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_background (engine, cr, x, y, width, height);
cairo_restore (cr);
}
/**
* 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)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
if (width <= 0 || height <= 0)
return;
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_frame (engine, cr, x, y, width, height);
cairo_restore (cr);
}
/**
* gtk_render_expander:
* @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 an expander (as used in #GtkTreeView and #GtkExpander) in the area
* defined by @x, @y, @width, @height. The state %GTK_STATE_FLAG_ACTIVE
* determines whether the expander is collapsed or expanded.
*
* Typical expander rendering:
*
* ![](expanders.png)
*
* Since: 3.0
**/
void
gtk_render_expander (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
if (width <= 0 || height <= 0)
return;
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_expander (engine, cr, x, y, width, height);
cairo_restore (cr);
}
/**
* gtk_render_focus:
* @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 focus indicator on the rectangle determined by @x, @y, @width, @height.
*
* Typical focus rendering:
*
* ![](focus.png)
*
* Since: 3.0
**/
void
gtk_render_focus (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
if (width <= 0 || height <= 0)
return;
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_focus (engine, cr, x, y, width, height);
cairo_restore (cr);
}
/**
* gtk_render_layout:
* @context: a #GtkStyleContext
* @cr: a #cairo_t
* @x: X origin
* @y: Y origin
* @layout: the #PangoLayout to render
*
* Renders @layout on the coordinates @x, @y
*
* Since: 3.0
**/
void
gtk_render_layout (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
PangoLayout *layout)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (PANGO_IS_LAYOUT (layout));
g_return_if_fail (cr != NULL);
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_layout (engine, cr, x, y, layout);
cairo_restore (cr);
}
/**
* gtk_render_line:
* @context: a #GtkStyleContext
* @cr: a #cairo_t
* @x0: X coordinate for the origin of the line
* @y0: Y coordinate for the origin of the line
* @x1: X coordinate for the end of the line
* @y1: Y coordinate for the end of the line
*
* Renders a line from (x0, y0) to (x1, y1).
*
* Since: 3.0
**/
void
gtk_render_line (GtkStyleContext *context,
cairo_t *cr,
gdouble x0,
gdouble y0,
gdouble x1,
gdouble y1)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_line (engine, cr, x0, y0, x1, y1);
cairo_restore (cr);
}
/**
* gtk_render_slider:
* @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
* @orientation: orientation of the slider
*
* Renders a slider (as in #GtkScale) in the rectangle defined by @x, @y,
* @width, @height. @orientation defines whether the slider is vertical
* or horizontal.
*
* Typical slider rendering:
*
* ![](sliders.png)
*
* Since: 3.0
**/
void
gtk_render_slider (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
GtkOrientation orientation)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
if (width <= 0 || height <= 0)
return;
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_slider (engine, cr, x, y, width, height, orientation);
cairo_restore (cr);
}
/**
* 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)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
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);
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_frame_gap (engine, cr,
x, y, width, height, gap_side,
xy0_gap, xy1_gap);
cairo_restore (cr);
}
/**
* gtk_render_extension:
* @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
*
* Renders a extension (as in a #GtkNotebook tab) in the rectangle
* defined by @x, @y, @width, @height. The side where the extension
* connects to is defined by @gap_side.
*
* Typical extension rendering:
*
* ![](extensions.png)
*
* Since: 3.0
**/
void
gtk_render_extension (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
GtkPositionType gap_side)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
if (width <= 0 || height <= 0)
return;
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_extension (engine, cr, x, y, width, height, gap_side);
cairo_restore (cr);
}
/**
* gtk_render_handle:
* @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 handle (as in #GtkHandleBox, #GtkPaned and
* #GtkWindows resize grip), in the rectangle
* determined by @x, @y, @width, @height.
*
* Handles rendered for the paned and grip classes:
*
* ![](handles.png)
*
* Since: 3.0
**/
void
gtk_render_handle (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
if (width <= 0 || height <= 0)
return;
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_handle (engine, cr, x, y, width, height);
cairo_restore (cr);
}
/**
* gtk_render_activity:
* @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 an activity indicator (such as in #GtkSpinner).
* The state %GTK_STATE_FLAG_ACTIVE determines whether there is
* activity going on.
*
* Since: 3.0
**/
void
gtk_render_activity (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
if (width <= 0 || height <= 0)
return;
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_activity (engine, cr, x, y, width, height);
cairo_restore (cr);
}
/**
* gtk_render_icon_pixbuf:
* @context: a #GtkStyleContext
* @source: the #GtkIconSource specifying the icon to render
* @size: (type int): the size to render the icon at. A size of (GtkIconSize) -1
* means render at the size of the source and dont scale.
*
* Renders the icon specified by @source at the given @size, returning the result
* in a pixbuf.
*
* Returns: (transfer full): a newly-created #GdkPixbuf containing the rendered icon
*
* Since: 3.0
*
* Deprecated: 3.10: Use gtk_icon_theme_load_icon() instead.
**/
GdkPixbuf *
gtk_render_icon_pixbuf (GtkStyleContext *context,
const GtkIconSource *source,
GtkIconSize size)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
g_return_val_if_fail (size > GTK_ICON_SIZE_INVALID || size == -1, NULL);
g_return_val_if_fail (source != NULL, NULL);
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
_gtk_theming_engine_set_context (engine, context);
return engine_class->render_icon_pixbuf (engine, source, size);
}
/**
* gtk_render_icon:
* @context: a #GtkStyleContext
* @cr: a #cairo_t
* @pixbuf: a #GdkPixbuf containing the icon to draw
* @x: X position for the @pixbuf
* @y: Y position for the @pixbuf
*
* Renders the icon in @pixbuf at the specified @x and @y coordinates.
*
* Since: 3.2
**/
void
gtk_render_icon (GtkStyleContext *context,
cairo_t *cr,
GdkPixbuf *pixbuf,
gdouble x,
gdouble y)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_icon (engine, cr, pixbuf, x, y);
cairo_restore (cr);
}
/**
* gtk_render_icon_surface:
* @context: a #GtkStyleContext
* @cr: a #cairo_t
* @surface: a #cairo_surface_t containing the icon to draw
* @x: X position for the @icon
* @y: Y position for the @incon
*
* Renders the icon in @surface at the specified @x and @y coordinates.
*
* Since: 3.10
**/
void
gtk_render_icon_surface (GtkStyleContext *context,
cairo_t *cr,
cairo_surface_t *surface,
gdouble x,
gdouble y)
{
GtkThemingEngineClass *engine_class;
GtkThemingEngine *engine;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
engine = _gtk_css_engine_value_get_engine (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ENGINE));
engine_class = GTK_THEMING_ENGINE_GET_CLASS (engine);
cairo_save (cr);
cairo_new_path (cr);
_gtk_theming_engine_set_context (engine, context);
engine_class->render_icon_surface (engine, cr, surface, x, y);
cairo_restore (cr);
}
static void
draw_insertion_cursor (GtkStyleContext *context,
cairo_t *cr,

View File

@ -1118,125 +1118,6 @@ GDK_AVAILABLE_IN_ALL
void gtk_style_context_set_background (GtkStyleContext *context,
GdkWindow *window);
/* Paint methods */
GDK_AVAILABLE_IN_ALL
void gtk_render_check (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height);
GDK_AVAILABLE_IN_ALL
void gtk_render_option (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height);
GDK_AVAILABLE_IN_ALL
void gtk_render_arrow (GtkStyleContext *context,
cairo_t *cr,
gdouble angle,
gdouble x,
gdouble y,
gdouble size);
GDK_AVAILABLE_IN_ALL
void gtk_render_background (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height);
GDK_AVAILABLE_IN_ALL
void gtk_render_frame (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height);
GDK_AVAILABLE_IN_ALL
void gtk_render_expander (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height);
GDK_AVAILABLE_IN_ALL
void gtk_render_focus (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height);
GDK_AVAILABLE_IN_ALL
void gtk_render_layout (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
PangoLayout *layout);
GDK_AVAILABLE_IN_ALL
void gtk_render_line (GtkStyleContext *context,
cairo_t *cr,
gdouble x0,
gdouble y0,
gdouble x1,
gdouble y1);
GDK_AVAILABLE_IN_ALL
void gtk_render_slider (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
GtkOrientation orientation);
GDK_AVAILABLE_IN_ALL
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);
GDK_AVAILABLE_IN_ALL
void gtk_render_extension (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
GtkPositionType gap_side);
GDK_AVAILABLE_IN_ALL
void gtk_render_handle (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height);
GDK_AVAILABLE_IN_ALL
void gtk_render_activity (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height);
GDK_DEPRECATED_IN_3_10_FOR(gtk_icon_theme_load_icon)
GdkPixbuf * gtk_render_icon_pixbuf (GtkStyleContext *context,
const GtkIconSource *source,
GtkIconSize size);
GDK_AVAILABLE_IN_3_2
void gtk_render_icon (GtkStyleContext *context,
cairo_t *cr,
GdkPixbuf *pixbuf,
gdouble x,
gdouble y);
GDK_AVAILABLE_IN_3_10
void gtk_render_icon_surface (GtkStyleContext *context,
cairo_t *cr,
cairo_surface_t *surface,
gdouble x,
gdouble y);
GDK_AVAILABLE_IN_3_4
void gtk_render_insertion_cursor
(GtkStyleContext *context,

View File

@ -37,22 +37,23 @@
#include "gtktoolbarprivate.h"
#include "gtkbindings.h"
#include "gtkbox.h"
#include "gtkcontainerprivate.h"
#include "gtkimage.h"
#include "gtkintl.h"
#include "gtklabel.h"
#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtkmenu.h"
#include "gtkorientable.h"
#include "gtkorientableprivate.h"
#include "gtkprivate.h"
#include "gtkradiobutton.h"
#include "gtkradiotoolbutton.h"
#include "gtkrender.h"
#include "gtkseparatormenuitem.h"
#include "gtkseparatortoolitem.h"
#include "gtktoolshell.h"
#include "gtkbox.h"
#include "gtkprivate.h"
#include "gtkintl.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetpath.h"
#include "gtkwidgetprivate.h"

View File

@ -32,6 +32,7 @@
#include "gtkpixelcacheprivate.h"
#include "gtkprivate.h"
#include "gtkscrollable.h"
#include "gtkrender.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"