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