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.MenuBar;
26 
27 private import gio.MenuModel;
28 private import glib.ConstructionException;
29 private import gobject.ObjectG;
30 private import gtk.Menu;
31 private import gtk.MenuItem;
32 private import gtk.MenuShell;
33 private import gtk.Widget;
34 private import gtkc.gtk;
35 public  import gtkc.gtktypes;
36 
37 
38 /**
39  * The #GtkMenuBar is a subclass of #GtkMenuShell which contains one or
40  * more #GtkMenuItems. The result is a standard menu bar which can hold
41  * many menu items.
42  */
43 public class MenuBar : MenuShell
44 {
45 	/** the main Gtk struct */
46 	protected GtkMenuBar* gtkMenuBar;
47 
48 	/** Get the main Gtk struct */
49 	public GtkMenuBar* getMenuBarStruct()
50 	{
51 		return gtkMenuBar;
52 	}
53 
54 	/** the main Gtk struct as a void* */
55 	protected override void* getStruct()
56 	{
57 		return cast(void*)gtkMenuBar;
58 	}
59 
60 	protected override void setStruct(GObject* obj)
61 	{
62 		gtkMenuBar = cast(GtkMenuBar*)obj;
63 		super.setStruct(obj);
64 	}
65 
66 	/**
67 	 * Sets our main struct and passes it to the parent class.
68 	 */
69 	public this (GtkMenuBar* gtkMenuBar, bool ownedRef = false)
70 	{
71 		this.gtkMenuBar = gtkMenuBar;
72 		super(cast(GtkMenuShell*)gtkMenuBar, ownedRef);
73 	}
74 
75 	/** */
76 	Menu append(string label, bool rightJustify=false)
77 	{
78 		MenuItem item = new MenuItem(label);
79 		super.append(item);
80 		item.setRightJustified(rightJustify);
81 		Menu menu= new Menu();
82 		item.setSubmenu(menu);
83 		return menu;
84 	}
85 	
86 	/** */
87 	public override void append(MenuItem item)
88 	{
89 		super.append(item);
90 	}
91 
92 	/**
93 	 */
94 
95 	public static GType getType()
96 	{
97 		return gtk_menu_bar_get_type();
98 	}
99 
100 	/**
101 	 * Creates a new #GtkMenuBar
102 	 *
103 	 * Return: the new menu bar, as a #GtkWidget
104 	 *
105 	 * Throws: ConstructionException GTK+ fails to create the object.
106 	 */
107 	public this()
108 	{
109 		auto p = gtk_menu_bar_new();
110 		
111 		if(p is null)
112 		{
113 			throw new ConstructionException("null returned by new");
114 		}
115 		
116 		this(cast(GtkMenuBar*) p);
117 	}
118 
119 	/**
120 	 * Creates a new #GtkMenuBar and populates it with menu items
121 	 * and submenus according to @model.
122 	 *
123 	 * The created menu items are connected to actions found in the
124 	 * #GtkApplicationWindow to which the menu bar belongs - typically
125 	 * by means of being contained within the #GtkApplicationWindows
126 	 * widget hierarchy.
127 	 *
128 	 * Params:
129 	 *     model = a #GMenuModel
130 	 *
131 	 * Return: a new #GtkMenuBar
132 	 *
133 	 * Since: 3.4
134 	 *
135 	 * Throws: ConstructionException GTK+ fails to create the object.
136 	 */
137 	public this(MenuModel model)
138 	{
139 		auto p = gtk_menu_bar_new_from_model((model is null) ? null : model.getMenuModelStruct());
140 		
141 		if(p is null)
142 		{
143 			throw new ConstructionException("null returned by new_from_model");
144 		}
145 		
146 		this(cast(GtkMenuBar*) p);
147 	}
148 
149 	/**
150 	 * Retrieves the current child pack direction of the menubar.
151 	 * See gtk_menu_bar_set_child_pack_direction().
152 	 *
153 	 * Return: the child pack direction
154 	 *
155 	 * Since: 2.8
156 	 */
157 	public GtkPackDirection getChildPackDirection()
158 	{
159 		return gtk_menu_bar_get_child_pack_direction(gtkMenuBar);
160 	}
161 
162 	/**
163 	 * Retrieves the current pack direction of the menubar.
164 	 * See gtk_menu_bar_set_pack_direction().
165 	 *
166 	 * Return: the pack direction
167 	 *
168 	 * Since: 2.8
169 	 */
170 	public GtkPackDirection getPackDirection()
171 	{
172 		return gtk_menu_bar_get_pack_direction(gtkMenuBar);
173 	}
174 
175 	/**
176 	 * Sets how widgets should be packed inside the children of a menubar.
177 	 *
178 	 * Params:
179 	 *     childPackDir = a new #GtkPackDirection
180 	 *
181 	 * Since: 2.8
182 	 */
183 	public void setChildPackDirection(GtkPackDirection childPackDir)
184 	{
185 		gtk_menu_bar_set_child_pack_direction(gtkMenuBar, childPackDir);
186 	}
187 
188 	/**
189 	 * Sets how items should be packed inside a menubar.
190 	 *
191 	 * Params:
192 	 *     packDir = a new #GtkPackDirection
193 	 *
194 	 * Since: 2.8
195 	 */
196 	public void setPackDirection(GtkPackDirection packDir)
197 	{
198 		gtk_menu_bar_set_pack_direction(gtkMenuBar, packDir);
199 	}
200 }