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  = GtkMenuButton.html
27  * outPack = gtk
28  * outFile = MenuButton
29  * strct   = GtkMenuButton
30  * realStrct=
31  * ctorStrct=
32  * clss    = MenuButton
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_menu_button_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- gio.MenuModel
47  * 	- gtk.Menu
48  * 	- gtk.Widget
49  * structWrap:
50  * 	- GMenuModel* -> MenuModel
51  * 	- GtkMenu* -> Menu
52  * 	- GtkWidget* -> Widget
53  * module aliases:
54  * local aliases:
55  * 	- getDirection -> getMenuDirection
56  * 	- setDirection -> setMenuDirection
57  * overrides:
58  */
59 
60 module gtk.MenuButton;
61 
62 public  import gtkc.gtktypes;
63 
64 private import gtkc.gtk;
65 private import glib.ConstructionException;
66 private import gobject.ObjectG;
67 
68 
69 private import gio.MenuModel;
70 private import gtk.Menu;
71 private import gtk.Widget;
72 
73 
74 
75 private import gtk.ToggleButton;
76 
77 /**
78  * The GtkMenuButton widget is used to display a menu when clicked on.
79  * This menu can be provided either as a GtkMenu, or an abstract GMenuModel.
80  *
81  * The GtkMenuButton widget can hold any valid child widget. That is, it
82  * can hold almost any other standard GtkWidget. The most commonly used
83  * child is the provided GtkArrow.
84  *
85  * The positioning of the menu is determined by the "direction"
86  * property of the menu button and the "halign" or "valign"
87  * properties of the menu. For example, when the direction is GTK_ARROW_DOWN
88  * and the horizontal alignment is GTK_ALIGN_START, the menu will be
89  * positioned below the button, with the starting edge (depending on the
90  * text direction) of the menu aligned with the starting edge of the button.
91  * If there is not enough space below the button, the menu is popped up above
92  * the button instead. If the alignment would move part of the menu offscreen,
93  * it is 'pushed in'.
94  *
95  * halign = start
96  * halign = center
97  * halign = end
98  *
99  * direction = down
100  *
101  * direction = up
102  *
103  * direction = left
104  * direction = right
105  *
106  * valign = start
107  *
108  * valign = center
109  *
110  * valign = end
111  */
112 public class MenuButton : ToggleButton
113 {
114 	
115 	/** the main Gtk struct */
116 	protected GtkMenuButton* gtkMenuButton;
117 	
118 	
119 	public GtkMenuButton* getMenuButtonStruct()
120 	{
121 		return gtkMenuButton;
122 	}
123 	
124 	
125 	/** the main Gtk struct as a void* */
126 	protected override void* getStruct()
127 	{
128 		return cast(void*)gtkMenuButton;
129 	}
130 	
131 	/**
132 	 * Sets our main struct and passes it to the parent class
133 	 */
134 	public this (GtkMenuButton* gtkMenuButton)
135 	{
136 		super(cast(GtkToggleButton*)gtkMenuButton);
137 		this.gtkMenuButton = gtkMenuButton;
138 	}
139 	
140 	protected override void setStruct(GObject* obj)
141 	{
142 		super.setStruct(obj);
143 		gtkMenuButton = cast(GtkMenuButton*)obj;
144 	}
145 	
146 	/**
147 	 */
148 	
149 	/**
150 	 * Creates a new GtkMenuButton widget with downwards-pointing
151 	 * arrow as the only child. You can replace the child widget
152 	 * with another GtkWidget should you wish to.
153 	 * Throws: ConstructionException GTK+ fails to create the object.
154 	 */
155 	public this ()
156 	{
157 		// GtkWidget * gtk_menu_button_new (void);
158 		auto p = gtk_menu_button_new();
159 		if(p is null)
160 		{
161 			throw new ConstructionException("null returned by gtk_menu_button_new()");
162 		}
163 		this(cast(GtkMenuButton*) p);
164 	}
165 	
166 	/**
167 	 * Sets the GtkMenu that will be popped up when the button is clicked,
168 	 * or NULL to disable the button. If "menu-model" is set,
169 	 * it will be set to NULL.
170 	 * Params:
171 	 * popup = a GtkMenu. [allow-none]
172 	 * Since 3.6
173 	 */
174 	public void setPopup(Widget popup)
175 	{
176 		// void gtk_menu_button_set_popup (GtkMenuButton *menu_button,  GtkWidget *popup);
177 		gtk_menu_button_set_popup(gtkMenuButton, (popup is null) ? null : popup.getWidgetStruct());
178 	}
179 	
180 	/**
181 	 * Returns the GtkMenu that pops out of the button.
182 	 * Returns: a GtkMenu or NULL. [transfer none] Since 3.6
183 	 */
184 	public Menu getPopup()
185 	{
186 		// GtkMenu * gtk_menu_button_get_popup (GtkMenuButton *menu_button);
187 		auto p = gtk_menu_button_get_popup(gtkMenuButton);
188 		
189 		if(p is null)
190 		{
191 			return null;
192 		}
193 		
194 		return ObjectG.getDObject!(Menu)(cast(GtkMenu*) p);
195 	}
196 	
197 	/**
198 	 * Sets the GMenuModel from which the "popup" property will be
199 	 * filled in, or NULL to disable the button.
200 	 * The GtkMenu will be created with gtk_menu_new_from_model(), so actions
201 	 * will be connected as documented there.
202 	 * If "popup" is already set, then its content will be lost
203 	 * and replaced by our newly created GtkMenu.
204 	 * Params:
205 	 * menuModel = a GMenuModel. [allow-none]
206 	 * Since 3.6
207 	 */
208 	public void setMenuModel(MenuModel menuModel)
209 	{
210 		// void gtk_menu_button_set_menu_model (GtkMenuButton *menu_button,  GMenuModel *menu_model);
211 		gtk_menu_button_set_menu_model(gtkMenuButton, (menuModel is null) ? null : menuModel.getMenuModelStruct());
212 	}
213 	
214 	/**
215 	 * Returns the GMenuModel used to generate the menu.
216 	 * Returns: a GMenuModel or NULL. [transfer none] Since 3.6
217 	 */
218 	public MenuModel getMenuModel()
219 	{
220 		// GMenuModel * gtk_menu_button_get_menu_model (GtkMenuButton *menu_button);
221 		auto p = gtk_menu_button_get_menu_model(gtkMenuButton);
222 		
223 		if(p is null)
224 		{
225 			return null;
226 		}
227 		
228 		return ObjectG.getDObject!(MenuModel)(cast(GMenuModel*) p);
229 	}
230 	
231 	/**
232 	 * Sets the direction in which the menu will be popped up, as
233 	 * well as changing the arrow's direction. The child will not
234 	 * be changed to an arrow if it was customized.
235 	 * If the menu when popped out would have collided with screen edges,
236 	 * we will do our best to keep it inside the screen and fully visible.
237 	 * If you pass GTK_ARROW_NONE for a direction, the menu will behave
238 	 * as if you passed GTK_ARROW_DOWN (although you won't see any arrows).
239 	 * Params:
240 	 * direction = a GtkArrowType
241 	 * Since 3.6
242 	 */
243 	public void setMenuDirection(GtkArrowType direction)
244 	{
245 		// void gtk_menu_button_set_direction (GtkMenuButton *menu_button,  GtkArrowType direction);
246 		gtk_menu_button_set_direction(gtkMenuButton, direction);
247 	}
248 	
249 	/**
250 	 * Returns the direction the menu will be pointing at when popped up.
251 	 * Returns: a GtkArrowType value. Since 3.6
252 	 */
253 	public GtkArrowType getMenuDirection()
254 	{
255 		// GtkArrowType gtk_menu_button_get_direction (GtkMenuButton *menu_button);
256 		return gtk_menu_button_get_direction(gtkMenuButton);
257 	}
258 	
259 	/**
260 	 * Sets the GtkWidget to use to line the menu with when popped up. Note that
261 	 * the align_widget must contain the GtkMenuButton itself.
262 	 * Setting it to NULL means that the popup menu will be aligned with the
263 	 * button itself.
264 	 * Params:
265 	 * alignWidget = a GtkWidget. [allow-none]
266 	 * Since 3.6
267 	 */
268 	public void setAlignWidget(Widget alignWidget)
269 	{
270 		// void gtk_menu_button_set_align_widget (GtkMenuButton *menu_button,  GtkWidget *align_widget);
271 		gtk_menu_button_set_align_widget(gtkMenuButton, (alignWidget is null) ? null : alignWidget.getWidgetStruct());
272 	}
273 	
274 	/**
275 	 * Returns the parent GtkWidget to use to line up with menu.
276 	 * Returns: a GtkWidget value or NULL. [transfer none] Since 3.6
277 	 */
278 	public Widget getAlignWidget()
279 	{
280 		// GtkWidget * gtk_menu_button_get_align_widget (GtkMenuButton *menu_button);
281 		auto p = gtk_menu_button_get_align_widget(gtkMenuButton);
282 		
283 		if(p is null)
284 		{
285 			return null;
286 		}
287 		
288 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
289 	}
290 }