PageRenderTime 27ms CodeModel.GetById 13ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/lib/titanium/mobile/ui/Picker.hx

http://github.com/visup/haxe-titanium-api
Haxe | 167 lines | 38 code | 6 blank | 123 comment | 0 complexity | 3826db5985633f2a7630c2ce087aa409 MD5 | raw file
  1package titanium.mobile.ui;
  2import titanium.mobile.core.BaseView;
  3import titanium.mobile.core.Dispatcher;
  4import titanium.mobile.core.Point;
  5
  6/**
  7Picker class
  8
  9Documentation available at:
 10http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.Picker-object.html
 11
 12- namespace
 13
 14Titanium.UI.Picker
 15
 16- type
 17
 18object
 19
 20- subtype
 21
 22proxy
 23
 24- description
 25
 26A Picker is created by the method [Titanium.UI.createPicker](Titanium.UI.createPicker).  A Picker can be used to select one or more fixed values.
 27
 28- since
 29
 300.8
 31
 32- platforms
 33
 34android, iphone, ipad
 35
 36- properties
 37
 38columns[array]: array of column values
 39type[int]: the type constant for the picker. One of `Titanium.UI.PICKER_TYPE_PLAIN` (default), `Titanium.UI.PICKER_TYPE_DATE_AND_TIME`, `Titanium.UI.PICKER_TYPE_DATE`, `Titanium.UI.PICKER_TYPE_TIME` or `Titanium.UI.PICKER_TYPE_COUNT_DOWN_TIMER`.
 40selectionIndicator[boolean]: for basic picker, boolean value to indicate whether the visual selection style is shown. On the iPhone, this is a blue selected bar.
 41minDate[date]: the minimum Date/Time for value for date pickers
 42maxDate[date]:the maximum Date/Time for value for date pickers
 43value[date]: the Date/Time value for date pickers
 44countDownDuration[double]: the duration value in milliseconds for count down timer pickers
 45locale[string]: the locale used for displaying Date/Time pickers values
 46minuteInterval[int]: property to set the interval displayed by the minutes wheel (for example, 15 minutes). The interval value must be evenly divided into 60; if it is not, the default value is used. The default and minimum values are 1; the maximum value is 30.
 47
 48
 49- methods
 50
 51add: add an array of rows, a single row or a column to the picker
 52reloadColumn: causes the picker to reload the values from the new column
 53getSelectedRow: get the selected row object for column
 54setSelectedRow: set the column's row to the selected state
 55
 56- method : getSelectedRow, object
 57
 58index[int]: for the column index, return the row object or nil if not found
 59
 60- method : setSelectedRow
 61
 62column[int]: the column index
 63row[int]: the row index
 64animated[boolean]: boolean to indicate if the selection should be animated (default)
 65
 66- method : add
 67
 68data[array,object]: add an array of rows, a single row or a column to the picker
 69
 70- method : reloadColumn
 71
 72column[object]: new column to load
 73
 74- events
 75
 76change: fired when the value of a picker row and/or column changes
 77
 78- event : change
 79
 80selectedValue: (plain picker only) the array of selected values, one element per column in the picker.
 81value: (date/time pickers only) the selected date/time value.
 82rowIndex: the selected row index
 83columnIndex: the selected column index
 84column: the column object
 85row: the row object
 86
 87- example : Basic Single Column Picker
 88
 89In this basic picker example, we create a one column picker with 4 rows. 
 90
 91~~~
 92var picker = Titanium.UI.createPicker();
 93var data = [];
 94data[0]=Titanium.UI.createPickerRow({title:'Bananas'});
 95data[1]=Titanium.UI.createPickerRow({title:'Strawberries'});
 96data[2]=Titanium.UI.createPickerRow({title:'Mangos'});
 97data[3]=Titanium.UI.createPickerRow({title:'Grapes'});
 98picker.add(data);
 99~~~
100
101- example : Custom View for Row
102
103In this example, we use a custom label for each row in a column.
104
105~~~
106var picker = Titanium.UI.createPicker();
107var row = Titanium.UI.createPickerRow();
108var label = Titanium.UI.createLabel({
109	text:text,
110	font:{fontSize:24,fontWeight:'bold'},
111	color:text,
112	width:'auto',
113	height:'auto'
114});
115row.add(label);
116picker.add(row);
117~~~
118
119
120- notes
121
122Android does not support the DateTime or Count Down Timer picker type.
123
124**/
125
126typedef PickerChangeEvent = 
127{ > Event,
128	column:Dynamic,
129	columnIndex:Int,
130	row:Dynamic,
131	rowIndex:Int,
132	selectedValue:Array<Dynamic>,
133	value:Date
134}
135
136@:native("Titanium.UI.Picker")
137extern class Picker extends BaseView
138{
139	// static constructor
140	public inline static function create(?params:Dynamic):Picker
141		return titanium.mobile.UI.createPicker(params)
142		
143	// events
144	public static inline var CHANGE_EVENT = "change";
145	
146	// properties
147	public var columns:Array<Dynamic>;
148	public var countDownDuration:Float;
149	public var locale:String;
150	public var minDate:Date;
151	public var maxDate:Date;
152	public var minuteInterval:Int;
153	public var selectionIndicator:Bool;
154	public var type:Int;
155	public var value:Date;
156	#if androidos
157	public var format24:Bool;
158	public var useSpinner:Bool;
159	public var visibleItems:Int;
160	#end
161	
162	// methods
163	override function add(data:Dynamic):Void;
164	public function setSelectedRow(col:Int, row:Int, animated:Bool):Void;
165	public function getSelectedRow(colIndex:Int):Dynamic;
166	public function reloadColumn(column:Dynamic):Void;
167}