-
Notifications
You must be signed in to change notification settings - Fork 0
/
SevenSeg.pb
730 lines (633 loc) · 23.4 KB
/
SevenSeg.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
EnableExplicit
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
UsePNGImageDecoder()
CompilerEndSelect
Global Window_0 = 0
Global Button_A = 1
Global Button_B = 2
Global Button_C = 3
Global Button_D = 4
Global Button_E = 5
Global Button_F = 6
Global Button_G = 7
Global Button_Dp = 8
Global ListView1 = 9
Global ListView2 = 10
Global InvertBtn = 11
Global BinTB = 12
Global TextBinTB = 13
Global PreBinTB = 14
Global DecTB = 15
Global TextDecTB = 16
Global HexTB = 17
Global TextHexTB = 18
Global PreHexTB = 19
Global BinCopyBtn = 20
Global DecCopyBtn = 21
Global HexCopyBtn = 22
Global CopyBtn = 23
Global PasteBtn = 24
Global ClearBtn = 25
Global Container0 = 26
Global Container1 = 27
Global Dim SegmentNames.s(7)
Enumeration
#Drag_ListView2
EndEnumeration
Enumeration FormFont
#Font_10
#Font_12
#Font_14
EndEnumeration
#Title = "7Segment to ..."
#FileName = "7SegmentSet.csv"
Structure udtBCG
State.i
Text.s
Fontid.i
BackColorOn.i
BackColorOff.i
TextColor.i
OnOff.i
EndStructure
; -------------------------------------------------------------------------------------
Procedure DrawColorButton(Gadget, *data.udtBCG)
Protected dx, dy
If StartDrawing(CanvasOutput(Gadget))
With *data
dx = DesktopScaledX(GadgetWidth(Gadget))
dy = DesktopScaledY(GadgetHeight(Gadget))
If \fontid
DrawingFont(\fontid)
EndIf
Select \state
Case #PB_EventType_MouseEnter
If \OnOff = 1
Box(0, 0, dx, dy, \BackColorOn)
Else
Box(0, 0, dx, dy, \backcolorOff)
EndIf
DrawingMode(#PB_2DDrawing_Outlined)
Box(0, 0, dx, dy, $D0D0D0)
DrawingMode(#PB_2DDrawing_Transparent)
DrawText((dx-TextWidth(\text))/2,(dy-TextHeight(\text))/2,\text,\textcolor)
Case #PB_EventType_LeftButtonDown
If \OnOff = 1
Box(1, 1, dx, dy, \BackColorOn)
Else
Box(1, 1, dx, dy, \backcolorOff)
EndIf
DrawingMode(#PB_2DDrawing_Outlined)
Box(1, 1, dx, dy, $808080)
DrawingMode(#PB_2DDrawing_Transparent)
DrawText((dx+1-TextWidth(\text))/2,(dy+2-TextHeight(\text))/2,\text,\textcolor)
Case #PB_EventType_LeftButtonUp, #PB_EventType_LeftClick
If \OnOff = 1
Box(0, 0, dx, dy, \BackColorOn)
Else
Box(0, 0, dx, dy, \backcolorOff)
EndIf
DrawingMode(#PB_2DDrawing_Outlined)
Box(0, 0, dx, dy, $D0D0D0)
DrawingMode(#PB_2DDrawing_Transparent)
DrawText((dx-TextWidth(\text))/2,(dy-TextHeight(\text))/2,\text,\textcolor)
Case #PB_EventType_MouseLeave
If \OnOff = 1
Box(0, 0, dx, dy, \BackColorOn)
Else
Box(0, 0, dx, dy, \backcolorOff)
EndIf
DrawingMode(#PB_2DDrawing_Outlined)
Box(0, 0, dx, dy, $808080)
DrawingMode(#PB_2DDrawing_Transparent)
DrawText((dx-TextWidth(\text))/2,(dy-TextHeight(\text))/2,\text,\textcolor)
EndSelect
\state = 0
StopDrawing()
EndWith
EndIf
EndProcedure
; -------------------------------------------------------------------------------------
Procedure EventHandlerColorButton()
Protected Gadget, event, *Data.udtBCG
event = EventType()
Select event
Case #PB_EventType_MouseEnter, #PB_EventType_MouseLeave, #PB_EventType_LeftButtonDown,
#PB_EventType_LeftButtonUp, #PB_EventType_LeftDoubleClick,#PB_EventType_LeftClick
; Do
Gadget = EventGadget()
*data = GetGadgetData(Gadget)
If event = #PB_EventType_LeftClick
If *data\OnOff = 1
*data\OnOff = 0
Else
*data\OnOff = 1
EndIf
EndIf
*data\state = event
DrawColorButton(Gadget, *data)
EndSelect
EndProcedure
; -------------------------------------------------------------------------------------
Procedure ButtonColorGadget(Gadget, x, y, Width, Height, Text.s)
Protected result, id, *Data.udtBCG
result = CanvasGadget(Gadget, x, y, Width, Height)
If result
If Gadget = #PB_Any
id = result
Else
id = Gadget
EndIf
*data = AllocateStructure(udtBCG)
*data\state = #PB_EventType_MouseLeave
*data\text = text
*data\backcolorOn = $C0C0C0
*data\backcolorOff = $C0C0C0
*data\textcolor = 0
*data\OnOff = 0
SetGadgetData(id, *data)
DrawColorButton(id, *data)
BindGadgetEvent(id, @EventHandlerColorButton())
EndIf
ProcedureReturn result
EndProcedure
; -------------------------------------------------------------------------------------
Procedure SetButtonColor(Gadget, TextColor, BackColorOn, BackColorOff)
Protected *Data.udtBCG
If IsGadget(Gadget)
If GadgetType(Gadget) = #PB_GadgetType_Canvas
*data = GetGadgetData(Gadget)
If *Data
*data\state = #PB_EventType_MouseLeave
If TextColor <> #PB_Ignore : *data\textcolor = TextColor : EndIf
If BackColorOn <> #PB_Ignore : *Data\backcolorOn = BackColorOn : EndIf
If BackColorOff <> #PB_Ignore : *Data\backcolorOff = BackColorOff : EndIf
DrawColorButton(Gadget, *data)
EndIf
EndIf
EndIf
EndProcedure
; -------------------------------------------------------------------------------------
Procedure SetButtonOnOff(Gadget, OnOff)
Protected *Data.udtBCG
If IsGadget(Gadget)
If GadgetType(Gadget) = #PB_GadgetType_Canvas
*Data = GetGadgetData(Gadget)
If *Data
*Data\state = #PB_EventType_MouseLeave
*Data\OnOff = OnOff
DrawColorButton(Gadget, *data)
EndIf
EndIf
EndIf
EndProcedure
; -------------------------------------------------------------------------------------
Procedure SetButtonFont(Gadget, FontID)
Protected *Data.udtBCG
If IsGadget(Gadget)
If GadgetType(Gadget) = #PB_GadgetType_Canvas
*data = GetGadgetData(Gadget)
If *Data
*data\state = #PB_EventType_MouseLeave
*data\fontid = FontID
DrawColorButton(Gadget, *data)
EndIf
EndIf
EndIf
EndProcedure
; -------------------------------------------------------------------------------------
Procedure SetButtonSize(Gadget, x, y, width, height)
Protected *Data.udtBCG
If IsGadget(Gadget)
If GadgetType(Gadget) = #PB_GadgetType_Canvas
*data = GetGadgetData(Gadget)
If *Data
*data\state = #PB_EventType_MouseLeave
ResizeGadget(Gadget, x, y, width, height)
DrawColorButton(Gadget, *data)
EndIf
EndIf
EndIf
EndProcedure
; -------------------------------------------------------------------------------------
Procedure DestroyGadget(Gadget)
Protected *data
If IsGadget(Gadget)
If GadgetType(Gadget) = #PB_GadgetType_Canvas
*data = GetGadgetData(Gadget)
If *Data
UnbindGadgetEvent(Gadget, @EventHandlerColorButton())
FreeStructure(*data)
EndIf
EndIf
FreeGadget(Gadget)
EndIf
EndProcedure
; -------------------------------------------------------------------------------------
Procedure ListViewGadgetMove(Gadget, Source, Dest)
Protected i, ItemText$, ItemData, Source$, SourceData
Source$ = GetGadgetItemText(Gadget, Source)
SourceData = GetGadgetItemData(Gadget, Source)
If Source = -1
ProcedureReturn
EndIf
If Dest = -1
Dest = CountGadgetItems(Gadget) - 1
EndIf
If Source < Dest
For i = Source To Dest - 1
ItemText$ = GetGadgetItemText(Gadget, i + 1)
ItemData = GetGadgetItemData(Gadget, i + 1)
SetGadgetItemText(Gadget, i, ItemText$)
SetGadgetItemData(Gadget, i, ItemData)
Next
Else
For i = Source To Dest + 1 Step - 1
ItemText$ = GetGadgetItemText(Gadget, i - 1)
ItemData = GetGadgetItemData(Gadget, i - 1)
SetGadgetItemText(Gadget, i, ItemText$)
SetGadgetItemData(Gadget, i, ItemData)
Next
EndIf
SetGadgetItemText(Gadget, i, Source$)
SetGadgetItemData(Gadget, i, SourceData)
EndProcedure
; -------------------------------------------------------------------------------------
Procedure SetOutputTB()
Protected Dec, i, z, OutText.s , *Data.udtBCG, OrderSegName.s
OutText=""
For i = 0 To 7
OrderSegName=GetGadgetItemText(ListView2, i)
For z =1 To 8
If SegmentNames(z-1)=OrderSegName
*data = GetGadgetData(z)
If GetGadgetState(InvertBtn)
If *data\OnOff = 1
OutText = OutText + "0"
Else
OutText = OutText + "1"
EndIf
Else
OutText = OutText + Str(*data\OnOff)
EndIf
Break
EndIf
Next z
Next i
Dec = Val("%" + OutText)
SetGadgetText(BinTB, OutText)
SetGadgetText(DecTB, Str(Dec))
SetGadgetText(HexTB,RSet(Hex(Dec), 2, "0"))
EndProcedure
; -------------------------------------------------------------------------------------
Procedure SetSegmentButton(Bin.s)
Protected i, z, v, b, Dec, OrderSegName.s
For i = 0 To 7
OrderSegName=GetGadgetItemText(ListView2, i)
For z =1 To 8
If SegmentNames(z-1)=OrderSegName
b = Val(Mid(Bin,i+1,1))
If GetGadgetState(InvertBtn)
If b = 1
v = 0
Else
v = 1
EndIf
Else
v = b
EndIf
SetButtonOnOff(z,v)
Break
EndIf
Next z
Next i
Dec = Val("%" + Bin)
SetGadgetText(BinTB, Bin)
SetGadgetText(DecTB, Str(Dec))
SetGadgetText(HexTB,RSet(Hex(Dec), 2, "0"))
EndProcedure
; -------------------------------------------------------------------------------------
Procedure CopyBtnClick()
If GetGadgetState(BinCopyBtn)
SetClipboardText(GetGadgetText(PreBinTB) + GetGadgetText(BinTB))
ElseIf GetGadgetState(DecCopyBtn)
SetClipboardText(GetGadgetText(DecTB))
ElseIf GetGadgetState(HexCopyBtn)
SetClipboardText(GetGadgetText(PreHexTB) +GetGadgetText(HexTB))
EndIf
EndProcedure
; -------------------------------------------------------------------------------------
Procedure PasteBtnClick()
Protected i, ClipText.s, T.s , Tt.s
Protected Dim ValidHex.s(15)
For i = 0 To 9
ValidHex(i) = Str(i)
Next i
ValidHex(10) = "a":ValidHex(11) = "b":ValidHex(12) = "c":ValidHex(13) = "d":ValidHex(14) = "e":ValidHex(15) = "f"
ClipText = LCase(GetClipboardText())
If Len(ClipText) >= 8
T = Right(ClipText,8)
If Len(ReplaceString(ReplaceString(T, "1",""),"0",""))=0
SetSegmentButton(T)
EndIf
ElseIf Len(ClipText) = 4
If FindString(ClipText,"0x") = 1
Tt = Right(ClipText,2)
For i = 0 To 15
Tt = ReplaceString(Tt, ValidHex(i),"")
Next i
If Len(Tt) = 0
Tt = "$" + Right(ClipText,2)
T = RSet(Bin(Val(Tt)),8,"0")
SetSegmentButton(T)
EndIf
EndIf
ElseIf Len(ClipText) <= 3
Tt = ClipText
For i = 0 To 9
Tt = ReplaceString(Tt, ValidHex(i),"")
Next i
If Len(Tt) = 0
T = RSet(Bin(Val(ClipText)),8,"0")
SetSegmentButton(T)
EndIf
EndIf
EndProcedure
; -------------------------------------------------------------------------------------
Procedure ClearBtnClick()
Protected i , v
If GetGadgetState(InvertBtn)
v = 1
Else
v=0
EndIf
For i =1 To 8
SetButtonOnOff(i,v)
Next i
SetOutputTB()
EndProcedure
; -------------------------------------------------------------------------------------
Procedure SaveSettings()
Protected OutPut.s, i
OutPut =""
For i = 0 To 7
OutPut= OutPut + GetGadgetItemText(ListView2, i) + ";"
Next i
If GetGadgetState(InvertBtn)
Output = Output + "1;"
Else
Output = Output + "0;"
EndIf
If GetGadgetState(BinCopyBtn)
Output = Output + "0"
ElseIf GetGadgetState(DecCopyBtn)
Output = Output + "1"
ElseIf GetGadgetState(HexCopyBtn)
Output = Output + "2"
EndIf
Output = Output + ";" + GetGadgetText(PreBinTB)
If CreateFile(0, GetCurrentDirectory() + #FileName)
WriteStringN(0, OutPut)
CloseFile(0)
EndIf
EndProcedure
; -------------------------------------------------------------------------------------
Procedure DrawWindow()
Protected Event, EventType, EventGadget, DragGadget, DragItem, TargetItem, i, z, Str.s, T.s, F, loadDefaultOrder
SegmentNames(7)="Dp":SegmentNames(6)="G":SegmentNames(5)="F":SegmentNames(4)="E":SegmentNames(3)="D":SegmentNames(2)="C":SegmentNames(1)="B":SegmentNames(0)="A"
If OpenWindow(Window_0, 100, 100, 430, 305, #Title , #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered )
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
gtk_window_set_icon_(WindowID(Window_0), ImageID(CatchImage(#PB_Any,?LINUXICON)))
CompilerEndSelect
loadDefaultOrder = 1
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
LoadFont(#Font_10, "Arial", 10, #PB_Font_HighQuality)
LoadFont(#Font_12, "Arial", 12 , #PB_Font_HighQuality)
LoadFont(#Font_14, "Arial", 14 , #PB_Font_HighQuality)
CompilerCase #PB_OS_Linux
LoadFont(#Font_10, "Sans", 8, #PB_Font_HighQuality)
LoadFont(#Font_12, "Sans", 10 , #PB_Font_HighQuality)
CompilerEndSelect
ButtonColorGadget(Button_A, 37, 15, 100, 25, "A")
ButtonColorGadget(Button_B, 137, 40, 25, 100, "B")
ButtonColorGadget(Button_C, 137, 165, 25, 100, "C")
ButtonColorGadget(Button_D, 37, 265, 100, 25, "D")
ButtonColorGadget(Button_E, 11, 165, 25, 100, "E")
ButtonColorGadget(Button_F, 11, 40, 25, 100, "F")
ButtonColorGadget(Button_G, 36, 140, 100, 25, "G")
ButtonColorGadget(Button_Dp, 177, 260, 35, 35, "Dp")
For i=1 To 8
SetButtonColor(i, $FFFFFF, $0000FF,$000000 )
SetButtonFont(i, FontID(#Font_10))
Next i
ContainerGadget(Container0, 172, 15, 20, 210, #PB_Container_BorderLess | #PB_Container_Flat)
ListViewGadget(ListView1, 0, 0, 20, 210)
CloseGadgetList()
ContainerGadget(Container1, 193, 15, 40, 210, #PB_Container_BorderLess | #PB_Container_Flat)
ListViewGadget(ListView2, 0, 0, 40, 210)
CloseGadgetList()
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
SetGadgetFont(ListView1, FontID(#Font_14))
SetGadgetFont(ListView2, FontID(#Font_14))
CompilerCase #PB_OS_Linux
SetGadgetFont(ListView1, FontID(#Font_12))
SetGadgetFont(ListView2, FontID(#Font_12))
CompilerEndSelect
DisableGadget(ListView1, 1)
For i = 7 To 0 Step -1
AddGadgetItem(listview1, -1, Str(i))
Next i
EnableGadgetDrop(ListView2, #PB_Drop_Private, #PB_Drag_Move, #Drag_Listview2)
CheckBoxGadget(InvertBtn, 350, 10, 50, 24, "Invert")
TextGadget(TextBinTB, 310, 25, 24, 16, "Bin")
SetGadgetFont(TextBinTB, FontID(#Font_12))
StringGadget(PreBinTB, 245, 47, 37, 20, "0%")
SetGadgetFont(PreBinTB, FontID(#Font_10))
StringGadget(BinTB, 282, 45, 85, 24, "00000000", #PB_String_ReadOnly)
SetGadgetFont(BinTB, FontID(#Font_12))
TextGadget(TextDecTB, 310, 75, 30, 16, "Dec")
SetGadgetFont(TextDecTB, FontID(#Font_12))
StringGadget(DecTB, 282, 95, 85, 24, "0", #PB_String_ReadOnly)
SetGadgetFont(DecTB, FontID(#Font_12))
TextGadget(TextHexTB, 310, 125, 30, 16, "Hex")
SetGadgetFont(TextHexTB, FontID(#Font_12))
StringGadget(PreHexTB, 245, 147, 37, 20, "0x", #PB_String_ReadOnly)
SetGadgetFont(PreHexTB, FontID(#Font_10))
StringGadget(HexTB, 282, 145, 85, 24, "00", #PB_String_ReadOnly)
SetGadgetFont(HexTB, FontID(#Font_12))
If GadgetHeight(PreBinTB, #PB_Gadget_ActualSize) < GadgetHeight(PreBinTB, #PB_Gadget_RequiredSize)
ResizeGadget(PreBinTB, #PB_Ignore, #PB_Ignore, #PB_Ignore, GadgetHeight(PreBinTB, #PB_Gadget_RequiredSize))
EndIf
If GadgetHeight(BinTB, #PB_Gadget_ActualSize) < GadgetHeight(BinTB, #PB_Gadget_RequiredSize)
ResizeGadget(BinTB, #PB_Ignore, #PB_Ignore, #PB_Ignore, GadgetHeight(BinTB, #PB_Gadget_RequiredSize))
EndIf
If GadgetHeight(DecTB, #PB_Gadget_ActualSize) < GadgetHeight(DecTB, #PB_Gadget_RequiredSize)
ResizeGadget(DecTB, #PB_Ignore, #PB_Ignore, #PB_Ignore, GadgetHeight(DecTB, #PB_Gadget_RequiredSize))
EndIf
If GadgetHeight(PreHexTB, #PB_Gadget_ActualSize) < GadgetHeight(PreHexTB, #PB_Gadget_RequiredSize)
ResizeGadget(PreHexTB, #PB_Ignore, #PB_Ignore, #PB_Ignore, GadgetHeight(PreHexTB, #PB_Gadget_RequiredSize))
EndIf
If GadgetHeight(HexTB, #PB_Gadget_ActualSize) < GadgetHeight(HexTB, #PB_Gadget_RequiredSize)
ResizeGadget(HexTB, #PB_Ignore, #PB_Ignore, #PB_Ignore, GadgetHeight(HexTB, #PB_Gadget_RequiredSize))
EndIf
ResizeGadget(PreHexTB, #PB_Ignore, GadgetY(HexTB) + (GadgetHeight(HexTB, #PB_Gadget_ActualSize) -GadgetHeight(PreHexTB, #PB_Gadget_ActualSize) )/2, #PB_Ignore, #PB_Ignore)
ResizeGadget(PreBinTB, #PB_Ignore, GadgetY(BinTB) + (GadgetHeight(BinTB, #PB_Gadget_ActualSize) -GadgetHeight(PreBinTB, #PB_Gadget_ActualSize) )/2, #PB_Ignore, #PB_Ignore)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
SetGadgetColor(BinTB, #PB_Gadget_BackColor, RGB(255,255,255))
SetGadgetColor(DecTB, #PB_Gadget_BackColor, RGB(255,255,255))
SetGadgetColor(PreHexTB, #PB_Gadget_BackColor, RGB(255,255,255))
SetGadgetColor(HexTB, #PB_Gadget_BackColor, RGB(255,255,255))
CompilerEndSelect
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
OptionGadget(BinCopyBtn, 372, 47, 60, 16, "Copy")
OptionGadget(DecCopyBtn, 372, 97, 60, 16, "Copy")
OptionGadget(HexCopyBtn, 372, 147, 60, 16, "Copy")
CompilerCase #PB_OS_Linux
OptionGadget(BinCopyBtn, 365, 47, 60, 16, "Copy")
OptionGadget(DecCopyBtn, 365, 97, 60, 16, "Copy")
OptionGadget(HexCopyBtn, 365, 147, 60, 16, "Copy")
CompilerEndSelect
SetGadgetState(BinCopyBtn, 1)
If GadgetHeight(BinCopyBtn, #PB_Gadget_ActualSize) < GadgetHeight(BinCopyBtn, #PB_Gadget_RequiredSize)
ResizeGadget(BinCopyBtn, #PB_Ignore, #PB_Ignore, #PB_Ignore, GadgetHeight(BinCopyBtn, #PB_Gadget_RequiredSize))
EndIf
If GadgetHeight(DecCopyBtn, #PB_Gadget_ActualSize) < GadgetHeight(DecCopyBtn, #PB_Gadget_RequiredSize)
ResizeGadget(DecCopyBtn, #PB_Ignore, #PB_Ignore, #PB_Ignore, GadgetHeight(DecCopyBtn, #PB_Gadget_RequiredSize))
EndIf
If GadgetHeight(HexCopyBtn, #PB_Gadget_ActualSize) < GadgetHeight(HexCopyBtn, #PB_Gadget_RequiredSize)
ResizeGadget(HexCopyBtn, #PB_Ignore, #PB_Ignore, #PB_Ignore, GadgetHeight(HexCopyBtn, #PB_Gadget_RequiredSize))
EndIf
ResizeGadget(BinCopyBtn, #PB_Ignore, GadgetY(BinTB) + (GadgetHeight(BinTB, #PB_Gadget_ActualSize) -GadgetHeight(BinCopyBtn, #PB_Gadget_ActualSize) )/2, #PB_Ignore, #PB_Ignore)
ResizeGadget(DecCopyBtn, #PB_Ignore, GadgetY(DecTB) + (GadgetHeight(DecTB, #PB_Gadget_ActualSize) -GadgetHeight(DecCopyBtn, #PB_Gadget_ActualSize) )/2, #PB_Ignore, #PB_Ignore)
ResizeGadget(HexCopyBtn, #PB_Ignore, GadgetY(HexTB) + (GadgetHeight(HexTB, #PB_Gadget_ActualSize) -GadgetHeight(HexCopyBtn, #PB_Gadget_ActualSize) )/2, #PB_Ignore, #PB_Ignore)
ButtonGadget(CopyBtn, 255, 235, 80, 30, "Copy")
ButtonGadget(PasteBtn, 340, 235, 80, 30, "Paste")
ButtonGadget(ClearBtn, 255, 270, 165, 30, "Clear")
SetGadgetFont(CopyBtn, FontID(#Font_12))
SetGadgetFont(PasteBtn, FontID(#Font_12))
SetGadgetFont(ClearBtn, FontID(#Font_12))
If ReadFile(0, GetCurrentDirectory() + #FileName)
Repeat
Str = ReadString(0)
Until Eof(0)
CloseFile(0)
If CountString(Str,";") = 10
For i = 1 To 8
T=LCase(StringField(Str,i,";"))
F = 0
For z = 0 To 7
If LCase(SegmentNames(z)) = t
AddGadgetItem(listview2, -1, SegmentNames(z))
F = 1
Break
EndIf
Next z
If F = 0
ClearGadgetItems(listview2)
loadDefaultOrder = 0
Break
EndIf
Next i
If StringField(Str,9,";") = "1"
SetGadgetState(InvertBtn, 1)
EndIf
Select StringField(Str,10,";")
Case "0"
SetGadgetState(BinCopyBtn, 1)
Case "1"
SetGadgetState(DecCopyBtn, 1)
Case "2"
SetGadgetState(HexCopyBtn, 1)
EndSelect
SetGadgetText(PreBinTB, StringField(Str,11,";"))
Else
loadDefaultOrder = 0
EndIf
Else
loadDefaultOrder = 0
EndIf
If loadDefaultOrder = 0
For i = 7 To 0 Step -1
AddGadgetItem(listview2, -1, SegmentNames(i))
Next i
EndIf
SetOutputTB()
Repeat
Event = WaitWindowEvent()
EventType = EventType()
EventGadget = EventGadget()
Select event
Case #PB_Event_CloseWindow
SaveSettings()
Case #PB_Event_Menu
Select EventMenu()
EndSelect
Case #PB_Event_Gadget
Select EventGadget
Case Button_A, Button_B, Button_C, Button_D, Button_E, Button_F, Button_G, Button_Dp
Select EventType
Case #PB_EventType_LeftClick
SetOutputTB()
EndSelect
Case CopyBtn
Select EventType
Case #PB_EventType_LeftClick
CopyBtnClick()
EndSelect
Case PasteBtn
Select EventType
Case #PB_EventType_LeftClick
PasteBtnClick()
EndSelect
Case ClearBtn
Select EventType
Case #PB_EventType_LeftClick
ClearBtnClick()
EndSelect
Case ListView2
Select EventType
Case #PB_EventType_DragStart
DragGadget = EventGadget
DragItem = GetGadgetState(DragGadget)
If DragGadget = listview2
DragPrivate(#Drag_Listview2, #PB_Drag_Move)
EndIf
EndSelect
Case InvertBtn
SetOutputTB()
EndSelect
Case #PB_Event_GadgetDrop
EventGadget = GetActiveGadget()
TargetItem = GetGadgetState(EventGadget)
If EventDropPrivate() = #Drag_Listview2
ListViewGadgetMove(EventGadget, DragItem, TargetItem)
SetOutputTB()
EndIf
EndSelect
Until Event = #PB_Event_CloseWindow
EndIf
For i=1 To 8
DestroyGadget(i)
Next i
EndProcedure
DrawWindow()
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
DataSection
LINUXICON: : IncludeBinary "linux.png"
EndDataSection
CompilerEndSelect
; IDE Options = PureBasic 6.00 LTS (Windows - x64)
; CursorPosition = 487
; FirstLine = 355
; Folding = ---
; EnableXP
; DPIAware
; UseIcon = Icon.ico
; Executable = Win\7Segment to_x64.exe