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