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(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 protected override void setStruct(GObject* obj) 58 { 59 atkStateSet = cast(AtkStateSet*)obj; 60 super.setStruct(obj); 61 } 62 63 /** 64 * Sets our main struct and passes it to the parent class. 65 */ 66 public this (AtkStateSet* atkStateSet, bool ownedRef = false) 67 { 68 this.atkStateSet = atkStateSet; 69 super(cast(GObject*)atkStateSet, ownedRef); 70 } 71 72 73 /** */ 74 public static GType getType() 75 { 76 return atk_state_set_get_type(); 77 } 78 79 /** 80 * Creates a new empty state set. 81 * 82 * Returns: a new #AtkStateSet 83 * 84 * Throws: ConstructionException GTK+ fails to create the object. 85 */ 86 public this() 87 { 88 auto p = atk_state_set_new(); 89 90 if(p is null) 91 { 92 throw new ConstructionException("null returned by new"); 93 } 94 95 this(cast(AtkStateSet*) p, true); 96 } 97 98 /** 99 * Adds the state of the specified type to the state set if it is not already 100 * present. 101 * 102 * Note that because an #AtkStateSet is a read-only object, this method should 103 * be used to add a state to a newly-created set which will then be returned by 104 * #atk_object_ref_state_set. It should not be used to modify the existing state 105 * of an object. See also #atk_object_notify_state_change. 106 * 107 * Params: 108 * type = an #AtkStateType 109 * 110 * Returns: %TRUE if the state for @type is not already in @set. 111 */ 112 public bool addState(AtkStateType type) 113 { 114 return atk_state_set_add_state(atkStateSet, type) != 0; 115 } 116 117 /** 118 * Adds the states of the specified types to the state set. 119 * 120 * Note that because an #AtkStateSet is a read-only object, this method should 121 * be used to add states to a newly-created set which will then be returned by 122 * #atk_object_ref_state_set. It should not be used to modify the existing state 123 * of an object. See also #atk_object_notify_state_change. 124 * 125 * Params: 126 * types = an array of #AtkStateType 127 * nTypes = The number of elements in the array 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 * nTypes = The number of elements in the array 184 * 185 * Returns: %TRUE if all the states for @type are in @set. 186 */ 187 public bool containsStates(AtkStateType[] types) 188 { 189 return atk_state_set_contains_states(atkStateSet, types.ptr, cast(int)types.length) != 0; 190 } 191 192 /** 193 * Checks whether the state set is empty, i.e. has no states set. 194 * 195 * Returns: %TRUE if @set has no states set, otherwise %FALSE 196 */ 197 public bool isEmpty() 198 { 199 return atk_state_set_is_empty(atkStateSet) != 0; 200 } 201 202 /** 203 * Constructs the union of the two sets. 204 * 205 * Params: 206 * compareSet = another #AtkStateSet 207 * 208 * Returns: a new #AtkStateSet which is 209 * the union of the two sets, returning %NULL is empty. 210 */ 211 public StateSet orSets(StateSet compareSet) 212 { 213 auto p = atk_state_set_or_sets(atkStateSet, (compareSet is null) ? null : compareSet.getStateSetStruct()); 214 215 if(p is null) 216 { 217 return null; 218 } 219 220 return ObjectG.getDObject!(StateSet)(cast(AtkStateSet*) p, true); 221 } 222 223 /** 224 * Removes the state for the specified type from the state set. 225 * 226 * Note that because an #AtkStateSet is a read-only object, this method should 227 * be used to remove a state to a newly-created set which will then be returned 228 * by #atk_object_ref_state_set. It should not be used to modify the existing 229 * state of an object. See also #atk_object_notify_state_change. 230 * 231 * Params: 232 * type = an #AtkType 233 * 234 * Returns: %TRUE if @type was the state type is in @set. 235 */ 236 public bool removeState(AtkStateType type) 237 { 238 return atk_state_set_remove_state(atkStateSet, type) != 0; 239 } 240 241 /** 242 * Constructs the exclusive-or of the two sets, returning %NULL is empty. 243 * The set returned by this operation contains the states in exactly 244 * one of the two sets. 245 * 246 * Params: 247 * compareSet = another #AtkStateSet 248 * 249 * Returns: a new #AtkStateSet which contains the states 250 * which are in exactly one of the two sets. 251 */ 252 public StateSet xorSets(StateSet compareSet) 253 { 254 auto p = atk_state_set_xor_sets(atkStateSet, (compareSet is null) ? null : compareSet.getStateSetStruct()); 255 256 if(p is null) 257 { 258 return null; 259 } 260 261 return ObjectG.getDObject!(StateSet)(cast(AtkStateSet*) p, true); 262 } 263 }