-
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathDatePicker.hx
More file actions
2247 lines (1897 loc) · 75.7 KB
/
DatePicker.hx
File metadata and controls
2247 lines (1897 loc) · 75.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Feathers UI
Copyright 2026 Bowler Hat LLC. All Rights Reserved.
This program is free software. You can redistribute and/or modify it in
accordance with the terms of the accompanying license agreement.
*/
package feathers.controls;
import feathers.controls.dataRenderers.IDataRenderer;
import feathers.controls.dataRenderers.ItemRenderer;
import feathers.core.FeathersControl;
import feathers.core.IDateSelector;
import feathers.core.IFocusObject;
import feathers.core.ITextControl;
import feathers.core.IUIControl;
import feathers.core.IValidating;
import feathers.core.InvalidationFlag;
import feathers.data.DatePickerItemState;
import feathers.events.DatePickerEvent;
import feathers.events.FeathersEvent;
import feathers.events.TriggerEvent;
import feathers.layout.CalendarGridLayout;
import feathers.layout.HorizontalAlign;
import feathers.layout.Measurements;
import feathers.skins.IProgrammaticSkin;
import feathers.style.IVariantStyleObject;
import feathers.utils.AbstractDisplayObjectFactory;
import feathers.utils.AbstractDisplayObjectRecycler;
import feathers.utils.DateUtil;
import feathers.utils.DisplayObjectFactory;
import feathers.utils.DisplayObjectRecycler;
import haxe.ds.ObjectMap;
import openfl.display.DisplayObject;
import openfl.errors.ArgumentError;
import openfl.errors.IllegalOperationError;
import openfl.errors.RangeError;
import openfl.events.Event;
import openfl.events.KeyboardEvent;
import openfl.events.MouseEvent;
import openfl.events.TouchEvent;
import openfl.text.TextField;
import openfl.ui.Keyboard;
#if air
import openfl.ui.Multitouch;
#end
#if (openfl >= "9.2.0" && !neko)
import openfl.globalization.DateTimeFormatter;
import openfl.globalization.LocaleID;
#elseif flash
import flash.globalization.DateTimeFormatter;
import flash.globalization.LocaleID;
#end
#if (openfl >= "9.1.0")
import openfl.utils.ObjectPool;
#else
import openfl._internal.utils.ObjectPool;
#end
/**
Displays a calendar month view that allows the selection of a date. The
header displays the current month and year name, along with buttons to
change the currently displayed month and year. The buttons in the header may
be hidden, if desired.
The following example creates a date picker, sets the selected date, and
listens for when the selection changes:
```haxe
var datePicker = new DatePicker();
datePicker.selectedDate = new Date(2020, 1, 6);
datePicker.addEventListener(Event.CHANGE, (event:Event) -> {
var datePicker = cast(event.currentTarget, DatePicker);
trace("DatePicker changed: " + datePicker.selectedDate);
});
this.addChild(datePicker);
```
@event openfl.events.Event.CHANGE Dispatched when `DatePicker.selectedDate`
changes.
@event feathers.events.DatePickerEvent.ITEM_TRIGGER Dispatched when the user
taps or clicks an item renderer in the date picker. The pointer must remain
within the bounds of the item renderer on release, or the gesture will be
ignored.
@event feathers.events.DatePickerEvent.ITEM_DOUBLE_CLICK Dispatched when the
user double-clicks an item renderer in the date picker with a mouse. The item
renderer's `doubleClickEnabled` property must be set to true, and in some
cases the same property must be set on its children.
@see [Tutorial: How to use the DatePicker component](https://feathersui.com/learn/haxe-openfl/date-picker/)
@since 1.0.0
**/
@:event(openfl.events.Event.CHANGE)
@:event(feathers.events.DatePickerEvent.ITEM_TRIGGER)
@:event(feathers.events.DatePickerEvent.ITEM_DOUBLE_CLICK)
@:styleContext
class DatePicker extends FeathersControl implements IDateSelector implements IFocusObject {
#if ((!flash && openfl < "9.2.0") || neko)
private static final DEFAULT_MONTH_NAMES = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
];
private var DEFAULT_WEEKDAY_NAMES = ["S", "M", "T", "W", "T", "F", "S"];
private var DEFAULT_START_OF_WEEK = 0;
#end
private static final INVALIDATION_FLAG_MONTH_TITLE_VIEW_FACTORY = InvalidationFlag.CUSTOM("monthTitleViewFactory");
private static final INVALIDATION_FLAG_DECREMENT_MONTH_BUTTON_FACTORY = InvalidationFlag.CUSTOM("decrementMonthButtonFactory");
private static final INVALIDATION_FLAG_INCREMENT_MONTH_BUTTON_FACTORY = InvalidationFlag.CUSTOM("incrementMonthButtonFactory");
private static final INVALIDATION_FLAG_DECREMENT_YEAR_BUTTON_FACTORY = InvalidationFlag.CUSTOM("decrementYearButtonFactory");
private static final INVALIDATION_FLAG_INCREMENT_YEAR_BUTTON_FACTORY = InvalidationFlag.CUSTOM("incrementYearButtonFactory");
private static final INVALIDATION_FLAG_DATE_RENDERER_FACTORY = InvalidationFlag.CUSTOM("dateRendererFactory");
private static final INVALIDATION_FLAG_WEEKDAY_LABEL_FACTORY = InvalidationFlag.CUSTOM("weekdayLabelFactory");
private static final RESET_ITEM_STATE = new DatePickerItemState();
/**
The variant used to style the date picker's date renderers in a theme.
To override this default variant, set the
`DatePicker.customDateRendererVariant` property.
@see `DatePicker.customDateRendererVariant`
@see `feathers.style.IVariantStyleObject.variant`
@see [Feathers UI User Manual: Themes](https://feathersui.com/learn/haxe-openfl/themes/)
@since 1.0.0
**/
public static final CHILD_VARIANT_DATE_RENDERER = "datePicker_dateRenderer";
/**
The variant used to style the date picker's date renderers in a theme.
To override this default variant, set the
`DatePicker.customMutedDateRendererVariant` property.
@see `DatePicker.customMutedDateRendererVariant`
@see `feathers.style.IVariantStyleObject.variant`
@see [Feathers UI User Manual: Themes](https://feathersui.com/learn/haxe-openfl/themes/)
@since 1.0.0
**/
public static final CHILD_VARIANT_MUTED_DATE_RENDERER = "datePicker_mutedDateRenderer";
/**
The variant used to style the decrement month `Button` child component
in a theme.
To override this default variant, set the
`DatePicker.customDecrementMonthButtonVariant` property.
@see `DatePicker.customDecrementMonthButtonVariant`
@see `feathers.style.IVariantStyleObject.variant`
@see [Feathers UI User Manual: Themes](https://feathersui.com/learn/haxe-openfl/themes/)
@since 1.0.0
**/
public static final CHILD_VARIANT_DECREMENT_MONTH_BUTTON = "datePicker_decrementMonthButton";
/**
The variant used to style the increment month `Button` child component
in a theme.
To override this default variant, set the
`DatePicker.customIncrementMonthButtonVariant` property.
@see `DatePicker.customIncrementMonthButtonVariant`
@see `feathers.style.IVariantStyleObject.variant`
@see [Feathers UI User Manual: Themes](https://feathersui.com/learn/haxe-openfl/themes/)
@since 1.0.0
**/
public static final CHILD_VARIANT_INCREMENT_MONTH_BUTTON = "datePicker_incrementMonthButton";
/**
The variant used to style the decrement year `Button` child component
in a theme.
To override this default variant, set the
`DatePicker.customDecrementYearButtonVariant` property.
@see `DatePicker.customDecrementYearButtonVariant`
@see `feathers.style.IVariantStyleObject.variant`
@see [Feathers UI User Manual: Themes](https://feathersui.com/learn/haxe-openfl/themes/)
@since 1.0.0
**/
public static final CHILD_VARIANT_DECREMENT_YEAR_BUTTON = "datePicker_decrementYearButton";
/**
The variant used to style the increment year `Button` child component
in a theme.
To override this default variant, set the
`DatePicker.customIncrementYearButtonVariant` property.
@see `DatePicker.customIncrementYearButtonVariant`
@see `feathers.style.IVariantStyleObject.variant`
@see [Feathers UI User Manual: Themes](https://feathersui.com/learn/haxe-openfl/themes/)
@since 1.0.0
**/
public static final CHILD_VARIANT_INCREMENT_YEAR_BUTTON = "datePicker_incrementYearButton";
/**
The variant used to style the current month title child component
in a theme.
To override this default variant, set the
`DatePicker.customMonthTitleViewVariant` property.
@see `DatePicker.customMonthTitleViewVariant`
@see `feathers.style.IVariantStyleObject.variant`
@see [Feathers UI User Manual: Themes](https://feathersui.com/learn/haxe-openfl/themes/)
@since 1.0.0
**/
public static final CHILD_VARIANT_MONTH_TITLE_VIEW = "datePicker_monthTitleView";
/**
The variant used to style the `Label` child components that display the
names of weekdays.
To override this default variant, set the
`DatePicker.customWeekdayLabelVariant` property.
@see `DatePicker.customWeekdayLabelVariant`
@see `feathers.style.IVariantStyleObject.variant`
@see [Feathers UI User Manual: Themes](https://feathersui.com/learn/haxe-openfl/themes/)
@since 1.0.0
**/
public static final CHILD_VARIANT_WEEKDAY_LABEL = "datePicker_weekdayLabel";
private static final defaultDecrementMonthButtonFactory = DisplayObjectFactory.withClass(Button);
private static final defaultIncrementMonthButtonFactory = DisplayObjectFactory.withClass(Button);
private static final defaultDecrementYearButtonFactory = DisplayObjectFactory.withClass(Button);
private static final defaultIncrementYearButtonFactory = DisplayObjectFactory.withClass(Button);
private static final defaultMonthTitleViewFactory = DisplayObjectFactory.withClass(Label);
private static final defaultWeekdayLabelFactory = DisplayObjectFactory.withClass(Label);
private static function defaultUpdateDateRenderer(dateRenderer:DisplayObject, state:DatePickerItemState):Void {
if ((dateRenderer is ITextControl)) {
var textControl:ITextControl = cast dateRenderer;
textControl.text = Std.string(state.date.getDate());
}
}
private static function defaultResetDateRenderer(dateRenderer:DisplayObject, state:DatePickerItemState):Void {
if ((dateRenderer is ITextControl)) {
var textControl:ITextControl = cast dateRenderer;
textControl.text = null;
}
}
/**
Creates a new `DatePicker` object.
@since 1.0.0
**/
public function new() {
initializeDatePickerTheme();
super();
this.addEventListener(KeyboardEvent.KEY_DOWN, datePicker_keyDownHandler);
}
private var dateContainer:LayoutGroup;
private var monthView:ITextControl;
private var decrementMonthButton:Button;
private var incrementMonthButton:Button;
private var decrementYearButton:Button;
private var incrementYearButton:Button;
private var monthTitleView:Label;
private var _dayNameLabels:Array<Label> = [];
private var dateRendererToItemState = new ObjectMap<DisplayObject, DatePickerItemState>();
private var _defaultStorage:DateRendererStorage = new DateRendererStorage(null, DisplayObjectRecycler.withClass(ItemRenderer));
private var _mutedStorage:DateRendererStorage = new DateRendererStorage(null, DisplayObjectRecycler.withClass(ItemRenderer));
private var decrementMonthButtonMeasurements:Measurements = new Measurements();
private var incrementMonthButtonMeasurements:Measurements = new Measurements();
private var decrementYearButtonMeasurements:Measurements = new Measurements();
private var incrementYearButtonMeasurements:Measurements = new Measurements();
private var monthTitleViewMeasurements:Measurements = new Measurements();
private var itemStatePool = new ObjectPool(() -> new DatePickerItemState());
private var _displayedFullYear:Int = Date.now().getFullYear();
/**
Along with the `displayedMonth`, sets the month that is currently
visible in the calendar. Defaults to the current year.
@see `DatePicker.displayedMonth`
@since 1.0.0
**/
@:bindable("scroll")
public var displayedFullYear(get, set):Int;
private function get_displayedFullYear():Int {
return this._displayedFullYear;
}
private function set_displayedFullYear(value:Int):Int {
if (this._displayedFullYear == value) {
return this._displayedFullYear;
}
this._displayedFullYear = value;
this.setInvalid(SELECTION);
FeathersEvent.dispatch(this, Event.SCROLL);
return this._displayedFullYear;
}
private var _displayedMonth:Int = Date.now().getMonth();
/**
Along with the `displayedFullYear`, sets the month that is currently
visible in the calendar. Defaults to the current month.
Months are indexed starting from `0`. So the index of January is `0`,
and the index of December is `11`.
@see `DatePicker.displayedFullYear`
@since 1.0.0
**/
@:bindable("scroll")
public var displayedMonth(get, set):Int;
private function get_displayedMonth():Int {
return this._displayedMonth;
}
private function set_displayedMonth(value:Int):Int {
if (value < 0 || value > 11) {
throw new RangeError("displayedMonth must be in the range 0-11");
}
if (this._displayedMonth == value) {
return this._displayedMonth;
}
this._displayedMonth = value;
this.setInvalid(SELECTION);
FeathersEvent.dispatch(this, Event.SCROLL);
return this._displayedMonth;
}
private var _selectable:Bool = true;
/**
@since 1.0.0
**/
public var selectable(get, set):Bool;
private function get_selectable():Bool {
return this._selectable;
}
private function set_selectable(value:Bool):Bool {
if (this._selectable == value) {
return this._selectable;
}
this._selectable = value;
if (!this._selectable && this._selectedDate != null) {
this.selectedDate = null;
}
this.setInvalid(SELECTION);
return this._selectable;
}
private var _ignoreSelectionChange:Bool = false;
private var _selectedDate:Date = null;
/**
The currently selected date.
@since 1.0.0
**/
@:inspectable
@:bindable("change")
public var selectedDate(get, set):Date;
private function get_selectedDate():Date {
return this._selectedDate;
}
private function set_selectedDate(value:Date):Date {
if (!this._selectable) {
value = null;
}
if (this._selectedDate == value) {
return this._selectedDate;
}
this._selectedDate = value;
this.setInvalid(SELECTION);
FeathersEvent.dispatch(this, Event.CHANGE);
return this._selectedDate;
}
private var _currentBackgroundSkin:DisplayObject = null;
private var _backgroundSkinMeasurements:Measurements = null;
/**
The default background skin to display behind the date picker's content.
The following example passes a bitmap for the date picker to use as a
background skin:
```haxe
datePicker.backgroundSkin = new Bitmap(bitmapData);
```
@default null
@see `DatePicker.disabledBackgroundSkin`
@since 1.0.0
**/
@:style
public var backgroundSkin:DisplayObject = null;
/**
A background skin to display behind the date picker's content when the
date picker is disabled.
The following example gives the date picker a disabled background skin:
```haxe
datePicker.disabledBackgroundSkin = new Bitmap(bitmapData);
datePicker.enabled = false;
```
@default null
@see `DatePicker.backgroundSkin`
@since 1.0.0
**/
@:style
public var disabledBackgroundSkin:DisplayObject = null;
private var _oldDecrementMonthButtonFactory:DisplayObjectFactory<Dynamic, Button>;
private var _decrementMonthButtonFactory:DisplayObjectFactory<Dynamic, Button>;
/**
Creates the decrement month button that is displayed as a sub-component.
The button must be of type `feathers.controls.Button`.
In the following example, a custom decrement month button factory is provided:
```haxe
datePicker.decrementMonthButtonFactory = () ->
{
return new Button();
};
```
@see `feathers.controls.Button`
@since 1.0.0
**/
public var decrementMonthButtonFactory(get, set):AbstractDisplayObjectFactory<Dynamic, Button>;
private function get_decrementMonthButtonFactory():AbstractDisplayObjectFactory<Dynamic, Button> {
return this._decrementMonthButtonFactory;
}
private function set_decrementMonthButtonFactory(value:AbstractDisplayObjectFactory<Dynamic, Button>):AbstractDisplayObjectFactory<Dynamic, Button> {
if (this._decrementMonthButtonFactory == value) {
return this._decrementMonthButtonFactory;
}
this._decrementMonthButtonFactory = value;
this.setInvalid(INVALIDATION_FLAG_DECREMENT_MONTH_BUTTON_FACTORY);
return this._decrementMonthButtonFactory;
}
private var _previousCustomDecrementMonthButtonVariant:String = null;
/**
A custom variant to set on the decrement month button sub-component,
instead of `DatePicker.CHILD_VARIANT_DECREMENT_MONTH_BUTTON`.
The `customDecrementMonthButtonVariant` will be not be used if the
result of `decrementMonthButtonFactory` already has a variant set.
@see `DatePicker.CHILD_VARIANT_DECREMENT_MONTH_BUTTON`
@see `feathers.style.IVariantStyleObject.variant`
@since 1.0.0
**/
@:style
public var customDecrementMonthButtonVariant:String = null;
private var _oldIncrementMonthButtonFactory:DisplayObjectFactory<Dynamic, Button>;
private var _incrementMonthButtonFactory:DisplayObjectFactory<Dynamic, Button>;
/**
Creates the increment month button that is displayed as a sub-component.
The button must be of type `feathers.controls.Button`.
In the following example, a custom increment month button factory is provided:
```haxe
datePicker.incrementMonthButtonFactory = () ->
{
return new Button();
};
```
@see `feathers.controls.Button`
@since 1.0.0
**/
public var incrementMonthButtonFactory(get, set):AbstractDisplayObjectFactory<Dynamic, Button>;
private function get_incrementMonthButtonFactory():AbstractDisplayObjectFactory<Dynamic, Button> {
return this._incrementMonthButtonFactory;
}
private function set_incrementMonthButtonFactory(value:AbstractDisplayObjectFactory<Dynamic, Button>):AbstractDisplayObjectFactory<Dynamic, Button> {
if (this._incrementMonthButtonFactory == value) {
return this._incrementMonthButtonFactory;
}
this._incrementMonthButtonFactory = value;
this.setInvalid(INVALIDATION_FLAG_INCREMENT_MONTH_BUTTON_FACTORY);
return this._incrementMonthButtonFactory;
}
private var _previousCustomIncrementMonthButtonVariant:String = null;
/**
A custom variant to set on the increment month button sub-component,
instead of `DatePicker.CHILD_VARIANT_INCREMENT_MONTH_BUTTON`.
The `customIncrementMonthButtonVariant` will be not be used if the
result of `incrementMonthButtonFactory` already has a variant set.
@see `DatePicker.CHILD_VARIANT_INCREMENT_MONTH_BUTTON`
@see `feathers.style.IVariantStyleObject.variant`
@since 1.0.0
**/
@:style
public var customIncrementMonthButtonVariant:String = null;
private var _oldDecrementYearButtonFactory:DisplayObjectFactory<Dynamic, Button>;
private var _decrementYearButtonFactory:DisplayObjectFactory<Dynamic, Button>;
/**
Creates the decrement year button that is displayed as a sub-component.
The button must be of type `feathers.controls.Button`.
In the following example, a custom decrement year button factory is provided:
```haxe
datePicker.decrementYearButtonFactory = () ->
{
return new Button();
};
```
@see `feathers.controls.Button`
@since 1.0.0
**/
public var decrementYearButtonFactory(get, set):AbstractDisplayObjectFactory<Dynamic, Button>;
private function get_decrementYearButtonFactory():AbstractDisplayObjectFactory<Dynamic, Button> {
return this._decrementYearButtonFactory;
}
private function set_decrementYearButtonFactory(value:AbstractDisplayObjectFactory<Dynamic, Button>):AbstractDisplayObjectFactory<Dynamic, Button> {
if (this._decrementYearButtonFactory == value) {
return this._decrementYearButtonFactory;
}
this._decrementYearButtonFactory = value;
this.setInvalid(INVALIDATION_FLAG_DECREMENT_YEAR_BUTTON_FACTORY);
return this._decrementYearButtonFactory;
}
private var _previousCustomDecrementYearButtonVariant:String = null;
/**
A custom variant to set on the decrement year button sub-component,
instead of `DatePicker.CHILD_VARIANT_DECREMENT_YEAR_BUTTON`.
The `customDecrementYearButtonVariant` will be not be used if the
result of `decrementYearButtonFactory` already has a variant set.
@see `DatePicker.CHILD_VARIANT_DECREMENT_YEAR_BUTTON`
@see `feathers.style.IVariantStyleObject.variant`
@since 1.0.0
**/
@:style
public var customDecrementYearButtonVariant:String = null;
private var _oldIncrementYearButtonFactory:DisplayObjectFactory<Dynamic, Button>;
private var _incrementYearButtonFactory:DisplayObjectFactory<Dynamic, Button>;
/**
Creates the increment year button that is displayed as a sub-component.
The button must be of type `feathers.controls.Button`.
In the following example, a custom increment year button factory is provided:
```haxe
datePicker.incrementYearButtonFactory = () ->
{
return new Button();
};
```
@see `feathers.controls.Button`
@since 1.0.0
**/
public var incrementYearButtonFactory(get, set):AbstractDisplayObjectFactory<Dynamic, Button>;
private function get_incrementYearButtonFactory():AbstractDisplayObjectFactory<Dynamic, Button> {
return this._incrementYearButtonFactory;
}
private function set_incrementYearButtonFactory(value:AbstractDisplayObjectFactory<Dynamic, Button>):AbstractDisplayObjectFactory<Dynamic, Button> {
if (this._incrementYearButtonFactory == value) {
return this._incrementYearButtonFactory;
}
this._incrementYearButtonFactory = value;
this.setInvalid(INVALIDATION_FLAG_INCREMENT_YEAR_BUTTON_FACTORY);
return this._incrementYearButtonFactory;
}
private var _previousCustomIncrementYearButtonVariant:String = null;
/**
A custom variant to set on the increment year button sub-component,
instead of `DatePicker.CHILD_VARIANT_INCREMENT_YEAR_BUTTON`.
The `customIncrementYearButtonVariant` will be not be used if the
result of `incrementYearButtonFactory` already has a variant set.
@see `DatePicker.CHILD_VARIANT_INCREMENT_YEAR_BUTTON`
@see `feathers.style.IVariantStyleObject.variant`
@since 1.0.0
**/
@:style
public var customIncrementYearButtonVariant:String = null;
private var _oldMonthTitleViewFactory:DisplayObjectFactory<Dynamic, Label>;
private var _monthTitleViewFactory:DisplayObjectFactory<Dynamic, Label>;
/**
Creates the current month view that is displayed as a sub-component.
The view must be of type `feathers.controls.Label`.
In the following example, a custom current month view factory is provided:
```haxe
datePicker.monthTitleViewFactory = () ->
{
return new Label();
};
```
@since 1.0.0
**/
public var monthTitleViewFactory(get, set):AbstractDisplayObjectFactory<Dynamic, Label>;
private function get_monthTitleViewFactory():AbstractDisplayObjectFactory<Dynamic, Label> {
return this._monthTitleViewFactory;
}
private function set_monthTitleViewFactory(value:AbstractDisplayObjectFactory<Dynamic, Label>):AbstractDisplayObjectFactory<Dynamic, Label> {
if (this._monthTitleViewFactory == value) {
return this._monthTitleViewFactory;
}
this._monthTitleViewFactory = value;
this.setInvalid(INVALIDATION_FLAG_MONTH_TITLE_VIEW_FACTORY);
return this._monthTitleViewFactory;
}
private var _previousCustomMonthTitleViewVariant:String = null;
/**
A custom variant to set on the month title view sub-component,
instead of `DatePicker.CHILD_VARIANT_MONTH_TITLE_VIEW`.
The `customMonthTitleViewVariant` will be not be used if the
result of `monthTitleViewFactory` already has a variant set.
@see `DatePicker.CHILD_VARIANT_MONTH_TITLE_VIEW`
@see `feathers.style.IVariantStyleObject.variant`
@since 1.0.0
**/
@:style
public var customMonthTitleViewVariant:String = null;
/**
The space, in pixels, between items in the date picker's header.
In the following example, the date picker's header gap is set to 20
pixels:
```haxe
datePicker.headerGap = 20.0;
```
@since 1.0.0
**/
@:style
public var headerGap:Float = 0.0;
/**
The minimum space, in pixels, between the date picker's top edge and the
date picker's content.
In the following example, the date picker's top padding is set to 20
pixels:
```haxe
datePicker.paddingTop = 20.0;
```
@since 1.0.0
**/
@:style
public var paddingTop:Float = 0.0;
/**
The minimum space, in pixels, between the date picker's right edge and
the date picker's content.
In the following example, the date picker's right padding is set to 20
pixels:
```haxe
datePicker.paddingRight = 20.0;
```
@since 1.0.0
**/
@:style
public var paddingRight:Float = 0.0;
/**
The minimum space, in pixels, between the date picker's bottom edge and
the date picker's content.
In the following example, the date picker's bottom padding is set to 20
pixels:
```haxe
datePicker.paddingBottom = 20.0;
```
@since 1.0.0
**/
@:style
public var paddingBottom:Float = 0.0;
/**
The minimum space, in pixels, between the date picker's left edge and
the date picker's content.
In the following example, the date picker's left padding is set to 20
pixels:
```haxe
datePicker.paddingLeft = 20.0;
```
@since 1.0.0
**/
@:style
public var paddingLeft:Float = 0.0;
/**
The horizontal position of the month title view, relative to the
increment and decrement buttons.
**Note:** The `HorizontalAlign.JUSTIFY` constant is not supported by this
component.
@see `feathers.layout.HorizontalAlign.LEFT`
@see `feathers.layout.HorizontalAlign.CENTER`
@see `feathers.layout.HorizontalAlign.RIGHT`
@since 1.0.0
**/
@:style
public var monthTitleViewPosition:HorizontalAlign = CENTER;
/**
Determines if the name of the month title view is displayed or hidden.
@since 1.0.0
**/
@:style
public var showMonthTitleView:Bool = true;
/**
Determines if the buttons to decrement and increment the month buttons
are displayed or hidden.
@since 1.0.0
**/
@:style
public var showMonthButtons:Bool = true;
/**
Determines if the buttons to decrement and increment the year buttons
are displayed or hidden.
@since 1.0.0
**/
@:style
public var showYearButtons:Bool = true;
/**
Determines if the weekday labels are visible or not.
@since 1.0.0
**/
@:style
public var showWeekdayLabels:Bool = true;
private var _currentMonthNames:Array<String>;
private var _currentWeekdayNames:Array<String>;
#if (flash || (openfl >= "9.2.0" && !neko))
private var _currentDateFormatter:DateTimeFormatter;
#end
private var _requestedLocaleIDName:String = null;
/**
The locale ID name that is requested.
@see `DatePicker.actualLocaleIDName`
@since 1.0.0
**/
public var requestedLocaleIDName(get, set):String;
private function get_requestedLocaleIDName():String {
return this._requestedLocaleIDName;
}
private function set_requestedLocaleIDName(value:String):String {
if (this._requestedLocaleIDName == value) {
return this._requestedLocaleIDName;
}
this._requestedLocaleIDName = value;
this._actualLocaleIDName = null;
this.setInvalid(DATA);
return this._requestedLocaleIDName;
}
private var _actualLocaleIDName:String = null;
/**
The locale ID name that is being used, which may be different from the
requested locale ID name.
@see `DatePicker.requestedLocaleIDName`
@since 1.0.0
**/
public var actualLocaleIDName(get, never):String;
private function get_actualLocaleIDName():String {
return this._actualLocaleIDName;
}
/**
Sets all four padding properties to the same value.
@see `DatePicker.paddingTop`
@see `DatePicker.paddingRight`
@see `DatePicker.paddingBottom`
@see `DatePicker.paddingLeft`
@since 1.0.0
**/
public function setPadding(value:Float):Void {
this.paddingTop = value;
this.paddingRight = value;
this.paddingBottom = value;
this.paddingLeft = value;
}
private var _customMonthNames:Array<String> = null;
/**
A custom set of month names to use instead of the default.
@since 1.0.0
**/
public var customMonthNames(get, set):Array<String>;
private function get_customMonthNames():Array<String> {
return this._customMonthNames;
}
private function set_customMonthNames(value:Array<String>):Array<String> {
if (value != null && value.length != 12) {
throw new ArgumentError("Length of customMonthNames must be exactly equal to 12");
}
if (this._customMonthNames == value) {
return this._customMonthNames;
}
this._customMonthNames = value;
this.setInvalid(DATA);
return this._customMonthNames;
}
private var _customWeekdayNames:Array<String> = null;
/**
A custom set of weekday names to use instead of the default.
@since 1.0.0
**/
public var customWeekdayNames(get, set):Array<String>;
private function get_customWeekdayNames():Array<String> {
return this._customWeekdayNames;
}
private function set_customWeekdayNames(value:Array<String>):Array<String> {
if (value != null && value.length != 7) {
throw new ArgumentError("Length of customWeekdayNames must be exactly equal to 7");
}
if (this._customWeekdayNames == value) {
return this._customWeekdayNames;
}
this._customWeekdayNames = value;
this.setInvalid(DATA);
return this._customWeekdayNames;
}
private var _currentStartOfWeek:Int = 0;
private var _customStartOfWeek:Null<Int> = null;
/**
The index of the day that starts each week. `0` is Sunday and `6` is
Saturday. Set to `null` to use the default.
@since 1.0.0
**/
public var customStartOfWeek(get, set):Null<Int>;
private function get_customStartOfWeek():Null<Int> {
return this._customStartOfWeek;
}
private function set_customStartOfWeek(value:Null<Int>):Null<Int> {
if (value != null && (value < 0 || value > 6)) {
throw new RangeError("startOfWeek must be in the range 0-6");
}
if (this._customStartOfWeek == value) {
return this._customStartOfWeek;
}
this._customStartOfWeek = value;
this.setInvalid(DATA);
return this._customStartOfWeek;
}
private var _oldWeekdayLabelFactory:DisplayObjectFactory<Dynamic, Label>;
private var _weekdayLabelFactory:DisplayObjectFactory<Dynamic, Label>;
/**
Creates the weekday labels that are displayed as sub-components.
The labels must be of type `feathers.controls.Label`.
In the following example, a custom weekday label factory is provided: