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 change21 // find conversion definition on APILookup.txt22 // implement new conversion functionalities on the wrap.utils pakage23 24 25 modulegtk.CellArea;
26 27 privateimportgdk.Event;
28 privateimportglib.ListG;
29 privateimportglib.Str;
30 privateimportglib.c.functions;
31 privateimportgobject.ObjectG;
32 privateimportgobject.Signals;
33 privateimportgobject.Value;
34 privateimportgtk.BuildableIF;
35 privateimportgtk.BuildableT;
36 privateimportgtk.CellAreaContext;
37 privateimportgtk.CellEditableIF;
38 privateimportgtk.CellLayoutIF;
39 privateimportgtk.CellLayoutT;
40 privateimportgtk.CellRenderer;
41 privateimportgtk.Snapshot;
42 privateimportgtk.TreeIter;
43 privateimportgtk.TreeModelIF;
44 privateimportgtk.Widget;
45 privateimportgtk.c.functions;
46 publicimportgtk.c.types;
47 privateimportstd.algorithm;
48 49 50 /**
51 * An abstract class for laying out GtkCellRenderers
52 *
53 * The #GtkCellArea is an abstract class for #GtkCellLayout widgets
54 * (also referred to as "layouting widgets") to interface with an
55 * arbitrary number of #GtkCellRenderers and interact with the user
56 * for a given #GtkTreeModel row.
57 *
58 * The cell area handles events, focus navigation, drawing and
59 * size requests and allocations for a given row of data.
60 *
61 * Usually users dont have to interact with the #GtkCellArea directly
62 * unless they are implementing a cell-layouting widget themselves.
63 *
64 * # Requesting area sizes
65 *
66 * As outlined in
67 * [GtkWidget’s geometry management section][geometry-management],
68 * GTK uses a height-for-width
69 * geometry management system to compute the sizes of widgets and user
70 * interfaces. #GtkCellArea uses the same semantics to calculate the
71 * size of an area for an arbitrary number of #GtkTreeModel rows.
72 *
73 * When requesting the size of a cell area one needs to calculate
74 * the size for a handful of rows, and this will be done differently by
75 * different layouting widgets. For instance a #GtkTreeViewColumn
76 * always lines up the areas from top to bottom while a #GtkIconView
77 * on the other hand might enforce that all areas received the same
78 * width and wrap the areas around, requesting height for more cell
79 * areas when allocated less width.
80 *
81 * It’s also important for areas to maintain some cell
82 * alignments with areas rendered for adjacent rows (cells can
83 * appear “columnized” inside an area even when the size of
84 * cells are different in each row). For this reason the #GtkCellArea
85 * uses a #GtkCellAreaContext object to store the alignments
86 * and sizes along the way (as well as the overall largest minimum
87 * and natural size for all the rows which have been calculated
88 * with the said context).
89 *
90 * The #GtkCellAreaContext is an opaque object specific to the
91 * #GtkCellArea which created it (see gtk_cell_area_create_context()).
92 * The owning cell-layouting widget can create as many contexts as
93 * it wishes to calculate sizes of rows which should receive the
94 * same size in at least one orientation (horizontally or vertically),
95 * However, it’s important that the same #GtkCellAreaContext which
96 * was used to request the sizes for a given #GtkTreeModel row be
97 * used when rendering or processing events for that row.
98 *
99 * In order to request the width of all the rows at the root level
100 * of a #GtkTreeModel one would do the following:
101 *
102 * |[<!-- language="C" -->
103 * GtkTreeIter iter;
104 * int minimum_width;
105 * int natural_width;
106 *
107 * valid = gtk_tree_model_get_iter_first (model, &iter);
108 * while (valid)
109 * {
110 * gtk_cell_area_apply_attributes (area, model, &iter, FALSE, FALSE);
111 * gtk_cell_area_get_preferred_width (area, context, widget, NULL, NULL);
112 *
113 * valid = gtk_tree_model_iter_next (model, &iter);
114 * }
115 * gtk_cell_area_context_get_preferred_width (context, &minimum_width, &natural_width);
116 * ]|
117 *
118 * Note that in this example it’s not important to observe the
119 * returned minimum and natural width of the area for each row
120 * unless the cell-layouting object is actually interested in the
121 * widths of individual rows. The overall width is however stored
122 * in the accompanying #GtkCellAreaContext object and can be consulted
123 * at any time.
124 *
125 * This can be useful since #GtkCellLayout widgets usually have to
126 * support requesting and rendering rows in treemodels with an
127 * exceedingly large amount of rows. The #GtkCellLayout widget in
128 * that case would calculate the required width of the rows in an
129 * idle or timeout source (see g_timeout_add()) and when the widget
130 * is requested its actual width in #GtkWidgetClass.measure()
131 * it can simply consult the width accumulated so far in the
132 * #GtkCellAreaContext object.
133 *
134 * A simple example where rows are rendered from top to bottom and
135 * take up the full width of the layouting widget would look like:
136 *
137 * |[<!-- language="C" -->
138 * static void
139 * foo_get_preferred_width (GtkWidget *widget,
140 * int *minimum_size,
141 * int *natural_size)
142 * {
143 * Foo *foo = FOO (widget);
144 * FooPrivate *priv = foo->priv;
145 *
146 * foo_ensure_at_least_one_handfull_of_rows_have_been_requested (foo);
147 *
148 * gtk_cell_area_context_get_preferred_width (priv->context, minimum_size, natural_size);
149 * }
150 * ]|
151 *
152 * In the above example the Foo widget has to make sure that some
153 * row sizes have been calculated (the amount of rows that Foo judged
154 * was appropriate to request space for in a single timeout iteration)
155 * before simply returning the amount of space required by the area via
156 * the #GtkCellAreaContext.
157 *
158 * Requesting the height for width (or width for height) of an area is
159 * a similar task except in this case the #GtkCellAreaContext does not
160 * store the data (actually, it does not know how much space the layouting
161 * widget plans to allocate it for every row. It’s up to the layouting
162 * widget to render each row of data with the appropriate height and
163 * width which was requested by the #GtkCellArea).
164 *
165 * In order to request the height for width of all the rows at the
166 * root level of a #GtkTreeModel one would do the following:
167 *
168 * |[<!-- language="C" -->
169 * GtkTreeIter iter;
170 * int minimum_height;
171 * int natural_height;
172 * int full_minimum_height = 0;
173 * int full_natural_height = 0;
174 *
175 * valid = gtk_tree_model_get_iter_first (model, &iter);
176 * while (valid)
177 * {
178 * gtk_cell_area_apply_attributes (area, model, &iter, FALSE, FALSE);
179 * gtk_cell_area_get_preferred_height_for_width (area, context, widget,
180 * width, &minimum_height, &natural_height);
181 *
182 * if (width_is_for_allocation)
183 * cache_row_height (&iter, minimum_height, natural_height);
184 *
185 * full_minimum_height += minimum_height;
186 * full_natural_height += natural_height;
187 *
188 * valid = gtk_tree_model_iter_next (model, &iter);
189 * }
190 * ]|
191 *
192 * Note that in the above example we would need to cache the heights
193 * returned for each row so that we would know what sizes to render the
194 * areas for each row. However we would only want to really cache the
195 * heights if the request is intended for the layouting widgets real
196 * allocation.
197 *
198 * In some cases the layouting widget is requested the height for an
199 * arbitrary for_width, this is a special case for layouting widgets
200 * who need to request size for tens of thousands of rows. For this
201 * case it’s only important that the layouting widget calculate
202 * one reasonably sized chunk of rows and return that height
203 * synchronously. The reasoning here is that any layouting widget is
204 * at least capable of synchronously calculating enough height to fill
205 * the screen height (or scrolled window height) in response to a single
206 * call to #GtkWidgetClass.measure(). Returning
207 * a perfect height for width that is larger than the screen area is
208 * inconsequential since after the layouting receives an allocation
209 * from a scrolled window it simply continues to drive the scrollbar
210 * values while more and more height is required for the row heights
211 * that are calculated in the background.
212 *
213 * # Rendering Areas
214 *
215 * Once area sizes have been acquired at least for the rows in the
216 * visible area of the layouting widget they can be rendered at
217 * #GtkWidgetClass.snapshot() time.
218 *
219 * A crude example of how to render all the rows at the root level
220 * runs as follows:
221 *
222 * |[<!-- language="C" -->
223 * GtkAllocation allocation;
224 * GdkRectangle cell_area = { 0, };
225 * GtkTreeIter iter;
226 * int minimum_width;
227 * int natural_width;
228 *
229 * gtk_widget_get_allocation (widget, &allocation);
230 * cell_area.width = allocation.width;
231 *
232 * valid = gtk_tree_model_get_iter_first (model, &iter);
233 * while (valid)
234 * {
235 * cell_area.height = get_cached_height_for_row (&iter);
236 *
237 * gtk_cell_area_apply_attributes (area, model, &iter, FALSE, FALSE);
238 * gtk_cell_area_render (area, context, widget, cr,
239 * &cell_area, &cell_area, state_flags, FALSE);
240 *
241 * cell_area.y += cell_area.height;
242 *
243 * valid = gtk_tree_model_iter_next (model, &iter);
244 * }
245 * ]|
246 *
247 * Note that the cached height in this example really depends on how
248 * the layouting widget works. The layouting widget might decide to
249 * give every row its minimum or natural height or, if the model content
250 * is expected to fit inside the layouting widget without scrolling, it
251 * would make sense to calculate the allocation for each row at
252 * the time the widget is allocated using gtk_distribute_natural_allocation().
253 *
254 * # Handling Events and Driving Keyboard Focus
255 *
256 * Passing events to the area is as simple as handling events on any
257 * normal widget and then passing them to the gtk_cell_area_event()
258 * API as they come in. Usually #GtkCellArea is only interested in
259 * button events, however some customized derived areas can be implemented
260 * who are interested in handling other events. Handling an event can
261 * trigger the #GtkCellArea::focus-changed signal to fire; as well as
262 * #GtkCellArea::add-editable in the case that an editable cell was
263 * clicked and needs to start editing. You can call
264 * gtk_cell_area_stop_editing() at any time to cancel any cell editing
265 * that is currently in progress.
266 *
267 * The #GtkCellArea drives keyboard focus from cell to cell in a way
268 * similar to #GtkWidget. For layouting widgets that support giving
269 * focus to cells it’s important to remember to pass %GTK_CELL_RENDERER_FOCUSED
270 * to the area functions for the row that has focus and to tell the
271 * area to paint the focus at render time.
272 *
273 * Layouting widgets that accept focus on cells should implement the
274 * #GtkWidgetClass.focus() virtual method. The layouting widget is always
275 * responsible for knowing where #GtkTreeModel rows are rendered inside
276 * the widget, so at #GtkWidgetClass.focus() time the layouting widget
277 * should use the #GtkCellArea methods to navigate focus inside the area
278 * and then observe the GtkDirectionType to pass the focus to adjacent
279 * rows and areas.
280 *
281 * A basic example of how the #GtkWidgetClass.focus() virtual method
282 * should be implemented:
283 *
284 * |[<!-- language="C" -->
285 * static gboolean
286 * foo_focus (GtkWidget *widget,
287 * GtkDirectionType direction)
288 * {
289 * Foo *foo = FOO (widget);
290 * FooPrivate *priv = foo->priv;
291 * int focus_row;
292 * gboolean have_focus = FALSE;
293 *
294 * focus_row = priv->focus_row;
295 *
296 * if (!gtk_widget_has_focus (widget))
297 * gtk_widget_grab_focus (widget);
298 *
299 * valid = gtk_tree_model_iter_nth_child (priv->model, &iter, NULL, priv->focus_row);
300 * while (valid)
301 * {
302 * gtk_cell_area_apply_attributes (priv->area, priv->model, &iter, FALSE, FALSE);
303 *
304 * if (gtk_cell_area_focus (priv->area, direction))
305 * {
306 * priv->focus_row = focus_row;
307 * have_focus = TRUE;
308 * break;
309 * }
310 * else
311 * {
312 * if (direction == GTK_DIR_RIGHT ||
313 * direction == GTK_DIR_LEFT)
314 * break;
315 * else if (direction == GTK_DIR_UP ||
316 * direction == GTK_DIR_TAB_BACKWARD)
317 * {
318 * if (focus_row == 0)
319 * break;
320 * else
321 * {
322 * focus_row--;
323 * valid = gtk_tree_model_iter_nth_child (priv->model, &iter, NULL, focus_row);
324 * }
325 * }
326 * else
327 * {
328 * if (focus_row == last_row)
329 * break;
330 * else
331 * {
332 * focus_row++;
333 * valid = gtk_tree_model_iter_next (priv->model, &iter);
334 * }
335 * }
336 * }
337 * }
338 * return have_focus;
339 * }
340 * ]|
341 *
342 * Note that the layouting widget is responsible for matching the
343 * GtkDirectionType values to the way it lays out its cells.
344 *
345 * # Cell Properties
346 *
347 * The #GtkCellArea introduces cell properties for #GtkCellRenderers.
348 * This provides some general interfaces for defining the relationship
349 * cell areas have with their cells. For instance in a #GtkCellAreaBox
350 * a cell might “expand” and receive extra space when the area is allocated
351 * more than its full natural request, or a cell might be configured to “align”
352 * with adjacent rows which were requested and rendered with the same
353 * #GtkCellAreaContext.
354 *
355 * Use gtk_cell_area_class_install_cell_property() to install cell
356 * properties for a cell area class and gtk_cell_area_class_find_cell_property()
357 * or gtk_cell_area_class_list_cell_properties() to get information about
358 * existing cell properties.
359 *
360 * To set the value of a cell property, use gtk_cell_area_cell_set_property(),
361 * gtk_cell_area_cell_set() or gtk_cell_area_cell_set_valist(). To obtain
362 * the value of a cell property, use gtk_cell_area_cell_get_property(),
363 * gtk_cell_area_cell_get() or gtk_cell_area_cell_get_valist().
364 */365 publicclassCellArea : ObjectG, BuildableIF, CellLayoutIF366 {
367 /** the main Gtk struct */368 protectedGtkCellArea* gtkCellArea;
369 370 /** Get the main Gtk struct */371 publicGtkCellArea* getCellAreaStruct(booltransferOwnership = false)
372 {
373 if (transferOwnership)
374 ownedRef = false;
375 returngtkCellArea;
376 }
377 378 /** the main Gtk struct as a void* */379 protectedoverridevoid* getStruct()
380 {
381 returncast(void*)gtkCellArea;
382 }
383 384 /**
385 * Sets our main struct and passes it to the parent class.
386 */387 publicthis (GtkCellArea* gtkCellArea, boolownedRef = false)
388 {
389 this.gtkCellArea = gtkCellArea;
390 super(cast(GObject*)gtkCellArea, ownedRef);
391 }
392 393 // add the Buildable capabilities394 mixinBuildableT!(GtkCellArea);
395 396 // add the CellLayout capabilities397 mixinCellLayoutT!(GtkCellArea);
398 399 400 /** */401 publicstaticGTypegetType()
402 {
403 returngtk_cell_area_get_type();
404 }
405 406 /**
407 * Activates @area, usually by activating the currently focused
408 * cell, however some subclasses which embed widgets in the area
409 * can also activate a widget if it currently has the focus.
410 *
411 * Params:
412 * context = the #GtkCellAreaContext in context with the current row data
413 * widget = the #GtkWidget that @area is rendering on
414 * cellArea = the size and location of @area relative to @widget’s allocation
415 * flags = the #GtkCellRendererState flags for @area for this row of data.
416 * editOnly = if %TRUE then only cell renderers that are %GTK_CELL_RENDERER_MODE_EDITABLE
417 * will be activated.
418 *
419 * Returns: Whether @area was successfully activated.
420 */421 publicboolactivate(CellAreaContextcontext, Widgetwidget, GdkRectangle* cellArea, GtkCellRendererStateflags, booleditOnly)
422 {
423 returngtk_cell_area_activate(gtkCellArea, (contextisnull) ? null : context.getCellAreaContextStruct(), (widgetisnull) ? null : widget.getWidgetStruct(), cellArea, flags, editOnly) != 0;
424 }
425 426 /**
427 * This is used by #GtkCellArea subclasses when handling events
428 * to activate cells, the base #GtkCellArea class activates cells
429 * for keyboard events for free in its own GtkCellArea->activate()
430 * implementation.
431 *
432 * Params:
433 * widget = the #GtkWidget that @area is rendering onto
434 * renderer = the #GtkCellRenderer in @area to activate
435 * event = the #GdkEvent for which cell activation should occur
436 * cellArea = the #GdkRectangle in @widget relative coordinates
437 * of @renderer for the current row.
438 * flags = the #GtkCellRendererState for @renderer
439 *
440 * Returns: whether cell activation was successful
441 */442 publicboolactivateCell(Widgetwidget, CellRendererrenderer, Eventevent, GdkRectangle* cellArea, GtkCellRendererStateflags)
443 {
444 returngtk_cell_area_activate_cell(gtkCellArea, (widgetisnull) ? null : widget.getWidgetStruct(), (rendererisnull) ? null : renderer.getCellRendererStruct(), (eventisnull) ? null : event.getEventStruct(), cellArea, flags) != 0;
445 }
446 447 /**
448 * Adds @renderer to @area with the default child cell properties.
449 *
450 * Params:
451 * renderer = the #GtkCellRenderer to add to @area
452 */453 publicvoidadd(CellRendererrenderer)
454 {
455 gtk_cell_area_add(gtkCellArea, (rendererisnull) ? null : renderer.getCellRendererStruct());
456 }
457 458 /**
459 * Adds @sibling to @renderer’s focusable area, focus will be drawn
460 * around @renderer and all of its siblings if @renderer can
461 * focus for a given row.
462 *
463 * Events handled by focus siblings can also activate the given
464 * focusable @renderer.
465 *
466 * Params:
467 * renderer = the #GtkCellRenderer expected to have focus
468 * sibling = the #GtkCellRenderer to add to @renderer’s focus area
469 */470 publicvoidaddFocusSibling(CellRendererrenderer, CellRenderersibling)
471 {
472 gtk_cell_area_add_focus_sibling(gtkCellArea, (rendererisnull) ? null : renderer.getCellRendererStruct(), (siblingisnull) ? null : sibling.getCellRendererStruct());
473 }
474 475 /**
476 * Applies any connected attributes to the renderers in
477 * @area by pulling the values from @tree_model.
478 *
479 * Params:
480 * treeModel = the #GtkTreeModel to pull values from
481 * iter = the #GtkTreeIter in @tree_model to apply values for
482 * isExpander = whether @iter has children
483 * isExpanded = whether @iter is expanded in the view and
484 * children are visible
485 */486 publicvoidapplyAttributes(TreeModelIFtreeModel, TreeIteriter, boolisExpander, boolisExpanded)
487 {
488 gtk_cell_area_apply_attributes(gtkCellArea, (treeModelisnull) ? null : treeModel.getTreeModelStruct(), (iterisnull) ? null : iter.getTreeIterStruct(), isExpander, isExpanded);
489 }
490 491 /**
492 * Connects an @attribute to apply values from @column for the
493 * #GtkTreeModel in use.
494 *
495 * Params:
496 * renderer = the #GtkCellRenderer to connect an attribute for
497 * attribute = the attribute name
498 * column = the #GtkTreeModel column to fetch attribute values from
499 */500 publicvoidattributeConnect(CellRendererrenderer, stringattribute, intcolumn)
501 {
502 gtk_cell_area_attribute_connect(gtkCellArea, (rendererisnull) ? null : renderer.getCellRendererStruct(), Str.toStringz(attribute), column);
503 }
504 505 /**
506 * Disconnects @attribute for the @renderer in @area so that
507 * attribute will no longer be updated with values from the
508 * model.
509 *
510 * Params:
511 * renderer = the #GtkCellRenderer to disconnect an attribute for
512 * attribute = the attribute name
513 */514 publicvoidattributeDisconnect(CellRendererrenderer, stringattribute)
515 {
516 gtk_cell_area_attribute_disconnect(gtkCellArea, (rendererisnull) ? null : renderer.getCellRendererStruct(), Str.toStringz(attribute));
517 }
518 519 /**
520 * Returns the model column that an attribute has been mapped to,
521 * or -1 if the attribute is not mapped.
522 *
523 * Params:
524 * renderer = a #GtkCellRenderer
525 * attribute = an attribute on the renderer
526 *
527 * Returns: the model column, or -1
528 */529 publicintattributeGetColumn(CellRendererrenderer, stringattribute)
530 {
531 returngtk_cell_area_attribute_get_column(gtkCellArea, (rendererisnull) ? null : renderer.getCellRendererStruct(), Str.toStringz(attribute));
532 }
533 534 /**
535 * Gets the value of a cell property for @renderer in @area.
536 *
537 * Params:
538 * renderer = a #GtkCellRenderer inside @area
539 * propertyName = the name of the property to get
540 * value = a location to return the value
541 */542 publicvoidcellGetProperty(CellRendererrenderer, stringpropertyName, Valuevalue)
543 {
544 gtk_cell_area_cell_get_property(gtkCellArea, (rendererisnull) ? null : renderer.getCellRendererStruct(), Str.toStringz(propertyName), (valueisnull) ? null : value.getValueStruct());
545 }
546 547 /**
548 * Gets the values of one or more cell properties for @renderer in @area.
549 *
550 * Params:
551 * renderer = a #GtkCellRenderer inside @area
552 * firstPropertyName = the name of the first property to get
553 * varArgs = return location for the first property, followed
554 * optionally by more name/return location pairs, followed by %NULL
555 */556 publicvoidcellGetValist(CellRendererrenderer, stringfirstPropertyName, void* varArgs)
557 {
558 gtk_cell_area_cell_get_valist(gtkCellArea, (rendererisnull) ? null : renderer.getCellRendererStruct(), Str.toStringz(firstPropertyName), varArgs);
559 }
560 561 /**
562 * Sets a cell property for @renderer in @area.
563 *
564 * Params:
565 * renderer = a #GtkCellRenderer inside @area
566 * propertyName = the name of the cell property to set
567 * value = the value to set the cell property to
568 */569 publicvoidcellSetProperty(CellRendererrenderer, stringpropertyName, Valuevalue)
570 {
571 gtk_cell_area_cell_set_property(gtkCellArea, (rendererisnull) ? null : renderer.getCellRendererStruct(), Str.toStringz(propertyName), (valueisnull) ? null : value.getValueStruct());
572 }
573 574 /**
575 * Sets one or more cell properties for @renderer in @area.
576 *
577 * Params:
578 * renderer = a #GtkCellRenderer which inside @area
579 * firstPropertyName = the name of the first cell property to set
580 * varArgs = a %NULL-terminated list of property names and values, starting
581 * with @first_prop_name
582 */583 publicvoidcellSetValist(CellRendererrenderer, stringfirstPropertyName, void* varArgs)
584 {
585 gtk_cell_area_cell_set_valist(gtkCellArea, (rendererisnull) ? null : renderer.getCellRendererStruct(), Str.toStringz(firstPropertyName), varArgs);
586 }
587 588 /**
589 * This is sometimes needed for cases where rows need to share
590 * alignments in one orientation but may be separately grouped
591 * in the opposing orientation.
592 *
593 * For instance, #GtkIconView creates all icons (rows) to have
594 * the same width and the cells theirin to have the same
595 * horizontal alignments. However each row of icons may have
596 * a separate collective height. #GtkIconView uses this to
597 * request the heights of each row based on a context which
598 * was already used to request all the row widths that are
599 * to be displayed.
600 *
601 * Params:
602 * context = the #GtkCellAreaContext to copy
603 *
604 * Returns: a newly created #GtkCellAreaContext copy of @context.
605 */606 publicCellAreaContextcopyContext(CellAreaContextcontext)
607 {
608 auto__p = gtk_cell_area_copy_context(gtkCellArea, (contextisnull) ? null : context.getCellAreaContextStruct());
609 610 if(__pisnull)
611 {
612 returnnull;
613 }
614 615 returnObjectG.getDObject!(CellAreaContext)(cast(GtkCellAreaContext*) __p, true);
616 }
617 618 /**
619 * Creates a #GtkCellAreaContext to be used with @area for
620 * all purposes. #GtkCellAreaContext stores geometry information
621 * for rows for which it was operated on, it is important to use
622 * the same context for the same row of data at all times (i.e.
623 * one should render and handle events with the same #GtkCellAreaContext
624 * which was used to request the size of those rows of data).
625 *
626 * Returns: a newly created #GtkCellAreaContext which can be used with @area.
627 */628 publicCellAreaContextcreateContext()
629 {
630 auto__p = gtk_cell_area_create_context(gtkCellArea);
631 632 if(__pisnull)
633 {
634 returnnull;
635 }
636 637 returnObjectG.getDObject!(CellAreaContext)(cast(GtkCellAreaContext*) __p, true);
638 }
639 640 /**
641 * Delegates event handling to a #GtkCellArea.
642 *
643 * Params:
644 * context = the #GtkCellAreaContext for this row of data.
645 * widget = the #GtkWidget that @area is rendering to
646 * event = the #GdkEvent to handle
647 * cellArea = the @widget relative coordinates for @area
648 * flags = the #GtkCellRendererState for @area in this row.
649 *
650 * Returns: %TRUE if the event was handled by @area.
651 */652 publicintevent(CellAreaContextcontext, Widgetwidget, Eventevent, GdkRectangle* cellArea, GtkCellRendererStateflags)
653 {
654 returngtk_cell_area_event(gtkCellArea, (contextisnull) ? null : context.getCellAreaContextStruct(), (widgetisnull) ? null : widget.getWidgetStruct(), (eventisnull) ? null : event.getEventStruct(), cellArea, flags);
655 }
656 657 /**
658 * This should be called by the @area’s owning layout widget
659 * when focus is to be passed to @area, or moved within @area
660 * for a given @direction and row data.
661 *
662 * Implementing #GtkCellArea classes should implement this
663 * method to receive and navigate focus in its own way particular
664 * to how it lays out cells.
665 *
666 * Params:
667 * direction = the #GtkDirectionType
668 *
669 * Returns: %TRUE if focus remains inside @area as a result of this call.
670 */671 publicboolfocus(GtkDirectionTypedirection)
672 {
673 returngtk_cell_area_focus(gtkCellArea, direction) != 0;
674 }
675 676 aliasforeac = foreach_;
677 /**
678 * Calls @callback for every #GtkCellRenderer in @area.
679 *
680 * Params:
681 * callback = the #GtkCellCallback to call
682 * callbackData = user provided data pointer
683 */684 publicvoidforeach_(GtkCellCallbackcallback, void* callbackData)
685 {
686 gtk_cell_area_foreach(gtkCellArea, callback, callbackData);
687 }
688 689 /**
690 * Calls @callback for every #GtkCellRenderer in @area with the
691 * allocated rectangle inside @cell_area.
692 *
693 * Params:
694 * context = the #GtkCellAreaContext for this row of data.
695 * widget = the #GtkWidget that @area is rendering to
696 * cellArea = the @widget relative coordinates and size for @area
697 * backgroundArea = the @widget relative coordinates of the background area
698 * callback = the #GtkCellAllocCallback to call
699 * callbackData = user provided data pointer
700 */701 publicvoidforeachAlloc(CellAreaContextcontext, Widgetwidget, GdkRectangle* cellArea, GdkRectangle* backgroundArea, GtkCellAllocCallbackcallback, void* callbackData)
702 {
703 gtk_cell_area_foreach_alloc(gtkCellArea, (contextisnull) ? null : context.getCellAreaContextStruct(), (widgetisnull) ? null : widget.getWidgetStruct(), cellArea, backgroundArea, callback, callbackData);
704 }
705 706 /**
707 * Derives the allocation of @renderer inside @area if @area
708 * were to be renderered in @cell_area.
709 *
710 * Params:
711 * context = the #GtkCellAreaContext used to hold sizes for @area.
712 * widget = the #GtkWidget that @area is rendering on
713 * renderer = the #GtkCellRenderer to get the allocation for
714 * cellArea = the whole allocated area for @area in @widget
715 * for this row
716 * allocation = where to store the allocation for @renderer
717 */718 publicvoidgetCellAllocation(CellAreaContextcontext, Widgetwidget, CellRendererrenderer, GdkRectangle* cellArea, outGdkRectangleallocation)
719 {
720 gtk_cell_area_get_cell_allocation(gtkCellArea, (contextisnull) ? null : context.getCellAreaContextStruct(), (widgetisnull) ? null : widget.getWidgetStruct(), (rendererisnull) ? null : renderer.getCellRendererStruct(), cellArea, &allocation);
721 }
722 723 /**
724 * Gets the #GtkCellRenderer at @x and @y coordinates inside @area and optionally
725 * returns the full cell allocation for it inside @cell_area.
726 *
727 * Params:
728 * context = the #GtkCellAreaContext used to hold sizes for @area.
729 * widget = the #GtkWidget that @area is rendering on
730 * cellArea = the whole allocated area for @area in @widget
731 * for this row
732 * x = the x position
733 * y = the y position
734 * allocArea = where to store the inner allocated area of the
735 * returned cell renderer, or %NULL.
736 *
737 * Returns: the #GtkCellRenderer at @x and @y.
738 */739 publicCellRenderergetCellAtPosition(CellAreaContextcontext, Widgetwidget, GdkRectangle* cellArea, intx, inty, outGdkRectangleallocArea)
740 {
741 auto__p = gtk_cell_area_get_cell_at_position(gtkCellArea, (contextisnull) ? null : context.getCellAreaContextStruct(), (widgetisnull) ? null : widget.getWidgetStruct(), cellArea, x, y, &allocArea);
742 743 if(__pisnull)
744 {
745 returnnull;
746 }
747 748 returnObjectG.getDObject!(CellRenderer)(cast(GtkCellRenderer*) __p);
749 }
750 751 /**
752 * Gets the current #GtkTreePath string for the currently
753 * applied #GtkTreeIter, this is implicitly updated when
754 * gtk_cell_area_apply_attributes() is called and can be
755 * used to interact with renderers from #GtkCellArea
756 * subclasses.
757 *
758 * Returns: The current #GtkTreePath string for the current
759 * attributes applied to @area. This string belongs to the area and
760 * should not be freed.
761 */762 publicstringgetCurrentPathString()
763 {
764 returnStr.toString(gtk_cell_area_get_current_path_string(gtkCellArea));
765 }
766 767 /**
768 * Gets the #GtkCellEditable widget currently used
769 * to edit the currently edited cell.
770 *
771 * Returns: The currently active #GtkCellEditable widget
772 */773 publicCellEditableIFgetEditWidget()
774 {
775 auto__p = gtk_cell_area_get_edit_widget(gtkCellArea);
776 777 if(__pisnull)
778 {
779 returnnull;
780 }
781 782 returnObjectG.getDObject!(CellEditableIF)(cast(GtkCellEditable*) __p);
783 }
784 785 /**
786 * Gets the #GtkCellRenderer in @area that is currently
787 * being edited.
788 *
789 * Returns: The currently edited #GtkCellRenderer
790 */791 publicCellRenderergetEditedCell()
792 {
793 auto__p = gtk_cell_area_get_edited_cell(gtkCellArea);
794 795 if(__pisnull)
796 {
797 returnnull;
798 }
799 800 returnObjectG.getDObject!(CellRenderer)(cast(GtkCellRenderer*) __p);
801 }
802 803 /**
804 * Retrieves the currently focused cell for @area
805 *
806 * Returns: the currently focused cell in @area.
807 */808 publicCellRenderergetFocusCell()
809 {
810 auto__p = gtk_cell_area_get_focus_cell(gtkCellArea);
811 812 if(__pisnull)
813 {
814 returnnull;
815 }
816 817 returnObjectG.getDObject!(CellRenderer)(cast(GtkCellRenderer*) __p);
818 }
819 820 /**
821 * Gets the #GtkCellRenderer which is expected to be focusable
822 * for which @renderer is, or may be a sibling.
823 *
824 * This is handy for #GtkCellArea subclasses when handling events,
825 * after determining the renderer at the event location it can
826 * then chose to activate the focus cell for which the event
827 * cell may have been a sibling.
828 *
829 * Params:
830 * renderer = the #GtkCellRenderer
831 *
832 * Returns: the #GtkCellRenderer for which @renderer
833 * is a sibling, or %NULL.
834 */835 publicCellRenderergetFocusFromSibling(CellRendererrenderer)
836 {
837 auto__p = gtk_cell_area_get_focus_from_sibling(gtkCellArea, (rendererisnull) ? null : renderer.getCellRendererStruct());
838 839 if(__pisnull)
840 {
841 returnnull;
842 }
843 844 returnObjectG.getDObject!(CellRenderer)(cast(GtkCellRenderer*) __p);
845 }
846 847 /**
848 * Gets the focus sibling cell renderers for @renderer.
849 *
850 * Params:
851 * renderer = the #GtkCellRenderer expected to have focus
852 *
853 * Returns: A #GList of #GtkCellRenderers.
854 * The returned list is internal and should not be freed.
855 */856 publicListGgetFocusSiblings(CellRendererrenderer)
857 {
858 auto__p = gtk_cell_area_get_focus_siblings(gtkCellArea, (rendererisnull) ? null : renderer.getCellRendererStruct());
859 860 if(__pisnull)
861 {
862 returnnull;
863 }
864 865 returnnewListG(cast(GList*) __p);
866 }
867 868 /**
869 * Retrieves a cell area’s initial minimum and natural height.
870 *
871 * @area will store some geometrical information in @context along the way;
872 * when requesting sizes over an arbitrary number of rows, it’s not important
873 * to check the @minimum_height and @natural_height of this call but rather to
874 * consult gtk_cell_area_context_get_preferred_height() after a series of
875 * requests.
876 *
877 * Params:
878 * context = the #GtkCellAreaContext to perform this request with
879 * widget = the #GtkWidget where @area will be rendering
880 * minimumHeight = location to store the minimum height, or %NULL
881 * naturalHeight = location to store the natural height, or %NULL
882 */883 publicvoidgetPreferredHeight(CellAreaContextcontext, Widgetwidget, outintminimumHeight, outintnaturalHeight)
884 {
885 gtk_cell_area_get_preferred_height(gtkCellArea, (contextisnull) ? null : context.getCellAreaContextStruct(), (widgetisnull) ? null : widget.getWidgetStruct(), &minimumHeight, &naturalHeight);
886 }
887 888 /**
889 * Retrieves a cell area’s minimum and natural height if it would be given
890 * the specified @width.
891 *
892 * @area stores some geometrical information in @context along the way
893 * while calling gtk_cell_area_get_preferred_width(). It’s important to
894 * perform a series of gtk_cell_area_get_preferred_width() requests with
895 * @context first and then call gtk_cell_area_get_preferred_height_for_width()
896 * on each cell area individually to get the height for width of each
897 * fully requested row.
898 *
899 * If at some point, the width of a single row changes, it should be
900 * requested with gtk_cell_area_get_preferred_width() again and then
901 * the full width of the requested rows checked again with
902 * gtk_cell_area_context_get_preferred_width().
903 *
904 * Params:
905 * context = the #GtkCellAreaContext which has already been requested for widths.
906 * widget = the #GtkWidget where @area will be rendering
907 * width = the width for which to check the height of this area
908 * minimumHeight = location to store the minimum height, or %NULL
909 * naturalHeight = location to store the natural height, or %NULL
910 */911 publicvoidgetPreferredHeightForWidth(CellAreaContextcontext, Widgetwidget, intwidth, outintminimumHeight, outintnaturalHeight)
912 {
913 gtk_cell_area_get_preferred_height_for_width(gtkCellArea, (contextisnull) ? null : context.getCellAreaContextStruct(), (widgetisnull) ? null : widget.getWidgetStruct(), width, &minimumHeight, &naturalHeight);
914 }
915 916 /**
917 * Retrieves a cell area’s initial minimum and natural width.
918 *
919 * @area will store some geometrical information in @context along the way;
920 * when requesting sizes over an arbitrary number of rows, it’s not important
921 * to check the @minimum_width and @natural_width of this call but rather to
922 * consult gtk_cell_area_context_get_preferred_width() after a series of
923 * requests.
924 *
925 * Params:
926 * context = the #GtkCellAreaContext to perform this request with
927 * widget = the #GtkWidget where @area will be rendering
928 * minimumWidth = location to store the minimum width, or %NULL
929 * naturalWidth = location to store the natural width, or %NULL
930 */931 publicvoidgetPreferredWidth(CellAreaContextcontext, Widgetwidget, outintminimumWidth, outintnaturalWidth)
932 {
933 gtk_cell_area_get_preferred_width(gtkCellArea, (contextisnull) ? null : context.getCellAreaContextStruct(), (widgetisnull) ? null : widget.getWidgetStruct(), &minimumWidth, &naturalWidth);
934 }
935 936 /**
937 * Retrieves a cell area’s minimum and natural width if it would be given
938 * the specified @height.
939 *
940 * @area stores some geometrical information in @context along the way
941 * while calling gtk_cell_area_get_preferred_height(). It’s important to
942 * perform a series of gtk_cell_area_get_preferred_height() requests with
943 * @context first and then call gtk_cell_area_get_preferred_width_for_height()
944 * on each cell area individually to get the height for width of each
945 * fully requested row.
946 *
947 * If at some point, the height of a single row changes, it should be
948 * requested with gtk_cell_area_get_preferred_height() again and then
949 * the full height of the requested rows checked again with
950 * gtk_cell_area_context_get_preferred_height().
951 *
952 * Params:
953 * context = the #GtkCellAreaContext which has already been requested for widths.
954 * widget = the #GtkWidget where @area will be rendering
955 * height = the height for which to check the width of this area
956 * minimumWidth = location to store the minimum width, or %NULL
957 * naturalWidth = location to store the natural width, or %NULL
958 */959 publicvoidgetPreferredWidthForHeight(CellAreaContextcontext, Widgetwidget, intheight, outintminimumWidth, outintnaturalWidth)
960 {
961 gtk_cell_area_get_preferred_width_for_height(gtkCellArea, (contextisnull) ? null : context.getCellAreaContextStruct(), (widgetisnull) ? null : widget.getWidgetStruct(), height, &minimumWidth, &naturalWidth);
962 }
963 964 /**
965 * Gets whether the area prefers a height-for-width layout
966 * or a width-for-height layout.
967 *
968 * Returns: The #GtkSizeRequestMode preferred by @area.
969 */970 publicGtkSizeRequestModegetRequestMode()
971 {
972 returngtk_cell_area_get_request_mode(gtkCellArea);
973 }
974 975 /**
976 * Checks if @area contains @renderer.
977 *
978 * Params:
979 * renderer = the #GtkCellRenderer to check
980 *
981 * Returns: %TRUE if @renderer is in the @area.
982 */983 publicboolhasRenderer(CellRendererrenderer)
984 {
985 returngtk_cell_area_has_renderer(gtkCellArea, (rendererisnull) ? null : renderer.getCellRendererStruct()) != 0;
986 }
987 988 /**
989 * This is a convenience function for #GtkCellArea implementations
990 * to get the inner area where a given #GtkCellRenderer will be
991 * rendered. It removes any padding previously added by gtk_cell_area_request_renderer().
992 *
993 * Params:
994 * widget = the #GtkWidget that @area is rendering onto
995 * cellArea = the @widget relative coordinates where one of @area’s cells
996 * is to be placed
997 * innerArea = the return location for the inner cell area
998 */999 publicvoidinnerCellArea(Widgetwidget, GdkRectangle* cellArea, outGdkRectangleinnerArea)
1000 {
1001 gtk_cell_area_inner_cell_area(gtkCellArea, (widgetisnull) ? null : widget.getWidgetStruct(), cellArea, &innerArea);
1002 }
1003 1004 /**
1005 * Returns whether the area can do anything when activated,
1006 * after applying new attributes to @area.
1007 *
1008 * Returns: whether @area can do anything when activated.
1009 */1010 publicboolisActivatable()
1011 {
1012 returngtk_cell_area_is_activatable(gtkCellArea) != 0;
1013 }
1014 1015 /**
1016 * Returns whether @sibling is one of @renderer’s focus siblings
1017 * (see gtk_cell_area_add_focus_sibling()).
1018 *
1019 * Params:
1020 * renderer = the #GtkCellRenderer expected to have focus
1021 * sibling = the #GtkCellRenderer to check against @renderer’s sibling list
1022 *
1023 * Returns: %TRUE if @sibling is a focus sibling of @renderer
1024 */1025 publicboolisFocusSibling(CellRendererrenderer, CellRenderersibling)
1026 {
1027 returngtk_cell_area_is_focus_sibling(gtkCellArea, (rendererisnull) ? null : renderer.getCellRendererStruct(), (siblingisnull) ? null : sibling.getCellRendererStruct()) != 0;
1028 }
1029 1030 /**
1031 * Removes @renderer from @area.
1032 *
1033 * Params:
1034 * renderer = the #GtkCellRenderer to remove from @area
1035 */1036 publicvoidremove(CellRendererrenderer)
1037 {
1038 gtk_cell_area_remove(gtkCellArea, (rendererisnull) ? null : renderer.getCellRendererStruct());
1039 }
1040 1041 /**
1042 * Removes @sibling from @renderer’s focus sibling list
1043 * (see gtk_cell_area_add_focus_sibling()).
1044 *
1045 * Params:
1046 * renderer = the #GtkCellRenderer expected to have focus
1047 * sibling = the #GtkCellRenderer to remove from @renderer’s focus area
1048 */1049 publicvoidremoveFocusSibling(CellRendererrenderer, CellRenderersibling)
1050 {
1051 gtk_cell_area_remove_focus_sibling(gtkCellArea, (rendererisnull) ? null : renderer.getCellRendererStruct(), (siblingisnull) ? null : sibling.getCellRendererStruct());
1052 }
1053 1054 /**
1055 * This is a convenience function for #GtkCellArea implementations
1056 * to request size for cell renderers. It’s important to use this
1057 * function to request size and then use gtk_cell_area_inner_cell_area()
1058 * at render and event time since this function will add padding
1059 * around the cell for focus painting.
1060 *
1061 * Params:
1062 * renderer = the #GtkCellRenderer to request size for
1063 * orientation = the #GtkOrientation in which to request size
1064 * widget = the #GtkWidget that @area is rendering onto
1065 * forSize = the allocation contextual size to request for, or -1 if
1066 * the base request for the orientation is to be returned.
1067 * minimumSize = location to store the minimum size, or %NULL
1068 * naturalSize = location to store the natural size, or %NULL
1069 */1070 publicvoidrequestRenderer(CellRendererrenderer, GtkOrientationorientation, Widgetwidget, intforSize, outintminimumSize, outintnaturalSize)
1071 {
1072 gtk_cell_area_request_renderer(gtkCellArea, (rendererisnull) ? null : renderer.getCellRendererStruct(), orientation, (widgetisnull) ? null : widget.getWidgetStruct(), forSize, &minimumSize, &naturalSize);
1073 }
1074 1075 /**
1076 * Explicitly sets the currently focused cell to @renderer.
1077 *
1078 * This is generally called by implementations of
1079 * #GtkCellAreaClass.focus() or #GtkCellAreaClass.event(),
1080 * however it can also be used to implement functions such
1081 * as gtk_tree_view_set_cursor_on_cell().
1082 *
1083 * Params:
1084 * renderer = the #GtkCellRenderer to give focus to
1085 */1086 publicvoidsetFocusCell(CellRendererrenderer)
1087 {
1088 gtk_cell_area_set_focus_cell(gtkCellArea, (rendererisnull) ? null : renderer.getCellRendererStruct());
1089 }
1090 1091 /**
1092 * Snapshots @area’s cells according to @area’s layout onto at
1093 * the given coordinates.
1094 *
1095 * Params:
1096 * context = the #GtkCellAreaContext for this row of data.
1097 * widget = the #GtkWidget that @area is rendering to
1098 * snapshot = the #GtkSnapshot to draw to
1099 * backgroundArea = the @widget relative coordinates for @area’s background
1100 * cellArea = the @widget relative coordinates for @area
1101 * flags = the #GtkCellRendererState for @area in this row.
1102 * paintFocus = whether @area should paint focus on focused cells for focused rows or not.
1103 */1104 publicvoidsnapshot(CellAreaContextcontext, Widgetwidget, Snapshotsnapshot, GdkRectangle* backgroundArea, GdkRectangle* cellArea, GtkCellRendererStateflags, boolpaintFocus)
1105 {
1106 gtk_cell_area_snapshot(gtkCellArea, (contextisnull) ? null : context.getCellAreaContextStruct(), (widgetisnull) ? null : widget.getWidgetStruct(), (snapshotisnull) ? null : snapshot.getGtkSnapshotStruct(), backgroundArea, cellArea, flags, paintFocus);
1107 }
1108 1109 /**
1110 * Explicitly stops the editing of the currently edited cell.
1111 *
1112 * If @canceled is %TRUE, the currently edited cell renderer
1113 * will emit the ::editing-canceled signal, otherwise the
1114 * the ::editing-done signal will be emitted on the current
1115 * edit widget.
1116 *
1117 * See gtk_cell_area_get_edited_cell() and gtk_cell_area_get_edit_widget().
1118 *
1119 * Params:
1120 * canceled = whether editing was canceled.
1121 */1122 publicvoidstopEditing(boolcanceled)
1123 {
1124 gtk_cell_area_stop_editing(gtkCellArea, canceled);
1125 }
1126 1127 /**
1128 * Indicates that editing has started on @renderer and that @editable
1129 * should be added to the owning cell-layouting widget at @cell_area.
1130 *
1131 * Params:
1132 * renderer = the #GtkCellRenderer that started the edited
1133 * editable = the #GtkCellEditable widget to add
1134 * cellArea = the #GtkWidget relative #GdkRectangle coordinates
1135 * where @editable should be added
1136 * path = the #GtkTreePath string this edit was initiated for
1137 */1138 gulongaddOnAddEditable(voiddelegate(CellRenderer, CellEditableIF, GdkRectangle*, string, CellArea) dlg, ConnectFlagsconnectFlags=cast(ConnectFlags)0)
1139 {
1140 returnSignals.connect(this, "add-editable", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1141 }
1142 1143 /**
1144 * This signal is emitted whenever applying attributes to @area from @model
1145 *
1146 * Params:
1147 * model = the #GtkTreeModel to apply the attributes from
1148 * iter = the #GtkTreeIter indicating which row to apply the attributes of
1149 * isExpander = whether the view shows children for this row
1150 * isExpanded = whether the view is currently showing the children of this row
1151 */1152 gulongaddOnApplyAttributes(voiddelegate(TreeModelIF, TreeIter, bool, bool, CellArea) dlg, ConnectFlagsconnectFlags=cast(ConnectFlags)0)
1153 {
1154 returnSignals.connect(this, "apply-attributes", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1155 }
1156 1157 /**
1158 * Indicates that focus changed on this @area. This signal
1159 * is emitted either as a result of focus handling or event
1160 * handling.
1161 *
1162 * It's possible that the signal is emitted even if the
1163 * currently focused renderer did not change, this is
1164 * because focus may change to the same renderer in the
1165 * same cell area for a different row of data.
1166 *
1167 * Params:
1168 * renderer = the #GtkCellRenderer that has focus
1169 * path = the current #GtkTreePath string set for @area
1170 */1171 gulongaddOnFocusChanged(voiddelegate(CellRenderer, string, CellArea) dlg, ConnectFlagsconnectFlags=cast(ConnectFlags)0)
1172 {
1173 returnSignals.connect(this, "focus-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1174 }
1175 1176 /**
1177 * Indicates that editing finished on @renderer and that @editable
1178 * should be removed from the owning cell-layouting widget.
1179 *
1180 * Params:
1181 * renderer = the #GtkCellRenderer that finished editeding
1182 * editable = the #GtkCellEditable widget to remove
1183 */1184 gulongaddOnRemoveEditable(voiddelegate(CellRenderer, CellEditableIF, CellArea) dlg, ConnectFlagsconnectFlags=cast(ConnectFlags)0)
1185 {
1186 returnSignals.connect(this, "remove-editable", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1187 }
1188 }