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 72
Expand file tree
/
Copy pathrevidelibrary.8.livecodescript
More file actions
12305 lines (10496 loc) · 417 KB
/
revidelibrary.8.livecodescript
File metadata and controls
12305 lines (10496 loc) · 417 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
script "revidelibrary"
/**
Main IDE library providing functionality for palettes and other IDE add-ons.
Name: ideNewControl
Type: message
Syntax: on ideNewControl
Summary: Sent when a control is created in the IDE
Description:
Handle the <ideNewControl> message to respond to the creation of controls using one of the
IDE palettes, or the create command.
>*Note:* The <ideNewControl> message is only sent to objects which have subscribed to it.
See the <revIDESubscribe> command for more details.
References: revIDESubscribe (command)
**/
/**
Called when loading the IDE library
**/
on extensionInitialize
if the target is not me then
pass extensionInitialize
end if
insert the script of me into back
revIDEInitialiseIDELibrary
end extensionInitialize
on extensionFinalize
if the target is not me then
pass extensionFinalize
end if
remove the script of me from back
revIDEFinaliseIDELibrary
end extensionFinalize
#############
# Internal functions
#############
# Reads in all the tool data
local sToolDefinition
private on __toolDefinitionsRead
put empty into sToolDefinition
# Set to folder to the path where the object definition files for classic controls are stored
local tToolDefinitionPath
put revIDESpecialFolderPath("Tool Definitions") into tToolDefinitionPath
revIDEPushDefaultFolder tToolDefinitionPath
# Read in each file and build an array
local tDefinitionData, tToolSection
repeat for each line tFile in the files
if char 1 of tFile is "." then next repeat
set the itemdel to "."
put item 1 of tFile into tToolSection
put URL ("file:" & tToolDefinitionPath & slash & tFile) into tDefinitionData
local tToolID, tCount
put 1 into tCount
set the itemdel to ","
repeat for each line tToolDescription in tDefinitionData
put item 1 of tToolDescription into tToolID
put item 2 of tToolDescription into sToolDefinition[tToolSection][tCount]["label"]
put item 3 of tToolDescription into sToolDefinition[tToolSection][tCount]["icon"]
local tCount2, tPropertyName, tPropertyValue
put 1 into tCount2
repeat for each item tProperty in item 4 of tToolDescription
set the itemdel to ":"
put item 1 of tProperty into tPropertyName
put item 2 of tProperty into tPropertyValue
put tPropertyValue into sToolDefinition[tToolSection][tCount]["properties"][tCount2][tPropertyName]
add 1 to tCount2
end repeat
add 1 to tCount
end repeat
end repeat
revIDEPopDefaultFolder
end __toolDefinitionsRead
private on __resolvePopupData @xInfo, pData
if not xInfo["options"] begins with "popup:" then
exit __resolvePopupData
end if
local tOptions
set the itemdel to ":"
put item 2 to -1 of xInfo["options"] into tOptions
set the itemdel to ","
local tCount, tProp
repeat for each item tPopup in tOptions
add 1 to tCount
put pData[tPopup] into tProp
__resolvePopupData tProp, pData
put tProp into xInfo["popup"][tPopup]
put tCount into xInfo["popup"][tPopup]["group_order"]
put empty into xInfo["options"]
end repeat
end __resolvePopupData
private function __propertyDataMapping
local tMapping
put "name:1,label:2,section:3,editor:4,user_visible:5,read_only:6,group:7,default:8,options:9,subsection:10,min:11,max:12,step:13" into tMapping
split tMapping by comma and ":"
return tMapping
end __propertyDataMapping
# Processes the data
private function __propertyDataProcessLine pLine
local tLineDataA, tMappingA
put __propertyDataMapping() into tMappingA
repeat for each key tDataName in tMappingA
local tItemNumber, tPreProcessed
put tMappingA[tDataName] into tItemNumber
set the itemdelimiter to tab
put item tItemNumber of pLine into tPreProcessed
set the itemdelimiter to comma
switch tDataName
case "name"
# Properties can use custom getters and setters.
# Default getter is revIDEPropertyOfObject
# Default setter is revIDESetPropertyOfObject
set the itemdelimiter to ":"
put item 1 of tPreProcessed into tLineDataA["name"]
put item 2 of tPreProcessed into tLineDataA["getter"]
put item 3 of tPreProcessed into tLineDataA["setter"]
set the itemdelimiter to comma
break
case "default"
set the itemdelimiter to ":"
if item 1 of tPreProcessed is "execute" then
do item 2 of tPreProcessed
put it into tPreProcessed
end if
set the itemdelimiter to comma
put __unescapeString(tPreProcessed) into tLineDataA["default"]
break
case "options"
# Get any popup info
set the itemdelimiter to ":"
if tPreProcessed begins with "popup:" then
put true into tLineDataA["popup"]
else
replace comma with return in tPreProcessed
end if
set the itemdelimiter to comma
put tPreProcessed into tLineDataA["options"]
break
default
put tPreProcessed into tLineDataA[tDataName]
break
end switch
end repeat
return tLineDataA
end __propertyDataProcessLine
private function __propertyDataFromInfoFile pFileName
local tPropertyInfo
put URL ("file:" & pFileName) into tPropertyInfo
local tDataStart, tDataA, tPropName
put false into tDataStart
local tCountsA, tGroupCountsA, tPopupsToResolve
repeat for each line tLine in tPropertyInfo
if tLine begins with "-----" then
put true into tDataStart
next repeat
end if
if not tDataStart then
next repeat
end if
if token 1 of tLine is empty then
next repeat
end if
local tLineDataA
put __propertyDataProcessLine(tLine) into tLineDataA
put tLineDataA["name"] into tPropName
put tLineDataA into tDataA[tPropName]
local tGroupName
put tLineDataA["group"] into tGroupName
if tGroupName is empty then
put tDataA[tPropName]["label"] into tGroupName
end if
if tGroupName is empty then
put tPropName into tGroupName
end if
put tGroupName into tDataA[tPropName]["group"]
local tSection
put tLineDataA["section"] into tSection
if tGroupCountsA[tSection][tGroupName] is empty then
add 1 to tCountsA[tSection]["count"]
put tCountsA[tSection]["count"] into tGroupCountsA[tSection][tGroupName]
end if
put tGroupCountsA[tSection][tGroupName] into tDataA[tPropName]["group_order"]
add 1 to tCountsA[tSection][tGroupName]["count"]
put tCountsA[tSection][tGroupName]["count"] into tDataA[tPropName]["order"]
if tLineDataA["popup"] is true then
put true into tPopupsToResolve[tPropName]
end if
end repeat
repeat for each key tKey in tPopupsToResolve
local tPropData
put tDataA[tKey] into tPropData
__resolvePopupData tPropData, tDataA
put tPropData into tDataA[tKey]
end repeat
return tDataA
end __propertyDataFromInfoFile
private function __organisePropertyInfo pInfoA, pPopup
local tOrganisedA
repeat for each key tKey in pInfoA
local tSection
put pInfoA[tKey]["section"] into tSection
local tGroupLabel
put pInfoA[tKey]["group"] into tGroupLabel
local tGroupData
put empty into tGroupData
# The groups are ordered by their appearance in the spec file
put pInfoA[tKey]["group_order"] into tGroupData["order"]
put pInfoA[tKey]["subsection"] into tGroupData["subsection"]
# Carry over the generic prop information into the object prop info array
put pInfoA[tKey] into tGroupData["proplist"][tKey]
# Organise the popup data if there is any
local tPopupData
if pInfoA[tKey]["popup"] is not empty then
put __organisePropertyInfo(pInfoA[tKey]["popup"], true) into tGroupData["proplist"][tKey]["popup"]
end if
if pPopup then
union tOrganisedA["grouplist"][tGroupLabel] with tGroupData recursively
else
union tOrganisedA[tSection]["grouplist"][tGroupLabel] with tGroupData recursively
end if
end repeat
return tOrganisedA
end __organisePropertyInfo
local sClassicObjectProperties, sClassicObjectPropertiesInfo, sClassicPropertiesInfo
-- Use this accessor instead of the array directly to ensure inherited props
-- are also included, eg control level defined props.
private function __classicObjectProperties pObjID
local tType
put ideObjectTypeFromObject(pObjID) into tType
return __classicObjectPropertiesFromType(tType)
end __classicObjectProperties
private function __classicObjectPropertiesFromType pType
set the itemdel to "."
switch the last item of pType
case "Card"
case "Stack"
case "Substack"
return sClassicObjectProperties[pType]
default
if not (pType begins with "com.livecode.interface.classic") then
put "com.livecode.interface.classic.widget" into pType
end if
local tPropsA
put sClassicObjectProperties[pType] into tPropsA
union tPropsA with sClassicObjectProperties["com.livecode.interface.Control"] recursively
return tPropsA
end switch
end __classicObjectPropertiesFromType
private on __setPropertyDataOfObjectFromFile pObjectType, pFile, pPropInfoA
local tObjectData
# Get the data from the file
put URL ("file:" & pFile) into tObjectData
# Parse the file into a structure array
local tObjectPropertiesA, tCountsA, tGroupCountsA
set the itemdel to tab
local tDataStart, tDataA
put false into tDataStart
repeat for each line tLine in tObjectData
if tLine is empty then next repeat
if tLine begins with "-----" then
put true into tDataStart
next repeat
end if
local tLineDataA
put __propertyDataProcessLine(tLine) into tLineDataA
if tLineDataA["name"] is "type" then
put tLineDataA["label"] into sClassicObjectProperties[pObjectType]["type"]
next repeat
end if
# Allow 'display title' of classic controls to be specified in property definition file
if tLineDataA["name"] is "title" and not tDataStart then
put tLineDataA["label"] into sClassicObjectProperties[pObjectType]["title"]
next repeat
end if
if tDataStart is false then
next repeat
end if
local tPropertyName
put tLineDataA["name"] into tPropertyName
repeat for each key tOverride in tLineDataA
if tLineDataA[tOverride] is not empty then
put tLineDataA[tOverride] into pPropInfoA[tPropertyName][tOverride]
end if
end repeat
# Default can override to empty if it is the string "empty"
if tLineDataA["default"] is not empty then
if tLineDataA["default"] is "empty" then
put empty into tLineDataA["default"]
end if
put tLineDataA["default"] into pPropInfoA[tPropertyName]["default"]
end if
local tGroupLabel
put pPropInfoA[tPropertyName]["group"] into tGroupLabel
if tGroupLabel is empty then
put pPropInfoA[tPropertyName]["label"] into tGroupLabel
end if
if tGroupLabel is empty then
put tPropertyName into tGroupLabel
end if
put tGroupLabel into pPropInfoA[tPropertyName]["group"]
local tSection
put pPropInfoA[tPropertyName]["section"] into tSection
# The groups are ordered by their appearance in the spec file
if tGroupCountsA[tSection][tGroupLabel] is empty then
add 1 to tCountsA[tSection]["count"]
put tCountsA[tSection]["count"] into tGroupCountsA[tSection][tGroupLabel]
end if
put tGroupCountsA[tSection][tGroupLabel] into pPropInfoA[tPropertyName]["group_order"]
add 1 to tCountsA[tSection][tGroupLabel]["count"]
put tCountsA[tSection][tGroupLabel]["count"] into pPropInfoA[tPropertyName]["order"]
-- Put 'control properties' last
-- TODO: there should be a more transparent way of ordering these
if pObjectType is "com.livecode.interface.Control" then
add 1000 to pPropInfoA[tPropertyName]["group_order"]
end if
put pPropInfoA[tPropertyName] into sClassicObjectProperties[pObjectType]["properties"][tPropertyName]
put pPropInfoA[tPropertyName] into tObjectPropertiesA[tPropertyName]
end repeat
put __organisePropertyInfo(tObjectPropertiesA) into sClassicObjectPropertiesInfo[pObjectType]
end __setPropertyDataOfObjectFromFile
private function __propertyInfoFilename
return "propertyInfo.tsv"
end __propertyInfoFilename
private function __classicToolsOrderFilename
return "classicToolsOrder.tsv"
end __classicToolsOrderFilename
private on __orderClassicTools
local tToolsOrderFile
put revIDESpecialFolderPath("Object Property Definitions") & slash & __classicToolsOrderFilename() into tToolsOrderFile
local tOrder
repeat for each line tTool in url ("file:" & tToolsOrderFile)
add 1 to tOrder
put tOrder into sClassicObjectProperties[tTool]["order"]
end repeat
end __orderClassicTools
# Reads in the basic property data for classic controls
private on __objectPropertiesRead
put empty into sClassicObjectProperties
put empty into sClassicObjectPropertiesInfo
put empty into sClassicPropertiesInfo
# Set to folder to the path where the object definition files for classic controls are stored
local tObjectDefinitionsPath
put revIDESpecialFolderPath("Object Property Definitions") into tObjectDefinitionsPath
local tPropertiesInfo
put __propertyDataFromInfoFile(tObjectDefinitionsPath & slash & __propertyInfoFilename()) into tPropertiesInfo
revIDEPushDefaultFolder tObjectDefinitionsPath
# Read in each file and build an array
local tObjectType
repeat for each line tFile in the files
if not (tFile begins with "com.livecode.interface") then next repeat
if char 1 of tFile is "." then next repeat
put tFile into tObjectType
# Get the name of the object
set the itemdel to "."
if the last item of tObjectType is "tsv" then delete the last item of tObjectType
if tObjectType is empty then next repeat
__setPropertyDataOfObjectFromFile tObjectType, tObjectDefinitionsPath & slash & tFile, tPropertiesInfo
end repeat
__orderClassicTools
put tPropertiesInfo into sClassicPropertiesInfo
revIDEPopDefaultFolder
end __objectPropertiesRead
private function __orderPropSubArray pSectionA, pIsGroupList
local tSubKey
if pIsGroupList then
put "grouplist" into tSubKey
else
put "proplist" into tSubKey
end if
local tPropKeys, tWidgetPropKeys
repeat for each key tKey in pSectionA[tSubKey]
if pSectionA[tSubKey][tKey]["widget_prop"] then
if tWidgetPropKeys is empty then
put tKey into tWidgetPropKeys
else
put return & tKey after tWidgetPropKeys
end if
else
if tPropKeys is empty then
put tKey into tPropKeys
else
put return & tKey after tPropKeys
end if
end if
end repeat
sort lines of tPropKeys ascending numeric by pSectionA[tSubKey][each]["order"]
sort lines of tWidgetPropKeys ascending numeric by pSectionA[tSubKey][each]["order"]
local tKeys, tCount
put 1 into tCount
put tPropKeys into tKeys
if tWidgetPropKeys is not empty then
if tKeys is empty then
put tWidgetPropKeys into tKeys
else
put return & tWidgetPropKeys after tKeys
end if
end if
local tOrderedA
repeat for each line tProp in tKeys
if pIsGroupList then
put tProp into tOrderedA[tCount]["label"]
put pSectionA[tSubKey][tProp]["subsection"] into tOrderedA[tCount]["subsection"]
put __orderPropSubArray(pSectionA[tSubKey][tProp], false) into tOrderedA[tCount]["proplist"]
# Inherit the prop label if there is only one
if the number of elements in tOrderedA[tCount]["proplist"] is 1 then
put tOrderedA[tCount]["proplist"][1]["label"] into tOrderedA[tCount]["label"]
end if
else
if pSectionA[tSubKey][tProp]["popup"] is not empty then
put __orderPropSubArray(pSectionA[tSubKey][tProp]["popup"], true) into pSectionA[tSubKey][tProp]["popup"]
end if
put pSectionA[tSubKey][tProp] into tOrderedA[tCount]
put tProp into tOrderedA[tCount]["property_name"]
end if
add 1 to tCount
end repeat
return tOrderedA
end __orderPropSubArray
private function __orderPropArray pPropsA, pSections
local tOrderedPropsA,x
local tCount
put 1 into tCount
repeat for each item tSection in pSections
if pPropsA[tSection] is empty then next repeat
put __orderPropSubArray(pPropsA[tSection], true) into tOrderedPropsA[tCount]["grouplist"]
put tSection into tOrderedPropsA[tCount]["label"]
add 1 to tCount
end repeat
return tOrderedPropsA
end __orderPropArray
private function __objectPropertiesInfo pObjectType, pOrganiseInSections, pOptionalSection
local tPropertiesArray, tClassicObjectType
if not (pObjectType begins with "com.livecode.interface.classic") then
# This is not a classic object, so fetch the 'extension' properties.
put revIDEExtensionPropertiesInfo(pObjectType, pOrganiseInSections) into tPropertiesArray
# Currently this must be a widget, so get the universal widget property info
# that has been parsed from the definitions file
put "com.livecode.interface.classic.widget" into tClassicObjectType
else
put pObjectType into tClassicObjectType
end if
if pOrganiseInSections then
# Add the object properties for this object type
union tPropertiesArray with sClassicObjectPropertiesInfo[tClassicObjectType] recursively
# Restrict to group, if present
if pOptionalSection is not empty then
local tSectionProps
put tPropertiesArray[pOptionalSection] into tSectionProps[pOptionalSection]
put tSectionProps into tPropertiesArray
end if
else
union tPropertiesArray with sClassicObjectProperties[tClassicObjectType] recursively
end if
return tPropertiesArray
end __objectPropertiesInfo
private function __objectPropertiesShared pObjectTypeList, pOrganiseInSections, pOptionalSection
local tPropertiesArray,tPropertiesArray2, tPropertiesArray3,x, tSectionProps, tAllControls
put pObjectTypeList is not empty into tAllControls
repeat for each line tObjectType in pObjectTypeList
if not __objectTypeIsControl(tObjectType) then
put false into tAllControls
end if
if tPropertiesArray is empty then
put __objectPropertiesInfo(tObjectType, pOrganiseInSections, pOptionalSection) into tPropertiesArray
else
intersect tPropertiesArray with __objectPropertiesInfo(tObjectType, pOrganiseInSections, pOptionalSection) recursively
end if
end repeat
if tAllControls then
union tPropertiesArray with sClassicObjectPropertiesInfo["com.livecode.interface.Control"] recursively
end if
if pOptionalSection is not empty then
return tPropertiesArray[pOptionalSection]
else
return tPropertiesArray
end if
end __objectPropertiesShared
/**
Information pertaining to the property <pPropName>.
Parameters:
pPropName (string): One of the IDE canonical object property names.
Returns (array): An array of information pertaining to the given property.
Description:
This function returns the information pertaining to the object property <pPropName>,
parsed from the file Toolset/resources/supporting_files/property_definitions.
Information about synonyms is not returned by this function. For a list of the canonical
property names which are valid inputs to this function, see the <idePropertyNames>
function.
References: idePropertyNames (function)
**/
function revIDEPropertyInfo pPropName
if sClassicPropertiesInfo is empty then
__objectPropertiesRead
end if
return sClassicPropertiesInfo[pPropName]
end revIDEPropertyInfo
/**
A list of the object property names considered canonical by the IDE
Parameters:
pObjectType (optional string): One of the IDE's object type IDs
Returns (string): A list of the object property names, one per line.
Description:
This function returns a list of the object property names considered canonical by
the IDE, as parsed from the file Toolset/resources/supporting_files/property_definitions.txt.
If the <pObjectType> parameter is used, this returns a list of the properties specific to
that object type, as parsed from the files in Toolset/resources/supporting_files/.
For a list of the object type IDs which are valid inputs to this function, see the <ideObjectTypes>
function.
References: ideObjectTypes (function)
**/
function idePropertyNames pObjectType
if sClassicPropertiesInfo is empty or sClassicObjectPropertiesInfo is empty then
__objectPropertiesRead
end if
local tProps
if pObjectType is empty then
put the keys of sClassicPropertiesInfo into tProps
else
put the keys of sClassicObjectPropertiesInfo[pObjectType] into tProps
end if
sort tProps
return tProps
end idePropertyNames
/**
A list of the object types, in 'type ID' form
Returns (string): A list of the object types, one per line.
Description:
This function returns a list of the object types in the form used by the IDE.
**/
function ideObjectTypes
if sClassicObjectPropertiesInfo is empty then
__objectPropertiesRead
end if
local tTypes
put the keys of sClassicObjectPropertiesInfo into tTypes
sort tTypes
return tTypes
end ideObjectTypes
/**
Information pertaining to the property <pPropName> in the context of <pObjectType>.
Parameters:
pPropName (string): One of the IDE canonical object property names.
pObjectType (string): One of the IDE's object types.
Returns (array): An array of information pertaining to the given property.
Description:
This function returns the information pertaining to the object property <pPropName>,
parsed from the files in Toolset/resources/supporting_files/. In some cases an individual
property's data can be overridden for a particular object type.
For a list of the canonical property names which are valid inputs to this function, see the
<idePropertyNames> function. For a list of the object type IDs which are valid inputs
to this function, see the <ideObjectTypes> function.
References: idePropertyNames (function), ideObjectTypes (function)
**/
function revIDEObjectPropertyInfo pObjectType, pPropName
if sClassicObjectPropertiesInfo is empty then
__objectPropertiesRead
end if
return sClassicObjectPropertiesInfo[pObjectType][pPropName]
end revIDEObjectPropertyInfo
/**
A list of the IDE object types corresponding to the list of objects given
Parameters:
pObjectIDs: A list, one per line, of object IDs
Returns: A list, one per line, of the IDE object types associated with
the objects in <pObjectIDs>
**/
function ideObjectTypesFromObjectList pObjectIDs
local tObjectTypeList, tObjectType
repeat for each line tObjectID in pObjectIDs
put ideObjectTypeFromObject(tObjectID) into tObjectType
if tObjectType is not among the lines of tObjectTypeList then
put tObjectType & return after tObjectTypeList
end if
end repeat
delete the last char of tObjectTypeList
return tObjectTypeList
end ideObjectTypesFromObjectList
/**
The IDE object type corresponding to the given object
Parameters:
pObjectID: An object ID
Returns: The IDE object type associated with the objects <pObjectID>
Example:
create field
put ideObjectTypeFromObject(it) -- outputs com.livecode.interface.classic.Field
set the listBehavior of it to true
put ideObjectTypeFromObject(it) -- outputs com.livecode.interface.classic.ListField
Description:
>*Note:* The type returned by <ideObjectTypeFromObject> can depend
on the values of the object's properties.
**/
function ideObjectTypeFromObject pObjectID
switch word 1 of the name of pObjectID
case "stack"
if word 4 of pObjectID is "stack" then
return "com.livecode.interface.classic.Substack"
else
return "com.livecode.interface.classic.Stack"
end if
case "card"
return "com.livecode.interface.classic.Card"
case "group"
if the dgProps["control type"] of pObjectID is "Data Grid" then
if the dgProps["style"] of pObjectID is "Table" then
return "com.livecode.interface.classic.DataGrid"
else
return "com.livecode.interface.classic.DataGridForm"
end if
else
return "com.livecode.interface.classic.Group"
end if
break
case "field"
if revIDEGetTableProperty(pObjectID, "basicTableObject") then
return "com.livecode.interface.classic.TableField"
else if the listbehavior of pObjectID is true then
return "com.livecode.interface.classic.ListField"
else if the vscrollbar of pObjectID is true then
return "com.livecode.interface.classic.TextArea"
else
return "com.livecode.interface.classic.Field"
end if
break
case "button"
if the menumode of pObjectID is "combobox" then return "com.livecode.interface.classic.ComboBox"
switch the style of pObjectID
case "radiobutton"
return "com.livecode.interface.classic.RadioButton"
break
case "checkbox"
return "com.livecode.interface.classic.Checkbox"
break
case "menu"
switch the menumode of pObjectID
case "combobox"
return "com.livecode.interface.classic.ComboBox"
break
case "option"
return "com.livecode.interface.classic.OptionMenu"
break
case "pulldown"
return "com.livecode.interface.classic.PulldownMenu"
break
case "tabbed"
return "com.livecode.interface.classic.TabPanel"
break
case "popup"
case "cascade"
default
return "com.livecode.interface.classic.PopupMenu"
break
end switch
case "rectangle"
return "com.livecode.interface.classic.RectangleButton"
break
default
if the default of pObjectID is true then
return "com.livecode.interface.classic.DefaultButton"
else
return "com.livecode.interface.classic.Button"
end if
break
end switch
case "scrollbar"
switch the style of pObjectID
case "scale"
return "com.livecode.interface.classic.Slider"
break
case "progress"
return "com.livecode.interface.classic.ProgressBar"
break
case "scrollbar"
if the height of pObjectID > the width of pObjectID and the height of pObjectID < 54 then
return "com.livecode.interface.classic.LittleArrows"
else
return "com.livecode.interface.classic.Scrollbar"
end if
break
end switch
break
case "image"
return "com.livecode.interface.classic.Image"
break
case "player"
return "com.livecode.interface.classic.Player"
case "widget"
return the kind of pObjectID
break
case "graphic"
switch the style of pObjectID
case "text"
case "rectangle"
return "com.livecode.interface.classic.RectangleGraphic"
break
case "roundrect"
return "com.livecode.interface.classic.RoundRectGraphic"
break
case "line"
return "com.livecode.interface.classic.LineGraphic"
break
case "arc"
case "oval"
return "com.livecode.interface.classic.OvalGraphic"
break
case "curve"
return "com.livecode.interface.classic.CurveGraphic"
break
case "polygon"
return "com.livecode.interface.classic.PolygonGraphic"
break
case "regular"
return "com.livecode.interface.classic.RegularGraphic"
break
end switch
break
end switch
end ideObjectTypeFromObject
private function __dumpArrayRecurse pArray, pLevel, @pCounter, @pList
local tOrderedKeys
put the keys of pArray into tOrderedKeys
sort lines of tOrderedKeys numeric
repeat for each line tKey in tOrderedKeys
add 1 to pCounter
repeat for pLevel
put tab after line pCounter of pList
end repeat
put (tKey && "= ") after line pCounter of pList
if (the keys of pArray[tKey]) is empty then
put line 1 of pArray[tKey] after line pCounter of pList
else
put __dumpArrayRecurse(pArray[tKey], (pLevel + 1), pCounter, pList) into pList
end if
end repeat
return pList
end __dumpArrayRecurse
function __revIDEError pMessage
global gRevDevelopment
local tErrorContext, tErrorText, tLockedMessages
put line -2 of the executioncontexts into tErrorContext
# Unlock messages to ensure the errors get through to the message box
put the lockmessages into tLockedMessages
unlock messages
put "ERROR:" && pMessage & return & "line:" && item 3 of tErrorContext & return & "handler:" && item 2 of tErrorContext & return & "script object:" && item 1 of tErrorContext into tErrorText
# If in IDE development mode output the error to the Message Box
if gRevDevelopment is true then
put return & tErrorText after msg
end if
# if the messages were locked, lock them again
if tLockedMessages is true then
lock messages
end if
return tErrorText
end __revIDEError
on ideThrow pMessage, pResult
throw __revIDEError(pMessage & return & pResult)
end ideThrow
local sControlPropertiesToRead, sCardPropertiesToRead, sStackPropertiesToRead
function __readStructureOfStackForDataView @pData, pParent, pLevel, pIndex
local tStackIndex
# 1) Get desired properties for the current stack
dispatch function "__readPropertiesOfControlForDataView" to the target with sStackPropertiesToRead, pData,pParent, pLevel, pIndex
put the result into tStackIndex
-- # 2) Process any cards
-- local tChildCardIDs
-- put empty into tChildCardIDs
-- repeat with x = 1 to the number of cards of the target
-- # a) Get basic properties for the card
-- dispatch function "__readPropertiesOfControlForDataView" to card x of the target with sCardPropertiesToRead, pData, tStackIndex, pLevel + 1
-- local tCardIndex
-- put the result into tCardIndex
-- if tChildCardIDs is empty then
-- put tCardIndex into tChildCardIDs
-- else
-- put comma & tCardIndex after tChildCardIDs
-- end if
-- # b) Process the card container for all its controls
-- dispatch function "__readStructureOfContainerForDataView" to card x of the target with pData, tCardIndex, pLevel + 1
-- put the result into pData[tCardIndex]["children"]
-- put false into pData[tCardIndex]["expanded"]
-- put "container" into pData[tCardIndex]["style"]
-- put "card" into pData[tCardIndex]["type"]
-- end repeat
-- # 3) Process any subsctacks
-- repeat for each line tSubstack in the substacks of the target
-- if tChildCardIDs is empty then
-- put the number of elements of pData + 1 into tChildCardIDs
-- else
-- put comma & the number of elements of pData + 1 after tChildCardIDs
-- end if
-- dispatch function "__readStructureOfStackForDataView" to stack tSubstack with pData,tStackIndex, pLevel + 1
-- end repeat
-- put tChildCardIDs into pData[tStackIndex]["children"]
--put the number of cards of the target into pData[tStackIndex]["childCount"]
put the number of cards of the target & the number of lines in the substacks of the target into pData[tStackIndex]["childCount"]
put false into pData[tStackIndex]["expanded"]
put "container" into pData[tStackIndex]["style"]
put "stack" into pData[tStackIndex]["type"]
end __readStructureOfStackForDataView
--function __readStructureOfStackForDataView @pData, pParent, pLevel
-- # 1) Get desired properties for the current stack
-- dispatch function "__readPropertiesOfControlForDataView" to the target with sStackPropertiesToRead, pData,pParent, pLevel
-- local tStackIndex
-- put the result into tStackIndex
-- # 2) Process any cards
-- local tChildCardIDs
-- put empty into tChildCardIDs
-- repeat with x = 1 to the number of cards of the target
-- # a) Get basic properties for the card
-- dispatch function "__readPropertiesOfControlForDataView" to card x of the target with sCardPropertiesToRead, pData, tStackIndex, pLevel + 1
-- local tCardIndex
-- put the result into tCardIndex
-- if tChildCardIDs is empty then
-- put tCardIndex into tChildCardIDs
-- else
-- put comma & tCardIndex after tChildCardIDs
-- end if
-- # b) Process the card container for all its controls
-- dispatch function "__readStructureOfContainerForDataView" to card x of the target with pData, tCardIndex, pLevel + 1
-- put the result into pData[tCardIndex]["children"]
-- put false into pData[tCardIndex]["expanded"]
-- put "container" into pData[tCardIndex]["style"]
-- put "card" into pData[tCardIndex]["type"]
-- end repeat
-- # 3) Process any subsctacks
-- repeat for each line tSubstack in the substacks of the target
-- if tChildCardIDs is empty then
-- put the number of elements of pData + 1 into tChildCardIDs
-- else
-- put comma & the number of elements of pData + 1 after tChildCardIDs
-- end if
-- dispatch function "__readStructureOfStackForDataView" to stack tSubstack with pData,tStackIndex, pLevel + 1
-- end repeat
-- put tChildCardIDs into pData[tStackIndex]["children"]
-- put false into pData[tStackIndex]["expanded"]
-- put "container" into pData[tStackIndex]["style"]
-- put "stack" into pData[tStackIndex]["type"]
--end __readStructureOfStackForDataView
function __readStructureOfContainerForDataView @pData, pParentIndex, pLevel
# 1) Repeat for each control in the container
local tChildIDs, tChildCount
//repeat with x = 1 to the number of controls of the target
--repeat for each line tControlId in the childcontrolIDs of the target
put the number of lines in the childcontrolIDs of the target into tChildCount
repeat with x = 1 to the number of lines in the childcontrolIDs of the target
local tControlId
if revIDEGetPreference("ideProjectBrowser_sortOrder") is "bottom to top" then
put line x of the childcontrolIDs of the target into tControlId
else