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