home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 6_2008-2009.ISO / data / zips / MenuBar_co2132961122008.psc / Classes / clsArrow.cls next >
Text File  |  2008-01-20  |  5KB  |  201 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "clsArrow"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = False
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. Option Explicit
  15.  
  16. ' Private Variables
  17. Private m_ArrowUp       As Boolean
  18. Private m_IsDisplayed   As Boolean
  19. Private m_GradientType  As GradientButtonTypes
  20. Private BorderState     As Long
  21. Private m_BackColor     As Long
  22. Private m_Border        As Long
  23. Private m_ButtonHeight  As Long
  24. Private m_ForeColor     As Long
  25. Private m_GradientColor As Long
  26. Private picParent       As PictureBox
  27. Private ImageRectangle  As Rect
  28.  
  29. Public Property Let ArrowUp(ByVal NewArrowUp As Boolean)
  30.  
  31.    m_ArrowUp = NewArrowUp
  32.  
  33. End Property
  34.  
  35. Public Property Let BackColor(ByVal NewBackColor As Long)
  36.  
  37.    m_BackColor = NewBackColor
  38.  
  39. End Property
  40.  
  41. Public Property Let Border(ByVal NewBorder As Long)
  42.  
  43.    m_Border = NewBorder
  44.  
  45. End Property
  46.  
  47. Public Property Let ButtonHeight(ByVal NewButtonHeight As Long)
  48.  
  49.    m_ButtonHeight = NewButtonHeight
  50.  
  51. End Property
  52.  
  53. Public Property Let ForeColor(ByVal NewForeColor As Long)
  54.  
  55.    m_ForeColor = NewForeColor
  56.  
  57. End Property
  58.  
  59. Public Property Let GradientColor(ByVal NewGradientColor As Long)
  60.  
  61.    m_GradientColor = NewGradientColor
  62.  
  63. End Property
  64.  
  65. Public Property Let GradientType(ByVal NewGradientType As GradientButtonTypes)
  66.  
  67.    m_GradientType = NewGradientType
  68.  
  69. End Property
  70.  
  71. Public Property Set Parent(ByVal NewParent As PictureBox)
  72.  
  73.    Set picParent = NewParent
  74.  
  75. End Property
  76.  
  77. Public Function HitTest(ByVal MousePosition As Long, ByVal X As Long, ByVal Y As Long) As Boolean
  78.  
  79.    If m_IsDisplayed Then
  80.       If PtInRect(ImageRectangle, X, Y) Then
  81.          HitTest = True
  82.          
  83.          If MousePosition = MOUSE_UP Then
  84.             If BorderState = SUNKEN Then Call DrawBorder(RAISED)
  85.             
  86.          ElseIf MousePosition = MOUSE_DOWN Then
  87.             If BorderState = RAISED Then Call DrawBorder(SUNKEN)
  88.          End If
  89.          
  90.       ElseIf MousePosition = MOUSE_DOWN Then
  91.          If BorderState = SUNKEN Then Call DrawBorder(RAISED)
  92.          
  93.       ' MOUSE_CHECK or MOUSE_MOVE
  94.       ElseIf BorderState = SUNKEN Then
  95.          Call DrawBorder(RAISED)
  96.       End If
  97.    End If
  98.  
  99. End Function
  100.  
  101. Public Sub Hide()
  102.  
  103.    If m_IsDisplayed Then
  104.       With ImageRectangle
  105.          picParent.Line (.Left, .Top)-(.Right, .Bottom), picParent.BackColor, BF
  106.       End With
  107.       
  108.       m_IsDisplayed = False
  109.    End If
  110.  
  111. End Sub
  112.  
  113. Public Sub Show(ByVal Alignment As AlignmentConstants, Optional ByVal MenusAtTop As Long, Optional ByVal MenusAtBottom As Long)
  114.  
  115.    If Not picParent Is Nothing Then
  116.       If Not picParent.Visible Then Exit Sub
  117.       
  118.       With ImageRectangle
  119.          If m_ArrowUp Then
  120.             .Top = MENU_SPACE + MenusAtTop * m_ButtonHeight
  121.             
  122.          Else
  123.             .Top = picParent.ScaleHeight - ARROW_BUTTON_SIZE - MENU_SPACE - MenusAtBottom * m_ButtonHeight
  124.          End If
  125.          
  126.          If Alignment = vbRightJustify Then
  127.             .Left = MENU_SPACE
  128.             
  129.          Else
  130.             .Left = picParent.ScaleWidth - MENU_SPACE - ARROW_BUTTON_SIZE
  131.          End If
  132.          
  133.          .Right = .Left + ARROW_BUTTON_SIZE
  134.          .Bottom = .Top + ARROW_BUTTON_SIZE
  135.          
  136.          If .Left Then
  137.             m_IsDisplayed = True
  138.             
  139.             Call DrawBorder(RAISED)
  140.          End If
  141.       End With
  142.    End If
  143.  
  144. End Sub
  145.  
  146. Private Sub DrawBorder(ByVal Edge As Long)
  147.  
  148. Dim lngEdge  As Long
  149. Dim intSize  As Integer
  150. Dim lngLines As Long
  151.  
  152.    If m_IsDisplayed Then
  153.       With ImageRectangle
  154.          If m_GradientType Then
  155.             Call DrawGradient(ImageRectangle, picParent, m_GradientType, m_GradientColor, m_BackColor)
  156.             
  157.          Else
  158.             picParent.Line (.Left, .Top)-(.Right - 2, .Bottom - 2), m_BackColor, BF
  159.          End If
  160.          
  161.          If Edge = RAISED Then
  162.             If m_Border = BDR_RAISED Then
  163.                lngEdge = BDR_RAISED
  164.                
  165.             Else
  166.                lngEdge = BDR_RAISEDOUTER
  167.             End If
  168.             
  169.             DrawEdge picParent.hDC, ImageRectangle, lngEdge, BF_RECT
  170.             BorderState = RAISED
  171.             
  172.          ' SUNKEN
  173.          Else
  174.             If m_Border = BDR_RAISED Then
  175.                lngEdge = BDR_SUNKEN
  176.                
  177.             Else
  178.                lngEdge = BDR_SUNKENOUTER
  179.             End If
  180.             
  181.             DrawEdge picParent.hDC, ImageRectangle, lngEdge, BF_RECT
  182.             BorderState = SUNKEN
  183.          End If
  184.          
  185.          intSize = 3 - 3 * Abs(m_ArrowUp)
  186.          
  187.          For lngLines = .Top + 8 To .Top + 11
  188.             picParent.Line (.Left - intSize + 9, lngLines)-(.Left + intSize + 11, lngLines), m_ForeColor
  189.             intSize = intSize + Abs(m_ArrowUp) - Abs(Not m_ArrowUp)
  190.          Next 'lnglines
  191.       End With
  192.    End If
  193.  
  194. End Sub
  195.  
  196. Private Sub Class_Terminate()
  197.  
  198.    Set picParent = Nothing
  199.  
  200. End Sub
  201.