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