1 /* 2 * This file is a part of the Cairo-Dock project 3 * 4 * Copyright : (C) see the 'copyright' file. 5 * E-mail : see the 'copyright' file. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 3 10 * of the License, or (at your option) any later version. 11 * 12 * This program 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 15 * GNU General Public License for more details. 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef __GLDI_STYLE_FACILITY__ 21 #define __GLDI_STYLE_FACILITY__ 22 23 #include <glib.h> 24 25 #include "cairo-dock-struct.h" 26 27 G_BEGIN_DECLS 28 29 /** 30 *@file cairo-dock-style-facility.h This file provides a few functions dealing with style elements like colors and text. 31 * 32 */ 33 34 /// Available types of color 35 typedef enum { 36 GLDI_COLOR_BG, 37 GLDI_COLOR_SELECTED, 38 GLDI_COLOR_LINE, 39 GLDI_COLOR_TEXT, 40 GLDI_COLOR_SEPARATOR, 41 GLDI_COLOR_CHILD, 42 GLDI_NB_COLORS 43 } GldiStyleColors; 44 45 struct _GldiColor { 46 GdkRGBA rgba; /// maybe we'll handle a double color later, to have simple linear patterns... 47 }; 48 49 /// A light shade level (dock background, ...) 50 #define GLDI_COLOR_SHADE_LIGHT .12 // 0.12 is barely noticeable, but that's fine 51 /// A medium shade level (selected menu-item, widget inside a dialog/menu, separator, ...) 52 #define GLDI_COLOR_SHADE_MEDIUM .2 53 /// A strong shade level (child widget inside a dialog/menu, ...) 54 #define GLDI_COLOR_SHADE_STRONG .3 55 56 /** Shade a color, making it darker if it's light, and lighter if it's dark. Note that the opposite behavior can be obtained by passing a negative shade value. Alpha is copied unchanged. Both pointers can be the same. 57 *@param icolor input color 58 *@param shade amount of light to add/remove, <= 1. 59 *@param ocolor output color 60 */ 61 void gldi_style_color_shade (GldiColor *icolor, double shade, GldiColor *ocolor); 62 63 gchar *_get_default_system_font (void); 64 65 void _get_color_from_pattern (cairo_pattern_t *pPattern, GldiColor *color); 66 67 #define gldi_color_set_cairo(pCairoContext, pColor) cairo_set_source_rgba (pCairoContext, (pColor)->rgba.red, (pColor)->rgba.green, (pColor)->rgba.blue, (pColor)->rgba.alpha) 68 #define gldi_color_set_cairo_rgb(pCairoContext, pColor) cairo_set_source_rgb (pCairoContext, (pColor)->rgba.red, (pColor)->rgba.green, (pColor)->rgba.blue) 69 #define gldi_color_set_opengl(pColor) glColor4f ((pColor)->rgba.red, (pColor)->rgba.green, (pColor)->rgba.blue, (pColor)->rgba.alpha) 70 #define gldi_color_set_opengl_rgb(pColor) glColor3f ((pColor)->rgba.red, (pColor)->rgba.green, (pColor)->rgba.blue) 71 #define gldi_color_compare(pColor1, pColor2) memcmp (pColor1, pColor2, sizeof(GldiColor)) // return 0 if equal 72 73 74 /// Description of the rendering of a text. 75 struct _GldiTextDescription { 76 /// font. 77 gchar *cFont; 78 /// pango font 79 PangoFontDescription *fd; 80 /// size in pixels 81 gint iSize; 82 /// whether to draw the decorations (frame and outline) or not 83 gboolean bNoDecorations; 84 /// whether to use the default colors or the colors defined below 85 gboolean bUseDefaultColors; 86 /// text color 87 GldiColor fColorStart; 88 /// background color 89 GldiColor fBackgroundColor; 90 /// outline color 91 GldiColor fLineColor; 92 /// TRUE to stroke the outline of the characters (in black). 93 gboolean bOutlined; 94 /// margin around the text, it is also the dimension of the frame if available. 95 gint iMargin; 96 /// whether to use Pango markups or not (markups are html-like marks, like <b>...</b>; using markups force you to escape some characters like "&" -> "&") 97 gboolean bUseMarkup; 98 /// maximum width allowed, in ratio of the screen's width. Carriage returns will be inserted if necessary. 0 means no limit. 99 gdouble fMaxRelativeWidth; 100 }; 101 102 void gldi_text_description_free (GldiTextDescription *pTextDescription); 103 void gldi_text_description_copy (GldiTextDescription *pDestTextDescription, GldiTextDescription *pOrigTextDescription); 104 GldiTextDescription *gldi_text_description_duplicate (GldiTextDescription *pTextDescription); 105 106 void gldi_text_description_reset (GldiTextDescription *pTextDescription); 107 108 void gldi_text_description_set_font (GldiTextDescription *pTextDescription, gchar *cFont); 109 110 #define gldi_text_description_get_size(pTextDescription) (pTextDescription)->iSize 111 112 #define gldi_text_description_get_description(pTextDescription) (pTextDescription)->fd 113 114 115 G_END_DECLS 116 #endif 117