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.Bin;
31 private import gtk.Widget;
32 private import gtkc.gtk;
33 public  import gtkc.gtktypes;
34 private import std.algorithm;
35 
36 
37 /** */
38 public class FlowBoxChild : Bin
39 {
40 	/** the main Gtk struct */
41 	protected GtkFlowBoxChild* gtkFlowBoxChild;
42 
43 	/** Get the main Gtk struct */
44 	public GtkFlowBoxChild* getFlowBoxChildStruct()
45 	{
46 		return gtkFlowBoxChild;
47 	}
48 
49 	/** the main Gtk struct as a void* */
50 	protected override void* getStruct()
51 	{
52 		return cast(void*)gtkFlowBoxChild;
53 	}
54 
55 	protected override void setStruct(GObject* obj)
56 	{
57 		gtkFlowBoxChild = cast(GtkFlowBoxChild*)obj;
58 		super.setStruct(obj);
59 	}
60 
61 	/**
62 	 * Sets our main struct and passes it to the parent class.
63 	 */
64 	public this (GtkFlowBoxChild* gtkFlowBoxChild, bool ownedRef = false)
65 	{
66 		this.gtkFlowBoxChild = gtkFlowBoxChild;
67 		super(cast(GtkBin*)gtkFlowBoxChild, ownedRef);
68 	}
69 
70 
71 	/** */
72 	public static GType getType()
73 	{
74 		return gtk_flow_box_child_get_type();
75 	}
76 
77 	/**
78 	 * Creates a new #GtkFlowBoxChild, to be used as a child
79 	 * of a #GtkFlowBox.
80 	 *
81 	 * Returns: a new #GtkFlowBoxChild
82 	 *
83 	 * Since: 3.12
84 	 *
85 	 * Throws: ConstructionException GTK+ fails to create the object.
86 	 */
87 	public this()
88 	{
89 		auto p = gtk_flow_box_child_new();
90 		
91 		if(p is null)
92 		{
93 			throw new ConstructionException("null returned by new");
94 		}
95 		
96 		this(cast(GtkFlowBoxChild*) p);
97 	}
98 
99 	/**
100 	 * Marks @child as changed, causing any state that depends on this
101 	 * to be updated. This affects sorting and filtering.
102 	 *
103 	 * Note that calls to this method must be in sync with the data
104 	 * used for the sorting and filtering functions. For instance, if
105 	 * the list is mirroring some external data set, and *two* children
106 	 * changed in the external data set when you call
107 	 * gtk_flow_box_child_changed() on the first child, the sort function
108 	 * must only read the new data for the first of the two changed
109 	 * children, otherwise the resorting of the children will be wrong.
110 	 *
111 	 * This generally means that if you don’t fully control the data
112 	 * model, you have to duplicate the data that affects the sorting
113 	 * and filtering functions into the widgets themselves. Another
114 	 * alternative is to call gtk_flow_box_invalidate_sort() on any
115 	 * model change, but that is more expensive.
116 	 *
117 	 * Since: 3.12
118 	 */
119 	public void changed()
120 	{
121 		gtk_flow_box_child_changed(gtkFlowBoxChild);
122 	}
123 
124 	/**
125 	 * Gets the current index of the @child in its #GtkFlowBox container.
126 	 *
127 	 * Returns: the index of the @child, or -1 if the @child is not
128 	 *     in a flow box.
129 	 *
130 	 * Since: 3.12
131 	 */
132 	public int getIndex()
133 	{
134 		return gtk_flow_box_child_get_index(gtkFlowBoxChild);
135 	}
136 
137 	/**
138 	 * Returns whether the @child is currently selected in its
139 	 * #GtkFlowBox container.
140 	 *
141 	 * Returns: %TRUE if @child is selected
142 	 *
143 	 * Since: 3.12
144 	 */
145 	public bool isSelected()
146 	{
147 		return gtk_flow_box_child_is_selected(gtkFlowBoxChild) != 0;
148 	}
149 
150 	protected class OnActivateDelegateWrapper
151 	{
152 		static OnActivateDelegateWrapper[] listeners;
153 		void delegate(FlowBoxChild) dlg;
154 		gulong handlerId;
155 		
156 		this(void delegate(FlowBoxChild) dlg)
157 		{
158 			this.dlg = dlg;
159 			this.listeners ~= this;
160 		}
161 		
162 		void remove(OnActivateDelegateWrapper source)
163 		{
164 			foreach(index, wrapper; listeners)
165 			{
166 				if (wrapper.handlerId == source.handlerId)
167 				{
168 					listeners[index] = null;
169 					listeners = std.algorithm.remove(listeners, index);
170 					break;
171 				}
172 			}
173 		}
174 	}
175 
176 	/**
177 	 * The ::activate signal is emitted when the user activates
178 	 * a child widget in a #GtkFlowBox, either by clicking or
179 	 * double-clicking, or by using the Space or Enter key.
180 	 *
181 	 * While this signal is used as a
182 	 * [keybinding signal][GtkBindingSignal],
183 	 * it can be used by applications for their own purposes.
184 	 */
185 	gulong addOnActivate(void delegate(FlowBoxChild) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
186 	{
187 		auto wrapper = new OnActivateDelegateWrapper(dlg);
188 		wrapper.handlerId = Signals.connectData(
189 			this,
190 			"activate",
191 			cast(GCallback)&callBackActivate,
192 			cast(void*)wrapper,
193 			cast(GClosureNotify)&callBackActivateDestroy,
194 			connectFlags);
195 		return wrapper.handlerId;
196 	}
197 	
198 	extern(C) static void callBackActivate(GtkFlowBoxChild* flowboxchildStruct, OnActivateDelegateWrapper wrapper)
199 	{
200 		wrapper.dlg(wrapper.outer);
201 	}
202 	
203 	extern(C) static void callBackActivateDestroy(OnActivateDelegateWrapper wrapper, GClosure* closure)
204 	{
205 		wrapper.remove(wrapper);
206 	}
207 }