[gtk+/gtk-style-context] Add a frame-gap illustration



commit 70cf4d9e369ae17be1dee5972c52505890bca222
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Nov 23 22:55:52 2010 -0500

    Add a frame-gap illustration

 docs/reference/gtk/Makefile.am          |    1 +
 docs/reference/gtk/images/frame-gap.png |  Bin 0 -> 322 bytes
 gtk/gtkstylecontext.c                   |   13 ++++++++---
 tests/styleexamples.c                   |   34 +++++++++++++++++++++++++++++++
 4 files changed, 44 insertions(+), 4 deletions(-)
---
diff --git a/docs/reference/gtk/Makefile.am b/docs/reference/gtk/Makefile.am
index ba12360..02980f0 100644
--- a/docs/reference/gtk/Makefile.am
+++ b/docs/reference/gtk/Makefile.am
@@ -347,6 +347,7 @@ HTML_IMAGES = \
 	$(srcdir)/images/expanders.png					\
 	$(srcdir)/images/background.png					\
 	$(srcdir)/images/frames.png					\
+	$(srcdir)/images/frame-gap.png					\
 	$(srcdir)/images/sliders.png					\
 	$(srcdir)/images/focus.png					\
 	$(srcdir)/images/extensions.png
diff --git a/docs/reference/gtk/images/frame-gap.png b/docs/reference/gtk/images/frame-gap.png
new file mode 100644
index 0000000..3c0caf2
Binary files /dev/null and b/docs/reference/gtk/images/frame-gap.png differ
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 6dac9bd..ff5038d 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -3037,7 +3037,7 @@ gtk_render_arrow (GtkStyleContext *context,
  * <example>
  * <title>Typical background rendering, showing the effect of
  * <parameter>background-image</parameter>,
- * <parameter>border-width</parameter and
+ * <parameter>border-width</parameter> and
  * <parameter>border-radius</parameter></title>
  * <inlinegraphic fileref="background.png" format="PNG"/>
  * </example>
@@ -3320,9 +3320,14 @@ gtk_render_slider (GtkStyleContext *context,
  * @xy1_gap: end coordinate (X or Y depending on @gap_side) for the gap
  *
  * Renders a frame around the rectangle defined by (@x, @y, @width, @height),
- * leaving a gap on one side. @xy0_gap and @xy1_gap will mean X coordinates for
- * %GTK_POS_TOP and %GTK_POS_BOTTOM gap sides, and Y coordinates for %GTK_POS_LEFT
- * and %GTK_POS_RIGHT.
+ * leaving a gap on one side. @xy0_gap and @xy1_gap will mean X coordinates
+ * for %GTK_POS_TOP and %GTK_POS_BOTTOM gap sides, and Y coordinates for
+ * %GTK_POS_LEFT and %GTK_POS_RIGHT.
+ *
+ * <example>
+ * <title>Typical rendering of a frame with a gap</title>
+ * <inlinegraphic fileref="frame-gap.png" format="PNG"/>
+ * </example>
  *
  * Since: 3.0
  **/
diff --git a/tests/styleexamples.c b/tests/styleexamples.c
index 6b65ba8..b20c7e4 100644
--- a/tests/styleexamples.c
+++ b/tests/styleexamples.c
@@ -265,6 +265,38 @@ draw_cb_extension (GtkWidget *widget, cairo_t *cr)
   return TRUE;
 }
 
+static gboolean
+draw_cb_frame_gap (GtkWidget *widget, cairo_t *cr)
+{
+  GtkStyleContext *context;
+  GtkStyleProvider *provider;
+
+  context = gtk_widget_get_style_context (widget);
+
+  gtk_style_context_save (context);
+
+  provider = (GtkStyleProvider *)gtk_css_provider_new ();
+  gtk_css_provider_load_from_data (GTK_CSS_PROVIDER (provider),
+                                   ".frame {\n"
+                                   "   border-style: solid;\n"
+                                   "   border-width: 1;\n"
+                                   "   border-radius: 0;\n"
+                                   "}\n",
+                                   -1, NULL);
+  gtk_style_context_add_provider (context, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+
+  gtk_style_context_add_class (context, "frame");
+  gtk_style_context_set_junction_sides (context, 0);
+  gtk_render_frame_gap (context, cr, 12, 12, 50, 50, GTK_POS_TOP, 15, 35);
+  gtk_style_context_remove_class (context, "frame");
+
+  gtk_style_context_remove_provider (context, provider);
+
+  gtk_style_context_restore (context);
+
+  return TRUE;
+}
+
 static char *what;
 
 static gboolean
@@ -290,6 +322,8 @@ draw_cb (GtkWidget *widget, cairo_t *cr)
     return draw_cb_focus (widget, cr);
   else if (strcmp (what, "extension") == 0)
     return draw_cb_extension (widget, cr);
+  else if (strcmp (what, "frame-gap") == 0)
+    return draw_cb_frame_gap (widget, cr);
 
   return FALSE;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]