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