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