forked from AuroraMiddleware/gtk
Add a background example to the docs
This commit is contained in:
parent
d532c0e5c2
commit
e522381183
@ -345,7 +345,8 @@ HTML_IMAGES = \
|
||||
$(srcdir)/images/checks.png \
|
||||
$(srcdir)/images/options.png \
|
||||
$(srcdir)/images/arrows.png \
|
||||
$(srcdir)/images/expanders.png
|
||||
$(srcdir)/images/expanders.png \
|
||||
$(srcdir)/images/background.png
|
||||
|
||||
# Extra options to supply to gtkdoc-fixref
|
||||
FIXXREF_OPTIONS=--extra-dir=../gdk/html \
|
||||
|
@ -3,6 +3,8 @@
|
||||
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
||||
<!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
|
||||
<!ENTITY version SYSTEM "version.xml">
|
||||
<!ENTITY pi "π">
|
||||
<!ENTITY solidus "⁄">
|
||||
]>
|
||||
<book id="index" xmlns:xi="http://www.w3.org/2003/XInclude">
|
||||
<bookinfo>
|
||||
|
BIN
docs/reference/gtk/images/background.png
Normal file
BIN
docs/reference/gtk/images/background.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
@ -3027,6 +3027,12 @@ gtk_render_arrow (GtkStyleContext *context,
|
||||
*
|
||||
* Renders the background of an element.
|
||||
*
|
||||
* <example>
|
||||
* <title>Typical background rendering, showing the effect of
|
||||
* @border-image, @border-width and @border-radius</title>
|
||||
* <inlinegraphic fileref="background.png" format="PNG"/>
|
||||
* </example>
|
||||
*
|
||||
* Since: 3.0.
|
||||
**/
|
||||
void
|
||||
|
@ -94,6 +94,57 @@ draw_cb_expanders (GtkWidget *widget, cairo_t *cr)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
draw_cb_background (GtkWidget *widget, cairo_t *cr)
|
||||
{
|
||||
GtkStyleProvider *provider;
|
||||
GtkStyleContext *context;
|
||||
|
||||
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),
|
||||
"* {\n"
|
||||
" border-radius: 10;\n"
|
||||
" border-width: 0;\n"
|
||||
" background-image: -gtk-gradient (linear, left top, right bottom, from(#ff00ff), to(#aabbcc));\n"
|
||||
"}\n", -1, NULL);
|
||||
gtk_style_context_add_provider (context, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
gtk_style_context_set_junction_sides (context, 0);
|
||||
gtk_render_background (context, cr, 12, 12, 100, 100);
|
||||
gtk_style_context_remove_provider (context, provider);
|
||||
gtk_style_context_restore (context);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
draw_cb_frame (GtkWidget *widget, cairo_t *cr)
|
||||
{
|
||||
GtkStyleProvider *provider;
|
||||
GtkStyleContext *context;
|
||||
|
||||
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-image: url('gradient1.png') 10 10 10 10 stretch;\n"
|
||||
" border-style; solid\n"
|
||||
"}\n", -1, NULL);
|
||||
gtk_style_context_add_provider (context, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
gtk_style_context_set_junction_sides (context, 0);
|
||||
gtk_render_frame (context, cr, 12, 12, 25, 25);
|
||||
gtk_style_context_remove_provider (context, provider);
|
||||
gtk_style_context_restore (context);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static char *what;
|
||||
|
||||
static gboolean
|
||||
@ -106,7 +157,11 @@ draw_cb (GtkWidget *widget, cairo_t *cr)
|
||||
else if (strcmp (what, "arrow") == 0)
|
||||
return draw_cb_arrows (widget, cr);
|
||||
else if (strcmp (what, "expander") == 0)
|
||||
return draw_cb_expanders (widget ,cr);
|
||||
return draw_cb_expanders (widget, cr);
|
||||
else if (strcmp (what, "background") == 0)
|
||||
return draw_cb_background (widget, cr);
|
||||
else if (strcmp (what, "frame") == 0)
|
||||
return draw_cb_frame (widget, cr);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user