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