alternative to assert
[gtkD.git] / src / gtk / CellRenderer.d
blobd4047d8bf930a4990d0ec6112fd8e4f0f19a8c42
1 /*
2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkCellRenderer.html
26 * outPack = gtk
27 * outFile = CellRenderer
28 * strct = GtkCellRenderer
29 * realStrct=
30 * ctorStrct=
31 * clss = CellRenderer
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_cell_renderer_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * imports:
45 * - glib.Str
46 * - gtk.Widget
47 * - gdk.Rectangle
48 * - gdk.Window
49 * - gdk.Event
50 * - gtk.CellEditable
51 * structWrap:
52 * - GdkEvent* -> Event
53 * - GdkRectangle* -> Rectangle
54 * - GdkWindow* -> Window
55 * - GtkCellEditable* -> CellEditable
56 * - GtkWidget* -> Widget
57 * local aliases:
60 module gtk.CellRenderer;
62 private import gtk.gtktypes;
64 private import lib.gtk;
66 private import glib.Str;
67 private import gtk.Widget;
68 private import gdk.Rectangle;
69 private import gdk.Window;
70 private import gdk.Event;
71 private import gtk.CellEditable;
73 /**
74 * Description
75 * The GtkCellRenderer is a base class of a set of objects used for
76 * rendering a cell to a GdkDrawable. These objects are used primarily by
77 * the GtkTreeView widget, though they aren't tied to them in any
78 * specific way. It is worth noting that GtkCellRenderer is not a
79 * GtkWidget and cannot be treated as such.
80 * The primary use of a GtkCellRenderer is for drawing a certain graphical
81 * elements on a GdkDrawable. Typically, one cell renderer is used to
82 * draw many cells on the screen. To this extent, it isn't expected that a
83 * CellRenderer keep any permanent state around. Instead, any state is set
84 * just prior to use using GObjects property system. Then, the
85 * cell is measured using gtk_cell_renderer_get_size(). Finally, the cell
86 * is rendered in the correct location using gtk_cell_renderer_render().
87 * There are a number of rules that must be followed when writing a new
88 * GtkCellRenderer. First and formost, it's important that a certain set
89 * of properties will always yield a cell renderer of the same size,
90 * barring a GtkStyle change. The GtkCellRenderer also has a number of
91 * generic properties that are expected to be honored by all children.
92 * Beyond merely rendering a cell, cell renderers can optionally
93 * provide active user interface elements. A cell renderer can be
94 * activatable like GtkCellRendererToggle,
95 * which toggles when it gets activated by a mouse click, or it can be
96 * editable like GtkCellRendererText, which
97 * allows the user to edit the text using a GtkEntry.
98 * To make a cell renderer activatable or editable, you have to
99 * implement the activate or start_editing virtual functions,
100 * respectively.
102 private import gtk.ObjectGtk;
103 public class CellRenderer : ObjectGtk
106 /** the main Gtk struct */
107 protected GtkCellRenderer* gtkCellRenderer;
110 public GtkCellRenderer* getCellRendererStruct()
112 return gtkCellRenderer;
116 /** the main Gtk struct as a void* */
117 protected void* getStruct()
119 return cast(void*)gtkCellRenderer;
123 * Sets our main struct and passes it to the parent class
125 public this (GtkCellRenderer* gtkCellRenderer)
127 super(cast(GtkObject*)gtkCellRenderer);
128 this.gtkCellRenderer = gtkCellRenderer;
134 // imports for the signal processing
135 private import gobject.Signals;
136 private import gdk.gdktypes;
137 int[char[]] connectedSignals;
139 void delegate(CellRenderer)[] onEditingCanceledListeners;
140 void addOnEditingCanceled(void delegate(CellRenderer) dlg)
142 if ( !("editing-canceled" in connectedSignals) )
144 Signals.connectData(
145 getStruct(),
146 "editing-canceled",
147 cast(GCallback)&callBackEditingCanceled,
148 this,
149 null,
150 cast(ConnectFlags)0);
151 connectedSignals["editing-canceled"] = 1;
153 onEditingCanceledListeners ~= dlg;
155 extern(C) static void callBackEditingCanceled(GtkCellRenderer* rendererStruct, CellRenderer cellRenderer)
157 bit consumed = false;
159 foreach ( void delegate(CellRenderer) dlg ; cellRenderer.onEditingCanceledListeners )
161 dlg(cellRenderer);
164 return consumed;
167 void delegate(CellEditable, char[], CellRenderer)[] onEditingStartedListeners;
168 void addOnEditingStarted(void delegate(CellEditable, char[], CellRenderer) dlg)
170 if ( !("editing-started" in connectedSignals) )
172 Signals.connectData(
173 getStruct(),
174 "editing-started",
175 cast(GCallback)&callBackEditingStarted,
176 this,
177 null,
178 cast(ConnectFlags)0);
179 connectedSignals["editing-started"] = 1;
181 onEditingStartedListeners ~= dlg;
183 extern(C) static void callBackEditingStarted(GtkCellRenderer* rendererStruct, GtkCellEditable* editable, gchar* path, CellRenderer cellRenderer)
185 bit consumed = false;
187 foreach ( void delegate(CellEditable, char[], CellRenderer) dlg ; cellRenderer.onEditingStartedListeners )
189 dlg(new CellEditable(editable), Str.toString(path), cellRenderer);
192 return consumed;
200 * Obtains the width and height needed to render the cell. Used by view widgets
201 * to determine the appropriate size for the cell_area passed to
202 * gtk_cell_renderer_render(). If cell_area is not NULL, fills in the x and y
203 * offsets (if set) of the cell relative to this location. Please note that the
204 * values set in width and height, as well as those in x_offset and y_offset
205 * are inclusive of the xpad and ypad properties.
206 * cell:
207 * a GtkCellRenderer
208 * widget:
209 * the widget the renderer is rendering to
210 * cell_area:
211 * The area a cell will be allocated, or NULL
212 * x_offset:
213 * location to return x offset of cell relative to cell_area, or NULL
214 * y_offset:
215 * location to return y offset of cell relative to cell_area, or NULL
216 * width:
217 * location to return width needed to render a cell, or NULL
218 * height:
219 * location to return height needed to render a cell, or NULL
221 public void getSize(Widget widget, Rectangle cellArea, int* xOffset, int* yOffset, int* width, int* height)
223 // void gtk_cell_renderer_get_size (GtkCellRenderer *cell, GtkWidget *widget, GdkRectangle *cell_area, gint *x_offset, gint *y_offset, gint *width, gint *height);
224 gtk_cell_renderer_get_size(gtkCellRenderer, (widget is null) ? null : widget.getWidgetStruct(), (cellArea is null) ? null : cellArea.getRectangleStruct(), xOffset, yOffset, width, height);
228 * Invokes the virtual render function of the GtkCellRenderer. The three
229 * passed-in rectangles are areas of window. Most renderers will draw within
230 * cell_area; the xalign, yalign, xpad, and ypad fields of the GtkCellRenderer
231 * should be honored with respect to cell_area. background_area includes the
232 * blank space around the cell, and also the area containing the tree expander;
233 * so the background_area rectangles for all cells tile to cover the entire
234 * window. expose_area is a clip rectangle.
235 * cell:
236 * a GtkCellRenderer
237 * window:
238 * a GdkDrawable to draw to
239 * widget:
240 * the widget owning window
241 * background_area:
242 * entire cell area (including tree expanders and maybe padding on the sides)
243 * cell_area:
244 * area normally rendered by a cell renderer
245 * expose_area:
246 * area that actually needs updating
247 * flags:
248 * flags that affect rendering
250 public void render(Window window, Widget widget, Rectangle backgroundArea, Rectangle cellArea, Rectangle exposeArea, GtkCellRendererState flags)
252 // void gtk_cell_renderer_render (GtkCellRenderer *cell, GdkWindow *window, GtkWidget *widget, GdkRectangle *background_area, GdkRectangle *cell_area, GdkRectangle *expose_area, GtkCellRendererState flags);
253 gtk_cell_renderer_render(gtkCellRenderer, (window is null) ? null : window.getWindowStruct(), (widget is null) ? null : widget.getWidgetStruct(), (backgroundArea is null) ? null : backgroundArea.getRectangleStruct(), (cellArea is null) ? null : cellArea.getRectangleStruct(), (exposeArea is null) ? null : exposeArea.getRectangleStruct(), flags);
257 * Passes an activate event to the cell renderer for possible processing. Some
258 * cell renderers may use events; for example, GtkCellRendererToggle toggles
259 * when it gets a mouse click.
260 * cell:
261 * a GtkCellRenderer
262 * event:
263 * a GdkEvent
264 * widget:
265 * widget that received the event
266 * path:
267 * widget-dependent string representation of the event location; e.g. for GtkTreeView, a string representation of GtkTreePath
268 * background_area:
269 * background area as passed to gtk_cell_renderer_render
270 * cell_area:
271 * cell area as passed to gtk_cell_renderer_render
272 * flags:
273 * render flags
274 * Returns:
275 * TRUE if the event was consumed/handled
277 public int activate(Event event, Widget widget, char[] path, Rectangle backgroundArea, Rectangle cellArea, GtkCellRendererState flags)
279 // gboolean gtk_cell_renderer_activate (GtkCellRenderer *cell, GdkEvent *event, GtkWidget *widget, const gchar *path, GdkRectangle *background_area, GdkRectangle *cell_area, GtkCellRendererState flags);
280 return gtk_cell_renderer_activate(gtkCellRenderer, (event is null) ? null : event.getEventStruct(), (widget is null) ? null : widget.getWidgetStruct(), Str.toStringz(path), (backgroundArea is null) ? null : backgroundArea.getRectangleStruct(), (cellArea is null) ? null : cellArea.getRectangleStruct(), flags);
284 * Passes an activate event to the cell renderer for possible processing.
285 * cell:
286 * a GtkCellRenderer
287 * event:
288 * a GdkEvent
289 * widget:
290 * widget that received the event
291 * path:
292 * widget-dependent string representation of the event location; e.g. for GtkTreeView, a string representation of GtkTreePath
293 * background_area:
294 * background area as passed to gtk_cell_renderer_render
295 * cell_area:
296 * cell area as passed to gtk_cell_renderer_render
297 * flags:
298 * render flags
299 * Returns:
300 * A new GtkCellEditable, or NULL
302 public CellEditable startEditing(Event event, Widget widget, char[] path, Rectangle backgroundArea, Rectangle cellArea, GtkCellRendererState flags)
304 // GtkCellEditable* gtk_cell_renderer_start_editing (GtkCellRenderer *cell, GdkEvent *event, GtkWidget *widget, const gchar *path, GdkRectangle *background_area, GdkRectangle *cell_area, GtkCellRendererState flags);
305 return new CellEditable( gtk_cell_renderer_start_editing(gtkCellRenderer, (event is null) ? null : event.getEventStruct(), (widget is null) ? null : widget.getWidgetStruct(), Str.toStringz(path), (backgroundArea is null) ? null : backgroundArea.getRectangleStruct(), (cellArea is null) ? null : cellArea.getRectangleStruct(), flags) );
309 * Warning
310 * gtk_cell_renderer_editing_canceled has been deprecated since version 2.6 and should not be used in newly-written code. Use gtk_cell_renderer_stop_editing() instead
311 * Causes the cell renderer to emit the "editing-canceled" signal. This
312 * function is for use only by implementations of cell renderers that need to
313 * notify the client program that an editing process was canceled and the
314 * changes were not committed.
315 * cell:
316 * A GtkCellRenderer
317 * Since 2.4
319 public void editingCanceled()
321 // void gtk_cell_renderer_editing_canceled (GtkCellRenderer *cell);
322 gtk_cell_renderer_editing_canceled(gtkCellRenderer);
326 * Informs the cell renderer that the editing is stopped.
327 * If canceled is TRUE, the cell renderer will emit the "editing-canceled"
328 * signal. This function should be called by cell renderer implementations
329 * in response to the "editing-done" signal of GtkCellEditable.
330 * cell:
331 * A GtkCellRenderer
332 * canceled:
333 * TRUE if the editing has been canceled
334 * Since 2.6
336 public void stopEditing(int canceled)
338 // void gtk_cell_renderer_stop_editing (GtkCellRenderer *cell, gboolean canceled);
339 gtk_cell_renderer_stop_editing(gtkCellRenderer, canceled);
343 * Fills in width and height with the appropriate size of cell.
344 * cell:
345 * A GtkCellRenderer
346 * width:
347 * location to fill in with the fixed width of the widget, or NULL
348 * height:
349 * location to fill in with the fixed height of the widget, or NULL
351 public void getFixedSize(int* width, int* height)
353 // void gtk_cell_renderer_get_fixed_size (GtkCellRenderer *cell, gint *width, gint *height);
354 gtk_cell_renderer_get_fixed_size(gtkCellRenderer, width, height);
358 * Sets the renderer size to be explicit, independent of the properties set.
359 * cell:
360 * A GtkCellRenderer
361 * width:
362 * the width of the cell renderer, or -1
363 * height:
364 * the height of the cell renderer, or -1
365 * Property Details
366 * The "cell-background" property
367 * "cell-background" gchararray : Write
368 * Cell background color as a string.
369 * Default value: NULL
371 public void setFixedSize(int width, int height)
373 // void gtk_cell_renderer_set_fixed_size (GtkCellRenderer *cell, gint width, gint height);
374 gtk_cell_renderer_set_fixed_size(gtkCellRenderer, width, height);