-
Notifications
You must be signed in to change notification settings - Fork 0
/
LockResize.pbi
157 lines (124 loc) · 3.58 KB
/
LockResize.pbi
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
;LockResizeGadget.pbi Version 2.00
;
;Create : 07 Aout 2012
;Update : 19 Septembre 2017
;
;OS : Window, Linux (En principe), OSx (En principe)
;PB 4.51, --> 5.61
;
;
;Contributors
; Falsam
;
; Licence : Use As You Like
;
Declare __ResizeWindow()
;
; Initialisation
Procedure UseLockGadget()
Structure Gadget
Window.i
Gadget.i
DeltaLeft.i
DeltaTop.i
DeltaRight.i
DeltaBottom.i
Width.i
Height.i
LockLeft.b
LockTop.b
LockRight.b
LockBottom.b
HorizontalCenter.b
VerticalCenter.b
EndStructure
Global NewMap Windows()
Global NewList LockGadgets.Gadget()
EndProcedure
;
;Fixe (#True) ou pas (#False) les bords d'un gadget sur une fenêtre.
;Centre (#True) ou pas (#False) un gadget horizontalement et/ou verticalement.
Procedure LockGadget(Window.i, Gadget.i, LockLeft.b, LockTop.b, LockRight.b, LockBottom.b, HorizontalCenter.b = #False, VerticalCenter.b = #False)
BindEvent(#PB_Event_SizeWindow, @__ResizeWindow())
AddElement(LockGadgets())
With LockGadgets()
\Gadget = Gadget
\Window = window
\LockLeft = Lockleft
\LockTop = Locktop
\LockRight = Lockright
\LockBottom = LockBottom
\HorizontalCenter = HorizontalCenter
\VerticalCenter = VerticalCenter
\DeltaLeft = GadgetX(Gadget)
\DeltaTop = GadgetY(Gadget)
\DeltaRight = WindowWidth(Window) - GadgetX(Gadget) - GadgetWidth(Gadget)
\DeltaBottom = WindowHeight(Window) - GadgetY(Gadget) - GadgetHeight(Gadget)
\Width = GadgetWidth(Gadget)
\Height = GadgetHeight(Gadget)
EndWith
EndProcedure
;
; Unlock un ou tous(Gadget.l=#True) les gadget d'une fenetre
Procedure UnlockGadget(Window.l, Gadget.l=#True)
ForEach LockGadgets()
If LockGadgets()\Window = Window
If LockGadgets()\Gadget = Gadget Or Gadget=#True
DeleteElement(LockGadgets())
EndIf
EndIf
Next
EndProcedure
;
; Redimensionne les gadgets mémorisés dans la liste.
Procedure __ResizeGadgets(Window.i)
Protected Gadget.i, X.i, Y.i, W.i, H.i
ForEach LockGadgets()
If LockGadgets()\Window = Window
With LockGadgets()
Gadget = \Gadget
X = WindowWidth(window) - \DeltaRight - \Width
Y = WindowHeight(window) - \DeltaBottom - \Height
W = #PB_Ignore
H = #PB_Ignore
If \LockRight = #False
X = #PB_Ignore
EndIf
If \LockBottom = #False
Y = #PB_Ignore
EndIf
If \LockLeft = #True
X = \DeltaLeft
EndIf
If \LockTop = #True
Y = \DeltaTop
EndIf
If \LockRight = #True
W = WindowWidth(Window) - X - \DeltaRight
EndIf
If \LockBottom = #True
H = WindowHeight(Window) - Y - \DeltaBottom
EndIf
If \HorizontalCenter = #True
X = (WindowWidth(Window) - \Width)/2
EndIf
If \VerticalCenter = #True
Y = (WindowHeight(Window) - \Height)/2
EndIf
ResizeGadget(Gadget, X, Y, W, H)
EndWith
EndIf
Next
EndProcedure
Procedure __ResizeWindow()
__ResizeGadgets(EventWindow())
EndProcedure
;
; Détruit la Liste et libère toutes les ressources associées
Procedure FreeLockGadget()
ResetList(LockGadgets())
EndProcedure
; IDE Options = PureBasic 5.60 (Windows - x86)
; Folding = ---
; EnableXP
; EnableUnicode