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.ButtonBox;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gtk.Box;
30 private import gtk.Button;
31 private import gtk.HButtonBox;
32 private import gtk.VButtonBox;
33 private import gtk.Widget;
34 private import gtk.c.functions;
35 public  import gtk.c.types;
36 public  import gtkc.gtktypes;
37 
38 
39 /** */
40 public class ButtonBox : Box
41 {
42 	/** the main Gtk struct */
43 	protected GtkButtonBox* gtkButtonBox;
44 
45 	/** Get the main Gtk struct */
46 	public GtkButtonBox* getButtonBoxStruct(bool transferOwnership = false)
47 	{
48 		if (transferOwnership)
49 			ownedRef = false;
50 		return gtkButtonBox;
51 	}
52 
53 	/** the main Gtk struct as a void* */
54 	protected override void* getStruct()
55 	{
56 		return cast(void*)gtkButtonBox;
57 	}
58 
59 	protected override void setStruct(GObject* obj)
60 	{
61 		gtkButtonBox = cast(GtkButtonBox*)obj;
62 		super.setStruct(obj);
63 	}
64 
65 	/**
66 	 * Sets our main struct and passes it to the parent class.
67 	 */
68 	public this (GtkButtonBox* gtkButtonBox, bool ownedRef = false)
69 	{
70 		this.gtkButtonBox = gtkButtonBox;
71 		super(cast(GtkBox*)gtkButtonBox, ownedRef);
72 	}
73 
74 	/** */
75 	static ButtonBox createActionBox(
76 		void delegate(Button) onClicked,
77 		StockID[] stocks,
78 		string[] actions,
79 		bool vertical=false
80 	)
81 	{
82 		ButtonBox bBox;
83 		if ( vertical )
84 		{
85 			bBox = VButtonBox.createActionBox();
86 		}
87 		else
88 		{
89 			bBox = HButtonBox.createActionBox();
90 		}
91 
92 		Button button;
93 		for( int i=0 ; i<stocks.length && i<actions.length ; i++)
94 		{
95 			button =  new Button(stocks[i]);
96 			bBox.packEnd(button, false, false, 7);
97 			button.setActionName(actions[i]);
98 			button.addOnClicked(onClicked);
99 		}
100 		return bBox;
101 	}
102 
103 	/** */
104 	static ButtonBox createOkBox(void delegate(Button) onClicked)
105 	{
106 		static StockID[] stocks = [StockID.OK];
107 		string[] actions;
108 		actions ~= "action.ok";
109 		return createActionBox(onClicked, stocks, actions);
110 	}
111 
112 	/** */
113 	static ButtonBox createOkCancelBox(void delegate(Button) onClicked)
114 	{
115 		static StockID[] stocks = [StockID.OK, StockID.CANCEL];
116 		string[] actions;
117 		actions ~= "action.ok";
118 		actions ~= "action.cancel";
119 		return createActionBox(onClicked, stocks, actions);
120 	}
121 
122 
123 	/**
124 	 */
125 
126 	/** */
127 	public static GType getType()
128 	{
129 		return gtk_button_box_get_type();
130 	}
131 
132 	/**
133 	 * Creates a new #GtkButtonBox.
134 	 *
135 	 * Params:
136 	 *     orientation = the box's orientation.
137 	 *
138 	 * Returns: a new #GtkButtonBox.
139 	 *
140 	 * Since: 3.0
141 	 *
142 	 * Throws: ConstructionException GTK+ fails to create the object.
143 	 */
144 	public this(GtkOrientation orientation)
145 	{
146 		auto p = gtk_button_box_new(orientation);
147 
148 		if(p is null)
149 		{
150 			throw new ConstructionException("null returned by new");
151 		}
152 
153 		this(cast(GtkButtonBox*) p);
154 	}
155 
156 	/**
157 	 * Returns whether the child is exempted from homogenous
158 	 * sizing.
159 	 *
160 	 * Params:
161 	 *     child = a child of @widget
162 	 *
163 	 * Returns: %TRUE if the child is not subject to homogenous sizing
164 	 *
165 	 * Since: 3.2
166 	 */
167 	public bool getChildNonHomogeneous(Widget child)
168 	{
169 		return gtk_button_box_get_child_non_homogeneous(gtkButtonBox, (child is null) ? null : child.getWidgetStruct()) != 0;
170 	}
171 
172 	/**
173 	 * Returns whether @child should appear in a secondary group of children.
174 	 *
175 	 * Params:
176 	 *     child = a child of @widget
177 	 *
178 	 * Returns: whether @child should appear in a secondary group of children.
179 	 *
180 	 * Since: 2.4
181 	 */
182 	public bool getChildSecondary(Widget child)
183 	{
184 		return gtk_button_box_get_child_secondary(gtkButtonBox, (child is null) ? null : child.getWidgetStruct()) != 0;
185 	}
186 
187 	/**
188 	 * Retrieves the method being used to arrange the buttons in a button box.
189 	 *
190 	 * Returns: the method used to lay out buttons in @widget.
191 	 */
192 	public GtkButtonBoxStyle getLayout()
193 	{
194 		return gtk_button_box_get_layout(gtkButtonBox);
195 	}
196 
197 	/**
198 	 * Sets whether the child is exempted from homogeous sizing.
199 	 *
200 	 * Params:
201 	 *     child = a child of @widget
202 	 *     nonHomogeneous = the new value
203 	 *
204 	 * Since: 3.2
205 	 */
206 	public void setChildNonHomogeneous(Widget child, bool nonHomogeneous)
207 	{
208 		gtk_button_box_set_child_non_homogeneous(gtkButtonBox, (child is null) ? null : child.getWidgetStruct(), nonHomogeneous);
209 	}
210 
211 	/**
212 	 * Sets whether @child should appear in a secondary group of children.
213 	 * A typical use of a secondary child is the help button in a dialog.
214 	 *
215 	 * This group appears after the other children if the style
216 	 * is %GTK_BUTTONBOX_START, %GTK_BUTTONBOX_SPREAD or
217 	 * %GTK_BUTTONBOX_EDGE, and before the other children if the style
218 	 * is %GTK_BUTTONBOX_END. For horizontal button boxes, the definition
219 	 * of before/after depends on direction of the widget (see
220 	 * gtk_widget_set_direction()). If the style is %GTK_BUTTONBOX_START
221 	 * or %GTK_BUTTONBOX_END, then the secondary children are aligned at
222 	 * the other end of the button box from the main children. For the
223 	 * other styles, they appear immediately next to the main children.
224 	 *
225 	 * Params:
226 	 *     child = a child of @widget
227 	 *     isSecondary = if %TRUE, the @child appears in a secondary group of the
228 	 *         button box.
229 	 */
230 	public void setChildSecondary(Widget child, bool isSecondary)
231 	{
232 		gtk_button_box_set_child_secondary(gtkButtonBox, (child is null) ? null : child.getWidgetStruct(), isSecondary);
233 	}
234 
235 	/**
236 	 * Changes the way buttons are arranged in their container.
237 	 *
238 	 * Params:
239 	 *     layoutStyle = the new layout style
240 	 */
241 	public void setLayout(GtkButtonBoxStyle layoutStyle)
242 	{
243 		gtk_button_box_set_layout(gtkButtonBox, layoutStyle);
244 	}
245 }