[gtk+/gtk-style-context: 51/276] GtkThemingEngine: Add vmethod to render an extension.
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-style-context: 51/276] GtkThemingEngine: Add vmethod to render an extension.
- Date: Sat, 23 Oct 2010 18:59:23 +0000 (UTC)
commit cb37634cb9bbab25993cc492e58fcfaae0c57cd6
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Mar 27 21:25:33 2010 +0100
GtkThemingEngine: Add vmethod to render an extension.
gtk/gtkthemingengine.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++
gtk/gtkthemingengine.h | 7 ++++
2 files changed, 95 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c
index b95d6de..6a2bd38 100644
--- a/gtk/gtkthemingengine.c
+++ b/gtk/gtkthemingengine.c
@@ -112,6 +112,13 @@ static void gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine,
GtkPositionType gap_side,
gdouble xy0_gap,
gdouble xy1_gap);
+static void gtk_theming_engine_render_extension (GtkThemingEngine *engine,
+ cairo_t *cr,
+ gdouble x,
+ gdouble y,
+ gdouble width,
+ gdouble height,
+ GtkPositionType gap_side);
G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT)
@@ -154,6 +161,7 @@ gtk_theming_engine_class_init (GtkThemingEngineClass *klass)
klass->render_line = gtk_theming_engine_render_line;
klass->render_slider = gtk_theming_engine_render_slider;
klass->render_frame_gap = gtk_theming_engine_render_frame_gap;
+ klass->render_extension = gtk_theming_engine_render_extension;
g_type_class_add_private (object_class, sizeof (GtkThemingEnginePrivate));
}
@@ -1256,5 +1264,85 @@ gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine,
gdk_color_free (bg_color);
}
+static void
+gtk_theming_engine_render_extension (GtkThemingEngine *engine,
+ cairo_t *cr,
+ gdouble x,
+ gdouble y,
+ gdouble width,
+ gdouble height,
+ GtkPositionType gap_side)
+{
+ GtkStateFlags flags;
+ GtkStateType state;
+ GdkColor *bg_color;
+ GdkColor lighter, darker;
+ guint sides;
+
+ cairo_save (cr);
+ flags = gtk_theming_engine_get_state (engine);
+
+ if (flags & GTK_STATE_FLAG_ACTIVE)
+ state = GTK_STATE_ACTIVE;
+ else if (flags & GTK_STATE_FLAG_PRELIGHT)
+ state = GTK_STATE_PRELIGHT;
+ else if (flags & GTK_STATE_FLAG_INSENSITIVE)
+ state = GTK_STATE_INSENSITIVE;
+ else
+ state = GTK_STATE_NORMAL;
+
+ cairo_set_line_width (cr, 1);
+
+ gtk_theming_engine_get (engine, state,
+ "background-color", &bg_color,
+ NULL);
+ color_shade (bg_color, 0.7, &darker);
+ color_shade (bg_color, 1.3, &lighter);
+
+ add_path_rounded_rectangle (cr, 0,
+ SIDE_BOTTOM | SIDE_RIGHT | SIDE_TOP | SIDE_LEFT,
+ x, y, width, height);
+ cairo_close_path (cr);
+
+ gdk_cairo_set_source_color (cr, bg_color);
+ cairo_fill (cr);
+
+ if (gap_side == GTK_POS_RIGHT)
+ sides = SIDE_BOTTOM;
+ else if (gap_side == GTK_POS_BOTTOM)
+ sides = SIDE_RIGHT;
+ else
+ sides = SIDE_BOTTOM | SIDE_RIGHT;
+
+ add_path_rounded_rectangle (cr, 0, sides,
+ x, y, width, height);
+
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_stroke (cr);
+
+ add_path_rounded_rectangle (cr, 0, sides,
+ x, y, width - 1, height - 1);
+
+ gdk_cairo_set_source_color (cr, &darker);
+ cairo_stroke (cr);
+
+ if (gap_side == GTK_POS_LEFT)
+ sides = SIDE_TOP;
+ else if (gap_side == GTK_POS_TOP)
+ sides = SIDE_LEFT;
+ else
+ sides = SIDE_TOP | SIDE_LEFT;
+
+ add_path_rounded_rectangle (cr, 0, sides,
+ x, y, width, height);
+
+ gdk_cairo_set_source_color (cr, &lighter);
+ cairo_stroke (cr);
+
+ cairo_restore (cr);
+
+ gdk_color_free (bg_color);
+}
+
#define __GTK_THEMING_ENGINE_C__
#include "gtkaliasdef.c"
diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h
index d085637..31e7635 100644
--- a/gtk/gtkthemingengine.h
+++ b/gtk/gtkthemingengine.h
@@ -76,6 +76,13 @@ struct GtkThemingEngineClass
GtkPositionType gap_side,
gdouble xy0_gap,
gdouble xy1_gap);
+ void (* render_extension) (GtkThemingEngine *engine,
+ cairo_t *cr,
+ gdouble x,
+ gdouble y,
+ gdouble width,
+ gdouble height,
+ GtkPositionType gap_side);
void (* render_check) (GtkThemingEngine *engine,
cairo_t *cr,
gdouble x,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]