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.ColumnViewColumn;
26 
27 private import gio.MenuModel;
28 private import glib.ConstructionException;
29 private import glib.Str;
30 private import glib.c.functions;
31 private import gobject.ObjectG;
32 private import gtk.ColumnView;
33 private import gtk.ListItemFactory;
34 private import gtk.Sorter;
35 private import gtk.c.functions;
36 public  import gtk.c.types;
37 
38 
39 /**
40  * `GtkColumnViewColumn` represents the columns being added to `GtkColumnView`.
41  * 
42  * The main ingredient for a `GtkColumnViewColumn` is the `GtkListItemFactory`
43  * that tells the columnview how to create cells for this column from items in
44  * the model.
45  * 
46  * Columns have a title, and can optionally have a header menu set
47  * with [method@Gtk.ColumnViewColumn.set_header_menu].
48  * 
49  * A sorter can be associated with a column using
50  * [method@Gtk.ColumnViewColumn.set_sorter], to let users influence sorting
51  * by clicking on the column header.
52  */
53 public class ColumnViewColumn : ObjectG
54 {
55 	/** the main Gtk struct */
56 	protected GtkColumnViewColumn* gtkColumnViewColumn;
57 
58 	/** Get the main Gtk struct */
59 	public GtkColumnViewColumn* getColumnViewColumnStruct(bool transferOwnership = false)
60 	{
61 		if (transferOwnership)
62 			ownedRef = false;
63 		return gtkColumnViewColumn;
64 	}
65 
66 	/** the main Gtk struct as a void* */
67 	protected override void* getStruct()
68 	{
69 		return cast(void*)gtkColumnViewColumn;
70 	}
71 
72 	/**
73 	 * Sets our main struct and passes it to the parent class.
74 	 */
75 	public this (GtkColumnViewColumn* gtkColumnViewColumn, bool ownedRef = false)
76 	{
77 		this.gtkColumnViewColumn = gtkColumnViewColumn;
78 		super(cast(GObject*)gtkColumnViewColumn, ownedRef);
79 	}
80 
81 
82 	/** */
83 	public static GType getType()
84 	{
85 		return gtk_column_view_column_get_type();
86 	}
87 
88 	/**
89 	 * Creates a new `GtkColumnViewColumn` that uses the given @factory for
90 	 * mapping items to widgets.
91 	 *
92 	 * You most likely want to call [method@Gtk.ColumnView.append_column] next.
93 	 *
94 	 * The function takes ownership of the argument, so you can write code like:
95 	 *
96 	 * ```c
97 	 * column = gtk_column_view_column_new (_("Name"),
98 	 * gtk_builder_list_item_factory_new_from_resource ("/name.ui"));
99 	 * ```
100 	 *
101 	 * Params:
102 	 *     title = Title to use for this column
103 	 *     factory = The factory to populate items with
104 	 *
105 	 * Returns: a new `GtkColumnViewColumn` using the given @factory
106 	 *
107 	 * Throws: ConstructionException GTK+ fails to create the object.
108 	 */
109 	public this(string title, ListItemFactory factory)
110 	{
111 		auto __p = gtk_column_view_column_new(Str.toStringz(title), (factory is null) ? null : factory.getListItemFactoryStruct());
112 
113 		if(__p is null)
114 		{
115 			throw new ConstructionException("null returned by new");
116 		}
117 
118 		this(cast(GtkColumnViewColumn*) __p, true);
119 	}
120 
121 	/**
122 	 * Gets the column view that's currently displaying this column.
123 	 *
124 	 * If @self has not been added to a column view yet, %NULL is returned.
125 	 *
126 	 * Returns: The column view displaying @self.
127 	 */
128 	public ColumnView getColumnView()
129 	{
130 		auto __p = gtk_column_view_column_get_column_view(gtkColumnViewColumn);
131 
132 		if(__p is null)
133 		{
134 			return null;
135 		}
136 
137 		return ObjectG.getDObject!(ColumnView)(cast(GtkColumnView*) __p);
138 	}
139 
140 	/**
141 	 * Returns whether this column should expand.
142 	 *
143 	 * Returns: %TRUE if this column expands
144 	 */
145 	public bool getExpand()
146 	{
147 		return gtk_column_view_column_get_expand(gtkColumnViewColumn) != 0;
148 	}
149 
150 	/**
151 	 * Gets the factory that's currently used to populate list items for
152 	 * this column.
153 	 *
154 	 * Returns: The factory in use
155 	 */
156 	public ListItemFactory getFactory()
157 	{
158 		auto __p = gtk_column_view_column_get_factory(gtkColumnViewColumn);
159 
160 		if(__p is null)
161 		{
162 			return null;
163 		}
164 
165 		return ObjectG.getDObject!(ListItemFactory)(cast(GtkListItemFactory*) __p);
166 	}
167 
168 	/**
169 	 * Gets the fixed width of the column.
170 	 *
171 	 * Returns: the fixed with of the column
172 	 */
173 	public int getFixedWidth()
174 	{
175 		return gtk_column_view_column_get_fixed_width(gtkColumnViewColumn);
176 	}
177 
178 	/**
179 	 * Gets the menu model that is used to create the context menu
180 	 * for the column header.
181 	 *
182 	 * Returns: the #GMenuModel, or %NULL
183 	 */
184 	public MenuModel getHeaderMenu()
185 	{
186 		auto __p = gtk_column_view_column_get_header_menu(gtkColumnViewColumn);
187 
188 		if(__p is null)
189 		{
190 			return null;
191 		}
192 
193 		return ObjectG.getDObject!(MenuModel)(cast(GMenuModel*) __p);
194 	}
195 
196 	/**
197 	 * Returns whether this column is resizable.
198 	 *
199 	 * Returns: %TRUE if this column is resizable
200 	 */
201 	public bool getResizable()
202 	{
203 		return gtk_column_view_column_get_resizable(gtkColumnViewColumn) != 0;
204 	}
205 
206 	/**
207 	 * Returns the sorter that is associated with the column.
208 	 *
209 	 * Returns: the `GtkSorter` of @self
210 	 */
211 	public Sorter getSorter()
212 	{
213 		auto __p = gtk_column_view_column_get_sorter(gtkColumnViewColumn);
214 
215 		if(__p is null)
216 		{
217 			return null;
218 		}
219 
220 		return ObjectG.getDObject!(Sorter)(cast(GtkSorter*) __p);
221 	}
222 
223 	/**
224 	 * Returns the title set with gtk_column_view_column_set_title().
225 	 *
226 	 * Returns: The column's title
227 	 */
228 	public string getTitle()
229 	{
230 		return Str.toString(gtk_column_view_column_get_title(gtkColumnViewColumn));
231 	}
232 
233 	/**
234 	 * Returns whether this column is visible.
235 	 *
236 	 * Returns: %TRUE if this column is visible
237 	 */
238 	public bool getVisible()
239 	{
240 		return gtk_column_view_column_get_visible(gtkColumnViewColumn) != 0;
241 	}
242 
243 	/**
244 	 * Sets the column to take available extra space.
245 	 *
246 	 * The extra space is shared equally amongst all columns that
247 	 * have the expand set to %TRUE.
248 	 *
249 	 * Params:
250 	 *     expand = %TRUE if this column should expand to fill available sace
251 	 */
252 	public void setExpand(bool expand)
253 	{
254 		gtk_column_view_column_set_expand(gtkColumnViewColumn, expand);
255 	}
256 
257 	/**
258 	 * Sets the `GtkListItemFactory` to use for populating list items for this
259 	 * column.
260 	 *
261 	 * Params:
262 	 *     factory = the factory to use or %NULL for none
263 	 */
264 	public void setFactory(ListItemFactory factory)
265 	{
266 		gtk_column_view_column_set_factory(gtkColumnViewColumn, (factory is null) ? null : factory.getListItemFactoryStruct());
267 	}
268 
269 	/**
270 	 * If @fixed_width is not -1, sets the fixed width of @column;
271 	 * otherwise unsets it.
272 	 *
273 	 * Setting a fixed width overrides the automatically calculated
274 	 * width. Interactive resizing also sets the “fixed-width” property.
275 	 *
276 	 * Params:
277 	 *     fixedWidth = the new fixed width, or -1
278 	 */
279 	public void setFixedWidth(int fixedWidth)
280 	{
281 		gtk_column_view_column_set_fixed_width(gtkColumnViewColumn, fixedWidth);
282 	}
283 
284 	/**
285 	 * Sets the menu model that is used to create the context menu
286 	 * for the column header.
287 	 *
288 	 * Params:
289 	 *     menu = a `GMenuModel`, or %NULL
290 	 */
291 	public void setHeaderMenu(MenuModel menu)
292 	{
293 		gtk_column_view_column_set_header_menu(gtkColumnViewColumn, (menu is null) ? null : menu.getMenuModelStruct());
294 	}
295 
296 	/**
297 	 * Sets whether this column should be resizable by dragging.
298 	 *
299 	 * Params:
300 	 *     resizable = whether this column should be resizable
301 	 */
302 	public void setResizable(bool resizable)
303 	{
304 		gtk_column_view_column_set_resizable(gtkColumnViewColumn, resizable);
305 	}
306 
307 	/**
308 	 * Associates a sorter with the column.
309 	 *
310 	 * If @sorter is %NULL, the column will not let users change
311 	 * the sorting by clicking on its header.
312 	 *
313 	 * This sorter can be made active by clicking on the column
314 	 * header, or by calling [method@Gtk.ColumnView.sort_by_column].
315 	 *
316 	 * See [method@Gtk.ColumnView.get_sorter] for the necessary steps
317 	 * for setting up customizable sorting for [class@Gtk.ColumnView].
318 	 *
319 	 * Params:
320 	 *     sorter = the `GtkSorter` to associate with @column
321 	 */
322 	public void setSorter(Sorter sorter)
323 	{
324 		gtk_column_view_column_set_sorter(gtkColumnViewColumn, (sorter is null) ? null : sorter.getSorterStruct());
325 	}
326 
327 	/**
328 	 * Sets the title of this column.
329 	 *
330 	 * The title is displayed in the header of a `GtkColumnView`
331 	 * for this column and is therefore user-facing text that should
332 	 * be translated.
333 	 *
334 	 * Params:
335 	 *     title = Title to use for this column
336 	 */
337 	public void setTitle(string title)
338 	{
339 		gtk_column_view_column_set_title(gtkColumnViewColumn, Str.toStringz(title));
340 	}
341 
342 	/**
343 	 * Sets whether this column should be visible in views.
344 	 *
345 	 * Params:
346 	 *     visible = whether this column should be visible
347 	 */
348 	public void setVisible(bool visible)
349 	{
350 		gtk_column_view_column_set_visible(gtkColumnViewColumn, visible);
351 	}
352 }