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.Adjustment; 26 27 private import glib.ConstructionException; 28 private import gobject.ObjectG; 29 private import gobject.Signals; 30 private import gtk.c.functions; 31 public import gtk.c.types; 32 private import std.algorithm; 33 34 35 /** 36 * `GtkAdjustment` is a model for a numeric value. 37 * 38 * The `GtkAdjustment has an associated lower and upper bound. 39 * It also contains step and page increments, and a page size. 40 * 41 * Adjustments are used within several GTK widgets, including 42 * [class@Gtk.SpinButton], [class@Gtk.Viewport], [class@Gtk.Scrollbar] 43 * and [class@Gtk.Scale]. 44 * 45 * The `GtkAdjustment` object does not update the value itself. Instead 46 * it is left up to the owner of the `GtkAdjustment` to control the value. 47 */ 48 public class Adjustment : ObjectG 49 { 50 /** the main Gtk struct */ 51 protected GtkAdjustment* gtkAdjustment; 52 53 /** Get the main Gtk struct */ 54 public GtkAdjustment* getAdjustmentStruct(bool transferOwnership = false) 55 { 56 if (transferOwnership) 57 ownedRef = false; 58 return gtkAdjustment; 59 } 60 61 /** the main Gtk struct as a void* */ 62 protected override void* getStruct() 63 { 64 return cast(void*)gtkAdjustment; 65 } 66 67 /** 68 * Sets our main struct and passes it to the parent class. 69 */ 70 public this (GtkAdjustment* gtkAdjustment, bool ownedRef = false) 71 { 72 this.gtkAdjustment = gtkAdjustment; 73 super(cast(GObject*)gtkAdjustment, ownedRef); 74 } 75 76 77 /** */ 78 public static GType getType() 79 { 80 return gtk_adjustment_get_type(); 81 } 82 83 /** 84 * Creates a new `GtkAdjustment`. 85 * 86 * Params: 87 * value = the initial value 88 * lower = the minimum value 89 * upper = the maximum value 90 * stepIncrement = the step increment 91 * pageIncrement = the page increment 92 * pageSize = the page size 93 * 94 * Returns: a new `GtkAdjustment` 95 * 96 * Throws: ConstructionException GTK+ fails to create the object. 97 */ 98 public this(double value, double lower, double upper, double stepIncrement, double pageIncrement, double pageSize) 99 { 100 auto __p = gtk_adjustment_new(value, lower, upper, stepIncrement, pageIncrement, pageSize); 101 102 if(__p is null) 103 { 104 throw new ConstructionException("null returned by new"); 105 } 106 107 this(cast(GtkAdjustment*) __p); 108 } 109 110 /** 111 * Updates the value property to ensure that the range 112 * between @lower and @upper is in the current page. 113 * 114 * The current page goes from `value` to `value` + `page-size`. 115 * If the range is larger than the page size, then only the 116 * start of it will be in the current page. 117 * 118 * A [signal@Gtk.Adjustment::value-changed] signal will be emitted 119 * if the value is changed. 120 * 121 * Params: 122 * lower = the lower value 123 * upper = the upper value 124 */ 125 public void clampPage(double lower, double upper) 126 { 127 gtk_adjustment_clamp_page(gtkAdjustment, lower, upper); 128 } 129 130 /** 131 * Sets all properties of the adjustment at once. 132 * 133 * Use this function to avoid multiple emissions of the 134 * [signal@Gtk.Adjustment::changed] signal. See 135 * [method@Gtk.Adjustment.set_lower] for an alternative 136 * way of compressing multiple emissions of 137 * [signal@Gtk.Adjustment::changed] into one. 138 * 139 * Params: 140 * value = the new value 141 * lower = the new minimum value 142 * upper = the new maximum value 143 * stepIncrement = the new step increment 144 * pageIncrement = the new page increment 145 * pageSize = the new page size 146 */ 147 public void configure(double value, double lower, double upper, double stepIncrement, double pageIncrement, double pageSize) 148 { 149 gtk_adjustment_configure(gtkAdjustment, value, lower, upper, stepIncrement, pageIncrement, pageSize); 150 } 151 152 /** 153 * Retrieves the minimum value of the adjustment. 154 * 155 * Returns: The current minimum value of the adjustment 156 */ 157 public double getLower() 158 { 159 return gtk_adjustment_get_lower(gtkAdjustment); 160 } 161 162 /** 163 * Gets the smaller of step increment and page increment. 164 * 165 * Returns: the minimum increment of @adjustment 166 */ 167 public double getMinimumIncrement() 168 { 169 return gtk_adjustment_get_minimum_increment(gtkAdjustment); 170 } 171 172 /** 173 * Retrieves the page increment of the adjustment. 174 * 175 * Returns: The current page increment of the adjustment 176 */ 177 public double getPageIncrement() 178 { 179 return gtk_adjustment_get_page_increment(gtkAdjustment); 180 } 181 182 /** 183 * Retrieves the page size of the adjustment. 184 * 185 * Returns: The current page size of the adjustment 186 */ 187 public double getPageSize() 188 { 189 return gtk_adjustment_get_page_size(gtkAdjustment); 190 } 191 192 /** 193 * Retrieves the step increment of the adjustment. 194 * 195 * Returns: The current step increment of the adjustment. 196 */ 197 public double getStepIncrement() 198 { 199 return gtk_adjustment_get_step_increment(gtkAdjustment); 200 } 201 202 /** 203 * Retrieves the maximum value of the adjustment. 204 * 205 * Returns: The current maximum value of the adjustment 206 */ 207 public double getUpper() 208 { 209 return gtk_adjustment_get_upper(gtkAdjustment); 210 } 211 212 /** 213 * Gets the current value of the adjustment. 214 * 215 * Returns: The current value of the adjustment 216 */ 217 public double getValue() 218 { 219 return gtk_adjustment_get_value(gtkAdjustment); 220 } 221 222 /** 223 * Sets the minimum value of the adjustment. 224 * 225 * When setting multiple adjustment properties via their individual 226 * setters, multiple [signal@Gtk.Adjustment::changed] signals will 227 * be emitted. However, since the emission of the 228 * [signal@Gtk.Adjustment::changed] signal is tied to the emission 229 * of the ::notify signals of the changed properties, it’s possible 230 * to compress the [signal@Gtk.Adjustment::changed] signals into one 231 * by calling g_object_freeze_notify() and g_object_thaw_notify() 232 * around the calls to the individual setters. 233 * 234 * Alternatively, using a single g_object_set() for all the properties 235 * to change, or using [method@Gtk.Adjustment.configure] has the same effect. 236 * 237 * Params: 238 * lower = the new minimum value 239 */ 240 public void setLower(double lower) 241 { 242 gtk_adjustment_set_lower(gtkAdjustment, lower); 243 } 244 245 /** 246 * Sets the page increment of the adjustment. 247 * 248 * See [method@Gtk.Adjustment.set_lower] about how to compress 249 * multiple emissions of the [signal@Gtk.Adjustment::changed] 250 * signal when setting multiple adjustment properties. 251 * 252 * Params: 253 * pageIncrement = the new page increment 254 */ 255 public void setPageIncrement(double pageIncrement) 256 { 257 gtk_adjustment_set_page_increment(gtkAdjustment, pageIncrement); 258 } 259 260 /** 261 * Sets the page size of the adjustment. 262 * 263 * See [method@Gtk.Adjustment.set_lower] about how to compress 264 * multiple emissions of the [signal@Gtk.Adjustment::changed] 265 * signal when setting multiple adjustment properties. 266 * 267 * Params: 268 * pageSize = the new page size 269 */ 270 public void setPageSize(double pageSize) 271 { 272 gtk_adjustment_set_page_size(gtkAdjustment, pageSize); 273 } 274 275 /** 276 * Sets the step increment of the adjustment. 277 * 278 * See [method@Gtk.Adjustment.set_lower] about how to compress 279 * multiple emissions of the [signal@Gtk.Adjustment::changed] 280 * signal when setting multiple adjustment properties. 281 * 282 * Params: 283 * stepIncrement = the new step increment 284 */ 285 public void setStepIncrement(double stepIncrement) 286 { 287 gtk_adjustment_set_step_increment(gtkAdjustment, stepIncrement); 288 } 289 290 /** 291 * Sets the maximum value of the adjustment. 292 * 293 * Note that values will be restricted by `upper - page-size` 294 * if the page-size property is nonzero. 295 * 296 * See [method@Gtk.Adjustment.set_lower] about how to compress 297 * multiple emissions of the [signal@Gtk.Adjustment::changed] 298 * signal when setting multiple adjustment properties. 299 * 300 * Params: 301 * upper = the new maximum value 302 */ 303 public void setUpper(double upper) 304 { 305 gtk_adjustment_set_upper(gtkAdjustment, upper); 306 } 307 308 /** 309 * Sets the `GtkAdjustment` value. 310 * 311 * The value is clamped to lie between [property@Gtk.Adjustment:lower] 312 * and [property@Gtk.Adjustment:upper]. 313 * 314 * Note that for adjustments which are used in a `GtkScrollbar`, 315 * the effective range of allowed values goes from 316 * [property@Gtk.Adjustment:lower] to 317 * [property@Gtk.Adjustment:upper] - [property@Gtk.Adjustment:page-size]. 318 * 319 * Params: 320 * value = the new value 321 */ 322 public void setValue(double value) 323 { 324 gtk_adjustment_set_value(gtkAdjustment, value); 325 } 326 327 /** 328 * Emitted when one or more of the `GtkAdjustment` properties have been 329 * changed. 330 * 331 * Note that the [property@Gtk.Adjustment:value] property is 332 * covered by the [signal@Gtk.Adjustment::value-changed] signal. 333 */ 334 gulong addOnChanged(void delegate(Adjustment) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 335 { 336 return Signals.connect(this, "changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 337 } 338 339 /** 340 * Emitted when the value has been changed. 341 */ 342 gulong addOnValueChanged(void delegate(Adjustment) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 343 { 344 return Signals.connect(this, "value-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 345 } 346 }