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 = GtkTextTag.html 27 * outPack = gtk 28 * outFile = TextTag 29 * strct = GtkTextTag 30 * realStrct= 31 * ctorStrct= 32 * clss = TextTag 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_text_tag_ 41 * omit structs: 42 * omit prefixes: 43 * - gtk_text_attributes_ 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - gobject.ObjectG 49 * - gdk.Event 50 * - gtk.TextIter 51 * structWrap: 52 * - GObject* -> ObjectG 53 * - GdkEvent* -> Event 54 * - GtkTextIter* -> TextIter 55 * module aliases: 56 * local aliases: 57 * overrides: 58 */ 59 60 module gtk.TextTag; 61 62 public import gtkc.gtktypes; 63 64 private import gtkc.gtk; 65 private import glib.ConstructionException; 66 private import gobject.ObjectG; 67 68 private import gobject.Signals; 69 public import gtkc.gdktypes; 70 71 private import glib.Str; 72 private import gobject.ObjectG; 73 private import gdk.Event; 74 private import gtk.TextIter; 75 76 77 78 private import gobject.ObjectG; 79 80 /** 81 * You may wish to begin by reading the text widget 82 * conceptual overview which gives an overview of all the objects and 83 * data types related to the text widget and how they work together. 84 * 85 * Tags should be in the GtkTextTagTable for a given GtkTextBuffer 86 * before using them with that buffer. 87 * 88 * gtk_text_buffer_create_tag() is the best way to create tags. 89 * See gtk3-demo for numerous examples. 90 * 91 * For each property of GtkTextTag, there is a "set" property, e.g. 92 * "font-set" corresponds to "font". These "set" properties reflect 93 * whether a property has been set or not. 94 * They are maintained by GTK+ and you should not set them independently. 95 */ 96 public class TextTag : ObjectG 97 { 98 99 /** the main Gtk struct */ 100 protected GtkTextTag* gtkTextTag; 101 102 103 public GtkTextTag* getTextTagStruct() 104 { 105 return gtkTextTag; 106 } 107 108 109 /** the main Gtk struct as a void* */ 110 protected override void* getStruct() 111 { 112 return cast(void*)gtkTextTag; 113 } 114 115 /** 116 * Sets our main struct and passes it to the parent class 117 */ 118 public this (GtkTextTag* gtkTextTag) 119 { 120 super(cast(GObject*)gtkTextTag); 121 this.gtkTextTag = gtkTextTag; 122 } 123 124 protected override void setStruct(GObject* obj) 125 { 126 super.setStruct(obj); 127 gtkTextTag = cast(GtkTextTag*)obj; 128 } 129 130 /** 131 */ 132 int[string] connectedSignals; 133 134 bool delegate(ObjectG, Event, TextIter, TextTag)[] onListeners; 135 /** 136 * The ::event signal is emitted when an event occurs on a region of the 137 * buffer marked with this tag. 138 * TRUE to stop other handlers from being invoked for the 139 * event. FALSE to propagate the event further. 140 */ 141 void addOn(bool delegate(ObjectG, Event, TextIter, TextTag) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 142 { 143 if ( !("event" in connectedSignals) ) 144 { 145 Signals.connectData( 146 getStruct(), 147 "event", 148 cast(GCallback)&callBack, 149 cast(void*)this, 150 null, 151 connectFlags); 152 connectedSignals["event"] = 1; 153 } 154 onListeners ~= dlg; 155 } 156 extern(C) static gboolean callBack(GtkTextTag* tagStruct, GObject* object, GdkEvent* event, GtkTextIter* iter, TextTag _textTag) 157 { 158 foreach ( bool delegate(ObjectG, Event, TextIter, TextTag) dlg ; _textTag.onListeners ) 159 { 160 if ( dlg(ObjectG.getDObject!(ObjectG)(object), ObjectG.getDObject!(Event)(event), ObjectG.getDObject!(TextIter)(iter), _textTag) ) 161 { 162 return 1; 163 } 164 } 165 166 return 0; 167 } 168 169 170 /** 171 * Creates a GtkTextTag. Configure the tag using object arguments, 172 * i.e. using g_object_set(). 173 * Params: 174 * name = tag name, or NULL. [allow-none] 175 * Throws: ConstructionException GTK+ fails to create the object. 176 */ 177 public this (string name) 178 { 179 // GtkTextTag * gtk_text_tag_new (const gchar *name); 180 auto p = gtk_text_tag_new(Str.toStringz(name)); 181 if(p is null) 182 { 183 throw new ConstructionException("null returned by gtk_text_tag_new(Str.toStringz(name))"); 184 } 185 this(cast(GtkTextTag*) p); 186 } 187 188 /** 189 * Get the tag priority. 190 * Returns: The tag's priority. 191 */ 192 public int getPriority() 193 { 194 // gint gtk_text_tag_get_priority (GtkTextTag *tag); 195 return gtk_text_tag_get_priority(gtkTextTag); 196 } 197 198 /** 199 * Sets the priority of a GtkTextTag. Valid priorities 200 * start at 0 and go to one less than gtk_text_tag_table_get_size(). 201 * Each tag in a table has a unique priority; setting the priority 202 * of one tag shifts the priorities of all the other tags in the 203 * table to maintain a unique priority for each tag. Higher priority 204 * tags "win" if two tags both set the same text attribute. When adding 205 * a tag to a tag table, it will be assigned the highest priority in 206 * the table by default; so normally the precedence of a set of tags 207 * is the order in which they were added to the table, or created with 208 * gtk_text_buffer_create_tag(), which adds the tag to the buffer's table 209 * automatically. 210 * Params: 211 * priority = the new priority 212 */ 213 public void setPriority(int priority) 214 { 215 // void gtk_text_tag_set_priority (GtkTextTag *tag, gint priority); 216 gtk_text_tag_set_priority(gtkTextTag, priority); 217 } 218 219 /** 220 * Emits the "event" signal on the GtkTextTag. 221 * Params: 222 * eventObject = object that received the event, such as a widget 223 * event = the event 224 * iter = location where the event was received 225 * Returns: result of signal emission (whether the event was handled) 226 */ 227 public int event(ObjectG eventObject, Event event, TextIter iter) 228 { 229 // gboolean gtk_text_tag_event (GtkTextTag *tag, GObject *event_object, GdkEvent *event, const GtkTextIter *iter); 230 return gtk_text_tag_event(gtkTextTag, (eventObject is null) ? null : eventObject.getObjectGStruct(), (event is null) ? null : event.getEventStruct(), (iter is null) ? null : iter.getTextIterStruct()); 231 } 232 }