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