-
Notifications
You must be signed in to change notification settings - Fork 7
/
ListboxPRO.rbbas
executable file
·592 lines (555 loc) · 14 KB
/
ListboxPRO.rbbas
1
#tag ClassProtected Class ListboxPROInherits Listbox #tag Event Function CellBackgroundPaint(g As Graphics, row As Integer, column As Integer) As Boolean If AlternatingRows then SourceList = False If row <= LastIndex then If row mod 2 = 0 then g.ForeColor = RGB( 255, 255, 255 ) Else g.ForeColor = RGB( 237, 243, 254 ) End If Else g.ForeColor = RGB( 255, 255, 255 ) End If ElseIf SourceList then AlternatingRows = False If NOT self.Active or NOT Enabled then g.ForeColor = RGB( 237, 237, 237 ) ElseIf self.Active = True or Enabled then g.ForeColor = RGB( 222, 228, 234 ) End If End If g.FillRect 0, 0, g.Width, g.Height If SelectionGradient And Me.Selected( row ) then 'If NOT me.Selected(row) then Return False 'Dim Ratio, EndRatio as Double // Colors Dim StartColor, EndColor, TopColor, BorderTopColor, BorderBottomColor as Color If NOT Me.Active OR NOT me.Enabled then StartColor = RGBa( 73, 77, 87 ) EndColor = RGBa( 60, 66, 78 ) Else StartColor = RGBa( 45, 69, 89 ) EndColor = RGBa( 28, 51, 82 ) End If TopColor = RGBa( 100, 100, 100, .25 ) BorderTopColor = RGBa( 0, 0, 0, .05 ) BorderBottomColor = RGBa( 0, 0, 0, .10 ) g.DrawGradient( StartColor, EndColor, 0, 0, g.Width, g.Height ) 'For i as Integer = 0 to g.Height 'Ratio = ( ( g.Height - i ) / g.Height ) 'EndRatio = ( i / g.Height ) 'g.ForeColor = RGB( _ 'EndColor.Red * EndRatio + StartColor.Red * Ratio, _ 'EndColor.Green * EndRatio + StartColor.Green * Ratio, _ 'EndColor.Blue * EndRatio + StartColor.Blue * Ratio ) 'g.DrawLine 0, i, g.Width, i 'Next g.ForeColor = TopColor g.DrawLine 0, 1, g.Width, 1 g.ForeColor = BorderTopColor g.DrawLine 0, 0, g.Width, 0 g.ForeColor = BorderBottomColor g.DrawLine 0, g.Height -1, g.Width, g.Height -1 End If Dim b as Boolean = CellBackgroundPaint( g, row, column ) Return True End Function #tag EndEvent #tag Event Function CellTextPaint(g As Graphics, row As Integer, column As Integer, x as Integer, y as Integer) As Boolean If SelectionGradient then If g.TextSize = 0 Then g.TextSize = 13 If ListIndex = Row then If NOT Active or NOT Enabled then g.ForeColor = RGB( 114, 114, 114 ) Else g.ForeColor = RGB( 51, 84, 133 ) End If g.Bold = True 'g.DrawString Cell( Row, Column ), 4, DefaultRowHeight - ( DefaultRowHeight - g.TextSize ) \ 2 - 1, me.Width - 8, True If DefaultRowHeight >= ( 2 * g.TextSize ) Then g.DrawString Cell( row, column ), 4, g.TextAscent + 1 + ( DefaultRowHeight / 2 ) - ( g.StringHeight( Cell( row, column ), g.Width - 8 ) / 2 ), g.Width - 8, False Else g.DrawString Cell( Row, Column ), 4, DefaultRowHeight - ( DefaultRowHeight - g.TextSize ) \ 2 - 1, me.Width - 8, True End If g.ForeColor = RGB( 255, 255, 255 ) Else g.ForeColor = RGB( 0, 0, 0 ) End If 'g.DrawString Cell( Row, Column ), 4, DefaultRowHeight - ( DefaultRowHeight - g.TextSize ) \ 2 - 2, me.Width - 8, True If DefaultRowHeight >= ( 2 * g.TextSize ) Then g.DrawString Cell( row, column ), 4, g.TextAscent + ( DefaultRowHeight / 2 ) - ( g.StringHeight( Cell( row, column ), g.Width - 8 ) / 2 ), g.Width - 8, False Else g.DrawString Cell( Row, Column ), 4, DefaultRowHeight - ( DefaultRowHeight - g.TextSize ) \ 2 - 2, me.Width - 8, True End If If CellTextPaint( g, row, column, x, y ) Then Return True Else Return True End If End Function #tag EndEvent #tag Event Function KeyDown(Key As String) As Boolean // Let the listbox handle up/down arrows and tab keys If Keyboard.AsyncKeyDown(&h7D) Or Keyboard.AsyncKeyDown(&h7E) Or Keyboard.AsyncKeyDown(&h30) Then Return False If ( Ticks - LastKeyPressedAt <= 30 ) Then LastKeyPressed = LastKeyPressed + Key Else LastKeyPressed = Key LastKeyPressedAt = Ticks For i as Integer = 0 to ListCount - 1 If ( Lowercase( Left( List(i), Len( LastKeyPressed ) ) ) = Lowercase( LastKeyPressed ) ) Then ListIndex = i Exit End If Next If KeyDown(Key) then Return True Else Return False End Function #tag EndEvent #tag Hook, Flags = &h0 Event CellBackgroundPaint(g As Graphics, row As Integer, column As Integer) As Boolean #tag EndHook #tag Hook, Flags = &h0 Event CellTextPaint(g as Graphics, row As Integer, column As Integer, x as Integer, y as Integer) As Boolean #tag EndHook #tag Hook, Flags = &h0 Event KeyDown(Key As String) As Boolean #tag EndHook #tag Property, Flags = &h0 AlternatingRows As Boolean #tag EndProperty #tag Property, Flags = &h21 Private LastKeyPressed As String #tag EndProperty #tag Property, Flags = &h21 Private LastKeyPressedAt As Integer #tag EndProperty #tag Property, Flags = &h0 SelectionGradient As Boolean #tag EndProperty #tag Property, Flags = &h0 SourceList As Boolean #tag EndProperty #tag Property, Flags = &h0 TypeToSearch As Boolean = False #tag EndProperty #tag ViewBehavior #tag ViewProperty Name="AlternatingRows" Visible=true Group="List Style" InitialValue="True" Type="Boolean" #tag EndViewProperty #tag ViewProperty Name="AutoDeactivate" Visible=true Group="Appearance" InitialValue="True" Type="Boolean" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="AutoHideScrollbars" Visible=true Group="Behavior" InitialValue="True" Type="Boolean" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="Bold" Visible=true Group="Font" Type="Boolean" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="Border" Visible=true Group="Appearance" InitialValue="True" Type="Boolean" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="ColumnCount" Visible=true Group="Appearance" InitialValue="1" Type="Integer" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="ColumnsResizable" Visible=true Group="Behavior" Type="Boolean" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="ColumnWidths" Visible=true Group="Appearance" Type="String" EditorType="MultiLineEditor" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="DataField" Visible=true Group="Database Binding" Type="String" EditorType="DataField" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="DataSource" Visible=true Group="Database Binding" Type="String" EditorType="DataSource" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="DefaultRowHeight" Visible=true Group="Appearance" InitialValue="22" Type="Integer" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="Enabled" Visible=true Group="Appearance" InitialValue="True" Type="Boolean" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="EnableDrag" Visible=true Group="Behavior" Type="Boolean" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="EnableDragReorder" Visible=true Group="Behavior" Type="Boolean" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="GridLinesHorizontal" Visible=true Group="Appearance" InitialValue="0" Type="Integer" EditorType="Enum" InheritedFrom="Listbox" #tag EnumValues "0 - Default" "1 - None" "2 - ThinDotted" "3 - ThinSolid" "4 - ThickSolid" "5 - DoubleThinSolid" #tag EndEnumValues #tag EndViewProperty #tag ViewProperty Name="GridLinesVertical" Visible=true Group="Appearance" InitialValue="0" Type="Integer" EditorType="Enum" InheritedFrom="Listbox" #tag EnumValues "0 - Default" "1 - None" "2 - ThinDotted" "3 - ThinSolid" "4 - ThickSolid" "5 - DoubleThinSolid" #tag EndEnumValues #tag EndViewProperty #tag ViewProperty Name="HasHeading" Visible=true Group="Appearance" Type="Boolean" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="HeadingIndex" Visible=true Group="Appearance" InitialValue="-1" Type="Integer" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="Height" Visible=true Group="Position" InitialValue="100" Type="Integer" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="HelpTag" Visible=true Group="Appearance" Type="String" EditorType="MultiLineEditor" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="Hierarchical" Visible=true Group="Behavior" Type="Boolean" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="Index" Visible=true Group="ID" Type="Integer" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="InitialParent" Group="Initial State" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="InitialValue" Visible=true Group="Appearance" Type="String" EditorType="MultiLineEditor" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="Italic" Visible=true Group="Font" Type="Boolean" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="Left" Visible=true Group="Position" Type="Integer" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="LockBottom" Visible=true Group="Position" Type="Boolean" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="LockLeft" Visible=true Group="Position" Type="Boolean" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="LockRight" Visible=true Group="Position" Type="Boolean" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="LockTop" Visible=true Group="Position" Type="Boolean" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="Name" Visible=true Group="ID" Type="String" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="RequiresSelection" Visible=true Group="Behavior" Type="Boolean" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="ScrollbarHorizontal" Visible=true Group="Appearance" Type="Boolean" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="ScrollBarVertical" Visible=true Group="Appearance" InitialValue="True" Type="Boolean" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="SelectionGradient" Visible=true Group="List Style" InitialValue="True" Type="Boolean" #tag EndViewProperty #tag ViewProperty Name="SelectionType" Visible=true Group="Behavior" InitialValue="0" Type="Integer" EditorType="Enum" InheritedFrom="Listbox" #tag EnumValues "0 - Single" "1 - Multiple" #tag EndEnumValues #tag EndViewProperty #tag ViewProperty Name="SourceList" Visible=true Group="List Style" InitialValue="False" Type="Boolean" #tag EndViewProperty #tag ViewProperty Name="Super" Visible=true Group="ID" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="TabIndex" Visible=true Group="Position" InitialValue="0" Type="Integer" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="TabPanelIndex" Group="Position" InitialValue="0" Type="Integer" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="TabStop" Visible=true Group="Position" InitialValue="True" Type="Boolean" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="TextFont" Visible=true Group="Font" InitialValue="System" Type="String" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="TextSize" Visible=true Group="Font" InitialValue="13" Type="Single" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="TextUnit" Visible=true Group="Font" InitialValue="0" Type="FontUnits" EditorType="Enum" InheritedFrom="Listbox" #tag EnumValues "0 - Default" "1 - Pixel" "2 - Point" "3 - Inch" "4 - Millimeter" #tag EndEnumValues #tag EndViewProperty #tag ViewProperty Name="Top" Visible=true Group="Position" Type="Integer" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="TypeToSearch" Visible=true Group="Behavior" InitialValue="False" Type="Boolean" #tag EndViewProperty #tag ViewProperty Name="Underline" Visible=true Group="Font" Type="Boolean" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="UseFocusRing" Visible=true Group="Appearance" InitialValue="True" Type="Boolean" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="Visible" Visible=true Group="Appearance" InitialValue="True" Type="Boolean" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="Width" Visible=true Group="Position" InitialValue="100" Type="Integer" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="_ScrollOffset" Group="Appearance" InitialValue="0" Type="Integer" InheritedFrom="Listbox" #tag EndViewProperty #tag ViewProperty Name="_ScrollWidth" Group="Appearance" InitialValue="-1" Type="Integer" InheritedFrom="Listbox" #tag EndViewProperty #tag EndViewBehaviorEnd Class#tag EndClass