@@ -11,9 +11,9 @@ Public Enum CanvasRectFields
11
11
[_First] = 0
12
12
cvfRectLeft = 0
13
13
cvfRectTop
14
- cvfRectRight
15
- cvfRectBottom
16
- [_Last] = cvfRectBottom
14
+ cvfRectWidth
15
+ cvfRectHeight
16
+ [_Last] = cvfRectHeight
17
17
End Enum
18
18
19
19
Public Enum CanvasObjectStyles
@@ -204,22 +204,22 @@ Private Sub Class_Terminate()
204
204
End Sub
205
205
206
206
'Draw a rectangle
207
- '@param x1 - X Coord of top left corner
208
- '@param y1 - Y Coord of top left corner
209
- '@param x2 - X Coord of bottom right corner
210
- '@param y2 - Y Coord of bottom right corner
207
+ '@param left - X Coord of left edge
208
+ '@param top - Y Coord of top edge
209
+ '@param width - Width of rectangle
210
+ '@param height - Height of rectangle
211
211
'@returns - Pointer to a rectangle handle
212
- Public Function DrawRectangle (ByVal x1 As Long , ByVal y1 As Long , ByVal x2 As Long , ByVal y2 As Long , Optional ByVal fillColor As Long = 0 , Optional ByVal borderColor As Long = 0 , Optional ByVal borderWeight As Long = 1 ) As Long
212
+ Public Function DrawRectangle (ByVal left As Long , ByVal top As Long , ByVal width As Long , ByVal height As Long , Optional ByVal fillColor As Long = 0 , Optional ByVal borderColor As Long = 0 , Optional ByVal borderWeight As Long = 1 ) As Long
213
213
Dim index As Long : index = getNewObject()
214
214
With This.objects(index)
215
215
.ObjectType = cvtRectangle
216
216
ReDim .ObjectParams(CanvasRectFields.[_First] To CanvasRectFields.[_Last])
217
217
ReDim .ObjectStyle(CanvasObjectStyles.[_First] To CanvasObjectStyles.[_Last])
218
218
End With
219
- Data(index, CanvasRectFields.cvfRectLeft) = x1
220
- Data(index, CanvasRectFields.cvfRectTop) = y1
221
- Data(index, CanvasRectFields.cvfRectRight ) = x2
222
- Data(index, CanvasRectFields.cvfRectBottom ) = y2
219
+ Data(index, CanvasRectFields.cvfRectLeft) = left
220
+ Data(index, CanvasRectFields.cvfRectTop) = top
221
+ Data(index, CanvasRectFields.cvfRectWidth ) = width
222
+ Data(index, CanvasRectFields.cvfRectHeight ) = height
223
223
Style(index, cvsFillColor) = fillColor
224
224
Style(index, cvsLineColor) = borderColor
225
225
Style(index, cvsLineWidth) = borderWeight
@@ -238,12 +238,14 @@ Public Property Let Data(ByVal handle As Long, ByVal param As Long, ByVal RHS As
238
238
Select Case param
239
239
Case CanvasRectFields.cvfRectLeft
240
240
.bbox.Left = RHS
241
- Case CanvasRectFields.cvfRectRight
242
- .bbox.Right = RHS
241
+ .bbox.Right = RHS + .ObjectParams(CanvasRectFields.cvfRectWidth)
243
242
Case CanvasRectFields.cvfRectTop
244
243
.bbox.Top = RHS
245
- Case CanvasRectFields.cvfRectBottom
246
- .bbox.Bottom = RHS
244
+ .bbox.Bottom = RHS + .ObjectParams(CanvasRectFields.cvfRectHeight)
245
+ Case CanvasRectFields.cvfRectWidth
246
+ .bbox.Right = .ObjectParams(CanvasRectFields.cvfRectLeft) + RHS
247
+ Case CanvasRectFields.cvfRectHeight
248
+ .bbox.Bottom = .ObjectParams(CanvasRectFields.cvfRectTop) + RHS
247
249
End Select
248
250
End Select
249
251
End With
@@ -306,14 +308,14 @@ Public Sub Redraw()
306
308
If .ObjectStyle(CanvasObjectStyles.[_cvsFillVisible]) Then
307
309
Dim fillBrush As LongPtr
308
310
If GdipCreateSolidFill(.ObjectStyle(cvsFillColor), fillBrush) = 0 Then
309
- Call GdipFillRectangle (G, fillBrush, .ObjectParams(cvfRectLeft), .ObjectParams(cvfRectTop), .ObjectParams(cvfRectRight) - .ObjectParams(cvfRectLeft) , .ObjectParams(cvfRectBottom) - .ObjectParams(cvfRectTop ))
311
+ Call GdipFillRectangle (G, fillBrush, .ObjectParams(cvfRectLeft), .ObjectParams(cvfRectTop), .ObjectParams(cvfRectWidth) , .ObjectParams(cvfRectHeight ))
310
312
Call GdipDeleteBrush (fillBrush)
311
313
End If
312
314
End If
313
315
If .ObjectStyle(CanvasObjectStyles.[_cvsLineVisible]) Then
314
316
Dim strokePen As LongPtr
315
317
If GdipCreatePen1(.ObjectStyle(cvsLineColor), .ObjectStyle(cvsLineWidth), UnitPixel, strokePen) = 0 Then
316
- Call GdipDrawRectangle (G, strokePen, .ObjectParams(cvfRectLeft), .ObjectParams(cvfRectTop), .ObjectParams(cvfRectRight) - .ObjectParams(cvfRectLeft) , .ObjectParams(cvfRectBottom) - .ObjectParams(cvfRectTop ))
318
+ Call GdipDrawRectangle (G, strokePen, .ObjectParams(cvfRectLeft), .ObjectParams(cvfRectTop), .ObjectParams(cvfRectWidth) , .ObjectParams(cvfRectHeight ))
317
319
Call GdipDeletePen (strokePen)
318
320
End If
319
321
End If
@@ -350,14 +352,14 @@ Private Sub RedrawDirect()
350
352
If .ObjectStyle(CanvasObjectStyles.[_cvsFillVisible]) Then
351
353
Dim fillBrush As LongPtr
352
354
If GdipCreateSolidFill(.ObjectStyle(cvsFillColor), fillBrush) = 0 Then
353
- Call GdipFillRectangle (G, fillBrush, .ObjectParams(cvfRectLeft), .ObjectParams(cvfRectTop), .ObjectParams(cvfRectRight) - .ObjectParams(cvfRectLeft) , .ObjectParams(cvfRectBottom) - .ObjectParams(cvfRectTop ))
355
+ Call GdipFillRectangle (G, fillBrush, .ObjectParams(cvfRectLeft), .ObjectParams(cvfRectTop), .ObjectParams(cvfRectWidth) , .ObjectParams(cvfRectHeight ))
354
356
Call GdipDeleteBrush (fillBrush)
355
357
End If
356
358
End If
357
359
If .ObjectStyle(CanvasObjectStyles.[_cvsLineVisible]) Then
358
360
Dim strokePen As LongPtr
359
361
If GdipCreatePen1(.ObjectStyle(cvsLineColor), .ObjectStyle(cvsLineWidth), UnitPixel, strokePen) = 0 Then
360
- Call GdipDrawRectangle (G, strokePen, .ObjectParams(cvfRectLeft), .ObjectParams(cvfRectTop), .ObjectParams(cvfRectRight) - .ObjectParams(cvfRectLeft) , .ObjectParams(cvfRectBottom) - .ObjectParams(cvfRectTop ))
362
+ Call GdipDrawRectangle (G, strokePen, .ObjectParams(cvfRectLeft), .ObjectParams(cvfRectTop), .ObjectParams(cvfRectWidth) , .ObjectParams(cvfRectHeight ))
361
363
Call GdipDeletePen (strokePen)
362
364
End If
363
365
End If
0 commit comments