-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathPBForm2IceDesign.pbi
More file actions
1792 lines (1641 loc) · 86.4 KB
/
PBForm2IceDesign.pbi
File metadata and controls
1792 lines (1641 loc) · 86.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;- Top
; -------------------------------------------------------------------------------------------------
; Name: PBForm2IceDesign.pbi
; Description: Export an interface from a Purebasic source (*.pbf, *.pb) and convert it to IceDesign format (*.icef)
; This is done at RunTime (see how to use below) by enumerating all PB Window and Object and building the Container-Child hierarchy.
; The Attributes, Constants,... are then retrieved (See Inventories below)
; And the List is then saved, window by window, to IceDesign format (*.icef)
; You can now design your interface in IceDesign :)
; Author: ChrisR
; Date: 2022-05-16
; PB-Version: 5.73 x64/x86
; OS: Windows only
; Forum: IceDesign topic: https://www.purebasic.fr/english/viewtopic.php?t=74711
;
; -------------------------------------------------------------------------------------------------
;
; Inventories:
; The Window(s) are recovered with their Sizes, Titles, BackColor, Constants and a Flag if there is a Menu.
; The Gadget(s) are recovered with their Positions and Sizes.
; The following attributes are retrieved:
; The Text of Buttons, CheckBox,... Minimum, Maximum, InnerWidth, InnerHeight, ColumnWidth, ScrollStep And PageLength
; Status Disabled, Hidden
; FrontColor, BackColor and ToolTip
; And a large part of the Constants. See the List below.
;
; ToolBar, StatusBar, Fonts and Images are Not recovered.
;
; The Splitter is listed to browse the hierarchy.
; As it is not supported by IceDesign, it is then removed and both child gadgets inherit the splitter's level and parent.
;
; -------------------------------------------------------------------------------------------------
;
; How to use:
; Include PBForm2IceDesign.pbi at the Beginning of Your Source Code:
; XIncludeFile "PBForm2IceDesign.pbi"
;
; After loading the Window(s) With Their Gadgets and Before the Event Loop, Call the Function:
; PBForm2IceDesign() Or PBForm2IceDesign(#Window)
;
; Optional, Customize your IceDesign Form with the Following Constants:
; #UseShortNames = #True ; #True: Use Short Name for Controls (ex: #Btn) | #False: Use Long Name for Controls (ex: #Button)
; #RenameControlNames = #True ; Auto Rename the Controls Name Using the Caption Name. For Button, CheckBox and Option (ex: #Btn_CaptionName)
; #SetHiddenFlag = #False ; #False: No Gadgets are hidden | #True: it uses the same status (0/1) as in your Window
; #SetDisabledFlag = #False ; #False: No Gadgets are Disabled | #True: it uses the same status (0/1) as in your Window
;
; Compile/Run (F5)
;
; Source Example:
; | EnableExplicit
; |
; | XIncludeFile "PBForm2IceDesign.pbi" ; <== Include PBForm2IceDesign.pbi source code
; |
; | Enumeration Window
; | #Window_0
; | EndEnumeration
; |
; | Enumeration Gadgets
; | #Button_1
; | EndEnumeration
; |
; | Procedure Open_Window_0(X = 0, Y = 0, Width = 240, Height = 90)
; | If OpenWindow(#Window_0, X, Y, Width, Height, "Title", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
; | ButtonGadget(#Button_1, 20, 20, 200, 50, "Button_1")
; | EndIf
; | EndProcedure
; |
; | Open_Window_0()
; | PBForm2IceDesign() ; <== Call the function PBForm2IceDesign() After Loading the Window(s) and Gadget(s) and Before the Event Loop
; |
; | Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
;
; -------------------------------------------------------------------------------------------------
;
; List of Constants recovered or not (requires additional tests):
; | #PB_Window_SystemMenu | OK |
; | #PB_Window_MinimizeGadget | OK |
; | #PB_Window_MaximizeGadget | OK |
; | #PB_Window_ScreenCentered | ~OK | If Compiled With the DPIaware Option
; | #PB_Window_SizeGadget | OK |
; | #PB_Window_Invisible | OK |
; | #PB_Window_TitleBar | OK |
; | #PB_Window_BorderLess | OK |
; | #PB_Window_Maximize | OK |
; | #PB_Window_Minimize | OK |
; | #PB_Window_WindowCentered | ~OK | If Compiled With the DPIaware Option
; | #PB_Window_Tool | OK |
; | #PB_Window_NoActivate | OK |
; | #PB_Button_Right | OK |
; | #PB_Button_Left | OK |
; | #PB_Button_Default | OK |
; | #PB_Button_MultiLine | OK |
; | #PB_Button_Toggle | OK |
; | #PB_#BS_Bottom | OK |
; | #PB_#BS_Flat | OK |
; | #PB_#BS_Top | OK |
; | #PB_Button_Toggle | OK |
; | #PB_Calendar_Borderless | OK |
; | #PB_Canvas_Container | OK |
; | #PB_Canvas_Border | OK |
; | #PB_Canvas_ClipMouse | Not OK |
; | #PB_Canvas_Keyboard | OK |
; | #PB_Canvas_DrawFocus | Not OK |
; | #PB_CheckBox_Center | OK |
; | #PB_CheckBox_Right | OK |
; | #PB_CheckBox_ThreeState | OK |
; | #PB_#BS_Bottom | OK |
; | #PB_#BS_LeftText | OK |
; | #PB_#BS_MultiLine | OK |
; | #PB_#BS_Top | OK |
; | #PB_ComboBox_LowerCase | OK |
; | #PB_ComboBox_UpperCase | OK |
; | #PB_ComboBox_Editable | OK |
; | #PB_ComboBox_Editable | OK |
; | #PB_ComboBox_Image | OK |
; | #PB_ComboBox_Image | OK |
; | #PB_Container_Flat | OK |
; | #PB_Container_Raised | OK |
; | #PB_Container_Single | OK |
; | #PB_Container_Double | OK |
; | ;#PB_Container_BorderLess | Default|
; | #PB_Date_UpDown | OK |
; | #PB_Date_CheckBox | OK |
; | #PB_Editor_ReadOnly | OK |
; | #PB_Editor_WordWrap | Not OK |
; | #PB_#ES_Center | OK |
; | #PB_#ES_NoHideSel | Not OK |
; | #PB_#ES_Right | OK |
; | #PB_Explorer_Editable | OK |
; | #PB_Explorer_DrivesOnly | Not OK |
; | #PB_Explorer_NoMyDocuments | Not OK |
; | #PB_Explorer_BorderLess | OK |
; | #PB_Explorer_AlwaysShowSelection | OK |
; | #PB_Explorer_MultiSelect | OK |
; | #PB_Explorer_NoFolders | OK |
; | #PB_Explorer_NoSort | OK |
; | #PB_Explorer_GridLines | Not OK |
; | #PB_Explorer_HeaderDragDrop | Not OK |
; | #PB_Explorer_FullRowSelect | Not OK |
; | #PB_Explorer_NoFiles | Not OK |
; | #PB_Explorer_NoParentFolder | Not OK |
; | #PB_Explorer_NoDirectoryChange | Not OK |
; | #PB_Explorer_NoDriveRequester | Not OK |
; | #PB_Explorer_NoMyDocuments | Not OK |
; | #PB_Explorer_AutoSort | Not OK |
; | #PB_Explorer_HiddenFiles | Not OK |
; | #PB_Explorer_BorderLess | OK |
; | #PB_Explorer_AlwaysShowSelection | OK |
; | #PB_Explorer_NoLines | OK |
; | #PB_Explorer_NoButtons | OK |
; | #PB_Explorer_NoFiles | Not OK |
; | #PB_Explorer_NoDriveRequester | Not OK |
; | #PB_Explorer_NoMyDocuments | Not OK |
; | #PB_Explorer_AutoSort | Not OK |
; | #PB_Frame_Flat | OK |
; | #PB_Frame_Single | OK |
; | #PB_Frame_Double | OK |
; | #PB_HyperLink_Underline | Not OK |
; | #PB_Image_Border | OK |
; | #PB_Image_Raised | OK |
; | #PB_ListIcon_MultiSelect | OK |
; | #PB_ListIcon_AlwaysShowSelection | OK |
; | #PB_#LVS_NoColumnHeader | OK |
; | #PB_#LVS_NoScroll | OK |
; | #PB_ListIcon_CheckBoxes | Not OK |
; | #PB_ListIcon_ThreeState | Not OK |
; | #PB_ListIcon_GridLines | Not OK |
; | #PB_ListIcon_FullRowSelect | Not OK |
; | #PB_ListIcon_HeaderDragDrop | Not OK |
; | #PB_ListView_ClickSelect | OK |
; | #PB_ListView_MultiSelect | OK |
; | #PB_#LBS_MultiColumn | OK |
; | #PB_OpenGL_Keyboard | Not OK |
; | #PB_OpenGL_NoFlipSynchronization | Not OK |
; | #PB_OpenGL_FlipSynchronization | Not OK |
; | #PB_OpenGL_NoDepthBuffer | Not OK |
; | #PB_OpenGL_16BitDepthBuffer | Not OK |
; | #PB_OpenGL_24BitDepthBuffer | Not OK |
; | #PB_OpenGL_NoStencilBuffer | Not OK |
; | #PB_OpenGL_8BitStencilBuffer | Not OK |
; | #PB_OpenGL_NoAccumulationBuffer | Not OK |
; | #PB_OpenGL_32BitAccumulationBuffer | Not OK |
; | #PB_OpenGL_64BitAccumulationBuffer | Not OK |
; | #PB__#BS_Bottom | OK |
; | #PB__#BS_LeftText | OK |
; | #PB__#BS_MultiLine | OK |
; | #PB__#BS_PushLike | OK |
; | #PB__#BS_Top | OK |
; | #PB_ProgressBar_Smooth | OK |
; | #PB_ProgressBar_Vertical | OK |
; | #PB_ScrollArea_Raised | OK |
; | #PB_ScrollArea_Flat | OK |
; | #PB_ScrollArea_Single | OK |
; | #PB_ScrollArea_BorderLess | OK |
; | #PB_ScrollArea_Center | Not OK |
; | #PB_ScrollBar_Vertical | OK |
; | #PB_Spin_ReadOnly | OK |
; | #PB_Spin_Numeric | Not OK |
; | #PB__#ES_Number | OK |
; | #PB_Splitter_Vertical | Not OK |
; | #PB_Splitter_Separator | Not OK |
; | #PB_Splitter_FirstFixed | Not OK |
; | #PB_Splitter_SecondFixed | Not OK |
; | #PB_String_Password | OK |
; | #PB_String_ReadOnly | OK |
; | #PB_String_Numeric | OK |
; | #PB_String_LowerCase | OK |
; | #PB_String_UpperCase | OK |
; | #PB_#ES_Center | OK |
; | #PB_#ES_MultiLine | OK |
; | #PB_#ES_NoHideSel | OK |
; | #PB_#ES_Right | OK |
; | #PB_String_BorderLess | OK |
; | #PB_Text_Center | OK |
; | #PB_Text_Right | OK |
; | #PB_Text_Border | OK |
; | #PB_#SS_EndEllipsis | OK |
; | #PB_#SS_PathEllipsis | OK |
; | #PB_#SS_WordEllipsis | OK |
; | #PB_TrackBar_Ticks | OK |
; | #PB_TrackBar_Vertical | OK |
; | #PB_Tree_AlwaysShowSelection | OK |
; | #PB_Tree_NoLines | OK |
; | #PB_Tree_NoButtons | OK |
; | #PB_Tree_CheckBoxes | OK |
; | #PB_Tree_ThreeState | Not OK |
;
; -------------------------------------------------------------------------------------------------
;EnableExplicit ; Not required
;- Custom Constants
#UseShortNames = #True ; #True: Use Short Name for Controls (ex: #Btn) | #False: Use Long Name for Controls (ex: #Button)
#RenameControlNames = #True ; Auto Rename the Controls Name Using the Caption Name. For Button, CheckBox and Option (ex: #Btn_CaptionName)
#SetHiddenFlag = #False ; #False: No Gadgets are hidden | #True: it uses the same status (0/1) as in your Window
#SetDisabledFlag = #False ; #False: No Gadgets are Disabled | #True: it uses the same status (0/1) as in your Window
#DebugON = #False ; #False\#True
;XIncludeFile "Save_JSON.pbi" : UseModule JSave ; Little John's module, Save JSON data with object members well-arranged: https://www.purebasic.fr/english/viewtopic.php?t=69100
Structure ModelObjectStruct ; Structure Model Gadget from Data Section. Loaded in a Map for easy access to models, Key = Str(GadgetType)
Model.s
Name.s
ShortName.s
Caption.s
Option1.s
Option2.s
Option3.s
FontText.s
FrontColor.s
BackColor.s
ToolTip.s
BindGadget.s
Constants.s
CountGadget.i
EndStructure
Structure ObjectPBStruct ; Structure to build the hierarchical list of objects. Starting from PB_Object_Enumerate
Level.i ; If Level = 1, Parent is a Window else a Gadget
Object.i
ObjectID.i
Type.i
IsContainer.b
ParentObject.i
ParentObjectID.i
GParentObjectID.i ; Temporary Loaded for ScrollArea and Panel, it is then reset to 0 for the ScrollArea and replaced by the tab number for Panel and GetGadgetItemText()
X.i
Y.i
Width.i
Height.i
EndStructure
Structure LoadPBStruct ; Structure for Loading and Saving Gadgets
Level.i
Gadget.i ; Gadget 2 Hard Coded for the Window
Model.s
Type.i
Name.s
Container.b
ParentGadget.i
TabIndex.i
X.i
Y.i
Width.i
Height.i
Group.i
Caption.s
Option1.s
Option2.s
Option3.s
FontText.s
FrontColor.s
BackColor.s
Lock.b
Disable.b
Hide.b
ToolTip.s
BindGadget.s
LockLeft.b
LockRight.b
LockTop.b
LockBottom.b
ProportionalSize.b
Constants.s
Key.s
EndStructure
CompilerIf Not(Defined(PB_Globals, #PB_Structure))
Structure PB_Globals
CurrentWindow.i
FirstOptionGadget.i
DefaultFont.i
*PanelStack
PanelStackIndex.l
PanelStackSize.l
ToolTipWindow.i
EndStructure
CompilerEndIf
Global NewMap ModelObject.ModelObjectStruct()
Global NewList ObjectPB.ObjectPBStruct()
Global NewList LoadPB.LoadPBStruct()
Global Dim Window(1, 0)
Global CountWindow, IndexTab
Import ""
CompilerIf Not(Defined(PB_Object_GetThreadMemory, #PB_Procedure)) : PB_Object_GetThreadMemory(*Mem) : CompilerEndIf
CompilerIf Not(Defined(PB_Object_Count, #PB_Procedure)) : PB_Object_Count(PB_Gadget_Objects) : CompilerEndIf
CompilerIf Not(Defined(PB_Object_EnumerateAll, #PB_Procedure)) : PB_Object_EnumerateAll(Object, *Object, ObjectData) : CompilerEndIf
CompilerIf Not(Defined(PB_Object_EnumerateStart, #PB_Procedure)) : PB_Object_EnumerateStart(PB_Gadget_Objects) : CompilerEndIf
CompilerIf Not(Defined(PB_Object_EnumerateNext, #PB_Procedure)) : PB_Object_EnumerateNext(PB_Gadget_Objects, *Object.Integer) : CompilerEndIf
CompilerIf Not(Defined(PB_Object_EnumerateAbort, #PB_Procedure)) : PB_Object_EnumerateAbort(PB_Gadget_Objects) : CompilerEndIf
CompilerIf Not(Defined(PB_Gadget_Globals, #PB_Variable)) : PB_Gadget_Globals.i : CompilerEndIf
CompilerIf Not(Defined(PB_Gadget_Objects, #PB_Variable)) : PB_Gadget_Objects.i : CompilerEndIf
CompilerIf Not(Defined(PB_Window_Objects, #PB_Variable)) : PB_Window_Objects.i : CompilerEndIf
EndImport
Declare LoadModelObject()
Declare IsPBContainer(Gadget)
Declare WindowPBCallBack(Window, *Window, WindowData)
Declare TabObjectPB(Object)
Declare ObjectPBCallBack(Object, *Object, ObjectData)
Declare WinPBHierarchy(ParentObjectID, ParentObject, FirstPassDone = #False)
Declare LoadObjectPB()
Declare GetObjectPBFromID(ObjectID)
Declare GetParentPB(Gadget)
Declare GetWindowPBRoot(Gadget)
Declare GetParentPBID(Gadget)
Declare ParentPBisWindow(Gadget)
Declare ParentPBisGadget(Gadget)
Declare CountChildPBGadget(ParentObject, GrandChildren = #False, FirstPassDone = #False)
Declare EnumWinChildPB(ParentObject, FirstPassDone = #False)
Declare EnumChildPB(Window = #PB_All)
Declare.s AddWindowPBFlag(Window, Constants.s)
Declare AddWindowPB(Window)
Declare.s GetToolTipText(Gadget)
Declare.s GetFontText(Gadget)
Declare.s CheckPBName(Name.s)
Declare.s UniquePBName(BaseName.s, Caption.s)
Declare.s AddGadgetPBFlag(Gadget, Constants.s)
Declare AddGadgetPB(Gadget)
Declare AddWinLoadPB(ParentObject, FirstPassDone = #False)
Declare SaveIceDesignForm(Window)
Declare AddLoadPB(Window = #PB_All)
Declare PBForm2IceDesign(Window = #PB_All)
;- ----- Macro -----
Macro _ObjectPB_(pObject, Object, ReturnValue = #False)
PushListPosition(ObjectPB())
Repeat
ForEach ObjectPB()
If ObjectPB()\Object = Object
pObject = @ObjectPB()
PopListPosition(ObjectPB())
Break 2
EndIf
Next
Debug " LoadFromPB Error: Object number Not Found: " + Str(Object)
PopListPosition(ObjectPB())
ProcedureReturn ReturnValue
Until #True
EndMacro
Macro _IsFlag_(StyleFlag, IsFlag)
Bool((StyleFlag & IsFlag) = IsFlag)
EndMacro
Macro _IsExFlag_(ExStyleFlag, IsFlag)
Bool((ExStyleFlag & IsFlag) = IsFlag)
EndMacro
Macro _HexColor_(Color)
"$" + RSet(Hex(Blue(Color)), 2, "0") + RSet(Hex(Green(Color)), 2, "0") + RSet(Hex(Red(Color)), 2, "0")
EndMacro
Macro _ProcedureReturnIf_(Cond, ReturnVal = 0)
If Cond
ProcedureReturn ReturnVal
EndIf
EndMacro
;- ----- Private Model -----
Procedure LoadModelObject() ;Initializing Gadget Templates
Protected Buffer.s, CountItem.i, I.i, J.i
With ModelObject()
Restore ModelObjectData
For I = 0 To 999 ; Loop break if Model = "---END---"
For J=1 To 14
Read.s Buffer
Select J
Case 1
If Buffer = "99"
Break 2
EndIf
AddMapElement(ModelObject(), Buffer) ; \Type
Case 2 : \Model = Buffer
Case 3 : \Name = Buffer
Case 4 : \ShortName = Buffer
Case 5 : \Caption = Buffer
Case 6 : \Option1 = Buffer
Case 7 : \Option2 = Buffer
Case 8 : \Option3 = Buffer
Case 9 : \FontText = Buffer
Case 10 : \FrontColor = Buffer
Case 11 : \BackColor = Buffer
Case 12 : \ToolTip = Buffer
Case 13 : \BindGadget = Buffer
Case 14 : \Constants = Buffer
EndSelect
If I > 0 : \CountGadget = 1 : EndIf
Next
Next
EndWith
;- DataSection ModelObjectData
DataSection
ModelObjectData:
;"GadgetType","Model","Name","ShortName","Caption","Option1","Option2","Option3","FontText","FrontColor","BackColor","ToolTip","BindGadgetEvent","Constants"
Data.s "0","OpenWindow","Window","Window","#Titl:","#Tool:000","#Boun:0|0|0|0","","","#Nooo","","#Nooo","#Nooo","Window_SystemMenu|Window_MinimizeGadget|Window_MaximizeGadget|Window_SizeGadget|Window_Invisible|Window_TitleBar|Window_Tool|Window_BorderLess|Window_ScreenCentered|Window_WindowCentered|Window_Maximize|Window_Minimize|Window_NoGadgets|Window_NoActivate"
Data.s "1","ButtonGadget","Button","Btn","#Text:","","","","","#Nooo","#Nooo","","0","Button_Right|Button_Left|Button_Default|Button_MultiLine|Button_Toggle|#BS_Bottom|#BS_Flat|#BS_Top"
Data.s "19","ButtonImageGadget","ButtonImage","BtnImg","","#Imag:0","","","#Nooo","#Nooo","#Nooo","","0","Button_Toggle"
Data.s "20","CalendarGadget","Calendar","Calend","","#Date:0","","","","","","","0","Calendar_Borderless"
;Data.s "33","CanvasContainerGadget","CanvasContainer","CanvCont","","","","","#Nooo","#Nooo","#Nooo","","0","Canvas_Border|Canvas_ClipMouse|Canvas_Keyboard|Canvas_DrawFocus|Canvas_Container"
Data.s "33","CanvasGadget","Canvas","Canv","","","","","#Nooo","#Nooo","#Nooo","","0","Canvas_Border|Canvas_ClipMouse|Canvas_Keyboard|Canvas_DrawFocus|Canvas_Container"
Data.s "4","CheckBoxGadget","CheckBox","Check","#Text:","","","","","#Nooo","#Nooo","","0","CheckBox_Right|CheckBox_Center|CheckBox_ThreeState|#BS_Bottom|#BS_LeftText|#BS_MultiLine|#BS_Top"
Data.s "8","ComboBoxGadget","Combo","Combo","#Elem:","","","","","#Nooo","#Nooo","","0","ComboBox_Editable|ComboBox_LowerCase|ComboBox_UpperCase|ComboBox_Image"
Data.s "11","ContainerGadget","Container","Cont","","","","","#Nooo","","","","#Nooo","Container_BorderLess|Container_Flat|Container_Raised|Container_Single|Container_Double"
Data.s "21","DateGadget","Date","Date","#Date:%yyyy-%mm-%dd","#Date:0","","","","#Nooo","#Nooo","","0","Date_UpDown|Date_CheckBox"
Data.s "22","EditorGadget","Editor","Edit","","","","","","","","","0","Editor_ReadOnly|Editor_WordWrap|#ES_Center|#ES_NoHideSel|#ES_Right"
Data.s "25","ExplorerComboGadget","ExplorerCombo","ExpCombo","#Dir$:","","","","","#Nooo","#Nooo","#Nooo","0","Explorer_DrivesOnly|Explorer_Editable|Explorer_NoMyDocuments"
Data.s "23","ExplorerListGadget","ExplorerList","ExpList","#Dir$:","","","","","","","","0","Explorer_BorderLess|Explorer_AlwaysShowSelection|Explorer_MultiSelect|Explorer_GridLines|Explorer_HeaderDragDrop|Explorer_FullRowSelect|Explorer_NoFiles|Explorer_NoFolders|Explorer_NoParentFolder|Explorer_NoDirectoryChange|Explorer_NoDriveRequester|Explorer_NoSort|Explorer_NoMyDocuments|Explorer_AutoSort|Explorer_HiddenFiles"
Data.s "24","ExplorerTreeGadget","ExplorerTree","ExpTree","#Dir$:","","","","","","","","0","Explorer_BorderLess|Explorer_AlwaysShowSelection|Explorer_NoLines|Explorer_NoButtons|Explorer_NoFiles|Explorer_NoDriveRequester|Explorer_NoMyDocuments|Explorer_AutoSort"
Data.s "7","FrameGadget","Frame","Frame","#Text:","","","","","#Nooo","#Nooo","#Nooo","#Nooo","Frame_Single|Frame_Double|Frame_Flat"
Data.s "10","HyperLinkGadget","HyperLink","Hyper","#Url$:https://www.purebasic.com/","#Hard:RGB(0,0,128)","","","","","","","0","HyperLink_Underline"
Data.s "9","ImageGadget","Image","Img","","#Imag:0","","","#Nooo","#Nooo","#Nooo","","0","Image_Border|Image_Raised"
Data.s "13","IPAddressGadget","IPAddress","IPAdd","","","","","","#Nooo","#Nooo","","0",""
Data.s "12","ListIconGadget","ListIcon","ListIcon","#Text:","","#Widh:120","","","","","","0","ListIcon_CheckBoxes|ListIcon_ThreeState|ListIcon_MultiSelect|ListIcon_GridLines|ListIcon_FullRowSelect|ListIcon_HeaderDragDrop|ListIcon_AlwaysShowSelection|#LVS_NoColumnHeader|#LVS_NoScroll"
Data.s "6","ListViewGadget","ListView","ListView","","","","","","","","","0","ListView_MultiSelect|ListView_ClickSelect|#LBS_ExtendedSel|#LBS_MultiColumn"
Data.s "34","OpenGLGadget","OpenGL","OpenGL","","","","","#Nooo","#Nooo","#Nooo","","0","OpenGL_Keyboard|OpenGL_NoFlipSynchronization|OpenGL_FlipSynchronization|OpenGL_NoDepthBuffer|OpenGL_16BitDepthBuffer|OpenGL_24BitDepthBuffer|OpenGL_NoStencilBuffer|OpenGL_8BitStencilBuffer|OpenGL_NoAccumulationBuffer|OpenGL_32BitAccumulationBuffer|OpenGL_64BitAccumulationBuffer"
Data.s "5","OptionGadget","Option","Opt","#Text:","","","","","#Nooo","#Nooo","","0","_#BS_Bottom|_#BS_LeftText|_#BS_MultiLine|_#BS_PushLike|_#BS_Top"
Data.s "28","PanelGadget","Panel","Panel","","","","","","#Nooo","#Nooo","","0",""
Data.s "14","ProgressBarGadget","ProgressBar","Progres","","#Mini:0","#Maxi:100","","#Nooo","","","","#Nooo","ProgressBar_Smooth|ProgressBar_Vertical"
Data.s "31","ScintillaGadget","Scintilla","Scint","","#Hard:0","","","","#Nooo","#Nooo","#Nooo","0",""
Data.s "16","ScrollAreaGadget","ScrollArea","ScrlArea","","#InrW:1200","#InrH:800","#Step:10","#Nooo","#Nooo","","#Nooo","0","ScrollArea_Flat|ScrollArea_Raised|ScrollArea_Single|ScrollArea_BorderLess|ScrollArea_Center"
Data.s "15","ScrollBarGadget","ScrollBar","ScrlBar","","#Mini:0","#Maxi:100","#Step:10","#Nooo","#Nooo","#Nooo","","0","ScrollBar_Vertical"
Data.s "26","SpinGadget","Spin","Spin","","#Mini:0","#Maxi:100","","","","","","0","Spin_ReadOnly|Spin_Numeric|_#ES_Number"
Data.s "29","SplitterGadget","Splitter","Splitter","","","","","#Nooo","#Nooo","#Nooo","#Nooo","0","Splitter_Vertical|Splitter_Separator|Splitter_FirstFixed|Splitter_SecondFixed"
Data.s "2","StringGadget","String","String","#Text:","","","","","","","","0","String_Numeric|String_Password|String_ReadOnly|String_LowerCase|String_UpperCase|String_BorderLess|#ES_Center|#ES_MultiLine|#ES_NoHideSel|#ES_Right"
Data.s "3","TextGadget","Text","Txt","#Text:","","","","","","","#Nooo","#Nooo","Text_Center|Text_Right|Text_Border|#SS_EndEllipsis|#SS_PathEllipsis|#SS_WordEllipsis"
Data.s "17","TrackBarGadget","TrackBar","Track","","#Mini:0","#Maxi:100","","#Nooo","#Nooo","#Nooo","","0","TrackBar_Ticks|TrackBar_Vertical"
Data.s "27","TreeGadget","Tree","Tree","","","","","","","","","0","Tree_AlwaysShowSelection|Tree_NoLines|Tree_NoButtons|Tree_CheckBoxes|Tree_ThreeState"
Data.s "18","WebGadget","WebView","Web","#Url$:about:blank","","","","","#Nooo","#Nooo","#Nooo","0",""
Data.s "50","PanelGadget","Tab","Tab","#TabN:","","","","#Nooo","#Nooo","#Nooo","#Nooo","#Nooo",""
Data.s "99","---END---","","","","","","","#Nooo","#Nooo","#Nooo","#Nooo","0",""
EndDataSection
EndProcedure
; ----- End Private Model -----
;
;- ----- Private GetParentPB -----
Procedure IsPBContainer(Gadget)
; Procedure IsContainer based on procedure IsCanvasContainer by mk-soft: https://www.purebasic.fr/english/viewtopic.php?t=79002
Select GadgetType(Gadget)
Case #PB_GadgetType_Container, #PB_GadgetType_Panel, #PB_GadgetType_ScrollArea, #PB_GadgetType_Splitter
ProcedureReturn #True
Case #PB_GadgetType_Canvas
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
If GetWindowLongPtr_(GadgetID(Gadget), #GWL_STYLE) & #WS_CLIPCHILDREN
ProcedureReturn #True
EndIf
CompilerCase #PB_OS_MacOS
Protected sv, count
sv = CocoaMessage(0, GadgetID(Gadget), "subviews")
count = CocoaMessage(0, sv, "count")
ProcedureReturn count
CompilerCase #PB_OS_Linux
Protected GList, count
GList = gtk_container_get_children_(GadgetID(Gadget))
If GList
count = g_list_length_(GList)
g_list_free_(GList)
ProcedureReturn count
EndIf
CompilerEndSelect
EndSelect
ProcedureReturn #False
EndProcedure
Procedure WindowPBCallBack(Window, *Window, WindowData)
Window(0, CountWindow) = Window
Window(1, CountWindow) = WindowID(Window)
CountWindow + 1
ProcedureReturn #True
EndProcedure
Procedure TabObjectPB(Object)
Protected *ObjectPB.ObjectPBStruct, TmpGadget, I, NbTab = CountGadgetItems(Object)
For I = 0 To NbTab - 1
OpenGadgetList(Object, I)
TmpGadget = ButtonGadget(#PB_Any, 0, 0, 0, 0 , "")
*ObjectPB = AddElement(ObjectPB())
With *ObjectPB
\Object = 50000 + IndexTab
IndexTab + 1
\ObjectID = GetParent_(GadgetID(TmpGadget))
\Type = 50
\IsContainer = 1
\ParentObjectID = GetParent_(\ObjectID)
\GParentObjectID = I
EndWith
FreeGadget(TmpGadget)
CloseGadgetList()
Next
EndProcedure
Procedure ObjectPBCallBack(Object, *Object, ObjectData)
Protected *ObjectPB.ObjectPBStruct = AddElement(ObjectPB())
If *ObjectPB <> 0
With *ObjectPB
\Object = Object
\ObjectID = GadgetID(Object)
\Type = GadgetType(Object)
\IsContainer = IsPBContainer(Object)
\ParentObjectID = GetParent_(\ObjectID)
\GParentObjectID = GetParent_(\ParentObjectID)
If \Type = #PB_GadgetType_Panel
TabObjectPB(Object)
EndIf
EndWith
Else
MessageRequester("Erreur !", "Impossible d'allouer de la mémoire pour le nouvel élément", #PB_MessageRequester_Ok)
ProcedureReturn #False
EndIf
ProcedureReturn #True
EndProcedure
Procedure WinPBHierarchy(ParentObjectID, ParentObject, FirstPassDone = #False)
Static ParentWindowID, Level
Protected ObjectType
If FirstPassDone = #False
Level = 0
ParentWindowID = ParentObjectID
FirstPassDone = #True
EndIf
Level + 1
PushListPosition(ObjectPB())
ResetList(ObjectPB())
With ObjectPB()
While NextElement(ObjectPB())
If ParentWindowID <> ParentObjectID And IsGadget(ParentObject) : ObjectType = GadgetType(ParentObject) : Else : ObjectType = 0 : EndIf
If \GParentObjectID <> #PB_Default And (\ParentObjectID = ParentObjectID Or (\GParentObjectID = ParentObjectID And ObjectType = #PB_GadgetType_ScrollArea))
\ParentObject = ParentObject
\Level = Level
; Do Not Change \GParentObjectID For Tabs (\Object >= 50000 And < 60000). It is Used then by GetGadgetItemText to Get the Tab Name
If \GParentObjectID = ParentObjectID And ObjectType = #PB_GadgetType_ScrollArea
\X = GadgetX(\Object)
\Y = GadgetY(\Object)
\Width = GadgetWidth(\Object)
\Height = GadgetHeight(\Object)
\ParentObjectID = \GParentObjectID
\GParentObjectID = #PB_Default ; 0
ElseIf \ParentObjectID = ParentObjectID And ObjectType = #PB_GadgetType_Splitter ; Specific to Exclude Splitter. The Parent of its Chidren is the Grand Parent (= the Splitter Parent)
\X = GadgetX(\Object) + GadgetX(ParentObject)
\Y = GadgetY(\Object) + GadgetY(ParentObject)
\Width = GadgetWidth(\Object)
\Height = GadgetHeight(\Object)
\ParentObjectID = \GParentObjectID
\ParentObject = GetObjectPBFromID(\ParentObjectID) ; Or GetDlgCtrlID_(\ParentObjectID)
\GParentObjectID = #PB_Default ; 0
ElseIf \Object < 50000 Or \Object > 59999
\X = GadgetX(\Object)
\Y = GadgetY(\Object)
\Width = GadgetWidth(\Object)
\Height = GadgetHeight(\Object)
\GParentObjectID = #PB_Default ; 0
EndIf
If \IsContainer
If \Type = #PB_GadgetType_Splitter : \Level = 99 : Level - 1 : EndIf ; Specific to Exclude Splitter. Keep the current Level for the 2 Splitter chidren
WinPBHierarchy(\ObjectID, \Object, FirstPassDone)
If \Type <> #PB_GadgetType_Splitter : Level - 1 : EndIf ; Specific to Exclude Splitter. Level - 1 without the Splitter type test
EndIf
EndIf
Wend
EndWith
PopListPosition(ObjectPB())
EndProcedure
Procedure LoadObjectPB()
Protected I
CountWindow = PB_Object_Count(PB_Window_Objects)
If CountWindow = 0
MessageRequester("Warning", "No Open Window !" +#CRLF$+#CRLF$+ "PBForm2IceDesign() Function Must be Executed After Opening the Window(s)." +#CRLF$+#CRLF$+ "Continue.", #PB_MessageRequester_Ok | #PB_MessageRequester_Warning)
ProcedureReturn
EndIf
ReDim Window(1, CountWindow - 1)
CountWindow = 0
PB_Object_EnumerateAll(PB_Window_Objects, @WindowPBCallBack(), 0)
PB_Object_EnumerateAll(PB_Gadget_Objects, @ObjectPBCallBack(), 0)
If ListSize(ObjectPB()) > 0
; Pass through the hierarchy for each window
CountWindow = PB_Object_Count(PB_Window_Objects)
For I = 0 To CountWindow - 1
WinPBHierarchy(Window(1, I), Window(0, I))
Next
Else
ProcedureReturn #False
EndIf
ProcedureReturn #True
EndProcedure
; ----- End Private GetParentPB -----
;
;- ----- Public GetParentPB -----
Procedure GetObjectPBFromID(ObjectID)
_ProcedureReturnIf_(ListSize(ObjectPB()) = 0, #PB_Default)
Protected Object = #PB_Default, I
With ObjectPB()
PushListPosition(ObjectPB())
ForEach ObjectPB()
If \ObjectID = ObjectID
Object = \Object
Break
EndIf
Next
PopListPosition(ObjectPB())
EndWith
If Object = #PB_Default
For I = 0 To CountWindow - 1
If Window(1, I) = ObjectID
Object = Window(0, I)
Break
EndIf
Next
EndIf
ProcedureReturn Object
EndProcedure
Procedure GetParentPB(Object)
_ProcedureReturnIf_(ListSize(ObjectPB()) = 0, #PB_Default)
Protected *ObjectPB.ObjectPBStruct : _ObjectPB_(*ObjectPB, Object, 0)
ProcedureReturn *ObjectPB\ParentObject
EndProcedure
Procedure GetWindowPBRoot(Object)
_ProcedureReturnIf_(ListSize(ObjectPB()) = 0, #PB_Default)
Protected *ObjectPB.ObjectPBStruct
PushListPosition(ObjectPB())
Repeat
If _ObjectPB_(*ObjectPB, Object, 0)
Object = *ObjectPB\ParentObject
Else
Object = #PB_Default
Break ; It should not happen
EndIf
Until *ObjectPB\Level = 1
PopListPosition(ObjectPB())
ProcedureReturn Object
EndProcedure
Procedure GetParentPBID(Object)
_ProcedureReturnIf_(ListSize(ObjectPB()) = 0, #PB_Default)
Protected *ObjectPB.ObjectPBStruct : _ObjectPB_(*ObjectPB, Object, 0)
ProcedureReturn *ObjectPB\ParentObjectID
EndProcedure
Procedure ParentPBisWindow(Object)
_ProcedureReturnIf_(ListSize(ObjectPB()) = 0, #PB_Default)
Protected *ObjectPB.ObjectPBStruct : _ObjectPB_(*ObjectPB, Object, 0)
If *ObjectPB\Level = 1
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
Procedure ParentPBisGadget(Object)
_ProcedureReturnIf_(ListSize(ObjectPB()) = 0, #PB_Default)
Protected *ObjectPB.ObjectPBStruct : _ObjectPB_(*ObjectPB, Object, 0)
If *ObjectPB\Level > 1
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
Procedure CountChildPBGadget(ParentObject, GrandChildren = #False, FirstPassDone = #False)
Static Level, Count
Protected *ObjectPB.ObjectPBStruct, Object, ReturnVal
If FirstPassDone = 0
_ProcedureReturnIf_(ListSize(ObjectPB()) = 0, #PB_Default)
If IsWindow(ParentObject)
Level = 0
ElseIf IsGadget(ParentObject)
Object = ParentObject
If _ObjectPB_(*ObjectPB, Object, 0)
If Not(*ObjectPB\IsContainer)
ProcedureReturn #PB_Default
EndIf
Level = *ObjectPB\Level
Else
ProcedureReturn #PB_Default
EndIf
EndIf
Count = 0
FirstPassDone = #True
EndIf
Level + 1
PushListPosition(ObjectPB())
ResetList(ObjectPB())
With ObjectPB()
While NextElement(ObjectPB())
If \Level = Level And \ParentObject = ParentObject
Count + 1
If GrandChildren And \IsContainer
CountChildPBGadget(ObjectPB()\Object, GrandChildren, FirstPassDone)
Level - 1
EndIf
EndIf
Wend
EndWith
PopListPosition(ObjectPB())
ProcedureReturn Count
EndProcedure
Procedure EnumWinChildPB(ParentObject, FirstPassDone = #False)
Static Level
Protected ReturnVal
If FirstPassDone = 0
_ProcedureReturnIf_(ListSize(ObjectPB()) = 0, #PB_Default)
If IsWindow(ParentObject)
Level = 0
Debug "Enum Child Gadget of Window " + LSet(Str(ParentObject), 10) + "| WindowID " + LSet(Str(WindowID(ParentObject)), 10) + "(Level = 0)"
Else
ProcedureReturn #PB_Default
EndIf
FirstPassDone = #True
EndIf
Level + 1
PushListPosition(ObjectPB())
ResetList(ObjectPB())
With ObjectPB()
While NextElement(ObjectPB())
If \Level = Level And \ParentObject = ParentObject
If \Object >= 50000 And \Object < 60000
Debug LSet("", \Level * 4 , " ") + "PanelTab " + LSet(Str(\Object), 10) + "ParentGadget " + LSet(Str(\ParentObject), 10) + "| GadgetID " + LSet(Str(\ObjectID), 10) + "ParentGadgetID " + LSet(Str(\ParentObjectID), 10) + "(Level = " + Str(\Level) + ") - Tab: " + GetGadgetItemText(\ParentObject, \GParentObjectID)
ElseIf \Type = #PB_GadgetType_Canvas And \IsContainer
Debug LSet("", \Level * 4 , " ") + "CanvasContainerGadget " + LSet(Str(\Object), 10) + "ParentGadget " + LSet(Str(\ParentObject), 10) + "| GadgetID " + LSet(Str(\ObjectID), 10) + "ParentGadgetID " + LSet(Str(\ParentObjectID), 10) + "(Level = " + Str(\Level) + ") - Tab: " + GetGadgetItemText(\ParentObject, \GParentObjectID)
Else
Debug LSet("", \Level * 4 , " ") + LSet(ModelObject(Str(\Type))\Model, 22) + LSet(Str(\Object), 10) + "ParentGadget " + LSet(Str(\ParentObject), 10) + "| GadgetID " + LSet(Str(\ObjectID), 10) + "ParentGadgetID " + LSet(Str(\ParentObjectID), 10) + "(Level = " + Str(\Level) + ")"
EndIf
If \IsContainer
EnumWinChildPB(ObjectPB()\Object, FirstPassDone)
Level - 1
EndIf
EndIf
Wend
EndWith
PopListPosition(ObjectPB())
EndProcedure
Procedure EnumChildPB(Window = #PB_All)
_ProcedureReturnIf_(ListSize(ObjectPB()) = 0, #PB_Default)
Protected I
If Window = #PB_All
For I = 0 To CountWindow - 1
EnumWinChildPB(Window(0, I))
Debug ""
Next
Else
If IsWindow(Window)
EnumWinChildPB(Window)
EndIf
EndIf
EndProcedure
; ----- End Public GetParentPB -----
;
;- ----- Private LoadPB -----
Procedure.s AddWindowPBFlag(Window, Constants.s)
Protected Handle = WindowID(Window)
Protected StyleFlag = GetWindowLongPtr_(Handle, #GWL_STYLE)
Protected ExStyleFlag = GetWindowLongPtr_(Handle, #GWL_EXSTYLE)
Protected DesktopWidth, DesktopHeight, I, Desktop = ExamineDesktops()-1
; Window_SystemMenu|Window_MinimizeGadget|Window_MaximizeGadget|Window_SizeGadget|Window_Invisible|Window_TitleBar|Window_Tool|Window_BorderLess|Window_ScreenCentered|Window_WindowCentered|Window_Maximize|Window_Minimize|Window_NoGadgets|Window_NoActivate
If _IsFlag_(StyleFlag, #WS_SYSMENU)
Constants = ReplaceString(Constants, "Window_SystemMenu", "Window_SystemMenu(x)", #PB_String_NoCase)
EndIf
If _IsFlag_(StyleFlag, #WS_MINIMIZEBOX)
Constants = ReplaceString(Constants, "Window_MinimizeGadget", "Window_MinimizeGadget(x)", #PB_String_NoCase)
EndIf
If _IsFlag_(StyleFlag, #WS_MAXIMIZEBOX)
Constants = ReplaceString(Constants, "Window_MaximizeGadget", "Window_MaximizeGadget(x)", #PB_String_NoCase)
EndIf
If _IsFlag_(StyleFlag, #WS_SIZEBOX)
Constants = ReplaceString(Constants, "Window_SizeGadget", "Window_SizeGadget(x)", #PB_String_NoCase)
EndIf
If Not(_IsFlag_(StyleFlag, #WS_VISIBLE))
Constants = ReplaceString(Constants, "Window_Invisible", "Window_Invisible(x)", #PB_String_NoCase)
EndIf
If Not(_IsFlag_(StyleFlag, #WS_BORDER))
Constants = ReplaceString(Constants, "Window_BorderLess", "Window_BorderLess(x)", #PB_String_NoCase)
If _IsFlag_(StyleFlag, #WS_CAPTION)
Constants = ReplaceString(Constants, "Window_TitleBar", "Window_TitleBar(x)", #PB_String_NoCase)
EndIf
EndIf
If _IsFlag_(StyleFlag, #WS_MAXIMIZE)
Constants = ReplaceString(Constants, "Window_Maximize", "Window_Maximize(x)", #PB_String_NoCase)
ElseIf _IsFlag_(StyleFlag, #WS_MINIMIZE)
Constants = ReplaceString(Constants, "Window_Minimize", "Window_Minimize(x)", #PB_String_NoCase)
EndIf
;If _IsFlag_(StyleFlag, #PB_Window_NoGadgets) :Constants = ReplaceString(Constants, "Window_NoGadgets", "Window_NoGadgets(x)", #PB_String_NoCase) : EndIf ; no sense for importing gadgets
If _IsExFlag_(ExStyleFlag, #WS_EX_TOOLWINDOW)
Constants = ReplaceString(Constants, "Window_Tool", "Window_Tool(x)", #PB_String_NoCase)
EndIf
If _IsExFlag_(ExStyleFlag, #WS_EX_NOACTIVATE)
Constants = ReplaceString(Constants, "Window_NoActivate", "Window_NoActivate(x)", #PB_String_NoCase)
EndIf
; Window_ScreenCentered - If DPIaware
For i = 0 To Desktop
DesktopWidth + DesktopWidth(Desktop)
DesktopHeight + DesktopHeight(Desktop)
Next
DesktopWidth = (DesktopWidth - DesktopScaledX(WindowWidth(Window, #PB_Window_FrameCoordinate))) / 2
DesktopHeight = (DesktopHeight - DesktopScaledY(WindowHeight(Window, #PB_Window_FrameCoordinate))) / 2
If Abs(DesktopScaledX(WindowX(Window)) - DesktopWidth) < 2 And Abs(DesktopScaledY(WindowY(Window)) - DesktopHeight) < 2 ; 0 or 1 depending on rounding
Constants = ReplaceString(Constants, "Window_ScreenCentered", "Window_ScreenCentered(x)", #PB_String_NoCase)
CompilerIf #DebugON : Debug "#PB_Window_ScreenCentered" : CompilerEndIf
EndIf
; Window_WindowCentered - If DPIaware
Handle = GetProp_(GetParent_(Handle), "PB_WindowID")-1 ; PB Parent Window Number
If IsWindow(Handle)
DesktopWidth = (DesktopScaledX(WindowWidth(Handle)) - DesktopScaledX(WindowWidth(Window, #PB_Window_FrameCoordinate))) / 2
DesktopHeight = (DesktopScaledY(WindowHeight(Handle)) - DesktopScaledY(WindowHeight(Window, #PB_Window_FrameCoordinate))) / 2
If Abs(DesktopScaledX(WindowX(Window)) - DesktopWidth) < 2 And Abs(DesktopScaledY(WindowY(Window)) - DesktopHeight) < 2 ; 0 or 1 depending on rounding
Constants = ReplaceString(Constants, "Window_WindowCentered", "Window_WindowCentered(x)", #PB_String_NoCase)
CompilerIf #DebugON : Debug "#PB_Window_WindowCentered" : CompilerEndIf
EndIf
EndIf
ProcedureReturn Constants
EndProcedure
Procedure AddWindowPB(Window)
Protected *LoadPB.LoadPBStruct, Color
*LoadPB = AddElement(LoadPB())
If *LoadPB <> 0
With *LoadPB
\Level = 0
\Gadget = 2
\Type = 0
\Container = #True
\ParentGadget = 0
\TabIndex = #PB_Ignore
\X = 0
\Y = 0
\Width = WindowWidth(Window)
\Height = WindowHeight(Window)
\LockLeft = #True
\LockTop = #True
If FindMapElement(ModelObject(), Str(\Type))
\Model = ModelObject()\Model
CompilerIf #UseShortNames
\Name = "#" + ModelObject()\ShortName + "_" + Str(ModelObject()\CountGadget)
CompilerElse
\Name = "#" + ModelObject()\Name + "_" + Str(ModelObject()\CountGadget)
CompilerEndIf
ModelObject()\CountGadget + 1
\Caption = ModelObject()\Caption + GetWindowTitle(Window)
\Option1 = "#Tool:" ; "#Tool:000"
If GetMenu_(WindowID(Window))
\Option1 = \Option1 + "1"
Else
\Option1 = \Option1 + "0"
EndIf
\Option1 = \Option1 + "00" ; ToolBarFlag + StatusBar
\Option2 = ModelObject()\Option2
\Option3 = ModelObject()\Option3
\FontText = ModelObject()\FontText
\FrontColor = ModelObject()\FrontColor
Color = GetWindowColor(Window)
If Color <> #PB_Default
\BackColor = _HexColor_(Color)
EndIf
\ToolTip = ModelObject()\ToolTip
\BindGadget = ModelObject()\BindGadget
\Constants = AddWindowPBFlag(Window, ModelObject()\Constants)
\Key = RSet(Str(\Level),2, "0") + RSet(Str(\TabIndex), 6, "0") + RSet(Str(\Y), 5, "0") + RSet(Str(\X), 5, "0")
CompilerIf #DebugON
Debug " ---> Hierarchical View of Window and Gadgets Using: Object(#Gadget,X,Y,W,H,Capion,Option1,Option2,Option3,Constant(x))"
Debug \Model + "(" + \Name + ", " + Str(\X) + ", " + Str(\Y) + ", " + Str(\Width) + ", " + Str(\Height) + ", " +
#DQUOTE$+ Mid(\Caption, 7) +#DQUOTE$+ ", " + \Constants + ")"
If Left(\BackColor, 5) <> "#Nooo" And \BackColor <> "" : Debug "SetWindowColor(" + \Name + ", " + \BackColor + ")" : EndIf
CompilerEndIf
EndIf
EndWith
EndIf
EndProcedure
Procedure.s GetToolTipText(Gadget)
Static *PB_Globals.PB_Globals
Protected TTinfo.TOOLINFO, Buffer.s
If *PB_Globals = 0
*PB_Globals = PB_Object_GetThreadMemory(PB_Gadget_Globals)
EndIf
Buffer = Space(#MAX_PATH)
TTinfo\cbSize = SizeOf(TTinfo)
TTinfo\uId = GadgetID(Gadget)
TTinfo\hwnd = GetParent_(TTinfo\uId)
TTinfo\lpszText = @Buffer
SendMessage_(*PB_Globals\ToolTipWindow, #TTM_GETTEXT, 0, @TTinfo)
ProcedureReturn Trim(Buffer)
EndProcedure
Procedure.s GetFontText(Gadget)
Protected hDC, FontID, FontAttrib.LOGFONT
Protected FontName.s, FontSize, FontStyle.s
Static DefaultFont
If DefaultFont = 0
Protected TempGadget = ButtonGadget(#PB_Any, 0, 0, 25, 25, "ABC123")
SetGadgetFont(TempGadget, #PB_Default)
DefaultFont = GetGadgetFont(TempGadget)
FreeGadget(TempGadget)
EndIf
FontID = GetGadgetFont(Gadget)
If FontID And FontID <> DefaultFont
GetObject_(FontID, SizeOf(FontAttrib), @FontAttrib)
FontName = PeekS(@FontAttrib\lfFaceName[0])
hDC = GetDC_(GadgetID(Gadget))
FontSize = Int(Round((-FontAttrib \ lfHeight * 72 / GetDeviceCaps_(hDC, #LOGPIXELSY)), 1))
If FontAttrib\lfWeight > #FW_NORMAL : FontStyle + "B" : EndIf ; Bold
If FontAttrib\lfItalic : FontStyle + "I" : EndIf ; Italic
If FontAttrib\lfStrikeOut : FontStyle + "S" : EndIf ; StrikeOut
If FontAttrib\lfUnderline : FontStyle + "U" : EndIf ; Underline
If FontAttrib\lfQuality <> #DEFAULT_QUALITY : FontStyle + "H" : EndIf ; High Quality
FontName + " | " + FontSize
If FontStyle : FontName + " | " + FontStyle : EndIf
EndIf
ProcedureReturn FontName