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