forked from gphilippot/purebasic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CompilerOptions.pb
1488 lines (1219 loc) · 64 KB
/
CompilerOptions.pb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;--------------------------------------------------------------------------------------------
; Copyright (c) Fantaisie Software. All rights reserved.
; Dual licensed under the GPL and Fantaisie Software licenses.
; See LICENSE and LICENSE-FANTAISIE in the project root for license information.
;--------------------------------------------------------------------------------------------
Procedure DisableOptionGadgets()
If Options_IsProjectMode
UseMainFile = #False ; do disable any of these options
Else
UseMainFile = GetGadgetState(#GADGET_Option_UseMainFile)
DisableGadget(#GADGET_Option_MainFile, 1-UseMainFile)
DisableGadget(#GADGET_Option_SelectMainFile, 1-UseMainFile)
EndIf
For Gadget = #GADGET_Option_UseCompiler To #GADGET_Option_ConstantLine
DisableGadget(Gadget, UseMainFile)
Next Gadget
If UseMainFile = 0
CompilerIf Not #SpiderBasic
UseIcon = GetGadgetState(#GADGET_Option_UseIcon)
DisableGadget(#GADGET_Option_IconName, 1-UseIcon)
DisableGadget(#GADGET_Option_SelectIcon, 1-UseIcon)
CompilerEndIf
DisableGadget(#GADGET_Option_SelectCompiler, 1-GetGadgetState(#GADGET_Option_UseCompiler))
DisableGadget(#GADGET_Option_CompileCount, 1-GetGadgetState(#GADGET_Option_UseCompileCount))
DisableGadget(#GADGET_Option_BuildCount, 1-GetGadgetState(#GADGET_Option_UseBuildCount))
EndIf
CompilerIf Not #SpiderBasic
CustomDebugger = GetGadgetState(#GADGET_Option_SelectDebugger)
DisableGadget(#GADGET_Option_DebuggerMode, 1-CustomDebugger)
If (CustomDebugger And GetGadgetState(#GADGET_Option_DebuggerMode) = 2) Or (CustomDebugger = 0 And DebuggerMode = 3)
DisableGadget(#GADGET_Option_SelectWarning, 1)
DisableGadget(#GADGET_Option_WarningMode, 1)
Else
DisableGadget(#GADGET_Option_SelectWarning, 0)
DisableGadget(#GADGET_Option_WarningMode, 1-GetGadgetState(#GADGET_Option_SelectWarning))
EndIf
CompilerEndIf
; disable / enable the resource options
CompilerIf #CompileWindows And Not #SpiderBasic
DisableGadget(#GADGET_Option_IncludeVersion, UseMainFile)
UseVersion = GetGadgetState(#GADGET_Option_IncludeVersion)
For i = 0 To 23
DisableGadget(#GADGET_Option_VersionValue0+i, (1-UseVersion)|UseMainFile)
Next i
DisableGadget(#GADGET_Option_ResourceList, UseMainFile)
DisableGadget(#GADGET_Option_ResourceAdd, UseMainFile)
DisableGadget(#GADGET_Option_ResourceRemove, UseMainFile)
DisableGadget(#GADGET_Option_ResourceClear, UseMainFile)
DisableGadget(#GADGET_Option_ResourceFile, UseMainFile)
DisableGadget(#GADGET_Option_ResourceSelectFile, UseMainFile)
CompilerEndIf
; always disable unsupported options on linux / mac
CompilerIf #CompileLinux And Not #SpiderBasic ; Icon is supported only on windows
DisableGadget(#GADGET_Option_UseIcon, 1)
DisableGadget(#GADGET_Option_IconName, 1)
DisableGadget(#GADGET_Option_SelectIcon, 1)
CompilerEndIf
CompilerIf #CompileLinux | #CompileMac And Not #SpiderBasic; this stuff is windows only
DisableGadget(#GADGET_Option_EnableXP, 1)
DisableGadget(#GADGET_Option_EnableAdmin, 1)
DisableGadget(#GADGET_Option_EnableUser, 1)
DisableGadget(#GADGET_Option_DPIAware, 1)
CompilerEndIf
EndProcedure
; get the list of enabled tools as it is stored in the structure/ide options
; (in uppercase, spaces replaced by '_', separated by comma)
;
Procedure.s CompilerWindow_EnabledToolsList()
Result$ = ""
For i = 0 To CountGadgetItems(#GADGET_Option_ToolsList)-1
If GetGadgetItemState(#GADGET_Option_ToolsList, i) & #PB_ListIcon_Checked
Result$ + ReplaceString(UCase(Trim(GetGadgetItemText(#GADGET_Option_ToolsList, i, 0))), " ", "_") + ","
EndIf
Next i
If Len(Result$) > 0
ProcedureReturn Left(Result$, Len(Result$)-1) ; cut last ","
Else
ProcedureReturn ""
EndIf
EndProcedure
Procedure SetTargetOptions(*Target.CompileTarget)
SetGadgetText(#GADGET_Option_MainFile, *Target\MainFile$)
If Options_IsProjectMode
SetGadgetText(#GADGET_Option_OutputFile, *Target\OutputFile$)
Else
SetGadgetState(#GADGET_Option_UseMainFile, *Target\UseMainFile)
EndIf
SetGadgetState(#GADGET_Option_UseCompiler, *Target\CustomCompiler)
If *Target\CustomCompiler = #False
SetGadgetState(#GADGET_Option_SelectCompiler, 0) ; that's the default compiler
Else
; find a matching compiler
*Compiler.Compiler = FindCompiler(*Target\CompilerVersion$)
If *Compiler = 0
MessageRequester(#ProductName$, Language("Compiler","CompilerNotFound")+":"+#NewLine+*Target\CompilerVersion$, #FLAG_Warning)
SetGadgetState(#GADGET_Option_SelectCompiler, 0)
ElseIf *Compiler = @DefaultCompiler
SetGadgetState(#GADGET_Option_SelectCompiler, 0)
Else
; one of them must match, as FindCompiler() returned something
last = CountGadgetItems(#GADGET_Option_SelectCompiler)
For index = 1 To last
If GetGadgetItemData(#GADGET_Option_SelectCompiler, index) = *Compiler
SetGadgetState(#GADGET_Option_SelectCompiler, index)
Break
EndIf
Next index
EndIf
EndIf
SetGadgetText(#GADGET_Option_SubSystem, *Target\SubSystem$)
SetGadgetState(#GADGET_Option_Debugger , *Target\Debugger)
CompilerIf #SpiderBasic
SetGadgetState(#GADGET_Option_OptimizeJS, *Target\OptimizeJS)
SetGadgetText(#GADGET_Option_SelectWindowTheme, *Target\WindowTheme$)
SetGadgetText(#GADGET_Option_SelectGadgetTheme, *Target\GadgetTheme$)
SetGadgetText(#GADGET_Option_WebServerAddress, *Target\WebServerAddress$)
CompilerElse
SetGadgetText(#GADGET_Option_IconName, *Target\IconName$)
SetGadgetState(#GADGET_Option_UseIcon , *Target\UseIcon)
SetGadgetText(#GADGET_Option_CommandLine, *Target\CommandLine$)
SetGadgetText(#GADGET_Option_Linker, *Target\LinkerOptions$)
SetGadgetText(#GADGET_Option_CurrentDir, *Target\CurrentDirectory$)
SetGadgetState(#GADGET_Option_ExecutableFormat, *Target\ExecutableFormat)
SetGadgetState(#GADGET_Option_CPU , *Target\CPU)
SetGadgetState(#GADGET_Option_Purifier , *Target\EnablePurifier)
SetGadgetState(#GADGET_Option_EnableASM , *Target\EnableASM)
SetGadgetState(#GADGET_Option_EnableThread , *Target\EnableThread)
SetGadgetState(#GADGET_Option_EnableXP , *Target\EnableXP)
SetGadgetState(#GADGET_Option_EnableAdmin , *Target\EnableAdmin)
SetGadgetState(#GADGET_Option_EnableUser , *Target\EnableUser)
SetGadgetState(#GADGET_Option_DPIAware , *Target\DPIAware)
SetGadgetState(#GADGET_Option_EnableOnError, *Target\EnableOnError)
SetGadgetState(#GADGET_Option_SelectDebugger, *Target\CustomDebugger)
If *Target\DebuggerType > 0 And *Target\DebuggerType < 4
SetGadgetState(#GADGET_Option_DebuggerMode, *Target\DebuggerType-1)
Else
SetGadgetState(#GADGET_Option_DebuggerMode, 0)
EndIf
SetGadgetState(#GADGET_Option_SelectWarning, *Target\CustomWarning)
If *Target\WarningMode >= 0 And *Target\WarningMode < 3
SetGadgetState(#GADGET_Option_WarningMode, *Target\WarningMode)
Else
SetGadgetState(#GADGET_Option_WarningMode, 1)
EndIf
SetGadgetState(#GADGET_Option_TemporaryExe, *Target\TemporaryExePlace)
CompilerEndIf
SetGadgetState(#GADGET_Option_UseCompileCount, *Target\UseCompileCount)
SetGadgetState(#GADGET_Option_UseBuildCount, *Target\UseBuildCount)
SetGadgetState(#GADGET_Option_UseCreateExe, *Target\UseCreateExe)
SetGadgetText(#GADGET_Option_CompileCount, Str(*Target\CompileCount))
SetGadgetText(#GADGET_Option_BuildCount, Str(*Target\BuildCount))
ClearGadgetItems(#GADGET_Option_ConstantList)
SetGadgetText(#GADGET_Option_ConstantLine, "")
For i = 0 To *Target\NbConstants-1
AddGadgetItem(#GADGET_Option_ConstantList, i, *Target\Constant$[i])
If *Target\ConstantEnabled[i]
SetGadgetItemState(#GADGET_Option_ConstantList, i, #PB_ListIcon_Checked)
EndIf
Next i
ClearGadgetItems(#GADGET_Option_ToolsList)
ForEach ToolsList()
If ToolsList()\SourceSpecific
Tool$ = ToolsList()\MenuItemName$+Chr(10)+Language("AddTools","Trigger"+Str(ToolsList()\Trigger))
If ToolsList()\DeactivateTool
Tool$ + Chr(10) + Language("Misc", "Disabled")
Else
Tool$ + Chr(10) + Language("Misc", "Enabled")
EndIf
AddGadgetItem(#GADGET_Option_ToolsList, -1, Tool$)
; check if the tool is enabled
; the list is in uppercase, no spaces (spaces inside names replaced by '_')
; separated by comma
;
If FindString(","+*Target\EnabledTools$+",", ","+ReplaceString(UCase(Trim(ToolsList()\MenuItemName$)), " ", "_")+",", 1) <> 0
SetGadgetItemState(#GADGET_Option_ToolsList, CountGadgetItems(#GADGET_Option_ToolsList)-1, #PB_ListIcon_Checked)
EndIf
EndIf
Next ToolsList()
CompilerIf #CompileWindows And Not #SpiderBasic
For i = 0 To 23
If i >= 15 And i <= 17 And *Target\VersionField$[i] = "" ; comboboxes
SetGadgetState(#GADGET_Option_VersionValue0+i, 0) ; set comboboxes to default
Else
SetGadgetText(#GADGET_Option_VersionValue0+i, *Target\VersionField$[i])
EndIf
Next i
SetGadgetState(#GADGET_Option_IncludeVersion, *Target\VersionInfo)
ClearGadgetItems(#GADGET_Option_ResourceList)
SetGadgetText(#GADGET_Option_ResourceFile, "")
For i = 0 To *Target\NbResourceFiles-1
AddGadgetItem(#GADGET_Option_ResourceList, -1, *Target\ResourceFiles$[i])
Next i
CompilerEndIf
DisableOptionGadgets()
EndProcedure
; returns #true if changes were made
;
Procedure TargetOptionsChanged(*Target.CompileTarget)
Changed = 0
If Options_IsProjectMode
If *Target\OutputFile$ <> GetGadgetText(#GADGET_Option_OutputFile): Changed = 1: EndIf
Else
If *Target\UseMainFile <> GetGadgetState(#GADGET_Option_UseMainFile): Changed = 1: EndIf
EndIf
If *Target\CustomCompiler <> GetGadgetState(#GADGET_Option_UseCompiler): Changed = 1: EndIf
If *Target\CustomCompiler And MatchCompilerVersion(*Target\CompilerVersion$, GetGadgetText(#GADGET_Option_SelectCompiler), #MATCH_Version|#MATCH_Beta|#MATCH_Processor) = 0
Changed = 1
EndIf
If *Target\Debugger <> GetGadgetState(#GADGET_Option_Debugger): Changed = 1: EndIf
CompilerIf #SpiderBasic
If *Target\OptimizeJS <> GetGadgetState(#GADGET_Option_OptimizeJS): Changed = 1: EndIf
If *Target\WindowTheme$ <> GetGadgetText(#GADGET_Option_SelectWindowTheme): Changed = 1: EndIf
If *Target\GadgetTheme$ <> GetGadgetText(#GADGET_Option_SelectGadgetTheme): Changed = 1: EndIf
If *Target\WebServerAddress$ <> GetGadgetText(#GADGET_Option_WebServerAddress): Changed = 1: EndIf
CompilerElse
If *Target\EnableASM <> GetGadgetState(#GADGET_Option_EnableASM): Changed = 1: EndIf
If *Target\EnablePurifier <> GetGadgetState(#GADGET_Option_Purifier): Changed = 1: EndIf
If *Target\EnableThread <> GetGadgetState(#GADGET_Option_EnableThread): Changed = 1: EndIf
If *Target\EnableXP <> GetGadgetState(#GADGET_Option_EnableXP): Changed = 1: EndIf
If *Target\EnableAdmin <> GetGadgetState(#GADGET_Option_EnableAdmin): Changed = 1: EndIf
If *Target\EnableUser <> GetGadgetState(#GADGET_Option_EnableUser): Changed = 1: EndIf
If *Target\DPIAware <> GetGadgetState(#GADGET_Option_DPIAware): Changed = 1: EndIf
If *Target\EnableOnError <> GetGadgetState(#GADGET_Option_EnableOnError): Changed = 1: EndIf
If *Target\CPU <> GetGadgetState(#GADGET_Option_CPU): Changed = 1: EndIf
If *Target\ExecutableFormat <> GetGadgetState(#GADGET_Option_ExecutableFormat): Changed = 1: EndIf
If *Target\CommandLine$ <> GetGadgetText(#GADGET_Option_CommandLine): Changed = 1: EndIf
If *Target\LinkerOptions$ <> GetGadgetText(#GADGET_Option_Linker): Changed = 1: EndIf
If *Target\CurrentDirectory$ <> GetGadgetText(#GADGET_Option_CurrentDir): Changed = 1: EndIf
If *Target\CustomDebugger <> GetGadgetState(#GADGET_Option_SelectDebugger): Changed = 1: EndIf
If *Target\CustomWarning <> GetGadgetState(#GADGET_Option_SelectWarning): Changed = 1: EndIf
If *Target\DebuggerType-1 <> GetGadgetState(#GADGET_Option_DebuggerMode) And GetGadgetState(#GADGET_Option_SelectDebugger): Changed = 1: EndIf
If *Target\WarningMode <> GetGadgetState(#GADGET_Option_WarningMode) And GetGadgetState(#GADGET_Option_SelectWarning): Changed = 1: EndIf
If *Target\TemporaryExePlace <> GetGadgetState(#GADGET_Option_TemporaryExe): Changed = 1: EndIf
If *Target\UseIcon <> GetGadgetState(#GADGET_Option_UseIcon): Changed = 1: EndIf
If *Target\IconName$ <> GetGadgetText(#GADGET_Option_IconName): Changed = 1: EndIf
CompilerEndIf
If *Target\SubSystem$ <> GetGadgetText(#GADGET_Option_SubSystem): Changed = 1: EndIf
If *Target\MainFile$ <> GetGadgetText(#GADGET_Option_MainFile): Changed = 1: EndIf
If *Target\CompileCount <> Val(GetGadgetText(#GADGET_Option_CompileCount)): Changed = 1: EndIf
If *Target\BuildCount <> Val(GetGadgetText(#GADGET_Option_BuildCount)): Changed = 1: EndIf
If *Target\UseCompileCount <> GetGadgetState(#GADGET_Option_UseCompileCount): Changed = 1: EndIf
If *Target\UseBuildCount <> GetGadgetState(#GADGET_Option_UseBuildCount): Changed = 1: EndIf
If *Target\UseCreateExe <> GetGadgetState(#GADGET_Option_UseCreateExe): Changed = 1: EndIf
If *Target\EnabledTools$ <> CompilerWindow_EnabledToolsList(): Changed = 1: EndIf
Count = CountGadgetItems(#GADGET_Option_ConstantList)
If *Target\NbConstants <> Count
Changed = 1
Else
For i = 0 To Count-1
If *Target\Constant$[i] <> GetGadgetItemText(#GADGET_Option_ConstantList, i, 0)
Changed = 1
Break
EndIf
If (GetGadgetItemState(#GADGET_Option_ConstantList, i) & #PB_ListIcon_Checked And *Target\ConstantEnabled[i] = 0) Or (GetGadgetItemState(#GADGET_Option_ConstantList, i) & #PB_ListIcon_Checked = 0 And *Target\ConstantEnabled[i])
Changed = 1
Break
EndIf
Next i
EndIf
CompilerIf #CompileWindows And Not #SpiderBasic
If *Target\VersionInfo <> GetGadgetState(#GADGET_Option_IncludeVersion): Changed = 1: EndIf
For i = 0 To 14
If *Target\VersionField$[i] <> GetGadgetText(#GADGET_Option_VersionValue0+i): Changed = 1: EndIf
Next i
; these fields are made empty when the defaults are set:
For i = 15 To 17
If *Target\VersionField$[i] <> "" Or GetGadgetState(#GADGET_Option_VersionValue0+i) <> 0
If *Target\VersionField$[i] <> GetGadgetText(#GADGET_Option_VersionValue0+i): Changed = 1: EndIf
EndIf
Next i
For i = 18 To 23
If *Target\VersionField$[i] <> GetGadgetText(#GADGET_Option_VersionValue0+i): Changed = 1: EndIf
Next i
If *Target\NbResourceFiles <> CountGadgetItems(#GADGET_Option_ResourceList): Changed = 1: EndIf
If *Target\NbResourceFiles > 0
For i = 0 To *Target\NbResourceFiles-1
If *Target\ResourceFiles$[i] <> GetGadgetItemText(#GADGET_Option_ResourceList, i, 0)
Changed = 1
Break
EndIf
Next i
EndIf
CompilerEndIf
ProcedureReturn Changed
EndProcedure
Procedure GetTargetOptions(*Target.CompileTarget)
If Options_IsProjectMode = 0
*Target\UseMainFile = GetGadgetState(#GADGET_Option_UseMainFile)
EndIf
*Target\CustomCompiler = GetGadgetState(#GADGET_Option_UseCompiler)
If *Target\CustomCompiler
*Target\CompilerVersion$ = GetGadgetText(#GADGET_Option_SelectCompiler)
EndIf
*Target\Debugger = GetGadgetState(#GADGET_Option_Debugger)
CompilerIf #SpiderBasic
*Target\OptimizeJS = GetGadgetState(#GADGET_Option_OptimizeJS)
*Target\WebServerAddress$ = GetGadgetText(#GADGET_Option_WebServerAddress)
*Target\WindowTheme$ = GetGadgetText(#GADGET_Option_SelectWindowTheme)
*Target\GadgetTheme$ = GetGadgetText(#GADGET_Option_SelectGadgetTheme)
CompilerElse
*Target\EnableASM = GetGadgetState(#GADGET_Option_EnableASM)
*Target\EnablePurifier = GetGadgetState(#GADGET_Option_Purifier)
*Target\EnableThread = GetGadgetState(#GADGET_Option_EnableThread)
*Target\EnableXP = GetGadgetState(#GADGET_Option_EnableXP)
*Target\EnableAdmin = GetGadgetState(#GADGET_Option_EnableAdmin)
*Target\EnableUser = GetGadgetState(#GADGET_Option_EnableUser)
*Target\DPIAware = GetGadgetState(#GADGET_Option_DPIAware)
*Target\EnableOnError = GetGadgetState(#GADGET_Option_EnableOnError)
*Target\CPU = GetGadgetState(#GADGET_Option_CPU)
*Target\TemporaryExePlace= GetGadgetState(#GADGET_Option_TemporaryExe)
*Target\CustomDebugger = GetGadgetState(#GADGET_Option_SelectDebugger)
*Target\DebuggerType = GetGadgetState(#GADGET_Option_DebuggerMode)+1
*Target\CustomWarning = GetGadgetState(#GADGET_Option_SelectWarning)
*Target\WarningMode = GetGadgetState(#GADGET_Option_WarningMode)
*Target\UseIcon = GetGadgetState(#GADGET_Option_UseIcon)
If *Target\UseIcon
*Target\IconName$ = Trim(GetGadgetText(#GADGET_Option_IconName))
EndIf
CompilerEndIf
*Target\UseCompileCount = GetGadgetState(#GADGET_Option_UseCompileCount)
*Target\UseBuildCount = GetGadgetState(#GADGET_Option_UseBuildCount)
*Target\UseCreateExe = GetGadgetState(#GADGET_Option_UseCreateExe)
If Options_IsProjectMode
*Target\MainFile$ = Trim(GetGadgetText(#GADGET_Option_MainFile))
*Target\OutputFile$ = Trim(GetGadgetText(#GADGET_Option_OutputFile))
*Target\FileName$ = ResolveRelativePath(GetPathPart(ProjectFile$), *Target\MainFile$)
ElseIf *Target\UseMainFile
*Target\MainFile$ = Trim(GetGadgetText(#GADGET_Option_MainFile))
EndIf
CompilerIf Not #SpiderBasic
*Target\ExecutableFormat = GetGadgetState(#GADGET_Option_ExecutableFormat)
*Target\CommandLine$ = GetGadgetText(#GADGET_Option_CommandLine)
*Target\LinkerOptions$ = Trim(GetGadgetText(#GADGET_Option_Linker))
*Target\CurrentDirectory$ = Trim(GetGadgetText(#GADGET_Option_CurrentDir))
CompilerEndIf
*Target\SubSystem$ = GetGadgetText(#GADGET_Option_SubSystem)
*Target\CompileCount = Val(GetGadgetText(#GADGET_Option_CompileCount))
*Target\BuildCount = Val(GetGadgetText(#GADGET_Option_BuildCount))
*Target\EnabledTools$ = CompilerWindow_EnabledToolsList()
*Target\NbConstants = CountGadgetItems(#GADGET_Option_ConstantList)
If *Target\NbConstants > #MAX_Constants
*Target\NbConstants = #MAX_Constants
EndIf
For i = 0 To *Target\NbConstants-1
*Target\Constant$[i] = GetGadgetItemText(#GADGET_Option_ConstantList, i, 0)
If GetGadgetItemState(#GADGET_Option_ConstantList, i) & #PB_ListIcon_Checked
*Target\ConstantEnabled[i] = #True
Else
*Target\ConstantEnabled[i] = #False
EndIf
Next i
CompilerIf #CompileWindows And Not #SpiderBasic
*Target\VersionInfo = GetGadgetState(#GADGET_Option_IncludeVersion)
For i = 0 To 23
*Target\VersionField$[i] = GetGadgetText(#GADGET_Option_VersionValue0+i)
Next i
; make fields empty when the default values are selected ( so they do not appear in the file info block all the time)
If GetGadgetState(#GADGET_Option_VersionValue0+15) = 0
*Target\VersionField$[15] = ""
EndIf
If GetGadgetState(#GADGET_Option_VersionValue0+16) = 0
*Target\VersionField$[16] = ""
EndIf
If GetGadgetState(#GADGET_Option_VersionValue0+17) = 0
*Target\VersionField$[17] = ""
EndIf
*Target\NbResourceFiles = CountGadgetItems(#GADGET_Option_ResourceList)
If *Target\NbResourceFiles > #MAX_ResourceFiles
*Target\NbResourceFiles = #MAX_ResourceFiles
EndIf
For i = 0 To *Target\NbResourceFiles-1
*Target\ResourceFiles$[i] = Trim(GetGadgetItemText(#GADGET_Option_ResourceList, i, 0))
Next i
CompilerEndIf
ProcedureReturn Changed
EndProcedure
Procedure UpdateTargetGadgets()
State = GetGadgetState(#GADGET_Option_TargetList)
If State = -1
DisableGadget(#GADGET_Option_EditTarget, 1)
DisableGadget(#GADGET_Option_CopyTarget, 1)
DisableGadget(#GADGET_Option_RemoveTarget, 1)
DisableGadget(#GADGET_Option_TargetUp, 1)
DisableGadget(#GADGET_Option_TargetDown, 1)
DisableGadget(#GADGET_Option_DefaultTarget, 1)
DisableGadget(#GADGET_Option_TargetEnabled, 1)
SetGadgetState(#GADGET_Option_DefaultTarget, 0)
SetGadgetState(#GADGET_Option_TargetEnabled, 0)
DisableMenuItem(#POPUPMENU_Options, #GADGET_Option_EditTarget, 1)
DisableMenuItem(#POPUPMENU_Options, #GADGET_Option_CopyTarget, 1)
DisableMenuItem(#POPUPMENU_Options, #GADGET_Option_RemoveTarget, 1)
DisableMenuItem(#POPUPMENU_Options, #GADGET_Option_TargetUp, 1)
DisableMenuItem(#POPUPMENU_Options, #GADGET_Option_TargetDown, 1)
DisableMenuItem(#POPUPMENU_Options, #GADGET_Option_DefaultTargetMenu, 1)
DisableMenuItem(#POPUPMENU_Options, #GADGET_Option_TargetEnabledMenu, 1)
SetMenuItemState(#POPUPMENU_Options, #GADGET_Option_DefaultTargetMenu, 0)
SetMenuItemState(#POPUPMENU_Options, #GADGET_Option_TargetEnabledMenu, 0)
Else
SelectElement(ProjectOptionTargets(), State)
Count = ListSize(ProjectOptionTargets())
DisableGadget(#GADGET_Option_EditTarget, 0)
DisableGadget(#GADGET_Option_CopyTarget, 0)
DisableMenuItem(#POPUPMENU_Options, #GADGET_Option_EditTarget, 0)
DisableMenuItem(#POPUPMENU_Options, #GADGET_Option_CopyTarget, 0)
If Count = 1
DisableGadget(#GADGET_Option_RemoveTarget, 1) ; must keep at least one target (and at least one default)
DisableGadget(#GADGET_Option_DefaultTarget, 1)
SetGadgetState(#GADGET_Option_DefaultTarget, 1)
DisableMenuItem(#POPUPMENU_Options, #GADGET_Option_RemoveTarget, 1)
DisableMenuItem(#POPUPMENU_Options, #GADGET_Option_DefaultTargetMenu, 1)
SetMenuItemState(#POPUPMENU_Options, #GADGET_Option_DefaultTargetMenu, 1)
Else
DisableGadget(#GADGET_Option_RemoveTarget, 0)
DisableGadget(#GADGET_Option_DefaultTarget, 0)
DisableMenuItem(#POPUPMENU_Options, #GADGET_Option_RemoveTarget, 0)
DisableMenuItem(#POPUPMENU_Options, #GADGET_Option_DefaultTargetMenu, 0)
If ProjectOptionTargets()\IsDefault
SetGadgetState(#GADGET_Option_DefaultTarget, 1)
SetMenuItemState(#POPUPMENU_Options, #GADGET_Option_DefaultTargetMenu, 1)
Else
SetGadgetState(#GADGET_Option_DefaultTarget, 0)
SetMenuItemState(#POPUPMENU_Options, #GADGET_Option_DefaultTargetMenu, 0)
EndIf
EndIf
If State = 0
DisableGadget(#GADGET_Option_TargetUp, 1)
DisableMenuItem(#POPUPMENU_Options, #GADGET_Option_TargetUp, 1)
Else
DisableGadget(#GADGET_Option_TargetUp, 0)
DisableMenuItem(#POPUPMENU_Options, #GADGET_Option_TargetUp, 0)
EndIf
If State = Count-1
DisableGadget(#GADGET_Option_TargetDown, 1)
DisableMenuItem(#POPUPMENU_Options, #GADGET_Option_TargetDown, 1)
Else
DisableGadget(#GADGET_Option_TargetDown, 0)
DisableMenuItem(#POPUPMENU_Options, #GADGET_Option_TargetDown, 0)
EndIf
DisableGadget(#GADGET_Option_TargetEnabled, 0)
DisableMenuItem(#POPUPMENU_Options, #GADGET_Option_TargetEnabledMenu, 0)
If ProjectOptionTargets()\IsEnabled
SetGadgetState(#GADGET_Option_TargetEnabled, 1)
SetMenuItemState(#POPUPMENU_Options, #GADGET_Option_TargetEnabledMenu, 1)
Else
SetGadgetState(#GADGET_Option_TargetEnabled, 0)
SetMenuItemState(#POPUPMENU_Options, #GADGET_Option_TargetEnabledMenu, 0)
EndIf
EndIf
EndProcedure
Procedure ProjectTargetImage(*Target.CompileTarget)
If *Target\IsDefault
ProcedureReturn ImageID(#IMAGE_Option_DefaultTarget)
ElseIf *Target\IsEnabled
ProcedureReturn ImageID(#IMAGE_Option_NormalTarget)
Else
ProcedureReturn ImageID(#IMAGE_Option_DisabledTarget)
EndIf
EndProcedure
Procedure OpenOptionWindow(ForceProjectOptions, *InitialTarget.CompileTarget = 0)
If IsWindow(#WINDOW_Option) = 0
; Use a slightly different dialog for project options
;
If *ActiveSource = *ProjectInfo Or *ActiveSource\ProjectFile Or (IsProject And ForceProjectOptions)
Options_IsProjectMode = #True
OptionWindowDialog = OpenDialog(?Dialog_ProjectCompilerOptions, WindowID(#WINDOW_Main), @ProjectOptionWindowPosition)
Else
Options_IsProjectMode = #False
OptionWindowDialog = OpenDialog(?Dialog_CompilerOptions, WindowID(#WINDOW_Main), @OptionWindowPosition)
EndIf
If OptionWindowDialog
EnsureWindowOnDesktop(#WINDOW_Option)
EnableGadgetDrop(#GADGET_Option_MainFile, #PB_Drop_Files, #PB_Drag_Copy)
CompilerIf #SpiderBasic
If Options_IsProjectMode
HideGadget(#GADGET_Option_OutputFileLabel, #True)
HideGadget(#GADGET_Option_OutputFile, #True)
HideGadget(#GADGET_Option_SelectOutputFile, #True)
EndIf
; Scan the available window themes
;
If ExamineDirectory(0, PureBasicPath$+"libraries/javascript/themes", "")
While NextDirectoryEntry(0)
If DirectoryEntryType(0) = #PB_DirectoryEntry_Directory And Left(DirectoryEntryName(0), 1) <> "." ; ignore ".", ".." and all hidden directories
AddGadgetItem(#GADGET_Option_SelectWindowTheme, -1, DirectoryEntryName(0))
EndIf
Wend
EndIf
; Scan the available gadget themes
;
If ExamineDirectory(0, PureBasicPath$+"libraries/javascript/dojo/themes", "")
While NextDirectoryEntry(0)
If DirectoryEntryType(0) = #PB_DirectoryEntry_Directory And Left(DirectoryEntryName(0), 1) <> "." ; ignore ".", ".." and all hidden directories
AddGadgetItem(#GADGET_Option_SelectGadgetTheme, -1, DirectoryEntryName(0))
EndIf
Wend
EndIf
CompilerElse
EnableGadgetDrop(#GADGET_Option_IconName, #PB_Drop_Files, #PB_Drag_Copy)
EnableGadgetDrop(#GADGET_Option_Linker, #PB_Drop_Files, #PB_Drag_Copy)
EnableGadgetDrop(#GADGET_Option_CurrentDir, #PB_Drop_Files, #PB_Drag_Copy)
CompilerEndIf
AddGadgetItem(#GADGET_Option_SelectCompiler, -1, DefaultCompiler\VersionString$)
ForEach Compilers()
If Compilers()\Validated
AddGadgetItem(#GADGET_Option_SelectCompiler, -1, Compilers()\VersionString$)
SetGadgetItemData(#GADGET_Option_SelectCompiler, CountGadgetItems(#GADGET_Option_SelectCompiler)-1, @Compilers())
EndIf
Next Compilers()
CompilerIf #CompileWindows And Not #SpiderBasic
Restore Resource_Strings
For i = 15 To 17
Read.l Count
For s = 1 To Count
Read.s Value$
AddGadgetItem(#GADGET_Option_VersionValue0+i, -1, Value$)
Next s
Next i
EnableGadgetDrop(#GADGET_Option_ResourceList, #PB_Drop_Files, #PB_Drag_Copy)
EnableGadgetDrop(#GADGET_Option_ResourceFile, #PB_Drop_Files, #PB_Drag_Copy)
CompilerEndIf
If Options_IsProjectMode
Options_CurrentBasePath$ = GetPathPart(ProjectFile$)
EnableGadgetDrop(#GADGET_Option_OutputFile, #PB_Drop_Files, #PB_Drag_Copy)
SetGadgetAttribute(#GADGET_Option_AddTarget, #PB_Button_Image, ImageID(#IMAGE_Option_AddTarget))
SetGadgetAttribute(#GADGET_Option_EditTarget, #PB_Button_Image, ImageID(#IMAGE_Option_EditTarget))
SetGadgetAttribute(#GADGET_Option_CopyTarget, #PB_Button_Image, ImageID(#IMAGE_Option_CopyTarget))
SetGadgetAttribute(#GADGET_Option_RemoveTarget, #PB_Button_Image, ImageID(#IMAGE_Option_RemoveTarget))
SetGadgetAttribute(#GADGET_Option_TargetUp, #PB_Button_Image, ImageID(#IMAGE_Option_TargetUp))
SetGadgetAttribute(#GADGET_Option_TargetDown, #PB_Button_Image, ImageID(#IMAGE_Option_TargetDown))
GadgetToolTip(#GADGET_Option_AddTarget, Language("Compiler","AddTarget"))
GadgetToolTip(#GADGET_Option_EditTarget, Language("Compiler","RenameTarget"))
GadgetToolTip(#GADGET_Option_CopyTarget, Language("Compiler","CopyTarget"))
GadgetToolTip(#GADGET_Option_RemoveTarget, Language("Compiler","RemoveTarget"))
GadgetToolTip(#GADGET_Option_TargetUp, Language("Compiler","TargetUp"))
GadgetToolTip(#GADGET_Option_TargetDown, Language("Compiler","TargetDown"))
; resize with the actual button images and fold state
OptionWindowDialog\GuiUpdate()
; Create the popupmenu
;
If EnableMenuIcons
*Popup = CreatePopupImageMenu(#POPUPMENU_Options)
Else
*Popup = CreatePopupMenu(#POPUPMENU_Options)
EndIf
; Re-use the gadget ids for the menu for simplicity (same as for the shortcuts)
If *Popup
MenuItem(#GADGET_Option_AddTarget, Language("Compiler","AddTarget"), ImageID(#IMAGE_Option_AddTarget))
MenuItem(#GADGET_Option_CopyTarget, Language("Compiler","CopyTarget"), ImageID(#IMAGE_Option_CopyTarget))
MenuItem(#GADGET_Option_EditTarget, Language("Compiler","RenameTarget"), ImageID(#IMAGE_Option_EditTarget))
MenuBar()
MenuItem(#GADGET_Option_RemoveTarget, Language("Compiler","RemoveTarget"), ImageID(#IMAGE_Option_RemoveTarget))
MenuBar()
MenuItem(#GADGET_Option_TargetUp, Language("Compiler","TargetUp"), ImageID(#IMAGE_Option_TargetUp))
MenuItem(#GADGET_Option_TargetDown, Language("Compiler","TargetDown"), ImageID(#IMAGE_Option_TargetDown))
MenuBar()
MenuItem(#GADGET_Option_DefaultTargetMenu, Language("Compiler","DefaultTarget"))
MenuItem(#GADGET_Option_TargetEnabledMenu, Language("Compiler","EnableTarget"))
EndIf
ClearList(ProjectOptionTargets())
CurrentIndex = -1
*Options_CurrentTarget = 0
If *InitialTarget = 0
*InitialTarget = *DefaultTarget
EndIf
ForEach ProjectTargets()
AddElement(ProjectOptionTargets())
ProjectOptionTargets() = ProjectTargets() ; copy the entire settings
If @ProjectTargets() = *InitialTarget
CurrentIndex = ListIndex(ProjectTargets())
*Options_CurrentTarget = @ProjectOptionTargets()
EndIf
If @ProjectTargets() = *DefaultTarget
ProjectOptionTargets()\IsDefault = #True
Else
ProjectOptionTargets()\IsDefault = #False
EndIf
AddGadgetItem(#GADGET_Option_TargetList, -1, ProjectOptionTargets()\Name$, ProjectTargetImage(@ProjectOptionTargets()))
Next ProjectTargets()
If CurrentIndex <> -1
SetGadgetState(#GADGET_Option_TargetList, CurrentIndex)
EndIf
SetTargetOptions(*InitialTarget)
UpdateTargetGadgets()
Else
If *ActiveSource\Filename$ ; already saved
Options_CurrentBasePath$ = GetPathPart(*ActiveSource\Filename$)
Else
Options_CurrentBasePath$ = "" ; use full paths then
EndIf
; just set the active source options
SetTargetOptions(*ActiveSource)
EndIf
CompilerIf #CompileWindows
SendMessage_(GadgetID(#GADGET_Option_ConstantList), #LVM_SETCOLUMNWIDTH, 0, #LVSCW_AUTOSIZE_USEHEADER)
If Options_IsProjectMode
SendMessage_(GadgetID(#GADGET_Option_TargetList), #LVM_SETCOLUMNWIDTH, 0, #LVSCW_AUTOSIZE_USEHEADER)
EndIf
CompilerEndIf
; While this dialog is open, disable the menu entry to avoid inconsistency
DisableMenuItem(#MENU, #MENU_Debugger, #True)
HideWindow(#WINDOW_Option, 0)
EndIf
Else
SetWindowForeground(#WINDOW_Option)
EndIf
EndProcedure
Procedure OptionWindowEvents(EventID)
If EventID = #PB_Event_Menu ; Little wrapper to map the shortcut events (identified as menu)
EventID = #PB_Event_Gadget ; to normal gadget events...
GadgetID = EventMenu()
Else
GadgetID = EventGadget()
EndIf
Select EventID
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_GadgetDrop
Select GadgetID
Case #GADGET_Option_MainFile
File$ = StringField(EventDropFiles(), 1, Chr(10)) ; ignore all but the first entry
SetGadgetText(#GADGET_Option_MainFile, CreateRelativePath(Options_CurrentBasePath$, File$))
Case #GADGET_Option_OutputFile
File$ = StringField(EventDropFiles(), 1, Chr(10)) ; ignore all but the first entry
SetGadgetText(#GADGET_Option_MainFile, CreateRelativePath(Options_CurrentBasePath$, File$))
CompilerIf Not #SpiderBasic
Case #GADGET_Option_IconName
File$ = StringField(EventDropFiles(), 1, Chr(10))
SetGadgetText(#GADGET_Option_IconName, CreateRelativePath(Options_CurrentBasePath$, File$))
Case #GADGET_Option_Linker
File$ = StringField(EventDropFiles(), 1, Chr(10))
SetGadgetText(#GADGET_Option_Linker, CreateRelativePath(Options_CurrentBasePath$, File$))
Case #GADGET_Option_CurrentDir
Path$ = StringField(EventDropFiles(), 1, Chr(10))
If FileSize(Path$) <> -2 ; probably a file then
Path$ = GetPathPart(Path$)
EndIf
SetGadgetText(#GADGET_Option_CurrentDir, CreateRelativePath(Options_CurrentBasePath$, Path$))
CompilerIf #CompileWindows
Case #GADGET_Option_ResourceList
Files$ = EventDropFiles() ; look at all files here...
Count = CountString(Files$, Chr(10))+1
For i = 1 To Count
File$ = StringField(Files$, i, Chr(10))
If FileSize(File$) <> -2 ; no directories!
AddGadgetItem(#GADGET_Option_ResourceList, -1, CreateRelativePath(Options_CurrentBasePath$, File$))
EndIf
Next i
Case #GADGET_Option_ResourceFile
File$ = StringField(EventDropFiles(), 1, Chr(10))
SetGadgetText(#GADGET_Option_ResourceFile, CreateRelativePath(Options_CurrentBasePath$, File$))
CompilerEndIf
CompilerEndIf
EndSelect
Case #PB_Event_Gadget
Select GadgetID
Case #GADGET_Option_Ok
If Options_IsProjectMode = 0
; Make sure the modified flag is set if any changes were done.
;
If TargetOptionsChanged(*ActiveSource)
UpdateSourceStatus(1) ; set the changed flag
EndIf
; update the highlighting if EnableASM changes
;
OldEnableASM = *ActiveSource\EnableASM
GetTargetOptions(*ActiveSource)
If OldEnableASM <> *ActiveSource\EnableASM
UpdateHighlighting()
EndIf
SetDebuggerMenuStates() ; update the debugger menu state, as we can enable/disable it in the compiler options
Quit = 1
Else
; get the latest changes
If *Options_CurrentTarget
GetTargetOptions(*Options_CurrentTarget)
EndIf
; check for missing MainFile$ names in the list and warn/abort if so
Quit = 1
ForEach ProjectOptionTargets()
If Trim(ProjectOptionTargets()\MainFile$) = ""
; make the target in question the current one
*Options_CurrentTarget = @ProjectOptionTargets()
SetTargetOptions(*Options_CurrentTarget)
SetGadgetState(#GADGET_Option_TargetList, ListIndex(ProjectOptionTargets()))
UpdateTargetGadgets()
If MessageRequester(Language("Compiler","OptionsTitle"), LanguagePattern("Compiler","NoInputFile", "%target%", ProjectOptionTargets()\Name$)+#NewLine+Language("Compiler","SaveAnyway"), #PB_MessageRequester_YesNo|#FLAG_Warning) = #PB_MessageRequester_No
Quit = 0
Break
EndIf
EndIf
Next ProjectOptionTargets()
; copy the changes back to the real project list
If Quit
ClearList(ProjectTargets())
ForEach ProjectOptionTargets()
AddElement(ProjectTargets())
ProjectTargets() = ProjectOptionTargets() ; structure copy
Next ProjectOptionTargets()
; set the *DefaultTarget variable properly and ensuer there is a def target
SetProjectDefaultTarget()
SetDebuggerMenuStates()
; update the menu to reflect our target changes
StartFlickerFix(#WINDOW_Main)
CreateIDEMenu()
StopFlickerFix(#WINDOW_Main, 1)
EndIf
EndIf
Case #GADGET_Option_Cancel
ClearList(ProjectOptionTargets()) ; do not apply these changes
Quit = 1
Case #GADGET_Option_UseMainFile
DisableOptionGadgets()
Case #GADGET_Option_Debugger
; No action here anymore, as the menu item is disabled anyway for consistency
Case #GADGET_Option_SelectMainFile
File$ = ResolveRelativePath(Options_CurrentBasePath$, GetGadgetText(#GADGET_Option_MainFile))
If Trim(File$) = ""
File$ = Options_CurrentBasePath$
EndIf
File$ = OpenFileRequester(Language("Compiler","OpenMainFile"), File$, Language("Compiler","SourcePattern"), 0)
If File$
SetGadgetText(#GADGET_Option_MainFile, CreateRelativePath(Options_CurrentBasePath$, File$))
EndIf
Case #GADGET_Option_UseCompiler
DisableGadget(#GADGET_Option_SelectCompiler, 1-GetGadgetState(#GADGET_Option_UseCompiler))
CompilerIf Not #SpiderBasic
Case #GADGET_Option_SelectOutputFile
File$ = ResolveRelativePath(Options_CurrentBasePath$, GetGadgetText(#GADGET_Option_OutputFile))
If Trim(File$) = ""
File$ = Options_CurrentBasePath$
EndIf
If GetGadgetState(#GADGET_Option_ExecutableFormat) = 2 ; shared dll
CompilerIf #CompileWindows
Pattern$ = Language("Compiler","DllPattern")
Extension$ = ".dll"
CompilerElseIf #CompileMac
Pattern$ = "Shared Library (*.dylib)|*.dylib|All Files (*.*)|*.*"
Extension$ = ".dylib"
CompilerElse ; Linux
Pattern$ = "Shared Library (*.so)|*.so|All Files (*.*)|*.*"
Extension$ = ".so"
CompilerEndIf
Else
CompilerIf #CompileWindows
Pattern$ = Language("Compiler","ExePattern")
Extension$ = ".exe"
CompilerElseIf #CompileMac
Pattern$ = ""
If GetGadgetState(#GADGET_Option_ExecutableFormat) = 1 ; console
Extension$ = "" ; console, do not append .app automatically here
Else
Extension$ = ".app" ; automatically append ".app" for gui programs
EndIf
CompilerElse ; Linux
Pattern$ = ""
Extension$ = ""
CompilerEndIf
EndIf
File$ = SaveFileRequester(Language("Compiler","SetOutputFile"), File$, Pattern$, 0)
If File$
If LCase(Right(File$, Len(Extension$))) <> Extension$ And SelectedFilePattern() <> 1
File$+Extension$
EndIf
SetGadgetText(#GADGET_Option_OutputFile, CreateRelativePath(Options_CurrentBasePath$, File$))
EndIf
Case #GADGET_Option_SelectIcon
File$ = ResolveRelativePath(Options_CurrentBasePath$, GetGadgetText(#GADGET_Option_IconName))
If Trim(File$) = ""
File$ = Options_CurrentBasePath$
EndIf
Pattern$ = Language("Compiler","IconPattern")
CompilerIf #CompileMac
; change .ico to .icns
Pattern$ = ReplaceString(Pattern$, "ico", "icns")
CompilerEndIf
File$ = OpenFileRequester(Language("Compiler","OpenIcon"), File$, Pattern$, 0)
If File$
If SelectedFilePattern() = 0 And GetExtensionPart(File$) = ""
CompilerIf #CompileWindows
Ext$ = "ico"
CompilerElse
Ext$ = "icns"
CompilerEndIf
File$ + "." + Ext$
EndIf
SetGadgetText(#GADGET_Option_IconName, CreateRelativePath(Options_CurrentBasePath$, File$))
EndIf
Case #GADGET_Option_UseIcon
Result = GetGadgetState(#GADGET_Option_UseIcon)
DisableGadget(#GADGET_Option_IconName , 1-Result)
DisableGadget(#GADGET_Option_SelectIcon, 1-Result)
Case #GADGET_Option_GetLinker
File$ = ResolveRelativePath(Options_CurrentBasePath$, GetGadgetText(#GADGET_Option_Linker))
If Trim(File$) = ""
File$ = Options_CurrentBasePath$
EndIf
File$ = OpenFileRequester(Language("Compiler","OpenLinkerFile"), File$, Language("Compiler","AllFilesPattern"), 0)
If File$
SetGadgetText(#GADGET_Option_Linker, CreateRelativePath(Options_CurrentBasePath$, File$))
EndIf
Case #GADGET_Option_SelectDebugger
DisableOptionGadgets()
Case #GADGET_Option_DebuggerMode
DisableOptionGadgets()
Case #GADGET_Option_SelectWarning
DisableOptionGadgets()
Case #GADGET_Option_SelectCurrentDir
If Trim(GetGadgetText(#GADGET_Option_CurrentDir)) = ""
Path$ = Options_CurrentBasePath$
Else
Path$ = ResolveRelativePath(Options_CurrentBasePath$, GetGadgetText(#GADGET_Option_CurrentDir))
EndIf
Path$ = PathRequester("", Path$)
If Path$