This repository was archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 225
Expand file tree
/
Copy pathtreeview.lcb
More file actions
2862 lines (2347 loc) · 88 KB
/
treeview.lcb
File metadata and controls
2862 lines (2347 loc) · 88 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
/*
Copyright (C) 2015 - 2016 LiveCode Ltd.
This file is part of LiveCode.
LiveCode is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License v3 as published by the Free
Software Foundation.
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
/**
A widget to display array data in a tree view
Name: hiliteChanged
Type: message
Syntax: hiliteChanged
Summary: Sent when an element is hilited
Description:
The <hiliteChanged> message is sent to the widget's script object when a row of the
widget's display is clicked on, causing that row to be highlighted. Use the <hilitedElement>
property to fetch the row's associated array keys.
References: hilitedElement (property)
A widget to display array data in a tree view
Name: dataChanged
Type: message
Syntax: dataChanged
Summary: Sent when the arrayData of the widget changes
Description:
The <dataChanged> message is sent to the widget's script object when the underlying
<arrayData> of the tree view changes.
References: arrayData (property)
Name: actionInspect
Type: message
Syntax: actionInspect <pPath>
Summary: Sent when an the inspect icon is clicked in read only mode
Parameters:
pPath: The path to the clicked element
Description:
The actionInspect message is sent to the widget's script object when the inspect icon is clicked on.
The inspect icon appears when the value string of a particular array element contains a newline character,
or if it is too large to fit in the space provided. The <pPath> parameter contains the path to the
element whose icon was clicked.
Name: actionDoubleClick
Type: message
Syntax: actionDoubleClick <pPath>
Summary: Sent when a leaf node of the tree view is double-clicked.
Parameters:
pPath: The path to the clicked element
Description:
The actionDoubleClick message is sent to the widget's script object when a row of the widget
is double-clicked. The <pPath> parameter contains the path to the element whose row was clicked.
Name: formattedHeightChanged
Type: message
Syntax: formattedHeightChanged
Summary: Sent when the formatted height of the displayed data changes.
Description:
The formattedHeightChanged message is sent to the widget's script object when
the formatted height of the displayed data changes. This is useful when
using a mobileScroller to control the widget view.
**/
widget com.livecode.widget.treeview
use com.livecode.canvas
use com.livecode.widget
use com.livecode.engine
use com.livecode.library.widgetutils
use com.livecode.foreign
metadata author is "LiveCode"
metadata version is "2.4.1"
metadata title is "Tree View"
metadata svgicon is "M152.4,249.7c-6.4,0-11.8,4.3-13.5,10.1h-10v-26.7h10c1.7,5.8,7.1,10.1,13.5,10.1c7.8,0,14.1-6.3,14.1-14.1s-6.3-14.1-14.1-14.1c-6.4,0-11.8,4.3-13.5,10.1h-10v-16.1c8.4-1.8,14.8-9.3,14.8-18.3c0-10.4-8.4-18.8-18.8-18.8s-18.8,8.4-18.8,18.8c0,9,6.3,16.5,14.7,18.3v58.8h18c1.7,5.8,7.1,10.1,13.5,10.1c7.8,0,14.1-6.3,14.1-14.1S160.2,249.7,152.4,249.7z M128.7,202h-7.5v-7.5h-7.5V187h7.5v-7.5h7.5v7.5h7.5v7.5h-7.5V202z"
metadata _ide is "true"
-- property declarations
/**
Syntax: set the arrayData of <widget> to <pArray>
Syntax: get the arrayData of <widget>
Summary: The array being displayed by the widget
Parameters:
pArray (array): The array data.
Description:
The arrayData is the data currently being displayed by the tree view widget.
**/
property arrayData get getArrayData set setArrayData
metadata arrayData.label is "Array data"
/**
Syntax: set the foldState of <widget> to <pFoldState>
Syntax: get the foldState of <widget>
Summary: The fold state of the array being displayed by the widget
Parameters:
pFoldState (array): The fold state data. See description for details.
Description:
The foldState is the fold state currently being displayed by the tree view widget.
The fold state array only contains elements of the data array where the
value is a subarray. The value for each `folded` key must be a boolean.
Only the unfolded keys need to be specified.
```
[key1]
["folded"]
["array"]
[subkey1]
["folded"]
[key2]
["folded"]
```
Setting the foldState to empty will fold all keys.
**/
property foldState get getFoldState set setFoldState
metadata foldState.user_visible is "false"
/**
Syntax: set the hilitedElement of <widget> to <pPath>
Syntax: get the hilitedElement of <widget>
Summary: Select the row corresponding to <pPath>
Parameters:
pPath: A comma delimited list of array keys.
Description:
<pPath> is a list of the keys which determine the row to be selected. For example, if tArray is the arrayData
of the widget, to select a row corresponding to tArray["key1"]["subkey2"]["subsubkey5"], simply execute
``` set the hilitedElement of widget "Array Viewer" to "key1,subkey2,subsubkey5" ```
Setting to an invalid path or to `empty` will unselect the currently selected row.
**/
property hilitedElement get getSelectedElement set setSelectedElement
metadata hilitedElement.label is "Hilited element"
/**
Syntax: set the hilitedElementFoldState of <widget> to <pFoldState>
Syntax: get the hilitedElementFoldState of <widget>
Summary: Get/set the fold state of the selected element
Parameters:
pFoldState (enum): The fold state of the selected element.
- "folded": Sub-array for the selected element is hidden.
- "unfolded": Sub-array for the selected element is visible.
- "leaf": Selected element is a leaf node. This value may not be set.
Description:
<pFoldState> is the fold state of the selected element. When setting
the fold state, attempts to set the value for a leaf node will have no
effect. Setting the fold state when no element is selected has no effect.
**/
property hilitedElementFoldState get getSelectedElementFoldState set setSelectedElementFoldState
metadata hilitedElementFoldState.user_visible is "false"
/**
Syntax: set the hilitedElementIsFolded of <widget> to {true|false}
Syntax: get the hilitedElementIsFolded of <widget>
Summary: Determine if the selected element is folded
Description:
Value is true if the selected element is folded. False is returned in
all other cases including when nothing is selected and when a leaf node is
selected. When setting the fold state, attempts to set the value for a leaf
node will have no effect. Setting the fold state when no element is selected
has no effect.
**/
property hilitedElementIsFolded get getSelectedElementIsFolded set setSelectedElementIsFolded
metadata hilitedElementIsFolded.user_visible is "false"
/**
Syntax: set the hiliteNewElement of <widget> to {true|false}
Syntax: get the hiliteNewElement of <widget>
Summary: Automatically select new elements when created interactively.
Description:
If the <readOnly> property is false and the <hiliteNewElement> property is true,
then when new array elements are added, they will be automatically selected.
References: readOnly (property)
**/
property hiliteNewElement get mHiliteNewElement set mHiliteNewElement
metadata hiliteNewElement.label is "Hilite new element"
/**
Syntax: set the scrollHilitedElementIntoView of <widget> to {true|false}
Syntax: get the scrollHilitedElementIntoView of <widget>
Summary: Automatically scroll selected row into view.
Description:
If the <scrollHilitedElementIntoView> property is true, then when the
<hilitedElement> property changes the view will be scrolled such that the
selected row is visible.
References: hilitedElement (property)
**/
property scrollHilitedElementIntoView get mScrollHilitedElementIntoView set mScrollHilitedElementIntoView
metadata scrollHilitedElementIntoView.label is "Scroll hilited element into view"
/**
Syntax: set the autoFoldStateReset of <widget> to {true|false}
Syntax: get the autoFoldStateReset of <widget>
Summary: Automatically reset fold state when array data is set.
Description:
Use the <autoFoldStateReset> property to determine if the fold state is
reset (tree is completely folded) when the <arrayData> property is set.
References: arrayData (property)
**/
property autoFoldStateReset get mAutoFoldStateReset set mAutoFoldStateReset
metadata autoFoldStateReset.label is "Automatically reset fold state when array data is set"
/**
Name: foreColor
Type: property
Syntax: set the foreColor of <widget> to <pColor>
Syntax: get the foreColor of <widget>
Summary: The color used for the text of the tree view.
Parameters:
pColor: Any color name, or RGB value.
Description:
Use the <foreColor> property to get or set the color the tree view widget uses for its text.
**/
metadata foregroundColor.default is "50,50,50"
metadata foregroundColor.label is "Text color"
/**
Name: backColor
Type: property
Syntax: set the backColor of <widget> to <pColor>
Syntax: get the backColor of <widget>
Summary: The color used for the background of the rows of the tree view.
Parameters:
pColor: Any color name, or RGB value.
Description:
Use the <backColor> property to get or set the color the tree view widget uses for the
background of its rows.
**/
metadata backgroundColor.default is "244,244,244"
metadata backgroundColor.label is "Row background color"
/**
Syntax: set the hiliteColor of <widget> to <pColor>
Syntax: get the hiliteColor of <widget>
Summary: The color used to highlight a selected row.
Parameters:
pColor: Any color name, or RGB value.
Description:
Use the <hiliteColor> property to get or set the color the tree view widget uses to highlight
the selected row.
**/
metadata hiliteColor.default is "10,95,244"
metadata hiliteColor.label is "Selected row color"
/**
Name: borderColor
Type: property
Syntax: set the borderColor of <widget> to <pColor>
Syntax: get the borderColor of <widget>
Summary: The color used for the border and the separator of the tree view.
Parameters:
pColor: Any color name, or RGB value.
Description:
Use the <borderColor> property to get or set the color the tree view widget uses for its
border, and the separator (if the <showSeparator> property is true).
References: showSeparator (property)
**/
metadata borderColor.default is "109,109,109"
metadata borderColor.label is "Border color"
/**
Syntax: set the sortOrder of <widget> to <pOrder>
Syntax: get the sortOrder of <widget>
Summary: Manipulates the order in which elements of the tree view are displayed, with respect to the current <sortType>.
Parameters:
pOrder (enum): The order in which to display elements of the tree view.
- "ascending": Display from first to last in the order. This is the default
- "descending": Display from last to first in the order.
Description:
Use the <sortOrder> property to display the elements of the tree view in ascending or descending order of the
keys of its <arrayData>, given the current <sortType>.
References: arrayData (property), sortType (property)
**/
property sortOrder get getSortOrder set setSortOrder
metadata sortOrder.editor is "com.livecode.pi.enum"
metadata sortOrder.options is "ascending,descending"
metadata sortOrder.label is "Sort order"
/**
Syntax: set the sortType of <widget> to <pType>
Syntax: get the sortType of <widget>
Summary: Manipulates the type of ordering in which elements of the tree view are displayed.
Parameters:
pType (enum): The type of ordering to use in displaying elements of the tree view.
- "text": Display in alphabetical order of the keys
- "numeric": Display in numeric order of the keys. This is the default
Description:
Use the <sortType> property to use text or numeric comparison when ordering the keys of the <arrayData>
of the tree view widget.
References: sortOrder (property)
**/
property sortType get getSortType set setSortType
metadata sortType.editor is "com.livecode.pi.enum"
metadata sortType.options is "text,numeric"
metadata sortType.label is "Sort type"
/**
Name: pathDelimiter
Type: property
Syntax: set the pathDelimiter of <widget> to <pType>
Syntax: get the pathDelimiter of <widget>
Summary: Manipulates the separator between the elements of the array viewer
Description:
Use the <pathDelimiter> property as the separator between the elements describing
a path in the tree view widget.
**/
property pathDelimiter get mPathDelimiter set mPathDelimiter
metadata pathDelimiter.label is "Path delimiter"
metadata pathDelimiter.default is ","
/**
Syntax: set the alternateRowBackgrounds of <widget> to {true|false}
Syntax: get the alternateRowBackgrounds of <widget>
Summary: Whether the alternate rows of the widget have different backgrounds or not.
Description:
Use the alternateRowBackgrounds property if you want to more clearly distinguish the rows displayed by the widget.
**/
property alternateRowBackgrounds get mAlternateRowBackgrounds set setRowBackgrounds
metadata alternateRowBackgrounds.label is "Alternate row backgrounds"
/**
Syntax: set the showBorder of <widget> to {true|false}
Syntax: get the showBorder of <widget>
Summary: Whether the widget has a border or not.
Description:
Use the <showBorder> property to show or hide the bounds of the widget
object.
**/
property showBorder get mFrameBorder set setFrameBorder
metadata showBorder.label is "Show border"
/**
Syntax: set the showHover of <widget> to {true|false}
Syntax: get the showHover of <widget>
Summary: Whether the widget has a hover row displayed or not.
Description:
Use the <showHover> property to show or hide the hover row of the widget
object.
**/
property showHover get mShowHover set setShowHover
metadata showHover.label is "Show hover row"
/**
Syntax: set the readOnly of <widget> to {true|false}
Syntax: get the readOnly of <widget>
Summary: Whether the options to modify elements of the underlying array are present or not.
Description:
The <readOnly> property controls whether the widget presents the option to add elements to arrays or not.
If false, the first row of the widget is always "Add new element", and when rows are hovered over, icons
appear at the right to enable the removal of that element, or the addition of a new subelement.
**/
property readOnly get mReadOnly set setReadOnly
metadata readOnly.label is "Read only"
/**
Syntax: set the arrayStyle of <widget> to {true|false}
Syntax: get the arrayStyle of <widget>
Summary: Whether the tree view should display its contents in array style or as a standard tree view.
Description:
The <arrayStyle> property controls whether the keys of the <arrayData> of the widget are displayed with
square brackets around them or not.
References: arrayData (property)
**/
property arrayStyle get mArrayStyle set setArrayStyle
metadata arrayStyle.label is "Array style"
/**
Syntax: set the charsToTrimFromKey of <widget> to <pChars>
Syntax: get the charsToTrimFromKey of <widget>
Summary: The number of leading characters to trim from the key for display.
Parameters:
pChars: Number of leading characters to trim from the key.
Description:
The <charsToTrimFromKey> property controls the number of leading characters that
are removed from the keys of the <arrayData> of the widget. This allows
a custom sort where the sort portion of the key is not displayed.
With <charsToTrimFromKey> set to 2, the following array:
```
[1 CCC]
[2 BBB]
[3 AAA]
```
Would display in the widget as:
```
[CCC]
[BBB]
[AAA]
```
References: arrayData (property)
**/
property charsToTrimFromKey get mCharsToTrimFromKey set setCharsToTrimFromKey
metadata charsToTrimFromKey.label is "Key chars to trim"
/**
Syntax: get the formattedHeight of <widget>
Summary: Height of the data displayed by the widget
Description:
Use the <formattedHeight> property to get the height of the data displayed
by the widget in the current fold state.
**/
property formattedHeight get mDataHeight
metadata formattedHeight.user_visible is "false"
/**
Syntax: set the scroll of <widget> to <pScroll>
Syntax: get the scroll of <widget>
Syntax: get the vScroll of <widget>
Summary: Vertical scroll position of the widget
Parameters:
pScroll: Vertical scroll position of the widget
Description:
Use the <scroll> property to get or set the scroll position of
the widget.
**/
property scroll get mViewTopPosition set setViewTopPosition
metadata scroll.user_visible is "false"
/**
Syntax: set the textHeight of <widget> to <pTextHeight>
Syntax: get the textHeight of <widget>
Summary: Custom text height for the widget
Parameters:
pTextHeight: Custom text height for the widget
Description:
Use the <textHeight> property to set a custom text (row) height for
the widget. The default value is 0 which will use the calculated height
based on the currently selected font and size.
**/
property textHeight get mTextHeight set mTextHeight
metadata textHeight.label is "Text Height"
metadata textHeight.default is "0"
/**
Syntax: set the iconHeight of <widget> to <pIconHeight>
Syntax: get the iconHeight of <widget>
Summary: Custom icon height for the widget
Parameters:
pIconHeight: Custom icon height for the widget
Description:
Use the <iconHeight> property to set a custom icon size for
the widget. The default value is 10.
**/
property iconHeight get mIconHeight set setIconHeight
metadata iconHeight.label is "Icon Height"
metadata iconHeight.default is "10"
/**
Name: vScrollbar
Type: property
Syntax:
set the vScrollbar of <widget> to <pEnabled>
get the vScrollbar of <widget>
Summary: Controls the visibility of the browser's vertical scrollbar.
Value (boolean):
`true` if the vertical scrollbar should be enabled and displayed;
`false` otherwise.
Description:
Use the <vScrollbar> property to control the visibility of the widget's
vertical scrollbar
*/
property vScrollbar get mVScrollbar set setVScrollbar
metadata vScrollbar.editor is "com.livecode.pi.boolean"
metadata vScrollbar.default is "true"
metadata vScrollbar.label is "Vertical scrollbar"
/**
Syntax: set the showValues of <widget> to {true|false}
Syntax: get the showValues of <widget>
Summary: Whether the values are displayed or not
Description:
Use the <showValues> property to display or hide the values of the <arrayData>
of the tree view widget. This setting will be useful when using the
widget as a menu for navigation purposes.
Hiding values effectively hides the separator as well.
Related: showSeparator (property)
**/
property showValues get mShowValues set setShowValues
metadata showValues.label is "Show values"
/**
Syntax: set the showSeparator of <widget> to {true|false}
Syntax: get the showSeparator of <widget>
Summary: Whether the separator bar between keys and values is showing or not
Description:
Use the <showSeparator> property to display the keys and values of the <arrayData>
of the tree view widget in columns separated by a movable divide.
Related: separatorRatio (property)
**/
property showSeparator get mShowSeparator set setShowSeparator
metadata showSeparator.label is "Show separator"
/**
Syntax: set the separatorRatio of <widget> to {true|false}
Syntax: get the separatorRatio of <widget>
Summary: Manipulates the size of the arrayData view columns.
Description:
Use the <separatorRatio> property to display the keys and values of the <arrayData>
of the tree view widget in columns separated by a movable divide.
The <separatorRatio> is the size of the first column as a ratio of the total view area.
Related: showSeparator (property)
**/
property separatorRatio get mSeparatorRatio set setSeparatorRatio
metadata separatorRatio.editor is "com.livecode.pi.number"
metadata separatorRatio.step is "0.05"
metadata separatorRatio.min is "0"
metadata separatorRatio.max is "1"
metadata separatorRatio.label is "Separator ratio"
metadata themeClass.default is "list"
metadata themeClass.user_visible is "false"
// The unmodified array data
private variable mData as Array
// A flat list representing the array items to be displayed
private variable mDataList as optional List
// The number of lines to be displayed
private variable mDataCount as Integer
// The total height of the displayed data
private variable mDataHeight as Real
// The height of each row
private variable mRowHeight as Real
private variable mTextHeight as Real
private variable mFontSize as Integer
private variable mFontName as String
// The height of the view area
private variable mViewHeight as Real
// The width of the view area
private variable mViewWidth as Real
// The first part of the data being displayed
private variable mViewTopPosition as Real
// The index in the display list corresponding the the top of the view
private variable mFirstDataItem as Integer
private variable mRecalculate as Boolean
private variable mUpdateSeparator as Boolean
private variable mUpdateDataList as Boolean
private variable mRecalculateFit as Boolean
private variable mRedraw as Boolean
private variable mFoldChanged as Boolean
private variable mAlternateRowBackgrounds as Boolean
private variable mVScrollbar as Boolean
private variable mIndentPixels as Integer
private variable mHoverRow as Integer
private variable mHoverIcon as String
private variable mMouseDownRow as Integer
private variable mScrolledSinceMouseDown as Boolean
private variable mFrameBorder as Boolean
private variable mShowHover as Boolean
private variable mSelectedElement as optional List
private variable mFoldState as Array
private variable mAutoFoldStateReset as Boolean
private variable mLastKeyAdded as optional String
private variable mHiliteNewElement as Boolean
private variable mScrollHilitedElementIntoView as Boolean
private variable mFoldedArrowPath as Path
private variable mUnfoldedArrowPath as Path
private variable mDeleteItemPath as Path
private variable mAddItemPath as Path
private variable mInspectItemPath as Path
private variable mIconRect as Rectangle
private variable mIconWidth as Real
private variable mIconHeight as Integer
private variable mRightIconMargin as Real
private variable mReadOnly as Boolean
private variable mArrayStyle as Boolean
private variable mSortAscending as Boolean
private variable mSortNumeric as Boolean
private variable mPathDelimiter as String
private variable mCharsToTrimFromKey as Integer
private variable mShowValues as Boolean
private variable mShowSeparator as Boolean
private variable mSeparatorRatio as Number
private variable mSeparatorDragging as Boolean
private variable mOldTooltip as optional String
constant kRowBuffer is 1000
constant kRowTextPadding is 4
constant kItemPadding is 6
constant kSeparatorWidth is 4
constant kStrokeWidth is 1
constant kIconHeight is 10
--------------------------------------------------------------------------------
--
-- Message handlers
--
--------------------------------------------------------------------------------
public handler OnCreate() returns nothing
put 21 into mRowHeight
put kIconHeight into mIconHeight
UpdateIconRects()
put 0 into mTextHeight
put true into mAlternateRowBackgrounds
put the size of my font into mFontSize
put the name of my font into mFontName
put my height into mViewHeight
put my width into mViewWidth
put 0 into mHoverRow
put "" into mHoverIcon
put 0 into mViewTopPosition
put true into mFrameBorder
put true into mShowHover
put true into mVScrollbar
initialiseScrollbar()
put false into mReadOnly
put false into mArrayStyle
put true into mSortNumeric
put true into mSortAscending
put "," into mPathDelimiter
put true into mRecalculate
put true into mUpdateDataList
put true into mUpdateSeparator
put true into mRecalculateFit
put true into mRedraw
put false into mFoldChanged
put 0 into mCharsToTrimFromKey
put true into mShowValues
put false into mShowSeparator
put 0.5 into mSeparatorRatio
put false into mSeparatorDragging
put the empty array into mFoldState
put the empty array into mData
put false into mAutoFoldStateReset
put false into mHiliteNewElement
put false into mScrollHilitedElementIntoView
end handler
public handler OnSave(out rProperties as Array)
put the empty array into rProperties
put mData into rProperties["array"]
put mReadOnly into rProperties["read only"]
put mArrayStyle into rProperties["array style"]
put mSortAscending into rProperties["sort ascending"]
put mSortNumeric into rProperties["sort numeric"]
put mAutoFoldStateReset into rProperties["auto fold state reset"]
put mHiliteNewElement into rProperties["hilite new element"]
put mScrollHilitedElementIntoView into rProperties["scroll hilited element into view"]
put mTextHeight into rProperties["text height"]
put mIconHeight into rProperties["icon height"]
put mFrameBorder into rProperties["show border"]
put mShowHover into rProperties["show hover row"]
put mVScrollbar into rProperties["vertical scrollbar"]
put mAlternateRowBackgrounds into rProperties["alternate row backgrounds"]
put mCharsToTrimFromKey into rProperties["chars to trim from key"]
put mShowValues into rProperties["show values"]
put mShowSeparator into rProperties["show separator"]
put mSeparatorRatio into rProperties["separator ratio"]
return rProperties
end handler
public handler OnLoad(in pProperties as Array)
put pProperties["read only"] into mReadOnly
if "array style" is among the keys of pProperties then
put pProperties["array style"] into mArrayStyle
end if
if "sort ascending" is among the keys of pProperties then
put pProperties["sort ascending"] into mSortAscending
end if
if "sort numeric" is among the keys of pProperties then
put pProperties["sort numeric"] into mSortNumeric
end if
if "auto fold state reset" is among the keys of pProperties then
put pProperties["auto fold state reset"] into mAutoFoldStateReset
end if
if "hilite new element" is among the keys of pProperties then
put pProperties["hilite new element"] into mHiliteNewElement
end if
if "scroll hilited element into view" is among the keys of pProperties then
put pProperties["scroll hilited element into view"] into mScrollHilitedElementIntoView
end if
if "text height" is among the keys of pProperties then
put pProperties["text height"] into mTextHeight
end if
-- Prepare for being able to specify custom icons
variable tRecalculateIcons as Boolean
put false into tRecalculateIcons
if "icon height" is among the keys of pProperties then
put pProperties["icon height"] into mIconHeight
put mIconHeight is not kIconHeight into tRecalculateIcons
end if
if "show border" is among the keys of pProperties then
put pProperties["show border"] into mFrameBorder
end if
if "show hover row" is among the keys of pProperties then
put pProperties["show hover row"] into mShowHover
end if
if "vertical scrollbar" is among the keys of pProperties then
put pProperties["vertical scrollbar"] into mVScrollbar
end if
if "alternate row backgrounds" is among the keys of pProperties then
put pProperties["alternate row backgrounds"] into mAlternateRowBackgrounds
end if
if "chars to trim from key" is among the keys of pProperties then
put pProperties["chars to trim from key"] into mCharsToTrimFromKey
end if
if "show values" is among the keys of pProperties then
put pProperties["show values"] into mShowValues
end if
if "show separator" is among the keys of pProperties then
put pProperties["show separator"] into mShowSeparator
end if
if "separator ratio" is among the keys of pProperties then
put pProperties["separator ratio"] into mSeparatorRatio
end if
if tRecalculateIcons then
UpdateIconRects()
end if
setArrayData(pProperties["array"])
end handler
private handler elementIsProxyForMoreData(in pElement as Array) returns Boolean
return "more_data" is among the keys of pElement
end handler
public handler OnPaint() returns nothing
variable tFontSize as Integer
put the size of my font into tFontSize
if tFontSize is not mFontSize then
put tFontSize into mFontSize
put true into mRecalculate
put true into mRecalculateFit
put nothing into mEllipsisLength
end if
variable tFontName as String
put the name of my font into tFontName
if tFontName is not mFontName then
put tFontName into mFontName
put true into mRecalculate
put true into mRecalculateFit
put nothing into mEllipsisLength
end if
variable tRowHeight as Integer
if mTextHeight > 0 then
put mTextHeight into tRowHeight
else
put tFontSize + 2 * kRowTextPadding into tRowHeight
end if
if tRowHeight is not mRowHeight then
put tRowHeight into mRowHeight
put true into mRecalculate
put true into mRecalculateFit
end if
set the font of this canvas to my font
if mUpdateDataList then
updateDataList()
end if
// If anything has changed requiring a recalculation, update parameters
if mRecalculate then
updateParameters()
end if
if mUpdateSeparator or mRecalculateFit then
updateSeparator()
end if
variable tTop as Real
put 0 into tTop
variable tX as Integer
put 1 into tX
variable tTopOffset
put mViewTopPosition mod mRowHeight into tTopOffset
subtract tTopOffset from tTop
// Iterate from the first data item drawing each row until
// we can't display any more items
repeat with tX from mFirstDataItem up to mDataCount
if tX is 1 then
paintFirstRow(tTop)
else
variable tElement as Array
put element tX of mDataList into tElement
if elementIsProxyForMoreData(tElement) then
addToListBuffer(tX, tElement, mDataList)
updateParameters()
updateSeparator()
put mDataList[tX] into tElement
end if
paintDataItem(tElement, tTop, tX)
end if
if tTop > mViewHeight then
exit repeat
end if
add mRowHeight to tTop
end repeat
if mShowValues and mShowSeparator then
paintSeparator()
end if
// Paint the scrollbar
if mVScrollbar then
paintScrollbar(this canvas)
end if
// Draw the frame
if mFrameBorder is true then
variable tPath as Path
put rectangle path of rectangle [0.5,0.5,mViewWidth-0.5,mViewHeight-0.5] into tPath
paintBorder(tPath)
end if
end handler
// Utility for painting the separator
private handler paintSeparator()
set the stroke width of this canvas to kStrokeWidth
set the paint of this canvas to my border paint
variable tPath as Path