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