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