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 	/**
99 	 * Sets our main struct and passes it to the parent class.
100 	 */
101 	public this (GtkProgressBar* gtkProgressBar, bool ownedRef = false)
102 	{
103 		this.gtkProgressBar = gtkProgressBar;
104 		super(cast(GtkWidget*)gtkProgressBar, ownedRef);
105 	}
106 
107 	// add the Orientable capabilities
108 	mixin OrientableT!(GtkProgressBar);
109 
110 
111 	/** */
112 	public static GType getType()
113 	{
114 		return gtk_progress_bar_get_type();
115 	}
116 
117 	/**
118 	 * Creates a new #GtkProgressBar.
119 	 *
120 	 * Returns: a #GtkProgressBar.
121 	 *
122 	 * Throws: ConstructionException GTK+ fails to create the object.
123 	 */
124 	public this()
125 	{
126 		auto p = gtk_progress_bar_new();
127 
128 		if(p is null)
129 		{
130 			throw new ConstructionException("null returned by new");
131 		}
132 
133 		this(cast(GtkProgressBar*) p);
134 	}
135 
136 	/**
137 	 * Returns the ellipsizing position of the progress bar.
138 	 * See gtk_progress_bar_set_ellipsize().
139 	 *
140 	 * Returns: #PangoEllipsizeMode
141 	 *
142 	 * Since: 2.6
143 	 */
144 	public PangoEllipsizeMode getEllipsize()
145 	{
146 		return gtk_progress_bar_get_ellipsize(gtkProgressBar);
147 	}
148 
149 	/**
150 	 * Returns the current fraction of the task that’s been completed.
151 	 *
152 	 * Returns: a fraction from 0.0 to 1.0
153 	 */
154 	public double getFraction()
155 	{
156 		return gtk_progress_bar_get_fraction(gtkProgressBar);
157 	}
158 
159 	/**
160 	 * Gets the value set by gtk_progress_bar_set_inverted().
161 	 *
162 	 * Returns: %TRUE if the progress bar is inverted
163 	 */
164 	public bool getInverted()
165 	{
166 		return gtk_progress_bar_get_inverted(gtkProgressBar) != 0;
167 	}
168 
169 	/**
170 	 * Retrieves the pulse step set with gtk_progress_bar_set_pulse_step().
171 	 *
172 	 * Returns: a fraction from 0.0 to 1.0
173 	 */
174 	public double getPulseStep()
175 	{
176 		return gtk_progress_bar_get_pulse_step(gtkProgressBar);
177 	}
178 
179 	/**
180 	 * Gets the value of the #GtkProgressBar:show-text property.
181 	 * See gtk_progress_bar_set_show_text().
182 	 *
183 	 * Returns: %TRUE if text is shown in the progress bar
184 	 *
185 	 * Since: 3.0
186 	 */
187 	public bool getShowText()
188 	{
189 		return gtk_progress_bar_get_show_text(gtkProgressBar) != 0;
190 	}
191 
192 	/**
193 	 * Retrieves the text that is displayed with the progress bar,
194 	 * if any, otherwise %NULL. The return value is a reference
195 	 * to the text, not a copy of it, so will become invalid
196 	 * if you change the text in the progress bar.
197 	 *
198 	 * Returns: text, or %NULL; this string is owned by the widget
199 	 *     and should not be modified or freed.
200 	 */
201 	public string getText()
202 	{
203 		return Str.toString(gtk_progress_bar_get_text(gtkProgressBar));
204 	}
205 
206 	/**
207 	 * Indicates that some progress has been made, but you don’t know how much.
208 	 * Causes the progress bar to enter “activity mode,” where a block
209 	 * bounces back and forth. Each call to gtk_progress_bar_pulse()
210 	 * causes the block to move by a little bit (the amount of movement
211 	 * per pulse is determined by gtk_progress_bar_set_pulse_step()).
212 	 */
213 	public void pulse()
214 	{
215 		gtk_progress_bar_pulse(gtkProgressBar);
216 	}
217 
218 	/**
219 	 * Sets the mode used to ellipsize (add an ellipsis: "...") the
220 	 * text if there is not enough space to render the entire string.
221 	 *
222 	 * Params:
223 	 *     mode = a #PangoEllipsizeMode
224 	 *
225 	 * Since: 2.6
226 	 */
227 	public void setEllipsize(PangoEllipsizeMode mode)
228 	{
229 		gtk_progress_bar_set_ellipsize(gtkProgressBar, mode);
230 	}
231 
232 	/**
233 	 * Causes the progress bar to “fill in” the given fraction
234 	 * of the bar. The fraction should be between 0.0 and 1.0,
235 	 * inclusive.
236 	 *
237 	 * Params:
238 	 *     fraction = fraction of the task that’s been completed
239 	 */
240 	public void setFraction(double fraction)
241 	{
242 		gtk_progress_bar_set_fraction(gtkProgressBar, fraction);
243 	}
244 
245 	/**
246 	 * Progress bars normally grow from top to bottom or left to right.
247 	 * Inverted progress bars grow in the opposite direction.
248 	 *
249 	 * Params:
250 	 *     inverted = %TRUE to invert the progress bar
251 	 */
252 	public void setInverted(bool inverted)
253 	{
254 		gtk_progress_bar_set_inverted(gtkProgressBar, inverted);
255 	}
256 
257 	/**
258 	 * Sets the fraction of total progress bar length to move the
259 	 * bouncing block for each call to gtk_progress_bar_pulse().
260 	 *
261 	 * Params:
262 	 *     fraction = fraction between 0.0 and 1.0
263 	 */
264 	public void setPulseStep(double fraction)
265 	{
266 		gtk_progress_bar_set_pulse_step(gtkProgressBar, fraction);
267 	}
268 
269 	/**
270 	 * Sets whether the progress bar will show text next to the bar.
271 	 * The shown text is either the value of the #GtkProgressBar:text
272 	 * property or, if that is %NULL, the #GtkProgressBar:fraction value,
273 	 * as a percentage.
274 	 *
275 	 * To make a progress bar that is styled and sized suitably for containing
276 	 * text (even if the actual text is blank), set #GtkProgressBar:show-text to
277 	 * %TRUE and #GtkProgressBar:text to the empty string (not %NULL).
278 	 *
279 	 * Params:
280 	 *     showText = whether to show text
281 	 *
282 	 * Since: 3.0
283 	 */
284 	public void setShowText(bool showText)
285 	{
286 		gtk_progress_bar_set_show_text(gtkProgressBar, showText);
287 	}
288 
289 	/**
290 	 * Causes the given @text to appear next to the progress bar.
291 	 *
292 	 * If @text is %NULL and #GtkProgressBar:show-text is %TRUE, the current
293 	 * value of #GtkProgressBar:fraction will be displayed as a percentage.
294 	 *
295 	 * If @text is non-%NULL and #GtkProgressBar:show-text is %TRUE, the text
296 	 * will be displayed. In this case, it will not display the progress
297 	 * percentage. If @text is the empty string, the progress bar will still
298 	 * be styled and sized suitably for containing text, as long as
299 	 * #GtkProgressBar:show-text is %TRUE.
300 	 *
301 	 * Params:
302 	 *     text = a UTF-8 string, or %NULL
303 	 */
304 	public void setText(string text)
305 	{
306 		gtk_progress_bar_set_text(gtkProgressBar, Str.toStringz(text));
307 	}
308 }