-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from Shallowmallow/BetterNumberStepper
For Better number stepper that supports Floats ( SpinCtrlDouble)
- Loading branch information
Showing
3 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package hx.widgets; | ||
|
||
import cpp.Pointer; | ||
import wx.widgets.SpinCtrlDouble in WxSpinCtrlDouble; | ||
import wx.widgets.WxString; | ||
|
||
class SpinCtrlDouble extends Control { | ||
public function new(parent:Window, text:String = null, style:Int = 0, id:Int = -1) { | ||
if (_ref == null) { | ||
_ref = WxSpinCtrlDouble.createInstance().reinterpret(); | ||
var str = WxString.fromUTF8(text); | ||
spinCtrlDoubleRef.ptr.create(Window.toRaw(parent), id, str, Point.defaultPosition.ref, Size.defaultSize.ref, style); | ||
} | ||
|
||
super(parent, id); | ||
} | ||
|
||
public var value(get, set):Float; | ||
private function get_value():Float { | ||
return spinCtrlDoubleRef.ref.getValue(); | ||
} | ||
private function set_value(value:Float):Float { | ||
spinCtrlDoubleRef.ref.setValue(value); | ||
return value; | ||
} | ||
|
||
public var min(get, set):Float; | ||
private function get_min():Float { | ||
return spinCtrlDoubleRef.ptr.getMin(); | ||
} | ||
private function set_min(value:Float):Float { | ||
spinCtrlDoubleRef.ptr.setRange(value, max); | ||
return value; | ||
} | ||
|
||
public var max(get, set):Float; | ||
private function get_max():Float { | ||
return spinCtrlDoubleRef.ptr.getMax(); | ||
} | ||
private function set_max(value:Float):Float { | ||
spinCtrlDoubleRef.ptr.setRange(min, value); | ||
return value; | ||
} | ||
|
||
public var digits(get, set):Int; | ||
private function get_digits():Int { | ||
return spinCtrlDoubleRef.ptr.getDigits(); | ||
} | ||
private function set_digits(value:Int):Int { | ||
spinCtrlDoubleRef.ptr.setDigits(value); | ||
return value; | ||
} | ||
|
||
public var increment(get, set):Float; | ||
private function get_increment():Float { | ||
return spinCtrlDoubleRef.ptr.getIncrement(); | ||
} | ||
private function set_increment(value:Float):Float { | ||
spinCtrlDoubleRef.ptr.setIncrement(value); | ||
return value; | ||
} | ||
|
||
|
||
////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// Helpers | ||
////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
private var spinCtrlDoubleRef(get, null):Pointer<WxSpinCtrlDouble>; | ||
private function get_spinCtrlDoubleRef():Pointer<WxSpinCtrlDouble> { | ||
return _ref.reinterpret(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package wx.widgets; | ||
|
||
import cpp.Pointer; | ||
import cpp.RawPointer; | ||
|
||
@:include("wx/spinctrl.h") | ||
@:unreflective | ||
@:native("wxSpinCtrlDouble") | ||
@:structAccess | ||
extern class SpinCtrlDouble extends Control { | ||
|
||
////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// creation functions | ||
////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
@:native("new wxSpinCtrlDouble") private static function _new():RawPointer<SpinCtrlDouble>; | ||
public static inline function createInstance():Pointer<SpinCtrlDouble> { | ||
return Pointer.fromRaw(_new()); | ||
} | ||
|
||
@:native("Create") @:overload(function(parent:RawPointer<Window>, id:Int, value:WxString, point:Point, size:Size, style:Int):Bool {}) | ||
@:native("Create") override public function create(parent:RawPointer<Window>, id:Int, point:Point, size:Size, style:Int):Bool; | ||
|
||
@:native("GetValue") public function getValue():Float; | ||
@:native("SetValue") public function setValue(value:Float):Void; | ||
@:native("GetMin") public function getMin():Float; | ||
@:native("GetMax") public function getMax():Float; | ||
@:native("SetRange") public function setRange(value:Float, value:Float):Void; | ||
@:native("GetDigits") public function getDigits():Int; | ||
@:native("SetDigits") public function setDigits(value:Int):Void; | ||
@:native("GetIncrement") public function getIncrement():Float; | ||
@:native("SetIncrement") public function setIncrement(value:Float):Void; | ||
} |