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 gsk.TextNode;
26 
27 private import gdk.RGBA;
28 private import glib.ConstructionException;
29 private import gobject.ObjectG;
30 private import graphene.Point;
31 private import gsk.RenderNode;
32 private import gsk.c.functions;
33 public  import gsk.c.types;
34 private import pango.PgFont;
35 private import pango.PgGlyphString;
36 
37 
38 /**
39  * A render node drawing a set of glyphs.
40  */
41 public class TextNode : RenderNode
42 {
43 	/** the main Gtk struct */
44 	protected GskTextNode* gskTextNode;
45 
46 	/** Get the main Gtk struct */
47 	public GskTextNode* getTextNodeStruct(bool transferOwnership = false)
48 	{
49 		if (transferOwnership)
50 			ownedRef = false;
51 		return gskTextNode;
52 	}
53 
54 	/** the main Gtk struct as a void* */
55 	protected override void* getStruct()
56 	{
57 		return cast(void*)gskTextNode;
58 	}
59 
60 	/**
61 	 * Sets our main struct and passes it to the parent class.
62 	 */
63 	public this (GskTextNode* gskTextNode, bool ownedRef = false)
64 	{
65 		this.gskTextNode = gskTextNode;
66 		super(cast(GskRenderNode*)gskTextNode, ownedRef);
67 	}
68 
69 
70 	/** */
71 	public static GType getType()
72 	{
73 		return gsk_text_node_get_type();
74 	}
75 
76 	/**
77 	 * Creates a render node that renders the given glyphs.
78 	 *
79 	 * Note that @color may not be used if the font contains
80 	 * color glyphs.
81 	 *
82 	 * Params:
83 	 *     font = the #PangoFont containing the glyphs
84 	 *     glyphs = the #PangoGlyphString to render
85 	 *     color = the foreground color to render with
86 	 *     offset = offset of the baseline
87 	 *
88 	 * Returns: a new `GskRenderNode`
89 	 *
90 	 * Throws: ConstructionException GTK+ fails to create the object.
91 	 */
92 	public this(PgFont font, PgGlyphString glyphs, RGBA color, Point offset)
93 	{
94 		auto __p = gsk_text_node_new((font is null) ? null : font.getPgFontStruct(), (glyphs is null) ? null : glyphs.getPgGlyphStringStruct(), (color is null) ? null : color.getRGBAStruct(), (offset is null) ? null : offset.getPointStruct());
95 
96 		if(__p is null)
97 		{
98 			throw new ConstructionException("null returned by new");
99 		}
100 
101 		this(cast(GskTextNode*) __p);
102 	}
103 
104 	/**
105 	 * Retrieves the color used by the text @node.
106 	 *
107 	 * Returns: the text color
108 	 */
109 	public RGBA getColor()
110 	{
111 		auto __p = gsk_text_node_get_color(cast(GskRenderNode*)gskTextNode);
112 
113 		if(__p is null)
114 		{
115 			return null;
116 		}
117 
118 		return ObjectG.getDObject!(RGBA)(cast(GdkRGBA*) __p);
119 	}
120 
121 	/**
122 	 * Returns the font used by the text @node.
123 	 *
124 	 * Returns: the font
125 	 */
126 	public PgFont getFont()
127 	{
128 		auto __p = gsk_text_node_get_font(cast(GskRenderNode*)gskTextNode);
129 
130 		if(__p is null)
131 		{
132 			return null;
133 		}
134 
135 		return ObjectG.getDObject!(PgFont)(cast(PangoFont*) __p);
136 	}
137 
138 	/**
139 	 * Retrieves the glyph information in the @node.
140 	 *
141 	 * Returns: the glyph information
142 	 */
143 	public PangoGlyphInfo[] getGlyphs()
144 	{
145 		uint nGlyphs;
146 
147 		auto __p = gsk_text_node_get_glyphs(cast(GskRenderNode*)gskTextNode, &nGlyphs);
148 
149 		return __p[0 .. nGlyphs];
150 	}
151 
152 	/**
153 	 * Retrieves the number of glyphs in the text node.
154 	 *
155 	 * Returns: the number of glyphs
156 	 */
157 	public uint getNumGlyphs()
158 	{
159 		return gsk_text_node_get_num_glyphs(cast(GskRenderNode*)gskTextNode);
160 	}
161 
162 	/**
163 	 * Retrieves the offset applied to the text.
164 	 *
165 	 * Returns: a point with the horizontal and vertical offsets
166 	 */
167 	public Point getOffset()
168 	{
169 		auto __p = gsk_text_node_get_offset(cast(GskRenderNode*)gskTextNode);
170 
171 		if(__p is null)
172 		{
173 			return null;
174 		}
175 
176 		return ObjectG.getDObject!(Point)(cast(graphene_point_t*) __p);
177 	}
178 
179 	/**
180 	 * Checks whether the text @node has color glyphs.
181 	 *
182 	 * Returns: %TRUE if the text node has color glyphs
183 	 */
184 	public bool hasColorGlyphs()
185 	{
186 		return gsk_text_node_has_color_glyphs(cast(GskRenderNode*)gskTextNode) != 0;
187 	}
188 }