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