diff --git a/gtk/Makefile.am b/gtk/Makefile.am index fcae22bb8c..bb9b080ee6 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -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 \ diff --git a/gtk/deprecated/gtkhandlebox.c b/gtk/deprecated/gtkhandlebox.c index 3fb37c3399..3d2046b16d 100644 --- a/gtk/deprecated/gtkhandlebox.c +++ b/gtk/deprecated/gtkhandlebox.c @@ -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" diff --git a/gtk/deprecated/gtkhsv.c b/gtk/deprecated/gtkhsv.c index eb7de5f231..2da78cc397 100644 --- a/gtk/deprecated/gtkhsv.c +++ b/gtk/deprecated/gtkhsv.c @@ -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" diff --git a/gtk/deprecated/gtkiconfactory.c b/gtk/deprecated/gtkiconfactory.c index 0911e73da0..56a4e5ecd7 100644 --- a/gtk/deprecated/gtkiconfactory.c +++ b/gtk/deprecated/gtkiconfactory.c @@ -44,6 +44,7 @@ #include "gtktypebuiltins.h" #include "gtkstyle.h" #include "gtkstylecontextprivate.h" +#include "gtkrender.h" /** * SECTION:gtkiconfactory diff --git a/gtk/deprecated/gtkstyle.c b/gtk/deprecated/gtkstyle.c index 7a001bbf28..2c3bde61a6 100644 --- a/gtk/deprecated/gtkstyle.c +++ b/gtk/deprecated/gtkstyle.c @@ -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" diff --git a/gtk/deprecated/gtktearoffmenuitem.c b/gtk/deprecated/gtktearoffmenuitem.c index c850d665f1..87fdb80176 100644 --- a/gtk/deprecated/gtktearoffmenuitem.c +++ b/gtk/deprecated/gtktearoffmenuitem.c @@ -26,6 +26,7 @@ #include "gtkmenu.h" #include "gtkmenuitemprivate.h" +#include "gtkrender.h" #include "gtkstylecontext.h" #include "gtktearoffmenuitem.h" #include "gtkintl.h" diff --git a/gtk/deprecated/gtktrayicon-x11.c b/gtk/deprecated/gtktrayicon-x11.c index 503d64b65b..2f696f0d13 100644 --- a/gtk/deprecated/gtktrayicon-x11.c +++ b/gtk/deprecated/gtktrayicon-x11.c @@ -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 diff --git a/gtk/gtk.h b/gtk/gtk.h index 330f14a315..9155c2abc9 100644 --- a/gtk/gtk.h +++ b/gtk/gtk.h @@ -166,6 +166,7 @@ #include #include #include +#include #include #include #include diff --git a/gtk/gtkaccellabel.c b/gtk/gtkaccellabel.c index 132c1d6fcd..5289fa12e0 100644 --- a/gtk/gtkaccellabel.c +++ b/gtk/gtkaccellabel.c @@ -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 diff --git a/gtk/gtkcalendar.c b/gtk/gtkcalendar.c index 47f1e8bca9..0f6b5e1be0 100644 --- a/gtk/gtkcalendar.c +++ b/gtk/gtkcalendar.c @@ -81,6 +81,7 @@ #include "gtkmarshalers.h" #include "gtktooltip.h" #include "gtkprivate.h" +#include "gtkrender.h" #define TIMEOUT_INITIAL 500 #define TIMEOUT_REPEAT 50 diff --git a/gtk/gtkcellarea.c b/gtk/gtkcellarea.c index 753f00e76f..eb82de3efd 100644 --- a/gtk/gtkcellarea.c +++ b/gtk/gtkcellarea.c @@ -351,6 +351,7 @@ #include "gtkcellareacontext.h" #include "gtkmarshalers.h" #include "gtkprivate.h" +#include "gtkrender.h" #include diff --git a/gtk/gtkcellrendererprogress.c b/gtk/gtkcellrendererprogress.c index ec5aa31397..55e2d0c4a5 100644 --- a/gtk/gtkcellrendererprogress.c +++ b/gtk/gtkcellrendererprogress.c @@ -27,9 +27,10 @@ #include #include "gtkcellrendererprogress.h" +#include "gtkintl.h" #include "gtkorientable.h" #include "gtkprivate.h" -#include "gtkintl.h" +#include "gtkrender.h" /** diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c index c9adcc0247..80ac9e7c77 100644 --- a/gtk/gtkcheckbutton.c +++ b/gtk/gtkcheckbutton.c @@ -31,6 +31,7 @@ #include "gtkintl.h" #include "gtkprivate.h" +#include "gtkrender.h" #include "gtkwidgetprivate.h" diff --git a/gtk/gtkcoloreditor.c b/gtk/gtkcoloreditor.c index c2027500ad..d3eeee037d 100644 --- a/gtk/gtkcoloreditor.c +++ b/gtk/gtkcoloreditor.c @@ -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 diff --git a/gtk/gtkeventbox.c b/gtk/gtkeventbox.c index 38c8d91cf6..1f2369769d 100644 --- a/gtk/gtkeventbox.c +++ b/gtk/gtkeventbox.c @@ -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" /** diff --git a/gtk/gtkgrid.c b/gtk/gtkgrid.c index ce4a7dca43..1b821b22d0 100644 --- a/gtk/gtkgrid.c +++ b/gtk/gtkgrid.c @@ -23,6 +23,7 @@ #include "gtkgrid.h" #include "gtkorientableprivate.h" +#include "gtkrender.h" #include "gtksizerequest.h" #include "gtkwidgetprivate.h" #include "gtkprivate.h" diff --git a/gtk/gtkinfobar.c b/gtk/gtkinfobar.c index fd3f3e3a01..6737bedb99 100644 --- a/gtk/gtkinfobar.c +++ b/gtk/gtkinfobar.c @@ -45,6 +45,7 @@ #include "gtkintl.h" #include "gtkprivate.h" #include "gtkorientable.h" +#include "gtkrender.h" #include "gtktypebuiltins.h" #include "deprecated/gtkstock.h" diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c index e9d985b657..a2693420f9 100644 --- a/gtk/gtkmenubar.c +++ b/gtk/gtkmenubar.c @@ -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" diff --git a/gtk/gtkmodelbutton.c b/gtk/gtkmodelbutton.c index 8762839799..cf4e451241 100644 --- a/gtk/gtkmodelbutton.c +++ b/gtk/gtkmodelbutton.c @@ -28,6 +28,7 @@ #include "gtkimage.h" #include "gtklabel.h" #include "gtkbox.h" +#include "gtkrender.h" #include "gtkstylecontext.h" #include "gtktypebuiltins.h" diff --git a/gtk/gtkrender.c b/gtk/gtkrender.c new file mode 100644 index 0000000000..64d9a78519 --- /dev/null +++ b/gtk/gtkrender.c @@ -0,0 +1,809 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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 . + */ + +#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 π, π and 3&solidus;2 π: + * + * ![](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 + * #GtkWindow’s 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 don’t 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); +} + diff --git a/gtk/gtkrender.h b/gtk/gtkrender.h new file mode 100644 index 0000000000..ea4b84ae63 --- /dev/null +++ b/gtk/gtkrender.h @@ -0,0 +1,155 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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 . + */ + +#ifndef __GTK_RENDER_H__ +#define __GTK_RENDER_H__ + +#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include +#include + +#include +#include + +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__ */ diff --git a/gtk/gtksearchbar.c b/gtk/gtksearchbar.c index c9daf15142..7a737d61ae 100644 --- a/gtk/gtksearchbar.c +++ b/gtk/gtksearchbar.c @@ -31,7 +31,7 @@ #include "gtkentryprivate.h" #include "gtkintl.h" #include "gtkprivate.h" -#include "gtkstylecontext.h" +#include "gtkrender.h" #include "gtksearchbar.h" /** diff --git a/gtk/gtkseparator.c b/gtk/gtkseparator.c index ef36d0e10c..8b1b6b414f 100644 --- a/gtk/gtkseparator.c +++ b/gtk/gtkseparator.c @@ -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 diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 3b924c612a..991be6e1cf 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -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 π, π and 3&solidus;2 π: - * - * ![](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 - * #GtkWindow’s 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 don’t 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, diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 7f11b1ad4f..653a52c67f 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -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, diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c index ea05df472a..295a0a797e 100644 --- a/gtk/gtktoolbar.c +++ b/gtk/gtktoolbar.c @@ -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" diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c index 9fa63cd851..f17eea9c71 100644 --- a/gtk/gtkviewport.c +++ b/gtk/gtkviewport.c @@ -32,6 +32,7 @@ #include "gtkpixelcacheprivate.h" #include "gtkprivate.h" #include "gtkscrollable.h" +#include "gtkrender.h" #include "gtktypebuiltins.h" #include "gtkwidgetprivate.h"