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  = GtkToolPalette.html
27  * outPack = gtk
28  * outFile = ToolPalette
29  * strct   = GtkToolPalette
30  * realStrct=
31  * ctorStrct=GtkWidget
32  * clss    = ToolPalette
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * 	- OrientableIF
40  * prefixes:
41  * 	- gtk_tool_palette_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- gtk.Adjustment
49  * 	- gtk.ToolItem
50  * 	- gtk.ToolItemGroup
51  * 	- gtk.Widget
52  * 	- gtk.OrientableIF
53  * 	- gtk.OrientableT
54  * structWrap:
55  * 	- GtkAdjustment* -> Adjustment
56  * 	- GtkToolItem* -> ToolItem
57  * 	- GtkToolItemGroup* -> ToolItemGroup
58  * 	- GtkWidget* -> Widget
59  * module aliases:
60  * local aliases:
61  * 	- getStyle -> getToolbarStyle
62  * overrides:
63  */
64 
65 module gtk.ToolPalette;
66 
67 public  import gtkc.gtktypes;
68 
69 private import gtkc.gtk;
70 private import glib.ConstructionException;
71 private import gobject.ObjectG;
72 
73 private import gobject.Signals;
74 public  import gtkc.gdktypes;
75 
76 private import glib.Str;
77 private import gtk.Adjustment;
78 private import gtk.ToolItem;
79 private import gtk.ToolItemGroup;
80 private import gtk.Widget;
81 private import gtk.OrientableIF;
82 private import gtk.OrientableT;
83 
84 
85 
86 private import gtk.Container;
87 
88 /**
89  * Description
90  * A GtkToolPalette allows you to add GtkToolItems to a palette-like
91  * container with different categories and drag and drop support.
92  * A GtkToolPalette is created with a call to gtk_tool_palette_new().
93  * GtkToolItems cannot be added directly to a GtkToolPalette -
94  * instead they are added to a GtkToolItemGroup which can than be added
95  * to a GtkToolPalette. To add a GtkToolItemGroup to a GtkToolPalette,
96  * use gtk_container_add().
97  * $(DDOC_COMMENT example)
98  * The easiest way to use drag and drop with GtkToolPalette is to call
99  * gtk_tool_palette_add_drag_dest() with the desired drag source palette
100  * and the desired drag target widget. Then gtk_tool_palette_get_drag_item()
101  * can be used to get the dragged item in the "drag-data-received"
102  * signal handler of the drag target.
103  * $(DDOC_COMMENT example)
104  */
105 public class ToolPalette : Container, OrientableIF
106 {
107 	
108 	/** the main Gtk struct */
109 	protected GtkToolPalette* gtkToolPalette;
110 	
111 	
112 	public GtkToolPalette* getToolPaletteStruct()
113 	{
114 		return gtkToolPalette;
115 	}
116 	
117 	
118 	/** the main Gtk struct as a void* */
119 	protected override void* getStruct()
120 	{
121 		return cast(void*)gtkToolPalette;
122 	}
123 	
124 	/**
125 	 * Sets our main struct and passes it to the parent class
126 	 */
127 	public this (GtkToolPalette* gtkToolPalette)
128 	{
129 		super(cast(GtkContainer*)gtkToolPalette);
130 		this.gtkToolPalette = gtkToolPalette;
131 	}
132 	
133 	protected override void setStruct(GObject* obj)
134 	{
135 		super.setStruct(obj);
136 		gtkToolPalette = cast(GtkToolPalette*)obj;
137 	}
138 	
139 	// add the Orientable capabilities
140 	mixin OrientableT!(GtkToolPalette);
141 	
142 	/**
143 	 */
144 	int[string] connectedSignals;
145 	
146 	void delegate(Adjustment, Adjustment, ToolPalette)[] onSetScrollAdjustmentsListeners;
147 	/**
148 	 * Set the scroll adjustments for the viewport.
149 	 * Usually scrolled containers like GtkScrolledWindow will emit this
150 	 * signal to connect two instances of GtkScrollbar to the scroll
151 	 * directions of the GtkToolpalette.
152 	 * Since 2.20
153 	 */
154 	void addOnSetScrollAdjustments(void delegate(Adjustment, Adjustment, ToolPalette) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
155 	{
156 		if ( !("set-scroll-adjustments" in connectedSignals) )
157 		{
158 			Signals.connectData(
159 			getStruct(),
160 			"set-scroll-adjustments",
161 			cast(GCallback)&callBackSetScrollAdjustments,
162 			cast(void*)this,
163 			null,
164 			connectFlags);
165 			connectedSignals["set-scroll-adjustments"] = 1;
166 		}
167 		onSetScrollAdjustmentsListeners ~= dlg;
168 	}
169 	extern(C) static void callBackSetScrollAdjustments(GtkToolPalette* widgetStruct, GtkAdjustment* hadjustment, GtkAdjustment* vadjustment, ToolPalette _toolPalette)
170 	{
171 		foreach ( void delegate(Adjustment, Adjustment, ToolPalette) dlg ; _toolPalette.onSetScrollAdjustmentsListeners )
172 		{
173 			dlg(ObjectG.getDObject!(Adjustment)(hadjustment), ObjectG.getDObject!(Adjustment)(vadjustment), _toolPalette);
174 		}
175 	}
176 	
177 	
178 	/**
179 	 * Creates a new tool palette.
180 	 * Since 2.20
181 	 * Throws: ConstructionException GTK+ fails to create the object.
182 	 */
183 	public this ()
184 	{
185 		// GtkWidget * gtk_tool_palette_new (void);
186 		auto p = gtk_tool_palette_new();
187 		if(p is null)
188 		{
189 			throw new ConstructionException("null returned by gtk_tool_palette_new()");
190 		}
191 		this(cast(GtkToolPalette*) p);
192 	}
193 	
194 	/**
195 	 * Gets whether group is exclusive or not.
196 	 * See gtk_tool_palette_set_exclusive().
197 	 * Since 2.20
198 	 * Params:
199 	 * group = a GtkToolItemGroup which is a child of palette
200 	 * Returns: TRUE if group is exclusive
201 	 */
202 	public int getExclusive(ToolItemGroup group)
203 	{
204 		// gboolean gtk_tool_palette_get_exclusive (GtkToolPalette *palette,  GtkToolItemGroup *group);
205 		return gtk_tool_palette_get_exclusive(gtkToolPalette, (group is null) ? null : group.getToolItemGroupStruct());
206 	}
207 	
208 	/**
209 	 * Sets whether the group should be exclusive or not.
210 	 * If an exclusive group is expanded all other groups are collapsed.
211 	 * Since 2.20
212 	 * Params:
213 	 * group = a GtkToolItemGroup which is a child of palette
214 	 * exclusive = whether the group should be exclusive or not
215 	 */
216 	public void setExclusive(ToolItemGroup group, int exclusive)
217 	{
218 		// void gtk_tool_palette_set_exclusive (GtkToolPalette *palette,  GtkToolItemGroup *group,  gboolean exclusive);
219 		gtk_tool_palette_set_exclusive(gtkToolPalette, (group is null) ? null : group.getToolItemGroupStruct(), exclusive);
220 	}
221 	
222 	/**
223 	 * Gets whether group should be given extra space.
224 	 * See gtk_tool_palette_set_expand().
225 	 * Since 2.20
226 	 * Params:
227 	 * group = a GtkToolItemGroup which is a child of palette
228 	 * Returns: TRUE if group should be given extra space, FALSE otherwise
229 	 */
230 	public int getExpand(ToolItemGroup group)
231 	{
232 		// gboolean gtk_tool_palette_get_expand (GtkToolPalette *palette,  GtkToolItemGroup *group);
233 		return gtk_tool_palette_get_expand(gtkToolPalette, (group is null) ? null : group.getToolItemGroupStruct());
234 	}
235 	
236 	/**
237 	 * Sets whether the group should be given extra space.
238 	 * Since 2.20
239 	 * Params:
240 	 * group = a GtkToolItemGroup which is a child of palette
241 	 * expand = whether the group should be given extra space
242 	 */
243 	public void setExpand(ToolItemGroup group, int expand)
244 	{
245 		// void gtk_tool_palette_set_expand (GtkToolPalette *palette,  GtkToolItemGroup *group,  gboolean expand);
246 		gtk_tool_palette_set_expand(gtkToolPalette, (group is null) ? null : group.getToolItemGroupStruct(), expand);
247 	}
248 	
249 	/**
250 	 * Gets the position of group in palette as index.
251 	 * See gtk_tool_palette_set_group_position().
252 	 * Since 2.20
253 	 * Params:
254 	 * group = a GtkToolItemGroup
255 	 * Returns: the index of group or -1 if group is not a child of palette
256 	 */
257 	public int getGroupPosition(ToolItemGroup group)
258 	{
259 		// gint gtk_tool_palette_get_group_position (GtkToolPalette *palette,  GtkToolItemGroup *group);
260 		return gtk_tool_palette_get_group_position(gtkToolPalette, (group is null) ? null : group.getToolItemGroupStruct());
261 	}
262 	
263 	/**
264 	 * Sets the position of the group as an index of the tool palette.
265 	 * If position is 0 the group will become the first child, if position is
266 	 * -1 it will become the last child.
267 	 * Since 2.20
268 	 * Params:
269 	 * group = a GtkToolItemGroup which is a child of palette
270 	 * position = a new index for group
271 	 */
272 	public void setGroupPosition(ToolItemGroup group, int position)
273 	{
274 		// void gtk_tool_palette_set_group_position (GtkToolPalette *palette,  GtkToolItemGroup *group,  gint position);
275 		gtk_tool_palette_set_group_position(gtkToolPalette, (group is null) ? null : group.getToolItemGroupStruct(), position);
276 	}
277 	
278 	/**
279 	 * Gets the size of icons in the tool palette.
280 	 * See gtk_tool_palette_set_icon_size().
281 	 * Since 2.20
282 	 * Returns: the GtkIconSize of icons in the tool palette. [type int]
283 	 */
284 	public GtkIconSize getIconSize()
285 	{
286 		// GtkIconSize gtk_tool_palette_get_icon_size (GtkToolPalette *palette);
287 		return gtk_tool_palette_get_icon_size(gtkToolPalette);
288 	}
289 	
290 	/**
291 	 * Sets the size of icons in the tool palette.
292 	 * Since 2.20
293 	 * Params:
294 	 * iconSize = the GtkIconSize that icons in the tool
295 	 * palette shall have. [type int]
296 	 */
297 	public void setIconSize(GtkIconSize iconSize)
298 	{
299 		// void gtk_tool_palette_set_icon_size (GtkToolPalette *palette,  GtkIconSize icon_size);
300 		gtk_tool_palette_set_icon_size(gtkToolPalette, iconSize);
301 	}
302 	
303 	/**
304 	 * Unsets the tool palette icon size set with gtk_tool_palette_set_icon_size(),
305 	 * so that user preferences will be used to determine the icon size.
306 	 * Since 2.20
307 	 */
308 	public void unsetIconSize()
309 	{
310 		// void gtk_tool_palette_unset_icon_size (GtkToolPalette *palette);
311 		gtk_tool_palette_unset_icon_size(gtkToolPalette);
312 	}
313 	
314 	/**
315 	 * Gets the style (icons, text or both) of items in the tool palette.
316 	 * Since 2.20
317 	 * Returns: the GtkToolbarStyle of items in the tool palette.
318 	 */
319 	public GtkToolbarStyle getToolbarStyle()
320 	{
321 		// GtkToolbarStyle gtk_tool_palette_get_style (GtkToolPalette *palette);
322 		return gtk_tool_palette_get_style(gtkToolPalette);
323 	}
324 	
325 	/**
326 	 * Sets the style (text, icons or both) of items in the tool palette.
327 	 * Since 2.20
328 	 * Params:
329 	 * style = the GtkToolbarStyle that items in the tool palette shall have
330 	 */
331 	public void setStyle(GtkToolbarStyle style)
332 	{
333 		// void gtk_tool_palette_set_style (GtkToolPalette *palette,  GtkToolbarStyle style);
334 		gtk_tool_palette_set_style(gtkToolPalette, style);
335 	}
336 	
337 	/**
338 	 * Unsets a toolbar style set with gtk_tool_palette_set_style(),
339 	 * so that user preferences will be used to determine the toolbar style.
340 	 * Since 2.20
341 	 */
342 	public void unsetStyle()
343 	{
344 		// void gtk_tool_palette_unset_style (GtkToolPalette *palette);
345 		gtk_tool_palette_unset_style(gtkToolPalette);
346 	}
347 	
348 	/**
349 	 * Sets palette as drag source (see gtk_tool_palette_set_drag_source())
350 	 * and sets widget as a drag destination for drags from palette.
351 	 * See gtk_drag_dest_set().
352 	 * Since 2.20
353 	 * Params:
354 	 * widget = a GtkWidget which should be a drag destination for palette
355 	 * flags = the flags that specify what actions GTK+ should take for drops
356 	 * on that widget
357 	 * targets = the GtkToolPaletteDragTargets which the widget
358 	 * should support
359 	 * actions = the GdkDragActions which the widget should suppport
360 	 */
361 	public void addDragDest(Widget widget, GtkDestDefaults flags, GtkToolPaletteDragTargets targets, GdkDragAction actions)
362 	{
363 		// void gtk_tool_palette_add_drag_dest (GtkToolPalette *palette,  GtkWidget *widget,  GtkDestDefaults flags,  GtkToolPaletteDragTargets targets,  GdkDragAction actions);
364 		gtk_tool_palette_add_drag_dest(gtkToolPalette, (widget is null) ? null : widget.getWidgetStruct(), flags, targets, actions);
365 	}
366 	
367 	/**
368 	 * Get the dragged item from the selection.
369 	 * This could be a GtkToolItem or a GtkToolItemGroup.
370 	 * Since 2.20
371 	 * Params:
372 	 * selection = a GtkSelectionData
373 	 * Returns: the dragged item in selection. [transfer none]
374 	 */
375 	public Widget getDragItem(GtkSelectionData* selection)
376 	{
377 		// GtkWidget * gtk_tool_palette_get_drag_item (GtkToolPalette *palette,  const GtkSelectionData *selection);
378 		auto p = gtk_tool_palette_get_drag_item(gtkToolPalette, selection);
379 		
380 		if(p is null)
381 		{
382 			return null;
383 		}
384 		
385 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
386 	}
387 	
388 	/**
389 	 * Get the target entry for a dragged GtkToolItemGroup.
390 	 * Since 2.20
391 	 * Returns: the GtkTargetEntry for a dragged group. [transfer none]
392 	 */
393 	public static GtkTargetEntry* getDragTargetGroup()
394 	{
395 		// const GtkTargetEntry * gtk_tool_palette_get_drag_target_group  (void);
396 		return gtk_tool_palette_get_drag_target_group();
397 	}
398 	
399 	/**
400 	 * Gets the target entry for a dragged GtkToolItem.
401 	 * Since 2.20
402 	 * Returns: the GtkTargetEntry for a dragged item. [transfer none]
403 	 */
404 	public static GtkTargetEntry* getDragTargetItem()
405 	{
406 		// const GtkTargetEntry * gtk_tool_palette_get_drag_target_item  (void);
407 		return gtk_tool_palette_get_drag_target_item();
408 	}
409 	
410 	/**
411 	 * Gets the group at position (x, y).
412 	 * Since 2.20
413 	 * Params:
414 	 * x = the x position
415 	 * y = the y position
416 	 * Returns: the GtkToolItemGroup at position or NULL if there is no such group. [transfer none]
417 	 */
418 	public ToolItemGroup getDropGroup(int x, int y)
419 	{
420 		// GtkToolItemGroup * gtk_tool_palette_get_drop_group (GtkToolPalette *palette,  gint x,  gint y);
421 		auto p = gtk_tool_palette_get_drop_group(gtkToolPalette, x, y);
422 		
423 		if(p is null)
424 		{
425 			return null;
426 		}
427 		
428 		return ObjectG.getDObject!(ToolItemGroup)(cast(GtkToolItemGroup*) p);
429 	}
430 	
431 	/**
432 	 * Gets the item at position (x, y).
433 	 * See gtk_tool_palette_get_drop_group().
434 	 * Since 2.20
435 	 * Params:
436 	 * x = the x position
437 	 * y = the y position
438 	 * Returns: the GtkToolItem at position or NULL if there is no such item. [transfer none]
439 	 */
440 	public ToolItem getDropItem(int x, int y)
441 	{
442 		// GtkToolItem * gtk_tool_palette_get_drop_item (GtkToolPalette *palette,  gint x,  gint y);
443 		auto p = gtk_tool_palette_get_drop_item(gtkToolPalette, x, y);
444 		
445 		if(p is null)
446 		{
447 			return null;
448 		}
449 		
450 		return ObjectG.getDObject!(ToolItem)(cast(GtkToolItem*) p);
451 	}
452 	
453 	/**
454 	 * Sets the tool palette as a drag source.
455 	 * Enables all groups and items in the tool palette as drag sources
456 	 * on button 1 and button 3 press with copy and move actions.
457 	 * See gtk_drag_source_set().
458 	 * Since 2.20
459 	 * Params:
460 	 * targets = the GtkToolPaletteDragTargets
461 	 * which the widget should support
462 	 */
463 	public void setDragSource(GtkToolPaletteDragTargets targets)
464 	{
465 		// void gtk_tool_palette_set_drag_source (GtkToolPalette *palette,  GtkToolPaletteDragTargets targets);
466 		gtk_tool_palette_set_drag_source(gtkToolPalette, targets);
467 	}
468 	
469 	/**
470 	 * Gets the horizontal adjustment of the tool palette.
471 	 * Since 2.20
472 	 * Returns: the horizontal adjustment of palette. [transfer none]
473 	 */
474 	public Adjustment getHadjustment()
475 	{
476 		// GtkAdjustment * gtk_tool_palette_get_hadjustment (GtkToolPalette *palette);
477 		auto p = gtk_tool_palette_get_hadjustment(gtkToolPalette);
478 		
479 		if(p is null)
480 		{
481 			return null;
482 		}
483 		
484 		return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p);
485 	}
486 	
487 	/**
488 	 * Gets the vertical adjustment of the tool palette.
489 	 * Since 2.20
490 	 * Returns: the vertical adjustment of palette. [transfer none]
491 	 */
492 	public Adjustment getVadjustment()
493 	{
494 		// GtkAdjustment * gtk_tool_palette_get_vadjustment (GtkToolPalette *palette);
495 		auto p = gtk_tool_palette_get_vadjustment(gtkToolPalette);
496 		
497 		if(p is null)
498 		{
499 			return null;
500 		}
501 		
502 		return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p);
503 	}
504 }