1 /** DGui project file. 2 3 Copyright: Trogu Antonio Davide 2011-2013 4 5 License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0). 6 7 Authors: Trogu Antonio Davide 8 */ 9 module dgui.progressbar; 10 11 import dgui.core.controls.subclassedcontrol; 12 13 class ProgressBar: SubclassedControl 14 { 15 private uint _minRange = 0; 16 private uint _maxRange = 100; 17 private uint _step = 10; 18 private uint _value = 0; 19 20 @property public uint minRange() 21 { 22 return this._minRange; 23 } 24 25 @property public void minRange(uint mr) 26 { 27 this._minRange = mr; 28 29 if(this.created) 30 { 31 this.sendMessage(PBM_SETRANGE32, this._minRange, this._maxRange); 32 } 33 } 34 35 @property public uint maxRange() 36 { 37 return this._maxRange; 38 } 39 40 @property public void maxRange(uint mr) 41 { 42 this._maxRange = mr; 43 44 if(this.created) 45 { 46 this.sendMessage(PBM_SETRANGE32, this._minRange, this._maxRange); 47 } 48 } 49 50 @property public uint step() 51 { 52 return this._minRange; 53 } 54 55 @property public void step(uint s) 56 { 57 this._step = s; 58 59 if(this.created) 60 { 61 this.sendMessage(PBM_SETSTEP, this._step, 0); 62 } 63 } 64 65 @property public uint value() 66 { 67 if(this.created) 68 { 69 return this.sendMessage(PBM_GETPOS, 0, 0); 70 } 71 72 return this._value; 73 } 74 75 @property public void value(uint p) 76 { 77 this._value = p; 78 79 if(this.created) 80 { 81 this.sendMessage(PBM_SETPOS, p, 0); 82 } 83 } 84 85 public void increment() 86 { 87 if(this.created) 88 { 89 this.sendMessage(PBM_STEPIT, 0, 0); 90 } 91 else 92 { 93 throwException!(DGuiException)("Cannot increment the progress bar"); 94 } 95 } 96 97 protected override void createControlParams(ref CreateControlParams ccp) 98 { 99 ccp.superclassName = WC_PROGRESSBAR; 100 ccp.className = WC_DPROGRESSBAR; 101 102 assert(this._dock !is DockStyle.fill, "ProgressBar: Invalid Dock Style"); 103 104 if(this._dock is DockStyle.left || this._dock is DockStyle.right) 105 { 106 this.setStyle(PBS_VERTICAL, true); 107 } 108 109 super.createControlParams(ccp); 110 } 111 112 protected override void onHandleCreated(EventArgs e) 113 { 114 this.sendMessage(PBM_SETRANGE32, this._minRange, this._maxRange); 115 this.sendMessage(PBM_SETSTEP, this._step, 0); 116 this.sendMessage(PBM_SETPOS, this._value, 0); 117 118 super.onHandleCreated(e); 119 } 120 }