1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 /* 25 * Conversion parameters: 26 * inFile = 27 * outPack = pango 28 * outFile = PgColor 29 * strct = PangoColor 30 * realStrct= 31 * ctorStrct= 32 * clss = PgColor 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - pango_color_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * structWrap: 48 * - PangoColor* -> PgColor 49 * module aliases: 50 * local aliases: 51 * overrides: 52 * - toString 53 */ 54 55 module pango.PgColor; 56 57 public import gtkc.pangotypes; 58 59 private import gtkc.pango; 60 private import glib.ConstructionException; 61 private import gobject.ObjectG; 62 63 private import glib.Str; 64 65 66 67 /** 68 * Attributed text is used in a number of places in Pango. It 69 * is used as the input to the itemization process and also when 70 * creating a PangoLayout. The data types and functions in 71 * this section are used to represent and manipulate sets 72 * of attributes applied to a portion of text. 73 */ 74 public class PgColor 75 { 76 77 /** the main Gtk struct */ 78 protected PangoColor* pangoColor; 79 80 81 /** Get the main Gtk struct */ 82 public PangoColor* getPgColorStruct() 83 { 84 return pangoColor; 85 } 86 87 88 /** the main Gtk struct as a void* */ 89 protected void* getStruct() 90 { 91 return cast(void*)pangoColor; 92 } 93 94 /** 95 * Sets our main struct and passes it to the parent class 96 */ 97 public this (PangoColor* pangoColor) 98 { 99 this.pangoColor = pangoColor; 100 } 101 102 /** 103 */ 104 105 /** 106 * Fill in the fields of a color from a string specification. The 107 * string can either one of a large set of standard names. (Taken 108 * from the X11 rgb.txt file), or it can be a hex value in the 109 * form '#rgb' '#rrggbb' '#rrrgggbbb' or '#rrrrggggbbbb' where 110 * 'r', 'g' and 'b' are hex digits of the red, green, and blue 111 * components of the color, respectively. (White in the four 112 * forms is '#fff' '#ffffff' '#fffffffff' and '#ffffffffffff') 113 * Params: 114 * spec = a string specifying the new color 115 * Returns: TRUE if parsing of the specifier succeeded, otherwise false. 116 */ 117 public int parse(string spec) 118 { 119 // gboolean pango_color_parse (PangoColor *color, const char *spec); 120 return pango_color_parse(pangoColor, Str.toStringz(spec)); 121 } 122 123 /** 124 * Creates a copy of src, which should be freed with 125 * pango_color_free(). Primarily used by language bindings, 126 * not that useful otherwise (since colors can just be copied 127 * by assignment in C). 128 * Returns: the newly allocated PangoColor, which should be freed with pango_color_free(), or NULL if src was NULL. 129 */ 130 public PgColor copy() 131 { 132 // PangoColor * pango_color_copy (const PangoColor *src); 133 auto p = pango_color_copy(pangoColor); 134 135 if(p is null) 136 { 137 return null; 138 } 139 140 return ObjectG.getDObject!(PgColor)(cast(PangoColor*) p); 141 } 142 143 /** 144 * Frees a color allocated by pango_color_copy(). 145 */ 146 public void free() 147 { 148 // void pango_color_free (PangoColor *color); 149 pango_color_free(pangoColor); 150 } 151 152 /** 153 * Returns a textual specification of color in the hexadecimal form 154 * #rrrrggggbbbb, where r, 155 * g and b are hex digits representing 156 * the red, green, and blue components respectively. 157 * Since 1.16 158 * Returns: a newly-allocated text string that must be freed with g_free(). 159 */ 160 public override string toString() 161 { 162 // gchar * pango_color_to_string (const PangoColor *color); 163 return Str.toString(pango_color_to_string(pangoColor)); 164 } 165 }