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