diff options
author | Havoc Pennington <hp@redhat.com> | 2001-01-26 21:11:13 +0000 |
---|---|---|
committer | Havoc Pennington <hp@src.gnome.org> | 2001-01-26 21:11:13 +0000 |
commit | 2246697fe6b423b8837dcf49e237db8ade8ea2ff (patch) | |
tree | 6b6f12b7ef51fad7139b82d10797b0412da400a8 /pango | |
parent | 0ac9b1e4914f1ff01575fd9889e739a1b14c320a (diff) | |
download | pango-2246697fe6b423b8837dcf49e237db8ade8ea2ff.tar.gz |
take a PangoColor not a PangoAttrColor
2001-01-26 Havoc Pennington <hp@redhat.com>
* pango/pangox.h (PangoGetGCFunc): take a PangoColor not a
PangoAttrColor
* pango/pango-attributes.h: add PangoColor, add PANGO_ATTR_INVALID
as a placeholder for zero in the PangoAttrType enum, corresponds
to G_TYPE_INVALID.
* pango/pango-attributes.c: Add PangoColor type, use for
PangoAttrColor
(pango_color_get_type): new function
(pango_color_copy): new function
(pango_color_free): new function
Diffstat (limited to 'pango')
-rw-r--r-- | pango/pango-attributes.c | 57 | ||||
-rw-r--r-- | pango/pango-attributes.h | 25 | ||||
-rw-r--r-- | pango/pangox.c | 4 | ||||
-rw-r--r-- | pango/pangox.h | 2 |
4 files changed, 74 insertions, 14 deletions
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c index afcd8530..cc72fc30 100644 --- a/pango/pango-attributes.c +++ b/pango/pango-attributes.c @@ -210,7 +210,9 @@ pango_attr_color_copy (const PangoAttribute *attr) const PangoAttrColor *color_attr = (PangoAttrColor *)attr; return pango_attr_color_new (attr->klass, - color_attr->red, color_attr->green, color_attr->blue); + color_attr->color.red, + color_attr->color.green, + color_attr->color.blue); } static void @@ -225,10 +227,10 @@ pango_attr_color_equal (const PangoAttribute *attr1, { const PangoAttrColor *color_attr1 = (const PangoAttrColor *)attr1; const PangoAttrColor *color_attr2 = (const PangoAttrColor *)attr2; - - return (color_attr1->red == color_attr2->red && - color_attr1->blue == color_attr2->blue && - color_attr1->green == color_attr2->green); + + return (color_attr1->color.red == color_attr2->color.red && + color_attr1->color.blue == color_attr2->color.blue && + color_attr1->color.green == color_attr2->color.green); } static PangoAttribute * @@ -239,9 +241,9 @@ pango_attr_color_new (const PangoAttrClass *klass, { PangoAttrColor *result = g_new (PangoAttrColor, 1); result->attr.klass = klass; - result->red = red; - result->green = green; - result->blue = blue; + result->color.red = red; + result->color.green = green; + result->color.blue = blue; return (PangoAttribute *)result; } @@ -1474,3 +1476,42 @@ pango_attr_iterator_get_font (PangoAttrIterator *iterator, } } } + +GType +pango_color_get_type (void) +{ + static GType our_type = 0; + + if (our_type == 0) + { + g_type_init (); + + our_type = g_boxed_type_register_static ("PangoColor", + pango_color_copy, + pango_color_free); + } + + return our_type; +} + +PangoColor* +pango_color_copy (const PangoColor *src) +{ + PangoColor *ret; + + g_return_val_if_fail (src != NULL, NULL); + + ret = g_new (PangoColor, 1); + + *ret = *src; + + return ret; +} + +void +pango_color_free (PangoColor *color) +{ + g_return_if_fail (color != NULL); + + g_free (color); +} diff --git a/pango/pango-attributes.h b/pango/pango-attributes.h index d7859441..59012cc3 100644 --- a/pango/pango-attributes.h +++ b/pango/pango-attributes.h @@ -23,11 +23,31 @@ #define __PANGO_ATTRIBUTES_H__ #include <pango/pango-font.h> +#include <glib-object.h> #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ +/* PangoColor */ + +typedef struct _PangoColor PangoColor; + +struct _PangoColor +{ + guint16 red; + guint16 green; + guint16 blue; +}; + +#define PANGO_TYPE_COLOR pango_color_get_type () +GType pango_color_get_type (void) G_GNUC_CONST; + +PangoColor *pango_color_copy (const PangoColor *src); +void pango_color_free (PangoColor *color); + +/* Attributes */ + typedef struct _PangoAttribute PangoAttribute; typedef struct _PangoAttrClass PangoAttrClass; @@ -43,6 +63,7 @@ typedef struct _PangoAttrIterator PangoAttrIterator; typedef enum { + PANGO_ATTR_INVALID, /* 0 is an invalid attribute type */ PANGO_ATTR_LANG, /* PangoAttrString */ PANGO_ATTR_FAMILY, /* PangoAttrString */ PANGO_ATTR_STYLE, /* PangoAttrInt */ @@ -103,9 +124,7 @@ struct _PangoAttrFloat struct _PangoAttrColor { PangoAttribute attr; - guint16 red; - guint16 green; - guint16 blue; + PangoColor color; }; struct _PangoAttrShape diff --git a/pango/pangox.c b/pango/pangox.c index 3ea6a249..d429ca59 100644 --- a/pango/pangox.c +++ b/pango/pangox.c @@ -1290,7 +1290,7 @@ pango_x_render_layout_line (Display *display, pango_x_get_item_properties (run->item, &uline, &fg_color, &fg_set, &bg_color, &bg_set); if (fg_set && info->get_gc_func) - fg_gc = info->get_gc_func (context, &fg_color, gc); + fg_gc = info->get_gc_func (context, &fg_color.color, gc); else fg_gc = gc; @@ -1303,7 +1303,7 @@ pango_x_render_layout_line (Display *display, if (bg_set && info->get_gc_func) { - GC bg_gc = info->get_gc_func (context, &bg_color, gc); + GC bg_gc = info->get_gc_func (context, &bg_color.color, gc); XFillRectangle (display, drawable, bg_gc, x + (x_off + logical_rect.x) / PANGO_SCALE, diff --git a/pango/pangox.h b/pango/pangox.h index 222fddc2..85dedbe4 100644 --- a/pango/pangox.h +++ b/pango/pangox.h @@ -34,7 +34,7 @@ extern "C" { #define PANGO_RENDER_TYPE_X "PangoRenderX" -typedef GC (*PangoGetGCFunc) (PangoContext *context, PangoAttrColor *color, GC base_gc); +typedef GC (*PangoGetGCFunc) (PangoContext *context, PangoColor *color, GC base_gc); typedef void (*PangoFreeGCFunc) (PangoContext *context, GC gc); /* Calls for applications |