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