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