* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
-#include <config.h>
+#include "config.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
-#include "gtkalias.h"
+#include <gobject/gvaluecollector.h>
#include "gtkgc.h"
#include "gtkmarshalers.h"
+#undef GTK_DISABLE_DEPRECATED
#include "gtkrc.h"
#include "gtkspinbutton.h"
#include "gtkstyle.h"
#include "gtkthemes.h"
#include "gtkiconfactory.h"
#include "gtksettings.h" /* _gtk_settings_parse_convert() */
+#include "gtkintl.h"
+#include "gtkalias.h"
#define LIGHTNESS_MULT 1.3
#define DARKNESS_MULT 0.7
GValue value;
} PropertyValue;
+#define GTK_STYLE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_STYLE, GtkStylePrivate))
+
+typedef struct _GtkStylePrivate GtkStylePrivate;
+
+struct _GtkStylePrivate {
+ GSList *color_hashes;
+};
+
/* --- 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_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 gtk_style_shade (GdkColor *a,
- GdkColor *b,
- gdouble k);
static void rgb_to_hls (gdouble *r,
gdouble *g,
gdouble *b);
static const GtkRequisition default_option_indicator_size = { 7, 13 };
static const GtkBorder default_option_indicator_spacing = { 7, 5, 2, 2 };
-#define INDICATOR_PART_SIZE 13
-
-typedef enum {
- CHECK_AA,
- CHECK_BASE,
- CHECK_BLACK,
- CHECK_DARK,
- CHECK_LIGHT,
- CHECK_MID,
- CHECK_TEXT,
- CHECK_INCONSISTENT_TEXT,
- RADIO_BASE,
- RADIO_BLACK,
- RADIO_DARK,
- RADIO_LIGHT,
- RADIO_MID,
- RADIO_TEXT,
- RADIO_INCONSISTENT_AA,
- RADIO_INCONSISTENT_TEXT
-} IndicatorPart;
-
-/*
- * Extracted from check-13.png, width=13, height=13
- */
-static const guchar check_black_bits[] = {
- 0x00,0x00,0xfe,0x0f,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,
- 0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00};
-static const guchar check_dark_bits[] = {
- 0xff,0x1f,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
- 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x00,0x00};
-static const guchar check_mid_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,
- 0x08,0x00,0x08,0x00,0x08,0x00,0x08,0xfc,0x0f,0x00,0x00,0x00,0x00};
-static const guchar check_light_bits[] = {
- 0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,
- 0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0xfe,0x1f,0x00,0x00};
-static const guchar check_text_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x03,0x80,0x01,0x80,0x00,0x58,
- 0x00,0x60,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
-static const guchar check_aa_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x58,0x00,0xa0,
- 0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
-static const guchar check_base_bits[] = {
- 0x00,0x00,0x00,0x00,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,
- 0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0x00,0x00,0x00,0x00,0x00,0x00};
-
-/*
- * Extracted from check-13-inconsistent.png, width=13, height=13
- */
-static const guchar check_inconsistent_text_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x03,0xf8,
- 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
-#if 0
-/*
- * check_inconsistent_aa_bits is currently not used, since it is all zeros.
- */
-static const guchar check_inconsistent_aa_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
-#endif
-
-/*
- * Extracted from radio-13.png, width=13, height=13
- */
-static const guchar radio_black_bits[] = {
- 0x00,0x00,0xf0,0x01,0x0c,0x02,0x04,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,
- 0x00,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0d,0x08};
-static const guchar radio_dark_bits[] = {
- 0xf0,0x00,0x0c,0x02,0x02,0x04,0x02,0x04,0x01,0x08,0x01,0x08,0x01,0x08,0x01,
- 0x08,0x00,0x08,0x02,0x04,0x0c,0x06,0xf0,0x01,0x00,0x00,0x00,0x00};
-static const guchar radio_mid_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
-static const guchar radio_light_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x10,0x00,
- 0x10,0x00,0x10,0x00,0x08,0x00,0x08,0x00,0x06,0xe0,0x01,0x00,0x00};
-static const guchar radio_text_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x00,0xf0,0x01,0xf0,0x01,0xf0,
- 0x01,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
-#if 0
-/*
- * radio_aa_bits is currently not used, since it is all zeros.
- */
-static const guchar radio_aa_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
-#endif
-static const guchar radio_base_bits[] = {
- 0x00,0x00,0x00,0x00,0xf0,0x01,0xf8,0x03,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,
- 0x07,0xfc,0x07,0xf8,0x03,0xf0,0x01,0x00,0x00,0x00,0x00,0x00,0x00};
-
-/*
- * Extracted from radio-13.png, width=13, height=13
- */
-static const guchar radio_inconsistent_text_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x03,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
-static const guchar radio_inconsistent_aa_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x03,0x00,0x00,0xf8,
- 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
-
-static struct {
- const guchar *bits;
- GList *bmap_list; /* list of GdkBitmap */
-} indicator_parts[] = {
- { check_aa_bits, NULL },
- { check_base_bits, NULL },
- { check_black_bits, NULL },
- { check_dark_bits, NULL },
- { check_light_bits, NULL },
- { check_mid_bits, NULL },
- { check_text_bits, NULL },
- { check_inconsistent_text_bits, NULL },
- { radio_base_bits, NULL },
- { radio_black_bits, NULL },
- { radio_dark_bits, NULL },
- { radio_light_bits, NULL },
- { radio_mid_bits, NULL },
- { radio_text_bits, NULL },
- { radio_inconsistent_aa_bits, NULL },
- { radio_inconsistent_text_bits, NULL },
-};
#define GTK_GRAY 0xdcdc, 0xdada, 0xd5d5
#define GTK_DARK_GRAY 0xc4c4, 0xc2c2, 0xbdbd
#define GTK_LIGHT_GRAY 0xeeee, 0xebeb, 0xe7e7
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, "GtkStyle",
- &style_info, 0);
- }
-
- return style_type;
-}
/**
* _gtk_style_init_for_settings:
{
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_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));
-
/**
* GtkStyle::realize:
* @style: the object which received the signal
*
* Since: 2.4
*/
- realize_signal = g_signal_new ("realize",
+ realize_signal = g_signal_new (I_("realize"),
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkStyleClass, realize),
*
* Since: 2.4
*/
- unrealize_signal = g_signal_new ("unrealize",
+ unrealize_signal = g_signal_new (I_("unrealize"),
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkStyleClass, unrealize),
gtk_style_finalize (GObject *object)
{
GtkStyle *style = GTK_STYLE (object);
+ GtkStylePrivate *priv = GTK_STYLE_GET_PRIVATE (style);
g_return_if_fail (style->attach_count == 0);
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;
}
}
- if (style->icon_factories)
- {
- GSList *tmp_list = style->icon_factories;
-
- while (tmp_list)
- {
- g_object_unref (tmp_list->data);
- tmp_list = tmp_list->next;
- }
+ g_slist_foreach (style->icon_factories, (GFunc) g_object_unref, NULL);
+ g_slist_free (style->icon_factories);
- g_slist_free (style->icon_factories);
- }
+ g_slist_foreach (priv->color_hashes, (GFunc) g_hash_table_unref, NULL);
+ g_slist_free (priv->color_hashes);
pango_font_description_free (style->font_desc);
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
* it to a particular visual and colormap. The process may
* involve the creation of a new style if the style has already
* been attached to a window with a different style and colormap.
- **/
+ *
+ * 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)
return new_style;
}
+/**
+ * gtk_style_detach:
+ * @style: a #GtkStyle
+ *
+ * Detaches a style from a window. If the style is not attached
+ * to any windows anymore, it is unrealized. See gtk_style_attach().
+ *
+ */
void
gtk_style_detach (GtkStyle *style)
{
g_return_if_fail (GTK_IS_STYLE (style));
+ g_return_if_fail (style->attach_count > 0);
style->attach_count -= 1;
if (style->attach_count == 0)
}
}
-/**
- * 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_lookup_color:
* @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.
+ * @color_name: the name of the logical color to look up
+ * @color: the #GdkColor to fill in
+ *
+ * Looks up @color_name in the style's logical color mappings,
+ * filling in @color and returning %TRUE if found, otherwise
+ * returning %FALSE. Do not cache the found mapping, because
+ * it depends on the #GtkStyle and might change when a theme
+ * switch occurs.
+ *
+ * Return value: %TRUE if the mapping was found.
+ *
+ * Since: 2.10
**/
-void
-gtk_draw_hline (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- gint x1,
- gint x2,
- gint y)
+gboolean
+gtk_style_lookup_color (GtkStyle *style,
+ const char *color_name,
+ GdkColor *color)
{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_hline != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_hline (style, window, state_type, NULL, NULL, NULL, x1, x2, y);
-}
+ GtkStylePrivate *priv;
+ GSList *iter;
+ g_return_val_if_fail (GTK_IS_STYLE (style), FALSE);
+ g_return_val_if_fail (color_name != NULL, FALSE);
+ g_return_val_if_fail (color != NULL, FALSE);
-/**
- * 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)
-{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type, NULL, NULL, NULL, y1_, y2_, x);
-}
+ priv = GTK_STYLE_GET_PRIVATE (style);
-/**
- * gtk_draw_shadow:
- * @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
- *
- * Draws a shadow around the given rectangle in @window
- * using the given style and state and shadow type.
- *
- * Deprecated: Use gtk_paint_shadow() instead.
- */
-void
-gtk_draw_shadow (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_shadow != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_shadow (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
-}
+ for (iter = priv->color_hashes; iter != NULL; iter = iter->next)
+ {
+ GHashTable *hash = iter->data;
+ GdkColor *mapping = g_hash_table_lookup (hash, color_name);
-/**
- * gtk_draw_polygon:
- * @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.
- *
- * 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)
-{
- 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);
-}
+ if (mapping)
+ {
+ color->red = mapping->red;
+ color->green = mapping->green;
+ color->blue = mapping->blue;
+ return TRUE;
+ }
+ }
-/**
- * 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);
+ return FALSE;
}
/**
- * gtk_draw_diamond:
+ * gtk_draw_slider:
* @style: a #GtkStyle
- * @window: a #GdkWindow
+ @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
+ * @shadow_type: a shadow
+ * @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
+ * @height: the height of the rectangle in which to draw a slider
+ * @orientation: the orientation to be used
*
- * Draws a diamond in the given rectangle on @window using the given
- * parameters.
- *
- * Deprecated: Use gtk_paint_diamond() instead.
+ * Draws a slider in the given rectangle on @window using the
+ * given style and orientation.
*/
-void
-gtk_draw_diamond (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- gint x,
- gint y,
- gint width,
- gint height)
+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_diamond != NULL);
+ g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_slider != NULL);
- GTK_STYLE_GET_CLASS (style)->draw_diamond (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
+ GTK_STYLE_GET_CLASS (style)->draw_slider (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
}
/**
- * gtk_draw_string:
+ * gtk_draw_layout:
* @style: a #GtkStyle
* @window: a #GdkWindow
* @state_type: a state
+ * @use_text: whether to use the text or foreground
+ * graphics context of @style
* @x: x origin
* @y: y origin
- * @string: the string to draw
+ * @layout: the layout to draw
*
- * Draws a text string on @window with the given parameters.
- *
- * Deprecated: Use gtk_paint_layout() instead.
+ * Draws a layout on @window using the given parameters.
*/
void
-gtk_draw_string (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- gint x,
- gint y,
- const gchar *string)
+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_string != NULL);
+ g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL);
- GTK_STYLE_GET_CLASS (style)->draw_string (style, window, state_type, NULL, NULL, NULL, x, y, string);
+ GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type, use_text,
+ NULL, NULL, NULL,
+ x, y, layout);
}
/**
- * gtk_draw_box:
+ * gtk_style_set_background:
* @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.
+ * Sets the background of @window to the background color or pixmap
+ * specified by @style for the given state.
*/
void
-gtk_draw_box (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- gint x,
- gint y,
- gint width,
- gint height)
+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_box != NULL);
+ g_return_if_fail (window != NULL);
- GTK_STYLE_GET_CLASS (style)->draw_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
+ GTK_STYLE_GET_CLASS (style)->set_background (style, window, state_type);
}
-/**
- * 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)
+/* Default functions */
+static GtkStyle *
+gtk_style_real_clone (GtkStyle *style)
{
- 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);
-}
-
-/**
- * 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);
-}
-
-/**
- * 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);
-}
-
-/**
- * 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);
-}
-
-/**
- * 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);
-}
-
-/**
- * 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);
-}
-
-/**
- * gtk_draw_extension:
- * @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.
- *
- * 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
- *
- * Draws a focus indicator around the given rectangle on @window using the
- * given style.
- *
- * Deprecated: Use gtk_paint_focus() instead.
- */
-void
-gtk_draw_focus (GtkStyle *style,
- GdkWindow *window,
- 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);
-
- GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, GTK_STATE_NORMAL, NULL, NULL, NULL, x, y, width, height);
-}
-
-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 GTK_STYLE (g_object_new (G_OBJECT_TYPE (style), NULL));
+ return g_object_new (G_OBJECT_TYPE (style), NULL);
}
static void
gtk_style_real_copy (GtkStyle *style,
GtkStyle *src)
{
+ GtkStylePrivate *priv = GTK_STYLE_GET_PRIVATE (style);
+ GtkStylePrivate *src_priv = GTK_STYLE_GET_PRIVATE (src);
gint i;
for (i = 0; i < 5; i++)
style->ythickness = src->ythickness;
if (style->rc_style)
- gtk_rc_style_unref (style->rc_style);
+ g_object_unref (style->rc_style);
style->rc_style = src->rc_style;
if (src->rc_style)
- gtk_rc_style_ref (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);
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 */
if (rc_style->ythickness >= 0)
style->ythickness = rc_style->ythickness;
- if (rc_style->icon_factories)
- {
- GSList *iter;
+ style->icon_factories = g_slist_copy (rc_style->icon_factories);
+ g_slist_foreach (style->icon_factories, (GFunc) g_object_ref, NULL);
- style->icon_factories = g_slist_copy (rc_style->icon_factories);
-
- iter = style->icon_factories;
- while (iter != NULL)
- {
- g_object_ref (iter->data);
- iter = g_slist_next (iter);
- }
- }
+ 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
return val1->widget_type < val2->widget_type ? -1 : 1;
}
+/**
+ * gtk_style_get_style_property:
+ * @style: a #GtkStyle
+ * @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
+ *
+ * Queries the value of a style property corresponding to a
+ * widget class is in the given style.
+ *
+ * Since: 2.16
+ */
+void
+gtk_style_get_style_property (GtkStyle *style,
+ GType widget_type,
+ const gchar *property_name,
+ GValue *value)
+{
+ 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_style_get_valist:
+ * @style: a #GtkStyle
+ * @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.
+ *
+ * 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));
+
+ klass = g_type_class_ref (widget_type);
+
+ property_name = first_property_name;
+ while (property_name)
+ {
+ GParamSpec *pspec;
+ GtkRcPropertyParser parser;
+ const GValue *peek_value;
+ gchar *error;
+
+ pspec = gtk_widget_class_find_style_property (klass, property_name);
+
+ if (!pspec)
+ {
+ g_warning ("%s: widget class `%s' has no property named `%s'",
+ G_STRLOC,
+ g_type_name (widget_type),
+ property_name);
+ break;
+ }
+
+ 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);
+ G_VALUE_LCOPY (peek_value, var_args, 0, &error);
+ if (error)
+ {
+ g_warning ("%s: %s", G_STRLOC, error);
+ g_free (error);
+ break;
+ }
+
+ property_name = va_arg (var_args, gchar*);
+ }
+
+ g_type_class_unref (klass);
+}
+
+/**
+ * gtk_style_get:
+ * @style: a #GtkStyle
+ * @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.
+ *
+ * Gets the values of a multiple style properties for @widget_type
+ * from @style.
+ *
+ * Since: 2.16
+ */
+void
+gtk_style_get (GtkStyle *style,
+ GType widget_type,
+ const gchar *first_property_name,
+ ...)
+{
+ va_list var_args;
+
+ 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*
_gtk_style_peek_property_value (GtkStyle *style,
GType widget_type,
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,
for (i = 0; i < 5; i++)
{
- gtk_style_shade (&style->bg[i], &style->light[i], LIGHTNESS_MULT);
- gtk_style_shade (&style->bg[i], &style->dark[i], DARKNESS_MULT);
-
+ _gtk_style_shade (&style->bg[i], &style->light[i], LIGHTNESS_MULT);
+ _gtk_style_shade (&style->bg[i], &style->dark[i], DARKNESS_MULT);
+
style->mid[i].red = (style->light[i].red + style->dark[i].red) / 2;
style->mid[i].green = (style->light[i].green + style->dark[i].green) / 2;
style->mid[i].blue = (style->light[i].blue + style->dark[i].blue) / 2;
* @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;
}
}
-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 gboolean
+lookup_icon_size (GtkStyle *style,
+ GtkWidget *widget,
+ GtkIconSize size,
+ gint *width,
+ gint *height)
+{
+ GdkScreen *screen;
+ GtkSettings *settings;
+
+ if (widget && gtk_widget_has_screen (widget))
+ {
+ screen = gtk_widget_get_screen (widget);
+ settings = gtk_settings_get_for_screen (screen);
+ }
+ else if (style && style->colormap)
+ {
+ screen = gdk_colormap_get_screen (style->colormap);
+ settings = gtk_settings_get_for_screen (screen);
+ }
+ else
+ {
+ settings = gtk_settings_get_default ();
+ GTK_NOTE (MULTIHEAD,
+ g_warning ("Using the default screen for gtk_default_render_icon()"));
+ }
+
+ return gtk_icon_size_lookup_for_settings (settings, size, width, height);
+}
+
static GdkPixbuf *
gtk_default_render_icon (GtkStyle *style,
const GtkIconSource *source,
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
g_return_val_if_fail (base_pixbuf != NULL, NULL);
- if (widget && gtk_widget_has_screen (widget))
- {
- screen = gtk_widget_get_screen (widget);
- settings = gtk_settings_get_for_screen (screen);
- }
- else if (style && style->colormap)
- {
- screen = gdk_colormap_get_screen (style->colormap);
- settings = gtk_settings_get_for_screen (screen);
- }
- else
- {
- settings = gtk_settings_get_default ();
- GTK_NOTE (MULTIHEAD,
- 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))
+ if (size != (GtkIconSize) -1 && !lookup_icon_size(style, widget, size, &width, &height))
{
g_warning (G_STRLOC ": invalid icon size '%d'", size);
return NULL;
else
stated = scaled;
- return stated;
-}
-
-static void
-sanitize_size (GdkWindow *window,
- gint *width,
- gint *height)
-{
- if ((*width == -1) && (*height == -1))
- gdk_drawable_get_size (window, width, height);
- else if (*width == -1)
- gdk_drawable_get_size (window, width, NULL);
- else if (*height == -1)
- gdk_drawable_get_size (window, NULL, height);
-}
-
-static GdkBitmap *
-get_indicator_for_screen (GdkDrawable *drawable,
- IndicatorPart part)
-
-{
- GdkScreen *screen = gdk_drawable_get_screen (drawable);
- GdkBitmap *bitmap;
- GList *tmp_list;
-
- tmp_list = indicator_parts[part].bmap_list;
- while (tmp_list)
- {
- bitmap = tmp_list->data;
-
- if (gdk_drawable_get_screen (bitmap) == screen)
- return bitmap;
-
- tmp_list = tmp_list->next;
- }
-
- bitmap = gdk_bitmap_create_from_data (drawable,
- (gchar *)indicator_parts[part].bits,
- INDICATOR_PART_SIZE, INDICATOR_PART_SIZE);
- indicator_parts[part].bmap_list = g_list_prepend (indicator_parts[part].bmap_list, bitmap);
-
- return bitmap;
+ return stated;
}
static void
-draw_part (GdkDrawable *drawable,
- GdkGC *gc,
- GdkRectangle *area,
- gint x,
- gint y,
- IndicatorPart part)
+sanitize_size (GdkWindow *window,
+ gint *width,
+ gint *height)
{
- if (area)
- gdk_gc_set_clip_rectangle (gc, area);
-
- gdk_gc_set_ts_origin (gc, x, y);
- gdk_gc_set_stipple (gc, get_indicator_for_screen (drawable, part));
- gdk_gc_set_fill (gc, GDK_STIPPLED);
-
- gdk_draw_rectangle (drawable, gc, TRUE, x, y, INDICATOR_PART_SIZE, INDICATOR_PART_SIZE);
-
- gdk_gc_set_fill (gc, GDK_SOLID);
-
- if (area)
- gdk_gc_set_clip_rectangle (gc, NULL);
+ if ((*width == -1) && (*height == -1))
+ gdk_drawable_get_size (window, width, height);
+ else if (*width == -1)
+ gdk_drawable_get_size (window, width, NULL);
+ else if (*height == -1)
+ gdk_drawable_get_size (window, NULL, height);
}
static void
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;
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;
gint thickness_dark;
gint i;
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
if (shadow_type == GTK_SHADOW_IN)
{
- if (detail && (strcmp (detail, "buttondefault") == 0))
+ if (detail && strcmp (detail, "buttondefault") == 0)
{
sanitize_size (window, &width, &height);
x, y, width, height);
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,
}
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)
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:
static void
draw_arrow (GdkWindow *window,
- GdkGC *gc,
+ GdkColor *color,
GdkRectangle *area,
GtkArrowType arrow_type,
gint x,
gint width,
gint height)
{
- gint i, j;
-
+ cairo_t *cr = gdk_cairo_create (window);
+ gdk_cairo_set_source_color (cr, color);
+
if (area)
- gdk_gc_set_clip_rectangle (gc, area);
-
+ {
+ gdk_cairo_rectangle (cr, area);
+ cairo_clip (cr);
+ }
+
if (arrow_type == GTK_ARROW_DOWN)
{
- for (i = 0, j = 0; i < height; i++, j++)
- gdk_draw_line (window, gc, x + j, y + i, x + width - j - 1, y + i);
+ cairo_move_to (cr, x, y);
+ cairo_line_to (cr, x + width, y);
+ cairo_line_to (cr, x + width / 2., y + height);
}
else if (arrow_type == GTK_ARROW_UP)
{
- for (i = height - 1, j = 0; i >= 0; i--, j++)
- gdk_draw_line (window, gc, x + j, y + i, x + width - j - 1, y + i);
+ cairo_move_to (cr, x, y + height);
+ cairo_line_to (cr, x + width / 2., y);
+ cairo_line_to (cr, x + width, y + height);
}
else if (arrow_type == GTK_ARROW_LEFT)
{
- for (i = width - 1, j = 0; i >= 0; i--, j++)
- gdk_draw_line (window, gc, x + i, y + j, x + i, y + height - j - 1);
+ cairo_move_to (cr, x + width, y);
+ cairo_line_to (cr, x + width, y + height);
+ cairo_line_to (cr, x, y + height / 2.);
}
else if (arrow_type == GTK_ARROW_RIGHT)
{
- for (i = 0, j = 0; i < width; i++, j++)
- gdk_draw_line (window, gc, x + i, y + j, x + i, y + height - j - 1);
+ cairo_move_to (cr, x, y);
+ cairo_line_to (cr, x + width, y + height / 2.);
+ cairo_line_to (cr, x, y + height);
}
- if (area)
- gdk_gc_set_clip_rectangle (gc, NULL);
+ cairo_close_path (cr);
+ cairo_fill (cr);
+
+ cairo_destroy (cr);
}
static void
gint width,
gint height)
{
- gint original_width, original_x;
-
sanitize_size (window, &width, &height);
- original_width = width;
- original_x = x;
-
calculate_arrow_geometry (arrow_type, &x, &y, &width, &height);
if (detail && strcmp (detail, "menu_scroll_arrow_up") == 0)
y++;
if (state == GTK_STATE_INSENSITIVE)
- draw_arrow (window, style->white_gc, area, arrow_type,
+ draw_arrow (window, &style->white, area, arrow_type,
x + 1, y + 1, width, height);
- draw_arrow (window, style->fg_gc[state], area, arrow_type,
+ draw_arrow (window, &style->fg[state], area, arrow_type,
x, y, width, height);
}
GdkGC *inner_sw = NULL;
GdkGC *inner_se = NULL;
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
sanitize_size (window, &width, &height);
half_width = width / 2;
gint y,
const gchar *string)
{
- GdkDisplay *display;
-
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
- display = gdk_drawable_get_display (window);
-
if (area)
{
gdk_gc_set_clip_rectangle (style->white_gc, area);
{
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)
{
{
GdkGC *gc = style->bg_gc[state_type];
- if (state_type == GTK_STATE_SELECTED && strcmp (detail, "paned") == 0)
+ if (state_type == GTK_STATE_SELECTED && detail && strcmp (detail, "paned") == 0)
{
- if (!GTK_WIDGET_HAS_FOCUS (widget))
+ if (widget && !gtk_widget_has_focus (widget))
gc = style->base_gc[GTK_STATE_ACTIVE];
}
}
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)
}
}
-static GdkGC*
-get_darkened_gc (GdkWindow *window,
- GdkColor *color,
- gint darken_count)
+static GdkGC *
+get_darkened_gc (GdkWindow *window,
+ const GdkColor *color,
+ gint darken_count)
{
GdkColor src = *color;
GdkColor shaded = *color;
while (darken_count)
{
- gtk_style_shade (&src, &shaded, 0.93);
+ _gtk_style_shade (&src, &shaded, 0.93);
src = shaded;
--darken_count;
}
GdkGC *gc1;
GdkGC *freeme = NULL;
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
sanitize_size (window, &width, &height);
if (detail)
{
if (!strcmp ("text", detail))
gc1 = style->bg_gc[GTK_STATE_SELECTED];
- else if (!strncmp ("cell_even", detail, strlen ("cell_even")) ||
- !strncmp ("cell_odd", detail, strlen ("cell_odd")))
+ else if (!strcmp ("cell_even", detail) ||
+ !strcmp ("cell_odd", 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))
+ if (widget && gtk_widget_has_focus (widget))
gc1 = style->base_gc[state_type];
- else
- gc1 = style->base_gc[GTK_STATE_ACTIVE];
+ else
+ gc1 = style->base_gc[GTK_STATE_ACTIVE];
}
+ else if (!strcmp ("cell_odd_ruled", detail) ||
+ !strcmp ("cell_odd_ruled_sorted", detail))
+ {
+ if (widget && gtk_widget_has_focus (widget))
+ freeme = get_darkened_gc (window, &style->base[state_type], 1);
+ else
+ freeme = get_darkened_gc (window, &style->base[GTK_STATE_ACTIVE], 1);
+ gc1 = freeme;
+ }
else
{
gc1 = style->bg_gc[state_type];
GdkColor *color = NULL;
gtk_widget_style_get (widget,
- "even_row_color", &color,
+ "even-row-color", &color,
NULL);
if (color)
}
else if (!strcmp ("cell_odd_ruled", detail))
{
- GdkColor *color;
+ GdkColor *color = NULL;
gtk_widget_style_get (widget,
- "odd_row_color", &color,
+ "odd-row-color", &color,
NULL);
if (color)
else
{
gtk_widget_style_get (widget,
- "even_row_color", &color,
+ "even-row-color", &color,
NULL);
if (color)
if (!strcmp ("cell_odd_sorted", detail))
gtk_widget_style_get (widget,
- "odd_row_color", &color,
+ "odd-row-color", &color,
NULL);
else
gtk_widget_style_get (widget,
- "even_row_color", &color,
+ "even-row-color", &color,
NULL);
if (color)
GdkColor *color = NULL;
gtk_widget_style_get (widget,
- "odd_row_color", &color,
+ "odd-row-color", &color,
NULL);
if (color)
else
{
gtk_widget_style_get (widget,
- "even_row_color", &color,
+ "even-row-color", &color,
NULL);
if (color)
}
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);
g_object_unref (freeme);
}
-static GdkGC *
-create_aa_gc (GdkWindow *window, GtkStyle *style, GtkStateType state_type)
-{
- GdkColor aa_color;
- GdkGC *gc = gdk_gc_new (window);
-
- aa_color.red = (style->fg[state_type].red + style->bg[state_type].red) / 2;
- aa_color.green = (style->fg[state_type].green + style->bg[state_type].green) / 2;
- aa_color.blue = (style->fg[state_type].blue + style->bg[state_type].blue) / 2;
-
- gdk_gc_set_rgb_fg_color (gc, &aa_color);
-
- return gc;
-}
-
static void
gtk_default_draw_check (GtkStyle *style,
GdkWindow *window,
gint width,
gint height)
{
- if (detail && strcmp (detail, "cellcheck") == 0)
- {
- if (area)
- gdk_gc_set_clip_rectangle (widget->style->base_gc[state_type], area);
- gdk_draw_rectangle (window,
- widget->style->base_gc[state_type],
- TRUE,
- x, y,
- width, height);
- if (area)
- {
- gdk_gc_set_clip_rectangle (widget->style->base_gc[state_type], NULL);
- gdk_gc_set_clip_rectangle (widget->style->text_gc[state_type], area);
- }
- gdk_draw_rectangle (window,
- widget->style->text_gc[state_type],
- FALSE,
- x, y,
- width, height);
- if (area)
- gdk_gc_set_clip_rectangle (widget->style->text_gc[state_type], NULL);
-
- x -= (1 + INDICATOR_PART_SIZE - width) / 2;
- y -= (((1 + INDICATOR_PART_SIZE - height) / 2) - 1);
- if (shadow_type == GTK_SHADOW_IN)
- {
- draw_part (window, style->text_gc[state_type], area, x, y, CHECK_TEXT);
- draw_part (window, style->text_aa_gc[state_type], area, x, y, CHECK_AA);
- }
- else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */
- {
- draw_part (window, style->text_gc[state_type], area, x, y, CHECK_INCONSISTENT_TEXT);
- }
- }
- else
+ cairo_t *cr = gdk_cairo_create (window);
+ enum { BUTTON, MENU, CELL } type = BUTTON;
+ int exterior_size;
+ int interior_size;
+ int pad;
+
+ if (detail)
{
- GdkGC *free_me = NULL;
+ if (strcmp (detail, "cellcheck") == 0)
+ type = CELL;
+ else if (strcmp (detail, "check") == 0)
+ type = MENU;
+ }
- GdkGC *base_gc;
- GdkGC *text_gc;
- GdkGC *aa_gc;
+ if (area)
+ {
+ gdk_cairo_rectangle (cr, area);
+ cairo_clip (cr);
+ }
+
+ exterior_size = MIN (width, height);
+ if (exterior_size % 2 == 0) /* Ensure odd */
+ exterior_size -= 1;
- x -= (1 + INDICATOR_PART_SIZE - width) / 2;
- y -= (1 + INDICATOR_PART_SIZE - height) / 2;
+ pad = style->xthickness + MAX (1, (exterior_size - 2 * style->xthickness) / 9);
+ interior_size = MAX (1, exterior_size - 2 * pad);
- if (strcmp (detail, "check") == 0) /* Menu item */
- {
- text_gc = style->fg_gc[state_type];
- base_gc = style->bg_gc[state_type];
- aa_gc = free_me = create_aa_gc (window, style, state_type);
- }
+ if (interior_size < 7)
+ {
+ interior_size = 7;
+ pad = MAX (0, (exterior_size - interior_size) / 2);
+ }
+
+ x -= (1 + exterior_size - width) / 2;
+ y -= (1 + exterior_size - height) / 2;
+
+ switch (type)
+ {
+ case BUTTON:
+ case CELL:
+ if (type == BUTTON)
+ gdk_cairo_set_source_color (cr, &style->fg[state_type]);
else
- {
- if (state_type == GTK_STATE_ACTIVE)
- {
- text_gc = style->fg_gc[state_type];
- base_gc = style->bg_gc[state_type];
- aa_gc = free_me = create_aa_gc (window, style, state_type);
- }
- else
- {
- text_gc = style->text_gc[state_type];
- base_gc = style->base_gc[state_type];
- aa_gc = style->text_aa_gc[state_type];
- }
+ gdk_cairo_set_source_color (cr, &style->text[state_type]);
+
+ cairo_set_line_width (cr, 1.0);
+ cairo_rectangle (cr, x + 0.5, y + 0.5, exterior_size - 1, exterior_size - 1);
+ cairo_stroke (cr);
- draw_part (window, base_gc, area, x, y, CHECK_BASE);
- draw_part (window, style->black_gc, area, x, y, CHECK_BLACK);
- draw_part (window, style->dark_gc[state_type], area, x, y, CHECK_DARK);
- draw_part (window, style->mid_gc[state_type], area, x, y, CHECK_MID);
- draw_part (window, style->light_gc[state_type], area, x, y, CHECK_LIGHT);
- }
+ gdk_cairo_set_source_color (cr, &style->base[state_type]);
+ cairo_rectangle (cr, x + 1, y + 1, exterior_size - 2, exterior_size - 2);
+ cairo_fill (cr);
+ break;
- if (shadow_type == GTK_SHADOW_IN)
- {
- draw_part (window, text_gc, area, x, y, CHECK_TEXT);
- draw_part (window, aa_gc, area, x, y, CHECK_AA);
- }
- else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */
- {
- draw_part (window, text_gc, area, x, y, CHECK_INCONSISTENT_TEXT);
- }
+ case MENU:
+ break;
+ }
+
+ switch (type)
+ {
+ case BUTTON:
+ case CELL:
+ gdk_cairo_set_source_color (cr, &style->text[state_type]);
+ break;
+ case MENU:
+ gdk_cairo_set_source_color (cr, &style->fg[state_type]);
+ break;
+ }
+
+ if (shadow_type == GTK_SHADOW_IN)
+ {
+ cairo_translate (cr,
+ x + pad, y + pad);
+
+ cairo_scale (cr, interior_size / 7., interior_size / 7.);
+
+ cairo_move_to (cr, 7.0, 0.0);
+ cairo_line_to (cr, 7.5, 1.0);
+ cairo_curve_to (cr, 5.3, 2.0,
+ 4.3, 4.0,
+ 3.5, 7.0);
+ cairo_curve_to (cr, 3.0, 5.7,
+ 1.3, 4.7,
+ 0.0, 4.7);
+ cairo_line_to (cr, 0.2, 3.5);
+ cairo_curve_to (cr, 1.1, 3.5,
+ 2.3, 4.3,
+ 3.0, 5.0);
+ cairo_curve_to (cr, 1.0, 3.9,
+ 2.4, 4.1,
+ 3.2, 4.9);
+ cairo_curve_to (cr, 3.5, 3.1,
+ 5.2, 2.0,
+ 7.0, 0.0);
+
+ cairo_fill (cr);
+ }
+ else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */
+ {
+ int line_thickness = MAX (1, (3 + interior_size * 2) / 7);
- if (free_me)
- g_object_unref (free_me);
+ cairo_rectangle (cr,
+ x + pad,
+ y + pad + (1 + interior_size - line_thickness) / 2,
+ interior_size,
+ line_thickness);
+ cairo_fill (cr);
}
+
+ cairo_destroy (cr);
}
static void
gint width,
gint height)
{
- if (detail && strcmp (detail, "cellradio") == 0)
- {
- if (area)
- gdk_gc_set_clip_rectangle (widget->style->fg_gc[state_type], area);
- gdk_draw_arc (window,
- widget->style->fg_gc[state_type],
- FALSE,
- x, y,
- width,
- height,
- 0, 360*64);
-
- if (shadow_type == GTK_SHADOW_IN)
- {
- gdk_draw_arc (window,
- widget->style->fg_gc[state_type],
- TRUE,
- x + 2,
- y + 2,
- width - 4,
- height - 4,
- 0, 360*64);
- }
- else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */
- {
- draw_part (window, widget->style->fg_gc[state_type],
- area, x, y, CHECK_INCONSISTENT_TEXT);
- }
- if (area)
- gdk_gc_set_clip_rectangle (widget->style->fg_gc[state_type], NULL);
+ cairo_t *cr = gdk_cairo_create (window);
+ enum { BUTTON, MENU, CELL } type = BUTTON;
+ int exterior_size;
+
+ if (detail)
+ {
+ if (strcmp (detail, "radio") == 0)
+ type = CELL;
+ else if (strcmp (detail, "option") == 0)
+ type = MENU;
}
- else
+
+ if (area)
+ {
+ gdk_cairo_rectangle (cr, area);
+ cairo_clip (cr);
+ }
+
+ exterior_size = MIN (width, height);
+ if (exterior_size % 2 == 0) /* Ensure odd */
+ exterior_size -= 1;
+
+ x -= (1 + exterior_size - width) / 2;
+ y -= (1 + exterior_size - height) / 2;
+
+ switch (type)
{
- GdkGC *free_me = NULL;
+ case BUTTON:
+ case CELL:
+ gdk_cairo_set_source_color (cr, &style->base[state_type]);
- GdkGC *base_gc;
- GdkGC *text_gc;
- GdkGC *aa_gc;
+ cairo_arc (cr,
+ x + exterior_size / 2.,
+ y + exterior_size / 2.,
+ (exterior_size - 1) / 2.,
+ 0, 2 * G_PI);
- x -= (1 + INDICATOR_PART_SIZE - width) / 2;
- y -= (1 + INDICATOR_PART_SIZE - height) / 2;
+ cairo_fill_preserve (cr);
- if (strcmp (detail, "option") == 0) /* Menu item */
- {
- text_gc = style->fg_gc[state_type];
- base_gc = style->bg_gc[state_type];
- aa_gc = free_me = create_aa_gc (window, style, state_type);
- }
+ if (type == BUTTON)
+ gdk_cairo_set_source_color (cr, &style->fg[state_type]);
else
- {
- if (state_type == GTK_STATE_ACTIVE)
- {
- text_gc = style->fg_gc[state_type];
- base_gc = style->bg_gc[state_type];
- aa_gc = free_me = create_aa_gc (window, style, state_type);
- }
- else
- {
- text_gc = style->text_gc[state_type];
- base_gc = style->base_gc[state_type];
- aa_gc = style->text_aa_gc[state_type];
- }
+ gdk_cairo_set_source_color (cr, &style->text[state_type]);
+
+ cairo_set_line_width (cr, 1.);
+ cairo_stroke (cr);
+ break;
- draw_part (window, base_gc, area, x, y, RADIO_BASE);
- draw_part (window, style->black_gc, area, x, y, RADIO_BLACK);
- draw_part (window, style->dark_gc[state_type], area, x, y, RADIO_DARK);
- draw_part (window, style->mid_gc[state_type], area, x, y, RADIO_MID);
- draw_part (window, style->light_gc[state_type], area, x, y, RADIO_LIGHT);
- }
+ case MENU:
+ break;
+ }
+
+ switch (type)
+ {
+ case BUTTON:
+ gdk_cairo_set_source_color (cr, &style->text[state_type]);
+ break;
+ case CELL:
+ break;
+ case MENU:
+ gdk_cairo_set_source_color (cr, &style->fg[state_type]);
+ break;
+ }
+
+ if (shadow_type == GTK_SHADOW_IN)
+ {
+ int pad = style->xthickness + MAX (1, 2 * (exterior_size - 2 * style->xthickness) / 9);
+ int interior_size = MAX (1, exterior_size - 2 * pad);
- if (shadow_type == GTK_SHADOW_IN)
+ if (interior_size < 5)
{
- draw_part (window, text_gc, area, x, y, RADIO_TEXT);
+ interior_size = 7;
+ pad = MAX (0, (exterior_size - interior_size) / 2);
}
- else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */
+
+ cairo_arc (cr,
+ x + pad + interior_size / 2.,
+ y + pad + interior_size / 2.,
+ interior_size / 2.,
+ 0, 2 * G_PI);
+ cairo_fill (cr);
+ }
+ else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */
+ {
+ int pad = style->xthickness + MAX (1, (exterior_size - 2 * style->xthickness) / 9);
+ int interior_size = MAX (1, exterior_size - 2 * pad);
+ int line_thickness;
+
+ if (interior_size < 7)
{
- if (strcmp (detail, "option") == 0) /* Menu item */
- {
- draw_part (window, text_gc, area, x, y, CHECK_INCONSISTENT_TEXT);
- }
- else
- {
- draw_part (window, text_gc, area, x, y, RADIO_INCONSISTENT_TEXT);
- draw_part (window, aa_gc, area, x, y, RADIO_INCONSISTENT_AA);
- }
+ interior_size = 7;
+ pad = MAX (0, (exterior_size - interior_size) / 2);
}
- if (free_me)
- g_object_unref (free_me);
+ line_thickness = MAX (1, (3 + interior_size * 2) / 7);
+
+ cairo_rectangle (cr,
+ x + pad,
+ y + pad + (interior_size - line_thickness) / 2.,
+ interior_size,
+ line_thickness);
+ cairo_fill (cr);
}
+
+ cairo_destroy (cr);
}
static void
if (state_type == GTK_STATE_INSENSITIVE)
{
- draw_arrow (window, style->white_gc, area,
+ draw_arrow (window, &style->white, area,
GTK_ARROW_UP, x + 1, y + 1,
indicator_size.width, arrow_height);
- draw_arrow (window, style->white_gc, area,
+ draw_arrow (window, &style->white, area,
GTK_ARROW_DOWN, x + 1, y + arrow_height + ARROW_SPACE + 1,
indicator_size.width, arrow_height);
}
- draw_arrow (window, style->fg_gc[state_type], area,
+ draw_arrow (window, &style->fg[state_type], area,
GTK_ARROW_UP, x, y,
indicator_size.width, arrow_height);
- draw_arrow (window, style->fg_gc[state_type], area,
+ draw_arrow (window, &style->fg[state_type], area,
GTK_ARROW_DOWN, x, y + arrow_height + ARROW_SPACE,
indicator_size.width, arrow_height);
}
GdkGC *gc3 = NULL;
GdkGC *gc4 = NULL;
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
sanitize_size (window, &width, &height);
switch (shadow_type)
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),
+ widget && gtk_widget_get_has_window (widget),
state_type, area, x, y, width, height);
sanitize_size (window, &width, &height);
gdk_draw_line (window, gc2,
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, gc3,
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);
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),
+ widget && gtk_widget_get_has_window (widget),
GTK_STATE_NORMAL, area, x, y, width, height);
sanitize_size (window, &width, &height);
{
case GTK_POS_TOP:
gtk_style_apply_default_background (style, window,
- widget && !GTK_WIDGET_NO_WINDOW (widget),
+ widget && gtk_widget_get_has_window (widget),
state_type, area,
x + style->xthickness,
y,
break;
case GTK_POS_BOTTOM:
gtk_style_apply_default_background (style, window,
- widget && !GTK_WIDGET_NO_WINDOW (widget),
+ widget && gtk_widget_get_has_window (widget),
state_type, area,
x + style->xthickness,
y + style->ythickness,
break;
case GTK_POS_LEFT:
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 + style->ythickness,
break;
case GTK_POS_RIGHT:
gtk_style_apply_default_background (style, window,
- widget && !GTK_WIDGET_NO_WINDOW (widget),
+ widget && gtk_widget_get_has_window (widget),
state_type, area,
x + style->xthickness,
y + style->ythickness,
gint width,
gint height)
{
- GdkPoint points[5];
- GdkGC *gc;
+ cairo_t *cr;
gboolean free_dash_list = FALSE;
gint line_width = 1;
- gint8 *dash_list = "\1\1";
- gint dash_len;
+ gint8 *dash_list = (gint8 *) "\1\1";
if (widget)
{
free_dash_list = TRUE;
}
- sanitize_size (window, &width, &height);
-
- if (detail && !strcmp (detail, "colorwheel_light"))
- gc = style->black_gc;
- else if (detail && !strcmp (detail, "colorwheel_dark"))
- gc = style->white_gc;
- else
- gc = style->fg_gc[state_type];
-
- gdk_gc_set_line_attributes (gc, line_width,
- dash_list[0] ? GDK_LINE_ON_OFF_DASH : GDK_LINE_SOLID,
- GDK_CAP_BUTT, GDK_JOIN_MITER);
-
- if (area)
- gdk_gc_set_clip_rectangle (gc, area);
-
if (detail && !strcmp (detail, "add-mode"))
{
if (free_dash_list)
g_free (dash_list);
-
- dash_list = "\4\4";
+
+ dash_list = (gint8 *) "\4\4";
free_dash_list = FALSE;
}
- points[0].x = x + line_width / 2;
- points[0].y = y + line_width / 2;
- points[1].x = x + width - line_width + line_width / 2;
- points[1].y = y + line_width / 2;
- points[2].x = x + width - line_width + line_width / 2;
- points[2].y = y + height - line_width + line_width / 2;
- points[3].x = x + line_width / 2;
- points[3].y = y + height - line_width + line_width / 2;
- points[4] = points[0];
+ sanitize_size (window, &width, &height);
- if (!dash_list[0])
- {
- gdk_draw_lines (window, gc, points, 5);
- }
+ 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"))
+ cairo_set_source_rgb (cr, 1., 1., 1.);
else
+ gdk_cairo_set_source_color (cr, &style->fg[state_type]);
+
+ cairo_set_line_width (cr, line_width);
+
+ if (dash_list[0])
{
- /* We go through all the pain below because the X rasterization
- * rules don't really work right for dashed lines if you
- * want continuity in segments that go between top/right
- * and left/bottom. For instance, a top left corner
- * with a 1-1 dash is drawn as:
- *
- * X X X
- * X
- *
- * X
- *
- * This is because pixels on the top and left boundaries
- * of polygons are drawn, but not on the bottom and right.
- * So, if you have a line going up that turns the corner
- * and goes right, there is a one pixel shift in the pattern.
- *
- * So, to fix this, we drawn the top and right in one call,
- * then the left and bottom in another call, fixing up
- * the dash offset for the second call ourselves to get
- * continuity at the upper left.
- *
- * It's not perfect since we really should have a join at
- * the upper left and lower right instead of two intersecting
- * lines but that's only really apparent for no-dashes,
- * which (for this reason) are done as one polygon and
- * don't to through this code path.
- */
-
- dash_len = strlen (dash_list);
-
- if (dash_list[0])
- gdk_gc_set_dashes (gc, 0, dash_list, dash_len);
-
- gdk_draw_lines (window, gc, points, 3);
-
- /* We draw this line one farther over than it is "supposed" to
- * because of another rasterization problem ... if two 1 pixel
- * unjoined lines meet at the lower right, there will be a missing
- * pixel.
- */
- points[2].x += 1;
-
- if (dash_list[0])
+ gint n_dashes = strlen ((const gchar *) dash_list);
+ gdouble *dashes = g_new (gdouble, n_dashes);
+ gdouble total_length = 0;
+ gdouble dash_offset;
+ gint i;
+
+ for (i = 0; i < n_dashes; i++)
{
- gint dash_pixels = 0;
- gint i;
-
- /* Adjust the dash offset for the bottom and left so we
- * match up at the upper left.
- */
- for (i = 0; i < dash_len; i++)
- dash_pixels += dash_list[i];
-
- if (dash_len % 2 == 1)
- dash_pixels *= 2;
-
- gdk_gc_set_dashes (gc, dash_pixels - (width + height - 2 * line_width) % dash_pixels, dash_list, dash_len);
+ dashes[i] = dash_list[i];
+ total_length += dash_list[i];
}
+
+ /* The dash offset here aligns the pattern to integer pixels
+ * by starting the dash at the right side of the left border
+ * Negative dash offsets in cairo don't work
+ * (https://bugs.freedesktop.org/show_bug.cgi?id=2729)
+ */
+ dash_offset = - line_width / 2.;
+ while (dash_offset < 0)
+ dash_offset += total_length;
- gdk_draw_lines (window, gc, points + 2, 3);
+ cairo_set_dash (cr, dashes, n_dashes, dash_offset);
+ g_free (dashes);
}
- gdk_gc_set_line_attributes (gc, 0, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
-
if (area)
- gdk_gc_set_clip_rectangle (gc, NULL);
+ {
+ gdk_cairo_rectangle (cr, area);
+ cairo_clip (cr);
+ }
+
+ cairo_rectangle (cr,
+ x + line_width / 2.,
+ y + line_width / 2.,
+ width - line_width,
+ height - line_width);
+ cairo_stroke (cr);
+ cairo_destroy (cr);
if (free_dash_list)
g_free (dash_list);
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,
gint y,
gushort size)
{
-
size = CLAMP (size, 2, 3);
if (size == 2)
GdkRectangle dest;
gint intersect;
- 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, area, widget,
detail, x, y, width, height);
- if (!strcmp (detail, "paned"))
+ if (detail && !strcmp (detail, "paned"))
{
/* we want to ignore the shadow border in paned widgets */
xthick = 0;
ythick = 0;
- if (state_type == GTK_STATE_SELECTED && !GTK_WIDGET_HAS_FOCUS (widget))
+ 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,
- LIGHTNESS_MULT);
+
+ _gtk_style_shade (&style->base[GTK_STATE_ACTIVE], &unfocused_light,
+ LIGHTNESS_MULT);
light_gc = free_me = gdk_gc_new (window);
gdk_gc_set_rgb_fg_color (light_gc, &unfocused_light);
gdk_gc_set_clip_rectangle (light_gc, &dest);
gdk_gc_set_clip_rectangle (dark_gc, &dest);
- if (!strcmp (detail, "paned"))
+ if (detail && !strcmp (detail, "paned"))
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
for (xx = x + width/2 - 15; xx <= x + width/2 + 15; xx += 5)
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);
- }
- }
-
- gdk_gc_set_clip_rectangle (light_gc, NULL);
- gdk_gc_set_clip_rectangle (dark_gc, NULL);
-
- out:
- if (free_me)
- g_object_unref (G_OBJECT (free_me));
-}
-
-static void
-create_expander_affine (gdouble affine[6],
- gint degrees,
- gint expander_size,
- gint x,
- gint y)
-{
- gdouble s, c;
- gdouble width;
- gdouble height;
-
- width = expander_size / 4.0;
- height = expander_size / 2.0;
-
- switch (degrees)
- {
- case 0:
- s = 0.0;
- c = 1.0;
- break;
- case 90:
- s = 1.0;
- c = 0.0;
- break;
- case 180:
- s = 0.0;
- c = -1.0;
- break;
- default:
- s = sin (degrees * G_PI / 180.0);
- c = cos (degrees * G_PI / 180.0);
- break;
+ 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);
+ }
}
-
- affine[0] = c;
- affine[1] = s;
- affine[2] = -s;
- affine[3] = c;
- affine[4] = -width * c - height * -s + x;
- affine[5] = -width * s - height * c + y;
-}
-
-static void
-apply_affine_on_point (double affine[6], GdkPoint *point)
-{
- gdouble x, y;
-
- x = point->x * affine[0] + point->y * affine[2] + affine[4];
- y = point->x * affine[1] + point->y * affine[3] + affine[5];
-
- point->x = floor (x);
- point->y = floor (y);
-}
-static void
-gtk_style_draw_polygon_with_gc (GdkWindow *window, GdkGC *gc, gint line_width,
- gboolean do_fill, GdkPoint *points, gint n_points)
-{
- gdk_gc_set_line_attributes (gc, line_width,
- GDK_LINE_SOLID,
- GDK_CAP_BUTT, GDK_JOIN_MITER);
+ gdk_gc_set_clip_rectangle (light_gc, NULL);
+ gdk_gc_set_clip_rectangle (dark_gc, NULL);
- gdk_draw_polygon (window, gc, do_fill, points, n_points);
- gdk_gc_set_line_attributes (gc, 0, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
+ out:
+ if (free_me)
+ g_object_unref (free_me);
}
static void
gint y,
GtkExpanderStyle expander_style)
{
+#define DEFAULT_EXPANDER_SIZE 12
+
gint expander_size;
- GdkPoint points[3];
- gint i;
- gint line_width, o;
- gdouble affine[6];
+ gint line_width;
+ double vertical_overshoot;
+ int diameter;
+ double radius;
+ double interp; /* interpolation factor for center position */
+ double x_double_horz, y_double_horz;
+ double x_double_vert, y_double_vert;
+ double x_double, y_double;
gint degrees = 0;
- gtk_widget_style_get (widget,
- "expander-size", &expander_size,
- NULL);
- line_width = MAX (1, expander_size/9);
-
+ cairo_t *cr = gdk_cairo_create (window);
+
if (area)
{
- gdk_gc_set_clip_rectangle (style->fg_gc[GTK_STATE_NORMAL], area);
- gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], area);
+ gdk_cairo_rectangle (cr, area);
+ cairo_clip (cr);
}
- /* a rough estimate of how much the joins of the triangle will overshoot.
- * 2.4 ~ 1 / tan (45 / 2)
- */
- o = ceil (2.4 * line_width / 2.0);
- points[0].x = line_width / 2;
- points[0].y = o;
- points[1].x = expander_size / 2 + line_width / 2 - o;
- points[1].y = expander_size / 2;
- points[2].x = line_width / 2;
- points[2].y = expander_size - o;
+ if (widget &&
+ gtk_widget_class_find_style_property (GTK_WIDGET_GET_CLASS (widget),
+ "expander-size"))
+ {
+ gtk_widget_style_get (widget,
+ "expander-size", &expander_size,
+ NULL);
+ }
+ else
+ expander_size = DEFAULT_EXPANDER_SIZE;
+
+ line_width = MAX (1, expander_size/9);
switch (expander_style)
{
case GTK_EXPANDER_COLLAPSED:
degrees = (get_direction (widget) == GTK_TEXT_DIR_RTL) ? 180 : 0;
+ interp = 0.0;
break;
case GTK_EXPANDER_SEMI_COLLAPSED:
degrees = (get_direction (widget) == GTK_TEXT_DIR_RTL) ? 150 : 30;
+ interp = 0.25;
break;
case GTK_EXPANDER_SEMI_EXPANDED:
degrees = (get_direction (widget) == GTK_TEXT_DIR_RTL) ? 120 : 60;
+ interp = 0.75;
break;
case GTK_EXPANDER_EXPANDED:
degrees = 90;
+ interp = 1.0;
break;
default:
g_assert_not_reached ();
}
- create_expander_affine (affine, degrees, expander_size, x, y);
+ /* Compute distance that the stroke extends beyonds the end
+ * of the triangle we draw.
+ */
+ vertical_overshoot = line_width / 2.0 * (1. / tan (G_PI / 8));
+
+ /* For odd line widths, we end the vertical line of the triangle
+ * at a half pixel, so we round differently.
+ */
+ if (line_width % 2 == 1)
+ vertical_overshoot = ceil (0.5 + vertical_overshoot) - 0.5;
+ else
+ vertical_overshoot = ceil (vertical_overshoot);
+
+ /* Adjust the size of the triangle we draw so that the entire stroke fits
+ */
+ diameter = MAX (3, expander_size - 2 * vertical_overshoot);
+
+ /* If the line width is odd, we want the diameter to be even,
+ * and vice versa, so force the sum to be odd. This relationship
+ * makes the point of the triangle look right.
+ */
+ diameter -= (1 - (diameter + line_width) % 2);
+
+ radius = diameter / 2.;
+
+ /* Adjust the center so that the stroke is properly aligned with
+ * the pixel grid. The center adjustment is different for the
+ * horizontal and vertical orientations. For intermediate positions
+ * we interpolate between the two.
+ */
+ x_double_vert = floor (x - (radius + line_width) / 2.) + (radius + line_width) / 2.;
+ y_double_vert = y - 0.5;
+
+ x_double_horz = x - 0.5;
+ y_double_horz = floor (y - (radius + line_width) / 2.) + (radius + line_width) / 2.;
- for (i = 0; i < 3; i++)
- apply_affine_on_point (affine, &points[i]);
+ x_double = x_double_vert * (1 - interp) + x_double_horz * interp;
+ y_double = y_double_vert * (1 - interp) + y_double_horz * interp;
+
+ cairo_translate (cr, x_double, y_double);
+ cairo_rotate (cr, degrees * G_PI / 180);
+
+ cairo_move_to (cr, - radius / 2., - radius);
+ cairo_line_to (cr, radius / 2., 0);
+ cairo_line_to (cr, - radius / 2., radius);
+ cairo_close_path (cr);
+
+ cairo_set_line_width (cr, line_width);
if (state_type == GTK_STATE_PRELIGHT)
- {
- gtk_style_draw_polygon_with_gc (window, style->fg_gc[GTK_STATE_PRELIGHT],
- 1, TRUE, points, 3);
- }
+ gdk_cairo_set_source_color (cr,
+ &style->fg[GTK_STATE_PRELIGHT]);
else if (state_type == GTK_STATE_ACTIVE)
- {
- gtk_style_draw_polygon_with_gc (window, style->light_gc[GTK_STATE_ACTIVE],
- 1, TRUE, points, 3);
- gtk_style_draw_polygon_with_gc (window, style->fg_gc[GTK_STATE_NORMAL],
- line_width, FALSE, points, 3);
- }
+ gdk_cairo_set_source_color (cr,
+ &style->light[GTK_STATE_ACTIVE]);
else
- {
- gtk_style_draw_polygon_with_gc (window, style->base_gc[GTK_STATE_NORMAL],
- 1, TRUE, points, 3);
- gtk_style_draw_polygon_with_gc (window, style->fg_gc[GTK_STATE_NORMAL],
- line_width, FALSE, points, 3);
- }
- if (area)
- {
- gdk_gc_set_clip_rectangle (style->fg_gc[GTK_STATE_NORMAL], NULL);
- gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], NULL);
- }
+ gdk_cairo_set_source_color (cr,
+ &style->base[GTK_STATE_NORMAL]);
+
+ cairo_fill_preserve (cr);
+
+ gdk_cairo_set_source_color (cr, &style->fg[state_type]);
+ cairo_stroke (cr);
+
+ cairo_destroy (cr);
}
typedef struct _ByteRange ByteRange;
gboolean need_stipple = FALSE;
ByteRange *br;
- run = pango_layout_iter_get_run (iter);
+ run = pango_layout_iter_get_run_readonly (iter);
if (run)
{
PangoLayout *layout)
{
GdkGC *gc;
-
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
gc = use_text ? style->text_gc[state_type] : style->fg_gc[state_type];
GdkPoint points[4];
gint i, j, skip;
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
if (area)
{
gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
}
static void
-gtk_style_shade (GdkColor *a,
- GdkColor *b,
- gdouble k)
+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++)
+ {
+ 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 (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
- * @widget: the widget
- * @detail: a style detail
+ * @area: (allow-none): rectangle to which the output is clipped, or %NULL if the
+ * output should not be clipped
+ * @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);
-
- GTK_STYLE_GET_CLASS (style)->draw_hline (style, window, state_type, area, widget, detail, x1, x2, y);
+ g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
+
+ 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
- * @widget: the widget
- * @detail: a style detail
+ * @area: (allow-none): rectangle to which the output is clipped, or %NULL if the
+ * output should not be clipped
+ * @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);
-
- GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type, area, widget, detail, y1_, y2_, x);
+ g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
+
+ 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
- * @widget: the widget
- * @detail: a style detail
+ * @area: (allow-none): clip rectangle or %NULL if the
+ * output should not be clipped
+ * @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);
-
- GTK_STYLE_GET_CLASS (style)->draw_shadow (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+ g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
+
+ 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: type of shadow to draw
- * @area: clip rectangle
- * @widget: the widget
- * @detail: a style detail
+ * @area: (allow-none): clip rectangle, or %NULL if the
+ * output should not be clipped
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
* @points: an array of #GdkPoint<!-- -->s
- * @npoints: length of @points
+ * @n_points: 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)
+gtk_paint_polygon (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GtkShadowType shadow_type,
+ const GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ const GdkPoint *points,
+ gint n_points,
+ gboolean fill)
{
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, area, widget, detail, points, npoints, fill);
+ g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
+
+ GTK_STYLE_GET_CLASS (style)->draw_polygon (style, window, state_type, shadow_type,
+ (GdkRectangle *) area, widget, detail,
+ (GdkPoint *) points, n_points, fill);
}
/**
* @window: a #GdkWindow
* @state_type: a state
* @shadow_type: the type of shadow to draw
- * @area: clip rectangle
- * @widget: the widget
- * @detail: a style detail
+ * @area: (allow-none): clip rectangle, or %NULL if the
+ * output should not be clipped
+ * @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);
-
- GTK_STYLE_GET_CLASS (style)->draw_arrow (style, window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height);
+ g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
+
+ 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
- * @widget: the widget
- * @detail: a style detail
+ * @area: (allow-none): clip rectangle, or %NULL if the
+ * output should not be clipped
+ * @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);
-
- GTK_STYLE_GET_CLASS (style)->draw_diamond (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
-}
+ g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-/**
- * gtk_paint_string:
- * @style: a #GtkStyle
- * @window: a #GdkWindow
- * @state_type: a state
- * @area: clip rectangle
- * @widget: the widget
- * @detail: a style detail
- * @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);
-
- 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
- * @widget: the widget
- * @detail: a style detail
+ * @area: (allow-none): clip rectangle, or %NULL if the
+ * output should not be clipped
+ * @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);
-
- GTK_STYLE_GET_CLASS (style)->draw_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+ g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
+
+ 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
- * @widget: the widget
- * @detail: a style detail
+ * @area: (allow-none): clip rectangle, or %NULL if the
+ * output should not be clipped
+ * @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);
-
- GTK_STYLE_GET_CLASS (style)->draw_flat_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+ 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,
+ (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
- * @widget: the widget
- * @detail: a style detail
+ * @area: (allow-none): clip rectangle, or %NULL if the
+ * output should not be clipped
+ * @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);
-
- GTK_STYLE_GET_CLASS (style)->draw_check (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+ g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
+
+ 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
- * @widget: the widget
- * @detail: a style detail
+ * @area: (allow-none): clip rectangle, or %NULL if the
+ * output should not be clipped
+ * @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);
-
- GTK_STYLE_GET_CLASS (style)->draw_option (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+ g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
+
+ 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
- * @widget: the widget
- * @detail: a style detail
+ * @area: (allow-none): clip rectangle, or %NULL if the
+ * output should not be clipped
+ * @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);
-
- GTK_STYLE_GET_CLASS (style)->draw_tab (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+ g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
+
+ 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
- * @widget: the widget
- * @detail: a style detail
+ * @area: (allow-none): clip rectangle, or %NULL if the
+ * output should not be clipped
+ * @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);
-
- 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);
+ 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,
+ (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
- * @widget: the widget
- * @detail: a style detail
+ * @area: (allow-none): clip rectangle, or %NULL if the
+ * output should not be clipped
+ * @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);
-
- 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);
+ 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,
+ (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
- * @widget: the widget
- * @detail: a style detail
+ * @area: (allow-none): clip rectangle, or %NULL if the
+ * output should not be clipped
+ * @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);
-
- GTK_STYLE_GET_CLASS (style)->draw_extension (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side);
+ g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
+
+ 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
- * @widget: the widget
- * @detail: a style detail
+ * @area: (allow-none): clip rectangle, or %NULL if the
+ * output should not be clipped
+ * @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);
-
- GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, state_type, area, widget, detail, x, y, width, height);
+ g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
+
+ GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, state_type,
+ (GdkRectangle *) area, widget, detail,
+ x, y, width, height);
}
+/**
+ * gtk_paint_slider:
+ * @style: a #GtkStyle
+ * @window: a #GdkWindow
+ * @state_type: a state
+ * @shadow_type: a shadow
+ * @area: (allow-none): clip rectangle, or %NULL if the
+ * output should not be clipped
+ * @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
+ * @height: the height of the rectangle in which to draw a slider
+ * @orientation: the orientation to be used
+ *
+ * Draws a slider in the given rectangle on @window using the
+ * 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);
-
- GTK_STYLE_GET_CLASS (style)->draw_slider (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
+ g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
+
+ 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
- * @widget: the widget
- * @detail: a style detail
+ * @area: (allow-none): clip rectangle, or %NULL if the
+ * output should not be clipped
+ * @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);
-
- GTK_STYLE_GET_CLASS (style)->draw_handle (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
+ g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
+
+ 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
- * @widget: the widget
- * @detail: a style detail
+ * @area: (allow-none): clip rectangle, or %NULL if the
+ * output should not be clipped
+ * @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
+ * @expander_style: the style to draw the expander in; determines
+ * whether the expander is collapsed, expanded, or in an
+ * intermediate state.
*
- * Draws an expander as used in #GtkTreeView.
+ * Draws an expander as used in #GtkTreeView. @x and @y specify the
+ * center the expander. The size of the expander is determined by the
+ * "expander-size" style property of @widget. (If widget is not
+ * specified or doesn't have an "expander-size" property, an
+ * unspecified default size will be used, since the caller doesn't
+ * have sufficient information to position the expander, this is
+ * likely not useful.) The expander is expander_size pixels tall
+ * in the collapsed position and expander_size pixels wide in the
+ * 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);
-
- GTK_STYLE_GET_CLASS (style)->draw_expander (style, window, state_type, area,
- widget, detail, x, y, expander_style);
+ g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
+
+ GTK_STYLE_GET_CLASS (style)->draw_expander (style, window, state_type,
+ (GdkRectangle *) area, widget, detail,
+ x, y, expander_style);
}
+/**
+ * gtk_paint_layout:
+ * @style: a #GtkStyle
+ * @window: a #GdkWindow
+ * @state_type: a state
+ * @use_text: whether to use the text or foreground
+ * graphics context of @style
+ * @area: (allow-none): clip rectangle, or %NULL if the
+ * output should not be clipped
+ * @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);
-
- GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type, use_text, area,
- widget, detail, x, y, layout);
+ g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
+
+ 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
- * @widget: the widget
- * @detail: a style detail
+ * @area: (allow-none): clip rectangle, or %NULL if the
+ * output should not be clipped
+ * @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 (GTK_STYLE_GET_CLASS (style)->draw_resize_grip != NULL);
+ 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_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
+ *
+ * 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)
+{
+ 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_new:
+ *
+ * Allocates a new #GtkBorder structure and initializes its elements to zero.
+ *
+ * Returns: a new empty #GtkBorder. The newly allocated #GtkBorder should be
+ * freed with gtk_border_free()
+ *
+ * Since: 2.14
+ **/
+GtkBorder *
+gtk_border_new (void)
+{
+ return g_slice_new0 (GtkBorder);
+}
+
/**
* gtk_border_copy:
* @border_: a #GtkBorder.
GtkBorder *
gtk_border_copy (const GtkBorder *border)
{
- return (GtkBorder *)g_memdup (border, sizeof (GtkBorder));
+ g_return_val_if_fail (border != NULL, NULL);
+
+ return g_slice_dup (GtkBorder, border);
}
/**
void
gtk_border_free (GtkBorder *border)
{
- g_free (border);
+ g_slice_free (GtkBorder, border);
}
GType
static GType our_type = 0;
if (our_type == 0)
- our_type = g_boxed_type_register_static ("GtkBorder",
+ our_type = g_boxed_type_register_static (I_("GtkBorder"),
(GBoxedCopyFunc) gtk_border_copy,
(GBoxedFreeFunc) gtk_border_free);
return style->private_font;
}
-/**
- * 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().
- **/
-GdkFont *
-gtk_style_get_font (GtkStyle *style)
-{
- g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
-
- return gtk_style_get_font_internal (style);
-}
-
-/**
- * gtk_style_set_font:
- * @style: a #GtkStyle.
- * @font: a #GdkFont, or %NULL to use the #GdkFont corresponding
- * to style->font_desc.
- *
- * 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.
- **/
-void
-gtk_style_set_font (GtkStyle *style,
- GdkFont *font)
-{
- 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;
- }
-}
-
typedef struct _CursorInfo CursorInfo;
struct _CursorInfo
gtk_gc_release (cursor_info->secondary_gc);
g_free (cursor_info);
- g_object_set_data (G_OBJECT (style), "gtk-style-cursor-info", NULL);
+ g_object_set_data (G_OBJECT (style), I_("gtk-style-cursor-info"), NULL);
}
}
static GdkGC *
-make_cursor_gc (GtkWidget *widget,
- const gchar *property_name,
+make_cursor_gc (GtkWidget *widget,
+ const gchar *property_name,
const GdkColor *fallback)
{
GdkGCValues gc_values;
if (!cursor_info)
{
cursor_info = g_new (CursorInfo, 1);
- g_object_set_data (G_OBJECT (widget->style), "gtk-style-cursor-info", cursor_info);
+ 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->for_type = G_TYPE_INVALID;
}
}
+ /* Cursors in text widgets are drawn only in NORMAL state,
+ * so we can use text[GTK_STATE_NORMAL] as text color here */
if (is_primary)
{
if (!cursor_info->primary_gc)
cursor_info->primary_gc = make_cursor_gc (widget,
"cursor-color",
- &widget->style->black);
-
+ &widget->style->text[GTK_STATE_NORMAL]);
+
return cursor_info->primary_gc;
}
else
{
- 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);
-
+ /* text_aa is the average of text and base colors,
+ * in usual black-on-white case it's grey. */
+ &widget->style->text_aa[GTK_STATE_NORMAL]);
+
return cursor_info->secondary_gc;
}
}
+GdkGC *
+_gtk_widget_get_cursor_gc (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+ g_return_val_if_fail (gtk_widget_get_realized (widget), NULL);
+ return get_insertion_cursor_gc (widget, TRUE);
+}
+
+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)
+ {
+ *color = *style_color;
+ gdk_color_free (style_color);
+ }
+ else
+ *color = widget->style->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,
+ GdkDrawable *drawable,
+ GdkGC *gc,
+ const GdkRectangle *location,
+ GtkTextDirection direction,
+ gboolean draw_arrow)
{
gint stem_width;
gint arrow_width;
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().
+ */
+
gtk_widget_style_get (widget, "cursor-aspect-ratio", &cursor_aspect_ratio, NULL);
stem_width = location->height * cursor_aspect_ratio + 1;
/**
* 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;
if (area)
gdk_gc_set_clip_rectangle (gc, NULL);
}
+
+#define __GTK_STYLE_C__
+#include "gtkaliasdef.c"