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.NumericSorter;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gtk.Expression;
30 private import gtk.Sorter;
31 private import gtk.c.functions;
32 public  import gtk.c.types;
33 
34 
35 /**
36  * `GtkNumericSorter` is a `GtkSorter` that compares numbers.
37  * 
38  * To obtain the numbers to compare, this sorter evaluates a
39  * [class@Gtk.Expression].
40  */
41 public class NumericSorter : Sorter
42 {
43 	/** the main Gtk struct */
44 	protected GtkNumericSorter* gtkNumericSorter;
45 
46 	/** Get the main Gtk struct */
47 	public GtkNumericSorter* getNumericSorterStruct(bool transferOwnership = false)
48 	{
49 		if (transferOwnership)
50 			ownedRef = false;
51 		return gtkNumericSorter;
52 	}
53 
54 	/** the main Gtk struct as a void* */
55 	protected override void* getStruct()
56 	{
57 		return cast(void*)gtkNumericSorter;
58 	}
59 
60 	/**
61 	 * Sets our main struct and passes it to the parent class.
62 	 */
63 	public this (GtkNumericSorter* gtkNumericSorter, bool ownedRef = false)
64 	{
65 		this.gtkNumericSorter = gtkNumericSorter;
66 		super(cast(GtkSorter*)gtkNumericSorter, ownedRef);
67 	}
68 
69 
70 	/** */
71 	public static GType getType()
72 	{
73 		return gtk_numeric_sorter_get_type();
74 	}
75 
76 	/**
77 	 * Creates a new numeric sorter using the given @expression.
78 	 *
79 	 * Smaller numbers will be sorted first. You can call
80 	 * [method@Gtk.NumericSorter.set_sort_order] to change this.
81 	 *
82 	 * Params:
83 	 *     expression = The expression to evaluate
84 	 *
85 	 * Returns: a new `GtkNumericSorter`
86 	 *
87 	 * Throws: ConstructionException GTK+ fails to create the object.
88 	 */
89 	public this(Expression expression)
90 	{
91 		auto __p = gtk_numeric_sorter_new((expression is null) ? null : expression.getExpressionStruct(true));
92 
93 		if(__p is null)
94 		{
95 			throw new ConstructionException("null returned by new");
96 		}
97 
98 		this(cast(GtkNumericSorter*) __p, true);
99 	}
100 
101 	/**
102 	 * Gets the expression that is evaluated to obtain numbers from items.
103 	 *
104 	 * Returns: a `GtkExpression`, or %NULL
105 	 */
106 	public Expression getExpression()
107 	{
108 		auto __p = gtk_numeric_sorter_get_expression(gtkNumericSorter);
109 
110 		if(__p is null)
111 		{
112 			return null;
113 		}
114 
115 		return ObjectG.getDObject!(Expression)(cast(GtkExpression*) __p);
116 	}
117 
118 	/**
119 	 * Gets whether this sorter will sort smaller numbers first.
120 	 *
121 	 * Returns: the order of the numbers
122 	 */
123 	public GtkSortType getSortOrder()
124 	{
125 		return gtk_numeric_sorter_get_sort_order(gtkNumericSorter);
126 	}
127 
128 	/**
129 	 * Sets the expression that is evaluated to obtain numbers from items.
130 	 *
131 	 * Unless an expression is set on @self, the sorter will always
132 	 * compare items as invalid.
133 	 *
134 	 * The expression must have a return type that can be compared
135 	 * numerically, such as %G_TYPE_INT or %G_TYPE_DOUBLE.
136 	 *
137 	 * Params:
138 	 *     expression = a `GtkExpression`, or %NULL
139 	 */
140 	public void setExpression(Expression expression)
141 	{
142 		gtk_numeric_sorter_set_expression(gtkNumericSorter, (expression is null) ? null : expression.getExpressionStruct());
143 	}
144 
145 	/**
146 	 * Sets whether to sort smaller numbers before larger ones.
147 	 *
148 	 * Params:
149 	 *     sortOrder = whether to sort smaller numbers first
150 	 */
151 	public void setSortOrder(GtkSortType sortOrder)
152 	{
153 		gtk_numeric_sorter_set_sort_order(gtkNumericSorter, sortOrder);
154 	}
155 }