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.CellRendererText; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gobject.Signals; 31 private import gtk.CellRenderer; 32 public import gtkc.gdktypes; 33 private import gtkc.gtk; 34 public import gtkc.gtktypes; 35 36 37 /** 38 * A #GtkCellRendererText renders a given text in its cell, using the font, color and 39 * style information provided by its properties. The text will be ellipsized if it is 40 * too long and the #GtkCellRendererText:ellipsize property allows it. 41 * 42 * If the #GtkCellRenderer:mode is %GTK_CELL_RENDERER_MODE_EDITABLE, 43 * the #GtkCellRendererText allows to edit its text using an entry. 44 */ 45 public class CellRendererText : CellRenderer 46 { 47 /** the main Gtk struct */ 48 protected GtkCellRendererText* gtkCellRendererText; 49 50 /** Get the main Gtk struct */ 51 public GtkCellRendererText* getCellRendererTextStruct() 52 { 53 return gtkCellRendererText; 54 } 55 56 /** the main Gtk struct as a void* */ 57 protected override void* getStruct() 58 { 59 return cast(void*)gtkCellRendererText; 60 } 61 62 protected override void setStruct(GObject* obj) 63 { 64 gtkCellRendererText = cast(GtkCellRendererText*)obj; 65 super.setStruct(obj); 66 } 67 68 /** 69 * Sets our main struct and passes it to the parent class. 70 */ 71 public this (GtkCellRendererText* gtkCellRendererText, bool ownedRef = false) 72 { 73 this.gtkCellRendererText = gtkCellRendererText; 74 super(cast(GtkCellRenderer*)gtkCellRendererText, ownedRef); 75 } 76 77 /** 78 */ 79 80 public static GType getType() 81 { 82 return gtk_cell_renderer_text_get_type(); 83 } 84 85 /** 86 * Creates a new #GtkCellRendererText. Adjust how text is drawn using 87 * object properties. Object properties can be 88 * set globally (with g_object_set()). Also, with #GtkTreeViewColumn, 89 * you can bind a property to a value in a #GtkTreeModel. For example, 90 * you can bind the “text” property on the cell renderer to a string 91 * value in the model, thus rendering a different string in each row 92 * of the #GtkTreeView 93 * 94 * Return: the new cell renderer 95 * 96 * Throws: ConstructionException GTK+ fails to create the object. 97 */ 98 public this() 99 { 100 auto p = gtk_cell_renderer_text_new(); 101 102 if(p is null) 103 { 104 throw new ConstructionException("null returned by new"); 105 } 106 107 this(cast(GtkCellRendererText*) p); 108 } 109 110 /** 111 * Sets the height of a renderer to explicitly be determined by the “font” and 112 * “y_pad” property set on it. Further changes in these properties do not 113 * affect the height, so they must be accompanied by a subsequent call to this 114 * function. Using this function is unflexible, and should really only be used 115 * if calculating the size of a cell is too slow (ie, a massive number of cells 116 * displayed). If @number_of_rows is -1, then the fixed height is unset, and 117 * the height is determined by the properties again. 118 * 119 * Params: 120 * numberOfRows = Number of rows of text each cell renderer is allocated, or -1 121 */ 122 public void setFixedHeightFromFont(int numberOfRows) 123 { 124 gtk_cell_renderer_text_set_fixed_height_from_font(gtkCellRendererText, numberOfRows); 125 } 126 127 int[string] connectedSignals; 128 129 void delegate(string, string, CellRendererText)[] onEditedListeners; 130 /** 131 * This signal is emitted after @renderer has been edited. 132 * 133 * It is the responsibility of the application to update the model 134 * and store @new_text at the position indicated by @path. 135 * 136 * Params: 137 * path = the path identifying the edited cell 138 * newText = the new text 139 */ 140 void addOnEdited(void delegate(string, string, CellRendererText) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 141 { 142 if ( "edited" !in connectedSignals ) 143 { 144 Signals.connectData( 145 this, 146 "edited", 147 cast(GCallback)&callBackEdited, 148 cast(void*)this, 149 null, 150 connectFlags); 151 connectedSignals["edited"] = 1; 152 } 153 onEditedListeners ~= dlg; 154 } 155 extern(C) static void callBackEdited(GtkCellRendererText* cellrenderertextStruct, char* path, char* newText, CellRendererText _cellrenderertext) 156 { 157 foreach ( void delegate(string, string, CellRendererText) dlg; _cellrenderertext.onEditedListeners ) 158 { 159 dlg(Str.toString(path), Str.toString(newText), _cellrenderertext); 160 } 161 } 162 }