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