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 gtk.CellAreaContext;
26 
27 private import gobject.ObjectG;
28 private import gtk.CellArea;
29 private import gtk.c.functions;
30 public  import gtk.c.types;
31 public  import gtkc.gtktypes;
32 
33 
34 /**
35  * The #GtkCellAreaContext object is created by a given #GtkCellArea
36  * implementation via its #GtkCellAreaClass.create_context() virtual
37  * method and is used to store cell sizes and alignments for a series of
38  * #GtkTreeModel rows that are requested and rendered in the same context.
39  * 
40  * #GtkCellLayout widgets can create any number of contexts in which to
41  * request and render groups of data rows. However, it’s important that the
42  * same context which was used to request sizes for a given #GtkTreeModel
43  * row also be used for the same row when calling other #GtkCellArea APIs
44  * such as gtk_cell_area_render() and gtk_cell_area_event().
45  */
46 public class CellAreaContext : ObjectG
47 {
48 	/** the main Gtk struct */
49 	protected GtkCellAreaContext* gtkCellAreaContext;
50 
51 	/** Get the main Gtk struct */
52 	public GtkCellAreaContext* getCellAreaContextStruct(bool transferOwnership = false)
53 	{
54 		if (transferOwnership)
55 			ownedRef = false;
56 		return gtkCellAreaContext;
57 	}
58 
59 	/** the main Gtk struct as a void* */
60 	protected override void* getStruct()
61 	{
62 		return cast(void*)gtkCellAreaContext;
63 	}
64 
65 	/**
66 	 * Sets our main struct and passes it to the parent class.
67 	 */
68 	public this (GtkCellAreaContext* gtkCellAreaContext, bool ownedRef = false)
69 	{
70 		this.gtkCellAreaContext = gtkCellAreaContext;
71 		super(cast(GObject*)gtkCellAreaContext, ownedRef);
72 	}
73 
74 
75 	/** */
76 	public static GType getType()
77 	{
78 		return gtk_cell_area_context_get_type();
79 	}
80 
81 	/**
82 	 * Allocates a width and/or a height for all rows which are to be
83 	 * rendered with @context.
84 	 *
85 	 * Usually allocation is performed only horizontally or sometimes
86 	 * vertically since a group of rows are usually rendered side by
87 	 * side vertically or horizontally and share either the same width
88 	 * or the same height. Sometimes they are allocated in both horizontal
89 	 * and vertical orientations producing a homogeneous effect of the
90 	 * rows. This is generally the case for #GtkTreeView when
91 	 * #GtkTreeView:fixed-height-mode is enabled.
92 	 *
93 	 * Since 3.0
94 	 *
95 	 * Params:
96 	 *     width = the allocated width for all #GtkTreeModel rows rendered
97 	 *         with @context, or -1.
98 	 *     height = the allocated height for all #GtkTreeModel rows rendered
99 	 *         with @context, or -1.
100 	 */
101 	public void allocate(int width, int height)
102 	{
103 		gtk_cell_area_context_allocate(gtkCellAreaContext, width, height);
104 	}
105 
106 	/**
107 	 * Fetches the current allocation size for @context.
108 	 *
109 	 * If the context was not allocated in width or height, or if the
110 	 * context was recently reset with gtk_cell_area_context_reset(),
111 	 * the returned value will be -1.
112 	 *
113 	 * Params:
114 	 *     width = location to store the allocated width, or %NULL
115 	 *     height = location to store the allocated height, or %NULL
116 	 *
117 	 * Since: 3.0
118 	 */
119 	public void getAllocation(out int width, out int height)
120 	{
121 		gtk_cell_area_context_get_allocation(gtkCellAreaContext, &width, &height);
122 	}
123 
124 	/**
125 	 * Fetches the #GtkCellArea this @context was created by.
126 	 *
127 	 * This is generally unneeded by layouting widgets; however,
128 	 * it is important for the context implementation itself to
129 	 * fetch information about the area it is being used for.
130 	 *
131 	 * For instance at #GtkCellAreaContextClass.allocate() time
132 	 * it’s important to know details about any cell spacing
133 	 * that the #GtkCellArea is configured with in order to
134 	 * compute a proper allocation.
135 	 *
136 	 * Returns: the #GtkCellArea this context was created by.
137 	 *
138 	 * Since: 3.0
139 	 */
140 	public CellArea getArea()
141 	{
142 		auto p = gtk_cell_area_context_get_area(gtkCellAreaContext);
143 
144 		if(p is null)
145 		{
146 			return null;
147 		}
148 
149 		return ObjectG.getDObject!(CellArea)(cast(GtkCellArea*) p);
150 	}
151 
152 	/**
153 	 * Gets the accumulative preferred height for all rows which have been
154 	 * requested with this context.
155 	 *
156 	 * After gtk_cell_area_context_reset() is called and/or before ever
157 	 * requesting the size of a #GtkCellArea, the returned values are 0.
158 	 *
159 	 * Params:
160 	 *     minimumHeight = location to store the minimum height,
161 	 *         or %NULL
162 	 *     naturalHeight = location to store the natural height,
163 	 *         or %NULL
164 	 *
165 	 * Since: 3.0
166 	 */
167 	public void getPreferredHeight(out int minimumHeight, out int naturalHeight)
168 	{
169 		gtk_cell_area_context_get_preferred_height(gtkCellAreaContext, &minimumHeight, &naturalHeight);
170 	}
171 
172 	/**
173 	 * Gets the accumulative preferred height for @width for all rows
174 	 * which have been requested for the same said @width with this context.
175 	 *
176 	 * After gtk_cell_area_context_reset() is called and/or before ever
177 	 * requesting the size of a #GtkCellArea, the returned values are -1.
178 	 *
179 	 * Params:
180 	 *     width = a proposed width for allocation
181 	 *     minimumHeight = location to store the minimum height,
182 	 *         or %NULL
183 	 *     naturalHeight = location to store the natural height,
184 	 *         or %NULL
185 	 *
186 	 * Since: 3.0
187 	 */
188 	public void getPreferredHeightForWidth(int width, out int minimumHeight, out int naturalHeight)
189 	{
190 		gtk_cell_area_context_get_preferred_height_for_width(gtkCellAreaContext, width, &minimumHeight, &naturalHeight);
191 	}
192 
193 	/**
194 	 * Gets the accumulative preferred width for all rows which have been
195 	 * requested with this context.
196 	 *
197 	 * After gtk_cell_area_context_reset() is called and/or before ever
198 	 * requesting the size of a #GtkCellArea, the returned values are 0.
199 	 *
200 	 * Params:
201 	 *     minimumWidth = location to store the minimum width,
202 	 *         or %NULL
203 	 *     naturalWidth = location to store the natural width,
204 	 *         or %NULL
205 	 *
206 	 * Since: 3.0
207 	 */
208 	public void getPreferredWidth(out int minimumWidth, out int naturalWidth)
209 	{
210 		gtk_cell_area_context_get_preferred_width(gtkCellAreaContext, &minimumWidth, &naturalWidth);
211 	}
212 
213 	/**
214 	 * Gets the accumulative preferred width for @height for all rows which
215 	 * have been requested for the same said @height with this context.
216 	 *
217 	 * After gtk_cell_area_context_reset() is called and/or before ever
218 	 * requesting the size of a #GtkCellArea, the returned values are -1.
219 	 *
220 	 * Params:
221 	 *     height = a proposed height for allocation
222 	 *     minimumWidth = location to store the minimum width,
223 	 *         or %NULL
224 	 *     naturalWidth = location to store the natural width,
225 	 *         or %NULL
226 	 *
227 	 * Since: 3.0
228 	 */
229 	public void getPreferredWidthForHeight(int height, out int minimumWidth, out int naturalWidth)
230 	{
231 		gtk_cell_area_context_get_preferred_width_for_height(gtkCellAreaContext, height, &minimumWidth, &naturalWidth);
232 	}
233 
234 	/**
235 	 * Causes the minimum and/or natural height to grow if the new
236 	 * proposed sizes exceed the current minimum and natural height.
237 	 *
238 	 * This is used by #GtkCellAreaContext implementations during
239 	 * the request process over a series of #GtkTreeModel rows to
240 	 * progressively push the requested height over a series of
241 	 * gtk_cell_area_get_preferred_height() requests.
242 	 *
243 	 * Params:
244 	 *     minimumHeight = the proposed new minimum height for @context
245 	 *     naturalHeight = the proposed new natural height for @context
246 	 *
247 	 * Since: 3.0
248 	 */
249 	public void pushPreferredHeight(int minimumHeight, int naturalHeight)
250 	{
251 		gtk_cell_area_context_push_preferred_height(gtkCellAreaContext, minimumHeight, naturalHeight);
252 	}
253 
254 	/**
255 	 * Causes the minimum and/or natural width to grow if the new
256 	 * proposed sizes exceed the current minimum and natural width.
257 	 *
258 	 * This is used by #GtkCellAreaContext implementations during
259 	 * the request process over a series of #GtkTreeModel rows to
260 	 * progressively push the requested width over a series of
261 	 * gtk_cell_area_get_preferred_width() requests.
262 	 *
263 	 * Params:
264 	 *     minimumWidth = the proposed new minimum width for @context
265 	 *     naturalWidth = the proposed new natural width for @context
266 	 *
267 	 * Since: 3.0
268 	 */
269 	public void pushPreferredWidth(int minimumWidth, int naturalWidth)
270 	{
271 		gtk_cell_area_context_push_preferred_width(gtkCellAreaContext, minimumWidth, naturalWidth);
272 	}
273 
274 	/**
275 	 * Resets any previously cached request and allocation
276 	 * data.
277 	 *
278 	 * When underlying #GtkTreeModel data changes its
279 	 * important to reset the context if the content
280 	 * size is allowed to shrink. If the content size
281 	 * is only allowed to grow (this is usually an option
282 	 * for views rendering large data stores as a measure
283 	 * of optimization), then only the row that changed
284 	 * or was inserted needs to be (re)requested with
285 	 * gtk_cell_area_get_preferred_width().
286 	 *
287 	 * When the new overall size of the context requires
288 	 * that the allocated size changes (or whenever this
289 	 * allocation changes at all), the variable row
290 	 * sizes need to be re-requested for every row.
291 	 *
292 	 * For instance, if the rows are displayed all with
293 	 * the same width from top to bottom then a change
294 	 * in the allocated width necessitates a recalculation
295 	 * of all the displayed row heights using
296 	 * gtk_cell_area_get_preferred_height_for_width().
297 	 *
298 	 * Since 3.0
299 	 */
300 	public void reset()
301 	{
302 		gtk_cell_area_context_reset(gtkCellAreaContext);
303 	}
304 }