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.FlowBoxChild;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gobject.Signals;
30 private import gtk.Widget;
31 private import gtk.c.functions;
32 public  import gtk.c.types;
33 private import std.algorithm;
34 
35 
36 /**
37  * `GtkFlowBoxChild` is the kind of widget that can be added to a `GtkFlowBox`.
38  */
39 public class FlowBoxChild : Widget
40 {
41 	/** the main Gtk struct */
42 	protected GtkFlowBoxChild* gtkFlowBoxChild;
43 
44 	/** Get the main Gtk struct */
45 	public GtkFlowBoxChild* getFlowBoxChildStruct(bool transferOwnership = false)
46 	{
47 		if (transferOwnership)
48 			ownedRef = false;
49 		return gtkFlowBoxChild;
50 	}
51 
52 	/** the main Gtk struct as a void* */
53 	protected override void* getStruct()
54 	{
55 		return cast(void*)gtkFlowBoxChild;
56 	}
57 
58 	/**
59 	 * Sets our main struct and passes it to the parent class.
60 	 */
61 	public this (GtkFlowBoxChild* gtkFlowBoxChild, bool ownedRef = false)
62 	{
63 		this.gtkFlowBoxChild = gtkFlowBoxChild;
64 		super(cast(GtkWidget*)gtkFlowBoxChild, ownedRef);
65 	}
66 
67 
68 	/** */
69 	public static GType getType()
70 	{
71 		return gtk_flow_box_child_get_type();
72 	}
73 
74 	/**
75 	 * Creates a new `GtkFlowBoxChild`.
76 	 *
77 	 * This should only be used as a child of a `GtkFlowBox`.
78 	 *
79 	 * Returns: a new `GtkFlowBoxChild`
80 	 *
81 	 * Throws: ConstructionException GTK+ fails to create the object.
82 	 */
83 	public this()
84 	{
85 		auto __p = gtk_flow_box_child_new();
86 
87 		if(__p is null)
88 		{
89 			throw new ConstructionException("null returned by new");
90 		}
91 
92 		this(cast(GtkFlowBoxChild*) __p);
93 	}
94 
95 	/**
96 	 * Marks @child as changed, causing any state that depends on this
97 	 * to be updated.
98 	 *
99 	 * This affects sorting and filtering.
100 	 *
101 	 * Note that calls to this method must be in sync with the data
102 	 * used for the sorting and filtering functions. For instance, if
103 	 * the list is mirroring some external data set, and *two* children
104 	 * changed in the external data set when you call
105 	 * gtk_flow_box_child_changed() on the first child, the sort function
106 	 * must only read the new data for the first of the two changed
107 	 * children, otherwise the resorting of the children will be wrong.
108 	 *
109 	 * This generally means that if you don’t fully control the data
110 	 * model, you have to duplicate the data that affects the sorting
111 	 * and filtering functions into the widgets themselves.
112 	 *
113 	 * Another alternative is to call [method@Gtk.FlowBox.invalidate_sort]
114 	 * on any model change, but that is more expensive.
115 	 */
116 	public void changed()
117 	{
118 		gtk_flow_box_child_changed(gtkFlowBoxChild);
119 	}
120 
121 	/**
122 	 * Gets the child widget of @self.
123 	 *
124 	 * Returns: the child widget of @self
125 	 */
126 	public Widget getChild()
127 	{
128 		auto __p = gtk_flow_box_child_get_child(gtkFlowBoxChild);
129 
130 		if(__p is null)
131 		{
132 			return null;
133 		}
134 
135 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p);
136 	}
137 
138 	/**
139 	 * Gets the current index of the @child in its `GtkFlowBox` container.
140 	 *
141 	 * Returns: the index of the @child, or -1 if the @child is not
142 	 *     in a flow box.
143 	 */
144 	public int getIndex()
145 	{
146 		return gtk_flow_box_child_get_index(gtkFlowBoxChild);
147 	}
148 
149 	/**
150 	 * Returns whether the @child is currently selected in its
151 	 * `GtkFlowBox` container.
152 	 *
153 	 * Returns: %TRUE if @child is selected
154 	 */
155 	public bool isSelected()
156 	{
157 		return gtk_flow_box_child_is_selected(gtkFlowBoxChild) != 0;
158 	}
159 
160 	/**
161 	 * Sets the child widget of @self.
162 	 *
163 	 * Params:
164 	 *     child = the child widget
165 	 */
166 	public void setChild(Widget child)
167 	{
168 		gtk_flow_box_child_set_child(gtkFlowBoxChild, (child is null) ? null : child.getWidgetStruct());
169 	}
170 
171 	/**
172 	 * Emitted when the user activates a child widget in a `GtkFlowBox`.
173 	 *
174 	 * This can be happen either by clicking or double-clicking,
175 	 * or via a keybinding.
176 	 *
177 	 * This is a [keybinding signal](class.SignalAction.html),
178 	 * but it can be used by applications for their own purposes.
179 	 *
180 	 * The default bindings are <kbd>Space</kbd> and <kbd>Enter</kbd>.
181 	 */
182 	gulong addOnActivate(void delegate(FlowBoxChild) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
183 	{
184 		return Signals.connect(this, "activate", dlg, connectFlags ^ ConnectFlags.SWAPPED);
185 	}
186 }