-
Notifications
You must be signed in to change notification settings - Fork 1
/
LCARinterface2.bas
1393 lines (1249 loc) · 52.6 KB
/
LCARinterface2.bas
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
Attribute VB_Name = "LCARinterface"
Option Explicit
Public Type location
x As Long
y As Long
Width As Long
Height As Long
End Type
Public Type LCARButton
Name As String
Tag As String
Group As Long
x As Long
y As Long
Width As Long
Height As Long
OldLoc As location
Dest As location
LWidth As Long 'BarWidth for elbows
RWidth As Long 'BarHeight for elbows
IsClean As Boolean
Align As Long '-1 = button, 0 to 3 = elbow
Text As String 'Button only
TextAlign As Long
TextSize As Single
RedAlertHold As Long
RedAlertCycles As Long
State As Long '-1=blinking 0=mouse up, 1=mouse down
'Phase As Long
'Direction As Long 'for blinking
'EdgeColors(ColorSteps) As OLE_COLOR
PriColor As OLE_COLOR
SecColor As OLE_COLOR
Visible As Boolean
Icon As Long
Enabled As Boolean
ColorID As Long
'GNDN
Opacity As Long
DestID As Long
End Type
Public Type ListItem
Text As String
Side As String
Tag As String
Icon As Long
Selected As Boolean
Size As Long
FILEsize As String
FileLCAR As String
IsClean As Boolean
color As OLE_COLOR
ColorID As Long
LightColor As OLE_COLOR
WhiteSpace As Long
End Type
Public Type List
ListCount As Long
ListItems() As ListItem
ColsPortrait As Long
ColsLandscape As Long
Start As Long
x As Long
y As Long
Width As Long
Height As Long
ShowSize As Boolean
Name As String
IsClean As Boolean
MultiSelect As Boolean
SelectedItems As Long
SelectedItem As Long
TotalSize As Long
isDown As Boolean
Visible As Boolean
RedX As Long
RedY As Long
WhiteSpace As Long
LWidth As Long
RWidth As Long
SideWidth As Long
TextSize As Single
'GNDN
Opacity As Long
DestID As Long
End Type
Public Type LCARGroup
Visible As Boolean
RedAlert As Long
LCARlist() As Long
LCARcount As Long
End Type
Public Const SpeedReduction As Single = 0.9
Public OldInc As Long, ThreeDmode As Boolean
Public ClickedAtX As Long, OldClickedAtX As Long, oldsize As Long, SizeMode As Boolean, Inertia As Boolean, Speed As Long
Public GroupList() As LCARGroup, GroupCount As Long, GroupsEnumerated As Boolean, ClickedSide As Boolean
Public LCARlists() As List, LCARListCount As Long, isDown As Boolean, ListId As Long, RedAlert As Boolean
Public LCAR_ButtonList() As LCARButton, LCAR_ButtonCount As Long, IsClean As Boolean, State As Boolean
Public Type Destination
Dest As Form
Name As String
'Rotation state
isRotated As Boolean
hPrevFont As Long
hFont As Long
issetup As Boolean
F As LOGFONT
FontName As String
End Type
Public DestList() As Destination, DestCount As Long, CurrentDest As Long
Public Function LCAR_AddDestination(Destination As Form, Optional Name As String) As Long
If DestCount = 0 Then Set Dest = Destination
LCAR_AddDestination = DestCount
DestCount = DestCount + 1
ReDim Preserve DestList(DestCount)
With DestList(DestCount - 1)
Set .Dest = Destination
If Len(Name) = 0 Then Name = Destination.Name
.Name = LCase(Name)
End With
End Function
Public Function LCAR_SwitchToDestination(DestID As Long) As Boolean
If CurrentDest = DestID Then Exit Function
With DestList(CurrentDest)
.isRotated = isRotated
.hPrevFont = hPrevFont
.hFont = hFont
.issetup = issetup
.F = F
.FontName = FontName
End With
With DestList(DestID)
isRotated = .isRotated
hPrevFont = .hPrevFont
hFont = .hFont
issetup = .issetup
F = .F
FontName = .FontName
End With
'Set Dest = DestList(DestID)
LCAR_SwitchToDestination = True
End Function
Public Sub SetupUImode(Mode As String)
Select Case UCase(Mode) '
Case "CLASSIC+AA"
AntiAliasing = True
ThreeDmode = False
Case "NEMESIS"
AntiAliasing = False
ThreeDmode = True
Case Else
Mode = "Classic"
AntiAliasing = False
ThreeDmode = False
End Select
SaveSetting "LCAR", "MAIN", "UI", Mode
IsClean = False
End Sub
Public Sub LCAR_FontIncrement(Increment As Long)
Dim Delta As Long, temp As Long
Delta = Increment - OldInc
For temp = 0 To LCAR_ButtonCount - 1
With LCAR_ButtonList(temp)
.TextSize = .TextSize + Delta
.IsClean = False
End With
Next
For temp = 0 To LCARListCount - 1
With LCARlists(temp)
.TextSize = .TextSize + Delta
End With
Next
OldInc = Increment
End Sub
Private Function AddGroup() As Long
AddGroup = GroupCount
GroupCount = GroupCount + 1
ReDim Preserve GroupList(GroupCount)
GroupList(GroupCount - 1).Visible = True
End Function
Private Function ForceGroupCount(Count As Long) As Long
Dim temp As Long
For temp = GroupCount To Count + 1
AddGroup
Next
ForceGroupCount = GroupCount
End Function
Private Function AddLCARtoGroup(LCARid As Long, Group As Long) As Long
With GroupList(Group)
AddLCARtoGroup = .LCARcount
.LCARcount = .LCARcount + 1
ReDim Preserve .LCARlist(.LCARcount)
.LCARlist(.LCARcount - 1) = LCARid
End With
End Function
Public Sub SetRedAlert(Optional Enabled As Boolean = True)
Dim temp As Long
RedAlert = Enabled
If Enabled Then
If Not GroupsEnumerated Then
're-enumerate LCAR groups (in case things were deleted)
For temp = 0 To GroupCount - 1
With GroupList(temp)
.LCARcount = 0
ReDim .LCARlist(0)
End With
Next
For temp = 0 To LCAR_ButtonCount - 1
AddLCARtoGroup temp, LCAR_ButtonList(temp).Group
Next
GroupsEnumerated = True
End If
End If
IsClean = False
End Sub
Public Function LCAR_ListID(Name As String) As Long
Dim temp As Long
LCAR_ListID = -1
For temp = 0 To LCARListCount - 1
If StrComp(Name, LCARlists(temp).Name, vbTextCompare) = 0 Then
LCAR_ListID = temp
Exit For
End If
Next
End Function
Public Function LCAR_AddList(Name As String, ColsPortrait As Long, ColsLandscape As Long, x As Long, y As Long, Width As Long, Height As Long, Optional Visible As Boolean = True, Optional WhiteSpace As Long = 3, Optional LWidth As Long = 20, Optional RWidth As Long, Optional SideWidth As Long = 30, Optional ShowSize As Boolean = True) As Long
LCAR_AddList = LCARListCount
LCARListCount = LCARListCount + 1
ReDim Preserve LCARlists(LCARListCount)
With LCARlists(LCARListCount - 1)
.ColsPortrait = ColsPortrait
.ColsLandscape = ColsLandscape
.x = x
.y = y
.Width = Width
.Height = Height
.ShowSize = ShowSize
.Name = Name
.SelectedItem = -1
.Visible = Visible
.WhiteSpace = WhiteSpace
.LWidth = LWidth
.RWidth = RWidth
.SideWidth = SideWidth
.TextSize = 10
End With
End Function
Public Function LCAR_TextWidth(Text As String, Size As Long) As Long
Dim oldsize As Long
oldsize = Dest.Font.Size
Dest.Font.Size = Size
LCAR_TextWidth = Dest.TextWidth(Text)
Dest.Font.Size = oldsize
End Function
Public Sub LCAR_DrawLists()
Const ItemHeight As Long = 21, WhiteSpace As Long = 3 ', SizeWidth As Long = 30
Dim temp As Long, temp2 As Long, temp3 As Long, temp4 As Long, x As Long, y As Long
Dim ItemsOnScreen As Long, ItemsPerCol As Long, ItemWidth As Long, Cols As Long, color As Long
Dim Width As Long, Height As Long, tX As Long, tY As Long, SizeWidth As Long, min As Long
Dim WhiteSpace2 As Long, RText As String
For temp = 0 To LCARListCount - 1
With LCARlists(temp)
If .Visible Then
SizeWidth = .SideWidth
tX = .x
tY = .y
Width = .Width
Height = .Height
If tX < 0 Then tX = DestWidth + tX
If tY < 0 Then tY = DestHeight + tY
If Width <= 0 Then Width = DestWidth + Width
If Height <= 0 Then Height = DestHeight + Height
ItemsOnScreen = Height \ (ItemHeight + WhiteSpace)
Cols = IIf(Rotate, .ColsPortrait, .ColsLandscape)
ItemWidth = (Width \ Cols) - WhiteSpace
ItemsPerCol = .ListCount \ Cols
'If ItemsPerCol > ItemsOnScreen Then ItemsPerCol = ItemsOnScreen
If .ListCount Mod Cols > 0 Then ItemsPerCol = ItemsPerCol + 1
min = ItemsOnScreen
If min > ItemsPerCol Then min = ItemsPerCol
x = tX
For temp2 = 0 To Cols - 1
temp4 = .Start + (ItemsPerCol * temp2)
y = tY
For temp3 = 1 To min
If temp4 < .ListCount And temp4 > -1 Then
color = .ListItems(temp4).color
WhiteSpace2 = .ListItems(temp4).WhiteSpace
If SizeMode Then WhiteSpace2 = 41 ' LCAR_TextWidth("0000", ItemHeight) 'FIX THIS!
If .ListItems(temp4).Selected And State Then color = .ListItems(temp4).LightColor
If RedAlert Then
color = LCAR_Red
If temp2 = .RedX And (temp3 - 1) = .RedY Then color = LCAR_White
End If
If Len(.ListItems(temp4).Side) = 0 And Len(.ListItems(temp4).FILEsize) = 0 Then '.Size = -1 Then
DrawLCARButton x, y, ItemWidth, ItemHeight, .ListItems(temp4).Text, color, color, .LWidth, .RWidth, WhiteSpace, , .TextSize 'ammend
Else
RText = .ListItems(temp4).FILEsize
If Len(RText) = 0 Then WhiteSpace2 = WhiteSpace
If Len(.ListItems(temp4).FileLCAR) > 4 Then WhiteSpace2 = WhiteSpace2 * 2
DrawLCARButton x, y, ItemWidth - SizeWidth - .ListItems(temp4).WhiteSpace, ItemHeight, .ListItems(temp4).Text, color, color, .LWidth, .RWidth, WhiteSpace2, , .TextSize 'ammend
'DrawSquare X + ItemWidth - SizeWidth, Y, SizeWidth, ItemHeight, Color, Color
If SizeMode Or Len(RText) = 0 Then RText = .ListItems(temp4).Side
If SizeMode And Len(.ListItems(temp4).FileLCAR) > 0 Then
DrawText x + .LWidth, y - 5, .ListItems(temp4).FileLCAR, color, CSng(ItemHeight + 1)
Else
If Len(.ListItems(temp4).FILEsize) = 0 Then
If SizeWidth = 0 Then
DrawText x + ItemWidth - (WhiteSpace * 3) - .ListItems(temp4).WhiteSpace - Dest.TextWidth(.ListItems(temp4).Side) / 2, y + 2, .ListItems(temp4).Side, vbBlack, .TextSize
Else
DrawText x + ItemWidth + WhiteSpace - SizeWidth / 2 - .ListItems(temp4).WhiteSpace - Dest.TextWidth(.ListItems(temp4).Side) / 2, y + 2, .ListItems(temp4).Side, vbBlack, .TextSize
End If
Else
DrawText x + ItemWidth - SizeWidth - .ListItems(temp4).WhiteSpace - Dest.TextWidth(.ListItems(temp4).Side) - WhiteSpace, y + 2, .ListItems(temp4).Side, vbBlack, .TextSize
End If
End If
If SizeWidth > 0 Then DrawLCARButton x + ItemWidth - SizeWidth, y, SizeWidth, ItemHeight, RText, color, color, 0, 0, 0, 5, .TextSize
End If
y = y + ItemHeight + WhiteSpace
temp4 = temp4 + 1
End If
Next
x = x + ItemWidth + WhiteSpace
Next
.IsClean = True
End If
End With
Next
End Sub
Public Function LCAR_isBlinking(LCARid As Long) As Boolean
LCAR_isBlinking = LCAR_ButtonList(LCARid).State = -1
End Function
Public Function LCAR_Blink(LCARid As Long, Optional Blink As Boolean = True)
With LCAR_ButtonList(LCARid)
.State = Val(IIf(Blink, -1, 0))
.IsClean = False
End With
End Function
Public Sub LCAR_AddListItems(ListId As Long, ParamArray Items() As Variant)
Dim temp As Long
For temp = 0 To UBound(Items)
LCAR_AddListItem ListId, CStr(Items(temp))
Next
End Sub
Public Function LCAR_AddListItem(ListId As Long, Text As String, Optional color As Long = -1, Optional LightColor As Long = -1, Optional Size As Long = -1, Optional Tag As String, Optional Icon As Long = -1, Optional Selected As Boolean, Optional Side As String, Optional WhiteSpace As Long = -1, Optional FILEsize As String, Optional LCARtext As String) As Long
LCAR_AddListItem = LCARlists(ListId).ListCount
LCARlists(ListId).ListCount = LCARlists(ListId).ListCount + 1
ReDim Preserve LCARlists(ListId).ListItems(LCARlists(ListId).ListCount)
With LCARlists(ListId).ListItems(LCARlists(ListId).ListCount - 1)
.Text = UCase(Text)
.Side = UCase(Side)
.Tag = Tag
.Icon = Icon
.Selected = Selected
.Size = Size
.FileLCAR = LCARtext
If WhiteSpace = -1 Then .WhiteSpace = LCARlists(ListId).WhiteSpace Else .WhiteSpace = WhiteSpace
If Size = -1 And LCARlists(ListId).ShowSize Then
If color = -1 Then .color = LCAR_LightBlue Else .color = color
.FILEsize = FILEsize
Else
If color = -1 And LCARlists(ListId).ShowSize Then color = SizeToColor(Size)
.color = color
If Len(LCARtext) > 0 Then
.FILEsize = FILEsize
ElseIf LCARlists(ListId).ShowSize Then
.FILEsize = SizeToText(Size, " Q", " K", "M", " G")
.FileLCAR = Format(SizeToLCAR(Size), "0000")
End If
'If InStr(.FileSize, ".") = 0 Then .FileSize = Left(.FileSize, Len(.FileSize) - 1) & " " & Right(.FileSize, 1)
End If
If LightColor = -1 Then LightColor = AlterBrightness(.color, Brightness)
.LightColor = LightColor
.ColorID = LCAR_ColorIDfromColor(.color)
End With
End Function
Public Sub LCAR_ClearList(ListId As Long, Optional DownToItem As Long)
If DownToItem = 0 Then
ReDim LCARlists(ListId).ListItems(0)
Else
ReDim Preserve LCARlists(ListId).ListItems(DownToItem)
End If
With LCARlists(ListId)
.Start = 0
.ListCount = DownToItem
.IsClean = False
.SelectedItem = -1
.SelectedItems = 0
.TotalSize = 0
End With
IsClean = False
End Sub
Public Sub LCAR_AddFolder(ListId As Long, Path As String, Optional Side As String)
If Len(Path) > 0 Then LCAR_AddListItem ListId, Right(Path, Len(Path) - InStrRev(Path, "\")), LCAR_LightBlue, , , Path & "\", , , , , Side
End Sub
Public Sub LCAR_EnumFiles(ListId As Long, Optional DriveBox As DriveListBox, Optional Dirbox As DirListBox, Optional FILEbox As FileListBox, Optional Path As String, Optional SortBy As Long = 1, Optional SeparateExtention As Boolean = True, Optional HideExtention As Boolean, Optional SearchQuery As String, Optional Pattern As String = "*.*", Optional Side As String)
'On Error Resume Next
Dim temp As Long, File As String, Extention As String, Text As String, AddFile As Boolean
Dim FileList() As String, FileCount As Long
If Len(Path) = 0 Then
For temp = 0 To DriveBox.ListCount - 1
File = DriveBox.List(temp)
If InStr(File, "[") = 0 Then
File = File & " [" & DriveType(File) & "]"
Else
File = File & " " & FormatPercent(GetPercentFull(File), 2) & " of " & Round(GetTotalSpaceGigaBytes(File), 2) & " Gigaquads used"
End If
LCAR_AddListItem ListId, File, LCAR_LightBlue, , , UCase(Left(DriveBox.List(temp), 2)) & "\" ', , , "Drive"
Next
'LCAR_AddFolder ListId, ShellFolder("Desktop")
'LCAR_AddFolder ListId, ShellFolder
'LCAR_AddFolder ListId, ShellFolder("My Music")
'LCAR_AddFolder ListId, ShellFolder("My Pictures")
'LCAR_AddFolder ListId, ShellFolder("My Video")
'API_ListBookmarks ListId
Else
If InStr(Path, "\\") Then Exit Sub
If Not Dirbox Is Nothing Then
If StrComp(Dirbox.Path, Path, vbTextCompare) = 0 Then
Dirbox.Refresh
Else
If direxists(Path) Then Dirbox.Path = Path Else Exit Sub
End If
For temp = 0 To Dirbox.ListCount - 1
AddFile = True
Text = Right(Dirbox.List(temp), Len(Dirbox.List(temp)) - InStrRev(Dirbox.List(temp), "\"))
If Len(SearchQuery) > 0 Then AddFile = SearchText(Text, SearchQuery)
If InStr(Text, "?") > 0 Then AddFile = False
If AddFile Then LCAR_AddListItem ListId, Text, -1, -1, -1, Dirbox.List(temp), -1, False ', "Folder"
Next
End If
If Not FILEbox Is Nothing Then
FILEbox.Pattern = Pattern
If StrComp(FILEbox.Path, Path, vbTextCompare) = 0 Then
FILEbox.Refresh
Else
FILEbox.Path = Path
End If
FileCount = EnumSortedFiles(FILEbox, FileList, SortBy)
For temp = 0 To FileCount - 1 'FileBox.ListCount - 1
AddFile = True
File = FileList(0, temp) ' Replace(FileBox.Path & "\" & FileBox.List(temp), "\\", "\")
Text = Right(File, Len(File) - InStrRev(File, "\")) 'FileBox.List(temp)
If Len(SearchQuery) > 0 Then AddFile = SearchText(Text, SearchQuery)
If InStr(Text, "?") > 0 Then AddFile = False
If AddFile Then
If InStr(Text, ".") Then
If SeparateExtention Then Extention = GetExtention(Text) ' Right(Text, Len(Text) - InStrRev(Text, "."))
If SeparateExtention Or HideExtention Then Text = Left(Text, InStrRev(Text, ".") - 1)
If Len(Side) > 0 Then Extention = Side
End If
LCAR_AddListItem ListId, Text, -1, -1, CLng(FileList(2, temp)), File, -1, False, UCase(Extention) 'FileLen(File)
End If
Next
End If
End If
End Sub
Public Function SearchText(Text As String, SearchQuery As String) As Boolean
If isapattern(SearchQuery) Then
SearchText = islike(Text, SearchQuery)
Else
SearchText = InStr(1, Text, SearchQuery, vbTextCompare) = 0
End If
End Function
Public Function isapattern(Text As String) As Boolean
isapattern = InStr(Text, "?") > 0 Or InStr(Text, "*") > 0
End Function
Public Function islike(Text As String, expression As String) As Boolean 'islike("*.exe", "test.exe")
Dim tempstr() As String, Count As Long
expression = LCase(expression)
Text = LCase(Text)
If InStr(expression, ";") > 0 Then
tempstr = Split(expression, ";")
For Count = 0 To UBound(tempstr)
If Text Like tempstr(Count) Then
islike = True
Exit For
End If
Next
Else
islike = Text Like expression
End If
End Function
Public Function SizeToColor(Size As Long) As Long
Select Case Size 'FileLen(File)
Case 0 To 1024: SizeToColor = LCAR_Orange '0 to 1 KB
Case 1025 To 13107: SizeToColor = LCAR_Purple '1 KB to 12.8 KB
Case 13108 To 1048576: SizeToColor = LCAR_Yellow '12.8 KB to 1 MB
Case 1048577 To 13421772: SizeToColor = LCAR_DarkBlue '1 MB to 12.8 MB
Case 13421773 To 1073741824: SizeToColor = LCAR_DarkYellow ' 12.8 MB to 128 MB
Case Else: SizeToColor = LCAR_DarkPurple '128 MB to infinite
End Select
End Function
Public Sub LCAR_ANISetLCARLocs(Name As String, x As Long, y As Long, ParamArray Indexes() As Variant)
Dim temp As Long, LCARid As Long
For temp = 0 To UBound(Indexes)
'LCARid = LCAR_FindLCAR(Name, , Indexes(temp))
If LCARid > -1 Then LCAR_ANIMoveLCAR LCARid, x, y, , , True
Next
End Sub
Public Sub LCAR_ANISetLCARLoc(LCARid As Long, Optional x As Long = -999, Optional y As Long = -999, Optional Width As Long, Optional Height As Long)
With LCAR_ButtonList(LCARid)
If x > -999 Then .x = x
.OldLoc.x = .x
If y > -999 Then .y = y
.OldLoc.y = .y
If Width <> 0 Then .Width = Width
.OldLoc.Width = .Width
If Height <> 0 Then .Height = Height
.OldLoc.Height = .Height
End With
End Sub
Public Sub LCAR_ANIMoveLCAR(LCARid As Long, x As Long, y As Long, Optional Width As Long, Optional Height As Long, Optional Relative As Boolean)
With LCAR_ButtonList(LCARid)
If Relative Then
.Dest.x = .x + x
.Dest.y = .y + y
.Dest.Width = .Width + Width
.Dest.Height = .Height + Height
Else
.Dest.x = x
.Dest.y = y
If Width = 0 Then Dest.Width = .Width Else .Dest.Width = Width
If Height = 0 Then Dest.Height = .Height Else .Dest.Height = Height
End If
End With
End Sub
Public Sub LCAR_ANIIncrementLocs(Optional ReturnToOld As Boolean, Optional Speed As Long = 10, Optional LockAll As Boolean)
Dim temp As Long
For temp = 0 To LCAR_ButtonCount - 1
With LCAR_ButtonList(temp)
If ReturnToOld Then
.x = .OldLoc.x
.y = .OldLoc.y
.Width = .OldLoc.Width
.Height = .OldLoc.Height
ElseIf LockAll Then
.OldLoc.x = .x
.OldLoc.y = .y
.OldLoc.Width = .Width
.OldLoc.Height = .Height
Else
.x = LCAR_Increment(.x, .Dest.x, Speed)
.y = LCAR_Increment(.y, .Dest.y, Speed)
.Width = LCAR_Increment(.Width, .Dest.Width, Speed)
.Height = LCAR_Increment(.Height, .Dest.Height, Speed)
End If
End With
Next
End Sub
Public Function LCAR_Increment(ByVal Current As Long, Destination As Long, Speed As Long) As Long
LCAR_Increment = Destination
If Current < Destination Then
If Current + Speed < Destination Then LCAR_Increment = Current + Speed
ElseIf Current > Destination Then
If Current - Speed > Destination Then LCAR_Increment = Current - Speed
End If
End Function
Public Sub RotateScreen()
Rotate = Not Rotate
LCAR_DrawLCARs True
End Sub
Public Function LCAR_AddLCAR(Name As String, x As Long, y As Long, Width As Long, Height As Long, LWidth As Long, RWidth As Long, Optional LightColor As OLE_COLOR = LCAR_LightOrange, Optional DarkColor As OLE_COLOR = LCAR_DarkOrange, Optional Align As Long = -1, Optional Text As String, Optional Tag As String, Optional Group As Long, Optional Visible As Boolean = True, Optional Icon As Long = -1, Optional TextAlign As Long = 4, Optional Enabled As Boolean = True, Optional TextSize As Single) As Long
Dim temp As Long, temp2 As Double, Alpha As Double
LCAR_AddLCAR = LCAR_ButtonCount
LCAR_ButtonCount = LCAR_ButtonCount + 1
ReDim Preserve LCAR_ButtonList(LCAR_ButtonCount)
With LCAR_ButtonList(LCAR_ButtonCount - 1)
.Name = Name
.Tag = Tag
.Group = Group
ForceGroupCount Group
.x = x
.y = y
.Width = Width
.Height = Height
.OldLoc.x = x
.OldLoc.y = y
.OldLoc.Width = Width
.OldLoc.Height = Height
.LWidth = LWidth
.RWidth = RWidth
.Align = Align
.Text = UCase(Text)
.TextAlign = TextAlign
.Visible = Visible
.Icon = Icon
If TextSize = 0 Then
.TextSize = Dest.Font.Size
Else
.TextSize = TextSize
End If
.PriColor = DarkColor
.ColorID = LCAR_ColorIDfromColor(DarkColor)
.SecColor = LightColor
If LightColor = -1 Then .SecColor = AlterBrightness(DarkColor, Brightness)
.Enabled = Enabled
'temp2 = 256 / ColorSteps
'For temp = 0 To ColorSteps - 1
' '.EdgeColors(temp) = AlphaBlend(MidColor, DarkColor, Alpha)
' .FillColors(temp) = AlphaBlend(LightColor, DarkColor, Alpha)
' Alpha = Alpha + temp2
'Next
End With
End Function
Public Sub LCAR_MoveLCARs(Name As String, Start As Long, Optional Count As Long = 1, Optional ByVal x As Long = -1, Optional ByVal y As Long = -1, Optional Group As Long = -1, Optional AlongXaxis As Boolean = True, Optional WhiteSpace As Long = 2, Optional Width As Long, Optional Height As Long)
Dim temp As Long, LCAR As Long
For temp = Start To Start + Count - 1
LCAR = LCAR_FindLCAR(Name, Group, temp)
If LCAR > -1 Then
With LCAR_ButtonList(LCAR)
If x = -1 Then x = .x Else .x = x
If y = -1 Then y = .y Else .y = y
If Height <> 0 Then .Height = Height
If Width <> 0 Then .Width = Width
If AlongXaxis Then
x = x + WhiteSpace + .Width
Else
y = y + WhiteSpace + .Height
End If
.OldLoc.x = .x
.OldLoc.y = .y
.OldLoc.Width = .Width
.OldLoc.Height = .Height
End With
Else
Exit For
End If
Next
End Sub
Public Sub LCAR_HideLCAR(Name As String, Optional Visible As Boolean)
Dim temp As Long
For temp = 0 To LCAR_ButtonCount - 1
If StrComp(Name, LCAR_ButtonList(temp).Name, vbTextCompare) = 0 Then
LCAR_ButtonList(temp).Visible = Visible
LCAR_ButtonList(temp).IsClean = False
IsClean = False
End If
Next
End Sub
Public Function LCAR_FindLCAR(Name As String, Optional Group As Long = -1, Optional Index As Long = 0) As Long 'If Index=-1 then it will count the occurances of that button id
Dim temp As Long, temp2 As Long
LCAR_FindLCAR = -1
For temp = 0 To LCAR_ButtonCount - 1
If StrComp(Name, LCAR_ButtonList(temp).Name, vbTextCompare) = 0 Then
If Group = -1 Or Group = LCAR_ButtonList(temp).Group Then
If Index = 0 Then
LCAR_FindLCAR = temp
Exit For
Else
If temp2 = Index Then
LCAR_FindLCAR = temp
Exit For
End If
temp2 = temp2 + 1
End If
End If
End If
Next
If Index = -1 Then LCAR_FindLCAR = temp2
End Function
Public Function LCAR_FindIndex(ButtonID As Long) As Long
Dim temp As Long, Name As String, Index As Long
Name = LCAR_ButtonList(ButtonID).Name
For temp = ButtonID - 1 To 0 Step -1
If StrComp(Name, LCAR_ButtonList(temp).Name, vbTextCompare) = 0 Then Index = Index + 1
Next
LCAR_FindIndex = Index
End Function
Public Function isWithin(x As Long, y As Long, Left As Long, Top As Long, Width As Long, Height As Long) As Boolean
If x >= Left Then
If x < Left + Width Then
If y >= Top Then isWithin = y < Top + Height
End If
End If
End Function
Public Sub LCAR_Select(ListId As Long, Operation As Long)
Dim temp As Long
With LCARlists(ListId)
.TotalSize = 0
For temp = 0 To .ListCount - 1
Select Case Operation
Case -1 'invert selection
.ListItems(temp).Selected = Not .ListItems(temp).Selected
Case 0 'select none
If .ListItems(temp).Selected Then
.ListItems(temp).Selected = False
.ListItems(temp).IsClean = False
End If
Case 1 'select all
If Not .ListItems(temp).Selected Then
.ListItems(temp).Selected = True
.ListItems(temp).IsClean = False
End If
End Select
If .ListItems(temp).Selected And .ListItems(temp).Size > -1 Then .TotalSize = .TotalSize + .ListItems(temp).Size
Next
.IsClean = False
Select Case Operation
Case -1: .SelectedItems = .ListCount - .SelectedItems
Case 0: .SelectedItems = 0
Case 1: .SelectedItems = .ListCount
End Select
End With
End Sub
Public Sub LCAR_SelectItem(ListId As Long, ItemID As Long)
Dim temp As Long
If ItemID = -1 Then Exit Sub
With LCARlists(ListId)
If Not .MultiSelect Then LCAR_Select ListId, 0
.ListItems(ItemID).Selected = Not .ListItems(ItemID).Selected
.ListItems(ItemID).IsClean = False
If .ListItems(ItemID).Selected Then
.SelectedItems = .SelectedItems + 1
.SelectedItem = ItemID
If .ListItems(ItemID).Size > -1 Then .TotalSize = .TotalSize + .ListItems(ItemID).Size
Else
If .ListItems(ItemID).Size > -1 Then .TotalSize = .TotalSize - .ListItems(ItemID).Size
.SelectedItem = -1
.SelectedItems = .SelectedItems - 1
If .SelectedItems = 1 Then
For temp = 0 To .ListCount - 1
If .ListItems(temp).Selected Then
.SelectedItem = temp
Exit For
End If
Next
End If
End If
End With
End Sub
Public Function LCAR_SelectedItem(ListId As Long) As String
With LCARlists(ListId)
If .SelectedItem > -1 Then
LCAR_SelectedItem = .ListItems(.SelectedItem).Text
End If
End With
End Function
Public Function LCAR_ListRows(ListId As Long) As Long
Const ItemHeight As Long = 21, WhiteSpace As Long = 3
Dim Height As Long
With LCARlists(ListId)
Height = .Height
If Height <= 0 Then Height = DestHeight + Height
LCAR_ListRows = Height \ (ItemHeight + WhiteSpace)
End With
End Function
Public Function LCAR_ListCols(ListId As Long) As Long
With LCARlists(ListId)
LCAR_ListCols = IIf(Rotate, .ColsPortrait, .ColsLandscape)
End With
End Function
Public Function LCAR_ListHeight(ListId As Long) As Long
Const ItemHeight As Long = 21, WhiteSpace As Long = 3
Dim ItemsOnScreen As Long, ItemsPerCol As Long, ItemWidth As Long, Cols As Long, Height As Long
With LCARlists(ListId)
Height = .Height
If Height <= 0 Then Height = DestHeight + Height
ItemsOnScreen = Height \ (ItemHeight + WhiteSpace)
Cols = IIf(Rotate, .ColsPortrait, .ColsLandscape)
ItemsPerCol = .ListCount \ Cols
If ItemsPerCol < ItemsOnScreen Then
LCAR_ListHeight = ItemsOnScreen * (ItemHeight + WhiteSpace)
Else
LCAR_ListHeight = Height
End If
End With
End Function
Public Function LCAR_ClickedCol(ListId As Long, ByVal x As Long, ByVal y As Long, Optional AllowOB As Boolean = True) As Long
Const ItemHeight As Long = 21, WhiteSpace As Long = 3, SizeWidth As Long = 30
Dim temp As Long, tX As Long, tY As Long, Width As Long, Height As Long
Dim ItemsOnScreen As Long, ItemsPerCol As Long, ItemWidth As Long, Cols As Long, color As Long
LCAR_ClickedCol = -1
If Rotate Then
temp = x
x = Dest.ScaleHeight - y
y = temp
End If
With LCARlists(ListId)
tX = .x
Width = .Width
If tX < 0 Then tX = DestWidth + tX
If Width <= 0 Then Width = DestWidth + Width
Cols = IIf(Rotate, .ColsPortrait, .ColsLandscape)
ItemWidth = (Width \ Cols)
x = x - tX
temp = (x \ ItemWidth)
If AllowOB Then
LCAR_ClickedCol = temp
Else
If temp > -1 And temp < Cols Then LCAR_ClickedCol = temp
End If
End With
End Function
Public Function LCAR_ClickedRow(ListId As Long, ByVal x As Long, ByVal y As Long, Optional AllowOB As Boolean = True) As Long
Const ItemHeight As Long = 21, WhiteSpace As Long = 3 ', SizeWidth As Long = 30
Dim tY As Long, temp As Long, Cols As Long, ItemsPerCol As Long, Height As Long, ItemsOnScreen As Long
LCAR_ClickedRow = -1
If Rotate Then
temp = x
x = Dest.ScaleHeight - y
y = temp
End If
With LCARlists(ListId)
tY = .y
Height = .Height
If tY < 0 Then tY = DestHeight + tY
If Height <= 0 Then Height = DestHeight + Height
y = y - tY
temp = y \ (ItemHeight + WhiteSpace)
Cols = IIf(Rotate, .ColsPortrait, .ColsLandscape)
ItemsOnScreen = Height \ (ItemHeight + WhiteSpace)
If AllowOB Then
LCAR_ClickedRow = temp
Else
If temp > -1 And temp < ItemsOnScreen Then LCAR_ClickedRow = temp
End If
End With
End Function
Public Sub LCAR_ScrollList(ListId As Long, Rows As Long)
Const ItemHeight As Long = 21, WhiteSpace As Long = 3
Dim Cols As Long, ItemsPerCol As Long, Height As Long, ItemsOnScreen As Long, OldStart As Boolean
With LCARlists(ListId)
OldStart = .Start
Height = .Height
If Height <= 0 Then Height = DestHeight + Height
ItemsOnScreen = Height \ (ItemHeight + WhiteSpace)
Cols = IIf(Rotate, .ColsPortrait, .ColsLandscape)
ItemsPerCol = .ListCount \ Cols
.Start = .Start + Rows
If .Start < 0 Then
.Start = 0
ElseIf .Start >= ItemsPerCol - ItemsOnScreen Then
.Start = ItemsPerCol - ItemsOnScreen
End If
.IsClean = OldStart = .Start
If .IsClean Then Exit Sub
End With
LCAR_DrawLCARs True
End Sub
Public Function LCARS_ListItemsOnScreen(ListId As Long)
Const ItemHeight As Long = 21, WhiteSpace As Long = 3
Dim ItemsOnScreen As Long, ItemsPerCol As Long, Cols As Long, Height As Long
With LCARlists(ListId)
Height = .Height
If Height <= 0 Then Height = DestHeight + Height
ItemsOnScreen = Height \ (ItemHeight + WhiteSpace)
Cols = IIf(Rotate, .ColsPortrait, .ColsLandscape)
ItemsPerCol = .ListCount \ Cols
If ItemsOnScreen < ItemsPerCol Then LCARS_ListItemsOnScreen = ItemsOnScreen Else LCARS_ListItemsOnScreen = ItemsPerCol
End With
End Function
Public Function LCAR_ListItem(ListId As Long, Text As String, Optional Side As Boolean) As Long
Dim temp As Long, Found As Boolean
LCAR_ListItem = -1
With LCARlists(ListId)
For temp = 0 To .ListCount - 1
If Side Then
Found = StrComp(Text, .ListItems(temp).Tag, vbTextCompare) = 0
Else
Found = StrComp(Text, .ListItems(temp).Text, vbTextCompare) = 0
End If
If Found Then
LCAR_ListItem = temp
Exit For
End If
Next
End With
End Function
'new!
Public Function LCAR_FindListItemByName(ListId As Long, Text As String, Optional ByTag As Boolean) As Long
Dim temp As Long
LCAR_FindListItemByName = -1
For temp = 0 To LCARlists(ListId).ListCount - 1
With LCARlists(ListId).ListItems(temp)
If StrComp(Text, IIf(ByTag, .Tag, .Text), vbTextCompare) = 0 Then
LCAR_FindListItemByName = temp
Exit For
End If
End With
Next
End Function
Public Function LCAR_FindListItem(ByVal x As Long, ByVal y As Long) As Long
Const ItemHeight As Long = 21, WhiteSpace As Long = 3, SizeWidth As Long = 30
Dim temp As Long, tX As Long, tY As Long, Width As Long, Height As Long, ListId As Long, OldX As Long
Dim ItemsOnScreen As Long, ItemsPerCol As Long, ItemWidth As Long, Cols As Long, color As Long
LCAR_FindListItem = -1
ListId = LCAR_FindList(x, y)
If ListId = -1 Then Exit Function