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 	public static GType getType()
80 	{
81 		return gtk_cell_renderer_text_get_type();
82 	}
83 
84 	/**
85 	 * Creates a new #GtkCellRendererText. Adjust how text is drawn using
86 	 * object properties. Object properties can be
87 	 * set globally (with g_object_set()). Also, with #GtkTreeViewColumn,
88 	 * you can bind a property to a value in a #GtkTreeModel. For example,
89 	 * you can bind the “text” property on the cell renderer to a string
90 	 * value in the model, thus rendering a different string in each row
91 	 * of the #GtkTreeView
92 	 *
93 	 * Return: the new cell renderer
94 	 *
95 	 * Throws: ConstructionException GTK+ fails to create the object.
96 	 */
97 	public this()
98 	{
99 		auto p = gtk_cell_renderer_text_new();
100 		
101 		if(p is null)
102 		{
103 			throw new ConstructionException("null returned by new");
104 		}
105 		
106 		this(cast(GtkCellRendererText*) p);
107 	}
108 
109 	/**
110 	 * Sets the height of a renderer to explicitly be determined by the “font” and
111 	 * “y_pad” property set on it.  Further changes in these properties do not
112 	 * affect the height, so they must be accompanied by a subsequent call to this
113 	 * function.  Using this function is unflexible, and should really only be used
114 	 * if calculating the size of a cell is too slow (ie, a massive number of cells
115 	 * displayed).  If @number_of_rows is -1, then the fixed height is unset, and
116 	 * the height is determined by the properties again.
117 	 *
118 	 * Params:
119 	 *     numberOfRows = Number of rows of text each cell renderer is allocated, or -1
120 	 */
121 	public void setFixedHeightFromFont(int numberOfRows)
122 	{
123 		gtk_cell_renderer_text_set_fixed_height_from_font(gtkCellRendererText, numberOfRows);
124 	}
125 
126 	int[string] connectedSignals;
127 
128 	void delegate(string, string, CellRendererText)[] onEditedListeners;
129 	/**
130 	 * This signal is emitted after @renderer has been edited.
131 	 *
132 	 * It is the responsibility of the application to update the model
133 	 * and store @new_text at the position indicated by @path.
134 	 *
135 	 * Params:
136 	 *     path = the path identifying the edited cell
137 	 *     newText = the new text
138 	 */
139 	void addOnEdited(void delegate(string, string, CellRendererText) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
140 	{
141 		if ( "edited" !in connectedSignals )
142 		{
143 			Signals.connectData(
144 				this,
145 				"edited",
146 				cast(GCallback)&callBackEdited,
147 				cast(void*)this,
148 				null,
149 				connectFlags);
150 			connectedSignals["edited"] = 1;
151 		}
152 		onEditedListeners ~= dlg;
153 	}
154 	extern(C) static void callBackEdited(GtkCellRendererText* cellrenderertextStruct, char* path, char* newText, CellRendererText _cellrenderertext)
155 	{
156 		foreach ( void delegate(string, string, CellRendererText) dlg; _cellrenderertext.onEditedListeners )
157 		{
158 			dlg(Str.toString(path), Str.toString(newText), _cellrenderertext);
159 		}
160 	}
161 }