-
Notifications
You must be signed in to change notification settings - Fork 0
/
cwSun.cls
433 lines (322 loc) · 12.6 KB
/
cwSun.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
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
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "cwPlanet"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'---------------------------------------------------------------------------------------
' Module : cwplanet
' Author : beededea
' Date : 28/05/2023
' Purpose :
'---------------------------------------------------------------------------------------
Option Explicit
Private ringxo As Integer
Private ringyo As Integer
Private surroundxo As Integer
Private surroundyo As Integer
Private planetxo As Integer
Private planetyo As Integer
Private WithEvents W As cWidgetBase
Attribute W.VB_VarHelpID = -1
Private mZoom As Double
Private mZoomDirection As String
Private mLocked As Boolean
Private mHidden As Boolean
Private mOpacity As Double
' property mZoom
' property mZoomDirection
' property mLocked
' property mHidden
' property mOpacity
'---------------------------------------------------------------------------------------
' Procedure : Class_Initialize
' Author :
' Date : 03/05/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Private Sub Class_Initialize()
On Error GoTo Class_Initialize_Error
Call initialiseVars
mZoom = 0
planetxo = 15: planetyo = 27
Set W = Cairo.WidgetBase '<- this is required in each cwImplementation...
W.BorderColor = &H444444
W.ImplementsWheelMessages = True ' enables gblPlivate Sub W_MouseWheel
mZoom = 0.1 ' the planet size initially very small
ZoomDirection = mZoomDirection
On Error GoTo 0
Exit Sub
Class_Initialize_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Class_Initialize of Class Module cwplanet"
End Sub
'---------------------------------------------------------------------------------------
' Procedure : initialiseVars
' Author : beededea
' Date : 07/05/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Private Sub initialiseVars() ' set all vars to zero
On Error GoTo initialiseVars_Error
planetxo = 0: planetyo = 0
On Error GoTo 0
Exit Sub
initialiseVars_Error:
With Err
If .Number <> 0 Then
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure initialiseVars of Class Module cwplanet"
Resume Next
End If
End With
End Sub
Public Property Get Widget() As cWidgetBase: Set Widget = W: End Property
Public Property Get Widgets() As cWidgets: Set Widgets = W.Widgets: End Property ' does this really need to be exposed?
'---------------------------------------------------------------------------------------
' Procedure : Zoom
' Author : beededea
' Date : 17/05/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Public Property Get Zoom() As Double
On Error GoTo ZoomGet_Error
Zoom = mZoom
On Error GoTo 0
Exit Property
ZoomGet_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Zoom of Class Module cwplanet"
End Property
'---------------------------------------------------------------------------------------
' Procedure : Zoom
' Author : beededea
' Date : 17/05/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Public Property Let Zoom(ByVal newValue As Double)
On Error GoTo ZoomLet_Error
If mZoom <> newValue Then mZoom = newValue Else Exit Property
If mZoom > 1.2 Then mZoom = 1.2 Else If mZoom < 0.05 Then mZoom = 0.05
W.Refresh
On Error GoTo 0
Exit Property
ZoomLet_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Zoom of Class Module cwplanet"
End Property
'---------------------------------------------------------------------------------------
' Procedure : ZoomDirection
' Author : beededea
' Date : 17/05/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Public Property Get ZoomDirection() As String
On Error GoTo ZoomDirectionGet_Error
ZoomDirection = mZoomDirection
On Error GoTo 0
Exit Property
ZoomDirectionGet_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure ZoomDirection of Class Module cwplanet"
End Property
'---------------------------------------------------------------------------------------
' Procedure : ZoomDirection
' Author : beededea
' Date : 17/05/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Public Property Let ZoomDirection(ByVal newValue As String)
On Error GoTo ZoomDirectionLet_Error
If mZoomDirection <> newValue Then mZoomDirection = newValue Else Exit Property
W.Refresh
On Error GoTo 0
Exit Property
ZoomDirectionLet_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure ZoomDirection of Class Module cwplanet"
End Property
'---------------------------------------------------------------------------------------
' Procedure : opacity
' Author : beededea
' Date : 17/05/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Public Property Let opacity(ByVal newValue As Double)
On Error GoTo opacityLet_Error
If mOpacity <> newValue Then mOpacity = newValue Else Exit Property
On Error GoTo 0
Exit Property
opacityLet_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure opacity of Class Module cwplanet"
End Property
'---------------------------------------------------------------------------------------
' Procedure : opacity
' Author : beededea
' Date : 17/05/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Public Property Get opacity() As Double
On Error GoTo opacityGet_Error
opacity = mOpacity
On Error GoTo 0
Exit Property
opacityGet_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure opacity of Class Module cwplanet"
End Property
'---------------------------------------------------------------------------------------
' Procedure : Locked
' Author : beededea
' Date : 17/05/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Public Property Get Locked() As Boolean
On Error GoTo LockedGet_Error
Locked = mLocked
On Error GoTo 0
Exit Property
LockedGet_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Locked of Class Module cwplanet"
End Property
'---------------------------------------------------------------------------------------
' Procedure : Locked
' Author : beededea
' Date : 17/05/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Public Property Let Locked(ByVal newValue As Boolean)
On Error GoTo LockedLet_Error
If mLocked <> newValue Then mLocked = newValue Else Exit Property
On Error GoTo 0
Exit Property
LockedLet_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Locked of Class Module cwplanet"
End Property
'---------------------------------------------------------------------------------------
' Procedure : Hidden
' Author : beededea
' Date : 17/05/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Public Property Get Hidden() As Boolean
On Error GoTo HiddenGet_Error
Hidden = mHidden
On Error GoTo 0
Exit Property
HiddenGet_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Hidden of Class Module cwplanet"
End Property
'---------------------------------------------------------------------------------------
' Procedure : Hidden
' Author : beededea
' Date : 10/05/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Public Property Let Hidden(ByVal newValue As Boolean)
On Error GoTo HiddenLet_Error
If mHidden <> newValue Then mHidden = newValue Else Exit Property
If mHidden = True Then
opacity = 0
W.Refresh
Else
opacity = Val(gblPlOpacity) / 100
W.Refresh
End If
On Error GoTo 0
Exit Property
HiddenLet_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Hidden of Class Module cwplanet"
End Property
'---------------------------------------------------------------------------------------
' Procedure : W_MouseWheel
' Author : beededea
' Date : 09/05/2023
' Purpose : uses ScaleDrawings mZoom, mZoom
'---------------------------------------------------------------------------------------
'
Private Sub W_MouseWheel(ByVal MouseKeys As Long, ByVal Rotation As Long, ByVal LineOffset As Long, ByVal xAbs As Single, ByVal yAbs As Single)
On Error GoTo W_MouseWheel_Error
If gblPlIgnoreMouse = "1" Then Exit Sub
Select Case MouseKeys
Case 8 ' ctrl key pressed
If ZoomDirection = "up" Then
Zoom = Zoom - 0.02 * LineOffset
Else
Zoom = Zoom + 0.02 * LineOffset
End If
gblPlGaugeSize = LTrim$(Str$(planetWidget.Zoom * 100)) ' store the value dynamically
sPutINISetting softwarePlanet, "gaugeSize", gblPlGaugeSize, gblPlSettingsFile
If planetPrefs.IsVisible = True Then planetPrefs.sliGaugeSize = Val(gblPlGaugeSize)
End Select
On Error GoTo 0
Exit Sub
W_MouseWheel_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure W_MouseWheel of Class Module cwplanet"
End Sub
'---------------------------------------------------------------------------------------
' Procedure : W_MouseDown
' Author :
' Date : 09/05/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Private Sub W_MouseDown(Button As Integer, Shift As Integer, ByVal X As Single, ByVal Y As Single)
On Error GoTo W_MouseDown_Error
If Button = vbRightButton Then
Call menuForm.PopupMenu(menuForm.mnuMainMenu)
Else
If gblPlIgnoreMouse = "1" Then Exit Sub
' do whatever you want with a mouseDown here, not doing anything at the moment but we will...
End If
On Error GoTo 0
Exit Sub
W_MouseDown_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure W_MouseDown of Class Module cwplanet"
End Sub
'---------------------------------------------------------------------------------------
' Procedure : W_Paint
' Author : beededea
' Date : 20/06/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Private Sub W_Paint(CC As vbRichClient5.cCairoContext, ByVal xAbs As Single, ByVal yAbs As Single, ByVal dx_Aligned As Single, ByVal dy_Aligned As Single, UserObj As Object)
On Error GoTo W_Paint_Error
Draw CC, dx_Aligned, dy_Aligned, mOpacity
On Error GoTo 0
Exit Sub
W_Paint_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure W_Paint of Class Module cwplanet"
End Sub
'---------------------------------------------------------------------------------------
' Procedure : Draw
' Author :
' Date : 03/05/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Public Sub Draw(ByVal CC As cCairoContext, ByVal dx_Aligned As Single, ByVal dy_Aligned As Single, ByVal mOpacity As Double)
On Error GoTo Draw_Error
CC.TranslateDrawings 0, 0 ' dx / 2, dy / 2
CC.ScaleDrawings mZoom, mZoom
CC.Save
CC.RenderSurfaceContent "planet", planetxo, planetyo, 570, 570, , mOpacity
CC.Restore
On Error GoTo 0
Exit Sub
Draw_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Draw of Class Module cwplanet"
End Sub