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