-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathctlRuleEdit.ctl
More file actions
304 lines (272 loc) · 10.2 KB
/
Copy pathctlRuleEdit.ctl
File metadata and controls
304 lines (272 loc) · 10.2 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
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.UserControl ctlRuleEdit
BackColor = &H80000005&
BorderStyle = 1 'Fixed Single
ClientHeight = 2535
ClientLeft = 0
ClientTop = 0
ClientWidth = 4800
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ScaleHeight = 169
ScaleMode = 3 'Pixel
ScaleWidth = 320
Begin VB.PictureBox picSquare
Appearance = 0 'Flat
BorderStyle = 0 'None
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 180
Left = 4305
ScaleHeight = 180
ScaleWidth = 300
TabIndex = 3
Top = 2160
Width = 300
End
Begin MSComCtl2.FlatScrollBar ctlScrollV
Height = 1500
Left = 4200
TabIndex = 2
Top = 555
Width = 255
_ExtentX = 450
_ExtentY = 2646
_Version = 393216
Appearance = 0
Orientation = 1179648
End
Begin MSComCtl2.FlatScrollBar ctlScrollH
Height = 255
Left = 0
TabIndex = 1
Top = 2280
Width = 4275
_ExtentX = 7541
_ExtentY = 450
_Version = 393216
Appearance = 0
Arrows = 65536
Orientation = 1179649
End
Begin VB.PictureBox picContent
Appearance = 0 'Flat
BackColor = &H80000005&
BorderStyle = 0 'None
ForeColor = &H80000008&
Height = 1875
Left = 0
ScaleHeight = 125
ScaleMode = 3 'Pixel
ScaleWidth = 406
TabIndex = 0
Top = 0
Width = 6090
Begin VB.Image imgHand
Height = 480
Left = 2175
Picture = "ctlRuleEdit.ctx":0000
Top = 1335
Width = 480
Visible = 0 'False
End
Begin VB.Label lblText
AutoSize = -1 'True
BackColor = &H80000005&
Height = 195
Index = 0
Left = 45
TabIndex = 4
Top = 15
Width = 45
End
End
End
Attribute VB_Name = "ctlRuleEdit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
' variables
Private m_lngSelectedHotspot As Long
' constants
Private Const m_intRowSpacing = 3
' events
Public Event LinkClick(ByVal strLinkID As String, ByRef strValue As String, ByRef blnSetValue As Boolean)
Private Sub ctlScrollH_Change()
picContent.Left = -ctlScrollH.Value
End Sub
Private Sub ctlScrollV_Change()
picContent.Top = -ctlScrollV.Value
End Sub
Private Sub UserControl_Resize()
picContent.Move 0, 0
showScroll
End Sub
' handles a click on a text
Private Sub lblText_Click(Index As Integer)
Dim blnSetValue As Boolean, strValue As String
lblText_MouseMove Index, 0, 0, 0, 0
blnSetValue = False
strValue = lblText(Index).Caption
RaiseEvent LinkClick(lblText(Index).Tag, strValue, blnSetValue)
If blnSetValue = True Then
lblText(Index).Caption = FormatCaption(strValue)
lblText(Index).AutoSize = True
lblText(Index).Width = lblText(Index).Width + 2
lblText(Index).Height = lblText(Index).Height + 1
lblText(Index).Left = lblText(Index - 1).Left + lblText(Index - 1).Width
lblText(Index + 1).Left = lblText(Index).Left + lblText(Index).Width
showScroll
End If
End Sub
' hilights a hotspot
Private Sub lblText_MouseMove(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
With lblText(Index)
If .FontUnderline = False Then Exit Sub
If Index = m_lngSelectedHotspot Then Exit Sub
If m_lngSelectedHotspot >= 0 Then
lblText(m_lngSelectedHotspot).BackColor = vbWindowBackground
lblText(m_lngSelectedHotspot).ForeColor = vbButtonText
End If
.BackColor = vbHighlight
.ForeColor = vbWindowBackground
m_lngSelectedHotspot = Index
End With
End Sub
' sets the text (and hotspots) for this control. clicks are reported through
' the LinkClick event
Public Sub setText(strText As String)
' |link id*value|
Dim arrLines() As String, x As Long, y As Long
Dim lngTop As Long, lngLeft As Long
' clear selected hotspot
m_lngSelectedHotspot = -1
' unload previously set text
For x = lblText.Count - 1 To 1 Step -1
Unload lblText(x)
Next
lblText(0).Visible = False
' load new text
arrLines = Split(strText, vbTab)
y = 0
For x = LBound(arrLines) To UBound(arrLines)
lngLeft = lblText(0).Left
If y <> 0 Then
lngTop = lblText(y - 1).Top + lblText(y - 1).Height + m_intRowSpacing
Load lblText(y)
Else
lngTop = lblText(0).Top
End If
If InStr(1, arrLines(x), "|") > 0 Then
' line with expression
lblText(y).Move lngLeft, lngTop
lblText(y).Caption = Left(arrLines(x), InStr(1, arrLines(x), "|") - 1)
lblText(y).Visible = True
y = y + 1
Load lblText(y)
lblText(y).Move lblText(y - 1).Left + lblText(y - 1).Width, lngTop
lblText(y).Caption = FormatCaption(Mid(arrLines(x), InStr(1, arrLines(x), "*") + 1, InStrRev(arrLines(x), "|") - InStr(1, arrLines(x), "*") - 1))
lblText(y).Tag = Mid(arrLines(x), InStr(1, arrLines(x), "|") + 1, InStr(1, arrLines(x), "*") - InStr(1, arrLines(x), "|") - 1)
lblText(y).Alignment = vbCenter
lblText(y).FontUnderline = True
lblText(y).MousePointer = vbCustom
lblText(y).MouseIcon = imgHand.Picture
lblText(y).Height = lblText(y).Height + 1
lblText(y).Width = lblText(y).Width + 2
lblText(y).ZOrder 0
lblText(y).Visible = True
y = y + 1
Load lblText(y)
lblText(y).Move lblText(y - 1).Left + lblText(y - 1).Width, lngTop
lblText(y).Caption = Mid(arrLines(x), InStrRev(arrLines(x), "|") + 1)
lblText(y).Visible = True
Else
' simple line
lblText(y).Move lngLeft, lngTop
lblText(y).Caption = arrLines(x)
lblText(y).Visible = True
End If
y = y + 1
Next
showScroll
End Sub
' sizes scrollbars
Private Sub showScroll()
Dim blnShowH As Boolean, blnShowV As Boolean, x As Long
Dim lngMaxW As Long, lngMaxH As Long
lngMaxW = -1
lngMaxH = -1
For x = 0 To lblText.Count - 1
If lblText(x).Width + lblText(x).Left > lngMaxW Then lngMaxW = lblText(x).Width + lblText(x).Left
If lblText(x).Height + lblText(x).Top > lngMaxH Then lngMaxH = lblText(x).Height + lblText(x).Top
Next
picContent.Width = lngMaxW
picContent.Height = lngMaxH
If picContent.Width > UserControl.ScaleWidth Then blnShowH = True
If picContent.Height > UserControl.ScaleHeight Then blnShowV = True
If blnShowH = True And blnShowV = True Then
picSquare.Width = ctlScrollV.Width
picSquare.Height = ctlScrollH.Height
picSquare.Move UserControl.ScaleWidth - picSquare.Width, UserControl.ScaleHeight - picSquare.Height
End If
If blnShowH Then
If blnShowV Then
ctlScrollH.Move 0, UserControl.ScaleHeight - ctlScrollH.Height, UserControl.ScaleWidth - picSquare.Width, ctlScrollH.Height
Else
ctlScrollH.Move 0, UserControl.ScaleHeight - ctlScrollH.Height, UserControl.ScaleWidth, ctlScrollH.Height
End If
ctlScrollH.SmallChange = picContent.TextWidth("A")
ctlScrollH.LargeChange = ctlScrollH.SmallChange * 2
ctlScrollH.max = picContent.Width - UserControl.ScaleWidth + ctlScrollH.Height
ctlScrollH.Visible = True
Else
ctlScrollH.Visible = False
End If
If blnShowV Then
If blnShowH Then
ctlScrollV.Move UserControl.ScaleWidth - ctlScrollV.Width, 0, ctlScrollV.Width, UserControl.ScaleHeight - picSquare.Height
Else
ctlScrollV.Move UserControl.ScaleWidth - ctlScrollV.Width, 0, ctlScrollV.Width, UserControl.ScaleHeight
End If
ctlScrollV.SmallChange = lblText(0).Height + m_intRowSpacing
ctlScrollV.LargeChange = ctlScrollV.SmallChange * 2
ctlScrollV.max = picContent.Height - UserControl.ScaleHeight + ctlScrollV.Width
ctlScrollV.Visible = True
Else
ctlScrollV.Visible = False
End If
If blnShowH = True And blnShowV = True Then
picSquare.Visible = True
Else
picSquare.Visible = False
End If
End Sub
Private Function FormatCaption(strText As String) As String
If InStr(1, strText, vbCrLf) Then
FormatCaption = Left(strText, InStr(1, strText, vbCrLf) - 1) & "..."
Exit Function
End If
If Len(strText) > 40 Then
FormatCaption = Left(strText, 40) & "..."
Exit Function
End If
FormatCaption = strText
End Function