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 atk.SelectionT;
26 
27 public  import atk.ObjectAtk;
28 public  import gobject.ObjectG;
29 public  import gobject.Signals;
30 public  import gtkc.atk;
31 public  import gtkc.atktypes;
32 public  import gtkc.gdktypes;
33 
34 
35 /**
36  * #AtkSelection should be implemented by UI components with children
37  * which are exposed by #atk_object_ref_child and
38  * #atk_object_get_n_children, if the use of the parent UI component
39  * ordinarily involves selection of one or more of the objects
40  * corresponding to those #AtkObject children - for example,
41  * selectable lists.
42  * 
43  * Note that other types of "selection" (for instance text selection)
44  * are accomplished a other ATK interfaces - #AtkSelection is limited
45  * to the selection/deselection of children.
46  */
47 public template SelectionT(TStruct)
48 {
49 	/** Get the main Gtk struct */
50 	public AtkSelection* getSelectionStruct()
51 	{
52 		return cast(AtkSelection*)getStruct();
53 	}
54 
55 	/**
56 	 */
57 
58 	/**
59 	 * Adds the specified accessible child of the object to the
60 	 * object's selection.
61 	 *
62 	 * Params:
63 	 *     i = a #gint specifying the child index.
64 	 *
65 	 * Return: TRUE if success, FALSE otherwise.
66 	 */
67 	public bool addSelection(int i)
68 	{
69 		return atk_selection_add_selection(getSelectionStruct(), i) != 0;
70 	}
71 
72 	/**
73 	 * Clears the selection in the object so that no children in the object
74 	 * are selected.
75 	 *
76 	 * Return: TRUE if success, FALSE otherwise.
77 	 */
78 	public bool clearSelection()
79 	{
80 		return atk_selection_clear_selection(getSelectionStruct()) != 0;
81 	}
82 
83 	/**
84 	 * Gets the number of accessible children currently selected.
85 	 * Note: callers should not rely on %NULL or on a zero value for
86 	 * indication of whether AtkSelectionIface is implemented, they should
87 	 * use type checking/interface checking macros or the
88 	 * atk_get_accessible_value() convenience method.
89 	 *
90 	 * Return: a gint representing the number of items selected, or 0
91 	 *     if @selection does not implement this interface.
92 	 */
93 	public int getSelectionCount()
94 	{
95 		return atk_selection_get_selection_count(getSelectionStruct());
96 	}
97 
98 	/**
99 	 * Determines if the current child of this object is selected
100 	 * Note: callers should not rely on %NULL or on a zero value for
101 	 * indication of whether AtkSelectionIface is implemented, they should
102 	 * use type checking/interface checking macros or the
103 	 * atk_get_accessible_value() convenience method.
104 	 *
105 	 * Params:
106 	 *     i = a #gint specifying the child index.
107 	 *
108 	 * Return: a gboolean representing the specified child is selected, or 0
109 	 *     if @selection does not implement this interface.
110 	 */
111 	public bool isChildSelected(int i)
112 	{
113 		return atk_selection_is_child_selected(getSelectionStruct(), i) != 0;
114 	}
115 
116 	/**
117 	 * Gets a reference to the accessible object representing the specified
118 	 * selected child of the object.
119 	 * Note: callers should not rely on %NULL or on a zero value for
120 	 * indication of whether AtkSelectionIface is implemented, they should
121 	 * use type checking/interface checking macros or the
122 	 * atk_get_accessible_value() convenience method.
123 	 *
124 	 * Params:
125 	 *     i = a #gint specifying the index in the selection set.  (e.g. the
126 	 *         ith selection as opposed to the ith child).
127 	 *
128 	 * Return: an #AtkObject representing the
129 	 *     selected accessible, or %NULL if @selection does not implement this
130 	 *     interface.
131 	 */
132 	public ObjectAtk refSelection(int i)
133 	{
134 		auto p = atk_selection_ref_selection(getSelectionStruct(), i);
135 		
136 		if(p is null)
137 		{
138 			return null;
139 		}
140 		
141 		return ObjectG.getDObject!(ObjectAtk)(cast(AtkObject*) p, true);
142 	}
143 
144 	/**
145 	 * Removes the specified child of the object from the object's selection.
146 	 *
147 	 * Params:
148 	 *     i = a #gint specifying the index in the selection set.  (e.g. the
149 	 *         ith selection as opposed to the ith child).
150 	 *
151 	 * Return: TRUE if success, FALSE otherwise.
152 	 */
153 	public bool removeSelection(int i)
154 	{
155 		return atk_selection_remove_selection(getSelectionStruct(), i) != 0;
156 	}
157 
158 	/**
159 	 * Causes every child of the object to be selected if the object
160 	 * supports multiple selections.
161 	 *
162 	 * Return: TRUE if success, FALSE otherwise.
163 	 */
164 	public bool selectAllSelection()
165 	{
166 		return atk_selection_select_all_selection(getSelectionStruct()) != 0;
167 	}
168 
169 	int[string] connectedSignals;
170 
171 	void delegate(SelectionIF)[] _onSelectionChangedListeners;
172 	@property void delegate(SelectionIF)[] onSelectionChangedListeners()
173 	{
174 		return _onSelectionChangedListeners;
175 	}
176 	/**
177 	 * The "selection-changed" signal is emitted by an object which
178 	 * implements AtkSelection interface when the selection changes.
179 	 */
180 	void addOnSelectionChanged(void delegate(SelectionIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
181 	{
182 		if ( "selection-changed" !in connectedSignals )
183 		{
184 			Signals.connectData(
185 				this,
186 				"selection-changed",
187 				cast(GCallback)&callBackSelectionChanged,
188 				cast(void*)cast(SelectionIF)this,
189 				null,
190 				connectFlags);
191 			connectedSignals["selection-changed"] = 1;
192 		}
193 		_onSelectionChangedListeners ~= dlg;
194 	}
195 	extern(C) static void callBackSelectionChanged(AtkSelection* selectionStruct, SelectionIF _selection)
196 	{
197 		foreach ( void delegate(SelectionIF) dlg; _selection.onSelectionChangedListeners )
198 		{
199 			dlg(_selection);
200 		}
201 	}
202 }