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 atk.c.functions;
28 public  import atk.c.types;
29 private import glib.ConstructionException;
30 private import gobject.ObjectG;
31 public  import gtkc.atktypes;
32 
33 
34 /**
35  * An AtkStateSet is a read-only representation of the full set of #AtkStates
36  * that apply to an object at a given time. This set is not meant to be
37  * modified, but rather created when #atk_object_ref_state_set() is called.
38  */
39 public class StateSet : ObjectG
40 {
41 	/** the main Gtk struct */
42 	protected AtkStateSet* atkStateSet;
43 
44 	/** Get the main Gtk struct */
45 	public AtkStateSet* getStateSetStruct(bool transferOwnership = false)
46 	{
47 		if (transferOwnership)
48 			ownedRef = false;
49 		return atkStateSet;
50 	}
51 
52 	/** the main Gtk struct as a void* */
53 	protected override void* getStruct()
54 	{
55 		return cast(void*)atkStateSet;
56 	}
57 
58 	protected override void setStruct(GObject* obj)
59 	{
60 		atkStateSet = cast(AtkStateSet*)obj;
61 		super.setStruct(obj);
62 	}
63 
64 	/**
65 	 * Sets our main struct and passes it to the parent class.
66 	 */
67 	public this (AtkStateSet* atkStateSet, bool ownedRef = false)
68 	{
69 		this.atkStateSet = atkStateSet;
70 		super(cast(GObject*)atkStateSet, ownedRef);
71 	}
72 
73 
74 	/** */
75 	public static GType getType()
76 	{
77 		return atk_state_set_get_type();
78 	}
79 
80 	/**
81 	 * Creates a new empty state set.
82 	 *
83 	 * Returns: a new #AtkStateSet
84 	 *
85 	 * Throws: ConstructionException GTK+ fails to create the object.
86 	 */
87 	public this()
88 	{
89 		auto p = atk_state_set_new();
90 
91 		if(p is null)
92 		{
93 			throw new ConstructionException("null returned by new");
94 		}
95 
96 		this(cast(AtkStateSet*) p, true);
97 	}
98 
99 	/**
100 	 * Adds the state of the specified type to the state set if it is not already
101 	 * present.
102 	 *
103 	 * Note that because an #AtkStateSet is a read-only object, this method should
104 	 * be used to add a state to a newly-created set which will then be returned by
105 	 * #atk_object_ref_state_set. It should not be used to modify the existing state
106 	 * of an object. See also #atk_object_notify_state_change.
107 	 *
108 	 * Params:
109 	 *     type = an #AtkStateType
110 	 *
111 	 * Returns: %TRUE if  the state for @type is not already in @set.
112 	 */
113 	public bool addState(AtkStateType type)
114 	{
115 		return atk_state_set_add_state(atkStateSet, type) != 0;
116 	}
117 
118 	/**
119 	 * Adds the states of the specified types to the state set.
120 	 *
121 	 * Note that because an #AtkStateSet is a read-only object, this method should
122 	 * be used to add states to a newly-created set which will then be returned by
123 	 * #atk_object_ref_state_set. It should not be used to modify the existing state
124 	 * of an object. See also #atk_object_notify_state_change.
125 	 *
126 	 * Params:
127 	 *     types = an array of #AtkStateType
128 	 */
129 	public void addStates(AtkStateType[] types)
130 	{
131 		atk_state_set_add_states(atkStateSet, types.ptr, cast(int)types.length);
132 	}
133 
134 	/**
135 	 * Constructs the intersection of the two sets, returning %NULL if the
136 	 * intersection is empty.
137 	 *
138 	 * Params:
139 	 *     compareSet = another #AtkStateSet
140 	 *
141 	 * Returns: a new #AtkStateSet which is the intersection of
142 	 *     the two sets.
143 	 */
144 	public StateSet andSets(StateSet compareSet)
145 	{
146 		auto p = atk_state_set_and_sets(atkStateSet, (compareSet is null) ? null : compareSet.getStateSetStruct());
147 
148 		if(p is null)
149 		{
150 			return null;
151 		}
152 
153 		return ObjectG.getDObject!(StateSet)(cast(AtkStateSet*) p, true);
154 	}
155 
156 	/**
157 	 * Removes all states from the state set.
158 	 */
159 	public void clearStates()
160 	{
161 		atk_state_set_clear_states(atkStateSet);
162 	}
163 
164 	/**
165 	 * Checks whether the state for the specified type is in the specified set.
166 	 *
167 	 * Params:
168 	 *     type = an #AtkStateType
169 	 *
170 	 * Returns: %TRUE if @type is the state type is in @set.
171 	 */
172 	public bool containsState(AtkStateType type)
173 	{
174 		return atk_state_set_contains_state(atkStateSet, type) != 0;
175 	}
176 
177 	/**
178 	 * Checks whether the states for all the specified types are in the
179 	 * specified set.
180 	 *
181 	 * Params:
182 	 *     types = an array of #AtkStateType
183 	 *
184 	 * Returns: %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 	 * Returns: %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 	 * Returns: 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 	 * Returns: %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 	 * Returns: 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 }