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 gdk.Pango;
26 
27 private import cairo.Region;
28 private import gdk.Display;
29 private import gdk.Screen;
30 private import gdk.c.functions;
31 public  import gdk.c.types;
32 private import gobject.ObjectG;
33 public  import gtkc.gdktypes;
34 private import pango.PgContext;
35 private import pango.PgLayout;
36 private import pango.PgLayoutLine;
37 
38 
39 /** */
40 
41 /**
42  * Creates a #PangoContext for the default GDK screen.
43  *
44  * The context must be freed when you’re finished with it.
45  *
46  * When using GTK+, normally you should use gtk_widget_get_pango_context()
47  * instead of this function, to get the appropriate context for
48  * the widget you intend to render text onto.
49  *
50  * The newly created context will have the default font options (see
51  * #cairo_font_options_t) for the default screen; if these options
52  * change it will not be updated. Using gtk_widget_get_pango_context()
53  * is more convenient if you want to keep a context around and track
54  * changes to the screen’s font rendering settings.
55  *
56  * Returns: a new #PangoContext for the default display
57  */
58 public PgContext contextGet()
59 {
60 	auto p = gdk_pango_context_get();
61 
62 	if(p is null)
63 	{
64 		return null;
65 	}
66 
67 	return ObjectG.getDObject!(PgContext)(cast(PangoContext*) p, true);
68 }
69 
70 /**
71  * Creates a #PangoContext for @screen.
72  *
73  * The context must be freed when you’re finished with it.
74  *
75  * When using GTK+, normally you should use gtk_widget_get_pango_context()
76  * instead of this function, to get the appropriate context for
77  * the widget you intend to render text onto.
78  *
79  * The newly created context will have the default font options
80  * (see #cairo_font_options_t) for the screen; if these options
81  * change it will not be updated. Using gtk_widget_get_pango_context()
82  * is more convenient if you want to keep a context around and track
83  * changes to the screen’s font rendering settings.
84  *
85  * Params:
86  *     screen = the #GdkScreen for which the context is to be created.
87  *
88  * Returns: a new #PangoContext for @screen
89  *
90  * Since: 2.2
91  */
92 public PgContext contextGetForScreen(Screen screen)
93 {
94 	auto p = gdk_pango_context_get_for_screen((screen is null) ? null : screen.getScreenStruct());
95 
96 	if(p is null)
97 	{
98 		return null;
99 	}
100 
101 	return ObjectG.getDObject!(PgContext)(cast(PangoContext*) p, true);
102 }
103 
104 /**
105  * Obtains a clip region which contains the areas where the given ranges
106  * of text would be drawn. @x_origin and @y_origin are the top left point
107  * to center the layout. @index_ranges should contain
108  * ranges of bytes in the layout’s text.
109  *
110  * Note that the regions returned correspond to logical extents of the text
111  * ranges, not ink extents. So the drawn layout may in fact touch areas out of
112  * the clip region.  The clip region is mainly useful for highlightling parts
113  * of text, such as when text is selected.
114  *
115  * Params:
116  *     layout = a #PangoLayout
117  *     xOrigin = X pixel where you intend to draw the layout with this clip
118  *     yOrigin = Y pixel where you intend to draw the layout with this clip
119  *     indexRanges = array of byte indexes into the layout, where even members of array are start indexes and odd elements are end indexes
120  *     nRanges = number of ranges in @index_ranges, i.e. half the size of @index_ranges
121  *
122  * Returns: a clip region containing the given ranges
123  */
124 public Region layoutGetClipRegion(PgLayout layout, int xOrigin, int yOrigin, int* indexRanges, int nRanges)
125 {
126 	auto p = gdk_pango_layout_get_clip_region((layout is null) ? null : layout.getPgLayoutStruct(), xOrigin, yOrigin, indexRanges, nRanges);
127 
128 	if(p is null)
129 	{
130 		return null;
131 	}
132 
133 	return new Region(cast(cairo_region_t*) p);
134 }
135 
136 /**
137  * Obtains a clip region which contains the areas where the given
138  * ranges of text would be drawn. @x_origin and @y_origin are the top left
139  * position of the layout. @index_ranges
140  * should contain ranges of bytes in the layout’s text. The clip
141  * region will include space to the left or right of the line (to the
142  * layout bounding box) if you have indexes above or below the indexes
143  * contained inside the line. This is to draw the selection all the way
144  * to the side of the layout. However, the clip region is in line coordinates,
145  * not layout coordinates.
146  *
147  * Note that the regions returned correspond to logical extents of the text
148  * ranges, not ink extents. So the drawn line may in fact touch areas out of
149  * the clip region.  The clip region is mainly useful for highlightling parts
150  * of text, such as when text is selected.
151  *
152  * Params:
153  *     line = a #PangoLayoutLine
154  *     xOrigin = X pixel where you intend to draw the layout line with this clip
155  *     yOrigin = baseline pixel where you intend to draw the layout line with this clip
156  *     indexRanges = array of byte indexes into the layout,
157  *         where even members of array are start indexes and odd elements
158  *         are end indexes
159  *     nRanges = number of ranges in @index_ranges, i.e. half the size of @index_ranges
160  *
161  * Returns: a clip region containing the given ranges
162  */
163 public Region layoutLineGetClipRegion(PgLayoutLine line, int xOrigin, int yOrigin, int[] indexRanges, int nRanges)
164 {
165 	auto p = gdk_pango_layout_line_get_clip_region((line is null) ? null : line.getPgLayoutLineStruct(), xOrigin, yOrigin, indexRanges.ptr, nRanges);
166 
167 	if(p is null)
168 	{
169 		return null;
170 	}
171 
172 	return new Region(cast(cairo_region_t*) p);
173 }
174 
175 /**
176  * Creates a #PangoContext for @display.
177  *
178  * The context must be freed when you’re finished with it.
179  *
180  * When using GTK+, normally you should use gtk_widget_get_pango_context()
181  * instead of this function, to get the appropriate context for
182  * the widget you intend to render text onto.
183  *
184  * The newly created context will have the default font options
185  * (see #cairo_font_options_t) for the display; if these options
186  * change it will not be updated. Using gtk_widget_get_pango_context()
187  * is more convenient if you want to keep a context around and track
188  * changes to the font rendering settings.
189  *
190  * Params:
191  *     display = the #GdkDisplay for which the context is to be created
192  *
193  * Returns: a new #PangoContext for @display
194  *
195  * Since: 3.22
196  */
197 public PgContext contextGetForDisplay(Display display)
198 {
199 	auto p = gdk_pango_context_get_for_display((display is null) ? null : display.getDisplayStruct());
200 
201 	if(p is null)
202 	{
203 		return null;
204 	}
205 
206 	return ObjectG.getDObject!(PgContext)(cast(PangoContext*) p, true);
207 }