forked from nitrologic/maxide
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmaxide.bmx
8090 lines (7146 loc) · 220 KB
/
maxide.bmx
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
' maxide.bmx
' BlitzMax native integrated development environment
' Copyright (c) 2005-2014 Simon Armstrong, Blitz Research Limited
' Copyright (c) 2015-2022 Bruce A Henderson
' Permission is hereby granted, free of charge, to any person obtaining a copy
' of this software and associated documentation files (the "Software"), to deal
' in the Software without restriction, including without limitation the rights
' to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
' copies of the Software, and to permit persons to whom the Software is
' furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in
' all copies or substantial portions of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
' AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
' LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
' OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
' THE SOFTWARE.
Strict
Framework brl.standardio
?macos
Import MaxGUI.CocoaMaxGui
?win32
Import MaxGUI.Win32MaxGUIEx
Import MaxGUI.maxguitextareascintilla
?linux
Import MaxGUI.gtk3maxgui
'Import MaxGUI.gtk3webkitgtk
Import MaxGUI.gtk3webkit2gtk
Import MaxGUI.maxguitextareascintilla
?
Import MaxGUI.ProxyGadgets
Import brl.eventqueue
Import brl.filesystem
Import brl.system
Import brl.ramstream
Import pub.freeprocess
Import brl.pngloader
Import brl.timer
?bmxng
Import brl.timerdefault
?
Import brl.maxutil
Import brl.stringbuilder
Incbin "bmxlogo.png"
Incbin "toolbar.png"
Incbin "toolbar_48.png"
Incbin "toolbar_64.png"
Incbin "splash.png"
Incbin "default.language.ini"
Const DEFAULT_LANGUAGEPATH$ = "incbin::default.language.ini"
?Linux
Incbin "window_icon.png"
?
Const IDE_NAME$="MaxIDE"
Const IDE_VERSION$="1.56 [ng]"
Const TIMER_FREQUENCY=15
AppTitle = IDE_NAME + " " + IDE_VERSION
?Win32
Extern
Global _bbusew 'secret 'NT' flag
End Extern
If Not _bbusew
Notify ("This program is not compatible with Windows 95/98/ME.~n~n", True)
End
EndIf
?
Global BCC_VERSION$="{unknown}" 'not valid until codeplay opened
Const EOL$="~n"
Const FileTypes$="bmx,bbdoc,txt,ini,doc,plist,bb,cpp,c,cc,m,cxx,s,glsl,hlsl,lua,py,h,hpp,html,htm,css,js,bat,sh,mm,as,java,bbx,cx"
Const FileTypeFilters$="Code Files:"+FileTypes$+";All Files:*"
Const HOMEPAGE$="/docs/html/index.html"
?MacOS
Const LABELOFFSET=2
?Win32
Const LABELOFFSET=4
?Linux
Const LABELOFFSET=0
?
Const MENUNEW=1
Const MENUOPEN=2
Const MENUCLOSE=3
Const MENUSAVE=4
Const MENUSAVEAS=5
Const MENUSAVEALL=6
Const MENUPRINT=7
Const MENUQUIT=8
Const MENUUNDO=9
Const MENUREDO=10
Const MENUCUT=11
Const MENUCOPY=12
Const MENUPASTE=13
Const MENUSELECTALL=14
Const MENUGOTO=15
Const MENUINDENT=16
Const MENUOUTDENT=17
Const MENUFIND=18
Const MENUFINDNEXT=19
Const MENUREPLACE=20
Const MENUNEXT=21
Const MENUPREV=22
Const MENUBUILD=23
Const MENURUN=24
Const MENUSTEP=25
Const MENUSTEPIN=26
Const MENUSTEPOUT=27
Const MENUSTOP=28
Const MENULOCKBUILD=29
Const MENUUNLOCKBUILD=30
Const MENUBUILDMODULES=31
Const MENUBUILDALLMODULES=32
Const MENUQUICKENABLED=33
Const MENUDEBUGENABLED=34
'Const MENUGUIENABLED=35
Const MENUCOMMANDLINE=36
Const MENUIMPORTBB=38
Const MENUFINDINFILES=39
Const MENUPROJECTMANAGER=40
Const MENUSHOWCONSOLE=41
Const MENUOPTIONS=42
Const MENUHOME=43
Const MENUBACK=44
Const MENUFORWARD=45
Const MENUQUICKHELP=46
Const MENUABOUT=47
Const MENUNEWVIEW=48
Const MENUDOCMODS=49
Const MENUTRIGGERDOCMODS=50
Const MENUTRIGGERSYNCDOCS=51
Const MENUCLOSEALL=53
Const MENUREFRESH=54
Const MENUBROWSE=55
Const MENUSHELL=56
Const MENUPROPS=57
Const MENUUPDATE=58
Const MENUCOMMIT=59
Const MENUCLOSEOTHERS=60
Const MENUTHREADEDENABLED=61
Const MENUVERBOSEENABLED=62
Const MENUQUICKSCANENABLED=63
Const MENUUNIVERSALENABLED=64
Const MENUWARNOVERENABLED=65
Const MENUGDBDEBUGENABLED=66
Const MENUREQUIREOVERRIDEENABLED=67
Const MENUOVERRIDEERRORSENABLED=68
Const MENUGPROFENABLED=69
Const MENUHIRESENABLED=170
Const MENUAPPOPTIONS=70
Const MENUCONSOLEENABLED=71
Const MENUGUIENABLED=72
Const MENUMAKELIBENABLED=73
Const MENUPLATFORM=80
Const MENUWIN32ENABLED=81
Const MENULINUXENABLED=82
Const MENUMACOSXENABLED=83
Const MENURASPBERRYPIENABLED=84
Const MENUANDROIDENABLED=85
Const MENUEMSCRIPTENENABLED=86
Const MENUIOSENABLED=87
Const MENUNXENABLED=88
Const MENUARCHITECTURE=90
Const MENUX86ENABLED=91
Const MENUX64ENABLED=92
Const MENUPPCENABLED=93
Const MENUARMENABLED=94
Const MENUARMEABIV5ENABLED=95
Const MENUARMEABIV7AENABLED=96
Const MENUARM64V8AENABLED=97
Const MENUJSENABLED=98
Const MENUARMV7ENABLED=99
Const MENUARM64ENABLED=100
Const MENUGOTOBUILD=110
Const MENUMISC=140
Const MENUUPXENABLED=141
Const MENULAST=142
Const MENUAPPSTUB=160
Const MENURECENT=256
Const TB_NEW=0
Const TB_OPEN=1
Const TB_CLOSE=2
Const TB_SAVE=3
'spacer=4
Const TB_CUT=5
Const TB_COPY=6
Const TB_PASTE=7
Const TB_FIND=8
'spacer=9
Const TB_BUILD=10
Const TB_BUILDRUN=11
Const TB_STEP=12
Const TB_STEPIN=13
Const TB_STEPOUT=14
Const TB_STOP=15
'spacer=16
Const TB_HOME=17
Const TB_BACK=18
Const TB_FORWARDS=19
'spacer=20
Const TB_LOCKOPEN=21
Const TB_LOCKGOTO=22
'toggle state elements:
Const TB_CONTINUE=23
Const TB_LOCKCLOSED=24
Const TAB$=Chr(9)
Const QUOTES$=Chr(34)
'values assigned for the shortcut (OS specific)
Global lastTabKey:Int
Global lastTabMod:Int
Global TEMPCOUNT
Global codeplay:TCodePlay
Global defaultLanguage:TMaxGUILanguage = LoadLanguage( DEFAULT_LANGUAGEPATH )
SetLocalizationLanguage( defaultLanguage )
SetLocalizationMode( LOCALIZATION_ON|LOCALIZATION_OVERRIDE )
codeplay=New TCodePlay
codeplay.Initialize
While codeplay.running
codeplay.poll
Wend
End
Function Quote$(a$) 'add quotes to arg if spaces found
Local p
If Not a.length Return
If a[0]=34 Return a 'already quoted
p=a.find(" ")
If p=-1 Return a 'no spaces
Return Chr(34)+a+Chr(34)
End Function
Type TToken
Field token$
Field help$
Field ref$
Method Create:TToken(t$,h$,r$)
token=t
help=h
ref=r
Return Self
End Method
End Type
Type TQuickHelp
Field map:TMap=New TMap 'key=lower(token) value=token:TToken
Field tokens:String
Method AddCommand:TQuickHelp(t$,l$,a$)
map.Insert t.ToLower(),New TToken.Create(t$,l$,a$)
End Method
Method Token$(cmd$)
Local t:TToken = TToken(map.ValueForKey(cmd.toLower()))
If t Return t.token
End Method
Method Help$(cmd$)
Local t:TToken = TToken(map.ValueForKey(cmd.toLower()))
If t Return t.help
End Method
Method Link$(cmd$)
Local t:TToken = TToken(map.ValueForKey(cmd.toLower()))
If t Return t.ref
End Method
Function LoadCommandsTxt:TQuickHelp(bmxpath$)
Local Text$
Local qh:TQuickHelp
Local i:Int,c,p,q
Local token$,help$,anchor$
Try
Text=CacheAndLoadText(bmxpath+"/docs/html/Modules/commands.txt")
Catch exception:Object
Return Null
EndTry
If Not Text Return Null
qh=New TQuickHelp
Local sb:TStringBuilder = New TStringBuilder
For Local l$ = EachIn Text.Split("~n")
For i=0 Until l.length
c=l[i]
If c=Asc("_") Continue
If c>=Asc("0") And c<=Asc("9") Continue
If c>=Asc("a") And c<=Asc("z") Continue
If c>=Asc("A") And c<=Asc("Z") Continue
Exit
Next
token$=l[..i]
help$=""
anchor$=""
q=l.findlast("|")
If q>=0
help=l[..q]
anchor=l[q+1..]
EndIf
qh.AddCommand token,help,anchor
If sb.Length() > 0 Then
sb.Append(" ")
End If
sb.Append(token)
Next
qh.tokens = sb.ToString().ToLower()
Return qh
End Function
End Type
Const TOOLSHOW=1
Const TOOLREFRESH=2
Const TOOLNEW=3
Const TOOLOPEN=4
Const TOOLCLOSE=5
Const TOOLSAVE=6
Const TOOLHELP=7
Const TOOLUNDO=8
Const TOOLREDO=9
Const TOOLCUT=10
Const TOOLCOPY=11
Const TOOLPASTE=12
Const TOOLQUICKSAVE=13
Const TOOLSAVEAS=14
Const TOOLGOTO=15
Const TOOLFIND=16
Const TOOLFINDNEXT=17
Const TOOLREPLACE=18
Const TOOLBUILD=19
Const TOOLRUN=20
Const TOOLLOCK=21
Const TOOLUNLOCK=22
Const TOOLSELECT=23
Const TOOLSELECTALL=24
Const TOOLINDENT=25
Const TOOLOUTDENT=26
Const TOOLACTIVATE=27
Const TOOLNAVIGATE=28
Const TOOLNEWVIEW=29
Const TOOLMENU=30
Const TOOLPRINT=31
Const TOOLERROR=32
Const TOOLOUTPUT=32
Type TTool
Method Invoke(command,argument:Object=Null)
End Method
End Type
Type TRequester
Const STYLE_OK% = 1, STYLE_CANCEL% = 2
Const STYLE_DIVIDER% = 4, STYLE_STATUS% = 8
Const STYLE_RESIZABLE% = 16, STYLE_STDBORDER% = 32
Const STYLE_MODAL% = 64
Field host:TCodePlay
Field window:TGadget,ok:TGadget,cancel:TGadget,divider:TGadget
Field centered, modal
Method initrequester(owner:TCodeplay,label$,w=260,h=60,flags=STYLE_OK|STYLE_CANCEL|STYLE_DIVIDER,oktext$="{{btn_ok}}")
Local buttonPadding:Int = 7
host=owner
If (flags&STYLE_MODAL) Then flags:|STYLE_STDBORDER
If (flags & (STYLE_CANCEL|STYLE_OK)) Then h:+ScaledSize(32);If (flags&STYLE_DIVIDER) Then h:+ScaledSize(12)
Local windowflags% = WINDOW_TITLEBAR|WINDOW_HIDDEN|WINDOW_CLIENTCOORDS
If (flags & STYLE_STATUS) Then windowflags:|WINDOW_STATUS
If (flags & STYLE_RESIZABLE) Then windowflags:|WINDOW_RESIZABLE
If Not (flags & STYLE_STDBORDER) Then windowflags:|WINDOW_TOOL
window=CreateWindow(label,0,0,w,h,host.window,windowflags)
If (flags & STYLE_RESIZABLE) Then
If (flags & STYLE_STDBORDER) Then SetMaxWindowSize(window,ClientWidth(Desktop()),ClientHeight(Desktop()))
SetMinWindowSize(window,w,h)
EndIf
If (flags & STYLE_OK) Then
ok=CreateButton(oktext,ClientWidth(window)-ScaledSize(95+buttonPadding),ClientHeight(window)-ScaledSize(32),ScaledSize(95),ScaledSize(26),window,BUTTON_OK)
SetGadgetLayout(ok,EDGE_CENTERED,EDGE_ALIGNED,EDGE_CENTERED,EDGE_ALIGNED)
If (flags & STYLE_CANCEL) Then
cancel=CreateButton("{{btn_cancel}}",ScaledSize(buttonPadding),ClientHeight(window)-ScaledSize(32),ScaledSize(95),ScaledSize(26),window,BUTTON_CANCEL)
SetGadgetLayout(cancel,EDGE_ALIGNED,EDGE_CENTERED,EDGE_CENTERED,EDGE_ALIGNED)
EndIf
Else
If (flags & STYLE_CANCEL) Then
cancel=CreateButton("{{btn_close}}",ClientWidth(window)-ScaledSize(95+buttonPadding),ClientHeight(window)-ScaledSize(32),ScaledSize(95),ScaledSize(26),window,BUTTON_CANCEL)
SetGadgetLayout(cancel,EDGE_CENTERED,EDGE_ALIGNED,EDGE_CENTERED,EDGE_ALIGNED)
EndIf
EndIf
If (flags & STYLE_DIVIDER) And (flags & (STYLE_OK|STYLE_CANCEL)) Then
divider = CreateLabel( "", ScaledSize(buttonPadding), ClientHeight(window)-ScaledSize(42), ClientWidth(window)-ScaledSize(12), ScaledSize(4), window, LABEL_SEPARATOR )
SetGadgetLayout(divider,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_CENTERED,EDGE_ALIGNED)
EndIf
If (flags & STYLE_MODAL) Then modal = True Else modal = False
End Method
Method Show()
Local x,y,w,h,win:TGadget
If Not centered
win=host.window
w=GadgetWidth(window)
h=GadgetHeight(window)
x=GadgetX(win)+(GadgetWidth(win)-w)/2
y=GadgetY(win)+(GadgetHeight(win)-h)/2
SetGadgetShape window,x,y,w,h
centered=True
EndIf
host.HookRequester Self
ShowGadget window
ActivateGadget window
PollSystem
End Method
Method Hide()
EnableGadget host.window
HideGadget window
host.UnhookRequester Self
host.SelectPanel host.currentpanel
End Method
Method IsModal()
Return modal
EndMethod
Method Poll()
End Method
End Type
Rem
Type TProgressRequester Extends TRequester
Field message$,value
Field showing
Field label:TGadget
Field progbar:TGadget
Method Show() 'returns false if cancelled
showing=True
Super.Show
End Method
Method Hide()
showing=False
Super.Hide()
End Method
Method Open(title$)
SetGadgetText window,title
Show
End Method
Method Update(msg$,val)
If msg$<>message
message=msg
If label FreeGadget label
label=CreateLabel(message,8,8,260,20,window)
EndIf
If showing And (val&$fc)<>(value&$fc) 'only update every 4 percent
UpdateProgBar( progbar,val/100.0 )
PollSystem
EndIf
value=val
End Method
Function Create:TProgressRequester(host:TCodePlay)
Local progress:TProgressRequester
progress=New TProgressRequester
progress.initrequester(host,"{{progress_window_title}}",280,128,STYLE_CANCEL)
progress.progbar=CreateProgBar( 8,32,260,20,progress.window )
Return progress
End Function
End Type
EndRem
Type TPanelRequester Extends TRequester
Field tabber:TGadget
Field panels:TGadget[]
Field index
Method InitPanelRequester(owner:TCodeplay,label$,w=280,h=128)
InitRequester owner,label,w,h,STYLE_OK|STYLE_CANCEL|STYLE_STDBORDER|STYLE_MODAL
tabber=CreateTabber(ScaledSize(6),ScaledSize(6),w-ScaledSize(12),h-ScaledSize(12),window)
SetGadgetLayout tabber,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED
End Method
Method SetPanelIndex(i)
HideGadget panels[index]
index=i
ShowGadget panels[index]
SelectGadgetItem tabber,index
End Method
Method SetPanel(panel:TGadget)
Local i
For Local p:TGadget = EachIn panels
If p=panel SetPanelIndex i;Exit
i:+1
Next
End Method
Method AddPanel:TGadget(name$)
Local panel:TGadget
panel=CreatePanel(0,0,ClientWidth(tabber),ClientHeight(tabber),tabber)
SetGadgetLayout panel,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED
HideGadget panel
AddGadgetItem tabber,name,GADGETITEM_LOCALIZED
panels=panels[..panels.length+1]
panels[panels.length-1]=panel
Return panel
End Method
Method RemovePanel(panel)
End Method
End Type
Type TAboutRequester Extends TRequester
Global pixLogo:TPixmap
Field pnlLogo:TGadget, lblTitle:TGadget, lblSubtitle:TGadget
Field lblLeftAligned:TGadget[], lblRightAligned:TGadget[]
Field hypBlitz:TGadget
Method PopulateText()
Local strHeadings$[], strValues$[]
strHeadings:+["{{about_label_bccver}}:"]
strValues:+[BCC_VERSION]
strHeadings:+["{{about_label_bmkver}}:"]
strValues:+[GetBMK()]
strHeadings:+[""]
strValues:+[""]
strHeadings:+["{{about_label_bmxpath}}:"]
?Win32
strValues:+[BlitzMaxPath().Replace("/","\")]
?Not Win32
strValues:+[BlitzMaxPath()]
?
?Win32
strHeadings:+["{{about_label_mingwpath}}:"]
' check For Local mingw32 dir First
Local path:String = MinGWPath()
If path Then
strValues:+[path.Replace("/", "\")]
Else
strValues:+[LocalizeString("{{about_error_unavailable}}")]
EndIf
?
strHeadings:+[""]
strValues:+[""]
?Not MacOS
strHeadings:+["{{about_label_fasmver}}:"]
strValues:+[GetFASM()]
?
strHeadings:+["{{about_label_gccver}}:"]
strValues:+[GetGCC()]
strHeadings:+["{{about_label_gplusplusver}}:"]
strValues:+[GetGpp()]
strHeadings:+["{{about_label_upxver}}:"]
strValues:+[GetUPX()]
PopulateColumns( strHeadings, strValues )
EndMethod
Function GetProcessOutput$(cmd$, flags$ = "")
Local version$
?Win32
cmd:+".exe"
?
cmd=Quote(cmd)
If flags Then cmd:+" "+flags
Local process:TProcess = CreateProcess(cmd,HIDECONSOLE)
If process
Local bytes:Byte[]
Local tmpTimeout:Int = MilliSecs() + 500
Repeat
Delay 10
bytes=process.pipe.ReadPipe()
If bytes
version:+String.FromBytes(bytes,bytes.length)
EndIf
Until (Not process.status()) Or (MilliSecs() > tmpTimeout)
process.Close()
Return version.Trim().Replace("~r","")
EndIf
Return LocalizeString("{{about_error_unavailable}}")
EndFunction
Method GetFASM$()
?Not MacOS
Local tmpSections$[] = GetProcessOutput(BlitzMaxPath()+"/bin/fasm").Split("~n")[0].Split(" ")
Return tmpSections[tmpSections.length-1]
?
EndMethod
Method GetBMK$()
Local tmpSections$[] = GetProcessOutput(BlitzMaxPath()+"/bin/bmk", "-v").Split("~n")
Return tmpSections[tmpSections.length-1]
EndMethod
Method GetGCC$()
?Win32
Local gccPath:String = MinGWPath()
If Not gccPath Then Return LocalizeString("{{about_error_notapplicable}}")
gccPath :+ "/bin/gcc"
gccPath = gccPath.Replace("/", "\")
? Not win32
Local gccPath:String = "gcc"
?
Return GetProcessOutput(gccPath, "-dumpversion").Split("~n")[0]
EndMethod
Method GetGpp$()
?Win32
Local gppPath:String = MinGWPath()
If Not gppPath Then Return LocalizeString("{{about_error_notapplicable}}")
gppPath:+ "/bin/g++"
gppPath = gppPath.Replace("/", "\")
? Not win32
Local gppPath:String = "g++"
?
Return GetProcessOutput(gppPath, "-dumpversion").Split("~n")[0]
EndMethod
Method GetUPX$()
Local upxPath:String = BlitzMaxPath() + "/bin/upx"
Local ext:String
?Win32
ext = ".exe"
upxPath = upxPath.Replace("/", "\")
?
If FileType(upxPath + ext) = FILETYPE_FILE
Return GetProcessOutput(upxPath, "-V").Split("~n")[0]
Else
Return LocalizeString("{{about_error_notapplicable}}")
EndIf
EndMethod
Method PopulateColumns( strHeadings$[], strValues$[] )
strHeadings = strHeadings[..lblLeftAligned.length]
strValues = strValues[..lblRightAligned.length]
For Local i:Int = 0 Until lblLeftAligned.length
LocalizeGadget( lblLeftAligned[i], strHeadings[i] )
Next
For Local i:Int = 0 Until lblRightAligned.length
SetGadgetText( lblRightAligned[i], strValues[i] )
SetGadgetToolTip( lblRightAligned[i], strValues[i] )
Next
EndMethod
Method Show()
PopulateText()
Super.Show()
EndMethod
Method Poll()
Select EventSource()
Case window
If EventID()=EVENT_WINDOWCLOSE
Hide()
EndIf
Case cancel
If EventID()=EVENT_GADGETACTION
Hide()
EndIf
Default
Return 0
End Select
Return 1
End Method
Function Create:TAboutRequester(host:TCodePlay)
Local abt:TAboutRequester = New TAboutRequester
abt.initrequester(host,"{{about_window_title}}",ScaledSize(460),ScaledSize(299),STYLE_CANCEL|STYLE_DIVIDER|STYLE_MODAL)
Local win:TGadget = abt.window, w = ClientWidth(abt.window)-ScaledSize(12), h = ClientHeight(abt.window)
abt.pnlLogo = CreatePanel(w-ScaledSize(64-6),0,ScaledSize(64),ScaledSize(64),win)
SetGadgetLayout abt.pnlLogo, EDGE_CENTERED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_CENTERED
'abt.pnlLogo = CreatePanel(0,0,64,64,win)
'SetGadgetLayout abt.pnlLogo, EDGE_ALIGNED, EDGE_CENTERED, EDGE_ALIGNED, EDGE_CENTERED
If Not pixLogo Then pixLogo = LoadPixmapPNG("incbin::bmxlogo.png")
SetGadgetPixmap abt.pnlLogo, pixLogo, PANELPIXMAP_CENTER
Local y = 12
Local arch:String
?x86
arch = "x86"
?x64
arch = "x64"
?arm
arch = "arm"
?arm64
arch = "arm64"
?
abt.lblTitle = CreateLabel(IDE_NAME + " " + IDE_VERSION + " (" + arch + ")",ScaledSize(6),ScaledSize(y),w,ScaledSize(22),win,LABEL_LEFT)
SetGadgetFont abt.lblTitle, LookupGuiFont( GUIFONT_SYSTEM, 12, FONT_BOLD )
SetGadgetLayout abt.lblTitle, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_CENTERED
y:+23
abt.lblSubtitle = CreateLabel("{{about_label_subtitle}}",ScaledSize(6),ScaledSize(y),w,ScaledSize(22),win,LABEL_LEFT)
SetGadgetFont abt.lblSubtitle, LookupGuiFont( GUIFONT_SYSTEM, 10, FONT_ITALIC )
SetGadgetLayout abt.lblSubtitle, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_CENTERED
y = 64
SetGadgetLayout( CreateLabel("",ScaledSize(6),ScaledSize(y),w,ScaledSize(4),win,LABEL_SEPARATOR), EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_CENTERED )
y:+(4+6)
Local tmpGadget:TGadget
For y = y Until (299-21) Step 22
tmpGadget = CreateLabel("",ScaledSize(6),ScaledSize(y),ScaledSize(135),ScaledSize(22),win,LABEL_LEFT)
SetGadgetLayout( tmpGadget, EDGE_ALIGNED, EDGE_RELATIVE, EDGE_ALIGNED, EDGE_CENTERED )
abt.lblLeftAligned:+[tmpGadget]
tmpGadget = CreateLabel("",ScaledSize(135+6),ScaledSize(y),w-ScaledSize(175),ScaledSize(22),win,LABEL_LEFT)
SetGadgetLayout( tmpGadget, EDGE_RELATIVE, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_CENTERED )
DelocalizeGadget tmpGadget
abt.lblRightAligned:+[tmpGadget]
Next
abt.hypBlitz = CreateHyperlink("https://blitzmax.org",ScaledSize(6),(h-ScaledSize(28)),ScaledSize(200),ScaledSize(26),win,LABEL_LEFT)
SetGadgetLayout abt.hypBlitz, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_CENTERED, EDGE_ALIGNED
Return abt
EndFunction
Function Spacer( height:Int, inpout:Int Var )
inpout:+height+ScaledSize(6)
Return height
EndFunction
EndType
Type TCmdLineRequester Extends TRequester
Field label:TGadget,textfield:TGadget
Method Poll()
Select EventSource()
Case window
If EventID()=EVENT_WINDOWCLOSE
Hide
EndIf
Case ok
If EventID()=EVENT_GADGETACTION
host.SetCommandLine TextFieldText(textfield)
Hide
EndIf
Case cancel
If EventID()=EVENT_GADGETACTION
SetGadgetText textfield,host.GetCommandLine()
Hide
EndIf
Default
Return 0
End Select
Return 1
End Method
Method Show()
SetGadgetText textfield,host.GetCommandLine()
Super.Show()
ActivateGadget textfield
End Method
Function Create:TCmdLineRequester(host:TCodePlay)
Local cmd:TCmdLineRequester = New TCmdLineRequester
cmd.initrequester(host,"{{cmdline_window_title}}",ScaledSize(260),ScaledSize(60),STYLE_OK|STYLE_CANCEL|STYLE_DIVIDER|STYLE_MODAL)
cmd.label=CreateLabel("{{cmdline_label_cmdline}}:",ScaledSize(6),ScaledSize(8),ScaledSize(260),ScaledSize(20),cmd.window)
cmd.textfield=CreateTextField(ScaledSize(6),ScaledSize(30),ClientWidth(cmd.window)-ScaledSize(12),ScaledSize(21),cmd.window)
Return cmd
End Function
End Type
Type TGotoRequester Extends TRequester
Field linenumber:TGadget
Method Show()
Super.Show()
ActivateGadget linenumber
End Method
Method Poll()
Local line,data,Text$
Select EventSource()
Case linenumber
If EventID() = EVENT_GADGETACTION
Text = GadgetText(linenumber)
If Text And (Int(Text) <> Text) Then SetGadgetText linenumber, Int(Text)
EndIf
Case window
If EventID()=EVENT_WINDOWCLOSE
Hide
EndIf
Case ok
line=Int(GadgetText(linenumber))
Hide
host.activepanel.Invoke TOOLGOTO,String(line)
Case cancel
Hide
Default
Return 0
End Select
Return 1
End Method
Function Create:TGotoRequester(host:TCodePlay)
Local seek:TGotoRequester = New TGotoRequester
seek.initrequester(host,"{{goto_window_title}}",ScaledSize(260),ScaledSize(66),STYLE_OK|STYLE_CANCEL|STYLE_DIVIDER|STYLE_MODAL,"{{goto_btn_goto}}")
CreateLabel("{{goto_label_linenum}}:",ScaledSize(6),ScaledSize(8+4),ScaledSize(114),ScaledSize(20),seek.window)
seek.linenumber=CreateTextField(ScaledSize(150),ScaledSize(8),ClientWidth(seek.window)-ScaledSize(150+6),ScaledSize(21),seek.window)
SetGadgetFilter( seek.linenumber, IntegerFilter )
Return seek
End Function
Function IntegerFilter:Int( event:TEvent, context:Object )
Select event.id
Case EVENT_KEYCHAR
If event.data >= Asc("0") And event.data <= Asc("9") Return True
If event.data = 8 Or event.data = 127 Or event.data = 13 Return True
Return False
Case EVENT_KEYDOWN
Return True
EndSelect
EndFunction
End Type
Type TColor
Field red,green,blue
Method Set(rgb)
red=(rgb Shr 16)&$FF
green=(rgb Shr 8)&$FF
blue=rgb&$FF
End Method
Method ToString$()
Return ""+red+","+green+","+blue
End Method
Method FromString(s$)
Local p=s.Find(",")+1
If Not p Return
Local q=s.Find(",",p)+1
If Not q Return
red=Int(s[..p-1])
green=Int(s[p..q-1])
blue=Int(s[q..])
End Method
Method Request()
If RequestColor(red,green,blue)
red=RequestedRed()
green=RequestedGreen()
blue=RequestedBlue()
Return True
EndIf
End Method
End Type
Type TTextStyle
Field label:TGadget,panel:TGadget,combo:TGadget
Field underline:TGadget, color:TColor
Field flags
Method Set(rgb,bolditalic)
color.set(rgb)
flags=bolditalic
End Method
Method Format(textarea:TGadget,pos,length,emphasise:Int = False)
Local tmpFlags:Int = flags
If emphasise Then tmpFlags:|TEXTFORMAT_BOLD
FormatTextAreaText textarea,color.red,color.green,color.blue,tmpFlags,pos,length
End Method
Method ToString$()
Return ""+color.red+","+color.green+","+color.blue+","+flags
End Method
Method FromString(s$)
Local p,q,r
p=s.Find(",")+1;If Not p Return
q=s.Find(",",p)+1;If Not q Return
r=s.Find(",",q)+1;If Not r Return
color.red=Int(s[..p-1])
color.green=Int(s[p..q-1])
color.blue=Int(s[q..r-1])
flags=Int(s[r..])
End Method
Method Poll()
Select EventSource()
Case panel
If EventID()=EVENT_MOUSEDOWN
Return color.Request()
EndIf
Case combo
flags=(flags&~3)|SelectedGadgetItem(combo)
Return True
Case underline
If EventData() Then flags:|TEXTFORMAT_UNDERLINE Else flags:&~TEXTFORMAT_UNDERLINE
Return True
End Select
End Method
Method Refresh()
SetPanelColor panel,color.red,color.green,color.blue
SelectGadgetItem combo,flags&3