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