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