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 module pango.PgColor; 26 27 private import glib.Str; 28 private import gobject.ObjectG; 29 private import gtkc.pango; 30 public import gtkc.pangotypes; 31 private import gtkd.Loader; 32 33 34 /** 35 * The #PangoColor structure is used to 36 * represent a color in an uncalibrated RGB color-space. 37 */ 38 public class PgColor 39 { 40 /** the main Gtk struct */ 41 protected PangoColor* pangoColor; 42 protected bool ownedRef; 43 44 /** Get the main Gtk struct */ 45 public PangoColor* getPgColorStruct(bool transferOwnership = false) 46 { 47 if (transferOwnership) 48 ownedRef = false; 49 return pangoColor; 50 } 51 52 /** the main Gtk struct as a void* */ 53 protected void* getStruct() 54 { 55 return cast(void*)pangoColor; 56 } 57 58 /** 59 * Sets our main struct and passes it to the parent class. 60 */ 61 public this (PangoColor* pangoColor, bool ownedRef = false) 62 { 63 this.pangoColor = pangoColor; 64 this.ownedRef = ownedRef; 65 } 66 67 ~this () 68 { 69 if ( Linker.isLoaded(LIBRARY_PANGO) && ownedRef ) 70 pango_color_free(pangoColor); 71 } 72 73 74 /** */ 75 public static GType getType() 76 { 77 return pango_color_get_type(); 78 } 79 80 /** 81 * Creates a copy of @src, which should be freed with 82 * pango_color_free(). Primarily used by language bindings, 83 * not that useful otherwise (since colors can just be copied 84 * by assignment in C). 85 * 86 * Returns: the newly allocated #PangoColor, which 87 * should be freed with pango_color_free(), or %NULL if 88 * @src was %NULL. 89 */ 90 public PgColor copy() 91 { 92 auto p = pango_color_copy(pangoColor); 93 94 if(p is null) 95 { 96 return null; 97 } 98 99 return ObjectG.getDObject!(PgColor)(cast(PangoColor*) p, true); 100 } 101 102 /** 103 * Frees a color allocated by pango_color_copy(). 104 */ 105 public void free() 106 { 107 pango_color_free(pangoColor); 108 ownedRef = false; 109 } 110 111 /** 112 * Fill in the fields of a color from a string specification. The 113 * string can either one of a large set of standard names. (Taken 114 * from the CSS <ulink url="http://dev.w3.org/csswg/css-color/#named-colors">specification</ulink>), or it can be a hexadecimal 115 * value in the 116 * form '#rgb' '#rrggbb' '#rrrgggbbb' or '#rrrrggggbbbb' where 117 * 'r', 'g' and 'b' are hex digits of the red, green, and blue 118 * components of the color, respectively. (White in the four 119 * forms is '#fff' '#ffffff' '#fffffffff' and '#ffffffffffff') 120 * 121 * Params: 122 * spec = a string specifying the new color 123 * 124 * Returns: %TRUE if parsing of the specifier succeeded, 125 * otherwise false. 126 */ 127 public bool parse(string spec) 128 { 129 return pango_color_parse(pangoColor, Str.toStringz(spec)) != 0; 130 } 131 132 /** 133 * Returns a textual specification of @color in the hexadecimal form 134 * <literal>#rrrrggggbbbb</literal>, where <literal>r</literal>, 135 * <literal>g</literal> and <literal>b</literal> are hex digits representing 136 * the red, green, and blue components respectively. 137 * 138 * Returns: a newly-allocated text string that must be freed with g_free(). 139 * 140 * Since: 1.16 141 */ 142 public override string toString() 143 { 144 auto retStr = pango_color_to_string(pangoColor); 145 146 scope(exit) Str.freeString(retStr); 147 return Str.toString(retStr); 148 } 149 }