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 module gtk.ImageMenuItem;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gtk.AccelGroup;
31 private import gtk.MenuItem;
32 private import gtk.Widget;
33 private import gtkc.gtk;
34 public  import gtkc.gtktypes;
35 
36 
37 /**
38  * A GtkImageMenuItem is a menu item which has an icon next to the text label.
39  * 
40  * Note that the user can disable display of menu icons, so make sure to still
41  * fill in the text label.
42  */
43 public class ImageMenuItem : MenuItem
44 {
45 	/** the main Gtk struct */
46 	protected GtkImageMenuItem* gtkImageMenuItem;
47 
48 	/** Get the main Gtk struct */
49 	public GtkImageMenuItem* getImageMenuItemStruct()
50 	{
51 		return gtkImageMenuItem;
52 	}
53 
54 	/** the main Gtk struct as a void* */
55 	protected override void* getStruct()
56 	{
57 		return cast(void*)gtkImageMenuItem;
58 	}
59 
60 	protected override void setStruct(GObject* obj)
61 	{
62 		gtkImageMenuItem = cast(GtkImageMenuItem*)obj;
63 		super.setStruct(obj);
64 	}
65 
66 	/**
67 	 * Sets our main struct and passes it to the parent class.
68 	 */
69 	public this (GtkImageMenuItem* gtkImageMenuItem, bool ownedRef = false)
70 	{
71 		this.gtkImageMenuItem = gtkImageMenuItem;
72 		super(cast(GtkMenuItem*)gtkImageMenuItem, ownedRef);
73 	}
74 
75 	/**
76 	 * Creates a new GtkImageMenuItem containing a label.
77 	 * If mnemonic it true the label will be created using
78 	 * gtk_label_new_with_mnemonic(), so underscores
79 	 * in label indicate the mnemonic for the menu item.
80 	 * Params:
81 	 *  label = the text of the menu item.
82 	 * Throws: ConstructionException GTK+ fails to create the object.
83 	 */
84 	public this (string label, bool mnemonic=true)
85 	{
86 		GtkImageMenuItem* p;
87 		
88 		if ( mnemonic )
89 		{
90 			// GtkWidget* gtk_image_menu_item_new_with_mnemonic  (const gchar *label);
91 			p = cast(GtkImageMenuItem*)gtk_image_menu_item_new_with_mnemonic(Str.toStringz(label));
92 		}
93 		else
94 		{
95 			// GtkWidget* gtk_image_menu_item_new_with_label  (const gchar *label);
96 			p = cast(GtkImageMenuItem*)gtk_image_menu_item_new_with_label(Str.toStringz(label));
97 		}
98 		
99 		if(p is null)
100 		{
101 			throw new ConstructionException("null returned by gtk_image_menu_item_new_with_");
102 		}
103 		
104 		this(p);
105 	}
106 	
107 	/**
108 	 * Creates a new GtkImageMenuItem containing the image and text from a
109 	 * stock item.
110 	 * If you want this menu item to have changeable accelerators, then pass in
111 	 * null for accelGroup. Next call setAccelPath() with an appropriate path
112 	 * for the menu item, use gtk.StockItem.StockItem.lookup() to look up the
113 	 * standard accelerator for the stock item, and if one is found, call
114 	 * gtk.AccelMap.AccelMap.addEntry() to register it.
115 	 * Params:
116 	 *   StockID    = the name of the stock item
117 	 *   accelGroup = the GtkAccelGroup to add the menu items accelerator to,
118 	 *                or NULL.
119 	 * Throws: ConstructionException GTK+ fails to create the object.
120 	 */
121 	public this (StockID stockID, AccelGroup accelGroup)
122 	{
123 		auto p = gtk_image_menu_item_new_from_stock(Str.toStringz(stockID), (accelGroup is null) ? null : accelGroup.getAccelGroupStruct());
124 		if(p is null)
125 		{
126 			throw new ConstructionException("null returned by gtk_image_menu_item_new_from_stock");
127 		}
128 		this(cast(GtkImageMenuItem*) p);
129 	}
130 
131 	/**
132 	 */
133 
134 	public static GType getType()
135 	{
136 		return gtk_image_menu_item_get_type();
137 	}
138 
139 	/**
140 	 * Creates a new #GtkImageMenuItem with an empty label.
141 	 *
142 	 * Deprecated: Use gtk_menu_item_new() instead.
143 	 *
144 	 * Return: a new #GtkImageMenuItem
145 	 *
146 	 * Throws: ConstructionException GTK+ fails to create the object.
147 	 */
148 	public this()
149 	{
150 		auto p = gtk_image_menu_item_new();
151 		
152 		if(p is null)
153 		{
154 			throw new ConstructionException("null returned by new");
155 		}
156 		
157 		this(cast(GtkImageMenuItem*) p);
158 	}
159 
160 	/**
161 	 * Returns whether the menu item will ignore the #GtkSettings:gtk-menu-images
162 	 * setting and always show the image, if available.
163 	 *
164 	 * Return: %TRUE if the menu item will always show the image
165 	 *
166 	 * Since: 2.16
167 	 */
168 	public bool getAlwaysShowImage()
169 	{
170 		return gtk_image_menu_item_get_always_show_image(gtkImageMenuItem) != 0;
171 	}
172 
173 	/**
174 	 * Gets the widget that is currently set as the image of @image_menu_item.
175 	 * See gtk_image_menu_item_set_image().
176 	 *
177 	 * Return: the widget set as image of @image_menu_item
178 	 */
179 	public Widget getImage()
180 	{
181 		auto p = gtk_image_menu_item_get_image(gtkImageMenuItem);
182 		
183 		if(p is null)
184 		{
185 			return null;
186 		}
187 		
188 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
189 	}
190 
191 	/**
192 	 * Checks whether the label set in the menuitem is used as a
193 	 * stock id to select the stock item for the item.
194 	 *
195 	 * Return: %TRUE if the label set in the menuitem is used as a
196 	 *     stock id to select the stock item for the item
197 	 *
198 	 * Since: 2.16
199 	 */
200 	public bool getUseStock()
201 	{
202 		return gtk_image_menu_item_get_use_stock(gtkImageMenuItem) != 0;
203 	}
204 
205 	/**
206 	 * Specifies an @accel_group to add the menu items accelerator to
207 	 * (this only applies to stock items so a stock item must already
208 	 * be set, make sure to call gtk_image_menu_item_set_use_stock()
209 	 * and gtk_menu_item_set_label() with a valid stock item first).
210 	 *
211 	 * If you want this menu item to have changeable accelerators then
212 	 * you shouldnt need this (see gtk_image_menu_item_new_from_stock()).
213 	 *
214 	 * Params:
215 	 *     accelGroup = the #GtkAccelGroup
216 	 *
217 	 * Since: 2.16
218 	 */
219 	public void setAccelGroup(AccelGroup accelGroup)
220 	{
221 		gtk_image_menu_item_set_accel_group(gtkImageMenuItem, (accelGroup is null) ? null : accelGroup.getAccelGroupStruct());
222 	}
223 
224 	/**
225 	 * If %TRUE, the menu item will ignore the #GtkSettings:gtk-menu-images
226 	 * setting and always show the image, if available.
227 	 *
228 	 * Use this property if the menuitem would be useless or hard to use
229 	 * without the image.
230 	 *
231 	 * Params:
232 	 *     alwaysShow = %TRUE if the menuitem should always show the image
233 	 *
234 	 * Since: 2.16
235 	 */
236 	public void setAlwaysShowImage(bool alwaysShow)
237 	{
238 		gtk_image_menu_item_set_always_show_image(gtkImageMenuItem, alwaysShow);
239 	}
240 
241 	/**
242 	 * Sets the image of @image_menu_item to the given widget.
243 	 * Note that it depends on the show-menu-images setting whether
244 	 * the image will be displayed or not.
245 	 *
246 	 * Params:
247 	 *     image = a widget to set as the image for the menu item.
248 	 */
249 	public void setImage(Widget image)
250 	{
251 		gtk_image_menu_item_set_image(gtkImageMenuItem, (image is null) ? null : image.getWidgetStruct());
252 	}
253 
254 	/**
255 	 * If %TRUE, the label set in the menuitem is used as a
256 	 * stock id to select the stock item for the item.
257 	 *
258 	 * Params:
259 	 *     useStock = %TRUE if the menuitem should use a stock item
260 	 *
261 	 * Since: 2.16
262 	 */
263 	public void setUseStock(bool useStock)
264 	{
265 		gtk_image_menu_item_set_use_stock(gtkImageMenuItem, useStock);
266 	}
267 }