[libcroco-list] Two patches..
- From: Benjamin Dauvergne <feanor-list tol-eressea org>
- To: libcroco <libcroco-list gnome org>
- Subject: [libcroco-list] Two patches..
- Date: Sun, 07 Mar 2004 02:32:01 +0100
These two little patches finish the support for the "color:" property in
libcroco and sewfox.
Index: src/cr-style.c
===================================================================
RCS file: /cvs/gnome/libcroco/src/cr-style.c,v
retrieving revision 1.21
diff -a -u -p -r1.21 cr-style.c
--- src/cr-style.c 29 Feb 2004 00:18:00 -0000 1.21
+++ src/cr-style.c 6 Mar 2004 23:49:22 -0000
@@ -279,7 +279,7 @@ static enum CRStatus
set_prop_width (CRStyle *a_style, CRTerm *a_value) ;
static enum CRStatus
-set_prop_color_rgb (CRStyle *a_style, CRTerm *a_value) ;
+set_prop_color (CRStyle *a_style, CRTerm *a_value) ;
static enum CRStatus
set_prop_background_color (CRStyle *a_style, CRTerm *a_value) ;
@@ -1158,23 +1158,36 @@ set_prop_width (CRStyle *a_style, CRTerm
}
static enum CRStatus
-set_prop_color_rgb (CRStyle *a_style, CRTerm *a_value)
+set_prop_color (CRStyle *a_style, CRTerm *a_value)
{
+ enum CRStatus status = CR_OK ;
g_return_val_if_fail (a_style && a_value,
CR_BAD_PARAM_ERROR) ;
- if (a_value->type == TERM_RGB)
- {
+ switch(a_value->type) {
+ case TERM_RGB:
if (a_value->content.rgb)
{
cr_rgb_set_from_rgb
(&a_style->rgb_props[RGB_PROP_COLOR].sv,
a_value->content.rgb) ;
}
+ break ;
+ case TERM_IDENT:
+ status = cr_rgb_set_from_name
+ (&a_style->rgb_props[RGB_PROP_COLOR].sv,
+ a_value->content.str->str) ;
+ break ;
+ case TERM_HASH:
+ status = cr_rgb_set_from_hex_str
+ (&a_style->rgb_props[RGB_PROP_COLOR].sv,
+ a_value->content.str->str) ;
+ break ;
+ default:
+ status = CR_UNKNOWN_TYPE_ERROR ;
+ }
- }
-
- return CR_OK ;
+ return status ;
}
static enum CRStatus
@@ -2214,7 +2227,7 @@ cr_style_set_style_from_decl (CRStyle *a
break ;
case PROP_ID_COLOR:
- status = set_prop_color_rgb (a_this, value) ;
+ status = set_prop_color (a_this, value) ;
break ;
case PROP_ID_BACKGROUND_COLOR:
Index: src/sx-lay-eng.c
===================================================================
RCS file: /cvs/gnome/sewfox/src/sx-lay-eng.c,v
retrieving revision 1.12
diff -a -u -p -r1.12 sx-lay-eng.c
--- src/sx-lay-eng.c 28 Feb 2004 13:46:56 -0000 1.12
+++ src/sx-lay-eng.c 6 Mar 2004 23:50:08 -0000
@@ -1947,7 +1947,31 @@ sx_lay_eng_style_to_pango_font_attribute
pgo_attr->end_index = a_text_len ;
pango_attr_list_change (a_pgo_attrs, pgo_attr) ;
pgo_attr = NULL ;
-
+ /* Set font color TODO */
+ if ( ! a_style->rgb_props[RGB_PROP_COLOR].cv.is_percentage) {
+ pgo_attr = pango_attr_foreground_new(
+ a_style->rgb_props[RGB_PROP_COLOR].cv.red << 8,
+ a_style->rgb_props[RGB_PROP_COLOR].cv.green << 8,
+ a_style->rgb_props[RGB_PROP_COLOR].cv.blue << 8);
+ } else {
+ guint16 red,green,blue;
+ red = a_style->rgb_props[RGB_PROP_COLOR].cv.red;
+ red = red * 0xFFFF / 100;
+ green = a_style->rgb_props[RGB_PROP_COLOR].cv.green;
+ green = green * 0xFFFF / 100;
+ blue = a_style->rgb_props[RGB_PROP_COLOR].cv.blue;
+ blue = blue * 0xFFFF / 100;
+ pgo_attr = pango_attr_foreground_new(red, green, blue);
+ }
+ if (!pgo_attr)
+ {
+ status = CR_INSTANCIATION_FAILED_ERROR ;
+ goto cleanup ;
+ }
+ pgo_attr->start_index = 0 ;
+ pgo_attr->end_index = a_text_len ;
+ pango_attr_list_change (a_pgo_attrs, pgo_attr) ;
+ pgo_attr = NULL ;
cleanup:
Index: tests/input-files/test-color-0.css
===================================================================
RCS file: /cvs/gnome/sewfox/tests/input-files/test-color-0.css,v
retrieving revision 1.1
diff -a -u -p -r1.1 test-color-0.css
--- tests/input-files/test-color-0.css 2 Mar 2004 18:29:45 -0000 1.1
+++ tests/input-files/test-color-0.css 6 Mar 2004 23:50:08 -0000
@@ -4,7 +4,7 @@ doc {
color-rgb {
display: block;
- color: #ff0;
+ color: #f00;
}
color-rrggbb {
display: block;
Index: tests/input-files/test-color-0.xml
===================================================================
RCS file: /cvs/gnome/sewfox/tests/input-files/test-color-0.xml,v
retrieving revision 1.1
diff -a -u -p -r1.1 test-color-0.xml
--- tests/input-files/test-color-0.xml 2 Mar 2004 18:29:45 -0000 1.1
+++ tests/input-files/test-color-0.xml 6 Mar 2004 23:50:08 -0000
@@ -1,8 +1,8 @@
<doc>
-<color-rgb>is green</color-rgb>
-<color-rrggbb>is green</color-rrggbb>
-<color-integer>is green</color-integer>
-<color-percent>is green</color-percent>
+<color-rgb>is red</color-rgb>
+<color-rrggbb>is red</color-rrggbb>
+<color-integer>is red</color-integer>
+<color-percent>is red</color-percent>
</doc>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]