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  = GtkSourceGutter.html
27  * outPack = gsv
28  * outFile = SourceGutter
29  * strct   = GtkSourceGutter
30  * realStrct=
31  * ctorStrct=
32  * clss    = SourceGutter
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_source_gutter_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- gdk.Window
47  * 	- gtk.CellRenderer
48  * structWrap:
49  * 	- GdkWindow* -> Window
50  * 	- GtkCellRenderer* -> CellRenderer
51  * module aliases:
52  * local aliases:
53  * overrides:
54  */
55 
56 module gsv.SourceGutter;
57 
58 public  import gsvc.gsvtypes;
59 
60 private import gsvc.gsv;
61 private import glib.ConstructionException;
62 private import gobject.ObjectG;
63 
64 private import gobject.Signals;
65 public  import gtkc.gdktypes;
66 
67 private import gdk.Window;
68 private import gtk.CellRenderer;
69 
70 
71 
72 private import gobject.ObjectG;
73 
74 /**
75  * Description
76  * The GtkSourceGutter object represents the left and right gutters of the text
77  * view. It is used by GtkSourceView to draw the line numbers and category
78  * marks that might be present on a line. By packing additional GtkCellRenderer
79  * objects in the gutter, you can extend the gutter with your own custom
80  * drawings.
81  * The gutter works very much the same way as cells rendered in a GtkTreeView.
82  * The concept is similar, with the exception that the gutter does not have an
83  * underlying GtkTreeModel. Instead, you should use
84  * gtk_source_gutter_set_cell_data_func to set a callback to fill in any of the
85  * cell renderers properties, given the line for which the cell is to be
86  * rendered. Renderers are inserted into the gutter at a certain position. The
87  * builtin line number renderer is at position
88  * GTK_SOURCE_VIEW_GUTTER_POSITION_LINES (-30) and the marks renderer is at
89  * GTK_SOURCE_VIEW_GUTTER_POSITION_MARKS (-20). You can use these values to
90  * position custom renderers accordingly. The width of a cell renderer can be
91  * specified as either fixed (using
92  * gtk_cell_renderer_set_fixed_size) or dynamic, in which case you
93  * must set gtk_source_gutter_set_cell_size_func. This
94  * callback is used to set the properties of the renderer such that
95  * gtk_cell_renderer_get_size yields the maximum width of the cell.
96  */
97 public class SourceGutter : ObjectG
98 {
99 	
100 	/** the main Gtk struct */
101 	protected GtkSourceGutter* gtkSourceGutter;
102 	
103 	
104 	public GtkSourceGutter* getSourceGutterStruct()
105 	{
106 		return gtkSourceGutter;
107 	}
108 	
109 	
110 	/** the main Gtk struct as a void* */
111 	protected override void* getStruct()
112 	{
113 		return cast(void*)gtkSourceGutter;
114 	}
115 	
116 	/**
117 	 * Sets our main struct and passes it to the parent class
118 	 */
119 	public this (GtkSourceGutter* gtkSourceGutter)
120 	{
121 		super(cast(GObject*)gtkSourceGutter);
122 		this.gtkSourceGutter = gtkSourceGutter;
123 	}
124 	
125 	protected override void setStruct(GObject* obj)
126 	{
127 		super.setStruct(obj);
128 		gtkSourceGutter = cast(GtkSourceGutter*)obj;
129 	}
130 	
131 	/**
132 	 */
133 	int[string] connectedSignals;
134 	
135 	void delegate(CellRenderer, GtkTextIter*, GdkEvent*, SourceGutter)[] onCellActivatedListeners;
136 	/**
137 	 * Emitted when a cell has been activated (for instance when there was
138 	 * a button press on the cell). The signal is only emitted for cells
139 	 * that have the activatable property set to TRUE.
140 	 */
141 	void addOnCellActivated(void delegate(CellRenderer, GtkTextIter*, GdkEvent*, SourceGutter) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
142 	{
143 		if ( !("cell-activated" in connectedSignals) )
144 		{
145 			Signals.connectData(
146 			getStruct(),
147 			"cell-activated",
148 			cast(GCallback)&callBackCellActivated,
149 			cast(void*)this,
150 			null,
151 			connectFlags);
152 			connectedSignals["cell-activated"] = 1;
153 		}
154 		onCellActivatedListeners ~= dlg;
155 	}
156 	extern(C) static void callBackCellActivated(GtkSourceGutter* gutterStruct, GtkCellRenderer* renderer, GtkTextIter* iter, GdkEvent* event, SourceGutter _sourceGutter)
157 	{
158 		foreach ( void delegate(CellRenderer, GtkTextIter*, GdkEvent*, SourceGutter) dlg ; _sourceGutter.onCellActivatedListeners )
159 		{
160 			dlg(ObjectG.getDObject!(CellRenderer)(renderer), iter, event, _sourceGutter);
161 		}
162 	}
163 	
164 	bool delegate(CellRenderer, GtkTextIter*, GtkTooltip*, SourceGutter)[] onQueryTooltipListeners;
165 	/**
166 	 * Emitted when a tooltip is requested for a specific cell. Signal
167 	 * handlers can return TRUE to notify the tooltip has been handled.
168 	 * See Also
169 	 * GtkSourceView
170 	 */
171 	void addOnQueryTooltip(bool delegate(CellRenderer, GtkTextIter*, GtkTooltip*, SourceGutter) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
172 	{
173 		if ( !("query-tooltip" in connectedSignals) )
174 		{
175 			Signals.connectData(
176 			getStruct(),
177 			"query-tooltip",
178 			cast(GCallback)&callBackQueryTooltip,
179 			cast(void*)this,
180 			null,
181 			connectFlags);
182 			connectedSignals["query-tooltip"] = 1;
183 		}
184 		onQueryTooltipListeners ~= dlg;
185 	}
186 	extern(C) static gboolean callBackQueryTooltip(GtkSourceGutter* gutterStruct, GtkCellRenderer* renderer, GtkTextIter* iter, GtkTooltip* tooltip, SourceGutter _sourceGutter)
187 	{
188 		foreach ( bool delegate(CellRenderer, GtkTextIter*, GtkTooltip*, SourceGutter) dlg ; _sourceGutter.onQueryTooltipListeners )
189 		{
190 			if ( dlg(ObjectG.getDObject!(CellRenderer)(renderer), iter, tooltip, _sourceGutter) )
191 			{
192 				return 1;
193 			}
194 		}
195 		
196 		return 0;
197 	}
198 	
199 	
200 	/**
201 	 * Get the GdkWindow of the gutter. The window will only be available when the
202 	 * gutter has at least one, non-zero width, cell renderer packed.
203 	 * Since 2.8
204 	 * Returns: the GdkWindow of the gutter, or NULL if the gutter has no window.
205 	 */
206 	public Window getWindow()
207 	{
208 		// GdkWindow * gtk_source_gutter_get_window (GtkSourceGutter *gutter);
209 		auto p = gtk_source_gutter_get_window(gtkSourceGutter);
210 		
211 		if(p is null)
212 		{
213 			return null;
214 		}
215 		
216 		return ObjectG.getDObject!(Window)(cast(GdkWindow*) p);
217 	}
218 	
219 	/**
220 	 * Inserts renderer into gutter at position.
221 	 * Since 2.8
222 	 * Params:
223 	 * renderer = a GtkCellRenderer
224 	 * position = the renderers position
225 	 */
226 	public void insert(CellRenderer renderer, int position)
227 	{
228 		// void gtk_source_gutter_insert (GtkSourceGutter *gutter,  GtkCellRenderer *renderer,  gint position);
229 		gtk_source_gutter_insert(gtkSourceGutter, (renderer is null) ? null : renderer.getCellRendererStruct(), position);
230 	}
231 	
232 	/**
233 	 * Reorders renderer in gutter to new position.
234 	 * Since 2.8
235 	 * Params:
236 	 * renderer = a GtkCellRenderer
237 	 * position = the new renderer position
238 	 */
239 	public void reorder(CellRenderer renderer, int position)
240 	{
241 		// void gtk_source_gutter_reorder (GtkSourceGutter *gutter,  GtkCellRenderer *renderer,  gint position);
242 		gtk_source_gutter_reorder(gtkSourceGutter, (renderer is null) ? null : renderer.getCellRendererStruct(), position);
243 	}
244 	
245 	/**
246 	 * Removes renderer from gutter.
247 	 * Since 2.8
248 	 * Params:
249 	 * renderer = a GtkCellRenderer
250 	 */
251 	public void remove(CellRenderer renderer)
252 	{
253 		// void gtk_source_gutter_remove (GtkSourceGutter *gutter,  GtkCellRenderer *renderer);
254 		gtk_source_gutter_remove(gtkSourceGutter, (renderer is null) ? null : renderer.getCellRendererStruct());
255 	}
256 	
257 	/**
258 	 * Sets the GtkSourceGutterDataFunc to use for renderer. This function is
259 	 * used to setup the cell renderer properties for rendering the current cell.
260 	 * Since 2.8
261 	 * Params:
262 	 * renderer = a GtkCellRenderer
263 	 * func = the GtkSourceGutterDataFunc to use
264 	 * funcData = the user data for func
265 	 * destroy = the destroy notification for func_data
266 	 */
267 	public void setCellDataFunc(CellRenderer renderer, GtkSourceGutterDataFunc func, void* funcData, GDestroyNotify destroy)
268 	{
269 		// void gtk_source_gutter_set_cell_data_func  (GtkSourceGutter *gutter,  GtkCellRenderer *renderer,  GtkSourceGutterDataFunc func,  gpointer func_data,  GDestroyNotify destroy);
270 		gtk_source_gutter_set_cell_data_func(gtkSourceGutter, (renderer is null) ? null : renderer.getCellRendererStruct(), func, funcData, destroy);
271 	}
272 	
273 	/**
274 	 * Sets the GtkSourceGutterSizeFunc to use for renderer. This function is
275 	 * used to setup the cell renderer properties for measuring the maximum size
276 	 * of the cell.
277 	 * Since 2.8
278 	 * Params:
279 	 * renderer = a GtkCellRenderer
280 	 * func = the GtkSourceGutterSizeFunc to use
281 	 * funcData = the user data for func
282 	 * destroy = the destroy notification for func_data
283 	 */
284 	public void setCellSizeFunc(CellRenderer renderer, GtkSourceGutterSizeFunc func, void* funcData, GDestroyNotify destroy)
285 	{
286 		// void gtk_source_gutter_set_cell_size_func  (GtkSourceGutter *gutter,  GtkCellRenderer *renderer,  GtkSourceGutterSizeFunc func,  gpointer func_data,  GDestroyNotify destroy);
287 		gtk_source_gutter_set_cell_size_func(gtkSourceGutter, (renderer is null) ? null : renderer.getCellRendererStruct(), func, funcData, destroy);
288 	}
289 	
290 	/**
291 	 * Invalidates the drawable area of the gutter. You can use this to force a
292 	 * redraw of the gutter if something has changed and needs to be redrawn.
293 	 * Since 2.8
294 	 */
295 	public void queueDraw()
296 	{
297 		// void gtk_source_gutter_queue_draw (GtkSourceGutter *gutter);
298 		gtk_source_gutter_queue_draw(gtkSourceGutter);
299 	}
300 }