00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef GO_COLOR_H
00027 #define GO_COLOR_H
00028
00029 #include <goffice/goffice.h>
00030
00031 G_BEGIN_DECLS
00032
00033 typedef struct {
00034 GOColor color;
00035 char const *name;
00036 } GONamedColor;
00037
00038
00039
00040
00041
00042
00043
00044 #define GO_COLOR_FROM_GDK_RGBA(c) GO_COLOR_FROM_RGBA((int)((c).red * 255.), (int)((c).green * 255.), (int)((c).blue * 255.), (int)((c).alpha * 255.))
00045
00046 #define GO_COLOR_FROM_RGB(r,g,b) ((((guint)(r&0xff))<<24)|(((guint)(g&0xff))<<16)|((guint)(b&0xff)<<8)|0xff)
00047 #define GO_COLOR_FROM_RGBA(r,g,b,a) ((((guint)(r&0xff))<<24)|(((guint)(g&0xff))<<16)|((guint)(b&0xff)<<8)|(guint)(a&0xff))
00048 #define GO_COLOR_WHITE GO_COLOR_FROM_RGB(0xff, 0xff, 0xff)
00049 #define GO_COLOR_BLACK GO_COLOR_FROM_RGB(0x00, 0x00, 0x00)
00050 #define GO_COLOR_RED GO_COLOR_FROM_RGB(0xff, 0x00, 0x00)
00051 #define GO_COLOR_GREEN GO_COLOR_FROM_RGB(0x00, 0xff, 0x00)
00052 #define GO_COLOR_BLUE GO_COLOR_FROM_RGB(0x00, 0x00, 0xff)
00053 #define GO_COLOR_YELLOW GO_COLOR_FROM_RGB(0xff, 0xff, 0x00)
00054 #define GO_COLOR_VIOLET GO_COLOR_FROM_RGB(0xff, 0x00, 0xff)
00055 #define GO_COLOR_CYAN GO_COLOR_FROM_RGB(0x00, 0xff, 0xff)
00056 #define GO_COLOR_GREY(x) GO_COLOR_FROM_RGB(x,x,x)
00057
00058 #define GO_COLOR_UINT_R(x) (((guint)(x))>>24)
00059 #define GO_COLOR_UINT_G(x) ((((guint)(x))>>16)&0xff)
00060 #define GO_COLOR_UINT_B(x) ((((guint)(x))>>8)&0xff)
00061 #define GO_COLOR_UINT_A(x) (((guint)(x))&0xff)
00062 #define GO_COLOR_CHANGE_R(x, r) (((x)&(~(0xff<<24)))|(((r)&0xff)<<24))
00063 #define GO_COLOR_CHANGE_G(x, g) (((x)&(~(0xff<<16)))|(((g)&0xff)<<16))
00064 #define GO_COLOR_CHANGE_B(x, b) (((x)&(~(0xff<<8)))|(((b)&0xff)<<8))
00065 #define GO_COLOR_CHANGE_A(x, a) (((x)&(~0xff))|((a)&0xff))
00066 #define GO_COLOR_TO_RGB(u,r,g,b) \
00067 { (*(r)) = ((u)>>24)&0xff; (*(g)) = ((u)>>16)&0xff; (*(b)) = ((u)>>8)&0xff; }
00068 #define GO_COLOR_TO_RGBA(u,r,g,b,a) \
00069 {GO_COLOR_TO_RGB((u),r,g,b); (*(a)) = (u)&0xff; }
00070 #define GO_COLOR_MONO_INTERPOLATE(v1, v2, t) ((gint)go_rint((v2)*(t)+(v1)*(1-(t))))
00071 #define GO_COLOR_INTERPOLATE(c1, c2, t) \
00072 GO_COLOR_FROM_RGBA( GO_COLOR_MONO_INTERPOLATE(GO_COLOR_UINT_R(c1), GO_COLOR_UINT_R(c2), t), \
00073 GO_COLOR_MONO_INTERPOLATE(GO_COLOR_UINT_G(c1), GO_COLOR_UINT_G(c2), t), \
00074 GO_COLOR_MONO_INTERPOLATE(GO_COLOR_UINT_B(c1), GO_COLOR_UINT_B(c2), t), \
00075 GO_COLOR_MONO_INTERPOLATE(GO_COLOR_UINT_A(c1), GO_COLOR_UINT_A(c2), t) )
00076
00077 #define GO_COLOR_DOUBLE_R(x) (GO_COLOR_UINT_R(x)/255.0)
00078 #define GO_COLOR_DOUBLE_G(x) (GO_COLOR_UINT_G(x)/255.0)
00079 #define GO_COLOR_DOUBLE_B(x) (GO_COLOR_UINT_B(x)/255.0)
00080 #define GO_COLOR_DOUBLE_A(x) (GO_COLOR_UINT_A(x)/255.0)
00081
00082 #define GO_COLOR_TO_CAIRO(x) GO_COLOR_DOUBLE_R(x),GO_COLOR_DOUBLE_G(x),GO_COLOR_DOUBLE_B(x),GO_COLOR_DOUBLE_A(x)
00083
00084 gboolean go_color_from_str (char const *str, GOColor *res);
00085 gchar *go_color_as_str (GOColor color);
00086 PangoAttribute *go_color_to_pango (GOColor color, gboolean is_fore);
00087 #ifdef GOFFICE_WITH_GTK
00088 GdkRGBA *go_color_to_gdk_rgba (GOColor color, GdkRGBA *res);
00089 #endif
00090
00091 G_END_DECLS
00092
00093 #endif