alternative to assert
[gtkD.git] / gtkD / src / gtk / ProgressBar.d
blob931ec6802015c03fb4943e7d7d3bb1a66cc3195e
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkProgressBar.html
26 * outPack = gtk
27 * outFile = ProgressBar
28 * strct = GtkProgressBar
29 * realStrct=
30 * ctorStrct=
31 * clss = ProgressBar
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_progress_bar_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * imports:
45 * - glib.Str
46 * - gtk.Adjustment
47 * structWrap:
48 * - GtkAdjustment* -> Adjustment
49 * module aliases:
50 * local aliases:
53 module gtk.ProgressBar;
55 version(noAssert)
57 version(Tango)
59 import tango.io.Stdout; // use the tango loging?
63 private import gtkc.gtktypes;
65 private import gtkc.gtk;
68 private import glib.Str;
69 private import gtk.Adjustment;
74 /**
75 * Description
76 * The GtkProgressBar is typically used to display the progress of a long
77 * running operation. It provides a visual clue that processing
78 * is underway. The GtkProgressBar can be used in two different
79 * modes: percentage mode and activity mode.
80 * When an application can determine how much work needs to take place
81 * (e.g. read a fixed number of bytes from a file) and can monitor its
82 * progress, it can use the GtkProgressBar in percentage mode and the user
83 * sees a growing bar indicating the percentage of the work that has
84 * been completed. In this mode, the application is required to call
85 * gtk_progress_bar_set_fraction() periodically to update the progress bar.
86 * When an application has no accurate way of knowing the amount of work
87 * to do, it can use the GtkProgressBar in activity mode, which shows activity
88 * by a block moving back and forth within the progress area. In this mode,
89 * the application is required to call gtk_progress_bar_pulse() perodically
90 * to update the progress bar.
91 * There is quite a bit of flexibility provided to control the appearance
92 * of the GtkProgressBar. Functions are provided to control the
93 * orientation of the bar, optional text can be displayed along with
94 * the bar, and the step size used in activity mode can be set.
95 * Note
96 * The GtkProgressBar/GtkProgress API in GTK 1.2 was bloated, needlessly complex
97 * and hard to use properly. Therefore GtkProgress has been deprecated
98 * completely and the GtkProgressBar API has been reduced to the following 10
99 * functions: gtk_progress_bar_new(), gtk_progress_bar_pulse(),
100 * gtk_progress_bar_set_text(), gtk_progress_bar_set_fraction(),
101 * gtk_progress_bar_set_pulse_step(), gtk_progress_bar_set_orientation(),
102 * gtk_progress_bar_get_text(), gtk_progress_bar_get_fraction(),
103 * gtk_progress_bar_get_pulse_step(), gtk_progress_bar_get_orientation().
104 * These have been grouped at the beginning of this section, followed by
105 * a large chunk of deprecated 1.2 compatibility functions.
107 private import gtk.Progress;
108 public class ProgressBar : Progress
111 /** the main Gtk struct */
112 protected GtkProgressBar* gtkProgressBar;
115 public GtkProgressBar* getProgressBarStruct()
117 return gtkProgressBar;
121 /** the main Gtk struct as a void* */
122 protected void* getStruct()
124 return cast(void*)gtkProgressBar;
128 * Sets our main struct and passes it to the parent class
130 public this (GtkProgressBar* gtkProgressBar)
132 version(noAssert)
134 if ( gtkProgressBar is null )
136 int zero = 0;
137 version(Tango)
139 Stdout("struct gtkProgressBar is null on constructor").newline;
141 else
143 printf("struct gtkProgressBar is null on constructor");
145 zero = zero / zero;
148 else
150 assert(gtkProgressBar !is null, "struct gtkProgressBar is null on constructor");
152 super(cast(GtkProgress*)gtkProgressBar);
153 this.gtkProgressBar = gtkProgressBar;
161 * Creates a new GtkProgressBar.
162 * Returns:
163 * a GtkProgressBar.
165 public this ()
167 // GtkWidget* gtk_progress_bar_new (void);
168 this(cast(GtkProgressBar*)gtk_progress_bar_new() );
172 * Indicates that some progress is made, but you don't know how much.
173 * Causes the progress bar to enter "activity mode," where a block
174 * bounces back and forth. Each call to gtk_progress_bar_pulse()
175 * causes the block to move by a little bit (the amount of movement
176 * per pulse is determined by gtk_progress_bar_set_pulse_step()).
177 * pbar:
178 * a GtkProgressBar
180 public void pulse()
182 // void gtk_progress_bar_pulse (GtkProgressBar *pbar);
183 gtk_progress_bar_pulse(gtkProgressBar);
187 * Causes the given text to appear superimposed on the progress bar.
188 * pbar:
189 * a GtkProgressBar
190 * text:
191 * a UTF-8 string, or NULL
193 public void setText(char[] text)
195 // void gtk_progress_bar_set_text (GtkProgressBar *pbar, const gchar *text);
196 gtk_progress_bar_set_text(gtkProgressBar, Str.toStringz(text));
200 * Causes the progress bar to "fill in" the given fraction
201 * of the bar. The fraction should be between 0.0 and 1.0,
202 * inclusive.
203 * pbar:
204 * a GtkProgressBar
205 * fraction:
206 * fraction of the task that's been completed
208 public void setFraction(double fraction)
210 // void gtk_progress_bar_set_fraction (GtkProgressBar *pbar, gdouble fraction);
211 gtk_progress_bar_set_fraction(gtkProgressBar, fraction);
215 * Sets the fraction of total progress bar length to move the
216 * bouncing block for each call to gtk_progress_bar_pulse().
217 * pbar:
218 * a GtkProgressBar
219 * fraction:
220 * fraction between 0.0 and 1.0
222 public void setPulseStep(double fraction)
224 // void gtk_progress_bar_set_pulse_step (GtkProgressBar *pbar, gdouble fraction);
225 gtk_progress_bar_set_pulse_step(gtkProgressBar, fraction);
229 * Causes the progress bar to switch to a different orientation
230 * (left-to-right, right-to-left, top-to-bottom, or bottom-to-top).
231 * pbar:
232 * a GtkProgressBar
233 * orientation:
234 * orientation of the progress bar
236 public void setOrientation(GtkProgressBarOrientation orientation)
238 // void gtk_progress_bar_set_orientation (GtkProgressBar *pbar, GtkProgressBarOrientation orientation);
239 gtk_progress_bar_set_orientation(gtkProgressBar, orientation);
243 * Sets the mode used to ellipsize (add an ellipsis: "...") the text
244 * if there is not enough space to render the entire string.
245 * pbar:
246 * a GtkProgressBar
247 * mode:
248 * a PangoEllipsizeMode
249 * Since 2.6
251 public void setEllipsize(PangoEllipsizeMode mode)
253 // void gtk_progress_bar_set_ellipsize (GtkProgressBar *pbar, PangoEllipsizeMode mode);
254 gtk_progress_bar_set_ellipsize(gtkProgressBar, mode);
259 * Retrieves the text displayed superimposed on the progress bar,
260 * if any, otherwise NULL. The return value is a reference
261 * to the text, not a copy of it, so will become invalid
262 * if you change the text in the progress bar.
263 * pbar:
264 * a GtkProgressBar
265 * Returns:
266 * text, or NULL; this string is owned by the widget
267 * and should not be modified or freed.
269 public char[] getText()
271 // const gchar* gtk_progress_bar_get_text (GtkProgressBar *pbar);
272 return Str.toString(gtk_progress_bar_get_text(gtkProgressBar) );
276 * Returns the current fraction of the task that's been completed.
277 * pbar:
278 * a GtkProgressBar
279 * Returns:
280 * a fraction from 0.0 to 1.0
282 public double getFraction()
284 // gdouble gtk_progress_bar_get_fraction (GtkProgressBar *pbar);
285 return gtk_progress_bar_get_fraction(gtkProgressBar);
289 * Retrieves the pulse step set with gtk_progress_bar_set_pulse_step()
290 * pbar:
291 * a GtkProgressBar
292 * Returns:
293 * a fraction from 0.0 to 1.0
295 public double getPulseStep()
297 // gdouble gtk_progress_bar_get_pulse_step (GtkProgressBar *pbar);
298 return gtk_progress_bar_get_pulse_step(gtkProgressBar);
302 * Retrieves the current progress bar orientation.
303 * pbar:
304 * a GtkProgressBar
305 * Returns:
306 * orientation of the progress bar
308 public GtkProgressBarOrientation getOrientation()
310 // GtkProgressBarOrientation gtk_progress_bar_get_orientation (GtkProgressBar *pbar);
311 return gtk_progress_bar_get_orientation(gtkProgressBar);
315 * Returns the ellipsizing position of the progressbar.
316 * See gtk_progress_bar_set_ellipsize().
317 * pbar:
318 * a GtkProgressBar
319 * Returns:
320 * PangoEllipsizeMode
321 * Since 2.6
323 public PangoEllipsizeMode getEllipsize()
325 // PangoEllipsizeMode gtk_progress_bar_get_ellipsize (GtkProgressBar *pbar);
326 return gtk_progress_bar_get_ellipsize(gtkProgressBar);
330 * Warning
331 * gtk_progress_bar_new_with_adjustment is deprecated and should not be used in newly-written code.
332 * Creates a new GtkProgressBar with an associated GtkAdjustment.
333 * adjustment:
334 * a GtkAdjustment.
335 * Returns:
336 * a GtkProgressBar.
338 public this (Adjustment adjustment)
340 // GtkWidget* gtk_progress_bar_new_with_adjustment (GtkAdjustment *adjustment);
341 this(cast(GtkProgressBar*)gtk_progress_bar_new_with_adjustment((adjustment is null) ? null : adjustment.getAdjustmentStruct()) );
345 * Warning
346 * gtk_progress_bar_set_bar_style is deprecated and should not be used in newly-written code.
347 * Sets the style of the GtkProgressBar. The default style is
348 * GTK_PROGRESS_CONTINUOUS.
349 * pbar:
350 * a GtkProgressBar.
351 * style:
352 * a GtkProgressBarStyle value indicating the desired style.
354 public void setBarStyle(GtkProgressBarStyle style)
356 // void gtk_progress_bar_set_bar_style (GtkProgressBar *pbar, GtkProgressBarStyle style);
357 gtk_progress_bar_set_bar_style(gtkProgressBar, style);
362 * Warning
363 * gtk_progress_bar_set_discrete_blocks is deprecated and should not be used in newly-written code.
364 * Sets the number of blocks that the progress bar is divided into
365 * when the style is GTK_PROGRESS_DISCRETE.
366 * pbar:
367 * a GtkProgressBar.
368 * blocks:
369 * number of individual blocks making up the bar.
371 public void setDiscreteBlocks(uint blocks)
373 // void gtk_progress_bar_set_discrete_blocks (GtkProgressBar *pbar, guint blocks);
374 gtk_progress_bar_set_discrete_blocks(gtkProgressBar, blocks);
378 * Warning
379 * gtk_progress_bar_set_activity_step is deprecated and should not be used in newly-written code.
380 * Sets the step value used when the progress bar is in activity
381 * mode. The step is the amount by which the progress is incremented
382 * each iteration.
383 * pbar:
384 * a GtkProgressBar.
385 * step:
386 * the amount which the progress is incremented in activity
387 * mode.
389 public void setActivityStep(uint step)
391 // void gtk_progress_bar_set_activity_step (GtkProgressBar *pbar, guint step);
392 gtk_progress_bar_set_activity_step(gtkProgressBar, step);
396 * Warning
397 * gtk_progress_bar_set_activity_blocks is deprecated and should not be used in newly-written code.
398 * Sets the number of blocks used when the progress bar is in activity
399 * mode. Larger numbers make the visible block smaller.
400 * pbar:
401 * a GtkProgressBar.
402 * blocks:
403 * number of blocks which can fit within the progress bar area.
405 public void setActivityBlocks(uint blocks)
407 // void gtk_progress_bar_set_activity_blocks (GtkProgressBar *pbar, guint blocks);
408 gtk_progress_bar_set_activity_blocks(gtkProgressBar, blocks);
412 * Warning
413 * gtk_progress_bar_update is deprecated and should not be used in newly-written code.
414 * This function is deprecated. Please use gtk_progress_set_value() or
415 * gtk_progress_set_percentage() instead.
416 * pbar:
417 * a GtkProgressBar.
418 * percentage:
419 * the new percent complete value.
420 * Property Details
421 * The "activity-blocks" property
422 * "activity-blocks" guint : Read / Write
423 * The number of blocks which can fit in the progress bar area in activity mode (Deprecated).
424 * Allowed values: >= 2
425 * Default value: 5
427 public void update(double percentage)
429 // void gtk_progress_bar_update (GtkProgressBar *pbar, gdouble percentage);
430 gtk_progress_bar_update(gtkProgressBar, percentage);