* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
-#include <config.h>
+#include "config.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
-#include "gtkgc.h"
+#include <gobject/gvaluecollector.h>
#include "gtkmarshalers.h"
+#include "gtkpango.h"
#include "gtkrc.h"
#include "gtkspinbutton.h"
#include "gtkstyle.h"
#include "gtkiconfactory.h"
#include "gtksettings.h" /* _gtk_settings_parse_convert() */
#include "gtkintl.h"
-#include "gtkalias.h"
+#include "gtkspinner.h"
+
+
+/**
+ * SECTION:gtkstyle
+ * @Short_description: An object that hold style information for widgets
+ * @Title: GtkStyle
+ *
+ * A #GtkStyle object encapsulates the information that provides the look and
+ * feel for a widget. Each #GtkWidget has an associated #GTkStyle object that
+ * is used when rendering that widget. Also, a #GtkStyle holds information for
+ * the five possible widget states though not every widget supports all five
+ * states; see #GtkStateType.
+ *
+ * Usually the #GtkStyle for a widget is the same as the default style that is
+ * set by GTK+ and modified the theme engine.
+ *
+ * Usually applications should not need to use or modify the #GtkStyle of their
+ * widgets.
+ */
+
#define LIGHTNESS_MULT 1.3
#define DARKNESS_MULT 0.7
};
/* --- prototypes --- */
-static void gtk_style_init (GtkStyle *style);
-static void gtk_style_class_init (GtkStyleClass *klass);
static void gtk_style_finalize (GObject *object);
static void gtk_style_realize (GtkStyle *style,
GdkColormap *colormap);
gint y,
gint width,
gint height);
-static void gtk_default_draw_polygon (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- GdkPoint *points,
- gint npoints,
- gboolean fill);
static void gtk_default_draw_arrow (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type,
gint y,
gint width,
gint height);
-static void gtk_default_draw_string (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x,
- gint y,
- const gchar *string);
static void gtk_default_draw_box (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type,
gint y,
gint width,
gint height);
+static void gtk_default_draw_spinner (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ guint step,
+ gint x,
+ gint y,
+ gint width,
+ gint height);
static void rgb_to_hls (gdouble *r,
gdouble *g,
gdouble *l,
gdouble *s);
-static void style_unrealize_cursor_gcs (GtkStyle *style);
-
-static GdkFont *gtk_style_get_font_internal (GtkStyle *style);
+static void style_unrealize_cursors (GtkStyle *style);
/*
* Data for default check and radio buttons
static const GdkColor gtk_default_selected_base = { 0, GTK_BLUE };
static const GdkColor gtk_default_active_base = { 0, GTK_VERY_DARK_GRAY };
-static gpointer parent_class = NULL;
-
/* --- signals --- */
static guint realize_signal = 0;
static guint unrealize_signal = 0;
+G_DEFINE_TYPE (GtkStyle, gtk_style, G_TYPE_OBJECT)
+
/* --- functions --- */
-GType
-gtk_style_get_type (void)
-{
- static GType style_type = 0;
-
- if (!style_type)
- {
- static const GTypeInfo style_info =
- {
- sizeof (GtkStyleClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) gtk_style_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (GtkStyle),
- 0, /* n_preallocs */
- (GInstanceInitFunc) gtk_style_init,
- };
-
- style_type = g_type_register_static (G_TYPE_OBJECT, I_("GtkStyle"),
- &style_info, 0);
- }
-
- return style_type;
-}
/**
* _gtk_style_init_for_settings:
style->white.green = 65535;
style->white.blue = 65535;
- style->black_gc = NULL;
- style->white_gc = NULL;
-
style->fg[GTK_STATE_NORMAL] = gtk_default_normal_fg;
style->fg[GTK_STATE_ACTIVE] = gtk_default_active_fg;
style->fg[GTK_STATE_PRELIGHT] = gtk_default_prelight_fg;
style->rc_style = NULL;
- for (i = 0; i < 5; i++)
- {
- style->fg_gc[i] = NULL;
- style->bg_gc[i] = NULL;
- style->light_gc[i] = NULL;
- style->dark_gc[i] = NULL;
- style->mid_gc[i] = NULL;
- style->text_gc[i] = NULL;
- style->base_gc[i] = NULL;
- style->text_aa_gc[i] = NULL;
- }
-
style->xthickness = 2;
style->ythickness = 2;
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- parent_class = g_type_class_peek_parent (klass);
-
object_class->finalize = gtk_style_finalize;
klass->clone = gtk_style_real_clone;
klass->draw_hline = gtk_default_draw_hline;
klass->draw_vline = gtk_default_draw_vline;
klass->draw_shadow = gtk_default_draw_shadow;
- klass->draw_polygon = gtk_default_draw_polygon;
klass->draw_arrow = gtk_default_draw_arrow;
klass->draw_diamond = gtk_default_draw_diamond;
- klass->draw_string = gtk_default_draw_string;
klass->draw_box = gtk_default_draw_box;
klass->draw_flat_box = gtk_default_draw_flat_box;
klass->draw_check = gtk_default_draw_check;
klass->draw_expander = gtk_default_draw_expander;
klass->draw_layout = gtk_default_draw_layout;
klass->draw_resize_grip = gtk_default_draw_resize_grip;
+ klass->draw_spinner = gtk_default_draw_spinner;
g_type_class_add_private (object_class, sizeof (GtkStylePrivate));
*
* Emitted when the aspects of the style specific to a particular colormap
* and depth are being cleaned up. A connection to this signal can be useful
- * if a widget wants to cache objects like a #GdkGC as object data on #GtkStyle.
+ * if a widget wants to cache objects as object data on #GtkStyle.
* This signal provides a convenient place to free such cached objects.
*
* Since: 2.4
if (style->styles)
{
if (style->styles->data != style)
- g_slist_remove (style->styles, style);
+ style->styles = g_slist_remove (style->styles, style);
else
{
GSList *tmp_list = style->styles->next;
g_slist_free (priv->color_hashes);
pango_font_description_free (style->font_desc);
-
- if (style->private_font)
- gdk_font_unref (style->private_font);
if (style->private_font_desc)
pango_font_description_free (style->private_font_desc);
-
+
if (style->rc_style)
- gtk_rc_style_unref (style->rc_style);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ g_object_unref (style->rc_style);
+
+ G_OBJECT_CLASS (gtk_style_parent_class)->finalize (object);
}
+/**
+ * gtk_style_copy:
+ * @style: a #GtkStyle
+ *
+ * Creates a copy of the passed in #GtkStyle object.
+ *
+ * Returns: a copy of @style
+ */
GtkStyle*
gtk_style_copy (GtkStyle *style)
{
* gtk_style_attach:
* @style: a #GtkStyle.
* @window: a #GdkWindow.
- * @returns: Either @style, or a newly-created #GtkStyle.
- * If the style is newly created, the style parameter
- * will be dereferenced, and the new style will have
- * a reference count belonging to the caller.
*
* Attaches a style to a window; this process allocates the
* colors and creates the GC's for the style - it specializes
* Since this function may return a new object, you have to use it
* in the following way:
* <literal>style = gtk_style_attach (style, window)</literal>
- **/
+ *
+ * Returns: Either @style, or a newly-created #GtkStyle.
+ * If the style is newly created, the style parameter
+ * will be unref'ed, and the new style will have
+ * a reference count belonging to the caller.
+ */
GtkStyle*
gtk_style_attach (GtkStyle *style,
GdkWindow *window)
if (!new_style)
{
new_style = gtk_style_duplicate (style);
- if (gdk_colormap_get_screen (style->colormap) != gdk_colormap_get_screen (colormap) &&
- new_style->private_font)
- {
- gdk_font_unref (new_style->private_font);
- new_style->private_font = NULL;
- }
gtk_style_realize (new_style, colormap);
}
if (style->private_font_desc)
{
- if (style->private_font)
- {
- gdk_font_unref (style->private_font);
- style->private_font = NULL;
- }
-
pango_font_description_free (style->private_font_desc);
style->private_font_desc = NULL;
}
}
}
-/**
- * gtk_style_ref:
- * @style: a #GtkStyle.
- * @returns: @style.
- *
- * Deprecated equivalent of g_object_ref().
- **/
-GtkStyle*
-gtk_style_ref (GtkStyle *style)
-{
- return (GtkStyle *) g_object_ref (style);
-}
-
-/**
- * gtk_style_unref:
- * @style: a #GtkStyle.
- *
- * Deprecated equivalent of g_object_unref().
- **/
-void
-gtk_style_unref (GtkStyle *style)
-{
- g_object_unref (style);
-}
-
static void
gtk_style_realize (GtkStyle *style,
GdkColormap *colormap)
{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GDK_IS_COLORMAP (colormap));
-
style->colormap = g_object_ref (colormap);
style->depth = gdk_colormap_get_visual (colormap)->depth;
g_signal_emit (style, realize_signal, 0);
}
+/**
+ * gtk_style_lookup_icon_set:
+ * @style: a #GtkStyle
+ * @stock_id: an icon name
+ *
+ * Looks up @stock_id in the icon factories associated with @style
+ * and the default icon factory, returning an icon set if found,
+ * otherwise %NULL.
+ *
+ * Return value: icon set of @stock_id
+ */
GtkIconSet*
gtk_style_lookup_icon_set (GtkStyle *style,
const char *stock_id)
}
/**
- * gtk_draw_hline:
+ * gtk_style_set_background:
* @style: a #GtkStyle
* @window: a #GdkWindow
* @state_type: a state
- * @x1: the starting x coordinate
- * @x2: the ending x coordinate
- * @y: the y coordinate
- *
- * Draws a horizontal line from (@x1, @y) to (@x2, @y) in @window
- * using the given style and state.
*
- * Deprecated: Use gtk_paint_hline() instead.
- **/
+ * Sets the background of @window to the background color or pixmap
+ * specified by @style for the given state.
+ */
void
-gtk_draw_hline (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- gint x1,
- gint x2,
- gint y)
+gtk_style_set_background (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type)
{
g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_hline != NULL);
+ g_return_if_fail (window != NULL);
- GTK_STYLE_GET_CLASS (style)->draw_hline (style, window, state_type, NULL, NULL, NULL, x1, x2, y);
+ GTK_STYLE_GET_CLASS (style)->set_background (style, window, state_type);
}
+/* Default functions */
+static GtkStyle *
+gtk_style_real_clone (GtkStyle *style)
+{
+ return g_object_new (G_OBJECT_TYPE (style), NULL);
+}
-/**
- * gtk_draw_vline:
- * @style: a #GtkStyle
- * @window: a #GdkWindow
- * @state_type: a state
- * @y1_: the starting y coordinate
- * @y2_: the ending y coordinate
- * @x: the x coordinate
- *
- * Draws a vertical line from (@x, @y1_) to (@x, @y2_) in @window
- * using the given style and state.
- *
- * Deprecated: Use gtk_paint_vline() instead.
- **/
-void
-gtk_draw_vline (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- gint y1_,
- gint y2_,
- gint x)
+static void
+gtk_style_real_copy (GtkStyle *style,
+ GtkStyle *src)
{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL);
+ GtkStylePrivate *priv = GTK_STYLE_GET_PRIVATE (style);
+ GtkStylePrivate *src_priv = GTK_STYLE_GET_PRIVATE (src);
+ gint i;
+
+ for (i = 0; i < 5; i++)
+ {
+ style->fg[i] = src->fg[i];
+ style->bg[i] = src->bg[i];
+ style->text[i] = src->text[i];
+ style->base[i] = src->base[i];
+
+ if (style->bg_pixmap[i])
+ g_object_unref (style->bg_pixmap[i]),
+ style->bg_pixmap[i] = src->bg_pixmap[i];
+ if (style->bg_pixmap[i])
+ g_object_ref (style->bg_pixmap[i]);
+ }
+
+ if (style->font_desc)
+ pango_font_description_free (style->font_desc);
+ if (src->font_desc)
+ style->font_desc = pango_font_description_copy (src->font_desc);
+ else
+ style->font_desc = NULL;
- GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type, NULL, NULL, NULL, y1_, y2_, x);
+ style->xthickness = src->xthickness;
+ style->ythickness = src->ythickness;
+
+ if (style->rc_style)
+ g_object_unref (style->rc_style);
+ style->rc_style = src->rc_style;
+ if (src->rc_style)
+ g_object_ref (src->rc_style);
+
+ g_slist_foreach (style->icon_factories, (GFunc) g_object_unref, NULL);
+ g_slist_free (style->icon_factories);
+ style->icon_factories = g_slist_copy (src->icon_factories);
+ g_slist_foreach (style->icon_factories, (GFunc) g_object_ref, NULL);
+
+ g_slist_foreach (priv->color_hashes, (GFunc) g_hash_table_unref, NULL);
+ g_slist_free (priv->color_hashes);
+ priv->color_hashes = g_slist_copy (src_priv->color_hashes);
+ g_slist_foreach (priv->color_hashes, (GFunc) g_hash_table_ref, NULL);
+
+ /* don't copy, just clear cache */
+ clear_property_cache (style);
+}
+
+static void
+gtk_style_real_init_from_rc (GtkStyle *style,
+ GtkRcStyle *rc_style)
+{
+ GtkStylePrivate *priv = GTK_STYLE_GET_PRIVATE (style);
+ gint i;
+
+ /* cache _should_ be still empty */
+ clear_property_cache (style);
+
+ if (rc_style->font_desc)
+ pango_font_description_merge (style->font_desc, rc_style->font_desc, TRUE);
+
+ for (i = 0; i < 5; i++)
+ {
+ if (rc_style->color_flags[i] & GTK_RC_FG)
+ style->fg[i] = rc_style->fg[i];
+ if (rc_style->color_flags[i] & GTK_RC_BG)
+ style->bg[i] = rc_style->bg[i];
+ if (rc_style->color_flags[i] & GTK_RC_TEXT)
+ style->text[i] = rc_style->text[i];
+ if (rc_style->color_flags[i] & GTK_RC_BASE)
+ style->base[i] = rc_style->base[i];
+ }
+
+ if (rc_style->xthickness >= 0)
+ style->xthickness = rc_style->xthickness;
+ if (rc_style->ythickness >= 0)
+ style->ythickness = rc_style->ythickness;
+
+ style->icon_factories = g_slist_copy (rc_style->icon_factories);
+ g_slist_foreach (style->icon_factories, (GFunc) g_object_ref, NULL);
+
+ priv->color_hashes = g_slist_copy (_gtk_rc_style_get_color_hashes (rc_style));
+ g_slist_foreach (priv->color_hashes, (GFunc) g_hash_table_ref, NULL);
+}
+
+static gint
+style_property_values_cmp (gconstpointer bsearch_node1,
+ gconstpointer bsearch_node2)
+{
+ const PropertyValue *val1 = bsearch_node1;
+ const PropertyValue *val2 = bsearch_node2;
+
+ if (val1->widget_type == val2->widget_type)
+ return val1->pspec < val2->pspec ? -1 : val1->pspec == val2->pspec ? 0 : 1;
+ else
+ return val1->widget_type < val2->widget_type ? -1 : 1;
}
/**
- * gtk_draw_shadow:
+ * gtk_style_get_style_property:
* @style: a #GtkStyle
- * @window: a #GdkWindow
- * @state_type: a state
- * @shadow_type: type of shadow to draw
- * @x: x origin of the rectangle
- * @y: y origin of the rectangle
- * @width: width of the rectangle
- * @height: width of the rectangle
+ * @widget_type: the #GType of a descendant of #GtkWidget
+ * @property_name: the name of the style property to get
+ * @value: a #GValue where the value of the property being
+ * queried will be stored
*
- * Draws a shadow around the given rectangle in @window
- * using the given style and state and shadow type.
- *
- * Deprecated: Use gtk_paint_shadow() instead.
+ * Queries the value of a style property corresponding to a
+ * widget class is in the given style.
+ *
+ * Since: 2.16
*/
-void
-gtk_draw_shadow (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- gint x,
- gint y,
- gint width,
- gint height)
+void
+gtk_style_get_style_property (GtkStyle *style,
+ GType widget_type,
+ const gchar *property_name,
+ GValue *value)
{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_shadow (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
+ GtkWidgetClass *klass;
+ GParamSpec *pspec;
+ GtkRcPropertyParser parser;
+ const GValue *peek_value;
+
+ klass = g_type_class_ref (widget_type);
+ pspec = gtk_widget_class_find_style_property (klass, property_name);
+ g_type_class_unref (klass);
+
+ if (!pspec)
+ {
+ g_warning ("%s: widget class `%s' has no property named `%s'",
+ G_STRLOC,
+ g_type_name (widget_type),
+ property_name);
+ return;
+ }
+
+ parser = g_param_spec_get_qdata (pspec,
+ g_quark_from_static_string ("gtk-rc-property-parser"));
+
+ peek_value = _gtk_style_peek_property_value (style, widget_type, pspec, parser);
+
+ if (G_VALUE_TYPE (value) == G_PARAM_SPEC_VALUE_TYPE (pspec))
+ g_value_copy (peek_value, value);
+ else if (g_value_type_transformable (G_PARAM_SPEC_VALUE_TYPE (pspec), G_VALUE_TYPE (value)))
+ g_value_transform (peek_value, value);
+ else
+ g_warning ("can't retrieve style property `%s' of type `%s' as value of type `%s'",
+ pspec->name,
+ g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
+ G_VALUE_TYPE_NAME (value));
}
/**
- * gtk_draw_polygon:
+ * gtk_style_get_valist:
* @style: a #GtkStyle
- * @window: a #GdkWindow
- * @state_type: a state
- * @shadow_type: type of shadow to draw
- * @points: an array of #GdkPoint<!-- -->s
- * @npoints: length of @points
- * @fill: %TRUE if the polygon should be filled
- *
- * Draws a polygon on @window with the given parameters.
+ * @widget_type: the #GType of a descendant of #GtkWidget
+ * @first_property_name: the name of the first style property to get
+ * @var_args: a <type>va_list</type> of pairs of property names and
+ * locations to return the property values, starting with the
+ * location for @first_property_name.
*
- * Deprecated: Use gtk_paint_polygon() instead.
- */
-void
-gtk_draw_polygon (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkPoint *points,
- gint npoints,
- gboolean fill)
+ * Non-vararg variant of gtk_style_get().
+ * Used primarily by language bindings.
+ *
+ * Since: 2.16
+ */
+void
+gtk_style_get_valist (GtkStyle *style,
+ GType widget_type,
+ const gchar *first_property_name,
+ va_list var_args)
{
+ const char *property_name;
+ GtkWidgetClass *klass;
+
g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_polygon != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_polygon (style, window, state_type, shadow_type, NULL, NULL, NULL, points, npoints, fill);
-}
-/**
- * gtk_draw_arrow:
- * @style: a #GtkStyle
- * @window: a #GdkWindow
- * @state_type: a state
- * @shadow_type: the type of shadow to draw
- * @arrow_type: the type of arrow to draw
- * @fill: %TRUE if the arrow tip should be filled
- * @x: x origin of the rectangle to draw the arrow in
- * @y: y origin of the rectangle to draw the arrow in
- * @width: width of the rectangle to draw the arrow in
- * @height: height of the rectangle to draw the arrow in
- *
- * Draws an arrow in the given rectangle on @window using the given
- * parameters. @arrow_type determines the direction of the arrow.
- *
- * Deprecated: Use gtk_paint_arrow() instead.
- */
-void
-gtk_draw_arrow (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GtkArrowType arrow_type,
- gboolean fill,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_arrow != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_arrow (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, fill, x, y, width, height);
-}
+ klass = g_type_class_ref (widget_type);
-/**
- * gtk_draw_diamond:
- * @style: a #GtkStyle
- * @window: a #GdkWindow
- * @state_type: a state
- * @shadow_type: the type of shadow to draw
- * @x: x origin of the rectangle to draw the diamond in
- * @y: y origin of the rectangle to draw the diamond in
- * @width: width of the rectangle to draw the diamond in
- * @height: height of the rectangle to draw the diamond in
- *
- * Draws a diamond in the given rectangle on @window using the given
- * parameters.
- *
- * Deprecated: Use gtk_paint_diamond() instead.
- */
-void
-gtk_draw_diamond (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_diamond != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_diamond (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
-}
-
-/**
- * gtk_draw_string:
- * @style: a #GtkStyle
- * @window: a #GdkWindow
- * @state_type: a state
- * @x: x origin
- * @y: y origin
- * @string: the string to draw
- *
- * Draws a text string on @window with the given parameters.
- *
- * Deprecated: Use gtk_paint_layout() instead.
- */
-void
-gtk_draw_string (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- gint x,
- gint y,
- const gchar *string)
-{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_string != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_string (style, window, state_type, NULL, NULL, NULL, x, y, string);
-}
-
-/**
- * gtk_draw_box:
- * @style: a #GtkStyle
- * @window: a #GdkWindow
- * @state_type: a state
- * @shadow_type: the type of shadow to draw
- * @x: x origin of the box
- * @y: y origin of the box
- * @width: the width of the box
- * @height: the height of the box
- *
- * Draws a box on @window with the given parameters.
- *
- * Deprecated: Use gtk_paint_box() instead.
- */
-void
-gtk_draw_box (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
-}
+ property_name = first_property_name;
+ while (property_name)
+ {
+ GParamSpec *pspec;
+ GtkRcPropertyParser parser;
+ const GValue *peek_value;
+ gchar *error;
-/**
- * gtk_draw_flat_box:
- * @style: a #GtkStyle
- * @window: a #GdkWindow
- * @state_type: a state
- * @shadow_type: the type of shadow to draw
- * @x: x origin of the box
- * @y: y origin of the box
- * @width: the width of the box
- * @height: the height of the box
- *
- * Draws a flat box on @window with the given parameters.
- *
- * Deprecated: Use gtk_paint_flat_box() instead.
- */
-void
-gtk_draw_flat_box (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_flat_box != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_flat_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
-}
+ pspec = gtk_widget_class_find_style_property (klass, property_name);
-/**
- * gtk_draw_check:
- * @style: a #GtkStyle
- * @window: a #GdkWindow
- * @state_type: a state
- * @shadow_type: the type of shadow to draw
- * @x: x origin of the rectangle to draw the check in
- * @y: y origin of the rectangle to draw the check in
- * @width: the width of the rectangle to draw the check in
- * @height: the height of the rectangle to draw the check in
- *
- * Draws a check button indicator in the given rectangle on @window with
- * the given parameters.
- *
- * Deprecated: Use gtk_paint_check() instead.
- */
-void
-gtk_draw_check (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_check != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_check (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
-}
+ if (!pspec)
+ {
+ g_warning ("%s: widget class `%s' has no property named `%s'",
+ G_STRLOC,
+ g_type_name (widget_type),
+ property_name);
+ break;
+ }
-/**
- * gtk_draw_option:
- * @style: a #GtkStyle
- * @window: a #GdkWindow
- * @state_type: a state
- * @shadow_type: the type of shadow to draw
- * @x: x origin of the rectangle to draw the option in
- * @y: y origin of the rectangle to draw the option in
- * @width: the width of the rectangle to draw the option in
- * @height: the height of the rectangle to draw the option in
- *
- * Draws a radio button indicator in the given rectangle on @window with
- * the given parameters.
- *
- * Deprecated: Use gtk_paint_option() instead.
- */
-void
-gtk_draw_option (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_option != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_option (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
-}
+ parser = g_param_spec_get_qdata (pspec,
+ g_quark_from_static_string ("gtk-rc-property-parser"));
-/**
- * gtk_draw_tab:
- * @style: a #GtkStyle
- * @window: a #GdkWindow
- * @state_type: a state
- * @shadow_type: the type of shadow to draw
- * @x: x origin of the rectangle to draw the tab in
- * @y: y origin of the rectangle to draw the tab in
- * @width: the width of the rectangle to draw the tab in
- * @height: the height of the rectangle to draw the tab in
- *
- * Draws an option menu tab (i.e. the up and down pointing arrows)
- * in the given rectangle on @window using the given parameters.
- *
- * Deprecated: Use gtk_paint_tab() instead.
- */
-void
-gtk_draw_tab (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_tab != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_tab (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
-}
+ peek_value = _gtk_style_peek_property_value (style, widget_type, pspec, parser);
+ G_VALUE_LCOPY (peek_value, var_args, 0, &error);
+ if (error)
+ {
+ g_warning ("%s: %s", G_STRLOC, error);
+ g_free (error);
+ break;
+ }
-/**
- * gtk_draw_shadow_gap:
- * @style: a #GtkStyle
- * @window: a #GdkWindow
- * @state_type: a state
- * @shadow_type: type of shadow to draw
- * @x: x origin of the rectangle
- * @y: y origin of the rectangle
- * @width: width of the rectangle
- * @height: width of the rectangle
- * @gap_side: side in which to leave the gap
- * @gap_x: starting position of the gap
- * @gap_width: width of the gap
- *
- * Draws a shadow around the given rectangle in @window
- * using the given style and state and shadow type, leaving a
- * gap in one side.
- *
- * Deprecated: Use gtk_paint_shadow_gap() instead.
-*/
-void
-gtk_draw_shadow_gap (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- gint x,
- gint y,
- gint width,
- gint height,
- GtkPositionType gap_side,
- gint gap_x,
- gint gap_width)
-{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_shadow_gap (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
-}
+ property_name = va_arg (var_args, gchar*);
+ }
-/**
- * gtk_draw_box_gap:
- * @style: a #GtkStyle
- * @window: a #GdkWindow
- * @state_type: a state
- * @shadow_type: type of shadow to draw
- * @x: x origin of the rectangle
- * @y: y origin of the rectangle
- * @width: width of the rectangle
- * @height: width of the rectangle
- * @gap_side: side in which to leave the gap
- * @gap_x: starting position of the gap
- * @gap_width: width of the gap
- *
- * Draws a box in @window using the given style and state and shadow type,
- * leaving a gap in one side.
- *
- * Deprecated: Use gtk_paint_box_gap() instead.
- */
-void
-gtk_draw_box_gap (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- gint x,
- gint y,
- gint width,
- gint height,
- GtkPositionType gap_side,
- gint gap_x,
- gint gap_width)
-{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box_gap != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_box_gap (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
+ g_type_class_unref (klass);
}
/**
- * gtk_draw_extension:
+ * gtk_style_get:
* @style: a #GtkStyle
- * @window: a #GdkWindow
- * @state_type: a state
- * @shadow_type: type of shadow to draw
- * @x: x origin of the extension
- * @y: y origin of the extension
- * @width: width of the extension
- * @height: width of the extension
- * @gap_side: the side on to which the extension is attached
- *
- * Draws an extension, i.e. a notebook tab.
+ * @widget_type: the #GType of a descendant of #GtkWidget
+ * @first_property_name: the name of the first style property to get
+ * @Varargs: pairs of property names and locations to
+ * return the property values, starting with the location for
+ * @first_property_name, terminated by %NULL.
*
- * Deprecated: Use gtk_paint_extension() instead.
- **/
-void
-gtk_draw_extension (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- gint x,
- gint y,
- gint width,
- gint height,
- GtkPositionType gap_side)
-{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_extension (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side);
-}
-
-/**
- * gtk_draw_focus:
- * @style: a #GtkStyle
- * @window: a #GdkWindow
- * @x: the x origin of the rectangle around which to draw a focus indicator
- * @y: the y origin of the rectangle around which to draw a focus indicator
- * @width: the width of the rectangle around which to draw a focus indicator
- * @height: the height of the rectangle around which to draw a focus indicator
+ * Gets the values of a multiple style properties for @widget_type
+ * from @style.
*
- * Draws a focus indicator around the given rectangle on @window using the
- * given style.
- *
- * Deprecated: Use gtk_paint_focus() instead.
+ * Since: 2.16
*/
void
-gtk_draw_focus (GtkStyle *style,
- GdkWindow *window,
- gint x,
- gint y,
- gint width,
- gint height)
+gtk_style_get (GtkStyle *style,
+ GType widget_type,
+ const gchar *first_property_name,
+ ...)
{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_focus != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, GTK_STATE_NORMAL, NULL, NULL, NULL, x, y, width, height);
-}
+ va_list var_args;
-void
-gtk_draw_slider (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- gint x,
- gint y,
- gint width,
- gint height,
- GtkOrientation orientation)
-{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_slider != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_slider (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
-}
-
-/**
- * gtk_draw_handle:
- * @style: a #GtkStyle
- * @window: a #GdkWindow
- * @state_type: a state
- * @shadow_type: type of shadow to draw
- * @x: x origin of the handle
- * @y: y origin of the handle
- * @width: with of the handle
- * @height: height of the handle
- * @orientation: the orientation of the handle
- *
- * Draws a handle as used in #GtkHandleBox and #GtkPaned.
- *
- * Deprecated: Use gtk_paint_handle() instead.
- **/
-void
-gtk_draw_handle (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- gint x,
- gint y,
- gint width,
- gint height,
- GtkOrientation orientation)
-{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_handle != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_handle (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
-}
-
-/**
- * gtk_draw_expander:
- * @style: a #GtkStyle
- * @window: a #GdkWindow
- * @state_type: a state
- * @x: the x position to draw the expander at
- * @y: the y position to draw the expander at
- * @expander_style: the style to draw the expander in
- *
- * Draws an expander as used in #GtkTreeView.
- *
- * Deprecated: Use gtk_paint_expander() instead.
- **/
-void
-gtk_draw_expander (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- gint x,
- gint y,
- GtkExpanderStyle expander_style)
-{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_expander != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_expander (style, window, state_type,
- NULL, NULL, NULL,
- x, y, expander_style);
-}
-
-void
-gtk_draw_layout (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- gboolean use_text,
- gint x,
- gint y,
- PangoLayout *layout)
-{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type, use_text,
- NULL, NULL, NULL,
- x, y, layout);
-}
-
-/**
- * gtk_draw_resize_grip:
- * @style: a #GtkStyle
- * @window: a #GdkWindow
- * @state_type: a state
- * @edge: the edge in which to draw the resize grip
- * @x: the x origin of the rectangle in which to draw the resize grip
- * @y: the y origin of the rectangle in which to draw the resize grip
- * @width: the width of the rectangle in which to draw the resize grip
- * @height: the height of the rectangle in which to draw the resize grip
- *
- * Draws a resize grip in the given rectangle on @window using the given
- * parameters.
- *
- * Deprecated: Use gtk_paint_resize_grip() instead.
- */
-void
-gtk_draw_resize_grip (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GdkWindowEdge edge,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_resize_grip != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_resize_grip (style, window, state_type,
- NULL, NULL, NULL,
- edge,
- x, y, width, height);
-}
-
-
-/**
- * gtk_style_set_background:
- * @style: a #GtkStyle
- * @window: a #GdkWindow
- * @state_type: a state
- *
- * Sets the background of @window to the background color or pixmap
- * specified by @style for the given state.
- */
-void
-gtk_style_set_background (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type)
-{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
- GTK_STYLE_GET_CLASS (style)->set_background (style, window, state_type);
-}
-
-/* Default functions */
-static GtkStyle *
-gtk_style_real_clone (GtkStyle *style)
-{
- return g_object_new (G_OBJECT_TYPE (style), NULL);
-}
-
-static void
-gtk_style_real_copy (GtkStyle *style,
- GtkStyle *src)
-{
- gint i;
-
- for (i = 0; i < 5; i++)
- {
- style->fg[i] = src->fg[i];
- style->bg[i] = src->bg[i];
- style->text[i] = src->text[i];
- style->base[i] = src->base[i];
-
- if (style->bg_pixmap[i])
- g_object_unref (style->bg_pixmap[i]),
- style->bg_pixmap[i] = src->bg_pixmap[i];
- if (style->bg_pixmap[i])
- g_object_ref (style->bg_pixmap[i]);
- }
-
- if (style->private_font)
- gdk_font_unref (style->private_font);
- style->private_font = src->private_font;
- if (style->private_font)
- gdk_font_ref (style->private_font);
-
- if (style->font_desc)
- pango_font_description_free (style->font_desc);
- if (src->font_desc)
- style->font_desc = pango_font_description_copy (src->font_desc);
- else
- style->font_desc = NULL;
-
- style->xthickness = src->xthickness;
- style->ythickness = src->ythickness;
-
- if (style->rc_style)
- gtk_rc_style_unref (style->rc_style);
- style->rc_style = src->rc_style;
- if (src->rc_style)
- gtk_rc_style_ref (src->rc_style);
-
- /* don't copy, just clear cache */
- clear_property_cache (style);
-}
-
-static void
-gtk_style_real_init_from_rc (GtkStyle *style,
- GtkRcStyle *rc_style)
-{
- GtkStylePrivate *priv = GTK_STYLE_GET_PRIVATE (style);
- gint i;
-
- /* cache _should_ be still empty */
- clear_property_cache (style);
-
- if (rc_style->font_desc)
- pango_font_description_merge (style->font_desc, rc_style->font_desc, TRUE);
-
- for (i = 0; i < 5; i++)
- {
- if (rc_style->color_flags[i] & GTK_RC_FG)
- style->fg[i] = rc_style->fg[i];
- if (rc_style->color_flags[i] & GTK_RC_BG)
- style->bg[i] = rc_style->bg[i];
- if (rc_style->color_flags[i] & GTK_RC_TEXT)
- style->text[i] = rc_style->text[i];
- if (rc_style->color_flags[i] & GTK_RC_BASE)
- style->base[i] = rc_style->base[i];
- }
-
- if (rc_style->xthickness >= 0)
- style->xthickness = rc_style->xthickness;
- if (rc_style->ythickness >= 0)
- style->ythickness = rc_style->ythickness;
-
- style->icon_factories = g_slist_copy (rc_style->icon_factories);
- g_slist_foreach (style->icon_factories, (GFunc) g_object_ref, NULL);
-
- priv->color_hashes = g_slist_copy (_gtk_rc_style_get_color_hashes (rc_style));
- g_slist_foreach (priv->color_hashes, (GFunc) g_hash_table_ref, NULL);
-}
-
-static gint
-style_property_values_cmp (gconstpointer bsearch_node1,
- gconstpointer bsearch_node2)
-{
- const PropertyValue *val1 = bsearch_node1;
- const PropertyValue *val2 = bsearch_node2;
-
- if (val1->widget_type == val2->widget_type)
- return val1->pspec < val2->pspec ? -1 : val1->pspec == val2->pspec ? 0 : 1;
- else
- return val1->widget_type < val2->widget_type ? -1 : 1;
+ va_start (var_args, first_property_name);
+ gtk_style_get_valist (style, widget_type, first_property_name, var_args);
+ va_end (var_args);
}
const GValue*
gchar *contents = g_strdup_value_contents (&rcprop->value);
g_message ("%s: failed to retrieve property `%s::%s' of type `%s' from rc file value \"%s\" of type `%s'",
- rcprop->origin,
+ rcprop->origin ? rcprop->origin : "(for origin information, set GTK_DEBUG)",
g_type_name (pspec->owner_type), pspec->name,
g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
contents,
return (GdkPixmap*) GDK_PARENT_RELATIVE;
else
{
- return gdk_pixmap_colormap_create_from_xpm (NULL, colormap, NULL,
- bg_color,
- filename);
+ GdkPixmap *pixmap;
+ GdkPixbuf *pixbuf;
+ cairo_t *cr;
+ GdkScreen *screen = gdk_colormap_get_screen (colormap);
+
+ pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
+ if (!pixbuf)
+ return NULL;
+
+ pixmap = gdk_pixmap_new (gdk_screen_get_root_window (screen),
+ gdk_pixbuf_get_width (pixbuf),
+ gdk_pixbuf_get_height (pixbuf),
+ gdk_colormap_get_visual (colormap)->depth);
+ gdk_drawable_set_colormap (pixmap, colormap);
+
+ cr = gdk_cairo_create (pixmap);
+
+ gdk_cairo_set_source_color (cr, bg_color);
+ cairo_paint (cr);
+
+ gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
+ cairo_paint (cr);
+
+ cairo_destroy (cr);
+ g_object_unref (pixbuf);
+
+ return pixmap;
}
}
static void
gtk_style_real_realize (GtkStyle *style)
{
- GdkGCValues gc_values;
- GdkGCValuesMask gc_values_mask;
-
gint i;
for (i = 0; i < 5; i++)
style->black.red = 0x0000;
style->black.green = 0x0000;
style->black.blue = 0x0000;
- gdk_colormap_alloc_color (style->colormap, &style->black, FALSE, TRUE);
style->white.red = 0xffff;
style->white.green = 0xffff;
style->white.blue = 0xffff;
- gdk_colormap_alloc_color (style->colormap, &style->white, FALSE, TRUE);
-
- gc_values_mask = GDK_GC_FOREGROUND | GDK_GC_BACKGROUND;
-
- gc_values.foreground = style->black;
- gc_values.background = style->white;
- style->black_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
-
- gc_values.foreground = style->white;
- gc_values.background = style->black;
- style->white_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
-
- gc_values_mask = GDK_GC_FOREGROUND;
for (i = 0; i < 5; i++)
{
style->bg_pixmap[i] = load_bg_image (style->colormap,
&style->bg[i],
style->rc_style->bg_pixmap_name[i]);
-
- if (!gdk_colormap_alloc_color (style->colormap, &style->fg[i], FALSE, TRUE))
- g_warning ("unable to allocate color: ( %d %d %d )",
- style->fg[i].red, style->fg[i].green, style->fg[i].blue);
- if (!gdk_colormap_alloc_color (style->colormap, &style->bg[i], FALSE, TRUE))
- g_warning ("unable to allocate color: ( %d %d %d )",
- style->bg[i].red, style->bg[i].green, style->bg[i].blue);
- if (!gdk_colormap_alloc_color (style->colormap, &style->light[i], FALSE, TRUE))
- g_warning ("unable to allocate color: ( %d %d %d )",
- style->light[i].red, style->light[i].green, style->light[i].blue);
- if (!gdk_colormap_alloc_color (style->colormap, &style->dark[i], FALSE, TRUE))
- g_warning ("unable to allocate color: ( %d %d %d )",
- style->dark[i].red, style->dark[i].green, style->dark[i].blue);
- if (!gdk_colormap_alloc_color (style->colormap, &style->mid[i], FALSE, TRUE))
- g_warning ("unable to allocate color: ( %d %d %d )",
- style->mid[i].red, style->mid[i].green, style->mid[i].blue);
- if (!gdk_colormap_alloc_color (style->colormap, &style->text[i], FALSE, TRUE))
- g_warning ("unable to allocate color: ( %d %d %d )",
- style->text[i].red, style->text[i].green, style->text[i].blue);
- if (!gdk_colormap_alloc_color (style->colormap, &style->base[i], FALSE, TRUE))
- g_warning ("unable to allocate color: ( %d %d %d )",
- style->base[i].red, style->base[i].green, style->base[i].blue);
- if (!gdk_colormap_alloc_color (style->colormap, &style->text_aa[i], FALSE, TRUE))
- g_warning ("unable to allocate color: ( %d %d %d )",
- style->text_aa[i].red, style->text_aa[i].green, style->text_aa[i].blue);
-
- gc_values.foreground = style->fg[i];
- style->fg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
-
- gc_values.foreground = style->bg[i];
- style->bg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
-
- gc_values.foreground = style->light[i];
- style->light_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
-
- gc_values.foreground = style->dark[i];
- style->dark_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
-
- gc_values.foreground = style->mid[i];
- style->mid_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
-
- gc_values.foreground = style->text[i];
- style->text_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
-
- gc_values.foreground = style->base[i];
- style->base_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
-
- gc_values.foreground = style->text_aa[i];
- style->text_aa_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
}
}
{
int i;
- gtk_gc_release (style->black_gc);
- gtk_gc_release (style->white_gc);
-
for (i = 0; i < 5; i++)
{
- gtk_gc_release (style->fg_gc[i]);
- gtk_gc_release (style->bg_gc[i]);
- gtk_gc_release (style->light_gc[i]);
- gtk_gc_release (style->dark_gc[i]);
- gtk_gc_release (style->mid_gc[i]);
- gtk_gc_release (style->text_gc[i]);
- gtk_gc_release (style->base_gc[i]);
- gtk_gc_release (style->text_aa_gc[i]);
-
if (style->bg_pixmap[i] && style->bg_pixmap[i] != (GdkPixmap*) GDK_PARENT_RELATIVE)
{
g_object_unref (style->bg_pixmap[i]);
}
- gdk_colormap_free_colors (style->colormap, style->fg, 5);
- gdk_colormap_free_colors (style->colormap, style->bg, 5);
- gdk_colormap_free_colors (style->colormap, style->light, 5);
- gdk_colormap_free_colors (style->colormap, style->dark, 5);
- gdk_colormap_free_colors (style->colormap, style->mid, 5);
- gdk_colormap_free_colors (style->colormap, style->text, 5);
- gdk_colormap_free_colors (style->colormap, style->base, 5);
- gdk_colormap_free_colors (style->colormap, style->text_aa, 5);
-
- style_unrealize_cursor_gcs (style);
+ style_unrealize_cursors (style);
}
static void
* @source: the #GtkIconSource specifying the icon to render
* @direction: a text direction
* @state: a state
- * @size: the size to render the icon at. A size of (GtkIconSize)-1
- * means render at the size of the source and don't scale.
- * @widget: the widget
- * @detail: a style detail
+ * @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.
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
* @returns: a newly-created #GdkPixbuf containing the rendered icon
*
- * Renders the icon specified by @source at the given @size
- * according to the given parameters and returns the result in a
+ * Renders the icon specified by @source at the given @size
+ * according to the given parameters and returns the result in a
* pixbuf.
*/
GdkPixbuf *
}
/* Default functions */
+
+/**
+ * gtk_style_apply_default_background:
+ * @style:
+ * @window:
+ * @set_bg:
+ * @state_type:
+ * @area: (allow-none):
+ * @x:
+ * @y:
+ * @width:
+ * @height:
+ */
void
-gtk_style_apply_default_background (GtkStyle *style,
- GdkWindow *window,
- gboolean set_bg,
- GtkStateType state_type,
- GdkRectangle *area,
- gint x,
- gint y,
- gint width,
- gint height)
+gtk_style_apply_default_background (GtkStyle *style,
+ GdkWindow *window,
+ gboolean set_bg,
+ GtkStateType state_type,
+ const GdkRectangle *area,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
{
GdkRectangle new_rect, old_rect;
GDK_IS_PIXMAP (window) ||
(!set_bg && style->bg_pixmap[state_type] != (GdkPixmap*) GDK_PARENT_RELATIVE))
{
- GdkGC *gc = style->bg_gc[state_type];
-
+ cairo_t *cr = gdk_cairo_create (window);
+
if (style->bg_pixmap[state_type])
{
- gdk_gc_set_fill (gc, GDK_TILED);
- gdk_gc_set_tile (gc, style->bg_pixmap[state_type]);
+ gdk_cairo_set_source_pixmap (cr, style->bg_pixmap[state_type], 0, 0);
+ cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
}
-
- gdk_draw_rectangle (window, gc, TRUE,
- new_rect.x, new_rect.y, new_rect.width, new_rect.height);
- if (style->bg_pixmap[state_type])
- gdk_gc_set_fill (gc, GDK_SOLID);
+ else
+ gdk_cairo_set_source_color (cr, &style->bg[state_type]);
+
+ gdk_cairo_rectangle (cr, &new_rect);
+ cairo_fill (cr);
+
+ cairo_destroy (cr);
}
else
{
}
}
-static GdkPixbuf*
+static GdkPixbuf *
scale_or_ref (GdkPixbuf *src,
- gint width,
- gint height)
+ gint width,
+ gint height)
{
if (width == gdk_pixbuf_get_width (src) &&
height == gdk_pixbuf_get_height (src))
}
}
-static GdkPixbuf *
-gtk_default_render_icon (GtkStyle *style,
- const GtkIconSource *source,
- GtkTextDirection direction,
- GtkStateType state,
- GtkIconSize size,
- GtkWidget *widget,
- const gchar *detail)
+static gboolean
+lookup_icon_size (GtkStyle *style,
+ GtkWidget *widget,
+ GtkIconSize size,
+ gint *width,
+ gint *height)
{
- gint width = 1;
- gint height = 1;
- GdkPixbuf *scaled;
- GdkPixbuf *stated;
- GdkPixbuf *base_pixbuf;
GdkScreen *screen;
GtkSettings *settings;
- /* Oddly, style can be NULL in this function, because
- * GtkIconSet can be used without a style and if so
- * it uses this function.
- */
-
- base_pixbuf = gtk_icon_source_get_pixbuf (source);
-
- g_return_val_if_fail (base_pixbuf != NULL, NULL);
-
if (widget && gtk_widget_has_screen (widget))
{
screen = gtk_widget_get_screen (widget);
g_warning ("Using the default screen for gtk_default_render_icon()"));
}
-
- if (size != (GtkIconSize) -1 && !gtk_icon_size_lookup_for_settings (settings, size, &width, &height))
+ return gtk_icon_size_lookup_for_settings (settings, size, width, height);
+}
+
+static GdkPixbuf *
+gtk_default_render_icon (GtkStyle *style,
+ const GtkIconSource *source,
+ GtkTextDirection direction,
+ GtkStateType state,
+ GtkIconSize size,
+ GtkWidget *widget,
+ const gchar *detail)
+{
+ gint width = 1;
+ gint height = 1;
+ GdkPixbuf *scaled;
+ GdkPixbuf *stated;
+ GdkPixbuf *base_pixbuf;
+
+ /* Oddly, style can be NULL in this function, because
+ * GtkIconSet can be used without a style and if so
+ * it uses this function.
+ */
+
+ base_pixbuf = gtk_icon_source_get_pixbuf (source);
+
+ g_return_val_if_fail (base_pixbuf != NULL, NULL);
+
+ if (size != (GtkIconSize) -1 && !lookup_icon_size(style, widget, size, &width, &height))
{
g_warning (G_STRLOC ": invalid icon size '%d'", size);
return NULL;
gdk_drawable_get_size (window, NULL, height);
}
+static void
+_cairo_draw_line (cairo_t *cr,
+ GdkColor *color,
+ gint x1,
+ gint y1,
+ gint x2,
+ gint y2)
+{
+ cairo_save (cr);
+
+ gdk_cairo_set_source_color (cr, color);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+
+ cairo_move_to (cr, x1 + 0.5, y1 + 0.5);
+ cairo_line_to (cr, x2 + 0.5, y2 + 0.5);
+ cairo_stroke (cr);
+
+ cairo_restore (cr);
+}
+
+static void
+_cairo_draw_rectangle (cairo_t *cr,
+ GdkColor *color,
+ gboolean filled,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
+{
+ gdk_cairo_set_source_color (cr, color);
+
+ if (filled)
+ {
+ cairo_rectangle (cr, x, y, width, height);
+ cairo_fill (cr);
+ }
+ else
+ {
+ cairo_rectangle (cr, x + 0.5, y + 0.5, width, height);
+ cairo_stroke (cr);
+ }
+}
+
+static void
+_cairo_draw_point (cairo_t *cr,
+ GdkColor *color,
+ gint x,
+ gint y)
+{
+ gdk_cairo_set_source_color (cr, color);
+ cairo_rectangle (cr, x, y, 1, 1);
+ cairo_fill (cr);
+}
+
static void
gtk_default_draw_hline (GtkStyle *style,
GdkWindow *window,
gint x2,
gint y)
{
+ cairo_t *cr;
gint thickness_light;
gint thickness_dark;
gint i;
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
thickness_light = style->ythickness / 2;
thickness_dark = style->ythickness - thickness_light;
+ cr = gdk_cairo_create (window);
+ cairo_set_line_width (cr, 1.0);
+
if (area)
{
- gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
- gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
+ gdk_cairo_rectangle (cr, area);
+ cairo_clip (cr);
}
if (detail && !strcmp (detail, "label"))
{
if (state_type == GTK_STATE_INSENSITIVE)
- gdk_draw_line (window, style->white_gc, x1 + 1, y + 1, x2 + 1, y + 1);
- gdk_draw_line (window, style->fg_gc[state_type], x1, y, x2, y);
+ _cairo_draw_line (cr, &style->white, x1 + 1, y + 1, x2 + 1, y + 1);
+ _cairo_draw_line (cr, &style->fg[state_type], x1, y, x2, y);
}
else
{
for (i = 0; i < thickness_dark; i++)
{
- gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x2 - i - 1, y + i);
- gdk_draw_line (window, style->light_gc[state_type], x2 - i, y + i, x2, y + i);
+ _cairo_draw_line (cr, &style->dark[state_type], x1, y + i, x2 - i - 1, y + i);
+ _cairo_draw_line (cr, &style->light[state_type], x2 - i, y + i, x2, y + i);
}
y += thickness_dark;
for (i = 0; i < thickness_light; i++)
{
- gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x1 + thickness_light - i - 1, y + i);
- gdk_draw_line (window, style->light_gc[state_type], x1 + thickness_light - i, y + i, x2, y + i);
+ _cairo_draw_line (cr, &style->dark[state_type], x1, y + i, x1 + thickness_light - i - 1, y + i);
+ _cairo_draw_line (cr, &style->light[state_type], x1 + thickness_light - i, y + i, x2, y + i);
}
}
-
- if (area)
- {
- gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
- gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
- }
+
+ cairo_destroy (cr);
}
gint y2,
gint x)
{
+ cairo_t *cr;
gint thickness_light;
gint thickness_dark;
gint i;
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
thickness_light = style->xthickness / 2;
thickness_dark = style->xthickness - thickness_light;
-
+
+ cr = gdk_cairo_create (window);
+ cairo_set_line_width (cr, 1.0);
+
if (area)
{
- gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
- gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
+ gdk_cairo_rectangle (cr, area);
+ cairo_clip (cr);
}
+
for (i = 0; i < thickness_dark; i++)
{
- gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y2 - i - 1);
- gdk_draw_line (window, style->light_gc[state_type], x + i, y2 - i, x + i, y2);
+ _cairo_draw_line (cr, &style->dark[state_type],
+ x + i, y1, x + i, y2 - i - 1);
+ _cairo_draw_line (cr, &style->light[state_type],
+ x + i, y2 - i, x + i, y2);
}
x += thickness_dark;
for (i = 0; i < thickness_light; i++)
{
- gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y1 + thickness_light - i - 1);
- gdk_draw_line (window, style->light_gc[state_type], x + i, y1 + thickness_light - i, x + i, y2);
- }
- if (area)
- {
- gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
- gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
+ _cairo_draw_line (cr, &style->dark[state_type],
+ x + i, y1, x + i, y1 + thickness_light - i - 1);
+ _cairo_draw_line (cr, &style->light[state_type],
+ x + i, y1 + thickness_light - i, x + i, y2);
}
+
+ cairo_destroy (cr);
}
static void
draw_thin_shadow (GtkStyle *style,
- GdkWindow *window,
+ cairo_t *cr,
GtkStateType state,
GdkRectangle *area,
gint x,
gint width,
gint height)
{
- GdkGC *gc1, *gc2;
+ GdkColor *gc1, *gc2;
- sanitize_size (window, &width, &height);
-
- gc1 = style->light_gc[state];
- gc2 = style->dark_gc[state];
-
- if (area)
- {
- gdk_gc_set_clip_rectangle (gc1, area);
- gdk_gc_set_clip_rectangle (gc2, area);
- }
-
- gdk_draw_line (window, gc1,
- x, y + height - 1, x + width - 1, y + height - 1);
- gdk_draw_line (window, gc1,
- x + width - 1, y, x + width - 1, y + height - 1);
-
- gdk_draw_line (window, gc2,
- x, y, x + width - 2, y);
- gdk_draw_line (window, gc2,
- x, y, x, y + height - 2);
+ gc1 = &style->light[state];
+ gc2 = &style->dark[state];
- if (area)
- {
- gdk_gc_set_clip_rectangle (gc1, NULL);
- gdk_gc_set_clip_rectangle (gc2, NULL);
- }
+ _cairo_draw_line (cr, gc1,
+ x, y + height - 1, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, gc1,
+ x + width - 1, y, x + width - 1, y + height - 1);
+
+ _cairo_draw_line (cr, gc2,
+ x, y, x + width - 2, y);
+ _cairo_draw_line (cr, gc2,
+ x, y, x, y + height - 2);
}
static void
draw_spinbutton_shadow (GtkStyle *style,
- GdkWindow *window,
+ cairo_t *cr,
GtkStateType state,
GtkTextDirection direction,
GdkRectangle *area,
gint width,
gint height)
{
- sanitize_size (window, &width, &height);
-
- if (area)
- {
- gdk_gc_set_clip_rectangle (style->black_gc, area);
- gdk_gc_set_clip_rectangle (style->bg_gc[state], area);
- gdk_gc_set_clip_rectangle (style->dark_gc[state], area);
- gdk_gc_set_clip_rectangle (style->light_gc[state], area);
- }
if (direction == GTK_TEXT_DIR_LTR)
{
- gdk_draw_line (window, style->dark_gc[state],
- x, y, x + width - 1, y);
- gdk_draw_line (window, style->black_gc,
- x, y + 1, x + width - 2, y + 1);
- gdk_draw_line (window, style->black_gc,
- x + width - 2, y + 2, x + width - 2, y + height - 3);
- gdk_draw_line (window, style->light_gc[state],
- x + width - 1, y + 1, x + width - 1, y + height - 2);
- gdk_draw_line (window, style->light_gc[state],
- x, y + height - 1, x + width - 1, y + height - 1);
- gdk_draw_line (window, style->bg_gc[state],
- x, y + height - 2, x + width - 2, y + height - 2);
- gdk_draw_line (window, style->black_gc,
- x, y + 2, x, y + height - 3);
+ _cairo_draw_line (cr, &style->dark[state],
+ x, y, x + width - 1, y);
+ _cairo_draw_line (cr, &style->black,
+ x, y + 1, x + width - 2, y + 1);
+ _cairo_draw_line (cr, &style->black,
+ x + width - 2, y + 2, x + width - 2, y + height - 3);
+ _cairo_draw_line (cr, &style->light[state],
+ x + width - 1, y + 1, x + width - 1, y + height - 2);
+ _cairo_draw_line (cr, &style->light[state],
+ x, y + height - 1, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, &style->bg[state],
+ x, y + height - 2, x + width - 2, y + height - 2);
+ _cairo_draw_line (cr, &style->black,
+ x, y + 2, x, y + height - 3);
}
else
{
- gdk_draw_line (window, style->dark_gc[state],
- x, y, x + width - 1, y);
- gdk_draw_line (window, style->dark_gc[state],
- x, y + 1, x, y + height - 1);
- gdk_draw_line (window, style->black_gc,
- x + 1, y + 1, x + width - 1, y + 1);
- gdk_draw_line (window, style->black_gc,
- x + 1, y + 2, x + 1, y + height - 2);
- gdk_draw_line (window, style->black_gc,
- x + width - 1, y + 2, x + width - 1, y + height - 3);
- gdk_draw_line (window, style->light_gc[state],
- x + 1, y + height - 1, x + width - 1, y + height - 1);
- gdk_draw_line (window, style->bg_gc[state],
- x + 2, y + height - 2, x + width - 1, y + height - 2);
- }
-
- if (area)
- {
- gdk_gc_set_clip_rectangle (style->black_gc, NULL);
- gdk_gc_set_clip_rectangle (style->bg_gc[state], NULL);
- gdk_gc_set_clip_rectangle (style->dark_gc[state], NULL);
- gdk_gc_set_clip_rectangle (style->light_gc[state], NULL);
+ _cairo_draw_line (cr, &style->dark[state],
+ x, y, x + width - 1, y);
+ _cairo_draw_line (cr, &style->dark[state],
+ x, y + 1, x, y + height - 1);
+ _cairo_draw_line (cr, &style->black,
+ x + 1, y + 1, x + width - 1, y + 1);
+ _cairo_draw_line (cr, &style->black,
+ x + 1, y + 2, x + 1, y + height - 2);
+ _cairo_draw_line (cr, &style->black,
+ x + width - 1, y + 2, x + width - 1, y + height - 3);
+ _cairo_draw_line (cr, &style->light[state],
+ x + 1, y + height - 1, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, &style->bg[state],
+ x + 2, y + height - 2, x + width - 1, y + height - 2);
}
}
static void
draw_menu_shadow (GtkStyle *style,
- GdkWindow *window,
+ cairo_t *cr,
GtkStateType state,
GdkRectangle *area,
gint x,
{
if (style->ythickness > 1)
{
- gdk_draw_line (window, style->dark_gc[state],
- x + 1, y + height - 2, x + width - 2, y + height - 2);
- gdk_draw_line (window, style->black_gc,
- x, y + height - 1, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, &style->dark[state],
+ x + 1, y + height - 2,
+ x + width - 2, y + height - 2);
+ _cairo_draw_line (cr, &style->black,
+ x, y + height - 1, x + width - 1, y + height - 1);
}
else
{
- gdk_draw_line (window, style->dark_gc[state],
- x + 1, y + height - 1, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, &style->dark[state],
+ x + 1, y + height - 1, x + width - 1, y + height - 1);
}
}
{
if (style->xthickness > 1)
{
- gdk_draw_line (window, style->dark_gc[state],
- x + width - 2, y + 1, x + width - 2, y + height - 2);
-
- gdk_draw_line (window, style->black_gc,
- x + width - 1, y, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, &style->dark[state],
+ x + width - 2, y + 1,
+ x + width - 2, y + height - 2);
+
+ _cairo_draw_line (cr, &style->black,
+ x + width - 1, y, x + width - 1, y + height - 1);
}
else
{
- gdk_draw_line (window, style->dark_gc[state],
- x + width - 1, y + 1, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, &style->dark[state],
+ x + width - 1, y + 1, x + width - 1, y + height - 1);
}
}
/* Light around top and left */
if (style->ythickness > 0)
- gdk_draw_line (window, style->black_gc,
+ _cairo_draw_line (cr, &style->black,
x, y, x + width - 2, y);
if (style->xthickness > 0)
- gdk_draw_line (window, style->black_gc,
- x, y, x, y + height - 2);
+ _cairo_draw_line (cr, &style->black,
+ x, y, x, y + height - 2);
if (style->ythickness > 1)
- gdk_draw_line (window, style->light_gc[state],
- x + 1, y + 1, x + width - 3, y + 1);
+ _cairo_draw_line (cr, &style->light[state],
+ x + 1, y + 1, x + width - 3, y + 1);
if (style->xthickness > 1)
- gdk_draw_line (window, style->light_gc[state],
- x + 1, y + 1, x + 1, y + height - 3);
+ _cairo_draw_line (cr, &style->light[state],
+ x + 1, y + 1, x + 1, y + height - 3);
}
static GtkTextDirection
gint width,
gint height)
{
- GdkGC *gc1 = NULL;
- GdkGC *gc2 = NULL;
+ cairo_t *cr;
+ GdkColor *gc1 = NULL;
+ GdkColor *gc2 = NULL;
gint thickness_light;
gint thickness_dark;
gint i;
-
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
+
+ sanitize_size (window, &width, &height);
+
+ cr = gdk_cairo_create (window);
+ cairo_set_line_width (cr, 1.0);
+
+ if (area)
+ {
+ gdk_cairo_rectangle (cr, area);
+ cairo_clip (cr);
+ }
if (shadow_type == GTK_SHADOW_IN)
{
- if (detail && (strcmp (detail, "buttondefault") == 0))
+ if (detail && strcmp (detail, "buttondefault") == 0)
{
- sanitize_size (window, &width, &height);
+ _cairo_draw_rectangle (cr, &style->black, FALSE,
+ x, y, width - 1, height - 1);
- gdk_draw_rectangle (window, style->black_gc, FALSE,
- x, y, width - 1, height - 1);
-
+ cairo_destroy (cr);
return;
}
if (detail && strcmp (detail, "trough") == 0)
{
- draw_thin_shadow (style, window, state_type, area,
- x, y, width, height);
+ draw_thin_shadow (style, cr, state_type, area,
+ x, y, width, height);
+
+ cairo_destroy (cr);
return;
}
- if (widget && GTK_IS_SPIN_BUTTON (widget) &&
+ if (GTK_IS_SPIN_BUTTON (widget) &&
detail && strcmp (detail, "spinbutton") == 0)
{
- draw_spinbutton_shadow (style, window, state_type,
+ draw_spinbutton_shadow (style, cr, state_type,
get_direction (widget), area, x, y, width, height);
+ cairo_destroy (cr);
return;
}
}
if (shadow_type == GTK_SHADOW_OUT && detail && strcmp (detail, "menu") == 0)
{
- draw_menu_shadow (style, window, state_type, area, x, y, width, height);
+ draw_menu_shadow (style, cr, state_type, area, x, y, width, height);
+ cairo_destroy (cr);
return;
}
- sanitize_size (window, &width, &height);
-
switch (shadow_type)
{
case GTK_SHADOW_NONE:
+ cairo_destroy (cr);
return;
case GTK_SHADOW_IN:
case GTK_SHADOW_ETCHED_IN:
- gc1 = style->light_gc[state_type];
- gc2 = style->dark_gc[state_type];
+ gc1 = &style->light[state_type];
+ gc2 = &style->dark[state_type];
break;
case GTK_SHADOW_OUT:
case GTK_SHADOW_ETCHED_OUT:
- gc1 = style->dark_gc[state_type];
- gc2 = style->light_gc[state_type];
+ gc1 = &style->dark[state_type];
+ gc2 = &style->light[state_type];
break;
}
- if (area)
- {
- gdk_gc_set_clip_rectangle (gc1, area);
- gdk_gc_set_clip_rectangle (gc2, area);
- if (shadow_type == GTK_SHADOW_IN ||
- shadow_type == GTK_SHADOW_OUT)
- {
- gdk_gc_set_clip_rectangle (style->black_gc, area);
- gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
- }
- }
-
switch (shadow_type)
{
case GTK_SHADOW_NONE:
/* Light around right and bottom edge */
if (style->ythickness > 0)
- gdk_draw_line (window, gc1,
- x, y + height - 1, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, gc1,
+ x, y + height - 1, x + width - 1, y + height - 1);
if (style->xthickness > 0)
- gdk_draw_line (window, gc1,
- x + width - 1, y, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, gc1,
+ x + width - 1, y, x + width - 1, y + height - 1);
if (style->ythickness > 1)
- gdk_draw_line (window, style->bg_gc[state_type],
- x + 1, y + height - 2, x + width - 2, y + height - 2);
+ _cairo_draw_line (cr, &style->bg[state_type],
+ x + 1, y + height - 2, x + width - 2, y + height - 2);
if (style->xthickness > 1)
- gdk_draw_line (window, style->bg_gc[state_type],
- x + width - 2, y + 1, x + width - 2, y + height - 2);
+ _cairo_draw_line (cr, &style->bg[state_type],
+ x + width - 2, y + 1, x + width - 2, y + height - 2);
/* Dark around left and top */
if (style->ythickness > 1)
- gdk_draw_line (window, style->black_gc,
- x + 1, y + 1, x + width - 2, y + 1);
+ _cairo_draw_line (cr, &style->black,
+ x + 1, y + 1, x + width - 2, y + 1);
if (style->xthickness > 1)
- gdk_draw_line (window, style->black_gc,
- x + 1, y + 1, x + 1, y + height - 2);
+ _cairo_draw_line (cr, &style->black,
+ x + 1, y + 1, x + 1, y + height - 2);
if (style->ythickness > 0)
- gdk_draw_line (window, gc2,
- x, y, x + width - 1, y);
+ _cairo_draw_line (cr, gc2,
+ x, y, x + width - 1, y);
if (style->xthickness > 0)
- gdk_draw_line (window, gc2,
- x, y, x, y + height - 1);
+ _cairo_draw_line (cr, gc2,
+ x, y, x, y + height - 1);
break;
case GTK_SHADOW_OUT:
{
if (style->ythickness > 1)
{
- gdk_draw_line (window, gc1,
- x + 1, y + height - 2, x + width - 2, y + height - 2);
- gdk_draw_line (window, style->black_gc,
- x, y + height - 1, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, gc1,
+ x + 1, y + height - 2, x + width - 2, y + height - 2);
+ _cairo_draw_line (cr, &style->black,
+ x, y + height - 1, x + width - 1, y + height - 1);
}
else
{
- gdk_draw_line (window, gc1,
- x + 1, y + height - 1, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, gc1,
+ x + 1, y + height - 1, x + width - 1, y + height - 1);
}
}
{
if (style->xthickness > 1)
{
- gdk_draw_line (window, gc1,
- x + width - 2, y + 1, x + width - 2, y + height - 2);
+ _cairo_draw_line (cr, gc1,
+ x + width - 2, y + 1, x + width - 2, y + height - 2);
- gdk_draw_line (window, style->black_gc,
- x + width - 1, y, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, &style->black,
+ x + width - 1, y, x + width - 1, y + height - 1);
}
else
{
- gdk_draw_line (window, gc1,
- x + width - 1, y + 1, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, gc1,
+ x + width - 1, y + 1, x + width - 1, y + height - 1);
}
}
/* Light around top and left */
if (style->ythickness > 0)
- gdk_draw_line (window, gc2,
- x, y, x + width - 2, y);
+ _cairo_draw_line (cr, gc2,
+ x, y, x + width - 2, y);
if (style->xthickness > 0)
- gdk_draw_line (window, gc2,
- x, y, x, y + height - 2);
+ _cairo_draw_line (cr, gc2,
+ x, y, x, y + height - 2);
if (style->ythickness > 1)
- gdk_draw_line (window, style->bg_gc[state_type],
- x + 1, y + 1, x + width - 3, y + 1);
+ _cairo_draw_line (cr, &style->bg[state_type],
+ x + 1, y + 1, x + width - 3, y + 1);
if (style->xthickness > 1)
- gdk_draw_line (window, style->bg_gc[state_type],
- x + 1, y + 1, x + 1, y + height - 3);
+ _cairo_draw_line (cr, &style->bg[state_type],
+ x + 1, y + 1, x + 1, y + height - 3);
break;
case GTK_SHADOW_ETCHED_IN:
for (i = 0; i < thickness_dark; i++)
{
- gdk_draw_line (window, gc1,
- x + width - i - 1,
- y + i,
- x + width - i - 1,
- y + height - i - 1);
- gdk_draw_line (window, gc2,
- x + i,
- y + i,
- x + i,
- y + height - i - 2);
+ _cairo_draw_line (cr, gc1,
+ x + width - i - 1,
+ y + i,
+ x + width - i - 1,
+ y + height - i - 1);
+ _cairo_draw_line (cr, gc2,
+ x + i,
+ y + i,
+ x + i,
+ y + height - i - 2);
}
for (i = 0; i < thickness_light; i++)
{
- gdk_draw_line (window, gc1,
- x + thickness_dark + i,
- y + thickness_dark + i,
- x + thickness_dark + i,
- y + height - thickness_dark - i - 1);
- gdk_draw_line (window, gc2,
- x + width - thickness_light - i - 1,
- y + thickness_dark + i,
- x + width - thickness_light - i - 1,
- y + height - thickness_light - 1);
+ _cairo_draw_line (cr, gc1,
+ x + thickness_dark + i,
+ y + thickness_dark + i,
+ x + thickness_dark + i,
+ y + height - thickness_dark - i - 1);
+ _cairo_draw_line (cr, gc2,
+ x + width - thickness_light - i - 1,
+ y + thickness_dark + i,
+ x + width - thickness_light - i - 1,
+ y + height - thickness_light - 1);
}
}
else
{
- gdk_draw_line (window,
- style->dark_gc[state_type],
- x, y, x, y + height);
- gdk_draw_line (window,
- style->dark_gc[state_type],
- x + width, y, x + width, y + height);
+ _cairo_draw_line (cr,
+ &style->dark[state_type],
+ x, y, x, y + height);
+ _cairo_draw_line (cr,
+ &style->dark[state_type],
+ x + width, y, x + width, y + height);
}
}
for (i = 0; i < thickness_dark; i++)
{
- gdk_draw_line (window, gc1,
- x + i,
- y + height - i - 1,
- x + width - i - 1,
- y + height - i - 1);
+ _cairo_draw_line (cr, gc1,
+ x + i,
+ y + height - i - 1,
+ x + width - i - 1,
+ y + height - i - 1);
- gdk_draw_line (window, gc2,
- x + i,
- y + i,
- x + width - i - 2,
- y + i);
+ _cairo_draw_line (cr, gc2,
+ x + i,
+ y + i,
+ x + width - i - 2,
+ y + i);
}
for (i = 0; i < thickness_light; i++)
{
- gdk_draw_line (window, gc1,
- x + thickness_dark + i,
- y + thickness_dark + i,
- x + width - thickness_dark - i - 2,
- y + thickness_dark + i);
+ _cairo_draw_line (cr, gc1,
+ x + thickness_dark + i,
+ y + thickness_dark + i,
+ x + width - thickness_dark - i - 2,
+ y + thickness_dark + i);
- gdk_draw_line (window, gc2,
- x + thickness_dark + i,
- y + height - thickness_light - i - 1,
- x + width - thickness_light - 1,
- y + height - thickness_light - i - 1);
+ _cairo_draw_line (cr, gc2,
+ x + thickness_dark + i,
+ y + height - thickness_light - i - 1,
+ x + width - thickness_light - 1,
+ y + height - thickness_light - i - 1);
}
}
else
{
- gdk_draw_line (window,
- style->dark_gc[state_type],
- x, y, x + width, y);
- gdk_draw_line (window,
- style->dark_gc[state_type],
- x, y + height, x + width, y + height);
+ _cairo_draw_line (cr,
+ &style->dark[state_type],
+ x, y, x + width, y);
+ _cairo_draw_line (cr,
+ &style->dark[state_type],
+ x, y + height, x + width, y + height);
}
}
}
if (shadow_type == GTK_SHADOW_IN &&
- widget && GTK_IS_SPIN_BUTTON (widget) &&
+ GTK_IS_SPIN_BUTTON (widget) &&
detail && strcmp (detail, "entry") == 0)
{
if (get_direction (widget) == GTK_TEXT_DIR_LTR)
{
- gdk_draw_line (window,
- style->base_gc[state_type],
- x + width - 1, y + 2,
- x + width - 1, y + height - 3);
- gdk_draw_line (window,
- style->base_gc[state_type],
- x + width - 2, y + 2,
- x + width - 2, y + height - 3);
- gdk_draw_point (window,
- style->black_gc,
- x + width - 1, y + 1);
- gdk_draw_point (window,
- style->bg_gc[state_type],
- x + width - 1, y + height - 2);
+ _cairo_draw_line (cr,
+ &style->base[state_type],
+ x + width - 1, y + 2,
+ x + width - 1, y + height - 3);
+ _cairo_draw_line (cr,
+ &style->base[state_type],
+ x + width - 2, y + 2,
+ x + width - 2, y + height - 3);
+ /* draw point */
+ _cairo_draw_point (cr,
+ &style->black,
+ x + width - 1, y + 1);
+ _cairo_draw_point (cr,
+ &style->bg[state_type],
+ x + width - 1, y + height - 2);
}
else
{
- gdk_draw_line (window,
- style->base_gc[state_type],
- x, y + 2,
- x, y + height - 3);
- gdk_draw_line (window,
- style->base_gc[state_type],
- x + 1, y + 2,
- x + 1, y + height - 3);
- gdk_draw_point (window,
- style->black_gc,
- x, y + 1);
- gdk_draw_line (window,
- style->bg_gc[state_type],
- x, y + height - 2,
- x + 1, y + height - 2);
- gdk_draw_point (window,
- style->light_gc[state_type],
- x, y + height - 1);
+ _cairo_draw_line (cr,
+ &style->base[state_type],
+ x, y + 2,
+ x, y + height - 3);
+ _cairo_draw_line (cr,
+ &style->base[state_type],
+ x + 1, y + 2,
+ x + 1, y + height - 3);
+
+ _cairo_draw_point (cr,
+ &style->black,
+ x, y + 1);
+
+ _cairo_draw_line (cr,
+ &style->bg[state_type],
+ x, y + height - 2,
+ x + 1, y + height - 2);
+ _cairo_draw_point (cr,
+ &style->light[state_type],
+ x, y + height - 1);
}
}
- if (area)
- {
- gdk_gc_set_clip_rectangle (gc1, NULL);
- gdk_gc_set_clip_rectangle (gc2, NULL);
- if (shadow_type == GTK_SHADOW_IN ||
- shadow_type == GTK_SHADOW_OUT)
- {
- gdk_gc_set_clip_rectangle (style->black_gc, NULL);
- gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
- }
- }
-}
-
-static void
-gtk_default_draw_polygon (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- GdkPoint *points,
- gint npoints,
- gboolean fill)
-{
- static const gdouble pi_over_4 = G_PI_4;
- static const gdouble pi_3_over_4 = G_PI_4 * 3;
- GdkGC *gc1;
- GdkGC *gc2;
- GdkGC *gc3;
- GdkGC *gc4;
- gdouble angle;
- gint xadjust;
- gint yadjust;
- gint i;
-
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
- g_return_if_fail (points != NULL);
-
- switch (shadow_type)
- {
- case GTK_SHADOW_IN:
- gc1 = style->bg_gc[state_type];
- gc2 = style->dark_gc[state_type];
- gc3 = style->light_gc[state_type];
- gc4 = style->black_gc;
- break;
- case GTK_SHADOW_ETCHED_IN:
- gc1 = style->light_gc[state_type];
- gc2 = style->dark_gc[state_type];
- gc3 = style->dark_gc[state_type];
- gc4 = style->light_gc[state_type];
- break;
- case GTK_SHADOW_OUT:
- gc1 = style->dark_gc[state_type];
- gc2 = style->light_gc[state_type];
- gc3 = style->black_gc;
- gc4 = style->bg_gc[state_type];
- break;
- case GTK_SHADOW_ETCHED_OUT:
- gc1 = style->dark_gc[state_type];
- gc2 = style->light_gc[state_type];
- gc3 = style->light_gc[state_type];
- gc4 = style->dark_gc[state_type];
- break;
- default:
- return;
- }
-
- if (area)
- {
- gdk_gc_set_clip_rectangle (gc1, area);
- gdk_gc_set_clip_rectangle (gc2, area);
- gdk_gc_set_clip_rectangle (gc3, area);
- gdk_gc_set_clip_rectangle (gc4, area);
- }
-
- if (fill)
- gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, npoints);
-
- npoints--;
-
- for (i = 0; i < npoints; i++)
- {
- if ((points[i].x == points[i+1].x) &&
- (points[i].y == points[i+1].y))
- {
- angle = 0;
- }
- else
- {
- angle = atan2 (points[i+1].y - points[i].y,
- points[i+1].x - points[i].x);
- }
-
- if ((angle > -pi_3_over_4) && (angle < pi_over_4))
- {
- if (angle > -pi_over_4)
- {
- xadjust = 0;
- yadjust = 1;
- }
- else
- {
- xadjust = 1;
- yadjust = 0;
- }
-
- gdk_draw_line (window, gc1,
- points[i].x-xadjust, points[i].y-yadjust,
- points[i+1].x-xadjust, points[i+1].y-yadjust);
- gdk_draw_line (window, gc3,
- points[i].x, points[i].y,
- points[i+1].x, points[i+1].y);
- }
- else
- {
- if ((angle < -pi_3_over_4) || (angle > pi_3_over_4))
- {
- xadjust = 0;
- yadjust = 1;
- }
- else
- {
- xadjust = 1;
- yadjust = 0;
- }
-
- gdk_draw_line (window, gc4,
- points[i].x+xadjust, points[i].y+yadjust,
- points[i+1].x+xadjust, points[i+1].y+yadjust);
- gdk_draw_line (window, gc2,
- points[i].x, points[i].y,
- points[i+1].x, points[i+1].y);
- }
- }
-
- if (area)
- {
- gdk_gc_set_clip_rectangle (gc1, NULL);
- gdk_gc_set_clip_rectangle (gc2, NULL);
- gdk_gc_set_clip_rectangle (gc3, NULL);
- gdk_gc_set_clip_rectangle (gc4, NULL);
- }
+ cairo_destroy (cr);
}
static void
-draw_arrow (GdkWindow *window,
+draw_arrow (cairo_t *cr,
GdkColor *color,
- GdkRectangle *area,
GtkArrowType arrow_type,
gint x,
gint y,
gint width,
gint height)
{
- cairo_t *cr = gdk_cairo_create (window);
gdk_cairo_set_source_color (cr, color);
-
- if (area)
- {
- gdk_cairo_rectangle (cr, area);
- cairo_clip (cr);
- }
+ cairo_save (cr);
if (arrow_type == GTK_ARROW_DOWN)
{
cairo_close_path (cr);
cairo_fill (cr);
- cairo_destroy (cr);
+ cairo_restore (cr);
}
static void
gint width,
gint height)
{
+ cairo_t *cr;
+
sanitize_size (window, &width, &height);
calculate_arrow_geometry (arrow_type, &x, &y, &width, &height);
if (detail && strcmp (detail, "menu_scroll_arrow_up") == 0)
y++;
+ cr = gdk_cairo_create (window);
+
+ if (area)
+ {
+ gdk_cairo_rectangle (cr, area);
+ cairo_clip (cr);
+ }
+
if (state == GTK_STATE_INSENSITIVE)
- draw_arrow (window, &style->white, area, arrow_type,
+ draw_arrow (cr, &style->white, arrow_type,
x + 1, y + 1, width, height);
- draw_arrow (window, &style->fg[state], area, arrow_type,
+ draw_arrow (cr, &style->fg[state], arrow_type,
x, y, width, height);
+
+ cairo_destroy (cr);
}
static void
{
gint half_width;
gint half_height;
- GdkGC *outer_nw = NULL;
- GdkGC *outer_ne = NULL;
- GdkGC *outer_sw = NULL;
- GdkGC *outer_se = NULL;
- GdkGC *middle_nw = NULL;
- GdkGC *middle_ne = NULL;
- GdkGC *middle_sw = NULL;
- GdkGC *middle_se = NULL;
- GdkGC *inner_nw = NULL;
- GdkGC *inner_ne = NULL;
- GdkGC *inner_sw = NULL;
- GdkGC *inner_se = NULL;
-
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
+ GdkColor *outer_nw = NULL;
+ GdkColor *outer_ne = NULL;
+ GdkColor *outer_sw = NULL;
+ GdkColor *outer_se = NULL;
+ GdkColor *middle_nw = NULL;
+ GdkColor *middle_ne = NULL;
+ GdkColor *middle_sw = NULL;
+ GdkColor *middle_se = NULL;
+ GdkColor *inner_nw = NULL;
+ GdkColor *inner_ne = NULL;
+ GdkColor *inner_sw = NULL;
+ GdkColor *inner_se = NULL;
+ cairo_t *cr;
sanitize_size (window, &width, &height);
- half_width = width / 2;
- half_height = height / 2;
-
- if (area)
- {
- gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
- gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
- gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
- gdk_gc_set_clip_rectangle (style->black_gc, area);
- }
-
- switch (shadow_type)
- {
- case GTK_SHADOW_IN:
- inner_sw = inner_se = style->bg_gc[state_type];
- middle_sw = middle_se = style->light_gc[state_type];
- outer_sw = outer_se = style->light_gc[state_type];
- inner_nw = inner_ne = style->black_gc;
- middle_nw = middle_ne = style->dark_gc[state_type];
- outer_nw = outer_ne = style->dark_gc[state_type];
- break;
-
- case GTK_SHADOW_OUT:
- inner_sw = inner_se = style->dark_gc[state_type];
- middle_sw = middle_se = style->dark_gc[state_type];
- outer_sw = outer_se = style->black_gc;
- inner_nw = inner_ne = style->bg_gc[state_type];
- middle_nw = middle_ne = style->light_gc[state_type];
- outer_nw = outer_ne = style->light_gc[state_type];
- break;
-
- case GTK_SHADOW_ETCHED_IN:
- inner_sw = inner_se = style->bg_gc[state_type];
- middle_sw = middle_se = style->dark_gc[state_type];
- outer_sw = outer_se = style->light_gc[state_type];
- inner_nw = inner_ne = style->bg_gc[state_type];
- middle_nw = middle_ne = style->light_gc[state_type];
- outer_nw = outer_ne = style->dark_gc[state_type];
- break;
-
- case GTK_SHADOW_ETCHED_OUT:
- inner_sw = inner_se = style->bg_gc[state_type];
- middle_sw = middle_se = style->light_gc[state_type];
- outer_sw = outer_se = style->dark_gc[state_type];
- inner_nw = inner_ne = style->bg_gc[state_type];
- middle_nw = middle_ne = style->dark_gc[state_type];
- outer_nw = outer_ne = style->light_gc[state_type];
- break;
-
- default:
-
- break;
- }
-
- if (inner_sw)
- {
- gdk_draw_line (window, inner_sw,
- x + 2, y + half_height,
- x + half_width, y + height - 2);
- gdk_draw_line (window, inner_se,
- x + half_width, y + height - 2,
- x + width - 2, y + half_height);
- gdk_draw_line (window, middle_sw,
- x + 1, y + half_height,
- x + half_width, y + height - 1);
- gdk_draw_line (window, middle_se,
- x + half_width, y + height - 1,
- x + width - 1, y + half_height);
- gdk_draw_line (window, outer_sw,
- x, y + half_height,
- x + half_width, y + height);
- gdk_draw_line (window, outer_se,
- x + half_width, y + height,
- x + width, y + half_height);
-
- gdk_draw_line (window, inner_nw,
- x + 2, y + half_height,
- x + half_width, y + 2);
- gdk_draw_line (window, inner_ne,
- x + half_width, y + 2,
- x + width - 2, y + half_height);
- gdk_draw_line (window, middle_nw,
- x + 1, y + half_height,
- x + half_width, y + 1);
- gdk_draw_line (window, middle_ne,
- x + half_width, y + 1,
- x + width - 1, y + half_height);
- gdk_draw_line (window, outer_nw,
- x, y + half_height,
- x + half_width, y);
- gdk_draw_line (window, outer_ne,
- x + half_width, y,
- x + width, y + half_height);
- }
-
- if (area)
- {
- gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
- gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
- gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
- gdk_gc_set_clip_rectangle (style->black_gc, NULL);
- }
-}
-
-static void
-gtk_default_draw_string (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x,
- gint y,
- const gchar *string)
-{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
+ half_width = width / 2;
+ half_height = height / 2;
- if (area)
+ switch (shadow_type)
{
- gdk_gc_set_clip_rectangle (style->white_gc, area);
- gdk_gc_set_clip_rectangle (style->fg_gc[state_type], area);
- }
+ case GTK_SHADOW_IN:
+ inner_sw = inner_se = &style->bg[state_type];
+ middle_sw = middle_se = &style->light[state_type];
+ outer_sw = outer_se = &style->light[state_type];
+ inner_nw = inner_ne = &style->black;
+ middle_nw = middle_ne = &style->dark[state_type];
+ outer_nw = outer_ne = &style->dark[state_type];
+ break;
+
+ case GTK_SHADOW_OUT:
+ inner_sw = inner_se = &style->dark[state_type];
+ middle_sw = middle_se = &style->dark[state_type];
+ outer_sw = outer_se = &style->black;
+ inner_nw = inner_ne = &style->bg[state_type];
+ middle_nw = middle_ne = &style->light[state_type];
+ outer_nw = outer_ne = &style->light[state_type];
+ break;
- if (state_type == GTK_STATE_INSENSITIVE)
- gdk_draw_string (window,
- gtk_style_get_font_internal (style),
- style->white_gc, x + 1, y + 1, string);
+ case GTK_SHADOW_ETCHED_IN:
+ inner_sw = inner_se = &style->bg[state_type];
+ middle_sw = middle_se = &style->dark[state_type];
+ outer_sw = outer_se = &style->light[state_type];
+ inner_nw = inner_ne = &style->bg[state_type];
+ middle_nw = middle_ne = &style->light[state_type];
+ outer_nw = outer_ne = &style->dark[state_type];
+ break;
+
+ case GTK_SHADOW_ETCHED_OUT:
+ inner_sw = inner_se = &style->bg[state_type];
+ middle_sw = middle_se = &style->light[state_type];
+ outer_sw = outer_se = &style->dark[state_type];
+ inner_nw = inner_ne = &style->bg[state_type];
+ middle_nw = middle_ne = &style->dark[state_type];
+ outer_nw = outer_ne = &style->light[state_type];
+ break;
+
+ default:
- gdk_draw_string (window,
- gtk_style_get_font_internal (style),
- style->fg_gc[state_type], x, y, string);
+ break;
+ }
+ cr = gdk_cairo_create (window);
if (area)
{
- gdk_gc_set_clip_rectangle (style->white_gc, NULL);
- gdk_gc_set_clip_rectangle (style->fg_gc[state_type], NULL);
+ gdk_cairo_rectangle (cr, area);
+ cairo_clip (cr);
+ }
+
+ if (inner_sw)
+ {
+ _cairo_draw_line (cr, inner_sw,
+ x + 2, y + half_height,
+ x + half_width, y + height - 2);
+ _cairo_draw_line (cr, inner_se,
+ x + half_width, y + height - 2,
+ x + width - 2, y + half_height);
+ _cairo_draw_line (cr, middle_sw,
+ x + 1, y + half_height,
+ x + half_width, y + height - 1);
+ _cairo_draw_line (cr, middle_se,
+ x + half_width, y + height - 1,
+ x + width - 1, y + half_height);
+ _cairo_draw_line (cr, outer_sw,
+ x, y + half_height,
+ x + half_width, y + height);
+ _cairo_draw_line (cr, outer_se,
+ x + half_width, y + height,
+ x + width, y + half_height);
+
+ _cairo_draw_line (cr, inner_nw,
+ x + 2, y + half_height,
+ x + half_width, y + 2);
+ _cairo_draw_line (cr, inner_ne,
+ x + half_width, y + 2,
+ x + width - 2, y + half_height);
+ _cairo_draw_line (cr, middle_nw,
+ x + 1, y + half_height,
+ x + half_width, y + 1);
+ _cairo_draw_line (cr, middle_ne,
+ x + half_width, y + 1,
+ x + width - 1, y + half_height);
+ _cairo_draw_line (cr, outer_nw,
+ x, y + half_height,
+ x + half_width, y);
+ _cairo_draw_line (cr, outer_ne,
+ x + half_width, y,
+ x + width, y + half_height);
}
+
+ cairo_destroy (cr);
}
static void
{
GtkRequisition *tmp_size = NULL;
GtkBorder *tmp_spacing = NULL;
-
- if (widget)
- gtk_widget_style_get (widget,
- "indicator-size", &tmp_size,
- "indicator-spacing", &tmp_spacing,
- NULL);
if (tmp_size)
{
*indicator_size = *tmp_size;
- g_free (tmp_size);
+ gtk_requisition_free (tmp_size);
}
else
*indicator_size = default_option_indicator_size;
if (tmp_spacing)
{
*indicator_spacing = *tmp_spacing;
- g_free (tmp_spacing);
+ gtk_border_free (tmp_spacing);
}
else
*indicator_spacing = default_option_indicator_spacing;
{
gboolean is_spinbutton_box = FALSE;
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
sanitize_size (window, &width, &height);
- if (widget && GTK_IS_SPIN_BUTTON (widget) && detail)
+ if (GTK_IS_SPIN_BUTTON (widget) && detail)
{
if (strcmp (detail, "spinbutton_up") == 0)
{
if (!style->bg_pixmap[state_type] ||
GDK_IS_PIXMAP (window))
{
- GdkGC *gc = style->bg_gc[state_type];
-
+ cairo_t *cr;
+ GdkColor *gc = &style->bg[state_type];
+
+ cr = gdk_cairo_create (window);
+
if (state_type == GTK_STATE_SELECTED && detail && strcmp (detail, "paned") == 0)
{
- if (widget && !GTK_WIDGET_HAS_FOCUS (widget))
- gc = style->base_gc[GTK_STATE_ACTIVE];
+ if (widget && !gtk_widget_has_focus (widget))
+ gc = &style->base[GTK_STATE_ACTIVE];
}
if (area)
- gdk_gc_set_clip_rectangle (gc, area);
+ {
+ gdk_cairo_rectangle (cr, area);
+ cairo_clip (cr);
+ }
- gdk_draw_rectangle (window, gc, TRUE,
- x, y, width, height);
- if (area)
- gdk_gc_set_clip_rectangle (gc, NULL);
+ _cairo_draw_rectangle (cr, gc, TRUE,
+ x, y, width, height);
+ cairo_destroy (cr);
}
else
gtk_style_apply_default_background (style, window,
- widget && !GTK_WIDGET_NO_WINDOW (widget),
+ widget && gtk_widget_get_has_window (widget),
state_type, area, x, y, width, height);
if (is_spinbutton_box)
{
- GdkGC *upper_gc;
- GdkGC *lower_gc;
-
- lower_gc = style->dark_gc[state_type];
+ cairo_t *cr;
+ GdkColor *upper;
+ GdkColor *lower;
+
+ cr = gdk_cairo_create (window);
+
+ lower = &style->dark[state_type];
if (shadow_type == GTK_SHADOW_OUT)
- upper_gc = style->light_gc[state_type];
+ upper = &style->light[state_type];
else
- upper_gc = style->dark_gc[state_type];
+ upper = &style->dark[state_type];
if (area)
{
- gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
- gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
+ gdk_cairo_rectangle (cr, area);
+ cairo_clip (cr);
}
- gdk_draw_line (window, upper_gc, x, y, x + width - 1, y);
- gdk_draw_line (window, lower_gc, x, y + height - 1, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, upper, x, y, x + width - 1, y);
+ _cairo_draw_line (cr, lower, x, y + height - 1, x + width - 1, y + height - 1);
- if (area)
- {
- gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
- gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
- }
+ cairo_destroy (cr);
return;
}
}
}
-static GdkGC*
-get_darkened_gc (GdkWindow *window,
- GdkColor *color,
- gint darken_count)
+static GdkColor *
+get_darkened (const GdkColor *color,
+ gint darken_count)
{
GdkColor src = *color;
GdkColor shaded = *color;
- GdkGC *gc;
- gc = gdk_gc_new (window);
-
while (darken_count)
{
_gtk_style_shade (&src, &shaded, 0.93);
--darken_count;
}
- gdk_gc_set_rgb_fg_color (gc, &shaded);
-
- return gc;
+ return gdk_color_copy (&shaded);
}
static void
gint width,
gint height)
{
- GdkGC *gc1;
- GdkGC *freeme = NULL;
-
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
+ GdkColor *gc1;
+ GdkColor *freeme = NULL;
sanitize_size (window, &width, &height);
if (state_type == GTK_STATE_SELECTED)
{
if (!strcmp ("text", detail))
- gc1 = style->bg_gc[GTK_STATE_SELECTED];
+ gc1 = &style->bg[GTK_STATE_SELECTED];
else if (!strcmp ("cell_even", detail) ||
!strcmp ("cell_odd", detail) ||
- !strcmp ("cell_even_ruled", detail))
+ !strcmp ("cell_even_ruled", detail) ||
+ !strcmp ("cell_even_ruled_sorted", detail))
{
/* This has to be really broken; alex made me do it. -jrb */
- if (GTK_WIDGET_HAS_FOCUS (widget))
- gc1 = style->base_gc[state_type];
+ if (widget && gtk_widget_has_focus (widget))
+ gc1 = &style->base[state_type];
else
- gc1 = style->base_gc[GTK_STATE_ACTIVE];
+ gc1 = &style->base[GTK_STATE_ACTIVE];
}
- else if (!strcmp ("cell_odd_ruled", detail))
+ else if (!strcmp ("cell_odd_ruled", detail) ||
+ !strcmp ("cell_odd_ruled_sorted", detail))
{
- if (GTK_WIDGET_HAS_FOCUS (widget))
- freeme = get_darkened_gc (window, &style->base[state_type], 1);
+ if (widget && gtk_widget_has_focus (widget))
+ freeme = get_darkened (&style->base[state_type], 1);
else
- freeme = get_darkened_gc (window, &style->base[GTK_STATE_ACTIVE], 1);
+ freeme = get_darkened (&style->base[GTK_STATE_ACTIVE], 1);
gc1 = freeme;
}
else
{
- gc1 = style->bg_gc[state_type];
+ gc1 = &style->bg[state_type];
}
}
else
{
if (!strcmp ("viewportbin", detail))
- gc1 = style->bg_gc[GTK_STATE_NORMAL];
+ gc1 = &style->bg[GTK_STATE_NORMAL];
else if (!strcmp ("entry_bg", detail))
- gc1 = style->base_gc[state_type];
+ gc1 = &style->base[gtk_widget_get_state (widget)];
/* For trees: even rows are base color, odd rows are a shade of
* the base color, the sort column is a shade of the original color
if (color)
{
- freeme = get_darkened_gc (window, color, 0);
+ freeme = get_darkened (color, 0);
gc1 = freeme;
gdk_color_free (color);
}
else
- gc1 = style->base_gc[state_type];
+ gc1 = &style->base[state_type];
}
else if (!strcmp ("cell_odd_ruled", detail))
{
- GdkColor *color;
+ GdkColor *color = NULL;
gtk_widget_style_get (widget,
"odd-row-color", &color,
if (color)
{
- freeme = get_darkened_gc (window, color, 0);
+ freeme = get_darkened (color, 0);
gc1 = freeme;
gdk_color_free (color);
if (color)
{
- freeme = get_darkened_gc (window, color, 1);
+ freeme = get_darkened (color, 1);
gdk_color_free (color);
}
else
- freeme = get_darkened_gc (window, &style->base[state_type], 1);
+ freeme = get_darkened (&style->base[state_type], 1);
gc1 = freeme;
}
}
if (color)
{
- freeme = get_darkened_gc (window, color, 1);
+ freeme = get_darkened (color, 1);
gc1 = freeme;
gdk_color_free (color);
}
else
{
- freeme = get_darkened_gc (window, &style->base[state_type], 1);
+ freeme = get_darkened (&style->base[state_type], 1);
gc1 = freeme;
}
}
if (color)
{
- freeme = get_darkened_gc (window, color, 1);
+ freeme = get_darkened (color, 1);
gc1 = freeme;
gdk_color_free (color);
if (color)
{
- freeme = get_darkened_gc (window, color, 2);
+ freeme = get_darkened (color, 2);
gdk_color_free (color);
}
else
- freeme = get_darkened_gc (window, &style->base[state_type], 2);
+ freeme = get_darkened (&style->base[state_type], 2);
gc1 = freeme;
}
}
else
- gc1 = style->bg_gc[state_type];
+ gc1 = &style->bg[state_type];
}
}
else
- gc1 = style->bg_gc[state_type];
+ gc1 = &style->bg[state_type];
- if (!style->bg_pixmap[state_type] || gc1 != style->bg_gc[state_type] ||
+ if (!style->bg_pixmap[state_type] || gc1 != &style->bg[state_type] ||
GDK_IS_PIXMAP (window))
{
+ cairo_t *cr;
+
+ cr = gdk_cairo_create (window);
+ cairo_set_line_width (cr, 1.0);
+
if (area)
- gdk_gc_set_clip_rectangle (gc1, area);
+ {
+ gdk_cairo_rectangle (cr, area);
+ cairo_clip (cr);
+ }
- gdk_draw_rectangle (window, gc1, TRUE,
- x, y, width, height);
+ _cairo_draw_rectangle (cr, gc1, TRUE,
+ x, y, width, height);
if (detail && !strcmp ("tooltip", detail))
- gdk_draw_rectangle (window, style->black_gc, FALSE,
- x, y, width - 1, height - 1);
+ _cairo_draw_rectangle (cr, &style->black, FALSE,
+ x, y, width - 1, height - 1);
- if (area)
- gdk_gc_set_clip_rectangle (gc1, NULL);
+ cairo_destroy (cr);
}
else
gtk_style_apply_default_background (style, window,
- widget && !GTK_WIDGET_NO_WINDOW (widget),
+ widget && gtk_widget_get_has_window (widget),
state_type, area, x, y, width, height);
if (freeme)
- g_object_unref (freeme);
+ gdk_color_free (freeme);
}
static void
exterior_size = MIN (width, height);
if (exterior_size % 2 == 0) /* Ensure odd */
- exterior_size -= -1;
+ exterior_size -= 1;
pad = style->xthickness + MAX (1, (exterior_size - 2 * style->xthickness) / 9);
interior_size = MAX (1, exterior_size - 2 * pad);
exterior_size = MIN (width, height);
if (exterior_size % 2 == 0) /* Ensure odd */
- exterior_size -= -1;
+ exterior_size -= 1;
x -= (1 + exterior_size - width) / 2;
y -= (1 + exterior_size - height) / 2;
{
#define ARROW_SPACE 4
+ cairo_t *cr;
GtkRequisition indicator_size;
GtkBorder indicator_spacing;
gint arrow_height;
-
+
+ cr = gdk_cairo_create (window);
+
+ if (area)
+ {
+ gdk_cairo_rectangle (cr, area);
+ cairo_clip (cr);
+ }
+
option_menu_get_props (widget, &indicator_size, &indicator_spacing);
indicator_size.width += (indicator_size.width % 2) - 1;
if (state_type == GTK_STATE_INSENSITIVE)
{
- draw_arrow (window, &style->white, area,
+ draw_arrow (cr, &style->white,
GTK_ARROW_UP, x + 1, y + 1,
indicator_size.width, arrow_height);
- draw_arrow (window, &style->white, area,
+ draw_arrow (cr, &style->white,
GTK_ARROW_DOWN, x + 1, y + arrow_height + ARROW_SPACE + 1,
indicator_size.width, arrow_height);
}
- draw_arrow (window, &style->fg[state_type], area,
+ draw_arrow (cr, &style->fg[state_type],
GTK_ARROW_UP, x, y,
indicator_size.width, arrow_height);
- draw_arrow (window, &style->fg[state_type], area,
+ draw_arrow (cr, &style->fg[state_type],
GTK_ARROW_DOWN, x, y + arrow_height + ARROW_SPACE,
indicator_size.width, arrow_height);
+
+ cairo_destroy (cr);
}
static void
gint gap_x,
gint gap_width)
{
- GdkGC *gc1 = NULL;
- GdkGC *gc2 = NULL;
- GdkGC *gc3 = NULL;
- GdkGC *gc4 = NULL;
-
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
+ GdkColor *color1 = NULL;
+ GdkColor *color2 = NULL;
+ GdkColor *color3 = NULL;
+ GdkColor *color4 = NULL;
+ cairo_t *cr;
sanitize_size (window, &width, &height);
switch (shadow_type)
{
case GTK_SHADOW_NONE:
+ default:
return;
case GTK_SHADOW_IN:
- gc1 = style->dark_gc[state_type];
- gc2 = style->black_gc;
- gc3 = style->bg_gc[state_type];
- gc4 = style->light_gc[state_type];
+ color1 = &style->dark[state_type];
+ color2 = &style->black;
+ color3 = &style->bg[state_type];
+ color4 = &style->light[state_type];
break;
case GTK_SHADOW_ETCHED_IN:
- gc1 = style->dark_gc[state_type];
- gc2 = style->light_gc[state_type];
- gc3 = style->dark_gc[state_type];
- gc4 = style->light_gc[state_type];
+ color1 = &style->dark[state_type];
+ color2 = &style->light[state_type];
+ color3 = &style->dark[state_type];
+ color4 = &style->light[state_type];
break;
case GTK_SHADOW_OUT:
- gc1 = style->light_gc[state_type];
- gc2 = style->bg_gc[state_type];
- gc3 = style->dark_gc[state_type];
- gc4 = style->black_gc;
+ color1 = &style->light[state_type];
+ color2 = &style->bg[state_type];
+ color3 = &style->dark[state_type];
+ color4 = &style->black;
break;
case GTK_SHADOW_ETCHED_OUT:
- gc1 = style->light_gc[state_type];
- gc2 = style->dark_gc[state_type];
- gc3 = style->light_gc[state_type];
- gc4 = style->dark_gc[state_type];
+ color1 = &style->light[state_type];
+ color2 = &style->dark[state_type];
+ color3 = &style->light[state_type];
+ color4 = &style->dark[state_type];
break;
}
+
+ cr = gdk_cairo_create (window);
if (area)
{
- gdk_gc_set_clip_rectangle (gc1, area);
- gdk_gc_set_clip_rectangle (gc2, area);
- gdk_gc_set_clip_rectangle (gc3, area);
- gdk_gc_set_clip_rectangle (gc4, area);
+ gdk_cairo_rectangle (cr, area);
+ cairo_clip (cr);
}
switch (shadow_type)
switch (gap_side)
{
case GTK_POS_TOP:
- gdk_draw_line (window, gc1,
- x, y, x, y + height - 1);
- gdk_draw_line (window, gc2,
- x + 1, y, x + 1, y + height - 2);
+ _cairo_draw_line (cr, color1,
+ x, y, x, y + height - 1);
+ _cairo_draw_line (cr, color2,
+ x + 1, y, x + 1, y + height - 2);
- gdk_draw_line (window, gc3,
- x + 1, y + height - 2, x + width - 2, y + height - 2);
- gdk_draw_line (window, gc3,
- x + width - 2, y, x + width - 2, y + height - 2);
- gdk_draw_line (window, gc4,
- x, y + height - 1, x + width - 1, y + height - 1);
- gdk_draw_line (window, gc4,
- x + width - 1, y, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, color3,
+ x + 1, y + height - 2, x + width - 2, y + height - 2);
+ _cairo_draw_line (cr, color3,
+ x + width - 2, y, x + width - 2, y + height - 2);
+ _cairo_draw_line (cr, color4,
+ x, y + height - 1, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, color4,
+ x + width - 1, y, x + width - 1, y + height - 1);
if (gap_x > 0)
{
- gdk_draw_line (window, gc1,
- x, y, x + gap_x - 1, y);
- gdk_draw_line (window, gc2,
- x + 1, y + 1, x + gap_x - 1, y + 1);
- gdk_draw_line (window, gc2,
- x + gap_x, y, x + gap_x, y);
+ _cairo_draw_line (cr, color1,
+ x, y, x + gap_x - 1, y);
+ _cairo_draw_line (cr, color2,
+ x + 1, y + 1, x + gap_x - 1, y + 1);
+ _cairo_draw_line (cr, color2,
+ x + gap_x, y, x + gap_x, y);
}
if ((width - (gap_x + gap_width)) > 0)
{
- gdk_draw_line (window, gc1,
- x + gap_x + gap_width, y, x + width - 2, y);
- gdk_draw_line (window, gc2,
- x + gap_x + gap_width, y + 1, x + width - 3, y + 1);
- gdk_draw_line (window, gc2,
- x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
+ _cairo_draw_line (cr, color1,
+ x + gap_x + gap_width, y, x + width - 2, y);
+ _cairo_draw_line (cr, color2,
+ x + gap_x + gap_width, y + 1, x + width - 3, y + 1);
+ _cairo_draw_line (cr, color2,
+ x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
}
break;
case GTK_POS_BOTTOM:
- gdk_draw_line (window, gc1,
- x, y, x + width - 1, y);
- gdk_draw_line (window, gc1,
- x, y, x, y + height - 1);
- gdk_draw_line (window, gc2,
- x + 1, y + 1, x + width - 2, y + 1);
- gdk_draw_line (window, gc2,
- x + 1, y + 1, x + 1, y + height - 1);
+ _cairo_draw_line (cr, color1,
+ x, y, x + width - 1, y);
+ _cairo_draw_line (cr, color1,
+ x, y, x, y + height - 1);
+ _cairo_draw_line (cr, color2,
+ x + 1, y + 1, x + width - 2, y + 1);
+ _cairo_draw_line (cr, color2,
+ x + 1, y + 1, x + 1, y + height - 1);
- gdk_draw_line (window, gc3,
- x + width - 2, y + 1, x + width - 2, y + height - 1);
- gdk_draw_line (window, gc4,
- x + width - 1, y, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, color3,
+ x + width - 2, y + 1, x + width - 2, y + height - 1);
+ _cairo_draw_line (cr, color4,
+ x + width - 1, y, x + width - 1, y + height - 1);
if (gap_x > 0)
{
- gdk_draw_line (window, gc4,
- x, y + height - 1, x + gap_x - 1, y + height - 1);
- gdk_draw_line (window, gc3,
- x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
- gdk_draw_line (window, gc3,
- x + gap_x, y + height - 1, x + gap_x, y + height - 1);
+ _cairo_draw_line (cr, color4,
+ x, y + height - 1, x + gap_x - 1, y + height - 1);
+ _cairo_draw_line (cr, color3,
+ x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
+ _cairo_draw_line (cr, color3,
+ x + gap_x, y + height - 1, x + gap_x, y + height - 1);
}
if ((width - (gap_x + gap_width)) > 0)
{
- gdk_draw_line (window, gc4,
- x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
- gdk_draw_line (window, gc3,
- x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
- gdk_draw_line (window, gc3,
- x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
+ _cairo_draw_line (cr, color4,
+ x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
+ _cairo_draw_line (cr, color3,
+ x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
+ _cairo_draw_line (cr, color3,
+ x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
}
break;
case GTK_POS_LEFT:
- gdk_draw_line (window, gc1,
- x, y, x + width - 1, y);
- gdk_draw_line (window, gc2,
- x, y + 1, x + width - 2, y + 1);
+ _cairo_draw_line (cr, color1,
+ x, y, x + width - 1, y);
+ _cairo_draw_line (cr, color2,
+ x, y + 1, x + width - 2, y + 1);
- gdk_draw_line (window, gc3,
- x, y + height - 2, x + width - 2, y + height - 2);
- gdk_draw_line (window, gc3,
- x + width - 2, y + 1, x + width - 2, y + height - 2);
- gdk_draw_line (window, gc4,
- x, y + height - 1, x + width - 1, y + height - 1);
- gdk_draw_line (window, gc4,
- x + width - 1, y, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, color3,
+ x, y + height - 2, x + width - 2, y + height - 2);
+ _cairo_draw_line (cr, color3,
+ x + width - 2, y + 1, x + width - 2, y + height - 2);
+ _cairo_draw_line (cr, color4,
+ x, y + height - 1, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, color4,
+ x + width - 1, y, x + width - 1, y + height - 1);
if (gap_x > 0)
{
- gdk_draw_line (window, gc1,
- x, y, x, y + gap_x - 1);
- gdk_draw_line (window, gc2,
- x + 1, y + 1, x + 1, y + gap_x - 1);
- gdk_draw_line (window, gc2,
- x, y + gap_x, x, y + gap_x);
+ _cairo_draw_line (cr, color1,
+ x, y, x, y + gap_x - 1);
+ _cairo_draw_line (cr, color2,
+ x + 1, y + 1, x + 1, y + gap_x - 1);
+ _cairo_draw_line (cr, color2,
+ x, y + gap_x, x, y + gap_x);
}
if ((width - (gap_x + gap_width)) > 0)
{
- gdk_draw_line (window, gc1,
- x, y + gap_x + gap_width, x, y + height - 2);
- gdk_draw_line (window, gc2,
- x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
- gdk_draw_line (window, gc2,
- x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
+ _cairo_draw_line (cr, color1,
+ x, y + gap_x + gap_width, x, y + height - 2);
+ _cairo_draw_line (cr, color2,
+ x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
+ _cairo_draw_line (cr, color2,
+ x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
}
break;
case GTK_POS_RIGHT:
- gdk_draw_line (window, gc1,
- x, y, x + width - 1, y);
- gdk_draw_line (window, gc1,
- x, y, x, y + height - 1);
- gdk_draw_line (window, gc2,
- x + 1, y + 1, x + width - 1, y + 1);
- gdk_draw_line (window, gc2,
- x + 1, y + 1, x + 1, y + height - 2);
+ _cairo_draw_line (cr, color1,
+ x, y, x + width - 1, y);
+ _cairo_draw_line (cr, color1,
+ x, y, x, y + height - 1);
+ _cairo_draw_line (cr, color2,
+ x + 1, y + 1, x + width - 1, y + 1);
+ _cairo_draw_line (cr, color2,
+ x + 1, y + 1, x + 1, y + height - 2);
- gdk_draw_line (window, gc3,
- x + 1, y + height - 2, x + width - 1, y + height - 2);
- gdk_draw_line (window, gc4,
- x, y + height - 1, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, color3,
+ x + 1, y + height - 2, x + width - 1, y + height - 2);
+ _cairo_draw_line (cr, color4,
+ x, y + height - 1, x + width - 1, y + height - 1);
if (gap_x > 0)
{
- gdk_draw_line (window, gc4,
- x + width - 1, y, x + width - 1, y + gap_x - 1);
- gdk_draw_line (window, gc3,
- x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
- gdk_draw_line (window, gc3,
- x + width - 1, y + gap_x, x + width - 1, y + gap_x);
+ _cairo_draw_line (cr, color4,
+ x + width - 1, y, x + width - 1, y + gap_x - 1);
+ _cairo_draw_line (cr, color3,
+ x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
+ _cairo_draw_line (cr, color3,
+ x + width - 1, y + gap_x, x + width - 1, y + gap_x);
}
if ((width - (gap_x + gap_width)) > 0)
{
- gdk_draw_line (window, gc4,
- x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
- gdk_draw_line (window, gc3,
- x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
- gdk_draw_line (window, gc3,
- x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
+ _cairo_draw_line (cr, color4,
+ x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
+ _cairo_draw_line (cr, color3,
+ x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
+ _cairo_draw_line (cr, color3,
+ x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
}
break;
}
}
- if (area)
- {
- gdk_gc_set_clip_rectangle (gc1, NULL);
- gdk_gc_set_clip_rectangle (gc2, NULL);
- gdk_gc_set_clip_rectangle (gc3, NULL);
- gdk_gc_set_clip_rectangle (gc4, NULL);
- }
+ cairo_destroy (cr);
}
static void
gint gap_x,
gint gap_width)
{
- GdkGC *gc1 = NULL;
- GdkGC *gc2 = NULL;
- GdkGC *gc3 = NULL;
- GdkGC *gc4 = NULL;
-
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
+ cairo_t *cr;
+ GdkColor color1;
+ GdkColor color2;
+ GdkColor color3;
+ GdkColor color4;
+ sanitize_size (window, &width, &height);
+
gtk_style_apply_default_background (style, window,
- widget && !GTK_WIDGET_NO_WINDOW (widget),
+ widget && gtk_widget_get_has_window (widget),
state_type, area, x, y, width, height);
-
- sanitize_size (window, &width, &height);
-
+
+ cr = gdk_cairo_create (window);
+ if (area)
+ {
+ gdk_cairo_rectangle (cr, area);
+ cairo_clip (cr);
+ }
+
switch (shadow_type)
{
case GTK_SHADOW_NONE:
+ cairo_destroy (cr);
return;
case GTK_SHADOW_IN:
- gc1 = style->dark_gc[state_type];
- gc2 = style->black_gc;
- gc3 = style->bg_gc[state_type];
- gc4 = style->light_gc[state_type];
+ color1 = style->dark[state_type];
+ color2 = style->black;
+ color3 = style->bg[state_type];
+ color4 = style->light[state_type];
break;
case GTK_SHADOW_ETCHED_IN:
- gc1 = style->dark_gc[state_type];
- gc2 = style->light_gc[state_type];
- gc3 = style->dark_gc[state_type];
- gc4 = style->light_gc[state_type];
+ color1 = style->dark[state_type];
+ color2 = style->light[state_type];
+ color3 = style->dark[state_type];
+ color4 = style->light[state_type];
break;
case GTK_SHADOW_OUT:
- gc1 = style->light_gc[state_type];
- gc2 = style->bg_gc[state_type];
- gc3 = style->dark_gc[state_type];
- gc4 = style->black_gc;
+ color1 = style->light[state_type];
+ color2 = style->bg[state_type];
+ color3 = style->dark[state_type];
+ color4 = style->black;
break;
case GTK_SHADOW_ETCHED_OUT:
- gc1 = style->light_gc[state_type];
- gc2 = style->dark_gc[state_type];
- gc3 = style->light_gc[state_type];
- gc4 = style->dark_gc[state_type];
+ color1 = style->light[state_type];
+ color2 = style->dark[state_type];
+ color3 = style->light[state_type];
+ color4 = style->dark[state_type];
break;
}
-
- if (area)
- {
- gdk_gc_set_clip_rectangle (gc1, area);
- gdk_gc_set_clip_rectangle (gc2, area);
- gdk_gc_set_clip_rectangle (gc3, area);
- gdk_gc_set_clip_rectangle (gc4, area);
- }
+ cairo_set_line_width (cr, 1.0);
+
switch (shadow_type)
{
case GTK_SHADOW_NONE:
switch (gap_side)
{
case GTK_POS_TOP:
- gdk_draw_line (window, gc1,
- x, y, x, y + height - 1);
- gdk_draw_line (window, gc2,
- x + 1, y, x + 1, y + height - 2);
+ _cairo_draw_line (cr, &color1,
+ x, y, x, y + height - 1);
+ _cairo_draw_line (cr, &color2,
+ x + 1, y, x + 1, y + height - 2);
- gdk_draw_line (window, gc3,
- x + 1, y + height - 2, x + width - 2, y + height - 2);
- gdk_draw_line (window, gc3,
- x + width - 2, y, x + width - 2, y + height - 2);
- gdk_draw_line (window, gc4,
- x, y + height - 1, x + width - 1, y + height - 1);
- gdk_draw_line (window, gc4,
- x + width - 1, y, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, &color3,
+ x + 1, y + height - 2, x + width - 2, y + height - 2);
+ _cairo_draw_line (cr, &color3,
+ x + width - 2, y, x + width - 2, y + height - 2);
+ _cairo_draw_line (cr, &color4,
+ x, y + height - 1, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, &color4,
+ x + width - 1, y, x + width - 1, y + height - 1);
if (gap_x > 0)
{
- gdk_draw_line (window, gc1,
- x, y, x + gap_x - 1, y);
- gdk_draw_line (window, gc2,
- x + 1, y + 1, x + gap_x - 1, y + 1);
- gdk_draw_line (window, gc2,
- x + gap_x, y, x + gap_x, y);
+ _cairo_draw_line (cr, &color1,
+ x, y, x + gap_x - 1, y);
+ _cairo_draw_line (cr, &color2,
+ x + 1, y + 1, x + gap_x - 1, y + 1);
+ _cairo_draw_line (cr, &color2,
+ x + gap_x, y, x + gap_x, y);
}
if ((width - (gap_x + gap_width)) > 0)
{
- gdk_draw_line (window, gc1,
- x + gap_x + gap_width, y, x + width - 2, y);
- gdk_draw_line (window, gc2,
- x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
- gdk_draw_line (window, gc2,
- x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
+ _cairo_draw_line (cr, &color1,
+ x + gap_x + gap_width, y, x + width - 2, y);
+ _cairo_draw_line (cr, &color2,
+ x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
+ _cairo_draw_line (cr, &color2,
+ x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
}
break;
case GTK_POS_BOTTOM:
- gdk_draw_line (window, gc1,
- x, y, x + width - 1, y);
- gdk_draw_line (window, gc1,
- x, y, x, y + height - 1);
- gdk_draw_line (window, gc2,
- x + 1, y + 1, x + width - 2, y + 1);
- gdk_draw_line (window, gc2,
- x + 1, y + 1, x + 1, y + height - 1);
+ _cairo_draw_line (cr, &color1,
+ x, y, x + width - 1, y);
+ _cairo_draw_line (cr, &color1,
+ x, y, x, y + height - 1);
+ _cairo_draw_line (cr, &color2,
+ x + 1, y + 1, x + width - 2, y + 1);
+ _cairo_draw_line (cr, &color2,
+ x + 1, y + 1, x + 1, y + height - 1);
- gdk_draw_line (window, gc3,
- x + width - 2, y + 1, x + width - 2, y + height - 1);
- gdk_draw_line (window, gc4,
- x + width - 1, y, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, &color3,
+ x + width - 2, y + 1, x + width - 2, y + height - 1);
+ _cairo_draw_line (cr, &color4,
+ x + width - 1, y, x + width - 1, y + height - 1);
if (gap_x > 0)
{
- gdk_draw_line (window, gc4,
- x, y + height - 1, x + gap_x - 1, y + height - 1);
- gdk_draw_line (window, gc3,
- x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
- gdk_draw_line (window, gc3,
- x + gap_x, y + height - 1, x + gap_x, y + height - 1);
+ _cairo_draw_line (cr, &color4,
+ x, y + height - 1, x + gap_x - 1, y + height - 1);
+ _cairo_draw_line (cr, &color3,
+ x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
+ _cairo_draw_line (cr, &color3,
+ x + gap_x, y + height - 1, x + gap_x, y + height - 1);
}
if ((width - (gap_x + gap_width)) > 0)
{
- gdk_draw_line (window, gc4,
- x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
- gdk_draw_line (window, gc3,
- x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
- gdk_draw_line (window, gc3,
- x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
+ _cairo_draw_line (cr, &color4,
+ x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
+ _cairo_draw_line (cr, &color3,
+ x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
+ _cairo_draw_line (cr, &color3,
+ x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
}
break;
case GTK_POS_LEFT:
- gdk_draw_line (window, gc1,
- x, y, x + width - 1, y);
- gdk_draw_line (window, gc2,
- x, y + 1, x + width - 2, y + 1);
+ _cairo_draw_line (cr, &color1,
+ x, y, x + width - 1, y);
+ _cairo_draw_line (cr, &color2,
+ x, y + 1, x + width - 2, y + 1);
- gdk_draw_line (window, gc3,
- x, y + height - 2, x + width - 2, y + height - 2);
- gdk_draw_line (window, gc3,
- x + width - 2, y + 1, x + width - 2, y + height - 2);
- gdk_draw_line (window, gc4,
- x, y + height - 1, x + width - 1, y + height - 1);
- gdk_draw_line (window, gc4,
- x + width - 1, y, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, &color3,
+ x, y + height - 2, x + width - 2, y + height - 2);
+ _cairo_draw_line (cr, &color3,
+ x + width - 2, y + 1, x + width - 2, y + height - 2);
+ _cairo_draw_line (cr, &color4,
+ x, y + height - 1, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, &color4,
+ x + width - 1, y, x + width - 1, y + height - 1);
if (gap_x > 0)
{
- gdk_draw_line (window, gc1,
- x, y, x, y + gap_x - 1);
- gdk_draw_line (window, gc2,
- x + 1, y + 1, x + 1, y + gap_x - 1);
- gdk_draw_line (window, gc2,
- x, y + gap_x, x, y + gap_x);
+ _cairo_draw_line (cr, &color1,
+ x, y, x, y + gap_x - 1);
+ _cairo_draw_line (cr, &color2,
+ x + 1, y + 1, x + 1, y + gap_x - 1);
+ _cairo_draw_line (cr, &color2,
+ x, y + gap_x, x, y + gap_x);
}
- if ((width - (gap_x + gap_width)) > 0)
+ if ((height - (gap_x + gap_width)) > 0)
{
- gdk_draw_line (window, gc1,
- x, y + gap_x + gap_width, x, y + height - 2);
- gdk_draw_line (window, gc2,
- x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
- gdk_draw_line (window, gc2,
- x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
+ _cairo_draw_line (cr, &color1,
+ x, y + gap_x + gap_width, x, y + height - 2);
+ _cairo_draw_line (cr, &color2,
+ x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
+ _cairo_draw_line (cr, &color2,
+ x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
}
break;
case GTK_POS_RIGHT:
- gdk_draw_line (window, gc1,
- x, y, x + width - 1, y);
- gdk_draw_line (window, gc1,
- x, y, x, y + height - 1);
- gdk_draw_line (window, gc2,
- x + 1, y + 1, x + width - 1, y + 1);
- gdk_draw_line (window, gc2,
- x + 1, y + 1, x + 1, y + height - 2);
+ _cairo_draw_line (cr, &color1,
+ x, y, x + width - 1, y);
+ _cairo_draw_line (cr, &color1,
+ x, y, x, y + height - 1);
+ _cairo_draw_line (cr, &color2,
+ x + 1, y + 1, x + width - 1, y + 1);
+ _cairo_draw_line (cr, &color2,
+ x + 1, y + 1, x + 1, y + height - 2);
- gdk_draw_line (window, gc3,
- x + 1, y + height - 2, x + width - 1, y + height - 2);
- gdk_draw_line (window, gc4,
- x, y + height - 1, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, &color3,
+ x + 1, y + height - 2, x + width - 1, y + height - 2);
+ _cairo_draw_line (cr, &color4,
+ x, y + height - 1, x + width - 1, y + height - 1);
if (gap_x > 0)
{
- gdk_draw_line (window, gc4,
- x + width - 1, y, x + width - 1, y + gap_x - 1);
- gdk_draw_line (window, gc3,
- x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
- gdk_draw_line (window, gc3,
- x + width - 1, y + gap_x, x + width - 1, y + gap_x);
+ _cairo_draw_line (cr, &color4,
+ x + width - 1, y, x + width - 1, y + gap_x - 1);
+ _cairo_draw_line (cr, &color3,
+ x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
+ _cairo_draw_line (cr, &color3,
+ x + width - 1, y + gap_x, x + width - 1, y + gap_x);
}
- if ((width - (gap_x + gap_width)) > 0)
+ if ((height - (gap_x + gap_width)) > 0)
{
- gdk_draw_line (window, gc4,
- x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
- gdk_draw_line (window, gc3,
- x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
- gdk_draw_line (window, gc3,
- x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
+ _cairo_draw_line (cr, &color4,
+ x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
+ _cairo_draw_line (cr, &color3,
+ x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
+ _cairo_draw_line (cr, &color3,
+ x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
}
break;
}
}
- if (area)
- {
- gdk_gc_set_clip_rectangle (gc1, NULL);
- gdk_gc_set_clip_rectangle (gc2, NULL);
- gdk_gc_set_clip_rectangle (gc3, NULL);
- gdk_gc_set_clip_rectangle (gc4, NULL);
- }
+
+ cairo_destroy (cr);
}
static void
gint height,
GtkPositionType gap_side)
{
- GdkGC *gc1 = NULL;
- GdkGC *gc2 = NULL;
- GdkGC *gc3 = NULL;
- GdkGC *gc4 = NULL;
-
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
- gtk_style_apply_default_background (style, window,
- widget && !GTK_WIDGET_NO_WINDOW (widget),
- GTK_STATE_NORMAL, area, x, y, width, height);
+ cairo_t *cr;
+ GdkColor color1;
+ GdkColor color2;
+ GdkColor color3;
+ GdkColor color4;
sanitize_size (window, &width, &height);
+
+ switch (gap_side)
+ {
+ case GTK_POS_TOP:
+ gtk_style_apply_default_background (style, window,
+ widget && gtk_widget_get_has_window (widget),
+ state_type, area,
+ x + 1,
+ y,
+ width - 2,
+ height - 1);
+ break;
+ case GTK_POS_BOTTOM:
+ gtk_style_apply_default_background (style, window,
+ widget && gtk_widget_get_has_window (widget),
+ state_type, area,
+ x + 1,
+ y + 1,
+ width - 2,
+ height - 1);
+ break;
+ case GTK_POS_LEFT:
+ gtk_style_apply_default_background (style, window,
+ widget && gtk_widget_get_has_window (widget),
+ state_type, area,
+ x,
+ y + 1,
+ width - 1,
+ height - 2);
+ break;
+ case GTK_POS_RIGHT:
+ gtk_style_apply_default_background (style, window,
+ widget && gtk_widget_get_has_window (widget),
+ state_type, area,
+ x + 1,
+ y + 1,
+ width - 1,
+ height - 2);
+ break;
+ }
+
+
+ cr = gdk_cairo_create (window);
+ if (area)
+ {
+ gdk_cairo_rectangle (cr, area);
+ cairo_clip (cr);
+ }
switch (shadow_type)
{
case GTK_SHADOW_NONE:
+ cairo_destroy (cr);
return;
case GTK_SHADOW_IN:
- gc1 = style->dark_gc[state_type];
- gc2 = style->black_gc;
- gc3 = style->bg_gc[state_type];
- gc4 = style->light_gc[state_type];
+ color1 = style->dark[state_type];
+ color2 = style->black;
+ color3 = style->bg[state_type];
+ color4 = style->light[state_type];
break;
case GTK_SHADOW_ETCHED_IN:
- gc1 = style->dark_gc[state_type];
- gc2 = style->light_gc[state_type];
- gc3 = style->dark_gc[state_type];
- gc4 = style->light_gc[state_type];
+ color1 = style->dark[state_type];
+ color2 = style->light[state_type];
+ color3 = style->dark[state_type];
+ color4 = style->light[state_type];
break;
case GTK_SHADOW_OUT:
- gc1 = style->light_gc[state_type];
- gc2 = style->bg_gc[state_type];
- gc3 = style->dark_gc[state_type];
- gc4 = style->black_gc;
+ color1 = style->light[state_type];
+ color2 = style->bg[state_type];
+ color3 = style->dark[state_type];
+ color4 = style->black;
break;
case GTK_SHADOW_ETCHED_OUT:
- gc1 = style->light_gc[state_type];
- gc2 = style->dark_gc[state_type];
- gc3 = style->light_gc[state_type];
- gc4 = style->dark_gc[state_type];
+ color1 = style->light[state_type];
+ color2 = style->dark[state_type];
+ color3 = style->light[state_type];
+ color4 = style->dark[state_type];
break;
}
- if (area)
- {
- gdk_gc_set_clip_rectangle (gc1, area);
- gdk_gc_set_clip_rectangle (gc2, area);
- gdk_gc_set_clip_rectangle (gc3, area);
- gdk_gc_set_clip_rectangle (gc4, area);
- }
+ cairo_set_line_width (cr, 1.0);
switch (shadow_type)
{
switch (gap_side)
{
case GTK_POS_TOP:
- gtk_style_apply_default_background (style, window,
- widget && !GTK_WIDGET_NO_WINDOW (widget),
- state_type, area,
- x + style->xthickness,
- y,
- width - (2 * style->xthickness),
- height - (style->ythickness));
- gdk_draw_line (window, gc1,
- x, y, x, y + height - 2);
- gdk_draw_line (window, gc2,
- x + 1, y, x + 1, y + height - 2);
+ _cairo_draw_line (cr, &color1,
+ x, y, x, y + height - 2);
+ _cairo_draw_line (cr, &color2,
+ x + 1, y, x + 1, y + height - 2);
- gdk_draw_line (window, gc3,
- x + 2, y + height - 2, x + width - 2, y + height - 2);
- gdk_draw_line (window, gc3,
- x + width - 2, y, x + width - 2, y + height - 2);
- gdk_draw_line (window, gc4,
- x + 1, y + height - 1, x + width - 2, y + height - 1);
- gdk_draw_line (window, gc4,
- x + width - 1, y, x + width - 1, y + height - 2);
+ _cairo_draw_line (cr, &color3,
+ x + 2, y + height - 2, x + width - 2, y + height - 2);
+ _cairo_draw_line (cr, &color3,
+ x + width - 2, y, x + width - 2, y + height - 2);
+ _cairo_draw_line (cr, &color4,
+ x + 1, y + height - 1, x + width - 2, y + height - 1);
+ _cairo_draw_line (cr, &color4,
+ x + width - 1, y, x + width - 1, y + height - 2);
break;
case GTK_POS_BOTTOM:
- gtk_style_apply_default_background (style, window,
- widget && !GTK_WIDGET_NO_WINDOW (widget),
- state_type, area,
- x + style->xthickness,
- y + style->ythickness,
- width - (2 * style->xthickness),
- height - (style->ythickness));
- gdk_draw_line (window, gc1,
- x + 1, y, x + width - 2, y);
- gdk_draw_line (window, gc1,
- x, y + 1, x, y + height - 1);
- gdk_draw_line (window, gc2,
- x + 1, y + 1, x + width - 2, y + 1);
- gdk_draw_line (window, gc2,
- x + 1, y + 1, x + 1, y + height - 1);
+ _cairo_draw_line (cr, &color1,
+ x + 1, y, x + width - 2, y);
+ _cairo_draw_line (cr, &color1,
+ x, y + 1, x, y + height - 1);
+ _cairo_draw_line (cr, &color2,
+ x + 1, y + 1, x + width - 2, y + 1);
+ _cairo_draw_line (cr, &color2,
+ x + 1, y + 1, x + 1, y + height - 1);
- gdk_draw_line (window, gc3,
- x + width - 2, y + 2, x + width - 2, y + height - 1);
- gdk_draw_line (window, gc4,
- x + width - 1, y + 1, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, &color3,
+ x + width - 2, y + 2, x + width - 2, y + height - 1);
+ _cairo_draw_line (cr, &color4,
+ x + width - 1, y + 1, x + width - 1, y + height - 1);
break;
case GTK_POS_LEFT:
- gtk_style_apply_default_background (style, window,
- widget && !GTK_WIDGET_NO_WINDOW (widget),
- state_type, area,
- x,
- y + style->ythickness,
- width - (style->xthickness),
- height - (2 * style->ythickness));
- gdk_draw_line (window, gc1,
- x, y, x + width - 2, y);
- gdk_draw_line (window, gc2,
- x + 1, y + 1, x + width - 2, y + 1);
+ _cairo_draw_line (cr, &color1,
+ x, y, x + width - 2, y);
+ _cairo_draw_line (cr, &color2,
+ x + 1, y + 1, x + width - 2, y + 1);
- gdk_draw_line (window, gc3,
- x, y + height - 2, x + width - 2, y + height - 2);
- gdk_draw_line (window, gc3,
- x + width - 2, y + 2, x + width - 2, y + height - 2);
- gdk_draw_line (window, gc4,
- x, y + height - 1, x + width - 2, y + height - 1);
- gdk_draw_line (window, gc4,
- x + width - 1, y + 1, x + width - 1, y + height - 2);
+ _cairo_draw_line (cr, &color3,
+ x, y + height - 2, x + width - 2, y + height - 2);
+ _cairo_draw_line (cr, &color3,
+ x + width - 2, y + 2, x + width - 2, y + height - 2);
+ _cairo_draw_line (cr, &color4,
+ x, y + height - 1, x + width - 2, y + height - 1);
+ _cairo_draw_line (cr, &color4,
+ x + width - 1, y + 1, x + width - 1, y + height - 2);
break;
case GTK_POS_RIGHT:
- gtk_style_apply_default_background (style, window,
- widget && !GTK_WIDGET_NO_WINDOW (widget),
- state_type, area,
- x + style->xthickness,
- y + style->ythickness,
- width - (style->xthickness),
- height - (2 * style->ythickness));
- gdk_draw_line (window, gc1,
- x + 1, y, x + width - 1, y);
- gdk_draw_line (window, gc1,
- x, y + 1, x, y + height - 2);
- gdk_draw_line (window, gc2,
- x + 1, y + 1, x + width - 1, y + 1);
- gdk_draw_line (window, gc2,
- x + 1, y + 1, x + 1, y + height - 2);
+ _cairo_draw_line (cr, &color1,
+ x + 1, y, x + width - 1, y);
+ _cairo_draw_line (cr, &color1,
+ x, y + 1, x, y + height - 2);
+ _cairo_draw_line (cr, &color2,
+ x + 1, y + 1, x + width - 1, y + 1);
+ _cairo_draw_line (cr, &color2,
+ x + 1, y + 1, x + 1, y + height - 2);
- gdk_draw_line (window, gc3,
- x + 2, y + height - 2, x + width - 1, y + height - 2);
- gdk_draw_line (window, gc4,
- x + 1, y + height - 1, x + width - 1, y + height - 1);
+ _cairo_draw_line (cr, &color3,
+ x + 2, y + height - 2, x + width - 1, y + height - 2);
+ _cairo_draw_line (cr, &color4,
+ x + 1, y + height - 1, x + width - 1, y + height - 1);
break;
}
}
- if (area)
- {
- gdk_gc_set_clip_rectangle (gc1, NULL);
- gdk_gc_set_clip_rectangle (gc2, NULL);
- gdk_gc_set_clip_rectangle (gc3, NULL);
- gdk_gc_set_clip_rectangle (gc4, NULL);
- }
+ cairo_destroy (cr);
}
static void
cairo_t *cr;
gboolean free_dash_list = FALSE;
gint line_width = 1;
- gint8 *dash_list = "\1\1";
+ gint8 *dash_list = (gint8 *) "\1\1";
if (widget)
{
{
if (free_dash_list)
g_free (dash_list);
-
- dash_list = "\4\4";
+
+ dash_list = (gint8 *) "\4\4";
free_dash_list = FALSE;
}
sanitize_size (window, &width, &height);
cr = gdk_cairo_create (window);
-
+
if (detail && !strcmp (detail, "colorwheel_light"))
cairo_set_source_rgb (cr, 0., 0., 0.);
else if (detail && !strcmp (detail, "colorwheel_dark"))
if (dash_list[0])
{
- gint n_dashes = strlen (dash_list);
+ gint n_dashes = strlen ((const gchar *) dash_list);
gdouble *dashes = g_new (gdouble, n_dashes);
gdouble total_length = 0;
gdouble dash_offset;
gint height,
GtkOrientation orientation)
{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
sanitize_size (window, &width, &height);
gtk_paint_box (style, window, state_type, shadow_type,
}
static void
-draw_dot (GdkWindow *window,
- GdkGC *light_gc,
- GdkGC *dark_gc,
- gint x,
- gint y,
- gushort size)
+draw_dot (cairo_t *cr,
+ GdkColor *light,
+ GdkColor *dark,
+ gint x,
+ gint y,
+ gushort size)
{
-
size = CLAMP (size, 2, 3);
if (size == 2)
{
- gdk_draw_point (window, light_gc, x, y);
- gdk_draw_point (window, light_gc, x+1, y+1);
+ _cairo_draw_point (cr, light, x, y);
+ _cairo_draw_point (cr, light, x+1, y+1);
}
else if (size == 3)
{
- gdk_draw_point (window, light_gc, x, y);
- gdk_draw_point (window, light_gc, x+1, y);
- gdk_draw_point (window, light_gc, x, y+1);
- gdk_draw_point (window, dark_gc, x+1, y+2);
- gdk_draw_point (window, dark_gc, x+2, y+1);
- gdk_draw_point (window, dark_gc, x+2, y+2);
+ _cairo_draw_point (cr, light, x, y);
+ _cairo_draw_point (cr, light, x+1, y);
+ _cairo_draw_point (cr, light, x, y+1);
+ _cairo_draw_point (cr, dark, x+1, y+2);
+ _cairo_draw_point (cr, dark, x+2, y+1);
+ _cairo_draw_point (cr, dark, x+2, y+2);
}
}
{
gint xx, yy;
gint xthick, ythick;
- GdkGC *light_gc, *dark_gc;
- GdkGC *free_me = NULL;
- GdkRectangle rect;
- GdkRectangle dest;
- gint intersect;
-
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
+ GdkColor light, dark;
+ cairo_t *cr;
sanitize_size (window, &width, &height);
gtk_paint_box (style, window, state_type, shadow_type, area, widget,
detail, x, y, width, height);
+ cr = gdk_cairo_create (window);
+ if (area)
+ {
+ gdk_cairo_rectangle (cr, area);
+ cairo_clip (cr);
+ }
if (detail && !strcmp (detail, "paned"))
{
xthick = 0;
ythick = 0;
- if (state_type == GTK_STATE_SELECTED && widget && !GTK_WIDGET_HAS_FOCUS (widget))
- {
- GdkColor unfocused_light;
-
- _gtk_style_shade (&style->base[GTK_STATE_ACTIVE], &unfocused_light,
+ if (state_type == GTK_STATE_SELECTED && widget && !gtk_widget_has_focus (widget))
+ _gtk_style_shade (&style->base[GTK_STATE_ACTIVE], &light,
LIGHTNESS_MULT);
-
- light_gc = free_me = gdk_gc_new (window);
- gdk_gc_set_rgb_fg_color (light_gc, &unfocused_light);
- }
else
- light_gc = style->light_gc[state_type];
+ light = style->light[state_type];
- dark_gc = style->black_gc;
+ dark = style->black;
}
else
{
xthick = style->xthickness;
ythick = style->ythickness;
- light_gc = style->light_gc[state_type];
- dark_gc = style->dark_gc[state_type];
+ light = style->light[state_type];
+ dark = style->dark[state_type];
}
- rect.x = x + xthick;
- rect.y = y + ythick;
- rect.width = width - (xthick * 2);
- rect.height = height - (ythick * 2);
-
- if (area)
- intersect = gdk_rectangle_intersect (area, &rect, &dest);
- else
- {
- intersect = TRUE;
- dest = rect;
- }
-
- if (!intersect)
- goto out;
-
- gdk_gc_set_clip_rectangle (light_gc, &dest);
- gdk_gc_set_clip_rectangle (dark_gc, &dest);
+ cairo_rectangle(cr, x + xthick, y + ythick,
+ width - (xthick * 2), height - (ythick * 2));
+ cairo_clip (cr);
if (detail && !strcmp (detail, "paned"))
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
for (xx = x + width/2 - 15; xx <= x + width/2 + 15; xx += 5)
- draw_dot (window, light_gc, dark_gc, xx, y + height/2 - 1, 3);
+ draw_dot (cr, &light, &dark, xx, y + height/2 - 1, 3);
else
for (yy = y + height/2 - 15; yy <= y + height/2 + 15; yy += 5)
- draw_dot (window, light_gc, dark_gc, x + width/2 - 1, yy, 3);
+ draw_dot (cr, &light, &dark, x + width/2 - 1, yy, 3);
}
else
{
for (yy = y + ythick; yy < (y + height - ythick); yy += 3)
for (xx = x + xthick; xx < (x + width - xthick); xx += 6)
{
- draw_dot (window, light_gc, dark_gc, xx, yy, 2);
- draw_dot (window, light_gc, dark_gc, xx + 3, yy + 1, 2);
+ draw_dot (cr, &light, &dark, xx, yy, 2);
+ draw_dot (cr, &light, &dark, xx + 3, yy + 1, 2);
}
}
- gdk_gc_set_clip_rectangle (light_gc, NULL);
- gdk_gc_set_clip_rectangle (dark_gc, NULL);
-
- out:
- if (free_me)
- g_object_unref (free_me);
+ cairo_destroy (cr);
}
static void
cairo_destroy (cr);
}
-typedef struct _ByteRange ByteRange;
-
-struct _ByteRange
-{
- guint start;
- guint end;
-};
-
-static ByteRange*
-range_new (guint start,
- guint end)
-{
- ByteRange *br = g_new (ByteRange, 1);
-
- br->start = start;
- br->end = end;
-
- return br;
-}
-
-static PangoLayout*
-get_insensitive_layout (GdkDrawable *drawable,
- PangoLayout *layout)
-{
- GSList *embossed_ranges = NULL;
- GSList *stippled_ranges = NULL;
- PangoLayoutIter *iter;
- GSList *tmp_list = NULL;
- PangoLayout *new_layout;
- PangoAttrList *attrs;
- GdkBitmap *stipple = NULL;
-
- iter = pango_layout_get_iter (layout);
-
- do
- {
- PangoLayoutRun *run;
- PangoAttribute *attr;
- gboolean need_stipple = FALSE;
- ByteRange *br;
-
- run = pango_layout_iter_get_run (iter);
-
- if (run)
- {
- tmp_list = run->item->analysis.extra_attrs;
-
- while (tmp_list != NULL)
- {
- attr = tmp_list->data;
- switch (attr->klass->type)
- {
- case PANGO_ATTR_FOREGROUND:
- case PANGO_ATTR_BACKGROUND:
- need_stipple = TRUE;
- break;
-
- default:
- break;
- }
-
- if (need_stipple)
- break;
-
- tmp_list = g_slist_next (tmp_list);
- }
-
- br = range_new (run->item->offset, run->item->offset + run->item->length);
-
- if (need_stipple)
- stippled_ranges = g_slist_prepend (stippled_ranges, br);
- else
- embossed_ranges = g_slist_prepend (embossed_ranges, br);
- }
- }
- while (pango_layout_iter_next_run (iter));
-
- pango_layout_iter_free (iter);
-
- new_layout = pango_layout_copy (layout);
-
- attrs = pango_layout_get_attributes (new_layout);
-
- if (attrs == NULL)
- {
- /* Create attr list if there wasn't one */
- attrs = pango_attr_list_new ();
- pango_layout_set_attributes (new_layout, attrs);
- pango_attr_list_unref (attrs);
- }
-
- tmp_list = embossed_ranges;
- while (tmp_list != NULL)
- {
- PangoAttribute *attr;
- ByteRange *br = tmp_list->data;
-
- attr = gdk_pango_attr_embossed_new (TRUE);
-
- attr->start_index = br->start;
- attr->end_index = br->end;
-
- pango_attr_list_change (attrs, attr);
-
- g_free (br);
-
- tmp_list = g_slist_next (tmp_list);
- }
-
- g_slist_free (embossed_ranges);
-
- tmp_list = stippled_ranges;
- while (tmp_list != NULL)
- {
- PangoAttribute *attr;
- ByteRange *br = tmp_list->data;
-
- if (stipple == NULL)
- {
-#define gray50_width 2
-#define gray50_height 2
- static const char gray50_bits[] = {
- 0x02, 0x01
- };
-
- stipple = gdk_bitmap_create_from_data (drawable,
- gray50_bits, gray50_width,
- gray50_height);
- }
-
- attr = gdk_pango_attr_stipple_new (stipple);
-
- attr->start_index = br->start;
- attr->end_index = br->end;
-
- pango_attr_list_change (attrs, attr);
-
- g_free (br);
-
- tmp_list = g_slist_next (tmp_list);
- }
-
- g_slist_free (stippled_ranges);
-
- if (stipple)
- g_object_unref (stipple);
-
- return new_layout;
-}
-
static void
gtk_default_draw_layout (GtkStyle *style,
GdkWindow *window,
gint y,
PangoLayout *layout)
{
- GdkGC *gc;
-
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
+ cairo_t *cr;
+ GdkColor *gc;
+ const PangoMatrix *matrix;
- gc = use_text ? style->text_gc[state_type] : style->fg_gc[state_type];
-
- if (area)
- gdk_gc_set_clip_rectangle (gc, area);
+ cr = gdk_cairo_create (window);
- if (state_type == GTK_STATE_INSENSITIVE)
+ if (area)
{
- PangoLayout *ins;
+ gdk_cairo_rectangle (cr, area);
+ cairo_clip (cr);
+ }
- ins = get_insensitive_layout (window, layout);
+ matrix = pango_context_get_matrix (pango_layout_get_context (layout));
+ if (matrix)
+ {
+ cairo_matrix_t cairo_matrix;
+ PangoMatrix tmp_matrix;
+ PangoRectangle rect;
- gdk_draw_layout (window, gc, x, y, ins);
+ cairo_matrix_init (&cairo_matrix,
+ matrix->xx, matrix->yx,
+ matrix->xy, matrix->yy,
+ matrix->x0, matrix->y0);
+
+ pango_layout_get_extents (layout, NULL, &rect);
+ pango_matrix_transform_rectangle (matrix, &rect);
+ pango_extents_to_pixels (&rect, NULL);
+
+ tmp_matrix = *matrix;
+ cairo_matrix.x0 += x - rect.x;
+ cairo_matrix.y0 += y - rect.y;
- g_object_unref (ins);
+ cairo_set_matrix (cr, &cairo_matrix);
}
else
+ cairo_translate (cr, x, y);
+
+ if (state_type == GTK_STATE_INSENSITIVE)
{
- gdk_draw_layout (window, gc, x, y, layout);
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &style->white);
+ cairo_move_to (cr, 1, 1);
+ _gtk_pango_fill_layout (cr, layout);
+ cairo_restore (cr);
}
- if (area)
- gdk_gc_set_clip_rectangle (gc, NULL);
+ gc = use_text ? &style->text[state_type] : &style->fg[state_type];
+
+ gdk_cairo_set_source_color (cr, gc);
+
+ pango_cairo_show_layout (cr, layout);
+
+ cairo_destroy (cr);
}
static void
gint width,
gint height)
{
- GdkPoint points[4];
- gint i, j, skip;
+ gint skip;
+ cairo_t *cr;
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
+ cr = gdk_cairo_create (window);
+ cairo_rectangle (cr, x, y, width, height);
+ cairo_clip (cr);
if (area)
{
- gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
- gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
- gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
+ gdk_cairo_rectangle (cr, area);
+ cairo_clip (cr);
}
-
+
+ cairo_set_line_width (cr, 1.0);
+
skip = -1;
switch (edge)
{
default:
g_assert_not_reached ();
}
- /* Clear background */
- j = 0;
- for (i = 0; i < 4; i++)
- {
- if (skip != i)
- {
- points[j].x = (i == 0 || i == 3) ? x : x + width;
- points[j].y = (i < 2) ? y : y + height;
- j++;
- }
- }
-
- gdk_draw_polygon (window, style->bg_gc[state_type], TRUE,
- points, skip < 0 ? 4 : 3);
switch (edge)
{
while (xi < x + width)
{
- gdk_draw_line (window,
- style->light_gc[state_type],
- xi, y,
- xi, y + height);
+ _cairo_draw_line (cr,
+ &style->light[state_type],
+ xi, y,
+ xi, y + height);
xi++;
- gdk_draw_line (window,
- style->dark_gc[state_type],
- xi, y,
- xi, y + height);
+ _cairo_draw_line (cr,
+ &style->dark[state_type],
+ xi, y,
+ xi, y + height);
xi += 2;
}
while (yi < y + height)
{
- gdk_draw_line (window,
- style->light_gc[state_type],
- x, yi,
- x + width, yi);
+ _cairo_draw_line (cr,
+ &style->light[state_type],
+ x, yi,
+ x + width, yi);
yi++;
- gdk_draw_line (window,
- style->dark_gc[state_type],
- x, yi,
- x + width, yi);
+ _cairo_draw_line (cr,
+ &style->dark[state_type],
+ x, yi,
+ x + width, yi);
yi+= 2;
}
while (xi > x + 3)
{
- gdk_draw_line (window,
- style->dark_gc[state_type],
- xi, y,
- x, yi);
+ _cairo_draw_line (cr,
+ &style->dark[state_type],
+ xi, y,
+ x, yi);
--xi;
--yi;
- gdk_draw_line (window,
- style->dark_gc[state_type],
- xi, y,
- x, yi);
+ _cairo_draw_line (cr,
+ &style->dark[state_type],
+ xi, y,
+ x, yi);
--xi;
--yi;
- gdk_draw_line (window,
- style->light_gc[state_type],
- xi, y,
- x, yi);
+ _cairo_draw_line (cr,
+ &style->light[state_type],
+ xi, y,
+ x, yi);
xi -= 3;
yi -= 3;
while (xi < (x + width - 3))
{
- gdk_draw_line (window,
- style->light_gc[state_type],
- xi, y,
- x + width, yi);
+ _cairo_draw_line (cr,
+ &style->light[state_type],
+ xi, y,
+ x + width, yi);
++xi;
--yi;
- gdk_draw_line (window,
- style->dark_gc[state_type],
- xi, y,
- x + width, yi);
+ _cairo_draw_line (cr,
+ &style->dark[state_type],
+ xi, y,
+ x + width, yi);
++xi;
--yi;
- gdk_draw_line (window,
- style->dark_gc[state_type],
- xi, y,
- x + width, yi);
+ _cairo_draw_line (cr,
+ &style->dark[state_type],
+ xi, y,
+ x + width, yi);
xi += 3;
yi -= 3;
while (xi > x + 3)
{
- gdk_draw_line (window,
- style->dark_gc[state_type],
- x, yi,
- xi, y + height);
+ _cairo_draw_line (cr,
+ &style->dark[state_type],
+ x, yi,
+ xi, y + height);
--xi;
++yi;
- gdk_draw_line (window,
- style->dark_gc[state_type],
- x, yi,
- xi, y + height);
+ _cairo_draw_line (cr,
+ &style->dark[state_type],
+ x, yi,
+ xi, y + height);
--xi;
++yi;
- gdk_draw_line (window,
- style->light_gc[state_type],
- x, yi,
- xi, y + height);
+ _cairo_draw_line (cr,
+ &style->light[state_type],
+ x, yi,
+ xi, y + height);
xi -= 3;
yi += 3;
while (xi < (x + width - 3))
{
- gdk_draw_line (window,
- style->light_gc[state_type],
- xi, y + height,
- x + width, yi);
+ _cairo_draw_line (cr,
+ &style->light[state_type],
+ xi, y + height,
+ x + width, yi);
++xi;
++yi;
- gdk_draw_line (window,
- style->dark_gc[state_type],
- xi, y + height,
- x + width, yi);
+ _cairo_draw_line (cr,
+ &style->dark[state_type],
+ xi, y + height,
+ x + width, yi);
++xi;
++yi;
- gdk_draw_line (window,
- style->dark_gc[state_type],
- xi, y + height,
- x + width, yi);
+ _cairo_draw_line (cr,
+ &style->dark[state_type],
+ xi, y + height,
+ x + width, yi);
xi += 3;
yi += 3;
break;
}
- if (area)
+ cairo_destroy (cr);
+}
+
+static void
+gtk_default_draw_spinner (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ guint step,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
+{
+ GdkColor *color;
+ cairo_t *cr;
+ guint num_steps;
+ gdouble dx, dy;
+ gdouble radius;
+ gdouble half;
+ gint i;
+ guint real_step;
+
+ gtk_style_get (style, GTK_TYPE_SPINNER,
+ "num-steps", &num_steps,
+ NULL);
+ real_step = step % num_steps;
+
+ /* get cairo context */
+ cr = gdk_cairo_create (window);
+
+ /* set a clip region for the expose event */
+ cairo_rectangle (cr, x, y, width, height);
+ cairo_clip (cr);
+
+ cairo_translate (cr, x, y);
+
+ /* draw clip region */
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+
+ color = &style->fg[state_type];
+ dx = width / 2;
+ dy = height / 2;
+ radius = MIN (width / 2, height / 2);
+ half = num_steps / 2;
+
+ for (i = 0; i < num_steps; i++)
{
- gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
- gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
- gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
+ gint inset = 0.7 * radius;
+
+ /* transparency is a function of time and intial value */
+ gdouble t = (gdouble) ((i + num_steps - real_step)
+ % num_steps) / num_steps;
+
+ cairo_save (cr);
+
+ cairo_set_source_rgba (cr,
+ color->red / 65535.,
+ color->green / 65535.,
+ color->blue / 65535.,
+ t);
+
+ cairo_set_line_width (cr, 2.0);
+ cairo_move_to (cr,
+ dx + (radius - inset) * cos (i * G_PI / half),
+ dy + (radius - inset) * sin (i * G_PI / half));
+ cairo_line_to (cr,
+ dx + radius * cos (i * G_PI / half),
+ dy + radius * sin (i * G_PI / half));
+ cairo_stroke (cr);
+
+ cairo_restore (cr);
}
+
+ /* free memory */
+ cairo_destroy (cr);
}
void
-_gtk_style_shade (GdkColor *a,
- GdkColor *b,
- gdouble k)
+_gtk_style_shade (const GdkColor *a,
+ GdkColor *b,
+ gdouble k)
{
gdouble red;
gdouble green;
* @style: a #GtkStyle
* @window: a #GdkWindow
* @state_type: a state
- * @area: rectangle to which the output is clipped, or %NULL if the
+ * @area: (allow-none): rectangle to which the output is clipped, or %NULL if the
* output should not be clipped
- * @widget: the widget (may be %NULL)
- * @detail: a style detail (may be %NULL)
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
* @x1: the starting x coordinate
* @x2: the ending x coordinate
* @y: the y coordinate
- *
+ *
* Draws a horizontal line from (@x1, @y) to (@x2, @y) in @window
* using the given style and state.
**/
void
-gtk_paint_hline (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x1,
- gint x2,
- gint y)
+gtk_paint_hline (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ const GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x1,
+ gint x2,
+ gint y)
{
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_hline != NULL);
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-
- GTK_STYLE_GET_CLASS (style)->draw_hline (style, window, state_type, area, widget, detail, x1, x2, y);
+
+ GTK_STYLE_GET_CLASS (style)->draw_hline (style, window, state_type,
+ (GdkRectangle *) area, widget, detail,
+ x1, x2, y);
}
/**
* @style: a #GtkStyle
* @window: a #GdkWindow
* @state_type: a state
- * @area: rectangle to which the output is clipped, or %NULL if the
+ * @area: (allow-none): rectangle to which the output is clipped, or %NULL if the
* output should not be clipped
- * @widget: the widget (may be %NULL)
- * @detail: a style detail (may be %NULL)
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
* @y1_: the starting y coordinate
* @y2_: the ending y coordinate
* @x: the x coordinate
- *
+ *
* Draws a vertical line from (@x, @y1_) to (@x, @y2_) in @window
* using the given style and state.
*/
void
-gtk_paint_vline (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint y1_,
- gint y2_,
- gint x)
+gtk_paint_vline (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ const GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint y1_,
+ gint y2_,
+ gint x)
{
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL);
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-
- GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type, area, widget, detail, y1_, y2_, x);
+
+ GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type,
+ (GdkRectangle *) area, widget, detail,
+ y1_, y2_, x);
}
/**
* @window: a #GdkWindow
* @state_type: a state
* @shadow_type: type of shadow to draw
- * @area: clip rectangle or %NULL if the
+ * @area: (allow-none): clip rectangle or %NULL if the
* output should not be clipped
- * @widget: the widget (may be %NULL)
- * @detail: a style detail (may be %NULL)
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
* @x: x origin of the rectangle
* @y: y origin of the rectangle
- * @width: width of the rectangle
- * @height: width of the rectangle
+ * @width: width of the rectangle
+ * @height: width of the rectangle
*
* Draws a shadow around the given rectangle in @window
* using the given style and state and shadow type.
*/
void
-gtk_paint_shadow (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x,
- gint y,
- gint width,
- gint height)
+gtk_paint_shadow (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GtkShadowType shadow_type,
+ const GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
{
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-
- GTK_STYLE_GET_CLASS (style)->draw_shadow (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
-}
-/**
- * gtk_paint_polygon:
- * @style: a #GtkStyle
- * @window: a #GdkWindow
- * @state_type: a state
- * @shadow_type: type of shadow to draw
- * @area: clip rectangle, or %NULL if the
- * output should not be clipped
- * @widget: the widget (may be %NULL)
- * @detail: a style detail (may be %NULL)
- * @points: an array of #GdkPoint<!-- -->s
- * @npoints: length of @points
- * @fill: %TRUE if the polygon should be filled
- *
- * Draws a polygon on @window with the given parameters.
- */
-void
-gtk_paint_polygon (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- GdkPoint *points,
- gint npoints,
- gboolean fill)
-{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_polygon != NULL);
- g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-
- GTK_STYLE_GET_CLASS (style)->draw_polygon (style, window, state_type, shadow_type, area, widget, detail, points, npoints, fill);
+ GTK_STYLE_GET_CLASS (style)->draw_shadow (style, window, state_type, shadow_type,
+ (GdkRectangle *) area, widget, detail,
+ x, y, width, height);
}
/**
* @window: a #GdkWindow
* @state_type: a state
* @shadow_type: the type of shadow to draw
- * @area: clip rectangle, or %NULL if the
+ * @area: (allow-none): clip rectangle, or %NULL if the
* output should not be clipped
- * @widget: the widget (may be %NULL)
- * @detail: a style detail (may be %NULL)
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
* @arrow_type: the type of arrow to draw
* @fill: %TRUE if the arrow tip should be filled
* @x: x origin of the rectangle to draw the arrow in
* parameters. @arrow_type determines the direction of the arrow.
*/
void
-gtk_paint_arrow (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- GtkArrowType arrow_type,
- gboolean fill,
- gint x,
- gint y,
- gint width,
- gint height)
+gtk_paint_arrow (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GtkShadowType shadow_type,
+ const GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ GtkArrowType arrow_type,
+ gboolean fill,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
{
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_arrow != NULL);
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-
- GTK_STYLE_GET_CLASS (style)->draw_arrow (style, window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height);
+
+ GTK_STYLE_GET_CLASS (style)->draw_arrow (style, window, state_type, shadow_type,
+ (GdkRectangle *) area, widget, detail,
+ arrow_type, fill, x, y, width, height);
}
/**
* @window: a #GdkWindow
* @state_type: a state
* @shadow_type: the type of shadow to draw
- * @area: clip rectangle, or %NULL if the
+ * @area: (allow-none): clip rectangle, or %NULL if the
* output should not be clipped
- * @widget: the widget (may be %NULL)
- * @detail: a style detail (may be %NULL)
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
* @x: x origin of the rectangle to draw the diamond in
* @y: y origin of the rectangle to draw the diamond in
* @width: width of the rectangle to draw the diamond in
* parameters.
*/
void
-gtk_paint_diamond (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x,
- gint y,
- gint width,
- gint height)
+gtk_paint_diamond (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GtkShadowType shadow_type,
+ const GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
{
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_diamond != NULL);
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-
- GTK_STYLE_GET_CLASS (style)->draw_diamond (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
-}
-/**
- * gtk_paint_string:
- * @style: a #GtkStyle
- * @window: a #GdkWindow
- * @state_type: a state
- * @area: clip rectangle, or %NULL if the
- * output should not be clipped
- * @widget: the widget (may be %NULL)
- * @detail: a style detail (may be %NULL)
- * @x: x origin
- * @y: y origin
- * @string: the string to draw
- *
- * Draws a text string on @window with the given parameters.
- *
- * Deprecated: Use gtk_paint_layout() instead.
- */
-void
-gtk_paint_string (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x,
- gint y,
- const gchar *string)
-{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_string != NULL);
- g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-
- GTK_STYLE_GET_CLASS (style)->draw_string (style, window, state_type, area, widget, detail, x, y, string);
+ GTK_STYLE_GET_CLASS (style)->draw_diamond (style, window, state_type, shadow_type,
+ (GdkRectangle *) area, widget, detail,
+ x, y, width, height);
}
/**
* @window: a #GdkWindow
* @state_type: a state
* @shadow_type: the type of shadow to draw
- * @area: clip rectangle, or %NULL if the
+ * @area: (allow-none): clip rectangle, or %NULL if the
* output should not be clipped
- * @widget: the widget (may be %NULL)
- * @detail: a style detail (may be %NULL)
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
* @x: x origin of the box
* @y: y origin of the box
* @width: the width of the box
* Draws a box on @window with the given parameters.
*/
void
-gtk_paint_box (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x,
- gint y,
- gint width,
- gint height)
+gtk_paint_box (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GtkShadowType shadow_type,
+ const GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
{
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box != NULL);
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-
- GTK_STYLE_GET_CLASS (style)->draw_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+
+ GTK_STYLE_GET_CLASS (style)->draw_box (style, window, state_type, shadow_type,
+ (GdkRectangle *) area, widget, detail,
+ x, y, width, height);
}
/**
* @window: a #GdkWindow
* @state_type: a state
* @shadow_type: the type of shadow to draw
- * @area: clip rectangle, or %NULL if the
+ * @area: (allow-none): clip rectangle, or %NULL if the
* output should not be clipped
- * @widget: the widget (may be %NULL)
- * @detail: a style detail (may be %NULL)
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
* @x: x origin of the box
* @y: y origin of the box
* @width: the width of the box
* Draws a flat box on @window with the given parameters.
*/
void
-gtk_paint_flat_box (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x,
- gint y,
- gint width,
- gint height)
+gtk_paint_flat_box (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GtkShadowType shadow_type,
+ const GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
{
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_flat_box != NULL);
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-
- GTK_STYLE_GET_CLASS (style)->draw_flat_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+
+ GTK_STYLE_GET_CLASS (style)->draw_flat_box (style, window, state_type, shadow_type,
+ (GdkRectangle *) area, widget, detail,
+ x, y, width, height);
}
/**
* @window: a #GdkWindow
* @state_type: a state
* @shadow_type: the type of shadow to draw
- * @area: clip rectangle, or %NULL if the
+ * @area: (allow-none): clip rectangle, or %NULL if the
* output should not be clipped
- * @widget: the widget (may be %NULL)
- * @detail: a style detail (may be %NULL)
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
* @x: x origin of the rectangle to draw the check in
* @y: y origin of the rectangle to draw the check in
* @width: the width of the rectangle to draw the check in
* the given parameters.
*/
void
-gtk_paint_check (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x,
- gint y,
- gint width,
- gint height)
+gtk_paint_check (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GtkShadowType shadow_type,
+ const GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
{
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_check != NULL);
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-
- GTK_STYLE_GET_CLASS (style)->draw_check (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+
+ GTK_STYLE_GET_CLASS (style)->draw_check (style, window, state_type, shadow_type,
+ (GdkRectangle *) area, widget, detail,
+ x, y, width, height);
}
/**
* @window: a #GdkWindow
* @state_type: a state
* @shadow_type: the type of shadow to draw
- * @area: clip rectangle, or %NULL if the
+ * @area: (allow-none): clip rectangle, or %NULL if the
* output should not be clipped
- * @widget: the widget (may be %NULL)
- * @detail: a style detail (may be %NULL)
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
* @x: x origin of the rectangle to draw the option in
* @y: y origin of the rectangle to draw the option in
* @width: the width of the rectangle to draw the option in
* the given parameters.
*/
void
-gtk_paint_option (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x,
- gint y,
- gint width,
- gint height)
+gtk_paint_option (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GtkShadowType shadow_type,
+ const GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
{
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_option != NULL);
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-
- GTK_STYLE_GET_CLASS (style)->draw_option (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+
+ GTK_STYLE_GET_CLASS (style)->draw_option (style, window, state_type, shadow_type,
+ (GdkRectangle *) area, widget, detail,
+ x, y, width, height);
}
/**
* @window: a #GdkWindow
* @state_type: a state
* @shadow_type: the type of shadow to draw
- * @area: clip rectangle, or %NULL if the
+ * @area: (allow-none): clip rectangle, or %NULL if the
* output should not be clipped
- * @widget: the widget (may be %NULL)
- * @detail: a style detail (may be %NULL)
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
* @x: x origin of the rectangle to draw the tab in
* @y: y origin of the rectangle to draw the tab in
* @width: the width of the rectangle to draw the tab in
* in the given rectangle on @window using the given parameters.
*/
void
-gtk_paint_tab (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x,
- gint y,
- gint width,
- gint height)
+gtk_paint_tab (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GtkShadowType shadow_type,
+ const GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
{
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_tab != NULL);
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-
- GTK_STYLE_GET_CLASS (style)->draw_tab (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+
+ GTK_STYLE_GET_CLASS (style)->draw_tab (style, window, state_type, shadow_type,
+ (GdkRectangle *) area, widget, detail,
+ x, y, width, height);
}
/**
* @window: a #GdkWindow
* @state_type: a state
* @shadow_type: type of shadow to draw
- * @area: clip rectangle, or %NULL if the
+ * @area: (allow-none): clip rectangle, or %NULL if the
* output should not be clipped
- * @widget: the widget (may be %NULL)
- * @detail: a style detail (may be %NULL)
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
* @x: x origin of the rectangle
* @y: y origin of the rectangle
- * @width: width of the rectangle
- * @height: width of the rectangle
+ * @width: width of the rectangle
+ * @height: width of the rectangle
* @gap_side: side in which to leave the gap
* @gap_x: starting position of the gap
* @gap_width: width of the gap
* gap in one side.
*/
void
-gtk_paint_shadow_gap (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- gchar *detail,
- gint x,
- gint y,
- gint width,
- gint height,
- GtkPositionType gap_side,
- gint gap_x,
- gint gap_width)
+gtk_paint_shadow_gap (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GtkShadowType shadow_type,
+ const GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ GtkPositionType gap_side,
+ gint gap_x,
+ gint gap_width)
{
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL);
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-
- GTK_STYLE_GET_CLASS (style)->draw_shadow_gap (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
+
+ GTK_STYLE_GET_CLASS (style)->draw_shadow_gap (style, window, state_type, shadow_type,
+ (GdkRectangle *) area, widget, detail,
+ x, y, width, height, gap_side, gap_x, gap_width);
}
* @window: a #GdkWindow
* @state_type: a state
* @shadow_type: type of shadow to draw
- * @area: clip rectangle, or %NULL if the
+ * @area: (allow-none): clip rectangle, or %NULL if the
* output should not be clipped
- * @widget: the widget (may be %NULL)
- * @detail: a style detail (may be %NULL)
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
* @x: x origin of the rectangle
* @y: y origin of the rectangle
- * @width: width of the rectangle
- * @height: width of the rectangle
+ * @width: width of the rectangle
+ * @height: width of the rectangle
* @gap_side: side in which to leave the gap
* @gap_x: starting position of the gap
* @gap_width: width of the gap
* leaving a gap in one side.
*/
void
-gtk_paint_box_gap (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- gchar *detail,
- gint x,
- gint y,
- gint width,
- gint height,
- GtkPositionType gap_side,
- gint gap_x,
- gint gap_width)
+gtk_paint_box_gap (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GtkShadowType shadow_type,
+ const GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ GtkPositionType gap_side,
+ gint gap_x,
+ gint gap_width)
{
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box_gap != NULL);
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-
- GTK_STYLE_GET_CLASS (style)->draw_box_gap (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
+
+ GTK_STYLE_GET_CLASS (style)->draw_box_gap (style, window, state_type, shadow_type,
+ (GdkRectangle *) area, widget, detail,
+ x, y, width, height, gap_side, gap_x, gap_width);
}
/**
* @window: a #GdkWindow
* @state_type: a state
* @shadow_type: type of shadow to draw
- * @area: clip rectangle, or %NULL if the
+ * @area: (allow-none): clip rectangle, or %NULL if the
* output should not be clipped
- * @widget: the widget (may be %NULL)
- * @detail: a style detail (may be %NULL)
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
* @x: x origin of the extension
* @y: y origin of the extension
- * @width: width of the extension
- * @height: width of the extension
+ * @width: width of the extension
+ * @height: width of the extension
* @gap_side: the side on to which the extension is attached
*
* Draws an extension, i.e. a notebook tab.
**/
void
-gtk_paint_extension (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- gchar *detail,
- gint x,
- gint y,
- gint width,
- gint height,
- GtkPositionType gap_side)
+gtk_paint_extension (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GtkShadowType shadow_type,
+ const GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ GtkPositionType gap_side)
{
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != NULL);
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-
- GTK_STYLE_GET_CLASS (style)->draw_extension (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side);
+
+ GTK_STYLE_GET_CLASS (style)->draw_extension (style, window, state_type, shadow_type,
+ (GdkRectangle *) area, widget, detail,
+ x, y, width, height, gap_side);
}
/**
* @style: a #GtkStyle
* @window: a #GdkWindow
* @state_type: a state
- * @area: clip rectangle, or %NULL if the
+ * @area: (allow-none): clip rectangle, or %NULL if the
* output should not be clipped
- * @widget: the widget (may be %NULL)
- * @detail: a style detail (may be %NULL)
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
* @x: the x origin of the rectangle around which to draw a focus indicator
* @y: the y origin of the rectangle around which to draw a focus indicator
* @width: the width of the rectangle around which to draw a focus indicator
* given style.
*/
void
-gtk_paint_focus (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x,
- gint y,
- gint width,
- gint height)
+gtk_paint_focus (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ const GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
{
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_focus != NULL);
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-
- GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, state_type, area, widget, detail, x, y, width, height);
+
+ GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, state_type,
+ (GdkRectangle *) area, widget, detail,
+ x, y, width, height);
}
/**
* @window: a #GdkWindow
* @state_type: a state
* @shadow_type: a shadow
- * @area: clip rectangle, or %NULL if the
+ * @area: (allow-none): clip rectangle, or %NULL if the
* output should not be clipped
- * @widget: the widget (may be %NULL)
- * @detail: a style detail (may be %NULL)
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
* @x: the x origin of the rectangle in which to draw a slider
* @y: the y origin of the rectangle in which to draw a slider
* @width: the width of the rectangle in which to draw a slider
* given style and orientation.
**/
void
-gtk_paint_slider (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x,
- gint y,
- gint width,
- gint height,
- GtkOrientation orientation)
+gtk_paint_slider (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GtkShadowType shadow_type,
+ const GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ GtkOrientation orientation)
{
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_slider != NULL);
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-
- GTK_STYLE_GET_CLASS (style)->draw_slider (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
+
+ GTK_STYLE_GET_CLASS (style)->draw_slider (style, window, state_type, shadow_type,
+ (GdkRectangle *) area, widget, detail,
+ x, y, width, height, orientation);
}
/**
* @window: a #GdkWindow
* @state_type: a state
* @shadow_type: type of shadow to draw
- * @area: clip rectangle, or %NULL if the
+ * @area: (allow-none): clip rectangle, or %NULL if the
* output should not be clipped
- * @widget: the widget (may be %NULL)
- * @detail: a style detail (may be %NULL)
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
* @x: x origin of the handle
* @y: y origin of the handle
* @width: with of the handle
* Draws a handle as used in #GtkHandleBox and #GtkPaned.
**/
void
-gtk_paint_handle (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x,
- gint y,
- gint width,
- gint height,
- GtkOrientation orientation)
+gtk_paint_handle (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GtkShadowType shadow_type,
+ const GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ GtkOrientation orientation)
{
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_handle != NULL);
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-
- GTK_STYLE_GET_CLASS (style)->draw_handle (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
+
+ GTK_STYLE_GET_CLASS (style)->draw_handle (style, window, state_type, shadow_type,
+ (GdkRectangle *) area, widget, detail,
+ x, y, width, height, orientation);
}
/**
* @style: a #GtkStyle
* @window: a #GdkWindow
* @state_type: a state
- * @area: clip rectangle, or %NULL if the
+ * @area: (allow-none): clip rectangle, or %NULL if the
* output should not be clipped
- * @widget: the widget (may be %NULL)
- * @detail: a style detail (may be %NULL)
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
* @x: the x position to draw the expander at
* @y: the y position to draw the expander at
* @expander_style: the style to draw the expander in; determines
* expanded position.
**/
void
-gtk_paint_expander (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x,
- gint y,
- GtkExpanderStyle expander_style)
+gtk_paint_expander (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ const GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ GtkExpanderStyle expander_style)
{
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_expander != NULL);
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-
- GTK_STYLE_GET_CLASS (style)->draw_expander (style, window, state_type, area,
- widget, detail, x, y, expander_style);
+
+ GTK_STYLE_GET_CLASS (style)->draw_expander (style, window, state_type,
+ (GdkRectangle *) area, widget, detail,
+ x, y, expander_style);
}
/**
* @state_type: a state
* @use_text: whether to use the text or foreground
* graphics context of @style
- * @area: clip rectangle, or %NULL if the
+ * @area: (allow-none): clip rectangle, or %NULL if the
* output should not be clipped
- * @widget: the widget (may be %NULL)
- * @detail: a style detail (may be %NULL)
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
* @x: x origin
* @y: y origin
* @layout: the layout to draw
- *
+ *
* Draws a layout on @window using the given parameters.
**/
void
-gtk_paint_layout (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- gboolean use_text,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x,
- gint y,
- PangoLayout *layout)
+gtk_paint_layout (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ gboolean use_text,
+ const GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ PangoLayout *layout)
{
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL);
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-
- GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type, use_text, area,
- widget, detail, x, y, layout);
+
+ GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type, use_text,
+ (GdkRectangle *) area, widget, detail,
+ x, y, layout);
}
/**
* @style: a #GtkStyle
* @window: a #GdkWindow
* @state_type: a state
- * @area: clip rectangle, or %NULL if the
+ * @area: (allow-none): clip rectangle, or %NULL if the
* output should not be clipped
- * @widget: the widget (may be %NULL)
- * @detail: a style detail (may be %NULL)
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
* @edge: the edge in which to draw the resize grip
* @x: the x origin of the rectangle in which to draw the resize grip
* @y: the y origin of the rectangle in which to draw the resize grip
* parameters.
*/
void
-gtk_paint_resize_grip (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- GdkWindowEdge edge,
- gint x,
- gint y,
- gint width,
- gint height)
+gtk_paint_resize_grip (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ const GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ GdkWindowEdge edge,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
{
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
GTK_STYLE_GET_CLASS (style)->draw_resize_grip (style, window, state_type,
- area, widget, detail,
+ (GdkRectangle *) area, widget, detail,
edge, x, y, width, height);
}
/**
- * gtk_border_copy:
- * @border_: a #GtkBorder.
- * @returns: a copy of @border_.
+ * gtk_paint_spinner:
+ * @style: a #GtkStyle
+ * @window: a #GdkWindow
+ * @state_type: a state
+ * @area: (allow-none): clip rectangle, or %NULL if the
+ * output should not be clipped
+ * @widget: (allow-none): the widget (may be %NULL)
+ * @detail: (allow-none): a style detail (may be %NULL)
+ * @step: the nth step, a value between 0 and #GtkSpinner:num-steps
+ * @x: the x origin of the rectangle in which to draw the spinner
+ * @y: the y origin of the rectangle in which to draw the spinner
+ * @width: the width of the rectangle in which to draw the spinner
+ * @height: the height of the rectangle in which to draw the spinner
*
- * Copies a #GtkBorder structure.
- **/
-GtkBorder *
-gtk_border_copy (const GtkBorder *border)
+ * Draws a spinner on @window using the given parameters.
+ *
+ * Since: 2.20
+ */
+void
+gtk_paint_spinner (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ const GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ guint step,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
{
- return (GtkBorder *)g_memdup (border, sizeof (GtkBorder));
+ g_return_if_fail (GTK_IS_STYLE (style));
+ g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_spinner != NULL);
+ g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
+
+ GTK_STYLE_GET_CLASS (style)->draw_spinner (style, window, state_type,
+ (GdkRectangle *)area, widget, detail,
+ step, x, y, width, height);
}
/**
- * gtk_border_free:
- * @border_: a #GtkBorder.
+ * gtk_border_new:
+ *
+ * Allocates a new #GtkBorder structure and initializes its elements to zero.
*
- * Frees a #GtkBorder structure.
+ * Returns: a new empty #GtkBorder. The newly allocated #GtkBorder should be
+ * freed with gtk_border_free()
+ *
+ * Since: 2.14
**/
-void
-gtk_border_free (GtkBorder *border)
-{
- g_free (border);
-}
-
-GType
-gtk_border_get_type (void)
-{
- static GType our_type = 0;
-
- if (our_type == 0)
- our_type = g_boxed_type_register_static (I_("GtkBorder"),
- (GBoxedCopyFunc) gtk_border_copy,
- (GBoxedFreeFunc) gtk_border_free);
-
- return our_type;
-}
-
-static GdkFont *
-gtk_style_get_font_internal (GtkStyle *style)
+GtkBorder *
+gtk_border_new (void)
{
- g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
-
- if (style->private_font && style->private_font_desc)
- {
- if (!style->font_desc ||
- !pango_font_description_equal (style->private_font_desc, style->font_desc))
- {
- gdk_font_unref (style->private_font);
- style->private_font = NULL;
-
- if (style->private_font_desc)
- {
- pango_font_description_free (style->private_font_desc);
- style->private_font_desc = NULL;
- }
- }
- }
-
- if (!style->private_font)
- {
- GdkDisplay *display;
-
- if (style->colormap)
- {
- display = gdk_screen_get_display (gdk_colormap_get_screen (style->colormap));
- }
- else
- {
- display = gdk_display_get_default ();
- GTK_NOTE (MULTIHEAD,
- g_warning ("gtk_style_get_font() should not be called on an unattached style"));
- }
-
- if (style->font_desc)
- {
- style->private_font = gdk_font_from_description_for_display (display, style->font_desc);
- style->private_font_desc = pango_font_description_copy (style->font_desc);
- }
-
- if (!style->private_font)
- style->private_font = gdk_font_load_for_display (display, "fixed");
-
- if (!style->private_font)
- g_error ("Unable to load \"fixed\" font");
- }
-
- return style->private_font;
+ return g_slice_new0 (GtkBorder);
}
/**
- * gtk_style_get_font:
- * @style: a #GtkStyle
- *
- * Gets the #GdkFont to use for the given style. This is
- * meant only as a replacement for direct access to @style->font
- * and should not be used in new code. New code should
- * use @style->font_desc instead.
- *
- * Return value: the #GdkFont for the style. This font is owned
- * by the style; if you want to keep around a copy, you must
- * call gdk_font_ref().
+ * gtk_border_copy:
+ * @border_: a #GtkBorder.
+ * @returns: a copy of @border_.
+ *
+ * Copies a #GtkBorder structure.
**/
-GdkFont *
-gtk_style_get_font (GtkStyle *style)
+GtkBorder *
+gtk_border_copy (const GtkBorder *border)
{
- g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
+ g_return_val_if_fail (border != NULL, NULL);
- return gtk_style_get_font_internal (style);
+ return g_slice_dup (GtkBorder, border);
}
/**
- * gtk_style_set_font:
- * @style: a #GtkStyle.
- * @font: a #GdkFont, or %NULL to use the #GdkFont corresponding
- * to style->font_desc.
+ * gtk_border_free:
+ * @border_: a #GtkBorder.
*
- * Sets the #GdkFont to use for a given style. This is
- * meant only as a replacement for direct access to style->font
- * and should not be used in new code. New code should
- * use style->font_desc instead.
+ * Frees a #GtkBorder structure.
**/
void
-gtk_style_set_font (GtkStyle *style,
- GdkFont *font)
+gtk_border_free (GtkBorder *border)
{
- GdkFont *old_font;
-
- g_return_if_fail (GTK_IS_STYLE (style));
-
- old_font = style->private_font;
-
- style->private_font = font;
- if (font)
- gdk_font_ref (font);
-
- if (old_font)
- gdk_font_unref (old_font);
-
- if (style->private_font_desc)
- {
- pango_font_description_free (style->private_font_desc);
- style->private_font_desc = NULL;
- }
+ g_slice_free (GtkBorder, border);
}
+G_DEFINE_BOXED_TYPE (GtkBorder, gtk_border,
+ gtk_border_copy,
+ gtk_border_free)
+
typedef struct _CursorInfo CursorInfo;
struct _CursorInfo
{
GType for_type;
- GdkGC *primary_gc;
- GdkGC *secondary_gc;
+ GdkColor primary;
+ GdkColor secondary;
};
static void
-style_unrealize_cursor_gcs (GtkStyle *style)
+style_unrealize_cursors (GtkStyle *style)
{
CursorInfo *
cursor_info = g_object_get_data (G_OBJECT (style), "gtk-style-cursor-info");
if (cursor_info)
{
- if (cursor_info->primary_gc)
- gtk_gc_release (cursor_info->primary_gc);
-
- if (cursor_info->secondary_gc)
- gtk_gc_release (cursor_info->secondary_gc);
-
g_free (cursor_info);
g_object_set_data (G_OBJECT (style), I_("gtk-style-cursor-info"), NULL);
}
}
-static GdkGC *
-make_cursor_gc (GtkWidget *widget,
- const gchar *property_name,
- const GdkColor *fallback)
+static const GdkColor *
+get_insertion_cursor_color (GtkWidget *widget,
+ gboolean is_primary)
{
- GdkGCValues gc_values;
- GdkGCValuesMask gc_values_mask;
+ CursorInfo *cursor_info;
+ GtkStyle *style;
GdkColor *cursor_color;
- gtk_widget_style_get (widget, property_name, &cursor_color, NULL);
-
- gc_values_mask = GDK_GC_FOREGROUND;
- if (cursor_color)
- {
- gc_values.foreground = *cursor_color;
- gdk_color_free (cursor_color);
- }
- else
- gc_values.foreground = *fallback;
-
- gdk_rgb_find_color (widget->style->colormap, &gc_values.foreground);
- return gtk_gc_get (widget->style->depth, widget->style->colormap, &gc_values, gc_values_mask);
-}
-
-static GdkGC *
-get_insertion_cursor_gc (GtkWidget *widget,
- gboolean is_primary)
-{
- CursorInfo *cursor_info;
+ style = gtk_widget_get_style (widget);
- cursor_info = g_object_get_data (G_OBJECT (widget->style), "gtk-style-cursor-info");
+ cursor_info = g_object_get_data (G_OBJECT (style), "gtk-style-cursor-info");
if (!cursor_info)
{
- cursor_info = g_new (CursorInfo, 1);
- g_object_set_data (G_OBJECT (widget->style), I_("gtk-style-cursor-info"), cursor_info);
- cursor_info->primary_gc = NULL;
- cursor_info->secondary_gc = NULL;
+ cursor_info = g_new0 (CursorInfo, 1);
+ g_object_set_data (G_OBJECT (style), I_("gtk-style-cursor-info"), cursor_info);
cursor_info->for_type = G_TYPE_INVALID;
}
if (cursor_info->for_type != G_OBJECT_TYPE (widget))
{
cursor_info->for_type = G_OBJECT_TYPE (widget);
- if (cursor_info->primary_gc)
- {
- gtk_gc_release (cursor_info->primary_gc);
- cursor_info->primary_gc = NULL;
- }
- if (cursor_info->secondary_gc)
- {
- gtk_gc_release (cursor_info->secondary_gc);
- cursor_info->secondary_gc = NULL;
- }
+
+ /* Cursors in text widgets are drawn only in NORMAL state,
+ * so we can use text[GTK_STATE_NORMAL] as text color here */
+ gtk_widget_style_get (widget, "cursor-color", &cursor_color, NULL);
+ if (cursor_color)
+ {
+ cursor_info->primary = *cursor_color;
+ gdk_color_free (cursor_color);
+ }
+ else
+ {
+ cursor_info->primary = style->text[GTK_STATE_NORMAL];
+ }
+
+ gtk_widget_style_get (widget, "secondary-cursor-color", &cursor_color, NULL);
+ if (cursor_color)
+ {
+ cursor_info->secondary = *cursor_color;
+ gdk_color_free (cursor_color);
+ }
+ else
+ {
+ /* text_aa is the average of text and base colors,
+ * in usual black-on-white case it's grey. */
+ cursor_info->secondary = style->text_aa[GTK_STATE_NORMAL];
+ }
}
if (is_primary)
- {
- if (!cursor_info->primary_gc)
- cursor_info->primary_gc = make_cursor_gc (widget,
- "cursor-color",
- &widget->style->black);
-
- return cursor_info->primary_gc;
- }
+ return &cursor_info->primary;
else
+ return &cursor_info->secondary;
+}
+
+void
+_gtk_widget_get_cursor_color (GtkWidget *widget,
+ GdkColor *color)
+{
+ GdkColor *style_color;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (color != NULL);
+
+ gtk_widget_style_get (widget, "cursor-color", &style_color, NULL);
+
+ if (style_color)
{
- static const GdkColor gray = { 0, 0x8888, 0x8888, 0x8888 };
-
- if (!cursor_info->secondary_gc)
- cursor_info->secondary_gc = make_cursor_gc (widget,
- "secondary-cursor-color",
- &gray);
-
- return cursor_info->secondary_gc;
+ *color = *style_color;
+ gdk_color_free (style_color);
}
+ else
+ *color = gtk_widget_get_style (widget)->text[GTK_STATE_NORMAL];
}
static void
-draw_insertion_cursor (GtkWidget *widget,
- GdkDrawable *drawable,
- GdkGC *gc,
- GdkRectangle *location,
- GtkTextDirection direction,
- gboolean draw_arrow)
+draw_insertion_cursor (GtkWidget *widget,
+ cairo_t *cr,
+ const GdkRectangle *location,
+ GtkTextDirection direction,
+ gboolean draw_arrow)
{
gint stem_width;
gint arrow_width;
gint x, y;
- gint i;
gfloat cursor_aspect_ratio;
gint offset;
- g_return_if_fail (direction != GTK_TEXT_DIR_NONE);
-
/* When changing the shape or size of the cursor here,
* propagate the changes to gtktextview.c:text_window_invalidate_cursors().
*/
else
offset = stem_width - stem_width / 2;
- for (i = 0; i < stem_width; i++)
- gdk_draw_line (drawable, gc,
- location->x + i - offset, location->y,
- location->x + i - offset, location->y + location->height - 1);
+ cairo_rectangle (cr,
+ location->x - offset, location->y,
+ stem_width, location->height);
+ cairo_fill (cr);
if (draw_arrow)
{
x = location->x - offset - 1;
y = location->y + location->height - arrow_width * 2 - arrow_width + 1;
- for (i = 0; i < arrow_width; i++)
- {
- gdk_draw_line (drawable, gc,
- x, y + i + 1,
- x, y + 2 * arrow_width - i - 1);
- x --;
- }
+ cairo_move_to (cr, x, y + 1);
+ cairo_line_to (cr, x - arrow_width, y + arrow_width);
+ cairo_line_to (cr, x, y + 2 * arrow_width);
+ cairo_fill (cr);
}
else if (direction == GTK_TEXT_DIR_LTR)
{
x = location->x + stem_width - offset;
y = location->y + location->height - arrow_width * 2 - arrow_width + 1;
- for (i = 0; i < arrow_width; i++)
- {
- gdk_draw_line (drawable, gc,
- x, y + i + 1,
- x, y + 2 * arrow_width - i - 1);
- x++;
- }
+ cairo_move_to (cr, x, y + 1);
+ cairo_line_to (cr, x + arrow_width, y + arrow_width);
+ cairo_line_to (cr, x, y + 2 * arrow_width);
+ cairo_fill (cr);
}
}
}
/**
* gtk_draw_insertion_cursor:
* @widget: a #GtkWidget
- * @drawable: a #GdkDrawable
- * @area: rectangle to which the output is clipped, or %NULL if the
+ * @drawable: a #GdkDrawable
+ * @area: (allow-none): rectangle to which the output is clipped, or %NULL if the
* output should not be clipped
* @location: location where to draw the cursor (@location->width is ignored)
* @is_primary: if the cursor should be the primary cursor color.
* Since: 2.4
**/
void
-gtk_draw_insertion_cursor (GtkWidget *widget,
- GdkDrawable *drawable,
- GdkRectangle *area,
- GdkRectangle *location,
- gboolean is_primary,
- GtkTextDirection direction,
- gboolean draw_arrow)
+gtk_draw_insertion_cursor (GtkWidget *widget,
+ GdkDrawable *drawable,
+ const GdkRectangle *area,
+ const GdkRectangle *location,
+ gboolean is_primary,
+ GtkTextDirection direction,
+ gboolean draw_arrow)
{
- GdkGC *gc;
+ cairo_t *cr;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (GDK_IS_DRAWABLE (drawable));
g_return_if_fail (location != NULL);
g_return_if_fail (direction != GTK_TEXT_DIR_NONE);
- gc = get_insertion_cursor_gc (widget, is_primary);
+ cr = gdk_cairo_create (drawable);
if (area)
- gdk_gc_set_clip_rectangle (gc, area);
+ {
+ gdk_cairo_rectangle (cr, area);
+ cairo_clip (cr);
+ }
- draw_insertion_cursor (widget, drawable, gc,
- location, direction, draw_arrow);
+ gdk_cairo_set_source_color (cr, get_insertion_cursor_color (widget, is_primary));
+ draw_insertion_cursor (widget, cr, location, direction, draw_arrow);
- if (area)
- gdk_gc_set_clip_rectangle (gc, NULL);
+ cairo_destroy (cr);
}
-
-#define __GTK_STYLE_C__
-#include "gtkaliasdef.c"