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.ProgressBar;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gtk.OrientableIF;
31 private import gtk.OrientableT;
32 private import gtk.Widget;
33 private import gtkc.gtk;
34 public  import gtkc.gtktypes;
35 
36 
37 /**
38  * The #GtkProgressBar is typically used to display the progress of a long
39  * running operation.  It provides a visual clue that processing
40  * is underway.  The #GtkProgressBar can be used in two different
41  * modes: percentage mode and activity mode.
42  * 
43  * When an application can determine how much work needs to take place
44  * (e.g. read a fixed number of bytes from a file) and can monitor its
45  * progress, it can use the #GtkProgressBar in percentage mode and the user
46  * sees a growing bar indicating the percentage of the work that has
47  * been completed.  In this mode, the application is required to call
48  * gtk_progress_bar_set_fraction() periodically to update the progress bar.
49  * 
50  * When an application has no accurate way of knowing the amount of work
51  * to do, it can use the #GtkProgressBar in activity mode, which shows
52  * activity by a block moving back and forth within the progress area. In
53  * this mode, the application is required to call gtk_progress_bar_pulse()
54  * periodically to update the progress bar.
55  * 
56  * There is quite a bit of flexibility provided to control the appearance
57  * of the #GtkProgressBar.  Functions are provided to control the
58  * orientation of the bar, optional text can be displayed along with
59  * the bar, and the step size used in activity mode can be set.
60  */
61 public class ProgressBar : Widget, OrientableIF
62 {
63 	/** the main Gtk struct */
64 	protected GtkProgressBar* gtkProgressBar;
65 
66 	/** Get the main Gtk struct */
67 	public GtkProgressBar* getProgressBarStruct()
68 	{
69 		return gtkProgressBar;
70 	}
71 
72 	/** the main Gtk struct as a void* */
73 	protected override void* getStruct()
74 	{
75 		return cast(void*)gtkProgressBar;
76 	}
77 
78 	protected override void setStruct(GObject* obj)
79 	{
80 		gtkProgressBar = cast(GtkProgressBar*)obj;
81 		super.setStruct(obj);
82 	}
83 
84 	/**
85 	 * Sets our main struct and passes it to the parent class.
86 	 */
87 	public this (GtkProgressBar* gtkProgressBar, bool ownedRef = false)
88 	{
89 		this.gtkProgressBar = gtkProgressBar;
90 		super(cast(GtkWidget*)gtkProgressBar, ownedRef);
91 	}
92 
93 	// add the Orientable capabilities
94 	mixin OrientableT!(GtkProgressBar);
95 
96 	/**
97 	 */
98 
99 	public static GType getType()
100 	{
101 		return gtk_progress_bar_get_type();
102 	}
103 
104 	/**
105 	 * Creates a new #GtkProgressBar.
106 	 *
107 	 * Return: a #GtkProgressBar.
108 	 *
109 	 * Throws: ConstructionException GTK+ fails to create the object.
110 	 */
111 	public this()
112 	{
113 		auto p = gtk_progress_bar_new();
114 		
115 		if(p is null)
116 		{
117 			throw new ConstructionException("null returned by new");
118 		}
119 		
120 		this(cast(GtkProgressBar*) p);
121 	}
122 
123 	/**
124 	 * Returns the ellipsizing position of the progress bar.
125 	 * See gtk_progress_bar_set_ellipsize().
126 	 *
127 	 * Return: #PangoEllipsizeMode
128 	 *
129 	 * Since: 2.6
130 	 */
131 	public PangoEllipsizeMode getEllipsize()
132 	{
133 		return gtk_progress_bar_get_ellipsize(gtkProgressBar);
134 	}
135 
136 	/**
137 	 * Returns the current fraction of the task that’s been completed.
138 	 *
139 	 * Return: a fraction from 0.0 to 1.0
140 	 */
141 	public double getFraction()
142 	{
143 		return gtk_progress_bar_get_fraction(gtkProgressBar);
144 	}
145 
146 	/**
147 	 * Gets the value set by gtk_progress_bar_set_inverted().
148 	 *
149 	 * Return: %TRUE if the progress bar is inverted
150 	 */
151 	public bool getInverted()
152 	{
153 		return gtk_progress_bar_get_inverted(gtkProgressBar) != 0;
154 	}
155 
156 	/**
157 	 * Retrieves the pulse step set with gtk_progress_bar_set_pulse_step().
158 	 *
159 	 * Return: a fraction from 0.0 to 1.0
160 	 */
161 	public double getPulseStep()
162 	{
163 		return gtk_progress_bar_get_pulse_step(gtkProgressBar);
164 	}
165 
166 	/**
167 	 * Gets the value of the #GtkProgressBar:show-text property.
168 	 * See gtk_progress_bar_set_show_text().
169 	 *
170 	 * Return: %TRUE if text is shown in the progress bar
171 	 *
172 	 * Since: 3.0
173 	 */
174 	public bool getShowText()
175 	{
176 		return gtk_progress_bar_get_show_text(gtkProgressBar) != 0;
177 	}
178 
179 	/**
180 	 * Retrieves the text displayed superimposed on the progress bar,
181 	 * if any, otherwise %NULL. The return value is a reference
182 	 * to the text, not a copy of it, so will become invalid
183 	 * if you change the text in the progress bar.
184 	 *
185 	 * Return: text, or %NULL; this string is owned by the widget
186 	 *     and should not be modified or freed.
187 	 */
188 	public string getText()
189 	{
190 		return Str.toString(gtk_progress_bar_get_text(gtkProgressBar));
191 	}
192 
193 	/**
194 	 * Indicates that some progress has been made, but you don’t know how much.
195 	 * Causes the progress bar to enter “activity mode,” where a block
196 	 * bounces back and forth. Each call to gtk_progress_bar_pulse()
197 	 * causes the block to move by a little bit (the amount of movement
198 	 * per pulse is determined by gtk_progress_bar_set_pulse_step()).
199 	 */
200 	public void pulse()
201 	{
202 		gtk_progress_bar_pulse(gtkProgressBar);
203 	}
204 
205 	/**
206 	 * Sets the mode used to ellipsize (add an ellipsis: "...") the text
207 	 * if there is not enough space to render the entire string.
208 	 *
209 	 * Params:
210 	 *     mode = a #PangoEllipsizeMode
211 	 *
212 	 * Since: 2.6
213 	 */
214 	public void setEllipsize(PangoEllipsizeMode mode)
215 	{
216 		gtk_progress_bar_set_ellipsize(gtkProgressBar, mode);
217 	}
218 
219 	/**
220 	 * Causes the progress bar to “fill in” the given fraction
221 	 * of the bar. The fraction should be between 0.0 and 1.0,
222 	 * inclusive.
223 	 *
224 	 * Params:
225 	 *     fraction = fraction of the task that’s been completed
226 	 */
227 	public void setFraction(double fraction)
228 	{
229 		gtk_progress_bar_set_fraction(gtkProgressBar, fraction);
230 	}
231 
232 	/**
233 	 * Progress bars normally grow from top to bottom or left to right.
234 	 * Inverted progress bars grow in the opposite direction.
235 	 *
236 	 * Params:
237 	 *     inverted = %TRUE to invert the progress bar
238 	 */
239 	public void setInverted(bool inverted)
240 	{
241 		gtk_progress_bar_set_inverted(gtkProgressBar, inverted);
242 	}
243 
244 	/**
245 	 * Sets the fraction of total progress bar length to move the
246 	 * bouncing block for each call to gtk_progress_bar_pulse().
247 	 *
248 	 * Params:
249 	 *     fraction = fraction between 0.0 and 1.0
250 	 */
251 	public void setPulseStep(double fraction)
252 	{
253 		gtk_progress_bar_set_pulse_step(gtkProgressBar, fraction);
254 	}
255 
256 	/**
257 	 * Sets whether the progress bar will show text superimposed
258 	 * over the bar. The shown text is either the value of
259 	 * the #GtkProgressBar:text property or, if that is %NULL,
260 	 * the #GtkProgressBar:fraction value, as a percentage.
261 	 *
262 	 * To make a progress bar that is styled and sized suitably for containing
263 	 * text (even if the actual text is blank), set #GtkProgressBar:show-text to
264 	 * %TRUE and #GtkProgressBar:text to the empty string (not %NULL).
265 	 *
266 	 * Params:
267 	 *     showText = whether to show superimposed text
268 	 *
269 	 * Since: 3.0
270 	 */
271 	public void setShowText(bool showText)
272 	{
273 		gtk_progress_bar_set_show_text(gtkProgressBar, showText);
274 	}
275 
276 	/**
277 	 * Causes the given @text to appear superimposed on the progress bar.
278 	 *
279 	 * If @text is %NULL and #GtkProgressBar:show-text is %TRUE, the current
280 	 * value of #GtkProgressBar:fraction will be displayed as a percentage.
281 	 *
282 	 * If @text is non-%NULL and #GtkProgressBar:show-text is %TRUE, the text will
283 	 * be displayed. In this case, it will not display the progress percentage.
284 	 * If @text is the empty string, the progress bar will still be styled and sized
285 	 * suitably for containing text, as long as #GtkProgressBar:show-text is %TRUE.
286 	 *
287 	 * Params:
288 	 *     text = a UTF-8 string, or %NULL
289 	 */
290 	public void setText(string text)
291 	{
292 		gtk_progress_bar_set_text(gtkProgressBar, Str.toStringz(text));
293 	}
294 }