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 * Conversion parameters: 26 * inFile = 27 * outPack = gobject 28 * outFile = Flags 29 * strct = GFlagsValue 30 * realStrct= 31 * ctorStrct= 32 * clss = Flags 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - g_flags_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * structWrap: 48 * - GFlagsValue* -> Flags 49 * module aliases: 50 * local aliases: 51 * overrides: 52 */ 53 54 module gobject.Flags; 55 56 public import gtkc.gobjecttypes; 57 58 private import gtkc.gobject; 59 private import glib.ConstructionException; 60 private import gobject.ObjectG; 61 62 63 private import glib.Str; 64 65 66 67 68 /** 69 * The GLib type system provides fundamental types for enumeration and 70 * flags types. (Flags types are like enumerations, but allow their 71 * values to be combined by bitwise or). A registered enumeration or 72 * flags type associates a name and a nickname with each allowed 73 * value, and the methods g_enum_get_value_by_name(), 74 * g_enum_get_value_by_nick(), g_flags_get_value_by_name() and 75 * g_flags_get_value_by_nick() can look up values by their name or 76 * nickname. When an enumeration or flags type is registered with the 77 * GLib type system, it can be used as value type for object 78 * properties, using g_param_spec_enum() or g_param_spec_flags(). 79 * 80 * GObject ships with a utility called glib-mkenums that can construct 81 * suitable type registration functions from C enumeration 82 * definitions. 83 */ 84 public class Flags 85 { 86 87 /** the main Gtk struct */ 88 protected GFlagsValue* gFlagsValue; 89 90 91 public GFlagsValue* getFlagsStruct() 92 { 93 return gFlagsValue; 94 } 95 96 97 /** the main Gtk struct as a void* */ 98 protected void* getStruct() 99 { 100 return cast(void*)gFlagsValue; 101 } 102 103 /** 104 * Sets our main struct and passes it to the parent class 105 */ 106 public this (GFlagsValue* gFlagsValue) 107 { 108 this.gFlagsValue = gFlagsValue; 109 } 110 111 /** 112 */ 113 114 /** 115 * Returns the first GFlagsValue which is set in value. 116 * Params: 117 * flagsClass = a GFlagsClass 118 * value = the value 119 * Returns: the first GFlagsValue which is set in value, or NULL if none is set 120 */ 121 public static Flags getFirstValue(GFlagsClass* flagsClass, uint value) 122 { 123 // GFlagsValue * g_flags_get_first_value (GFlagsClass *flags_class, guint value); 124 auto p = g_flags_get_first_value(flagsClass, value); 125 126 if(p is null) 127 { 128 return null; 129 } 130 131 return ObjectG.getDObject!(Flags)(cast(GFlagsValue*) p); 132 } 133 134 /** 135 * Looks up a GFlagsValue by name. 136 * Params: 137 * flagsClass = a GFlagsClass 138 * name = the name to look up 139 * Returns: the GFlagsValue with name name, or NULL if there is no flag with that name 140 */ 141 public static Flags getValueByName(GFlagsClass* flagsClass, string name) 142 { 143 // GFlagsValue * g_flags_get_value_by_name (GFlagsClass *flags_class, const gchar *name); 144 auto p = g_flags_get_value_by_name(flagsClass, Str.toStringz(name)); 145 146 if(p is null) 147 { 148 return null; 149 } 150 151 return ObjectG.getDObject!(Flags)(cast(GFlagsValue*) p); 152 } 153 154 /** 155 * Looks up a GFlagsValue by nickname. 156 * Params: 157 * flagsClass = a GFlagsClass 158 * nick = the nickname to look up 159 * Returns: the GFlagsValue with nickname nick, or NULL if there is no flag with that nickname 160 */ 161 public static Flags getValueByNick(GFlagsClass* flagsClass, string nick) 162 { 163 // GFlagsValue * g_flags_get_value_by_nick (GFlagsClass *flags_class, const gchar *nick); 164 auto p = g_flags_get_value_by_nick(flagsClass, Str.toStringz(nick)); 165 166 if(p is null) 167 { 168 return null; 169 } 170 171 return ObjectG.getDObject!(Flags)(cast(GFlagsValue*) p); 172 } 173 174 /** 175 * Registers a new static flags type with the name name. 176 * It is normally more convenient to let glib-mkenums generate a 177 * my_flags_get_type() function from a usual C enumeration definition 178 * than to write one yourself using g_flags_register_static(). 179 * Params: 180 * name = A nul-terminated string used as the name of the new type. 181 * Returns: The new type identifier. 182 */ 183 public static GType registerStatic(string name, Flags _StaticValues) 184 { 185 // GType g_flags_register_static (const gchar *name, const GFlagsValue *const_static_values); 186 return g_flags_register_static(Str.toStringz(name), (_StaticValues is null) ? null : _StaticValues.getFlagsStruct()); 187 } 188 189 /** 190 * This function is meant to be called from the complete_type_info() 191 * function of a GTypePlugin implementation, see the example for 192 * g_enum_complete_type_info() above. 193 * Params: 194 * type = the type identifier of the type being completed 195 * info = the GTypeInfo struct to be filled in 196 */ 197 public static void completeTypeInfo(GType type, GTypeInfo* info, Flags _Values) 198 { 199 // void g_flags_complete_type_info (GType g_flags_type, GTypeInfo *info, const GFlagsValue *const_values); 200 g_flags_complete_type_info(type, info, (_Values is null) ? null : _Values.getFlagsStruct()); 201 } 202 }