webobject.lss

' 妈的烂货!!!!!!!!!!!!!
'
' 模拟的程度不高,使用时请完全参照本sdk及配套文档。
' 失败的原因有三个:
' 1、大萝卜能力不足
' 2、Notes本身太烂,最愤怒的是多态!不支持event!或者是PropertyChanged!不支持类型转换
' 3、时间仓促。因为这个本来是为自定义表单功能服务的,做的时候发现缺少了这一块,只能用十个小时以内的时间来完成。

' 另外,这里的标准,最根本标准,是xhtml的,对于html中与前者冲突的,消除。
'  css部分留待以后继续补进,但是要求是css1、和css2标准

'
' 附注: 这次做这些,仅仅是为了支持一个web打印效果,所以很多的仅仅是部署了property in的方式。
'   不要说函数对象模型不健全,在当前的应用环境中,它已经很健全了。而且时间就那么一点点。

Public Class WebObject
 
End Class

Public Class WebComponent As WebObject
 Private m_Attributes List As String
 Private m_TagName As String
 Private m_Style As WebStyle
 
 Public Sub new
  MyInit
  Web_Child_Init
 End Sub
 
 Private Function MyInit As Long
  
 End Function
 Private Function Web_Child_Init As Long
 End Function 
 
 Public Function GetAttribute(strAttName As String ) As String
  GetAttribute=m_Attributes(strAttName)
 End Function
 Public Function SetAttribute(strAttName As String , strAttValue ) As Long
  m_Attributes(strAttName)=Cstr(strAttValue)
 End Function
 Public Function DelAttribute(strAttName As String) As Long
  Erase m_Attributes(strAttName)
 End Function
 
 Public Function ApplyStyle(objStyle As WebStyle) As Long
  Set m_Style=objStyle
 End Function
 
 Private Property Get AttributeString As String
  Dim str1 As String
  If Not m_Style Is Nothing Then
   str1=str1+" style=""" + m_Style.Style+""""
  End If
  Forall s1 In m_Attributes
   str1=str1+" " + Listtag(s1) +"="""+s1+""""
  End Forall
  AttributeString=str1
 End Property
 
 Public Property Get outerHTML As String
  outerHTML="<"+m_TagName+" "+Me.AttributeString+">"+Me.innerHTML+"</"+m_TagName+">"
 End Property
 Public Function toString() As String
  toString=Me.outerHTML
 End Function
 
 Public Property Get innerHTML As String
 End Property 
 
 Private Property Set TagName As String
  m_TagName=TagName
 End Property
 
 ' html4.0 普适属性
 Public Property Set ID As String
  Me.SetAttribute "ID" , ID
 End Property
 Public Property Set theName() As String
  Me.SetAttribute "Name" , theName
 End Property
 Public Property Set theWidth
  Me.SetAttribute "Width" , Cstr(theWidth)
 End Property
 Public Property Set Height
  Me.SetAttribute "Height" , Cstr(Height)
 End Property
 Public Property Set Size
  Me.SetAttribute "Size" , Cstr(Size)
 End Property
 Public Property Set AccessKey As String
  Me.SetAttribute "AccessKey" , AccessKey
 End Property
 Public Property Set TabIndex
  Me.SetAttribute "TabIndex" , Cstr(TabIndex)
 End Property
 Public Property Set theClass As String
  Me.SetAttribute "Class" , theClass
 End Property
 Public Property Set Align As String
  Me.SetAttribute "Align" , Align
 End Property
 Public Property Set ReadOnly As Boolean
  Me.SetAttribute "ReadOnly" , "True"
  If Not ReadOnly Then Me.DelAttribute "ReadOnly"
 End Property
 Public Property Set Disabled As Boolean
  Me.SetAttribute "Disabled" , "true"
  If Not Disabled Then Me.DelAttribute "Disabled"
 End Property
End Class

Public Class WebComponentEx As WebComponent
 Private m_Children As MyCollection
 Private m_InnerHTML As String
 Private m_InnerText As String
 
 Public Function AddChild(objChild , iIndex As Integer ) As Long
  If m_Children Is Nothing Then Set m_Children=New MyCollection
  m_Children.AddMember objChild , iIndex
 End Function
 
 Public Property Set innerText As String
  m_InnerText=innerText
 End Property
 Public Property Set innerHTML As String
  m_innerHTML=innerHTML
 End Property
 
 Public Property Get innerHTML As String
  Dim str1 As String , i As Integer
  If Not m_Children Is Nothing Then
   For i=1 To m_Children.Count
    str1=str1+m_Children.Member(i).outerHTML
   Next
  Elseif m_InnerHTML <> "" Then
   str1=m_InnerHTML
  Else
   str1=m_InnerText
  End If
  innerHTML=str1
 End Property 
End Class

Public Class WebPlanerText As WebObject
 Private m_Text As String
 
 Public Property Set innerText As String
  m_Text=innerText
 End Property
 Public Property Get outerHTML As String
  outerHTML=m_Text
 End Property 
End Class

Public Class WebStyle
 Private m_Styles List As String
 
 Public Function GetStyle(strAttName As String ) As String
  GetStyle=m_Styles(strAttName)
 End Function
 Public Function SetStyle(strAttName As String , strAttValue ) As Long
  m_Styles(strAttName)=Cstr(strAttValue)
 End Function
 Public Function DelStyle(strAttName As String) As Long
  Erase m_Styles(strAttName)
 End Function
 
 Public Property Get Style As String
  Dim str1 As String
  Forall v1 In m_Styles
   str1=str1+" " + Listtag(v1)+":"+Cstr(v1)+";"
  End Forall
  Style=str1
 End Property 
 
 ' 下面部分将实现css1和css2中的部分标准内容, 这可是一个浪费时间的体力活
 
End Class

Public Class WebTable As WebComponent
 Private m_Rows As MyCollection
 
 Private Function Web_Child_Init As Long
  Me.TagName="TABLE"
  Set m_Rows=New MyCollection
  WebTable_Child_Init
 End Function
 Private Function WebTable_Child_Init As Long
 End Function
 
 Private Property Get innerHTML As String
  Dim str1 As String , i As Integer
  For i=1 To m_Rows.Count
   str1=str1 + m_Rows.Member(i).outerHTML
  Next
  innerHTML=str1
 End Property
 
 Public Function InsertRow(objRow As WebRow , iIndex As Integer ) As Long
  m_Rows.AddMember objRow , iIndex
 End Function
 
 Public Function AppendChild(objRow As WebRow) As Long
  Me.InsertRow objRow , 0
 End Function
 
End Class

Public Class WebRow As WebComponent
 Private m_Cells As MyCollection
 
 Private Function Web_Child_Init As Long
  Me.TagName="TR"
  Set m_Cells=New MyCollection
 End Function
 
 Private Property Get innerHTML As String
  Dim str1 As String , i As Integer
  For i=1 To m_Cells.Count
   str1=str1+ m_Cells.Member(i).outerHTML
  Next
  innerHTML=str1
 End Property
 
 Public Function InsertCell(objCell As WebCell , iIndex As Integer ) As Long
  m_Cells.AddMember objCell , iIndex
 End Function
 
 Public Function AppendChild(objCell As WebCell) As Long
  Me.InsertCell objCell , 0
 End Function
 
End Class

Public Class WebCell As WebComponentEx
 Private Function Web_Child_Init As Long
  Me.TagName="TD"
 End Function
End Class

Public Class WebTextarea As WebComponent
 Private m_Value As String
 
 Private Function Web_Child_Init As Long
  Me.TagName="TEXTAREA"
  
 End Function
 
 Public Property Set Rows
  Me.SetAttribute "Rows" , Cstr(Rows)
 End Property
 Public Property Set Cols
  Me.SetAttribute "Cols" , Cstr(Cols)
 End Property 
 Public Property Set Value As String
  m_Value=Value
 End Property
 Private Property Get innerHTML As String
  innerHTML=m_Value
 End Property
End Class

Public Class WebField As WebComponent
 Private Function Web_Child_Init As Long
  Me.TagName="INPUT"
  WebField_Child_Init
 End Function
 
 Private Function WebField_Child_Init As Long
 End Function
 
 Public Property Set Value As String
  Me.SetAttribute "value" , Value
 End Property
 Public Property Get Value As String
  Value=Me.GetAttribute("value")
 End Property
 
End Class

Public Class WebFieldPassword As WebField
 Private Function WebField_Child_Init As Long
  Me.SetAttribute "TYPE" , "password"
 End Function
End Class
Public Class WebPassword As WebFieldPassword
End Class

Public Class WebFieldButton As WebField
 Private Function WebField_Child_Init As Long
  Me.SetAttribute "TYPE" , "BUTTON"
 End Function
End Class
Public Class WebButton As WebFieldButton
End Class

Public Class WebFieldRadio As WebField
 Private m_Text As String
 
 Private Function WebField_Child_Init As Long
  Me.SetAttribute "TYPE" , "RADIO"
 End Function
 
 Public Property Set Checked As Boolean
  Me.SetAttribute "Checked" , "True"
  If Not Checked Then Me.DelAttribute "Checked"
 End Property
 
 Public Property Set Text As String
  m_Text=Text
 End Property
 
 Private Property Get innerHTML As String
  innerHTML=m_Text
 End Property
End Class
Public Class WebRadio As WebFieldRadio
End Class

Public Class WebFieldCheckbox As WebField
 Private m_Text As String
 
 Private Function WebField_Child_Init As Long
  Me.SetAttribute "TYPE" , "CHECKBOX"
 End Function
 
 Public Property Set Checked As Boolean
  Me.SetAttribute "Checked" , "True"
  If Not Checked Then Me.DelAttribute "Checked"
 End Property
 
 Public Property Set Text As String
  m_Text=Text
 End Property
 
 Private Property Get innerHTML As String
  innerHTML=m_Text
 End Property
End Class
Public Class WebCheckbox As WebFieldCheckbox
End Class

Public Class WebFieldFile As WebField
 Private Function WebField_Child_Init As Long
  Me.SetAttribute "TYPE" , "FILE"
 End Function
End Class
Public Class WebFile As WebFieldFile
End Class

Public Class WebFieldImage As WebField
 Private Function WebField_Child_Init As Long
  Me.SetAttribute "TYPE" , "Image"
 End Function
 
 Public Property Set Src As String
  Me.SetAttribute "SRC" , Src
 End Property
End Class
Public Class WebImage As WebFieldImage
End Class

Public Class WebFieldText As WebField
 Private Function WebField_Child_Init As Long
  Me.SetAttribute "TYPE" , "TEXT"
 End Function
End Class
Public Class WebText As WebFieldText
End Class

Public Class WebSelect As WebComponent
 Private m_Options As MyCollection
 
 Private Function Web_Child_Init As Long
  Me.TagName="SELECT"
  Set m_Options=New MyCollection
 End Function
 
 Public Function AddOption(objOption As WebOption , iIndex As Integer ) As Long
  m_Options.AddMember objOption , iIndex
 End Function
 
 Public Property Set SelectedIndex As Integer
  Dim objOption As WebOption
  Set objOption=m_Options.Member(SelectedIndex)
  If objOption Is Nothing Then Exit Property
  objOption.Selected=True
 End Property
 
 Public Property Set Multiple As Boolean
  Me.SetAttribute "Multiple" , "True"
  If Not Multiple Then Me.DelAttribute "Multiple"
 End Property
 
 Private Property Get innerHTML As String
  Dim i As Integer , str1 As String
  For i=1 To m_Options.Count
   str1=str1+m_Options.Member(i).outerHTML + Chr(13) + Chr(10)
  Next
  innerHTML=str1
 End Property
 
End Class

Public Class WebOption As WebComponent
 Private m_Text As String
 
 Private Function Web_Child_Init As Long
  Me.TagName="OPTION"
 End Function
 
 Private Property Get innerHTML As String
  innerHTML=m_Text
 End Property
 
 Public Property Set Text As String
  m_Text=Text
 End Property
 Public Property Set Value As String
  Me.SetAttribute "Value" , Value
 End Property
 Public Property Set Selected As Boolean
  Me.SetAttribute "Selected" , "true"
  If Not Selected Then Me.DelAttribute "Selected"
 End Property
 
End Class

Public Class WebDiv As WebComponentEx
 Private Function Web_Child_Init As Long
  Me.TagName="DIV"
 End Function
End Class

Public Class WebSpan As WebComponentEx
 Private Function Web_Child_Init As Long
  Me.TagName="SPAN"
 End Function
End Class


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值