-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTRect.cls
146 lines (128 loc) · 3.39 KB
/
TRect.cls
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
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "TRect"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Description = "Classe rettangolo"
Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit
Private lLeft As Long
Private lTop As Long
Private lRight As Long
Private lBottom As Long
Public Enum rPosition
rLeftTop = 1
rRightTop
rLeftBottom
rRightBottom
End Enum
Private Sub Class_Initialize()
lLeft = 0
lTop = 0
lRight = 0
lBottom = 0
End Sub
Public Property Get Left() As Variant
Left = lLeft
End Property
Public Property Get Top() As Variant
Top = lTop
End Property
Public Static Property Get Right() As Variant
Right = lRight
End Property
Public Property Let Right(ByVal vNewRight As Variant)
lRight = vNewRight
End Property
Public Property Get Bottom() As Variant
Bottom = lBottom
End Property
Public Property Get Height() As Variant
Height = (lBottom - lTop)
End Property
Public Property Get Width() As Variant
Width = (lRight - lLeft)
End Property
Public Property Let Width(ByVal vNewWidth As Variant)
lRight = lLeft + vNewWidth
End Property
Public Sub Copy(ByVal Other As TRect)
lLeft = Other.Left
lRight = Other.Right
lTop = Other.Top
lBottom = Other.Bottom
End Sub
Public Sub SetRect(ByVal Left As Long, ByVal Top As Long, ByVal Right As Long, ByVal Bottom As Long)
lLeft = Left
lTop = Top
lRight = Right
lBottom = Bottom
End Sub
Public Sub SetRectWH(ByVal Left As Long, ByVal Top As Long, ByVal Width As Long, ByVal Height As Long)
lLeft = Left
lTop = Top
lRight = lLeft + Width
lBottom = lTop + Height
End Sub
Public Sub Inflate(ByVal dx As Long, ByVal dy As Long)
lLeft = lLeft + dx
lRight = lRight + dx
lTop = lTop + dy
lBottom = lBottom + dy
End Sub
Public Sub GetFormRect(frm As Form)
SetRect frm.ScaleLeft, frm.ScaleTop, frm.ScaleWidth, frm.ScaleHeight
End Sub
Public Sub GetControlRect(ctrl As Control)
SetRectWH ctrl.Left, ctrl.Top, ctrl.Width, ctrl.Height
End Sub
Public Sub MoveControlTo(ctrl As Control, ByVal X As Long, ByVal Y As Long)
GetControlRect ctrl
MoveTo X, Y
SetControlRect ctrl
End Sub
Public Sub MoveTo(ByVal X As Long, ByVal Y As Long)
Dim tmpW As Long, tmpH As Long
tmpW = Width
tmpH = Height
lLeft = X
lTop = Y
lRight = X + tmpW
lBottom = Y + tmpH
End Sub
Public Sub SetControlRect(ctrl As Control)
ctrl.Left = lLeft
ctrl.Top = lTop
ctrl.Width = Width
ctrl.Height = Height
End Sub
Public Sub Reposition(ByVal pos As rPosition, ByVal outerRec As TRect)
Select Case pos
Case rLeftTop
MoveTo 0, 0
Case rRightTop
MoveTo (outerRec.Width - Width), 0
Case rLeftBottom
MoveTo 0, (outerRec.Height - Height)
Case rRightBottom
MoveTo (outerRec.Width - Width), (outerRec.Height - Height)
End Select
End Sub
Public Sub Normalize()
Dim Temp As Long
If lLeft > lRight Then
Temp = lLeft
lLeft = lRight
lRight = Temp
End If
If lTop > lBottom Then
Temp = lTop
lTop = lBottom
lBottom = Temp
End If
End Sub