1 /* 2 * Copyright (c) 2015 Christian Hergert <chergert@gnome.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or (at your 7 * option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, but 10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 12 * License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public License 15 * along with this program; if not, write to the Free Software Foundation, 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 * 18 * Author: Christian Hergert <chergert@gnome.org> 19 * 20 */ 21 22 #ifndef __GTK_TEXT_ATTRIBUTE_PRIVATE_H__ 23 #define __GTK_TEXT_ATTRIBUTE_PRIVATE_H__ 24 25 /* 26 * The following macros are used to store and extract information about the 27 * Pango underline and strikethrough colors in the unused pixel member of 28 * the GdkColor members of GtkTextAppearance. 29 * 30 * In 4.0, we should revisit this. 31 */ 32 33 #define GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET(appr) \ 34 (((guint8*)&(appr)->bg_color)[3] != 0) 35 #define GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA_SET(appr,val) \ 36 G_STMT_START { \ 37 ((guint8*)&(appr)->bg_color)[3] = !!val; \ 38 } G_STMT_END 39 #define GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA(appr,rgba) \ 40 G_STMT_START { \ 41 (rgba)->red = ((guint8*)&(appr)->bg_color)[0] / 255.; \ 42 (rgba)->green = ((guint8*)&(appr)->bg_color)[1] / 255.; \ 43 (rgba)->blue = ((guint8*)&(appr)->bg_color)[2] / 255.; \ 44 (rgba)->alpha = 1.0; \ 45 } G_STMT_END 46 #define GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA(appr,rgba) \ 47 G_STMT_START { \ 48 ((guint8*)&(appr)->bg_color)[0] = (rgba)->red * 255; \ 49 ((guint8*)&(appr)->bg_color)[1] = (rgba)->green * 255; \ 50 ((guint8*)&(appr)->bg_color)[2] = (rgba)->blue * 255; \ 51 } G_STMT_END 52 53 54 #define GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET(appr) \ 55 (((guint8*)&(appr)->fg_color)[3] != 0) 56 #define GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA_SET(appr,val) \ 57 G_STMT_START { \ 58 ((guint8*)&(appr)->fg_color)[3] = !!val; \ 59 } G_STMT_END 60 #define GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA(appr,rgba) \ 61 G_STMT_START { \ 62 (rgba)->red = ((guint8*)&(appr)->fg_color)[0] / 255.; \ 63 (rgba)->green = ((guint8*)&(appr)->fg_color)[1] / 255.; \ 64 (rgba)->blue = ((guint8*)&(appr)->fg_color)[2] / 255.; \ 65 (rgba)->alpha = 1.0; \ 66 } G_STMT_END 67 #define GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA(appr,rgba) \ 68 G_STMT_START { \ 69 ((guint8*)&(appr)->fg_color)[0] = (rgba)->red * 255; \ 70 ((guint8*)&(appr)->fg_color)[1] = (rgba)->green * 255; \ 71 ((guint8*)&(appr)->fg_color)[2] = (rgba)->blue * 255; \ 72 } G_STMT_END 73 74 75 #endif /* __GTK_TEXT_ATTRIBUTE_PRIVATE_H__ */ 76