-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
macOStools.lcb
executable file
·1483 lines (1286 loc) · 77.9 KB
/
macOStools.lcb
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
/**
This Library is a collection of macOS Cocoa and AppKit related FFI wrappers.
Description:
A collection of macOS Cocoa AppKit related handlers
>*Note:* This library is MIT licensed (permissive).
> Please share and share a like.
*/
library org.openxtalk.library.macosnativeapptools
use com.livecode.engine
use com.livecode.foreign
use com.livecode.objc
use com.livecode.array
use com.livecode.list
use com.livecode.binary
use com.livecode.string
metadata version is "1.0.2"
metadata author is "Paul McClernan"
metadata title is "Openxtalk.org macOS Native Tools"
metadata _ide is "true" -- ? default load at startup
metadata userVisible is "true" -- Show Widget in ... ?
metadata svgicon is "M66.43,52.07c-0.71,0.32-1.48,0.56-2.31,0.78c-2.35,0.65-5.44,0.04-5.44,0.04l-8.52,9.56c0,0,11.03,11.58,13.36,13.92 s4.02,6.19,4.02,6.19l8.77-19.76C76.31,62.8,67.18,58.92,66.43,52.07z M56.35,86.86c-2.83-2.4-16.4-15.09-16.4-15.09L21.22,90.12c0,0,3.25,1.93,5.41,1.86c5.6-0.17,10.48-3.77,15.46-3.77 c4.58,0,8.99,3.52,15.56,3.77c1.55,0.06,2.88-0.35,4.41-1.24c0.7-0.41,2.02-1.54,2.02-1.54S59.18,89.26,56.35,86.86z M52.45,18.42c5.85-5.85,5.42-15.63,5.42-15.63s-8.65,0.97-13.34,6.82c-5.22,6.51-5.07,13.39-4.94,14.51 C44.49,24.13,48.71,22.16,52.45,18.42z M18.38,48.03c-3.59,0.27-3.23,4.28-3.21,4.45l0.03,0.32l-0.23,0.23l-5.54,5.89l-5.85-5.95l8.91,24.95l18.58-18.16l-8.8-9.83 C22.28,49.93,19.79,47.92,18.38,48.03z M9.98,39.65c0,0,1.4-2.6,5.19-5.27c2.15-1.51,4.69-2.88,7.45-3.52c1.75-0.41,3.72-0.62,5.86-0.62 c3.63,0,9.12,1.35,9.12,1.35l-10.85,4.24c-1.77,0.8-2.58,2.62-2.85,3.38l14.4,13.75c3.71-3.62,6.78-6.15,9.99-9.57 c-0.51-4.23,0.89-8.11,3.22-10.81c4.73-5.48,13.47-2.78,13.47-2.78l-3.55,3.05c0,0-4.13,3.16-3.01,6.79 c0.27,0.87,0.84,2.34,2.44,3.17c0.93,0.48,4.09,0.37,5.6-0.95C68.48,40.1,70.45,38,70.45,38s0.88-1.54,1.8-2.43 c1.11-1.08,3.56-2.91,3.56-2.91s-4.82-5.38-8.14-6.83c-2.91-1.27-6.15-1.89-9.71-1.91c-7.4-0.03-12.83,4.65-16.7,4.35 c-3.19-0.25-9.47-4.38-14.6-4.35c-7.22,0.05-13.04,2.44-17.47,7.33C5.44,35.37,4,45.11,4,45.11l1.89-1.93c0,0,2.98-0.11,3.34-0.41 c1.48-1.24,1.31-2.33,1.31-2.33L9.98,39.65z M18.15,46.11c1.68-0.19,4.88,2.09,4.88,2.09l9.22,10.03l4.11-3.86L21.75,39.42l0.13-0.52c0.03-0.14,0.88-3.49,3.9-4.84 l5.18-2.02c-1.95-0.07-5.6-0.11-7.97,0.42c-3.26,0.74-8.73,4.32-10.78,7.04c0.06,0.17,0.09,0.34,0.1,0.53 c0.08,1.49-1.41,3.45-2.02,3.98c-0.73,0.63-2.55,1.03-3.63,1.21l-3.94,3.94l6.59,6.6l3.85-3.86c-0.04-1.6,0.45-3.4,1.78-4.57 C15.67,46.71,16.48,46.3,18.15,46.11z M70.95,39.93c-0.62,0.44-4.18,6.07-9.58,4.98c-2.9-0.58-4.65-3.5-4.92-5.3c-0.6-4.07,1.8-6.16,3.56-7.69 c0.59-0.52,1.6-1.31,1.6-1.31s-6.16-0.73-9.16,3.5c-3.98,5.61-1.98,9.83-1.98,9.83S13.22,80.66,12.03,81.82 c-0.09,0.56-0.5,3.71,0.93,5.31c1.56,1.74,3.06,2.79,5.34,2.24c1.3-0.32,39.44-38.44,39.44-38.44s3.65,0.56,5.67,0.07 C68.3,49.8,70.71,46.32,70.95,39.93z M65.52,84.81c-0.14,0.85-0.52,1.48-1.2,1.99c-0.5,0.41-1.12,0.62-1.88,0.62c-2.8,0-6.23-3.51-6.24-3.52L41.82,70.25 l6.44-6.55c0,0,13.44,13.7,14.11,14.36C63.03,78.73,65.79,83.22,65.52,84.81z"
-------------------- Type Declarations -------------------------------
public foreign type CGSize binds to "MCAggregateTypeInfo:qq"
public foreign type NSRect binds to "MCAggregateTypeInfo:qqqq"
public foreign type CGImageRef binds to "MCAggregateTypeInfo:r"
public foreign type CGPoint binds to "MCAggregateTypeInfo:qq"
-- private foreign handler objC_NSRangeMakeRange( in pStart as CUint, in pLegth as CUint)) returns ObjcId binds to "c:NSMakeRange"
-- NSMakeRange(0,100)
public foreign type NSRange binds to "MCAggregateTypeInfo:ii"
private variable sMyWindow as optional ObjcObject
private variable sMyWindowController as optional ObjcObject
--------------------- foreign handlers -------------------------------
private foreign handler objC_NSArrayAlloc() returns ObjcRetainedId binds to "objc:NSArray.+alloc"
private foreign handler objC_NSArrayComponentsJoinedByString(in pObj as ObjcId, in pSeperator as ObjcId) returns ObjcId binds to "objc:NSArray.-componentsJoinedByString:"
private foreign handler objC_NSApplicationSharedApplication() returns ObjcId binds to "objc:NSApplication.+sharedApplication"
private foreign handler objC_NSApplicationRequestUserAttention(in sharedApplication as ObjcId, in requestType as CLong) returns CLong binds to "objc:NSApplication.-requestUserAttention:"
private foreign handler objC_NSApplicationMiniaturizeAll( in sharedApplication as optional ObjcId, in pSenderID as optional any) returns nothing binds to "objc:NSApplication.-miniaturizeAll:"
private foreign handler objC_NSApplicationHide ( in sharedApplication as ObjcId, in pSenderID as optional any) returns nothing binds to "objc:NSApplication.-hide:"
private foreign handler objC_NSApplicationUnhide ( in sharedApplication as ObjcId, in pSenderID as optional any) returns nothing binds to "objc:NSApplication.-unhide:"
private foreign handler objC_NSApplicationWindowWithWindowNumber(in pSharedApplication as ObjcId, in pWindowNumber as CLong) returns ObjcId binds to "objc:NSApplication.-windowWithWindowNumber:"
private foreign handler objC_NSApplicationGetNSDockTile(in sharedApplication as ObjcId) returns ObjcId binds to "objc:NSApplication.-dockTile"
private foreign handler objC_NSApplicationSetAppearance(in pNSApp as ObjcId, in pAppearanceNameNSStr as ObjcId) returns nothing binds to "objc:NSApplication.-setAppearance:"
private foreign handler objC_NSApplicationGetAutoWindowTabbing(in pNSApp as ObjcId) returns optional any binds to "objc:NSApplication.-allowsAutomaticWindowTabbing:"
private foreign handler objC_NSApplicationSetAutoWindowTabbing(in pNSApp as ObjcId, in pAllow as CBool) returns nothing binds to "objc:NSApplication.-setAllowsAutomaticWindowTabbing:"
private foreign handler objC_NSApplicationSetAppIconImage(in pNSApp as ObjcId, in pNSImage as optional ObjcId) returns nothing binds to "objc:NSApplication.-setApplicationIconImage:"
private foreign handler ObjC_NSImageAlloc() returns ObjcRetainedId binds to "objc:NSImage.+alloc"
private foreign handler ObjC_NSImageInit(in pObj as ObjcRetainedId) returns ObjcId binds to "objc:NSImage.-init"
private foreign handler ObjC_NSImageInitWithContentsOfFile(in pObj as ObjcId, in pFilename as ObjcId) returns ObjcId binds to "objc:NSImage.-initWithContentsOfFile:"
private foreign handler objC_NSImageInitFromFile(in pPathNSString as ObjcId) returns ObjcId binds to "objc:NSImage.-initWithContentsOfFile:" -- correct!!!
private foreign handler ObjC_NSImageInitWithData(in pObj as ObjcRetainedId, in pData as ObjcId) returns optional ObjcRetainedId binds to "objc:NSImage.-initWithData:"
private foreign handler objC_NSProcessInfoAlloc() returns ObjcRetainedId binds to "objc:NSProcessInfo.+alloc"
private foreign handler objC_NSProcessInfoInit(in pInstance as ObjcId) returns ObjcId binds to "objc:NSProcessInfo.-init"
private foreign handler objC_NSDockTileSetBadgeLabelProp(in pNSDockTile as ObjcId, in pNSString as ObjcId, in pSelectorNSString as ObjcId ) returns nothing binds to "objc:NSDockTile.-setValue:forKey:"
private foreign handler objC_NSDockTileSetShowAppBadge(in pNSDockTile as ObjcId, in pValue as cBool, in pSelectorNSString as ObjcId) returns nothing binds to "objc:NSDockTile.-setValue:forKey:"
private foreign handler objC_NSDockTileDisplay(in pNSDockTile as ObjcId) returns nothing binds to "objc:NSDockTile.-display"
private foreign handler objC_NSUserNotificationCenterDefaultUserNotificationCenter() returns ObjcId binds to "objc:NSUserNotificationCenter.+defaultUserNotificationCenter"
private foreign handler objC_NSUserNotificationAlloc() returns ObjcRetainedId binds to "objc:NSUserNotification.+alloc"
private foreign handler objC_NSUserNotificationInit(in anInstance as ObjcId) returns ObjcId binds to "objc:NSUserNotification.-init"
private foreign handler objC_NSUserNotificationSetProperty(in Obj as ObjcId, in pValue as ObjcId, in pProp as ObjcId) returns nothing binds to "objc:NSUserNotification.-setValue:forKey:"
private foreign handler objC_NSUserNotificationCenterDeliverNotification(in defaultUserNotificationCenter as ObjcId, in aNotificationInstance as ObjcId) returns nothing binds to "objc:NSUserNotificationCenter.-deliverNotification:"
private foreign handler objC_NSDistributedNotificationCenterDefaultCenter() returns ObjcId binds to "objc:NSDistributedNotificationCenter.+defaultCenter"
private foreign handler objC_NSDistributedNotificationCenterPostNotificationNameObject(in defaultCenter as ObjcId, in notificationName as ObjcId, in notificationObject as ObjcId) returns nothing binds to "objc:NSDistributedNotificationCenter.-postNotificationName:object:"
private foreign handler objC_NSFileManagerSharedManager() returns ObjcId binds to "objc:NSFileManager.+defaultManager"
private foreign handler objC_NSFileManagerCurrentUserHomeURL(in pNSSharedFilemanager as ObjcId) returns ObjcId binds to "objc:NSFileManager.homeDirectoryForCurrentUser"
private foreign handler objC_NSFileManagerAttributesOfItemAtPath(in pNSSharedFilemanager as ObjcId, in pPathNSString as ObjcId, inout pNSError as optional ObjcId ) returns optional ObjcId binds to "objc:NSFileManager.-attributesOfItemAtPath:error:"
private foreign handler objC_NSFileManagerSetAttributesOfItemAtPath(in pNSSharedFilemanager as ObjcId, in pAtributesNSDict as ObjcId, in pPathNSString as ObjcId, inout pNSError as optional ObjcId ) returns cBool binds to "objc:NSFileManager.-setAttributes:ofItemAtPath:error:"
private foreign handler objC_NSAppleScriptAlloc() returns ObjcRetainedId binds to "objc:NSAppleScript.+alloc"
private foreign handler objC_NSAppleScriptInitWithSource( in pNSAppleScript as ObjcId, in pNSStringAppleScript as ObjcId) returns ObjcId binds to "objc:NSAppleScript.-initWithSource:"
private foreign handler objC_NSAppleScriptCompileAndReturnError( in pNSAppleScript as ObjcId, inout rErrorNSDict as optional ObjcId) returns CBool binds to "objc:NSAppleScript.-compileAndReturnError:"
private foreign handler objC_NSAppleScriptExecuteAndReturnError( in pNSAppleScript as ObjcId, inout rErrorNSDict as optional ObjcId) returns CBool binds to "objc:NSAppleScript.-executeAndReturnError:"
private foreign handler objC_NSAppleScriptGetRichTextSource( in pNSAppleScript as ObjcId) returns optional ObjcId binds to "objc:NSAppleScript.richTextSource"
private foreign handler ObjC_NSWorkspaceSharedWorkspace() returns ObjcId binds to "objc:NSWorkspace.+sharedWorkspace"
private foreign handler ObjC_NSWorkspaceSelectFile(in pSharedWorkspace as ObjcId, in pFilename as ObjcId, in pRootedAtPath as ObjcId) returns CBool binds to "objc:NSWorkspace.-selectFile:inFileViewerRootedAtPath:"
private foreign handler ObjC_NSWorkspaceIsFilePackageAtPath(in pSharedWorkspace as ObjcId, in pFilename as ObjcId) returns CBool binds to "objc:NSWorkspace.-isFilePackageAtPath:"
private foreign handler ObjC_NSWorkspaceRunningApplications(in pSharedWorkspace as ObjcId) returns ObjcId binds to "objc:NSWorkspace.-runningApplications"
private foreign handler ObjC_NSWorkspaceLaunchApplication(in pSharedWorkspace as ObjcId, in pAppName as ObjcId) returns CBool binds to "objc:NSWorkspace.launchApplication:"
private foreign handler ObjC_NSWorkspaceFrontmostApplication(in pSharedWorkspace as ObjcId) returns ObjcId binds to "objc:NSWorkspace.-frontmostApplication"
private foreign handler ObjC_NSWorkspaceURLForAppBundleID(in pSharedWorkspace as ObjcId, in pBundleID as ObjcId ) returns ObjcId binds to "objc:NSWorkspace.-URLForApplicationWithBundleIdentifier:"
private foreign handler ObjC_NSRunningApplicationBundleIdentifier(in pObj as ObjcId) returns optional ObjcId binds to "objc:NSRunningApplication.-bundleIdentifier"
private foreign handler ObjC_NSRunningApplicationProcessIdentifier(in pObj as ObjcId) returns CInt binds to "objc:NSRunningApplication.-processIdentifier"
private foreign handler objC_NSURLURLWithString(in pURLString as ObjcId) returns ObjcId binds to "objc:NSURL.+URLWithString:"
private foreign handler objC_NSURLfileOrDirURLWithPath(in pPathString as ObjcId, in pIsDir as CBool) returns ObjcId binds to "objc:.NSURL.+fileURLWithPath:isDirectory:"
private foreign handler objC_NSURLfileURLWithPath(in pPathString as ObjcId) returns ObjcId binds to "objc:NSURL.+fileURLWithPath:"
private foreign handler objC_NSURLGetAbsoluteString(in pURLString as ObjcId) returns ObjcId binds to "objc:NSURL.absoluteString"
private foreign handler objC_NSURLGetPath(in pURLString as ObjcId) returns ObjcId binds to "objc:NSURL.path"
private foreign handler c_NSClassFromString(in pClassNameString as ObjcId) returns ObjcId binds to "c:NSClassFromString"
private foreign handler objC_NSErrorAlloc() returns ObjcRetainedId binds to "objc:NSError.+alloc"
private foreign handler objC_NSObjectRetain(in pNSObj as ObjcId) returns ObjcId binds to "objc:NSObject.-retain"
private foreign handler objC_NSObjectAutoRealease(in pNSObj as ObjcId) returns ObjcId binds to "objc:NSObject.-autorelease"
private foreign handler objC_NSObjectRelease(in pNSObj as ObjcId) returns nothing binds to "objc:NSObject.-release"
private foreign handler objC_NSObjectDescription(in pNSObj as optional ObjcId) returns ObjcId binds to "objc:NSObject.description"
private foreign handler objC_NSObjectClassName(in pNSObj as ObjcId) returns ObjcId binds to "objc:NSObject.className"
private foreign handler objC_NSObjectGetSuperClass(in pNSObj as ObjcId) returns ObjcRetainedId binds to "c:NObject.+superclass:"
private foreign handler objC_NSObjectSetValueForKey(in pAVAUSampler as ObjcId, in pValue as ObjcId, in pSelector as ObjcId) returns optional ObjcId binds to "objc:NSObject.-setValue:forKey:"
private foreign handler objC_NSObjectGetValueForKey(in pNSObject as ObjcId, in pSelector as ObjcId) returns optional ObjcId binds to "objc:NSObject.-valueForKey:"
private foreign handler ObjC_NSBundleWithURL(in pNSURL as ObjcId) returns ObjcId binds to "objc:NSBundle.+bundleWithURL:"
private foreign handler ObjC_NSBundleGetClassNamed(in pNSbundle as ObjcId,in pClassNameNSString as ObjcId) returns ObjcId binds to "objc:NSBundle.-classNamed:"
private foreign handler objC_NSMutableArrayAlloc() returns ObjcRetainedId binds to "objc:NSMutableArray.+alloc"
private foreign handler objC_NSMutableArrayInitWithCapacity(in pNSMutableArray as ObjcId, in pCapacity as NaturalFloat) returns ObjcId binds to "objc:NSMutableArray.-initWithCapacity:"
private foreign handler objC_NSMutableArrayInitWithNSArray(in pNSMutableArray as ObjcId, in pNSArray as ObjcId) returns ObjcId binds to "objc:NSMutableArray.-initWithArray:"
private foreign handler c_CFErrorCopyDescription(in pCFErrorRef as ObjcId) returns ObjcId binds to "c:CFErrorCopyDescription"
private foreign handler objC_NSAttributedStringLength(in pNSAttributedString as ObjcId) returns CUint binds to "objc:NSAttributedString.length"
private foreign handler objC_NSAttributedStringString(in pNSAttributedString as ObjcId) returns ObjcId binds to "objc:NSAttributedString.string"
private foreign handler ObjC_NSWindowAlloc() returns ObjcRetainedId binds to "objc:NSWindow.+alloc"
private foreign handler ObjC_NSWindowInitWithRectStyleBackingDefer(in pObj as ObjcRetainedId, in pRect as NSRect, in pStyleMask as CLong, in pBackingStoreType as CLong, in pDefer as CBool) \
returns ObjcId binds to "objc:NSWindow.-initWithContentRect:styleMask:backing:defer:"
--private foreign handler ObjC_NSWindowInitWithRectStyleBackingDefer(in pObj as ObjcRetainedId, in pRect as NSRect, in pStyleMask as CLong, in pBackingStoreType as CLong, in pDefer as CBool) returns ObjcId binds to "objc:NSWindow.-initWithContentRect:styleMask:backing:defer:"
private foreign handler ObjC_NSWindowCreateWithViewController(in pNSViewController as ObjcId) returns ObjcRetainedId binds to "objc:NSWindow.+windowWithContentViewController:"
private foreign handler ObjC_NSWindowDealloc(in pNSViewController as ObjcId) returns nothing binds to "objc:NSWindow.-dealloc"
private foreign handler ObjC_NSWindowSetContentView(in pNSWindow as ObjcId, in pNSView as ObjcId) returns nothing binds to "objc:NSWindow.-setContentView:"
private foreign handler ObjC_NSWindowSetValueForKey( in pNSWindow as ObjcId, in pValue as ObjcRetainedId, in pSelector as ObjcId) returns nothing binds to "objc:NSWindow.-setValue:forKey:"
private foreign handler ObjC_NSWindowGetValueForKey( in pNSWindow as ObjcId, in pSelector as ObjcId) returns optional ObjcId binds to "objc:NSWindow.-valueforKey:"
private foreign handler ObjC_NSWindowSIntValueForKey( in pNSWindow as ObjcId, in pValue as CSInt, in pSelector as ObjcId) returns nothing binds to "objc:NSWindow.-setValue:forKey:"
private foreign handler ObjC_NSWindowUIntValueForKey( in pNSWindow as ObjcId, in pValue as CUInt, in pSelector as ObjcId) returns nothing binds to "objc:NSWindow.-setValue:forKey:"
private foreign handler ObjC_NSWindowSetTitle(in pNSWindow as ObjcId, in pTitleNSStr as ObjcId) returns nothing binds to "objc:NSWindow.-setTitle:"
private foreign handler ObjC_NSWindowSetTitleVisibility(in pNSWindow as ObjcId, in pVisibleUnum as ObjcId) returns nothing binds to "objc:NSWindow.-setTitleVisibility:"
private foreign handler ObjC_NSWindowSetAppearance(in pNSWindow as ObjcId, in pAppearanceNameNSStr as ObjcId) returns nothing binds to "objc:NSWindow.-setAppearance:"
-- private foreign handler ObjC_NSWindowGetAppearance(in pNSWindow as ObjcId, in pAppearanceNameNSStr as ObjcId) returns ObjcId binds to "objc:NSWindow.-appearance:"
private foreign handler ObjC_NSWindowPerformMiniaturize(in pNSWindow as ObjcId, in pSenderID as optional any) returns nothing binds to "objc:NSWindow.-performMiniaturize:" -- (void)performMiniaturize:(id)sender;
private foreign handler ObjC_NSWindowDeminiaturize(in pNSWindow as ObjcId, in pSenderID as ObjcId) returns nothing binds to "objc:NSWindow.-deminiaturize:"
private foreign handler ObjC_NSWindowIsMiniaturized(in pNSWindow as ObjcId) returns CBool binds to "objc:NSWindow.isMiniaturized"
private foreign handler ObjC_NSWindowGetStyleMask(in pNSWindow as ObjcId) returns CLong binds to "objc:NSWindow.-styleMask"
private foreign handler ObjC_NSWindowSetStyleMask(in pNSWindow as ObjcId, in pOptions as CInt) returns nothing binds to "objc:NSWindow.-setStyleMask:"
private foreign handler ObjC_NSWindowGetFrameRect(in pNSWindow as ObjcId) returns NSRect binds to "objc:NSWindow.frame"
private foreign handler ObjC_NSWindowTabbingModeInt(in pNSWindow as ObjcId, in pNSStringMode as CUInt) returns nothing binds to "objc:NSWindow.-setTabbingMode:"
private foreign handler ObjC_NSWindowSetTabbingModeNSObj(in pNSWindow as ObjcId, in pNSStringMode as ObjcId) returns nothing binds to "objc:NSWindow.-setTabbingMode:"
private foreign handler ObjC_NSWindowTabbedWindows(in pNSWindow as ObjcId) returns optional any binds to "objc:NSWindow.tabbedWindows"
private foreign handler ObjC_NSWindowAllowsAutoTabbing(in pNSWindow as ObjcId) returns optional CBool binds to "objc:NSWindow.-allowsAutomaticWindowTabbing:"
private foreign handler objC_NSWindowMergeAllWindowsMth( in pNSWindow as ObjcId, in pSenderNSObj as optional ObjcId ) returns nothing binds to "objc:NSWindow.mergeAllWindows:"
private foreign handler objC_NSWindowMergeAllWindows(in pNSWindow1 as ObjcId, in pSenderID as optional ObjcId ) returns nothing binds to "objc:NSWindow.-mergeAllWindows:"
private foreign handler objC_NSWindowMergeWindows(in pNSWindow as optional ObjcId, in pSenderID as optional ObjcId) returns nothing binds to "objc:NSWindow.-mergeAllWindows:"
private foreign handler ObjC_NSWindowToggleTabBar(in pNSWindow as ObjcId, in pSenderID as optional ObjcId) returns nothing binds to "objc:NSWindow.-toggleTabBar:"
private foreign handler ObjC_NSWindowToggleTabOverview(in pNSWindow as ObjcId, in pSenderID as ObjcId) returns nothing binds to "objc:NSWindow.-toggleTabOverview:"
-- private foreign handler ObjC_NSWindowTabGroupAlloc() returns ObjcRetainedId binds to "objc:NSWindowTabGroup.+alloc"
private foreign handler ObjC_NSWindowTabGroupInit(in pNSWindow as ObjcRetainedId) returns optional ObjcId binds to "objc:NSWindow.-tabGroup"
private foreign handler ObjC_NSWindowTabGroupAddWindow(in pNSWindowTabGroup as ObjcRetainedId, in pNSWindow as optional ObjcId) returns nothing binds to "objc:NSWindowTabGroup.-addWindow:"
-- Adds a window to the tab group.
private foreign handler ObjC_NSWindowAddTabbedWindow(in pNSWindow as ObjcId, in tSender as optional ObjcId, in pNSWindowOrderingMode as CUInt ) returns nothing binds to "objc:NSWindow.-addTabbedWindow:ordered:"
-- NSStringFromRect is handy when used in conjunction with Log for printing debug messages:
private foreign handler c_NSStringFromRect(in pNSRect as NSRect) returns ObjcId binds to "c:NSStringFromRect"
-- c_NSRectFromString is super handy, it parses an NSstring for four numbers in order orig x, orig y, width, height:
private foreign handler c_NSRectFromString(in pNSString as ObjcId) returns optional NSRect binds to "c:NSRectFromString"
private foreign handler ObjC_NSWindowSetLevel(in pNSWindow as ObjcId, in pLevel as CInt) returns nothing binds to "objc:NSWindow.-setLevel:"
private foreign handler ObjC_NSWindowGetLevel(in pNSWindow as ObjcId) returns CInt binds to "objc:NSWindow.-level"
private foreign handler ObjC_NSWindowGetReleasedWhenClosed(in pNSWindow as ObjcId) returns CBool binds to "objc:NSWindow.isReleasedWhenClosed"
private foreign handler ObjC_NSWindowSetCollectionBehavior(in pNSWindow as ObjcId, in collectionBehavior as CLong) returns nothing binds to "objc:NSWindow.-setCollectionBehavior:"
private foreign handler ObjC_NSWindowGetCollectionBehavior(in pNSWindow as ObjcId) returns CLong binds to "objc:NSWindow.-collectionBehavior"
private foreign handler ObjC_NSWindowToggleFullScreen(in pNSWindow as optional ObjcId, in pSenderID as optional any) returns nothing binds to "objc:NSWindow.-toggleFullScreen:"
private foreign handler ObjC_NSWindowSetContentViewController(in pNSWindow as ObjcId, in pViewController as ObjcId) returns nothing binds to "objc:NSWindow.-setContentView:"
private foreign handler ObjC_NSWindowGetContentViewController(in pOpNSWindowbj as ObjcId) returns ObjcId binds to "objc:NSWindow.-contentViewController"
private foreign handler ObjC_NSWindowGetWindowController(in pNSWindow as ObjcId) returns ObjcId binds to "objc:NSWindow.-windowController"
private foreign handler ObjC_NSWindowGetRootViewController(in pNSWindow as ObjcId) returns ObjcId binds to "objc:NSWindow.rootViewController"
private foreign handler ObjC_NSWindowSetBoolValueForKey( in pNSWindow as ObjcId, in pValue as CBool, in pSelector as ObjcId) returns nothing binds to "objc:NSWindow.-setValue:forKey:"
private foreign handler ObjC_NSWindowGetBoolValueForKey( in pNSWindow as ObjcId, in pSelector as ObjcId) returns CBool binds to "objc:NSWindow.-valueForKey:"
private foreign handler ObjC_NSWindowControllerAlloc() returns ObjcRetainedId binds to "objc:NSWindowController.+alloc"
private foreign handler ObjC_NSWindowControllerDealloc(in pNSWindowController as ObjcId) returns nothing binds to "objc:NSWindowController.-dealloc"
private foreign handler ObjC_NSWindowControllerInitWithWindow(in pNSWindowController as ObjcRetainedId,in pNSWindow as ObjcRetainedId) returns ObjcId binds to "objc:NSWindowController.-initWithWindow:"
--private foreign handler ObjC_NSWindowControllerInitWithWindow(in pObj as ObjcId,in pNSWindow as ObjcId) returns ObjcId binds to "objc:NSWindowController.-initWithWindow:"
private foreign handler ObjC_NSWindowControllerShowWindow(in pNSWindowController as ObjcId,in pNSWindow as ObjcId) returns nothing binds to "objc:NSWindowController.-showWindow:"
private foreign handler ObjC_NSWindowControllerClose(in pNSWindowController as ObjcId) returns nothing binds to "objc:NSWindowController.-close"
private foreign handler ObjC_NSWindowControllerLoadWindow(in pNSWindowController as ObjcId) returns nothing binds to "objc:NSWindowController.-LoadWindow"
-- NSWindowController.LoadWindow
private foreign handler ObjC_NSAppearanceNewAppearanceNamed(in pNSStringAppearanceName as ObjcId) returns ObjcId binds to "objc:NSAppearance.+appearanceNamed:"
private foreign handler ObjC_NSViewControllerAlloc() returns ObjcRetainedId binds to "objc:NSViewController.+alloc"
private foreign handler ObjC_NSViewControllerDealloc(in pNSViewController as ObjcId) returns nothing binds to "objc:NSViewController.-dealloc"
--------------------- Private handlers
private handler LogNSObjectClassName(in tNSObj as optional ObjcId)
variable tOSStatus as CSInt
variable tNSStrObj as optional ObjcId
variable tStr as optional String
if tNSObj is not nothing then
unsafe
put objC_NSObjectClassName(tNSObj) into tNSStrObj
put StringFromNSString(tNSStrObj) into tStr
log tStr
end unsafe
else
log "No Object"
end if
end handler
private handler _NSWindowFromWindowID(in tWindowID as Integer) returns ObjcId
variable tNSSharedApplication as ObjcId
variable tNSWindow as ObjcId
unsafe
put objC_NSApplicationSharedApplication() into tNSSharedApplication
put objC_NSApplicationWindowWithWindowNumber(tNSSharedApplication, tWindowID) into tNSWindow
end unsafe
return tNSWindow
end handler
private handler _NSWindowGetCollectionBehavior(in pNSWindow as ObjcId) returns CLong
variable collectionBehavior as CLong
unsafe
put ObjC_NSWindowGetCollectionBehavior(pNSWindow) into collectionBehavior
end unsafe
return collectionBehavior
end handler
private handler NSArrayToString(in pNSArray as ObjcObject) returns String
variable tNSArray as ObjcObject
variable tNSString as ObjcObject
variable tStr as String
put "\n" into tStr
unsafe
put ObjC_NSArrayComponentsJoinedByString(pNSArray, StringToNSString(tStr)) into tNSString
end unsafe
return StringFromNSString(tNSString)
end handler
public handler getIntegerFromFourCharCodeLittleEndian(in pStr as String) returns optional Uint32
variable tUint32 as Uint32
put (the code of char 4 of pStr) * 16777216 into tUint32 --- 256 * 256 * 256
put tUint32 + ((the code of char 3 of pStr) * 65536 ) into tUint32 -- 256 * 256
put tUint32 + ((the code of char 2 of pStr) * 256 ) into tUint32
put tUint32 + (the code of char 1 of pStr) into tUint32
return tUint32
end handler
public handler getIntegerFromFourCharCodeBigEndian(in pStr as String) returns optional Uint32
variable tUint32 as Uint32
put (the code of char 1 of pStr) * 16777216 into tUint32
put tUint32 + ((the code of char 2 of pStr) * 65536 ) into tUint32
put tUint32 + ((the code of char 3 of pStr) * 256 ) into tUint32
put tUint32 + (the code of char 4 of pStr) into tUint32
return tUint32
end handler
-- foreign handler MCDataGetBytePtr(in pData as Data) returns Pointer binds to "<builtin>"
public handler getFourCharCodeFromUint32( in pNum as optional any) returns optional String
-- 1383023468 = appl
variable tStr as String
variable tTempStr as String
variable tNum as Number
variable tBinsStr as String
-- log pNum
if pNum is not nothing then
if pNum is a number then
put pNum formatted as string into pNum
end if
put pNum converted from base 10 to base 16 into tBinsStr
if (the number of chars in tBinsStr) < 8 then
put 8 - (the number of chars in tBinsStr) into tNum
repeat tNum times
put "0" before tBinsStr
end repeat
-- log tBinsStr
end if
put ( (char 1 to 2 of tBinsStr) converted from base 16 to base 10 ) into tTempStr
put the char with code (tTempStr parsed as number) into tStr
put ( (char 3 to 4 of tBinsStr) converted from base 16 to base 10 ) into tTempStr
put the char with code (tTempStr parsed as number) after tStr
put ( (char 5 to 6 of tBinsStr) converted from base 16 to base 10 ) into tTempStr
put the char with code (tTempStr parsed as number) after tStr
put ( (char 7 to 8 of tBinsStr) converted from base 16 to base 10 ) into tTempStr
put the char with code (tTempStr parsed as number) after tStr
return tStr
else
return the empty string
end if
end handler
public handler getBitFeild( in pNum as optional any) returns optional String
if pNum is not nothing then
variable tStr as String
variable tNum as Number
put pNum converted to base 2 into tStr
if (the number of chars in tStr) < 32 then
put 32 - (the number of chars in tStr) into tNum
repeat tNum times
put "0" before tStr
end repeat
end if
put tStr converted from base 2 into tNum
log tNum
return tStr
else
return "0"
end if
end handler
--------------------------------------------------------------------------------
----------------------------- Public handlers ----------------------------------
--------------------------------------------------------------------------------
public handler macOSVersion() returns String
variable tNSProcessInfo as ObjcObject
variable tString as String
-- unsafe
-- put objC_NSProcessInfoAlloc() into tNSProcessInfo
-- put objC_NSProcessInfoInit(tNSProcessInfo) into tNSProcessInfo
-- LogNSObjectClassName(tNSProcessInfo)
-- @property(readonly) NSOperatingSystemVersion operatingSystemVersion;
-- operatingSystemVersion & operatingSystemVersionString return the 10.16.x format instead of 11.x
-- this shell command is the only thing I could find that returns the correct version
-- end unsafe
execute script "return shell(\qsw_vers -productVersion\q)"
put the result into tString
return tString
end handler
public handler appleScriptObjTests(in pAppleScript as String) returns any
variable tNSAppleScriptObj as ObjcObject
variable rErrorDictionary as optional ObjcObject
variable tSuccess as Boolean
variable tNSPath as optional ObjcObject
variable tNSURLAtribString as optional ObjcObject
variable tNSString as optional ObjcId
variable tString as String
variable tNSNumber as optional ObjcObject
variable tCUInt as optional CUint
variable tNSRange as optional NSRange
variable tAttributesArray as optional Array
unsafe
put objC_NSAppleScriptAlloc() into tNSAppleScriptObj
-- put ArrayToNSDictionary(the empty array) into rErrorDictionary
-- log tSharedFileManager`
-- LogNSObjectClassName(tNSAppleScriptObj)
-- put objC_NSErrorAlloc() into rNSError
-- LogNSObjectClassName(rNSError)
--put nothing into rErrorDictionary
put objC_NSAppleScriptInitWithSource( tNSAppleScriptObj, StringToNSString(pAppleScript)) into tNSAppleScriptObj
LogNSObjectClassName(tNSAppleScriptObj)
put objC_NSAppleScriptCompileAndReturnError(tNSAppleScriptObj , rErrorDictionary ) into tSuccess
-- put objC_NSAppleScriptExecuteAndReturnError(tNSAppleScriptObj , rErrorDictionary ) into tSuccess
if tSuccess then
-- put 0 into tCUInt
-- put tCUInt into element 1 of tNSRange --- start
put objC_NSAppleScriptGetRichTextSource(tNSAppleScriptObj) into tNSURLAtribString
LogNSObjectClassName(tNSURLAtribString)
put objC_NSAttributedStringLength(tNSURLAtribString) into tCUInt
log tCUInt
put objC_NSAttributedStringString(tNSURLAtribString) into tNSString
put StringFromNSString(tNSString) into tString
log tString
-- put StringFromNSString( tNSURLAtribString ) into tString
-- put ArrayFromNSDictionary(tNSURLAtribString) into tAttributesArray
-- log [the keys of tAttributesArray]
--return tSuccess
-- put nothing into tNSRange
-- put tCUInt into element 2 of tNSRange --- legth
-- log tNSRange
else
put ArrayFromNSDictionary(rErrorDictionary) into tAttributesArray
log tAttributesArray
--return tSuccess
end if
--return getFourCharCodeFromUint32(tAttributesArray["NSFileHFSCreatorCode"]) &"\n"& getFourCharCodeFromUint32(tAttributesArray["NSFileHFSTypeCode"])
-- put objC_NSURLGetAbsoluteString(tUserHomeDir) into tNSURLString
-- put objC_NSURLGetPath(tUserHomeDir) into tNSPath
-- return StringFromNSString(tNSPath)
-- return StringFromNSString(tUserHomeDir)
-- put objC_NSURLGetPath(tUserHomeDir) into tNSPath
-- return ( StringFromNSString(tNSURLString) & "\n" & StringFromNSString(tNSPath) )
end unsafe
return tSuccess
end handler
/**
Summary: Returns the users home directory as URL and as a Path.
Returns: Users home directory as a URL string and as a Path string seperated by a newline.
*/
public handler GetrCurrentUserHome() returns any
variable tSharedFileManager as ObjcObject
variable tUserHomeDir as optional ObjcObject
variable tUserHomeDirStr as optional String
variable tNSUrl as optional ObjcObject
variable tNSPath as optional ObjcObject
variable tNSURLString as optional ObjcObject
variable tNSString as optional ObjcObject
unsafe
put objC_NSFileManagerSharedManager() into tSharedFileManager
-- log tSharedFileManager
-- LogNSObjectClassName(tSharedFileManager)
put objC_NSFileManagerCurrentUserHomeURL(tSharedFileManager) into tUserHomeDir
-- log tUserHomeDir
-- LogNSObjectClassName(tUserHomeDir) --- should log NSURL
put objC_NSURLGetAbsoluteString(tUserHomeDir) into tNSURLString
put objC_NSURLGetPath(tUserHomeDir) into tNSPath
return ( StringFromNSString(tNSURLString) & "\n" & StringFromNSString(tNSPath) )
end unsafe
-- return ""
end handler
/**
Summary: Reveals a file or folder in the Finder.
Parameters:
pFilePath: Path to the file or folder to reveal.
Returns: Boolean
*/
public handler RevealFileInFinder(in pFilePath as String) returns Boolean
variable sharedWorkspace as ObjcObject
variable tStatus as Boolean
unsafe
put ObjC_NSWorkspaceSharedWorkspace() into sharedWorkspace
put ObjC_NSWorkspaceSelectFile(sharedWorkspace, StringToNSString(pFilePath), StringToNSString("")) into tStatus
end unsafe
return tStatus
end handler
/**
Summary: retrieves Mac HFS Creator and Type Codes Of File.
Parameters:
pPathToFile: Path to the file to examine.
Returns: A two-line list. Line 1 is creator code. Line 2 is the file type code, or empty property is not set.
Description:
Retrieves the Mac HFS (Hierarchial File System) creator and type codes of a file.
Returns empty if the file does not have HFS type codes set, otherwise a two-line
list will be returned. Line 1 is creator code. Line 2 is the file type code.
NOTE: Mac HFS Type and Creator Codes are legacy macOS classic file system attributes
which have long been marked as 'deprecatred' by Apple, however since this potentially
effects many legacy files, Apple has included HFS Type and Creator in the
contemporary APFS file system.
*/
public handler GetHFSCreatorTypeCodesOfFile(in pPathToFile as String) returns any
variable tSharedFileManager as ObjcObject
variable rNSError as optional ObjcObject
variable tAttributesNSDict as optional ObjcObject
variable tNSPath as optional ObjcObject
variable tNSURLString as optional ObjcObject
variable tNSString as optional ObjcObject
variable tAttributesArray as optional Array
unsafe
put objC_NSFileManagerSharedManager() into tSharedFileManager
-- log tSharedFileManager
-- LogNSObjectClassName(tSharedFileManager)
put objC_NSErrorAlloc() into rNSError
-- LogNSObjectClassName(rNSError)
put nothing into rNSError
put objC_NSFileManagerAttributesOfItemAtPath( tSharedFileManager, StringToNSString(pPathToFile), rNSError) into tAttributesNSDict
LogNSObjectClassName(rNSError)
LogNSObjectClassName(tAttributesNSDict) --- should log 'NSDictionary'?
put ArrayFromNSDictionary(tAttributesNSDict) into tAttributesArray
log tAttributesArray
return getFourCharCodeFromUint32(tAttributesArray["NSFileHFSCreatorCode"]) &"\n"& getFourCharCodeFromUint32(tAttributesArray["NSFileHFSTypeCode"])
-- put objC_NSURLGetAbsoluteString(tUserHomeDir) into tNSURLString
-- put objC_NSURLGetPath(tUserHomeDir) into tNSPath
-- return StringFromNSString(tNSPath)
-- return StringFromNSString(tUserHomeDir)
-- put objC_NSURLGetPath(tUserHomeDir) into tNSPath
-- return ( StringFromNSString(tNSURLString) & "\n" & StringFromNSString(tNSPath) )
end unsafe
-- return ""
end handler
/**
Summary: Sets the Mac HFS Creator Code of a file.
Parameters:
pFilePath: Path to the file to examine.
pFourCharOSType: An 'OSType' four character creator code, such as 'WILD' or 'OXTk'
Returns: true on success, otherwise false
Description:
Sets the Mac HFS Creator Code of a file. A creator code is a four-character
'OSType' code, such as 'WILD' or 'OXTk, used to associate an application with
a file for legacy classic macOS files.
NOTE: Mac HFS Type and Creator Codes are legacy macOS classic file system attributes
which have long been marked as 'deprecatred' by Apple, however since this potentially
effects many legacy files, Apple has included HFS Type and Creator in the
contemporary APFS file system.
*/
public handler SetHFSCreatorCodeOfFile( in pPathToFile as String, in pFourCharOSType as String ) returns any
variable tSharedFileManager as ObjcObject
variable rNSError as optional ObjcObject
variable tAttributesNSDict as optional ObjcObject
variable tNSPath as optional ObjcObject
variable tNSURLString as optional ObjcObject
variable tNSString as optional ObjcObject
variable tAttributesArray as optional Array
variable tStatus as Boolean
variable tOSType as UInt32
unsafe
put objC_NSFileManagerSharedManager() into tSharedFileManager
-- log tSharedFileManager
-- LogNSObjectClassName(tSharedFileManager)
put objC_NSErrorAlloc() into rNSError
-- LogNSObjectClassName(rNSError)
put nothing into rNSError
put objC_NSFileManagerAttributesOfItemAtPath( tSharedFileManager, StringToNSString(pPathToFile), rNSError) into tAttributesNSDict
LogNSObjectClassName(rNSError) --should log 'NSError' or 'No Object' if no error
LogNSObjectClassName(tAttributesNSDict) --- should log 'NSFileAttributes' which is an NSDictionary type
put ArrayFromNSDictionary(tAttributesNSDict) into tAttributesArray
put getIntegerFromFourCharCodeBigEndian(char 1 to 4 of pFourCharOSType) into tAttributesArray["NSFileHFSCreatorCode"]
log tAttributesArray
put ArrayToNSDictionary(tAttributesArray) into tAttributesNSDict
put objC_NSFileManagerSetAttributesOfItemAtPath( tSharedFileManager, tAttributesNSDict,StringToNSString(pPathToFile), rNSError) into tStatus
-- put objC_NSURLGetAbsoluteString(tUserHomeDir) into tNSURLString
-- put objC_NSURLGetPath(tUserHomeDir) into tNSPath
-- return StringFromNSString(tNSPath)
-- return StringFromNSString(tUserHomeDir)
-- put objC_NSURLGetPath(tUserHomeDir) into tNSPath
-- return ( StringFromNSString(tNSURLString) & "\n" & StringFromNSString(tNSPath) )
end unsafe
return tStatus
end handler
/**
Summary: Sets the Mac HFS Type Code of a file.
Parameters:
pFilePath: Path to the file to examine.
pFourCharOSType: An 'OSType' four character type code, such as STAK or JFIF
Returns: true on success, otherwise false
Description:
Sets the Mac HFS Type Code of a file. A type code is a four-character
OSType code, such as MIDI or TIFF, used to associate a file type with a file for
legacy classic macOS files, which did not use filename extensions to detirmine a files type.
NOTE: Mac HFS Type and Creator Codes are legacy macOS classic file system attributes
which have long been marked as 'deprecatred' by Apple, however since this potentially
effects many legacy files, Apple has included HFS Type and Creator in the
contemporary APFS file system.
*/
public handler SetHFSTypeCodeOfFile( in pPathToFile as String, in pFourCharOSType as String ) returns any
variable tSharedFileManager as ObjcObject
variable rNSError as optional ObjcObject
variable tAttributesNSDict as optional ObjcObject
variable tNSPath as optional ObjcObject
variable tNSURLString as optional ObjcObject
variable tNSString as optional ObjcObject
variable tAttributesArray as optional Array
variable tStatus as Boolean
variable tOSType as UInt32
unsafe
put objC_NSFileManagerSharedManager() into tSharedFileManager
-- log tSharedFileManager
-- LogNSObjectClassName(tSharedFileManager)
put objC_NSErrorAlloc() into rNSError
-- LogNSObjectClassName(rNSError)
put nothing into rNSError
put objC_NSFileManagerAttributesOfItemAtPath( tSharedFileManager, StringToNSString(pPathToFile), rNSError) into tAttributesNSDict
-- LogNSObjectClassName(rNSError) --should log 'NSError' or 'No Object' if no error
-- LogNSObjectClassName(tAttributesNSDict) --- should log 'NSFileAttributes' which is an NSDictionary type
put ArrayFromNSDictionary(tAttributesNSDict) into tAttributesArray
put getIntegerFromFourCharCodeBigEndian(char 1 to 4 of pFourCharOSType) into tAttributesArray["NSFileHFSTypeCode"]
log tAttributesArray
put ArrayToNSDictionary(tAttributesArray) into tAttributesNSDict
put objC_NSFileManagerSetAttributesOfItemAtPath( tSharedFileManager, tAttributesNSDict,StringToNSString(pPathToFile), rNSError) into tStatus
end unsafe
return tStatus
end handler
/**
Badge the App's Dock Icon with a small string of text.
Example:
setDockTileBadge "Hello"
Parameters:
badgeText (string): a small string of text to badge the app's dock icon with.
Description:
Badge the App's Dock Icon with a small string of text. If badgeText string is
too long it will be automatically truncated to fit.
*/
public handler SetDockTileBadge(in badgeText as String) returns nothing
variable sharedApplication as ObjcId
variable tNSDockTile as ObjcId
if (the operating system is "mac") then
unsafe
put objC_NSApplicationSharedApplication() into sharedApplication
put objC_NSApplicationGetNSDockTile(sharedApplication) into tNSDockTile
objC_NSDockTileSetShowAppBadge(tNSDockTile, true, StringToNSString("showsApplicationBadge"))
objC_NSDockTileSetBadgeLabelProp(tNSDockTile,StringToNSString(badgeText),StringToNSString("badgeLabel"))
objC_NSDockTileDisplay(tNSDockTile)
end unsafe
end if
end handler
public handler SetDockTileImage(in pImageScriptObj as optional String) returns nothing
variable sharedApplication as ObjcId
variable tNSDockTile as ObjcId
variable pSharedWorkspace as ObjcObject
variable tStatus as Boolean
variable tNSImage as optional ObjcObject
variable tCIImage as optional ObjcObject
variable tCIFilter as optional ObjcObject
variable tData as optional Data
variable tList as optional List
variable tImageDataObj as ObjcId
variable tImageData as Data
variable tImageReps as ObjcObject
variable tImageRepsList as List
variable tImageRep as ObjcId
variable tBitmapImageRep as ObjcObject
variable tCGImageRef as CGImageRef
unsafe
-- get the dockTile
put objC_NSApplicationSharedApplication() into sharedApplication
put objC_NSApplicationGetNSDockTile(sharedApplication) into tNSDockTile
if pImageScriptObj is the empty string or pImageScriptObj is nothing then
objC_NSApplicationSetAppIconImage( sharedApplication , nothing)
else
--- boiler plate for getting the image data
variable tObject as optional ScriptObject
variable tFile as String
resolve script object pImageScriptObj
put the result into tObject
if tObject exists then
put property "filename" of tObject into tFile
if tFile is empty then
put property "text" of tObject into tData
put ObjC_NSImageAlloc() into tNSImage
put ObjC_NSImageInitWithData(tNSImage, DataToNSData(tData)) into tNSImage
else
resolve file tFile relative to tObject
if the result is not nothing then
put the result into tFile
end if
end if
else
resolve file pImageScriptObj
if the result is not nothing then
put the result into tFile
end if
end if
if tFile is not empty then
put ObjC_NSImageAlloc() into tNSImage
put ObjC_NSImageInitWithContentsOfFile(tNSImage, StringToNSString(tFile)) into tNSImage
end if
--- end of boiler plate for getting the image data
-- objC_NSDockTileSetShowAppBadge(tNSDockTile, true, StringToNSString("showsApplicationBadge"))
-- objC_NSDockTileSetBadgeLabelProp(tNSDockTile,StringToNSString(badgeText),StringToNSString("badgeLabel"))
-- NSAPPLICATION .applicationIconImage
objC_NSApplicationSetAppIconImage( sharedApplication , tNSImage)
-- tell appKit to redraw the dockTile
objC_NSDockTileDisplay(tNSDockTile)
end if
end unsafe
end handler
/**
When the app is in the background, RequestUserAttention calls for user
attention by bouncy the App's icon in the Dock
Example:
do "tell application "& quote & "Finder.app" & quote & " to activate" as AppleScript
wait 1 second with messages
RequestUserAttention TRUE
Parameters:
criticalRequest (boolean): Set wether or not attention is immediately needed.
- TRUE: the user attention request is a critical request. The dock icon will
continue to bounce until the application is brought forward.
- FALSE: the user attention request is an informational request.
The dock icon will bounce once.
Description:
When the app is in the background <RequestUserAttention> will call for the users
attention by bouncy the App's icon in the Dock. If <criticalRequest> is false it will
bounce the icon only once, otherwise the icon will continue to bounce until
the app is the active foreground app.
*/
public handler RequestUserAttention(in criticalRequest as Boolean) returns nothing
if (the operating system is "mac") then
unsafe
variable sharedApplication as ObjcId
put objC_NSApplicationSharedApplication() into sharedApplication
variable tResults as CLong
if (criticalRequest) then
put objC_NSApplicationRequestUserAttention(sharedApplication, 0) into tResults
else
put objC_NSApplicationRequestUserAttention(sharedApplication, 10) into tResults
end if
end unsafe
end if
end handler
public handler DownloadFileFinished(in pathToFile as String) returns nothing
if (the operating system is "mac") then
variable defaultCenter as ObjcId
unsafe
put objC_NSDistributedNotificationCenterDefaultCenter() into defaultCenter
objC_NSDistributedNotificationCenterPostNotificationNameObject(defaultCenter, StringToNSString("com.apple.DownloadFileFinished"), StringToNSString(pathToFile))
end unsafe
end if
end handler
--------------------------------------------------------------------------------
/**
Sets the mac native fullscreen attribute for a windowID passed to it.
Example:
FullScreenAllowed the windowID of this stack, TRUE
Parameters:
windowID (integer): retrieved from a stack's windowID property.
isAllowed (boolean): If true then allow, if false don't allow.
Description:
This handler will set the mac native Full Screen behaviour on the windowID passed.
Depending on the OS version, this will either display an icon in the window’s
top-right corner, or change the maximize button to display double arrows.
*/
public handler FullScreenAllowed(in windowID as Integer, in isAllowed as Boolean) returns nothing
if (the operating system is "mac") then
variable tNSWindow as ObjcId
variable collectionBehavior as CLong
unsafe
put _NSWindowFromWindowID(windowID) into tNSWindow
put _NSWindowGetCollectionBehavior(tNSWindow) into collectionBehavior
if isAllowed then
put collectionBehavior bitwise or 128 into collectionBehavior
else
put collectionBehavior bitwise and (bitwise not 128) into collectionBehavior
end if
ObjC_NSWindowSetCollectionBehavior(tNSWindow, collectionBehavior)
end unsafe
end if
end handler
--
/**
Returns the mac native Full Screen behavior state of stack's window.
Example:
if IsFullScreenAllowed(the windowID of this stack) then put "Ready to go mac native full screen."
Parameters:
windowID (integer): retrieved from a stack's windowID property.
Returns:
The mac native Full Screen allowed state of a stack's window.
Description:
Geven the windowID of a stack this returns the mac native Full Screen behavior
state of the stack.
*/
public handler IsFullScreenAllowed(in windowID as Integer) returns Boolean
if (the operating system is "mac") then
unsafe
variable tNSWindow as ObjcId
put _NSWindowFromWindowID(windowID) into tNSWindow
variable collectionBehavior as Clong
put _NSWindowGetCollectionBehavior(tNSWindow) into collectionBehavior
put collectionBehavior bitwise and 128 into collectionBehavior
if (collectionBehavior = 0) then
return false
else
return true
end if
end unsafe
end if
end handler
/**
Toggle the mac native Full Screen state of a stack's window
Example:
ToggleFullScreen the windowID of this stack
Parameters:
windowID (integer): retrieved from a stack's windowID property.
Description:
This handler will toggle the Full Screen state of the window passed.
The FullScreenAllowed must first be enabled for this to work (system requirement)
*/
public handler ToggleFullScreen(in windowID as Integer) returns nothing
if (the operating system is "mac") then
variable tNSWindow as ObjcId
unsafe
put _NSWindowFromWindowID(windowID) into tNSWindow
ObjC_NSWindowToggleFullScreen(tNSWindow, nothing)
end unsafe
end if
end handler
/**
Assign the macOS native "dark mode" window style to a stack's window
Example:
setWindowToDarkMode the windowID of this stack
Parameters:
windowID (integer): retrieved from a stack's windowID property.
Description:
This handler will set the macOS dark appearance of the window passed.
*/
private variable mNSAppearance as optional ObjcObject
public handler setWindowToDarkMode(in pWindowID as Integer) returns nothing
if (the operating system is "mac") then
variable tNSWindow as optional ObjcId
variable tNSWindowController as optional ObjcId
variable tNSWindowContentViewController as optional ObjcId
variable tNSAppearance as optional ObjcId
unsafe
put _NSWindowFromWindowID(pWindowID) into tNSWindow
-- log tNSWindow
------------------------------------------------------------------- It seems thst LiveCode stack windows on macOS are customized class of NSWindow
-- LogNSObjectClassName(tNSWindow) -- logs the class name as "com_runrev_livecode_MCWindow"
-- put ObjC_NSWindowGetWindowController(tNSWindow) into tNSWindowController
-- log tNSWindowController --- logs null, so apparently the stack window class "com_runrev_livecode_MCWindow" has no NSWindowController assigned to it.
-- put ObjC_NSWindowGetContentViewController(tNSWindow) into tNSWindowContentViewController
-- log tNSWindowContentViewController --- logs null, so apparently the stack window class "com_runrev_livecode_MCWindow" has no tNSWindowContentViewController assigned to it.
--------- create an NSWindowController and attaches it to the Stack Window:
-- put ObjC_NSWindowControllerAlloc() into tNSWindowContentViewController
-- put ObjC_NSWindowControllerInitWithWindow(tNSWindowContentViewController,tNSWindow) into tNSWindowContentViewController
-- log tNSWindowContentViewController
-- LogNSObjectClassName(tNSWindowContentViewController)
------------------------------------------------------------------ Do The DarkMode ------------------------------------------------------
put ObjC_NSAppearanceNewAppearanceNamed( StringToNSString("NSAppearanceNameVibrantDark") ) into mNSAppearance
------------------------------------------------------------------ Appearance Names: ------------------------------------------------------
-- NSAppearanceNameAqua - The standard light system appearance.
-- NSAppearanceNameDarkAqua - The standard dark system appearance.
-- NSAppearanceNameVibrantLight - The light vibrant appearance, available only in visual effect views.
-- NSAppearanceNameVibrantDark - A dark vibrant appearance, available only in visual effect views.
-- NSAppearanceNameAccessibilityHighContrastAqua - A high-contrast version of the standard light system appearance.
-- NSAppearanceNameAccessibilityHighContrastDarkAqua - A high-contrast version of the standard dark system appearance.
-- NSAppearanceNameAccessibilityHighContrastVibrantLight - A high-contrast version of the light vibrant appearance.
-- NSAppearanceNameAccessibilityHighContrastVibrantDark - A high-contrast version of the dark vibrant appearance.
-- Deprecated Names:x
-- NSAppearanceNameLightContent - The standard appearance that can be used by controls in light content areas (not including window-frame areas).
-- LogNSObjectClassName(tNSAppearance)
ObjC_NSWindowSetAppearance(tNSWindow,mNSAppearance)
-- Borderless = 0
-- Titled = 1 LCS 'Decoration' = "title"
-- Closable = 2 LCS 'Decoration' = "close"
-- Miniaturizable = 4 LCS 'Decoration' =" minimize"
-- Resizable = 8 -- LCS equivelant is stack "resizable" property
-- Utility = 16
-- DocModal = 64
-- NonactivatingPanel = 128
-- TexturedBackground = 256 (deprecated as of macOS 10.10)
-- Unscaled = 2048
-- UnifiedTitleAndToolbar = 4096
-- Hud = 8192
-- CanFullScreenWindow = 16384 LCS 'maximize' ="
-- FullSizeContentView = 32768 --
-- ObjC_NSWindowSetStyleMask(tNSWindow,11 + 4096 + 256 + 32768)
ObjC_NSWindowSetBoolValueForKey(tNSWindow,true,StringToNSString("titlebarAppearsTransparent"))
--ObjC_NSWindowSetTitleVisibility(tNSWindow,NumberToNSNumber(1)) --- 1 = TitleBar hidden, 0 = TitleBar Visible
-- window?.appearance
end unsafe
end if
end handler
/**
Get the real rect of a stack's window including decorations and titlebar.
Example:
put getNSWindowFrameRect( the windowID of this stack ) into message
Parameters:
pWindowID (integer): retrieved from a stack's windowID property.
Description:
Gets the actual rect of a stack's window on macOS, including the windows decorations,
titlebar, etc. This will likely be a different in height than a stacks rect property
( 19 pixel height differnece for a palette window type for example).
NOTE: macOS system use bottom/left start point and height/width size to define a
windows rect.
*/
public handler getNSWindowFrameRect(in pWindowID as Integer) returns String
if (the operating system is "mac") then
variable tNSString as optional ObjcId
variable tNSWindow as optional ObjcId
variable tNSWindowRect as optional NSRect
variable tCUInt as optional CSint
variable rReturnString as optional String
put the empty string into rReturnString
unsafe
-- test
-- variable tNSRect as optional NSRect
-- put c_NSRectFromString(StringToNSString("100.4,-34,500,900")) into tNSRect
-- slog tNSRect
put _NSWindowFromWindowID(pWindowID) into tNSWindow
------------------------------------------------------------------ return window rect ------------------------------------------------------
put ObjC_NSWindowGetFrameRect( tNSWindow ) into tNSWindowRect
-- log tNSWindowRect
-- apparently the NSRect coords are different than the xTalk engine.
-- NSRect (origin.x, origin.y, size.width, size.height)
-- origin is from BOTTOM left vs xTalk's origin Y from the TOP of the screen
-- to translate between NSWindow NSRect to Stack Rectangle we need the screen height.
put c_NSStringFromRect(tNSWindowRect) into tNSString
put StringFromNSString(tNSString) into rReturnString
log rReturnString
put element 1 of tNSWindowRect into tCUInt
put "origin x: " & tCUInt formatted as string & "," into rReturnString
put element 2 of tNSWindowRect into tCUInt
put "origin y: " & tCUInt formatted as string & "," after rReturnString
put element 3 of tNSWindowRect into tCUInt
put "width: " & tCUInt formatted as string & "," after rReturnString
put element 4 of tNSWindowRect into tCUInt
put "height: " & tCUInt formatted as string after rReturnString
return rReturnString
end unsafe
end if
end handler
/**
Assign the macOS native "light mode" window style to a stack's window
Example:
setWindowToLightMode the windowID of this stack
Parameters:
windowID (integer): retrieved from a stack's windowID property.
Description:
This handler will set the macOS "light" appearance of the window passed.
*/
public handler setWindowToLightMode(in pWindowID as Integer) returns nothing
if (the operating system is "mac") then
variable tNSWindow as optional ObjcId
unsafe
put _NSWindowFromWindowID(pWindowID) into tNSWindow
------------------------------------------------------------------ Do The LightMode ------------------------------------------------------
put ObjC_NSAppearanceNewAppearanceNamed( StringToNSString("NSAppearanceNameVibrantLight") ) into mNSAppearance
ObjC_NSWindowSetAppearance(tNSWindow,mNSAppearance)
end unsafe
end if
end handler
------------------------ For All App NSWindows ------------------------
/**
Assign the macOS native "Vibrant Dark" appearance style to all app windows
Example:
setAppToDarkMode
Description:
This sets an Apps appearance to Dark Mode, with all app windows inheriting the
dark appearance.