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 pathrevmenubar.livecodescript
More file actions
3194 lines (2847 loc) · 109 KB
/
revmenubar.livecodescript
File metadata and controls
3194 lines (2847 loc) · 109 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 "revMenuBar"
local sMenuTarget
on preOpenStack
global gREVDontLoadMenus
if gREVDontLoadMenus then
put false into gREVDontLoadMenus
exit preOpenStack
end if
subscribeMessages
setDefaultText
setMenuProperties
generateMenu
revMenubarBuildMenus
updateMenubarPreference
layoutMenu
revIDEPositionPalette the short name of me
# Since the menubar is topleveled on Linux and Windows, set the cantModify to true
# to prevent users being able to alter the menubar stack.
set the cantModify of me to true
end preOpenStack
on closeStackRequest
revIDEQuit
end closeStackRequest
on subscribeMessages
revIDESubscribe "ideSelectedObjectChanged"
revIDESubscribe "idePreferenceChanged:cToolbarIcons"
revIDESubscribe "idePreferenceChanged:cToolbarText"
revIDESubscribe "ideToolChanged"
revIDESubscribe "ideToggleChanged:suppressMessages"
revIDESubscribe "ideToggleChanged:suppressErrors"
revIDESubscribe "ideToggleChanged:selectGrouped"
revIDESubscribe "idePluginsChanged"
revIDESubscribe "ideWindowsChanged"
revIDESubscribe "ideTutorialProgressChanged"
revIDESubscribe "ideActiveStacksChanged"
end subscribeMessages
local sTextMenuDisabledText, sTextMenuText, sPluginMenuText
on setDefaultText
setupTextMenu
end setDefaultText
private on setupDevelopmentMenu
local tPlugins
put the keys of revIDEPlugins() into tPlugins
sort tPlugins
local tPluginMenuText
repeat for each line tPlugin in tPlugins
if tPluginMenuText is empty then
put tab & tPlugin into tPluginMenuText
else
put return & tab & tPlugin after tPluginMenuText
end if
end repeat
put tPluginMenuText into sPluginMenuText
end setupDevelopmentMenu
private on setupTextMenu
local tText
put toggleMenuItem("Plain/;", false) & return after tText
put toggleMenuItem("&Bold/B", false) & return after tText
put toggleMenuItem("&Italic/I", false) & return after tText
put toggleMenuItem("&Underline/U", false) & return after tText
put toggleMenuItem("Strikeout", false) & return after tText
put toggleMenuItem("Box", false) & return after tText
put toggleMenuItem("3D Box", false) & return after tText
put "-" & return after tText
put toggleMenuItem("Link", false) & return after tText
put "-" & return after tText
put toggleMenuItem("Subscript", false) & return after tText
put toggleMenuItem("Superscript", false) & return after tText
put "-" & return after tText
put "Font" & return after tText
local tFontNames
put the fontNames into tFontNames
replace "/" with "\" in tFontNames
sort lines of tFontNames
/* Fake fonts begin with "(", but the menu code interprets a "(" at
the beginning of the item to mean the item is disabled.
So, to show a "(" instead of disabling, we need to double it */
repeat with tLine = 1 to the number of lines of tFontNames
if line tLine of tFontNames begins with "(" then
put "(" before line tLine of tFontNames
end if
end repeat
put "Use Owner's Font" & return & "-" & return before tFontNames
local fontnum
put 1 into fontnum
repeat for each line tFontName in tFontNames
if tFontName is "-" then
put tab & tFontName & return after tText
else
put "!u" & tab & tFontName & return after tText
end if
end repeat
put "Size" & return after tText
local tFontSizes
put format("Use Owner's Size\n-\n8\n9\n10\n12\n14\n18\n24\n36\n48\n-\nOther...") into tFontSizes
repeat for each line l in tFontSizes
if l is "-" then put tab & l & cr after tText
else put "!u" & tab & l & cr after tText
end repeat
put "Color" & cr after tText
local tColors
put format("Use Owner's Color\n-\nBlack\nWhite\nRed\nGreen\nBlue\nYellow\n-\nPen Color") into tColors
repeat for each line tColor in tColors
if tColor is "-" then
put tab & tColor & return after tText
else
put "!u" & tab & tColor & return after tText
end if
end repeat
put "-" & return & "&Align" & return & "!u" & tab & "Left" & return & "!u" & tab & "Center" & return & "!u" & tab & "Right" after tText
# Cache the text menu text in non-disabled state
put tText into sTextMenuText
repeat for each line tLine in tText
if the platform is "MacOS" and tab is in tLine then
replace tab with empty in tLine
local tDisabledText
put tab & "(" & tLine & return after tDisabledText
else
put "(" & tLine & return after tDisabledText
end if
end repeat
delete last char of tDisabledText
# Cache the disabled text menu text
put tDisabledText into sTextMenuDisabledText
end setupTextMenu
# OK-2010-02-19: Bug 8157 - Escape special characters from stack names in menus, more may
# need to be added here.
private function revMenubarEscapeStackNameForMenu pName
replace "!" with "\!" in pName
replace "&" with "\&" in pName
if the platform is "MacOS" then
replace "/" with "\/" in pName
replace "(" with "\(" in pName
else
replace "/" with "//" in pName
end if
return pName
end revMenubarEscapeStackNameForMenu
local sWindowMenuWindows
private on setupWindowMenu
# Set sWindowMenuText to a list of open Windows in suitable format for putting into a menu button.
# This will be any script editors or the dictionary or resource center if they are open, and any user stacks.
local tWindows
put revIDEWindowList() into tWindows
if tWindows is empty then
put empty into sWindowMenuWindows
exit setupWindowMenu
end if
// PM-2016-05-14: [[ Bug 17638 ]] Show stacks by name, unless they are instances of the script editor,
// the Dictionary or the Resource Center. In this case show the stack title, as in LC 6.7.x
local tMenu, tMenuLine, tStackName
repeat for each line tStack in tWindows
if there is not a stack tStack then next repeat
put the short name of tStack into tStackName
if revIDEStackIsIDEWindow(tStackName) then
put the title of tStack into tStackName
end if
put "!n" & revMenubarEscapeStackNameForMenu(tStackName) & "/|" & tStack into tMenuLine
if tMenu is empty then
put tMenuLine into tMenu
else
put return & tMenuLine after tMenu
end if
end repeat
# Put a checkmark against the 'topmost' stack
put "!c" into char 1 to 2 of line 1 of tMenu
put tMenu into sWindowMenuWindows
end setupWindowMenu
/*
Generates the menu for the recent files
*/
function revMenuBarRecentFiles
# Get the recent file data
local tRecentFiles
put revIDERecentStacks() into tRecentFiles
# Generate the menu
local tMenu
repeat with x = 1 to the number of elements of tRecentFiles
if tMenu is empty then
put tab & revMenubarEscapeStackNameForMenu(tRecentFiles[x]["label"]) & "/|" & tRecentFiles[x]["filename"] into tMenu
else
put return & tab & revMenubarEscapeStackNameForMenu(tRecentFiles[x]["label"]) & "/|" & tRecentFiles[x]["filename"] after tMenu
end if
end repeat
return tMenu
end revMenuBarRecentFiles
on moveStack
if the platform is "MacOS" then
local tScreenRect
put revIDEStackScreenRect(the short name of this stack, true) into tScreenRect
set the topLeft of this stack to item 1 to 2 of tScreenRect
end if
revIDESetPaletteRectPreference the short name of me
ideSetWindowBoundingRect
pass moveStack
end moveStack
on setMenuProperties
set the height of me to 47
set the resizable of me to false
local tTitle
set the itemDelimiter to "-"
put "LiveCode" && revEnvironmentEditionProperty("name") into tTitle
if item 1 of the version ends with ".0" then
put space & char 1 to -3 of item 1 of the version after tTitle
else
put space & item 1 of the version after tTitle
end if
if item 2 of the version is not empty then
put space & "(" & item 2 of the version && item 3 of the version & ")" after tTitle
end if
set the itemDelimiter to comma
set the title of me to tTitle
local tScreenRect
put revIDEStackScreenRect(the short name of this stack, true) into tScreenRect
if the platform is not "MacOS" then
if item 3 of the screenRect is 800 then
set the topLeft of me to item 1 to 2 of tScreenRect
else
--screen rect > 800 by 600
if revIDEGetPreference("cREVMenuBarTopLeft") is empty
then set the loc of me to item 1 of revIDEStackScreenLoc(the short name of this stack), 54
else set the topLeft of me to revIDEGetPreference("cREVMenuBarTopLeft")
end if
end if
if the platform is "MacOS" then
set the decorations of me to empty
set the topLeft of me to item 1 to 2 of tScreenRect
else
set the decorations of me to "default"
end if
end setMenuProperties
on ideSelectedObjectChanged
updateButtonState
end ideSelectedObjectChanged
on ideActiveStacksChanged
updateButtonState
end ideActiveStacksChanged
on ideTutorialProgressChanged
highlightObject empty
layoutMenu
revMenubarBuildMenus
end ideTutorialProgressChanged
on idePreferenceChanged pPreference
switch pPreference
case "cToolbarText"
case "cToolbarIcons"
lock screen
show me
updateMenubarPreference
layoutMenu
ideSetWindowBoundingRect
unlock screen
break
end switch
end idePreferenceChanged
on ideToggleChanged pToggle
switch pToggle
case "suppressMessages"
case "suppressErrors"
case "selectGrouped"
updateButtonState
break
default
break
end switch
end ideToggleChanged
on idePluginsChanged
setupDevelopmentMenu
end idePluginsChanged
on generateMenu
generateMenubarUI
generateMenuGroup
generateContextMenu
end generateMenu
constant kTutorialActionSize = 10
on generateMenubarUI
if there is a group "icons" of me then
delete group "icons" of me
end if
if there is a group "toolbar" of me then
delete group "toolbar" of me
end if
reset the templatebutton
create group "icons"
create group "toolbar"
lock messages
# Setup the default button
set the showname of the templatebutton to true
set the style of the templatebutton to "transparent"
set the threed of the templatebutton to false
set the borderwidth of the templatebutton to 0
set the blendlevel of the templatebutton to 0
set the margins of the templatebutton to "4,0,4,1"
set the traversalOn of the templatebutton to false
set the autoHilite of the templatebutton to false
# Setup the default image
set the resizequality of the templateimage to "best"
# Setup the default field
set the traversalon of the templatefield to false
set the threed of the templatefield to false
set the showborder of the templatefield to false
set the showfocusborder of the templatefield to false
set the opaque of the templatefield to false
set the height of the templatefield to 21
set the locktext of the templatefield to true
local tDividerCount
put 1 into tDividerCount
repeat for each item tItem in revMenubarItems()
if tItem is "Divide" then
local tName
put tItem & tDividerCount into tName
create image tName in group "toolbar"of me
set the id of it to revIDENewIconID()
set the filename of image tName of group "toolbar" of me to revMenubarButtonNameToIconPath(tItem)
add 1 to tDividerCount
else
create invisible image tItem in group "icons" of me
set the id of it to revIDENewIconID()
set the filename of image tItem of me to revMenubarButtonNameToIconPath(tItem)
local tFilename
repeat for each item tStyle in "hilited,disabled,depressed,hilited-depressed"
put revMenubarButtonNameToIconPath(tItem, tStyle) into tFilename
if there is a file tFilename then
create invisible image (tItem & "-" & tStyle) in group "icons" of me
set the id of it to revIDENewIconID()
set the filename of image (tItem & "-" & tStyle) of me to tFilename
if tStyle is "hilited" then
set the cHighlightedIcon of the templatebutton to the id of image (tItem & "-" & tStyle) of group "icons" of me
else if tStyle is "depressed" then
set the cDepressedIcon of the templatebutton to the id of image (tItem & "-" & tStyle) of group "icons" of me
else if tStyle is "hilited-depressed" then
set the cHighlightedDepressedIcon of the templatebutton to the id of image (tItem & "-" & tStyle) of group "icons" of me
else if tStyle is "disabled" then
set the disabledIcon of the templatebutton to the id of image (tItem & "-" & tStyle) of group "icons" of me
end if
else
if tStyle is "hilited" then
set the cHighlightedIcon of the templatebutton to the cIcon of the templatebutton
else if tStyle is "disabled" then
set the disabledIcon of the templatebutton to the cIcon of the templatebutton
else if tStyle is "depressed" then
set the cDepressedIcon of the templatebutton to the cIcon of the templatebutton
else if tStyle is "hilited-depressed" then
set the cHighlightedDepressedIcon of the templatebutton to the cDepressedIcon of the templatebutton
end if
end if
end repeat
create button tItem in group "toolbar" of me
set the cIcon of it to the id of image tItem of group "icons" of me
set the icon of it to the cIcon of it
set the label of it to revIDELocalizeMenuItem(tItem)
end if
end repeat
set the hilitedIcon of the templatebutton to 0
set the disabledIcon of the templatebutton to 0
generateTutorialGroup
generateUpgradeGroup
reset the templategraphic
reset the templatebutton
reset the templateimage
reset the templatefield
unlock messages
end generateMenubarUI
private command generateTutorialGroup
if there is a group "tutorial" of me then
delete group "tutorial" of me
end if
create group "tutorial"
set the margins of it to 0
create group "progress" in group "tutorial" of me
set the margins of it to 0
set the opaque of the templateGraphic to true
set the style of the templateGraphic to "rectangle"
set the lineSize of the templateGraphic to 0
create graphic "Trough" in group "Progress" of group "tutorial" of me
create graphic "Bar" in group "Progress" of group "tutorial" of me
set the backcolor of it to "white"
create field "label" in group "tutorial" of me
set the margins of it to 4
set the textSize of it to 10
set the traversalOn of it to false
create group "actions" in group "tutorial" of me
set the margins of it to 0
create widget "stop" as "com.livecode.widget.svgpath" in group "actions" of group "tutorial" of me
set the width of it to kTutorialActionSize
set the height of it to kTutorialActionSize
set the iconPresetName of it to "stop"
set the traversalOn of it to false
create widget "skip" as "com.livecode.widget.svgpath" in group "actions" of group "tutorial" of me
set the width of it to kTutorialActionSize
set the height of it to kTutorialActionSize
set the iconPresetName of it to "forward"
set the traversalOn of it to false
hide group "tutorial" of me
end generateTutorialGroup
private command generateUpgradeGroup
if there is a group "upgrade" of me then
delete group "upgrade" of me
end if
create group "upgrade"
set the margins of it to 0
create graphic "bg" in group "upgrade" of me
set the opaque of it to true
set the style of it to "roundRect"
set the lineSize of it to 0
local tUpgradeEdition
put revEnvironmentEditionProperty("upgrade_edition") into tUpgradeEdition
set the backcolor of it to revEnvironmentEditionProperty("color", tUpgradeEdition)
set the roundRadius of it to 8
create field "label" in group "upgrade" of me
set the margins of it to 4
set the traversalOn of it to false
set the text of it to "Upgrade Options"
set the textStyle["bold"] of it to true
set the textColor of it to "white"
hide group "upgrade" of me
end generateUpgradeGroup
on generateMenuGroup
lock messages
if there is a group "revMenuBar" of me then
delete group "revMenuBar" of me
end if
set the traversalOn of the templatebutton to false
set the style of the templatebutton to "menu"
set the menumode of the templatebutton to "pulldown"
set the height of the templatebutton to 22
# Pulldown menus with showBorder true don't receive keyboard shortcut menu picks
set the showborder of the templatebutton to false
local tButtonScript
put "on menuPick pWhich; revMenubarMenuPick pWhich; end menuPick" into tButtonScript
set the script of the templatebutton to tButtonScript
local tGroupScript
put "on mouseDown; revMenubarBuildMenus; end mouseDown" into tGroupScript
create invisible group "revMenuBar"
set the script of it to tGroupScript
set the topleft of group "revMenuBar" of me to 0,0
set the lockloc of group "revMenuBar" of me to true
local tLeft
put 1 into tLeft
repeat for each item tItem in revMenubarMenus()
create button tItem in group "revMenuBar" of me
set the width of it to the formattedwidth of it
set the left of it to tLeft
set the top of it to 1
add the formattedwidth of it to tLeft
# Enable Alt + letter to open menu on Linux and Windows
if tItem is "Text" then
set the mnemonic of it to 3
else
set the mnemonic of it to 1
end if
end repeat
if the platform is not "macos" then
show group "revMenuBar" of me
end if
set the menubar of me to "revMenuBar"
reset the templatebutton
set the style of the templatebutton to "rectangle"
set the height of the templatebutton to 2
set the threed of the templatebutton to true
set the showborder of the templatebutton to true
set the borderwidth of the templatebutton to 2
set the showname of the templatebutton to false
if the platform is "Linux" then
create button "Divider" in group "revMenuBar"
else
create invisible button "Divider" in group "revMenuBar"
end if
reset the templatebutton
unlock messages
end generateMenuGroup
on generateContextMenu
if there is a button "context" of me then
delete button "context" of me
end if
set the style of the templatebutton to "menu"
set the menumode of the templatebutton to "popup"
set the visible of the templatebutton to false
create button "context"
end generateContextMenu
constant kPadding = 10
constant kDividerWidth = 2
constant kDividerHeight = 41
constant kMenuBarHeight = 26
constant kMenuBarTop = 3
constant kUpgradeButtonMarginVertical = 8
constant kUpgradeButtonMarginHorizontal = 15
on layoutMenu
lock screen
lock messages
local tDividerCount
put 1 into tDividerCount
local tLeft, tTop
put kPadding into tLeft
if the platform is "macos" then
put kMenuBarTop into tTop
else
put kMenuBarTop + kMenuBarHeight into tTop
end if
local tTopLeft
put the topleft of me into tTopLeft
local tLastDivide
repeat for each item tItem in revMenubarItems()
if tItem is "Divide" then
local tName
put tItem & tDividerCount into tName
set the rect of image tName of group "toolbar" of me to 0, 0, kDividerWidth, kDividerHeight
set the topleft of image tName of group "toolbar" of me to tLeft + kPadding / 2 - kDividerWidth / 2, tTop
add 1 to tDividerCount
add kPadding to tLeft
put the long id of image tName into tLastDivide
else
local tWidth, tHeight
set the textStyle["bold"] of button tItem of group "toolbar" of me to false
put revMenubarButtonFormattedWidth(tItem) into tWidth
set the width of button tItem of group "toolbar" of me to tWidth
set the topleft of button tItem of group "toolbar" of me to tLeft,tTop
add tWidth to tLeft
end if
end repeat
local tTutorial, tLabelWidth
put revIDETutorialInProgress() into tTutorial
if tTutorial is not empty then
hide group "upgrade" of me
add kPadding/2 to tLeft
show group "tutorial" of me
show tLastDivide
set the text of field "label" of group "tutorial" of me to tTutorial["lesson"]
set the width of field "label" of group "tutorial" of me to 1000
set the height of field "label" of group "tutorial" of me to the formattedHeight of field "label" of group "tutorial" of me
put the formattedwidth of field "label" of group "tutorial" of me into tLabelWidth
set the width of field "label" of group "tutorial" of me to tLabelWidth
set the topleft of field "label" of group "tutorial" of me to 0, 0
set the backcolor of graphic "Trough" of group "progress" of me to "white"
set the backcolor of graphic "Bar" of group "progress" of me to "black"
set the rect of graphic "Trough" of group "progress" of me to 0, 0, tLabelWidth, kPadding / 2
set the rect of graphic "Bar" of group "progress" of me to 0, 0, revIDETutorialDonePercentage() * tLabelWidth / 100, kPadding / 2
set the rect of group "progress" of me to the formattedRect of group "progress" of me
set the loc of group "progress" of me to the loc of field "label" of me
set the top of group "progress" of me to the bottom of field "label" of group "tutorial" of me + kPadding / 5
set the topleft of widget "skip" of group "actions" of group "tutorial" of me to 0,0
set the topleft of widget "stop" of group "actions" of group "tutorial" of me to kTutorialActionSize + kPadding / 2, 0
set the rect of group "actions" of group "tutorial" of me to the formattedRect of group "actions" of group "tutorial" of me
set the loc of group "actions" of group "tutorial" of me to the loc of field "label" of me
set the top of group "actions" of group "tutorial" of me to the bottom of group "progress" of me + kPadding / 2
set the rect of group "tutorial" of me to the formattedRect of group "tutorial" of me
set the loc of group "tutorial" of me to the loc of group "toolbar" of me
set the left of group "tutorial" of me to tLeft
add the width of group "tutorial" of me + kPadding to tLeft
else if ideShouldShowUpgradeOptions() then
hide group "tutorial" of me
add kPadding/2 to tLeft
show group "upgrade" of me
show tLastDivide
put the height of me into tHeight
local tMenuBarHeight = 0
if the platform is not "MacOS" then
subtract kMenuBarHeight from tHeight
put kMenuBarHeight into tMenuBarHeight
end if
set the topLeft of group "upgrade" of me to \
tLeft, \
tMenuBarHeight + (tHeight - the height of group "upgrade" of me) / 2
add the width of group "upgrade" of me + kPadding to tLeft
else
hide tLastDivide
hide group "tutorial" of me
hide group "upgrade" of me
end if
set the width of me to tLeft
set the height of group "revMenuBar" of me to kMenuBarHeight
set the width of group "revMenuBar" of me to the width of me
set the topleft of group "revMenuBar" of me to 0,0
set the rect of button "Divider" of group "revMenuBar" of me to 0, kMenuBarHeight - kDividerWidth, tLeft + kPadding, kMenuBarHeight
set the topleft of me to tTopLeft
unlock messages
updateButtonState
unlock screen
end layoutMenu
function revMenubarItems
return "Inspector,Code,Message Box,Divide,Group,Edit Group,Select Grouped,Divide,Messages,Errors,Divide,Sample Stacks,Tutorials,Resources,Dictionary,Divide,Test,Divide"
end revMenubarItems
on updateMenubarPreference
lock screen
lock messages
local tShowIcons, tShowText
put revIDEGetPreference("cToolbarIcons") is not false into tShowIcons
put revIDEGetPreference("cToolbarText") is not false into tShowText
local tTopLeft
put the topleft of me into tTopLeft
local tButtonRef
repeat for each line tButton in the childControlNames of group "toolbar" of me
if tButton is "Divide" then next repeat
if there is not a button tButton of group "toolbar" of me then
next repeat
end if
put the long id of button tButton of group "toolbar" into tButtonRef
if tShowIcons and tShowText then
set the height of tButtonRef to 43
else if tShowIcons then
set the height of tButtonRef to 26
else if tShowText then
set the height of tButtonRef to 14
end if
if tShowIcons then
set the showIcon of tButtonRef to true
else
set the showIcon of tButtonRef to false
end if
if tShowText then
set the showName of tButtonRef to true
else
set the showName of tButtonRef to false
end if
end repeat
if the platform is "macos" then
if tShowIcons is false and tShowText is false then
set the height of me to 0
hide me
else if tShowIcons is false then
set the height of me to 19
else if tShowText is false then
set the height of me to 32
else
set the height of me to 47
end if
else
show group "toolbar" of me
if tShowIcons is false and tShowText is false then
hide group "toolbar" of me
set the height of me to 23
else if tShowIcons is false then
set the height of me to 44
else if tShowText is false then
set the height of me to 59
else
set the height of me to 75
end if
end if
set the width of field "label" of group "upgrade" of me to 1000
set the height of field "label" of group "upgrade" of me to the formattedHeight of field "label" of group "upgrade" of me
local tLabelWidth
put the formattedwidth of field "label" of group "upgrade" of me into tLabelWidth
set the width of field "label" of group "upgrade" of me to tLabelWidth
set the loc of field "label" of group "upgrade" of me to 0,0
if tShowIcons is false then
set the visible of graphic "bg" of group "upgrade" of me to false
set the textColor of field "label" of group "upgrade" of me to "black"
else
set the visible of graphic "bg" of group "upgrade" of me to true
set the textColor of field "label" of group "upgrade" of me to "white"
local tHeight
put the height of me - kPadding into tHeight
if the platform is not "MacOS" then
subtract kMenuBarHeight from tHeight
end if
local tRect
put the rect of field "label" of group "upgrade" of me into tRect
put item 1 of tRect - kUpgradeButtonMarginHorizontal, \
-tHeight div 2, \
item 3 of tRect + kUpgradeButtonMarginHorizontal, \
tHeight div 2 into tRect
set the rect of graphic "bg" of group "upgrade" of me to tRect
end if
set the rect of group "upgrade" of me to the formattedRect of group "upgrade" of me
set the topleft of me to tTopLeft
unlock messages
unlock screen
end updateMenubarPreference
on setButtonHilite pLongId, pValue
if pValue then
set the hilite of pLongID to true
set the textStyle of pLongID to "bold"
else
set the hilite of pLongID to false
set the textStyle of pLongID to "plain"
end if
end setButtonHilite
private on disableToolbar
local tControlName
repeat for each line tControl in the childControlIDs of group "toolbar" of me
disable control id tControl of stack "revMenubar"
end repeat
end disableToolbar
private on enableToolbar
local tControlName
repeat for each line tControl in the childControlIDs of group "toolbar" of me
enable control id tControl of stack "revMenubar"
end repeat
end enableToolbar
on updateButtonHilite pTargetName, pValue
lock screen
lock messages
local tTargetLongID
put the long id of button pTargetName of group "toolbar" of me into tTargetLongID
local tShowIcon
put the showIcon of tTargetLongID into tShowIcon
setButtonHilite tTargetLongID, pValue
set the label of tTargetLongID to revMenubarButtonText(pTargetName, pValue)
if pValue then
set the icon of tTargetLongID to the cHighlightedIcon of tTargetLongID
else
set the icon of tTargetLongID to the cIcon of tTargetLongID
end if
set the showIcon of tTargetLongID to tShowIcon
unlock messages
unlock screen
end updateButtonHilite
private command setToolbarButtonState pName, pValue
set the enabled of button pName of group "toolbar" of me to pValue
end setToolbarButtonState
local sToolbarHighlight
on updateButtonState
lock screen
lock messages
enableToolbar
local tSelObj
put revIDESelectedObjects() into tSelObj
local tControlSelected
put tSelObj is not empty and word 1 of tSelObj \
is not among the items of "card,stack" into tControlSelected
local tUserStack
put not revIDEStackIsIDEStack(the topstack) into tUserStack
local tGroupHilite
put word 1 of tSelObj is "group" and the number of lines in tSelobj is 1 into tGroupHilite
updateButtonHilite "Group", tGroupHilite
-- Group button should be disabled if no controls are selected
setToolbarButtonState "Group", tControlSelected
local tEditGroupHilite
put the editBg of the topStack and word 1 of tSelObj is not "group" into tEditGroupHilite
updateButtonHilite "Edit Group", tEditGroupHilite
-- If a group is selected, the Edit Group button should be enabled
-- It should also be enabled (with label 'Stop Editing') if we're currently editing a group
setToolbarButtonState "Edit Group", \
tGroupHilite or the editBg of the topstack
# Click buttons don't stay hilited
updateButtonHilite "Message Box", false
updateButtonHilite "Inspector", false
updateButtonHilite "Code", false
updateButtonHilite "Test", false
updateButtonHilite "Sample Stacks", false
updateButtonHilite "Tutorials", false
updateButtonHilite "Resources", false
updateButtonHilite "Dictionary", false
# Toggle buttons hilited according to state of property
global gRevSuppressErrors, gRevSuppressMessages
updateButtonHilite "Errors", gRevSuppressErrors
updateButtonHilite "Messages", gRevSuppressMessages
updateButtonHilite "Select Grouped", the selectGroupedControls
# Deal with enabled/disabled of code and inspector
global gRevDevelopment
local tCanInspect
put tControlSelected or tUserStack or gRevDevelopment into tCanInspect
setToolbarButtonState "Code", tCanInspect
setToolbarButtonState "Inspector", tCanInspect
# Deal with enabled/disabled of test
setToolbarButtonState "Test", \
revIDEGetPreference("cDeployPlatforms") is not empty
if revIDETutorialInProgress() is not empty then
disableToolbar
if sToolbarHighlight is not empty then
enable button sToolbarHighlight of group "toolbar" of me
end if
end if
unlock messages
unlock screen
end updateButtonState
on revTextbar
revIDESetPreference "cToolbarText", true
revIDESetPreference "cToolbarIcons", false
end revTextbar
on revIconsBar
revIDESetPreference "cToolbarText", false
revIDESetPreference "cToolbarIcons", true
end revIconsBar
on revFullBar
revIDESetPreference "cToolbarText", true
revIDESetPreference "cToolbarIcons", true
end revFullBar
function revMenubarButtonNameToIconPath pName, pStyle
local tPath, tIcon
put revIDEPaletteResourcePath("images/") into tPath
replace " " with "-" in pName
put tPath & toLower(pName) into tIcon
if pStyle is not empty then
put "-" & pStyle after tIcon
end if
return tIcon & ".png"
end revMenubarButtonNameToIconPath
function revMenubarButtonText pName, pHilited
if pHIlited is false then
return pName
end if
switch pName
case "Group"
return "Ungroup"
case "Edit Group"
return "Stop Editing"
default
return pName
end switch
end revMenubarButtonText
function __buttonMaxFormattedWidth pName
lock screen
lock messages
local tWidth, tOldLabel, tNewLabel
put the label of button pName of group "toolbar" of me into tOldLabel
repeat for each item tHilite in "true,false"
set the label of button pName of group "toolbar" of me to revMenubarButtonText(pName, tHIlite)
put max(tWidth, the formattedwidth of button pName of group "toolbar" of me) into tWidth
end repeat
set the label of button pName of group "toolbar" of me to tOldLabel
unlock messages
unlock screen
return tWidth
end __buttonMaxFormattedWidth
constant kMinimumMenuButtonWidth = 64
function revMenubarButtonFormattedWidth pName
return max(__buttonMaxFormattedWidth(pName), kMinimumMenuButtonWidth)
end revMenubarButtonFormattedWidth
function revIDELocalizeMenuItem pItem
return pItem
end revIDELocalizeMenuItem
private on setButtonDepressed pTarget
lock screen
lock messages
local tHilite, tShowIcon
put the hilite of pTarget into tHilite
put the showIcon of pTarget into tShowIcon
if tHilite then
set the icon of pTarget to the cHighlightedDepressedIcon of pTarget
else
set the icon of pTarget to the cDepressedIcon of pTarget
end if
setButtonHilite pTarget, not the hilite of pTarget
set the showIcon of pTarget to tShowIcon
unlock messages
unlock screen
end setButtonDepressed
private on setButtonReleased pTarget
updateButtonState
end setButtonReleased
on mouseDown
if the short name of the owner of the target is "revMenuBar" then
revMenubarBuildMenus
else if the short name of the owner of the target is "toolbar" and the target begins with "button" then
setButtonDepressed the long id of the target
end if
end mouseDown