Menu

[r2]: / Class / cProperty.cls  Maximize  Restore  History

Download this file

235 lines (194 with data), 6.8 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
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "cProperty"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
'Flamebird MX
'Copyright (C) 2003-2007 Flamebird Team
'Contact:
' JaViS: javisarias@ gmail.com (JaViS)
' Danko: lord_danko@users.sourceforge.net (Darío Cutillas)
' Zubiaurre: izubiaurre@users.sourceforge.net (Imanol Zubiaurre)
'
'This program is free software; you can redistribute it and/or modify
'it under the terms of the GNU General Public License as published by
'the Free Software Foundation; either version 2 of the License, or
'(at your option) any later version.
'
'This program is distributed in the hope that it will be useful,
'but WITHOUT ANY WARRANTY; without even the implied warranty of
'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
'GNU General Public License for more details.
Option Explicit
Enum PropertyType
ptText = 1
ptInteger = 2
ptNumeric = 3
ptCombo = 4
ptLink = 5
End Enum
Private m_Name As String
Private m_Key As String
Private m_Type As PropertyType
Private m_CallBackFunction As String 'Función a la que se llama cuando se modifica una propiedad
Private m_CallingObject As Object 'Objeto donde se ejecuta la función callback
Private m_Value As Variant
Private m_Editable As Boolean
Private m_Description As String
'Las propiedades max y min son polivalentes,
'para ptText significa máximo y mínimo de caracteres
'mientras que para números significa valores límites
Private m_CanBeEmpty As Boolean
Private m_IsLimited As Boolean
Private m_Max As Integer
Private m_Min As Integer
Private m_colOptions As Collection
Public Property Let name(ByVal newName As String)
m_Name = newName
End Property
Public Property Get name() As String
name = m_Name
End Property
Public Property Let Key(ByVal newKey As String)
m_Key = newKey
End Property
Public Property Get Key() As String
Key = m_Key
End Property
Public Property Set CallingObject(newObject As Object)
Set m_CallingObject = newObject
End Property
Public Property Get CallingObject() As Object
Set CallingObject = m_CallingObject
End Property
Public Property Let TypeOfProp(ByVal newType As PropertyType)
m_Type = newType
Set m_colOptions = Nothing
If TypeOfProp = ptCombo Then
Set m_colOptions = New Collection
End If
m_Max = 0
m_Min = 0
m_IsLimited = False
End Property
Public Property Get TypeOfProp() As PropertyType
TypeOfProp = m_Type
End Property
Public Property Let CallBackFunction(newCallBackFunc As String)
m_CallBackFunction = newCallBackFunc
End Property
Public Property Get CallBackFunction() As String
CallBackFunction = m_CallBackFunction
End Property
Public Property Let Value(newValue As Variant)
'Comprobamos el tipo de propiedad
Select Case m_Type
Case ptInteger 'Entero
m_Value = newValue
Case ptNumeric 'Número cualquiera (admite decimales)
m_Value = newValue 'cambiamos la propiedad
Case ptCombo 'ComboBox
m_Value = CInt(newValue)
Case Else
m_Value = newValue
End Select
End Property
Public Property Get Value() As Variant
Attribute Value.VB_UserMemId = 0
Value = m_Value
End Property
Public Property Let Editable(newEditable As Boolean)
m_Editable = newEditable
End Property
Public Property Get Editable() As Boolean
Editable = m_Editable
End Property
Public Property Let description(newDesc As String)
m_Description = newDesc
End Property
Public Property Get description() As String
description = m_Description
End Property
Public Property Let IsLimited(newLimited As Boolean)
If Not m_Type = ptCombo Then m_IsLimited = newLimited
End Property
Public Property Get IsLimited() As Boolean
IsLimited = m_IsLimited
End Property
Public Property Let CanBeEmpty(newEmpty As Boolean)
If Not m_Type = ptCombo Then m_CanBeEmpty = newEmpty
End Property
Public Property Get CanBeEmpty() As Boolean
CanBeEmpty = m_CanBeEmpty
End Property
Public Function SetLimits(ValMax As Integer, ValMin As Integer)
m_IsLimited = True
If Not m_Type = ptCombo Then
m_Max = ValMax
m_Min = ValMin
End If
End Function
Public Property Let max(newMax As Integer)
If Not m_Type = ptCombo Then
m_Max = newMax
End If
End Property
Public Property Get max() As Integer
max = m_Max
End Property
Public Property Let min(newMin As Integer)
If Not m_Type = ptCombo Then
m_Min = newMin
End If
End Property
Public Property Get min() As Integer
min = m_Min
End Property
Public Function AddOption(OpName As String)
'Error si no es un combo
If m_Type <> ptCombo Then Err.Raise vbObjectError + 513, , "The property's type is not PTCOMBO": Exit Function
m_colOptions.Add OpName, OpName
'm_Max = m_colOptions.Count - 1 'Establece el máximo elemento
End Function
Public Property Get OptionItem(ByVal ItemIndex As Variant) As String
'Error si no es un combo
If m_Type <> ptCombo Then Err.Raise vbObjectError + 513, , "The property's type is not PTCOMBO": Exit Property
OptionItem = m_colOptions.item(ItemIndex + 1)
End Property
Public Property Get OptionCount() As Integer
'Error si no es un combo
If m_Type <> ptCombo Then Err.Raise vbObjectError + 513, , "The property's type is not PTCOMBO": Exit Property
OptionCount = m_colOptions.count
End Property
Public Sub OptionRemove(ByVal ItemIndex As Variant)
'Error si no es un combo
If m_Type <> ptCombo Then Err.Raise vbObjectError + 513, , "The property's type is not PTCOMBO": Exit Sub
m_colOptions.Remove ItemIndex
'm_Max = m_colOptions.Count - 1 'Establece el máximo elemento
End Sub
Public Function NewEnum() As IUnknown
Attribute NewEnum.VB_UserMemId = -4
Attribute NewEnum.VB_MemberFlags = "40"
'permite ser utilizado con For ...Each
Set NewEnum = m_colOptions.[_NewEnum]
End Function
Private Sub Class_Initialize()
m_Max = 0
m_Min = 0
m_IsLimited = False
m_CanBeEmpty = False
m_Description = "Description not available"
End Sub
Private Sub Class_Terminate()
Set m_colOptions = Nothing
End Sub