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