1 | /* GDK - The GIMP Drawing Kit |
2 | * Copyright (C) 2010, Red Hat, Inc |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Lesser General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2 of the License, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Lesser General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Lesser General Public |
15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
16 | */ |
17 | |
18 | #ifndef __GDK_RGBA_PRIVATE_H__ |
19 | #define __GDK_RGBA_PRIVATE_H__ |
20 | |
21 | #include "gdkrgba.h" |
22 | |
23 | #include <gtk/css/gtkcss.h> |
24 | |
25 | #include "gtk/css/gtkcssparserprivate.h" |
26 | |
27 | #define _GDK_RGBA_DECODE(c) ((unsigned)(((c) >= 'A' && (c) <= 'F') ? ((c)-'A'+10) : \ |
28 | ((c) >= 'a' && (c) <= 'f') ? ((c)-'a'+10) : \ |
29 | ((c) >= '0' && (c) <= '9') ? ((c)-'0') : \ |
30 | -1)) |
31 | #define _GDK_RGBA_SELECT_COLOR(_str, index3, index6) (sizeof(_str) <= 4 ? _GDK_RGBA_DECODE ((_str)[index3]) : _GDK_RGBA_DECODE ((_str)[index6])) |
32 | #define GDK_RGBA(str) ((GdkRGBA) {\ |
33 | ((_GDK_RGBA_SELECT_COLOR(str, 0, 0) << 4) | _GDK_RGBA_SELECT_COLOR(str, 0, 1)) / 255., \ |
34 | ((_GDK_RGBA_SELECT_COLOR(str, 1, 2) << 4) | _GDK_RGBA_SELECT_COLOR(str, 1, 3)) / 255., \ |
35 | ((_GDK_RGBA_SELECT_COLOR(str, 2, 4) << 4) | _GDK_RGBA_SELECT_COLOR(str, 2, 5)) / 255., \ |
36 | ((sizeof(str) % 4 == 1) ? ((_GDK_RGBA_SELECT_COLOR(str, 3, 6) << 4) | _GDK_RGBA_SELECT_COLOR(str, 3, 7)) : 0xFF) / 255. }) |
37 | |
38 | |
39 | gboolean gdk_rgba_parser_parse (GtkCssParser *parser, |
40 | GdkRGBA *rgba); |
41 | |
42 | G_END_DECLS |
43 | |
44 | #endif |
45 | |