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  = pango-Vertical-Text.html
27  * outPack = pango
28  * outFile = PgVertical
29  * strct   = 
30  * realStrct=
31  * ctorStrct=
32  * clss    = PgVertical
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- pango_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- pango.PgMatrix
47  * structWrap:
48  * 	- PangoMatrix* -> PgMatrix
49  * module aliases:
50  * local aliases:
51  * overrides:
52  */
53 
54 module pango.PgVertical;
55 
56 public  import gtkc.pangotypes;
57 
58 private import gtkc.pango;
59 private import glib.ConstructionException;
60 private import gobject.ObjectG;
61 
62 
63 private import pango.PgMatrix;
64 
65 
66 
67 
68 /**
69  * Since 1.16, Pango is able to correctly lay vertical text out. In fact, it can
70  * set layouts of mixed vertical and non-vertical text. This section describes
71  * the types used for setting vertical text parameters.
72  *
73  * The way this is implemented is through the concept of
74  * gravity. Gravity of normal Latin text is south. A
75  * gravity value of east means that glyphs will be rotated ninety degrees
76  * counterclockwise. So, to render vertical text one needs to set the gravity
77  * and rotate the layout using the matrix machinery already in place. This has
78  * the huge advantage that most algorithms working on a PangoLayout do not need
79  * any change as the assumption that lines run in the X direction and stack in
80  * the Y direction holds even for vertical text layouts.
81  *
82  * Applications should only need to set base gravity on PangoContext in use, and
83  * let Pango decide the gravity assigned to each run of text. This automatically
84  * handles text with mixed scripts. A very common use is to set the context base
85  * gravity to auto using pango_context_set_base_gravity()
86  * and rotate the layout normally. Pango will make sure that
87  * Asian languages take the right form, while other scripts are rotated normally.
88  *
89  * The correct way to set gravity on a layout is to set it on the context
90  * associated with it using pango_context_set_base_gravity(). The context
91  * of a layout can be accessed using pango_layout_get_context(). The currently
92  * set base gravity of the context can be accessed using
93  * pango_context_get_base_gravity() and the resolved
94  * gravity of it using pango_context_get_gravity(). The resolved gravity is
95  * the same as the base gravity for the most part, except that if the base
96  * gravity is set to PANGO_GRAVITY_AUTO, the resolved gravity will depend
97  * on the current matrix set on context, and is derived using
98  * pango_gravity_get_for_matrix().
99  *
100  * The next thing an application may want to set on the context is the
101  * gravity hint. A PangoGravityHint instructs how
102  * different scripts should react to the set base gravity.
103  *
104  * Font descriptions have a gravity property too, that can be set using
105  * pango_font_description_set_gravity() and accessed using
106  * pango_font_description_get_gravity(). However, those are rarely useful
107  * from application code and are mainly used by PangoLayout internally.
108  *
109  * Last but not least, one can create PangoAttributes for gravity
110  * and gravity hint using pango_attr_gravity_new() and
111  * pango_attr_gravity_hint_new().
112  */
113 public class PgVertical
114 {
115 	
116 	/**
117 	 */
118 	
119 	/**
120 	 * Finds the gravity that best matches the rotation component
121 	 * in a PangoMatrix.
122 	 * Since 1.16
123 	 * Params:
124 	 * matrix = a PangoMatrix
125 	 * Returns: the gravity of matrix, which will never be PANGO_GRAVITY_AUTO, or PANGO_GRAVITY_SOUTH if matrix is NULL
126 	 */
127 	public static PangoGravity gravityGetForMatrix(PgMatrix matrix)
128 	{
129 		// PangoGravity pango_gravity_get_for_matrix (const PangoMatrix *matrix);
130 		return pango_gravity_get_for_matrix((matrix is null) ? null : matrix.getPgMatrixStruct());
131 	}
132 	
133 	/**
134 	 * Based on the script, base gravity, and hint, returns actual gravity
135 	 * to use in laying out a single PangoItem.
136 	 * If base_gravity is PANGO_GRAVITY_AUTO, it is first replaced with the
137 	 * preferred gravity of script. To get the preferred gravity of a script,
138 	 * pass PANGO_GRAVITY_AUTO and PANGO_GRAVITY_HINT_STRONG in.
139 	 * Since 1.16
140 	 * Params:
141 	 * script = PangoScript to query
142 	 * baseGravity = base gravity of the paragraph
143 	 * hint = orientation hint
144 	 * Returns: resolved gravity suitable to use for a run of text with script.
145 	 */
146 	public static PangoGravity gravityGetForScript(PangoScript script, PangoGravity baseGravity, PangoGravityHint hint)
147 	{
148 		// PangoGravity pango_gravity_get_for_script (PangoScript script,  PangoGravity base_gravity,  PangoGravityHint hint);
149 		return pango_gravity_get_for_script(script, baseGravity, hint);
150 	}
151 	
152 	/**
153 	 * Based on the script, East Asian width, base gravity, and hint,
154 	 * returns actual gravity to use in laying out a single character
155 	 * or PangoItem.
156 	 * This function is similar to pango_gravity_get_for_script() except
157 	 * that this function makes a distinction between narrow/half-width and
158 	 * wide/full-width characters also. Wide/full-width characters always
159 	 * stand <emph>upright</emph>, that is, they always take the base gravity,
160 	 * whereas narrow/full-width characters are always rotated in vertical
161 	 * context.
162 	 * If base_gravity is PANGO_GRAVITY_AUTO, it is first replaced with the
163 	 * preferred gravity of script.
164 	 * Since 1.26
165 	 * Params:
166 	 * script = PangoScript to query
167 	 * wide = TRUE for wide characters as returned by g_unichar_iswide()
168 	 * baseGravity = base gravity of the paragraph
169 	 * hint = orientation hint
170 	 * Returns: resolved gravity suitable to use for a run of text with script and wide.
171 	 */
172 	public static PangoGravity gravityGetForScriptAndWidth(PangoScript script, int wide, PangoGravity baseGravity, PangoGravityHint hint)
173 	{
174 		// PangoGravity pango_gravity_get_for_script_and_width  (PangoScript script,  gboolean wide,  PangoGravity base_gravity,  PangoGravityHint hint);
175 		return pango_gravity_get_for_script_and_width(script, wide, baseGravity, hint);
176 	}
177 	
178 	/**
179 	 * Converts a PangoGravity value to its natural rotation in radians.
180 	 * gravity should not be PANGO_GRAVITY_AUTO.
181 	 * Note that pango_matrix_rotate() takes angle in degrees, not radians.
182 	 * So, to call pango_matrix_rotate() with the output of this function
183 	 * you should multiply it by (180. / G_PI).
184 	 * Since 1.16
185 	 * Params:
186 	 * gravity = gravity to query
187 	 * Returns: the rotation value corresponding to gravity.
188 	 */
189 	public static double gravityToRotation(PangoGravity gravity)
190 	{
191 		// double pango_gravity_to_rotation (PangoGravity gravity);
192 		return pango_gravity_to_rotation(gravity);
193 	}
194 }