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 	/** */
96 	public static GType getType()
97 	{
98 		return gtk_menu_bar_get_type();
99 	}
100 
101 	/**
102 	 * Creates a new #GtkMenuBar
103 	 *
104 	 * Return: the new menu bar, as a #GtkWidget
105 	 *
106 	 * Throws: ConstructionException GTK+ fails to create the object.
107 	 */
108 	public this()
109 	{
110 		auto p = gtk_menu_bar_new();
111 		
112 		if(p is null)
113 		{
114 			throw new ConstructionException("null returned by new");
115 		}
116 		
117 		this(cast(GtkMenuBar*) p);
118 	}
119 
120 	/**
121 	 * Creates a new #GtkMenuBar and populates it with menu items
122 	 * and submenus according to @model.
123 	 *
124 	 * The created menu items are connected to actions found in the
125 	 * #GtkApplicationWindow to which the menu bar belongs - typically
126 	 * by means of being contained within the #GtkApplicationWindows
127 	 * widget hierarchy.
128 	 *
129 	 * Params:
130 	 *     model = a #GMenuModel
131 	 *
132 	 * Return: a new #GtkMenuBar
133 	 *
134 	 * Since: 3.4
135 	 *
136 	 * Throws: ConstructionException GTK+ fails to create the object.
137 	 */
138 	public this(MenuModel model)
139 	{
140 		auto p = gtk_menu_bar_new_from_model((model is null) ? null : model.getMenuModelStruct());
141 		
142 		if(p is null)
143 		{
144 			throw new ConstructionException("null returned by new_from_model");
145 		}
146 		
147 		this(cast(GtkMenuBar*) p);
148 	}
149 
150 	/**
151 	 * Retrieves the current child pack direction of the menubar.
152 	 * See gtk_menu_bar_set_child_pack_direction().
153 	 *
154 	 * Return: the child pack direction
155 	 *
156 	 * Since: 2.8
157 	 */
158 	public GtkPackDirection getChildPackDirection()
159 	{
160 		return gtk_menu_bar_get_child_pack_direction(gtkMenuBar);
161 	}
162 
163 	/**
164 	 * Retrieves the current pack direction of the menubar.
165 	 * See gtk_menu_bar_set_pack_direction().
166 	 *
167 	 * Return: the pack direction
168 	 *
169 	 * Since: 2.8
170 	 */
171 	public GtkPackDirection getPackDirection()
172 	{
173 		return gtk_menu_bar_get_pack_direction(gtkMenuBar);
174 	}
175 
176 	/**
177 	 * Sets how widgets should be packed inside the children of a menubar.
178 	 *
179 	 * Params:
180 	 *     childPackDir = a new #GtkPackDirection
181 	 *
182 	 * Since: 2.8
183 	 */
184 	public void setChildPackDirection(GtkPackDirection childPackDir)
185 	{
186 		gtk_menu_bar_set_child_pack_direction(gtkMenuBar, childPackDir);
187 	}
188 
189 	/**
190 	 * Sets how items should be packed inside a menubar.
191 	 *
192 	 * Params:
193 	 *     packDir = a new #GtkPackDirection
194 	 *
195 	 * Since: 2.8
196 	 */
197 	public void setPackDirection(GtkPackDirection packDir)
198 	{
199 		gtk_menu_bar_set_pack_direction(gtkMenuBar, packDir);
200 	}
201 }