1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ 2 3 /* eel-gdk-extensions.h: Graphics routines to augment what's in gdk. 4 5 Copyright (C) 1999, 2000 Eazel, Inc. 6 7 The Mate Library is free software; you can redistribute it and/or 8 modify it under the terms of the GNU Library General Public License as 9 published by the Free Software Foundation; either version 2 of the 10 License, or (at your option) any later version. 11 12 The Mate Library is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 Library General Public License for more details. 16 17 You should have received a copy of the GNU Library General Public 18 License along with the Mate Library; see the file COPYING.LIB. If not, 19 write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 20 Boston, MA 02110-1301, USA. 21 22 Authors: Darin Adler <darin@eazel.com>, 23 Ramiro Estrugo <ramiro@eazel.com> 24 */ 25 26 #ifndef EEL_GDK_EXTENSIONS_H 27 #define EEL_GDK_EXTENSIONS_H 28 29 #include <gdk/gdk.h> 30 31 #define EEL_RGB_COLOR_RED 0xFF0000 32 #define EEL_RGB_COLOR_GREEN 0x00FF00 33 #define EEL_RGB_COLOR_BLUE 0x0000FF 34 #define EEL_RGB_COLOR_WHITE 0xFFFFFF 35 #define EEL_RGB_COLOR_BLACK 0x000000 36 37 #define EEL_RGBA_COLOR_OPAQUE_RED 0xFFFF0000 38 #define EEL_RGBA_COLOR_OPAQUE_GREEN 0xFF00FF00 39 #define EEL_RGBA_COLOR_OPAQUE_BLUE 0xFF0000FF 40 #define EEL_RGBA_COLOR_OPAQUE_WHITE 0xFFFFFFFF 41 #define EEL_RGBA_COLOR_OPAQUE_BLACK 0xFF000000 42 43 /* Pack RGBA values into 32 bits */ 44 #define EEL_RGBA_COLOR_PACK(r, g, b, a) \ 45 ( (((guint32)a) << 24) | \ 46 (((guint32)r) << 16) | \ 47 (((guint32)g) << 8) | \ 48 (((guint32)b) << 0) ) 49 50 /* Pack opaque RGBA values into 32 bits */ 51 #define EEL_RGB_COLOR_PACK(r, g, b) \ 52 EEL_RGBA_COLOR_PACK((r), (g), (b), 0xFF) 53 54 /* Access the individual RGBA components */ 55 #define EEL_RGBA_COLOR_GET_R(color) (((color) >> 16) & 0xff) 56 #define EEL_RGBA_COLOR_GET_G(color) (((color) >> 8) & 0xff) 57 #define EEL_RGBA_COLOR_GET_B(color) (((color) >> 0) & 0xff) 58 #define EEL_RGBA_COLOR_GET_A(color) (((color) >> 24) & 0xff) 59 60 /* Bits returned by eel_gdk_parse_geometry */ 61 typedef enum 62 { 63 EEL_GDK_NO_VALUE = 0x00, 64 EEL_GDK_X_VALUE = 0x01, 65 EEL_GDK_Y_VALUE = 0x02, 66 EEL_GDK_WIDTH_VALUE = 0x04, 67 EEL_GDK_HEIGHT_VALUE = 0x08, 68 EEL_GDK_ALL_VALUES = 0x0f, 69 EEL_GDK_X_NEGATIVE = 0x10, 70 EEL_GDK_Y_NEGATIVE = 0x20 71 } EelGdkGeometryFlags; 72 73 /* A gradient spec. is a string that contains a specifier for either a 74 color or a gradient. If the string has a "-" in it, then it's a gradient. 75 The gradient is vertical by default and the spec. can end with ":v" to indicate that. 76 If the gradient ends with ":h", the gradient is horizontal. 77 */ 78 char * eel_gradient_new (const char *start_color, 79 const char *end_color, 80 gboolean is_horizontal); 81 char * eel_gradient_parse_one_color_spec (const char *spec, 82 int *percent, 83 const char **next_spec); 84 gboolean eel_gradient_is_gradient (const char *gradient_spec); 85 char * eel_gradient_get_start_color_spec (const char *gradient_spec); 86 char * eel_gradient_get_end_color_spec (const char *gradient_spec); 87 gboolean eel_gradient_is_horizontal (const char *gradient_spec); 88 char * eel_gradient_set_left_color_spec (const char *gradient_spec, 89 const char *left_color); 90 char * eel_gradient_set_top_color_spec (const char *gradient_spec, 91 const char *top_color); 92 char * eel_gradient_set_right_color_spec (const char *gradient_spec, 93 const char *right_color); 94 char * eel_gradient_set_bottom_color_spec (const char *gradient_spec, 95 const char *bottom_color); 96 97 98 /* A version of parse_color that substitutes a default color instead of returning 99 a boolean to indicate it cannot be parsed. 100 */ 101 void eel_gdk_rgba_parse_with_white_default (GdkRGBA *parsed_color, 102 const char *color_spec); 103 104 guint32 eel_rgb16_to_rgb (gushort r, 105 gushort g, 106 gushort b); 107 guint32 eel_gdk_rgba_to_rgb (const GdkRGBA *color); 108 GdkRGBA eel_gdk_rgb_to_rgba (guint32 color); 109 110 char * eel_gdk_rgb_to_color_spec (guint32 color); 111 112 gboolean eel_gdk_rgba_is_dark (const GdkRGBA *color); 113 114 115 /* Wrapper for XParseGeometry */ 116 EelGdkGeometryFlags eel_gdk_parse_geometry (const char *string, 117 int *x_return, 118 int *y_return, 119 guint *width_return, 120 guint *height_return); 121 122 #endif /* EEL_GDK_EXTENSIONS_H */ 123