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