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.StateSet;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gtkc.atk;
30 public  import gtkc.atktypes;
31 
32 
33 /**
34  * An AtkStateSet is a read-only representation of the full set of #AtkStates
35  * that apply to an object at a given time. This set is not meant to be
36  * modified, but rather created when #atk_object_ref_state_set() is called.
37  */
38 public class StateSet : ObjectG
39 {
40 	/** the main Gtk struct */
41 	protected AtkStateSet* atkStateSet;
42 
43 	/** Get the main Gtk struct */
44 	public AtkStateSet* getStateSetStruct()
45 	{
46 		return atkStateSet;
47 	}
48 
49 	/** the main Gtk struct as a void* */
50 	protected override void* getStruct()
51 	{
52 		return cast(void*)atkStateSet;
53 	}
54 
55 	protected override void setStruct(GObject* obj)
56 	{
57 		atkStateSet = cast(AtkStateSet*)obj;
58 		super.setStruct(obj);
59 	}
60 
61 	/**
62 	 * Sets our main struct and passes it to the parent class.
63 	 */
64 	public this (AtkStateSet* atkStateSet, bool ownedRef = false)
65 	{
66 		this.atkStateSet = atkStateSet;
67 		super(cast(GObject*)atkStateSet, ownedRef);
68 	}
69 
70 	/**
71 	 */
72 
73 	public static GType getType()
74 	{
75 		return atk_state_set_get_type();
76 	}
77 
78 	/**
79 	 * Creates a new empty state set.
80 	 *
81 	 * Return: a new #AtkStateSet
82 	 *
83 	 * Throws: ConstructionException GTK+ fails to create the object.
84 	 */
85 	public this()
86 	{
87 		auto p = atk_state_set_new();
88 		
89 		if(p is null)
90 		{
91 			throw new ConstructionException("null returned by new");
92 		}
93 		
94 		this(cast(AtkStateSet*) p, true);
95 	}
96 
97 	/**
98 	 * Adds the state of the specified type to the state set if it is not already
99 	 * present.
100 	 *
101 	 * Note that because an #AtkStateSet is a read-only object, this method should
102 	 * be used to add a state to a newly-created set which will then be returned by
103 	 * #atk_object_ref_state_set. It should not be used to modify the existing state
104 	 * of an object. See also #atk_object_notify_state_change.
105 	 *
106 	 * Params:
107 	 *     type = an #AtkStateType
108 	 *
109 	 * Return: %TRUE if  the state for @type is not already in @set.
110 	 */
111 	public bool addState(AtkStateType type)
112 	{
113 		return atk_state_set_add_state(atkStateSet, type) != 0;
114 	}
115 
116 	/**
117 	 * Adds the states of the specified types to the state set.
118 	 *
119 	 * Note that because an #AtkStateSet is a read-only object, this method should
120 	 * be used to add states to a newly-created set which will then be returned by
121 	 * #atk_object_ref_state_set. It should not be used to modify the existing state
122 	 * of an object. See also #atk_object_notify_state_change.
123 	 *
124 	 * Params:
125 	 *     types = an array of #AtkStateType
126 	 *     nTypes = The number of elements in the array
127 	 */
128 	public void addStates(AtkStateType[] types)
129 	{
130 		atk_state_set_add_states(atkStateSet, types.ptr, cast(int)types.length);
131 	}
132 
133 	/**
134 	 * Constructs the intersection of the two sets, returning %NULL if the
135 	 * intersection is empty.
136 	 *
137 	 * Params:
138 	 *     compareSet = another #AtkStateSet
139 	 *
140 	 * Return: a new #AtkStateSet which is the intersection of
141 	 *     the two sets.
142 	 */
143 	public StateSet andSets(StateSet compareSet)
144 	{
145 		auto p = atk_state_set_and_sets(atkStateSet, (compareSet is null) ? null : compareSet.getStateSetStruct());
146 		
147 		if(p is null)
148 		{
149 			return null;
150 		}
151 		
152 		return ObjectG.getDObject!(StateSet)(cast(AtkStateSet*) p, true);
153 	}
154 
155 	/**
156 	 * Removes all states from the state set.
157 	 */
158 	public void clearStates()
159 	{
160 		atk_state_set_clear_states(atkStateSet);
161 	}
162 
163 	/**
164 	 * Checks whether the state for the specified type is in the specified set.
165 	 *
166 	 * Params:
167 	 *     type = an #AtkStateType
168 	 *
169 	 * Return: %TRUE if @type is the state type is in @set.
170 	 */
171 	public bool containsState(AtkStateType type)
172 	{
173 		return atk_state_set_contains_state(atkStateSet, type) != 0;
174 	}
175 
176 	/**
177 	 * Checks whether the states for all the specified types are in the
178 	 * specified set.
179 	 *
180 	 * Params:
181 	 *     types = an array of #AtkStateType
182 	 *     nTypes = The number of elements in the array
183 	 *
184 	 * Return: %TRUE if all the states for @type are in @set.
185 	 */
186 	public bool containsStates(AtkStateType[] types)
187 	{
188 		return atk_state_set_contains_states(atkStateSet, types.ptr, cast(int)types.length) != 0;
189 	}
190 
191 	/**
192 	 * Checks whether the state set is empty, i.e. has no states set.
193 	 *
194 	 * Return: %TRUE if @set has no states set, otherwise %FALSE
195 	 */
196 	public bool isEmpty()
197 	{
198 		return atk_state_set_is_empty(atkStateSet) != 0;
199 	}
200 
201 	/**
202 	 * Constructs the union of the two sets.
203 	 *
204 	 * Params:
205 	 *     compareSet = another #AtkStateSet
206 	 *
207 	 * Return: a new #AtkStateSet which is
208 	 *     the union of the two sets, returning %NULL is empty.
209 	 */
210 	public StateSet orSets(StateSet compareSet)
211 	{
212 		auto p = atk_state_set_or_sets(atkStateSet, (compareSet is null) ? null : compareSet.getStateSetStruct());
213 		
214 		if(p is null)
215 		{
216 			return null;
217 		}
218 		
219 		return ObjectG.getDObject!(StateSet)(cast(AtkStateSet*) p, true);
220 	}
221 
222 	/**
223 	 * Removes the state for the specified type from the state set.
224 	 *
225 	 * Note that because an #AtkStateSet is a read-only object, this method should
226 	 * be used to remove a state to a newly-created set which will then be returned
227 	 * by #atk_object_ref_state_set. It should not be used to modify the existing
228 	 * state of an object. See also #atk_object_notify_state_change.
229 	 *
230 	 * Params:
231 	 *     type = an #AtkType
232 	 *
233 	 * Return: %TRUE if @type was the state type is in @set.
234 	 */
235 	public bool removeState(AtkStateType type)
236 	{
237 		return atk_state_set_remove_state(atkStateSet, type) != 0;
238 	}
239 
240 	/**
241 	 * Constructs the exclusive-or of the two sets, returning %NULL is empty.
242 	 * The set returned by this operation contains the states in exactly
243 	 * one of the two sets.
244 	 *
245 	 * Params:
246 	 *     compareSet = another #AtkStateSet
247 	 *
248 	 * Return: a new #AtkStateSet which contains the states
249 	 *     which are in exactly one of the two sets.
250 	 */
251 	public StateSet xorSets(StateSet compareSet)
252 	{
253 		auto p = atk_state_set_xor_sets(atkStateSet, (compareSet is null) ? null : compareSet.getStateSetStruct());
254 		
255 		if(p is null)
256 		{
257 			return null;
258 		}
259 		
260 		return ObjectG.getDObject!(StateSet)(cast(AtkStateSet*) p, true);
261 	}
262 }