home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / axtree / axtree.bas < prev    next >
Encoding:
BASIC Source File  |  1998-12-28  |  42.6 KB  |  1,119 lines

  1. Attribute VB_Name = "otlcb95bas"
  2. Option Explicit
  3. Option Base 1
  4.  
  5. 'OTL variables
  6. Public Type OtlSetup 'one per outline
  7.     Levels As Integer
  8.     VariableNames(5) As String 'Max 5 levels
  9.     BmpField As String 'field holding bitmap to use for leafs if not use default
  10.     CheckmarkField As String 'field to examine to determine if record is selected
  11.     BmpFlag As Integer
  12.     LineFlag As Integer
  13.     PlusFlag As Integer
  14.     CheckmarkFlag As Integer
  15.     AutoCheckParents As Integer
  16.     DisplayLines As Integer
  17.     DisplayIdx(100) As Integer 'Max 100 lines visible
  18.     DisplayCount As Integer 'virtual Ubound of displayidx
  19.     VisibleItems As Integer
  20.     VisChangeFlag As Integer
  21.     LineHeight As Integer 'Twips
  22.     ColWidth As Integer 'twips
  23.     ElementClicked As Integer
  24.     SelectColor As Long 'RGB
  25.     SelectTextColor As Long
  26.     FontName As String
  27.     FontColor As Long
  28.     Fontsize As Single
  29.     TopIdx As Integer
  30.     SelectIdx As Integer
  31.     CurrentLine As Integer
  32.     LastLine As Integer
  33.     PrevTop As Integer
  34.     PrevSel As Integer
  35.     LastType As Integer     ' 0=None, 1=Parent, 2=Collapse, 3=Expand, 4=Child, Last clicked or keypress
  36. End Type
  37.  
  38. Public Type OtlData  'Use in array
  39.     Caption As String
  40.     Level As Integer
  41.     Visible As Integer
  42.     Expanded As Integer
  43.     VisibleIdx As Long
  44.     Bookmark As String
  45.     Bitmap As Picture 'if not use default
  46.     Selected As Integer '0-none, 1-all, 2-some
  47.     SyncIdx As Integer 'Optional, sync to another array
  48.     Itemdata As Long
  49.     IsParent As Boolean 'is this a parent
  50. End Type
  51.  
  52. 'standard images
  53. Global gBranchOpenPic As Control
  54. Global gBranchClosedPic As Control
  55. Global gLeafPic As Control
  56. Global gCustomPic As Control
  57. Global gPlusPic As Control
  58. Global gMinusPic As Control
  59. 'checked images
  60. Global gBranchOpenAllPic As Control 'checked
  61. Global gBranchClosedAllPic As Control
  62. Global gBranchOpenSomePic As Control
  63. Global gBranchClosedSomePic As Control
  64. Global gLeafCheckedPic As Control
  65. Dim ChangingScroll As Integer
  66.  
  67. 'KeyCodes Constants
  68. Const KEY_PRIOR = &H21
  69. Const KEY_NEXT = &H22
  70. Const KEY_END = &H23
  71. Const KEY_HOME = &H24
  72. Const KEY_LEFT = &H25
  73. Const KEY_UP = &H26
  74. Const KEY_RIGHT = &H27
  75. Const KEY_DOWN = &H28
  76. Const KEY_ADD = &H6B
  77. Const KEY_SUBTRACT = &H6D
  78.  
  79. #If Win32 Then
  80.     Declare Function BitBlt Lib "gdi32" (ByVal hDestDC%, ByVal x%, ByVal y%, ByVal nWidth%, ByVal nHeight%, ByVal hSrcDC%, ByVal xSrc%, ByVal ySrc%, ByVal dwRop&) As Integer
  81.     Declare Function StretchBlt Lib "gdi32" (ByVal hDestDC%, ByVal x%, ByVal y%, ByVal nWidth%, ByVal nHeight%, ByVal hSrcDC%, ByVal xSrc%, ByVal ySrc%, ByVal nsrcWidth%, ByVal nsrcHeight%, ByVal dwRop&) As Integer
  82.     Declare Function SetPixel Lib "gdi32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
  83. #Else
  84.     Declare Function BitBlt Lib "GDI" (ByVal hDestDC%, ByVal x%, ByVal y%, ByVal nWidth%, ByVal nHeight%, ByVal hSrcDC%, ByVal xSrc%, ByVal ySrc%, ByVal dwRop&) As Integer
  85.     Declare Function StretchBlt Lib "GDI" (ByVal hDestDC%, ByVal x%, ByVal y%, ByVal nWidth%, ByVal nHeight%, ByVal hSrcDC%, ByVal xSrc%, ByVal ySrc%, ByVal nsrcWidth%, ByVal nsrcHeight%, ByVal dwRop&) As Integer
  86.     Declare Function SetPixel Lib "GDI" (ByVal hDC As Integer, ByVal x As Integer, ByVal y As Integer, ByVal crColor As Long) As Long
  87. #End If
  88.  
  89. 'Establishes the Bitmap objects for an outline control
  90. 'Sub OutlineBmpSetup(BranchOpen As Control, BoFile As String, BranchClosed As Control, BcFile As String, Leaf As Control, LFile As String, CustomPic As Control)
  91. 'On Error Resume Next
  92. '
  93. 'Set gBranchOpenPic = IIf(m_PictureOpen = Nothing, BranchOpen, m_PictureOpen)
  94. 'Set gBranchClosedPic = IIf(m_PictureClosed = Nothing, BranchClosed, m_PictureClosed)
  95. 'Set gLeafPic = IIf(m_PictureItemNotSelected = Nothing, Leaf, m_PictureItemNotSelected)
  96. 'Set gCustomPic = IIf(m_PictureItemNotSelected = Nothing, CustomPic, m_PictureItemNotSelected)
  97. '
  98. 'If BoFile > "" Then gBranchOpenPic.Picture = LoadPicture(BoFile)
  99. 'If BcFile > "" Then gBranchClosedPic.Picture = LoadPicture(BcFile)
  100. 'If LFile > "" Then gLeafPic.Picture = LoadPicture(LFile)
  101. '
  102. 'End Sub
  103. Sub OutlineBmpSetup(BranchOpen As Control, BoPic As Picture, BranchClosed As Control, BcPic As Picture, Leaf As Control, LPic As Picture, CustomPic As Control, CPic As Picture)
  104. On Error Resume Next
  105.  
  106. Set gBranchOpenPic = BranchOpen
  107. Set gBranchClosedPic = BranchClosed
  108. Set gLeafPic = Leaf
  109. Set gCustomPic = CustomPic
  110.  
  111. If Not BoPic Is Nothing Then gBranchOpenPic.Picture = BoPic
  112. If Not BcPic Is Nothing Then gBranchClosedPic.Picture = BcPic
  113. If Not LPic Is Nothing Then gLeafPic.Picture = LPic
  114. If Not CPic Is Nothing Then gCustomPic.Picture = CPic
  115.  
  116. End Sub
  117.  
  118. Sub OutlineBmpCheckedSetup(BranchOpenAll As Control, BoaPic As Picture, BranchClosedAll As Control, BcaPic As Picture, BranchOpenSome As Control, BosPic As Picture, BranchClosedSome As Control, BcsPic As Picture, LeafChecked As Control, LcPic As Picture)
  119. 'On Error Resume Next
  120.  
  121. Set gBranchOpenAllPic = BranchOpenAll
  122. Set gBranchClosedAllPic = BranchClosedAll
  123. Set gBranchOpenSomePic = BranchOpenSome
  124. Set gBranchClosedSomePic = BranchClosedSome
  125. Set gLeafCheckedPic = LeafChecked
  126.  
  127. If Not BoaPic Is Nothing Then gBranchOpenAllPic.Picture = BoaPic
  128. If Not BcaPic Is Nothing Then gBranchClosedAllPic.Picture = BcaPic
  129. If Not BosPic Is Nothing Then gBranchOpenSomePic.Picture = BosPic
  130. If Not BcsPic Is Nothing Then gBranchClosedSomePic.Picture = BcsPic
  131. If Not LcPic Is Nothing Then gLeafCheckedPic.Picture = LcPic
  132.  
  133.  
  134. End Sub
  135.  
  136.  
  137. 'Processes a mouse click.
  138. Sub OutlineClick(OtlPic As Control, OtlScroll As Control, OtlSet As OtlSetup, Otldat As CollectionEx)
  139. Dim foo As Integer
  140. Dim Children As Integer
  141.  
  142. 'set select
  143. OtlSet.LastType = 0
  144. If OtlSet.CurrentLine > OtlSet.DisplayCount Then Exit Sub
  145.  
  146. 'default as child click, but change later if parent
  147. OtlSet.LastType = IIf(OtlSet.ElementClicked > 0, 4, 0)
  148.  
  149. 'If OtlSet.ElementClicked > 0 Then OtlSet.SelectIdx = OtlSet.DisplayIdx(OtlSet.CurrentLine)
  150. OtlSet.SelectIdx = OtlSet.DisplayIdx(OtlSet.CurrentLine)
  151.  
  152. 'if pictureclick then select all or deselect all, don't expand
  153. If OtlSet.ElementClicked = 1 And OtlSet.CheckmarkFlag Then
  154.   If Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).IsParent Then
  155.     OtlSet.LastType = 1
  156.   Else
  157.     OtlSet.LastType = 4
  158.   End If
  159.   OtlSet.VisChangeFlag = True
  160.   If Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Selected = 1 Then
  161.     Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Selected = 0
  162.   Else
  163.     Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Selected = 1
  164.   End If
  165.  
  166.   If OtlSet.AutoCheckParents Then
  167.     'set child select
  168.     For foo = OtlSet.DisplayIdx(OtlSet.CurrentLine) + 1 To Otldat.Count
  169.       If Otldat(foo).Level <= Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Level Then Exit For
  170.       Otldat(foo).Selected = Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Selected
  171.     Next foo
  172.     'set parent selects
  173.     CheckMarkParents OtlSet, Otldat
  174.   End If
  175. Else
  176.   'is it a branch?
  177.   'If OtlDat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Level < OtlSet.Levels - 1 Then
  178.   If Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).IsParent Then
  179.   
  180.       OtlSet.VisChangeFlag = True
  181.       'was it expanded?
  182.       If Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Expanded = True Then
  183.           'Collapse children
  184.           OtlSet.LastType = 2
  185.           For foo = OtlSet.DisplayIdx(OtlSet.CurrentLine) + 1 To Otldat.Count
  186.               If Otldat(foo).Level <= Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Level Then Exit For
  187.               Otldat(foo).Expanded = False
  188.               Otldat(foo).Visible = False
  189.           Next foo
  190.       Else
  191.           'Expand next level
  192.           OtlSet.LastType = 3
  193.           Children = 0
  194.           For foo = OtlSet.DisplayIdx(OtlSet.CurrentLine) + 1 To Otldat.Count
  195.               If Otldat(foo).Level <= Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Level Then
  196.                   Exit For
  197.               Else
  198.                   If Otldat(foo).Level = Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Level + 1 Then
  199.                       Otldat(foo).Expanded = False
  200.                       Otldat(foo).Visible = True
  201.                       Children = Children + 1
  202.                   End If
  203.               End If
  204.           Next foo
  205.       End If
  206.       Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Expanded = Not Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Expanded
  207.       If Children + OtlSet.CurrentLine >= OtlSet.DisplayLines Then
  208.         If Children < OtlSet.DisplayLines Then
  209.           OtlSet.TopIdx = OtlSet.DisplayIdx((OtlSet.CurrentLine + Children + 1) - OtlSet.DisplayLines)
  210.           OtlSet.SelectIdx = OtlSet.DisplayIdx(OtlSet.CurrentLine)
  211.           OtlSet.CurrentLine = OtlSet.CurrentLine - (Children + 1)
  212.         Else
  213.           OtlSet.TopIdx = OtlSet.DisplayIdx(OtlSet.CurrentLine)
  214.           OtlSet.SelectIdx = OtlSet.DisplayIdx(OtlSet.CurrentLine)
  215.           OtlSet.CurrentLine = 1
  216.         End If
  217.           
  218.       End If
  219.      
  220.   End If
  221. End If
  222. OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  223.  
  224. End Sub
  225.  
  226. Public Sub OutlineExpand(Index As Integer, OtlPic As Control, OtlScroll As Control, OtlSet As OtlSetup, Otldat As CollectionEx)
  227. Dim foo As Integer
  228. Dim Children As Integer
  229.  
  230. 'set select
  231. OtlSet.LastType = 0
  232. OtlSet.SelectIdx = Index
  233.   
  234.   If Otldat(Index).IsParent Then
  235.   
  236.       OtlSet.VisChangeFlag = True
  237.       'was it expanded?
  238.       If Otldat(Index).Expanded = False Then
  239.           'Expand next level
  240.           OtlSet.LastType = 3
  241.           Children = 0
  242.           For foo = Index + 1 To Otldat.Count
  243.               If Otldat(foo).Level <= Otldat(Index).Level Then
  244.                   Exit For
  245.               Else
  246.                   If Otldat(foo).Level = Otldat(Index).Level + 1 Then
  247.                       Otldat(foo).Expanded = False
  248.                       Otldat(foo).Visible = True
  249.                       Children = Children + 1
  250.                   End If
  251.               End If
  252.           Next foo
  253.       
  254.       Otldat(Index).Expanded = True
  255.       If Children + Index >= OtlSet.DisplayLines Then
  256.         If Children < OtlSet.DisplayLines Then
  257.           OtlSet.TopIdx = (Index + Children + 1) - OtlSet.DisplayLines
  258.           OtlSet.SelectIdx = Index
  259.           Index = Index - (Children + 1)
  260.         Else
  261.           OtlSet.TopIdx = Index
  262.           OtlSet.SelectIdx = Index
  263.           OtlSet.CurrentLine = 1
  264.         End If  'if children
  265.       End If
  266.       End If
  267.      
  268.   End If
  269. OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  270.  
  271. End Sub
  272.  
  273. Public Sub OutlineCollapse(Index As Integer, OtlPic As Control, OtlScroll As Control, OtlSet As OtlSetup, Otldat As CollectionEx)
  274. Dim foo As Integer
  275. Dim Children As Integer
  276.  
  277. 'set select
  278. OtlSet.LastType = 0
  279. OtlSet.SelectIdx = Index
  280.   
  281.   If Otldat(Index).IsParent Then
  282.   
  283.       OtlSet.VisChangeFlag = True
  284.       'was it expanded?
  285.       If Otldat(Index).Expanded = True Then
  286.           'Collapse children
  287.           OtlSet.LastType = 2
  288.           For foo = Index + 1 To Otldat.Count
  289.               If Otldat(foo).Level <= Otldat(Index).Level Then Exit For
  290.               Otldat(foo).Expanded = False
  291.               Otldat(foo).Visible = False
  292.           Next foo
  293.       
  294.           Otldat(Index).Expanded = False
  295.           OtlSet.TopIdx = Index
  296.           OtlSet.SelectIdx = Index
  297.           OtlSet.CurrentLine = 1
  298.       End If
  299.      
  300.   End If
  301. OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  302.  
  303. End Sub
  304.  
  305. Public Sub CheckMarkParents(OtlSet As OtlSetup, Otldat As CollectionEx)
  306. Dim foo As Integer
  307. ReDim LevelValue(OtlSet.Levels) As Double
  308. ReDim levelcount(OtlSet.Levels) As Integer
  309. For foo = Otldat.Count To 1 Step -1
  310.   'handle control break if this is not a child
  311. '  If OtlDat(foo).Level <= OtlSet.Levels - 2 Then
  312.   If Otldat(foo).IsParent Then
  313.     If LevelValue(Otldat(foo).Level + 1) = 0 Then
  314.       Otldat(foo).Selected = 0  'none selected
  315.     Else
  316.       If levelcount(Otldat(foo).Level + 1) = LevelValue(Otldat(foo).Level + 1) Then
  317.         Otldat(foo).Selected = 1  'all selected
  318.       Else
  319.         Otldat(foo).Selected = 2  'some selected
  320.       End If
  321.     End If
  322.     LevelValue(Otldat(foo).Level + 1) = 0
  323.     levelcount(Otldat(foo).Level + 1) = 0
  324.   End If
  325.   If Otldat(foo).Level > 0 Then
  326.     'increment parent count
  327.     Select Case Otldat(foo).Selected
  328.     Case 1
  329.       LevelValue(Otldat(foo).Level) = LevelValue(Otldat(foo).Level) + 1
  330.     Case 2
  331.       LevelValue(Otldat(foo).Level) = LevelValue(Otldat(foo).Level) + 0.0001
  332.     End Select
  333.     levelcount(Otldat(foo).Level) = levelcount(Otldat(foo).Level) + 1
  334.     
  335.   End If
  336. Next foo
  337. End Sub
  338.  
  339. 'Closes all open branches.
  340.  
  341. Sub OutlineCollapseAll(OtlPic As Control, OtlScroll As Control, OtlSet As OtlSetup, Otldat As CollectionEx)
  342. Dim foo As Integer
  343. Dim TotVisible As Integer
  344. For foo = 1 To Otldat.Count
  345.     If Otldat(foo).Level > 0 Then
  346.         Otldat(foo).Visible = False
  347.         Otldat(foo).Expanded = False
  348.     Else
  349.         Otldat(foo).Expanded = False
  350.     End If
  351.     If Otldat(foo).Visible = True Then TotVisible = TotVisible + 1
  352. Next foo
  353. If Otldat(OtlSet.SelectIdx).Visible = False Then OtlSet.SelectIdx = 1
  354. If TotVisible <= OtlSet.DisplayLines Then
  355.   OtlSet.TopIdx = 1
  356. Else
  357.   OtlSet.TopIdx = OtlSet.SelectIdx
  358. End If
  359. OtlSet.VisChangeFlag = True
  360. OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  361.  
  362. End Sub
  363.  
  364.  
  365. 'Opens all branches.
  366.  
  367. Sub OutlineExpandAll(OtlPic As Control, OtlScroll As Control, OtlSet As OtlSetup, Otldat As CollectionEx)
  368. Dim foo As Integer
  369.  
  370. For foo = 1 To Otldat.Count
  371.     Otldat(foo).Visible = True
  372.     'If OtlDat(foo).Level < OtlSet.Levels - 1 Then OtlDat(foo).Expanded = True
  373.     If Otldat(foo).IsParent Then Otldat(foo).Expanded = True
  374. Next foo
  375. OtlSet.VisChangeFlag = True
  376. OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  377.  
  378. End Sub
  379.  
  380.  
  381. 'Locates text within the control.
  382.  
  383. Sub OutlineFind(FindItem As String, FindMode As Integer, OtlPic As Control, OtlScroll As Control, OtlSet As OtlSetup, Otldat As CollectionEx)
  384. Dim ItemStart As Integer, foo As Integer, foobar As Integer
  385. Dim foo2 As Integer
  386. If FindMode = 0 Then
  387.     ItemStart = 1
  388. Else
  389.     ItemStart = OtlSet.SelectIdx + 1
  390. End If
  391. For foo = ItemStart To Otldat.Count
  392.     If InStr(1, Otldat(foo).Caption, FindItem, 1) > 0 Then
  393.         OtlSet.SelectIdx = foo
  394.         OtlSet.TopIdx = foo
  395.         If Otldat(foo).Level <> 0 Then
  396.             For foobar = foo To 1 Step -1
  397.                 If Otldat(foobar).Level = 0 Then
  398.                     Otldat(foobar).Expanded = True
  399.                     Otldat(foobar).Visible = True
  400.                     Exit For
  401.                 End If
  402.             Next foobar
  403.             For foo2 = foobar + 1 To Otldat.Count
  404.                 If Otldat(foo2).Level = 0 Then Exit For
  405.                 Otldat(foo2).Visible = True
  406.             Next foo2
  407.         End If
  408.         OtlSet.CurrentLine = 1
  409.         OtlSet.VisChangeFlag = True
  410.         OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  411.         Exit Sub
  412.     End If
  413. Next foo
  414. 'item not found
  415. Beep
  416.  
  417. End Sub
  418.  
  419. 'goto a specific node
  420.  
  421. Sub OutlineGoto(FindItem As Integer, OtlPic As Control, OtlScroll As Control, OtlSet As OtlSetup, Otldat As CollectionEx)
  422. Dim foo As Integer, foobar As Integer
  423. Dim foo2 As Integer
  424.         
  425. foo = FindItem
  426. If foo <= Otldat.Count Then
  427.         OtlSet.SelectIdx = foo
  428.         OtlSet.TopIdx = foo
  429.         If Otldat(foo).Level <> 0 Then
  430.             For foobar = foo To 1 Step -1
  431.                 If Otldat(foobar).Level = 0 Then
  432.                     Otldat(foobar).Expanded = True
  433.                     Otldat(foobar).Visible = True
  434.                     Exit For
  435.                 End If
  436.             Next foobar
  437.             For foo2 = foobar + 1 To Otldat.Count
  438.                 If Otldat(foo2).Level = 0 Then Exit For
  439.                 Otldat(foo2).Visible = True
  440.             Next foo2
  441.         End If
  442.         OtlSet.CurrentLine = 1
  443.         OtlSet.VisChangeFlag = True
  444.         OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  445. Else
  446.   Beep
  447. End If
  448. End Sub
  449.  
  450.  
  451. 'Processes outline control keys
  452.  
  453. Sub OutlineKeyPress(KeyCode As Integer, OtlPic As Control, OtlScroll As Control, OtlSet As OtlSetup, Otldat As CollectionEx)
  454. Dim foo As Integer, VisCount As Integer
  455. On Error Resume Next
  456. Select Case KeyCode
  457.  
  458. Case vbKeyReturn
  459.     OtlSet.ElementClicked = 2
  460.     OutlineClick OtlPic, OtlScroll, OtlSet, Otldat
  461.     
  462. Case vbKeySpace
  463.     OtlSet.ElementClicked = 1
  464.     OutlineClick OtlPic, OtlScroll, OtlSet, Otldat
  465.     
  466. Case KEY_PRIOR
  467.     VisCount = 0
  468.     foo = 0
  469.     For foo = OtlSet.TopIdx To 1 Step -1
  470.         If Otldat(foo).Visible = True Then VisCount = VisCount + 1
  471.         If VisCount = OtlSet.DisplayLines Then Exit For
  472.     Next foo
  473.     OtlSet.CurrentLine = 1
  474.     OtlSet.TopIdx = foo + 1
  475.     OtlSet.SelectIdx = OtlSet.TopIdx
  476.     OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  477.  
  478. Case KEY_NEXT
  479.     For foo = OtlSet.DisplayLines To 1 Step -1
  480.         If OtlSet.DisplayIdx(foo) > 0 Then
  481.             OtlSet.TopIdx = OtlSet.DisplayIdx(foo)
  482.             Exit For
  483.         End If
  484.     Next foo
  485.     OtlSet.CurrentLine = 1
  486.     OtlSet.SelectIdx = OtlSet.TopIdx
  487.     OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  488.  
  489. Case KEY_END
  490.     OutlineGoto Otldat.Count, OtlPic, OtlScroll, OtlSet, Otldat
  491.     
  492. Case KEY_HOME
  493.     OutlineGoto 1, OtlPic, OtlScroll, OtlSet, Otldat
  494.  
  495. Case KEY_LEFT
  496.     OutlineCollapse OtlSet.SelectIdx, OtlPic, OtlScroll, OtlSet, Otldat
  497.     
  498. Case KEY_RIGHT
  499.     OutlineExpand OtlSet.SelectIdx, OtlPic, OtlScroll, OtlSet, Otldat
  500.  
  501. Case KEY_UP
  502.     If OtlSet.CurrentLine > 1 Then
  503.         OtlSet.CurrentLine = OtlSet.CurrentLine - 1
  504.         OtlSet.SelectIdx = OtlSet.DisplayIdx(OtlSet.CurrentLine)
  505.     Else
  506.         For foo = OtlSet.TopIdx - 1 To 1 Step -1
  507.             If Otldat(foo).Visible = True Then
  508.                 OtlSet.TopIdx = foo
  509.                 OtlSet.SelectIdx = OtlSet.TopIdx
  510.                 Exit For
  511.             End If
  512.         Next foo
  513.     End If
  514.     OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  515.     
  516. Case KEY_DOWN
  517.     If OtlSet.CurrentLine < OtlSet.DisplayCount Then
  518.         OtlSet.CurrentLine = OtlSet.CurrentLine + 1
  519.         OtlSet.SelectIdx = OtlSet.DisplayIdx(OtlSet.CurrentLine)
  520.     Else
  521.         For foo = OtlSet.DisplayIdx(OtlSet.CurrentLine) + 1 To Otldat.Count
  522.             If Otldat(foo).Visible = True Then
  523.                 OtlSet.TopIdx = OtlSet.DisplayIdx(2)
  524.                 OtlSet.SelectIdx = foo
  525.                 Exit For
  526.             End If
  527.         Next foo
  528.     End If
  529.     OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  530.  
  531. Case Else
  532. End Select
  533. End Sub
  534.  
  535. 'Processes MouseDown to get coordinates of click.
  536.  
  537. Sub OutlineMouseDown2Line(OtlSet As OtlSetup, Otldat As CollectionEx, y As Single, x As Single)
  538. On Error Resume Next
  539. OtlSet.LastLine = OtlSet.CurrentLine
  540. OtlSet.CurrentLine = (y \ OtlSet.LineHeight) + 1
  541. OtlSet.ElementClicked = (x - Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Level * OtlSet.ColWidth) \ OtlSet.ColWidth  '0=+/-, 1=Pic, 2=Caption
  542. If OtlSet.ElementClicked > 2 Then OtlSet.ElementClicked = 2
  543.  
  544. If OtlSet.LineFlag = 0 And OtlSet.ElementClicked = 0 Then
  545.   OtlSet.ElementClicked = 1
  546. ElseIf OtlSet.LineFlag = 0 And OtlSet.ElementClicked = 1 Then
  547.   OtlSet.ElementClicked = 2
  548. End If
  549. If OtlSet.BmpFlag = 0 And OtlSet.ElementClicked = 1 Then OtlSet.ElementClicked = 2
  550. End Sub
  551.  
  552.  
  553. 'Setup routine for plus/minus
  554.  
  555. Sub OutlinePlusMinusSetup(PlusPic As Control, PlusFile As String, MinusPic As Control, MinusFile As String)
  556. On Error Resume Next
  557.  
  558. Set gPlusPic = PlusPic
  559. Set gMinusPic = MinusPic
  560.  
  561. If PlusFile > "" Then gPlusPic.Picture = LoadPicture(PlusFile)
  562. If MinusFile > "" Then gMinusPic.Picture = LoadPicture(MinusFile)
  563.  
  564. End Sub
  565.  
  566. 'This is main drawing routine for outline control.
  567.  
  568. Sub OutlineRefresh(OtlPic As Control, OtlScroll As Control, OtlSet As OtlSetup, Otldat As CollectionEx)
  569.  
  570. 'On Error Resume Next
  571. 'Paints control from data array
  572. Dim foo As Integer, foobar As Integer, TotItems As Long
  573. Dim CurrY As Integer, currX As Integer
  574. Dim BmpWidth As Integer, BmpHeight As Integer
  575. Dim TwipsY As Integer, TwipsX As Integer, TxtWidth As Integer
  576. Dim LineCount As Integer, HoldForeColor As Long
  577. Dim TotVis As Long, SelPnt As Long
  578. ReDim PrevLevelLine(20) As Integer
  579. Dim PrevBmpFile As Picture
  580. Dim SearchLevel As Integer
  581.  
  582. 'GMG 989818:
  583. Dim yLine1 As Single, yLine2 As Single
  584.  
  585. If ChangingScroll Then
  586.     Exit Sub 'don't recurse scroll change
  587. End If
  588.  
  589. TwipsY = Screen.TwipsPerPixelY
  590. TwipsX = Screen.TwipsPerPixelX
  591. 'OtlSet.LineHeight = 12 * twipsx
  592. BmpWidth = OtlSet.LineHeight
  593. BmpHeight = OtlSet.LineHeight
  594. 'Just changing select bar?
  595. If OtlSet.TopIdx = OtlSet.PrevTop And OtlSet.VisChangeFlag = False Then
  596.     'OtlPic.AutoRedraw = False
  597.     For foo = 1 To OtlSet.DisplayCount
  598.         CurrY = (foo - 1) * OtlSet.LineHeight
  599.         'highlight currently selected item
  600.         If OtlSet.DisplayIdx(foo) = OtlSet.SelectIdx Then
  601.             OtlPic.CurrentY = CurrY
  602.             currX = OutlineSetX(3, Otldat(OtlSet.DisplayIdx(foo)).Level, OtlSet)
  603.             TxtWidth = currX + OtlPic.TextWidth(Otldat(OtlSet.DisplayIdx(foo)).Caption) + 75
  604.             OtlPic.Line (currX + 10, CurrY)-(TxtWidth * 2, CurrY + OtlSet.LineHeight - TwipsY), OtlPic.BackColor, BF
  605.             OtlPic.Line (currX + 10, CurrY)-(TxtWidth, CurrY + OtlSet.LineHeight - TwipsY), OtlSet.SelectColor, BF
  606.             OtlSet.CurrentLine = foo
  607.             'Print Caption
  608.             OtlPic.CurrentY = CurrY
  609.             OtlPic.CurrentX = currX
  610.             HoldForeColor = OtlPic.ForeColor
  611.             OtlPic.ForeColor = OtlSet.SelectTextColor
  612.             OtlPic.Print " " & Otldat(OtlSet.DisplayIdx(foo)).Caption
  613.             OtlPic.ForeColor = HoldForeColor
  614.         Else
  615.             'unhighlight previously selected item
  616.             If OtlSet.DisplayIdx(foo) = OtlSet.PrevSel Then
  617.                 OtlPic.CurrentY = CurrY
  618.                 currX = OutlineSetX(3, Otldat(OtlSet.DisplayIdx(foo)).Level, OtlSet)
  619.                 TxtWidth = currX + OtlPic.TextWidth(Otldat(OtlSet.DisplayIdx(foo)).Caption) + 75
  620.                 OtlPic.Line (currX + 10, CurrY)-(TxtWidth, CurrY + OtlSet.LineHeight - TwipsY), OtlPic.BackColor, BF
  621.                 'Print Caption
  622.                 OtlPic.CurrentY = CurrY
  623.                 OtlPic.CurrentX = currX
  624.                 OtlPic.Print " " & Otldat(OtlSet.DisplayIdx(foo)).Caption
  625.             End If
  626.         End If
  627.     Next foo
  628.     'OtlPic.AutoRedraw = True
  629. Else
  630.     Erase OtlSet.DisplayIdx
  631.     OtlPic.Cls
  632.     'TotItems = UBound(OtlDat)
  633.     TotItems = Otldat.Count
  634.     LineCount = 0
  635.     For foo = OtlSet.TopIdx To TotItems
  636.       'GMG 980818 : without this we will crash
  637.       If foo > 0 Then
  638.         If Otldat(foo).Visible = True Then
  639.             CurrY = (LineCount) * OtlSet.LineHeight
  640.             If LineCount = 0 Then
  641.                 OtlSet.TopIdx = foo
  642.             End If
  643.             OtlSet.DisplayIdx(LineCount + 1) = foo
  644.             'Print Select Highlight
  645.             If OtlSet.SelectIdx = foo Then
  646.                 OtlPic.CurrentY = CurrY
  647.                 currX = OutlineSetX(3, Otldat(foo).Level, OtlSet)
  648.                 TxtWidth = currX + OtlPic.TextWidth(Otldat(foo).Caption) + 75
  649.                 OtlPic.Line (currX + 10, CurrY)-(TxtWidth, CurrY + OtlSet.LineHeight - TwipsY), OtlSet.SelectColor, BF
  650.                 OtlSet.CurrentLine = LineCount + 1
  651.                 HoldForeColor = OtlPic.ForeColor
  652.                 
  653.                 'Print Select Caption
  654.                 OtlPic.ForeColor = OtlSet.SelectTextColor
  655.                 OtlPic.CurrentY = CurrY
  656.                 OtlPic.CurrentX = currX
  657.                 OtlPic.Print " " & Otldat(foo).Caption
  658.                 OtlPic.ForeColor = HoldForeColor
  659.             Else
  660.                 'Print Caption
  661.                 OtlPic.CurrentY = CurrY
  662.                 currX = OutlineSetX(3, Otldat(foo).Level, OtlSet)
  663.                 OtlPic.CurrentX = currX
  664.                 OtlPic.Print " " & Otldat(foo).Caption
  665.             End If
  666.             
  667.             'draw lines with default forecolor
  668.             'MOD FOR EXPLORER STYLE DOTTED LINES...
  669.             If OtlSet.LineFlag = 1 Then
  670.                 PrevLevelLine(Otldat(foo).Level + 1) = LineCount
  671.                 currX = OutlineSetX(0, Otldat(foo).Level, OtlSet)
  672.                 'horizontal lines connecting subitems
  673.                 DotLine95 OtlPic, currX, CurrY + OtlSet.LineHeight \ 2, currX + OtlSet.ColWidth * 0.6, CurrY + OtlSet.LineHeight \ 2
  674.                 If LineCount = 0 Then
  675.                     If Otldat(foo).Level > 0 Then DotLine95 OtlPic, currX, CurrY + OtlSet.LineHeight \ 2, currX, CurrY
  676.                 Else
  677.                     If Otldat(foo - 1).Level = Otldat(foo).Level Then
  678.                         'vertical lines connecting subitems
  679.                         DotLine95 OtlPic, currX, CurrY + OtlSet.LineHeight \ 2, currX, CurrY - OtlSet.LineHeight \ 2 '- twipsy
  680.                     Else
  681.                         If Otldat(foo - 1).Level < Otldat(foo).Level Then
  682.                             'vertical line below pictures/folders
  683.                             DotLine95 OtlPic, currX, CurrY + OtlSet.LineHeight \ 2, currX, CurrY
  684.                         Else
  685.                             For foobar = LineCount - 1 To 1 Step -1
  686.                                 If Otldat(OtlSet.DisplayIdx(foobar) + 1).Level <= Otldat(foo).Level Then
  687.                                     Exit For
  688.                                 End If
  689.                             Next foobar
  690.                             If Otldat(OtlSet.DisplayIdx(foobar) + 1).Level <= Otldat(foo).Level Then
  691.                                 'vertical line between collapsed parents
  692.                                 
  693.                                 '*************************************************************************************
  694.                                 'GMG 980811 : don't draw any lines above the top [+]
  695.                                   yLine2 = CurrY + OtlSet.LineHeight \ 2
  696.                                   yLine1 = OtlSet.LineHeight * (foobar) - OtlSet.LineHeight \ 2
  697.                                   'If (yLine1 < 120) And (OtlDat(foo).Level = 0) And (OtlSet.TopIdx = 1) Then
  698.                                   ' i wasnt sure whether to use foo or (otlset.displayidx(foobar)+1),
  699.                                   ' but i dont think we should have any case like this:
  700.                                   
  701.                                   If (yLine1 < OtlSet.LineHeight \ 2 + 10) And (OtlSet.TopIdx = 1) Then
  702.                                       'this must be the very top node, so dont draw too high
  703.                                       yLine1 = OtlSet.LineHeight \ 2 + 10
  704.                                   End If
  705.                                   
  706.                                   DotLine95 OtlPic, currX, yLine2, currX, yLine1
  707.                                 'DotLine95 OtlPic, currX, CurrY + OtlSet.LineHeight \ 2, currX, OtlSet.LineHeight * (foobar + 1) - OtlSet.LineHeight \ 2
  708.                                 '*************************************************************************************
  709.                             Else
  710.                                 'Equal level at top or next/any is above limit of control visible area
  711.                                 DotLine95 OtlPic, currX, CurrY + OtlSet.LineHeight \ 2, currX, 0 'OtlSet.LineHeight * (foobar + 1) - OtlSet.LineHeight \ 2
  712.                             End If
  713.                         End If
  714.                     End If
  715.                 End If
  716.             End If
  717.  
  718.             'GMG 980811 : moved this down here so the bitmap gets blt'd last
  719.             
  720.             'blt bmp
  721.             If OtlSet.BmpFlag = 1 Then
  722.                 OtlPic.CurrentY = CurrY
  723.                 currX = OutlineSetX(2, Otldat(foo).Level, OtlSet)
  724.                 OtlPic.CurrentX = currX
  725.                 
  726.                 'do bitmap by kind
  727.                 'If OtlDat(foo).Level = OtlSet.Levels - 1 Then
  728.                 If Not Otldat(foo).IsParent Then
  729.                     'Leaf
  730.                     
  731.                     If Not Otldat(foo).Bitmap Is Nothing Then
  732.                         Err = 0
  733.                         If Not PrevBmpFile Is Otldat(foo).Bitmap Then
  734.                             'gCustomPic.Picture = LoadPicture(OtlDat(foo).Bitmap)
  735.                             Set gCustomPic.Picture = Otldat(foo).Bitmap
  736.                             If Err <> 0 Then
  737.                                 Err = 0
  738.                                 'gCustomPic.Picture = LoadPicture(App.Path & "\" & OtlDat(foo).Bitmap)
  739.                                 Set gCustomPic.Picture = Otldat(foo).Bitmap
  740.                             End If
  741.                             If Err = 0 Then
  742.                                 Set PrevBmpFile = Otldat(foo).Bitmap
  743.                             End If
  744.                         End If
  745.                         If Err = 0 And OtlSet.CheckmarkFlag = 0 Then
  746.                             OtlPic.PaintPicture gCustomPic.Picture, currX, CurrY
  747.                         Else
  748.                             If OtlSet.CheckmarkFlag And (Otldat(foo).Selected = 1) Then
  749.                               OtlPic.PaintPicture gLeafCheckedPic.Picture, currX, CurrY
  750.                             Else
  751.                               OtlPic.PaintPicture gLeafPic.Picture, currX, CurrY
  752.                             End If
  753.                         End If
  754.                     Else
  755.                         If OtlSet.CheckmarkFlag And (Otldat(foo).Selected = 1) Then
  756.                           OtlPic.PaintPicture gLeafCheckedPic.Picture, currX, CurrY
  757.                         Else
  758.                           OtlPic.PaintPicture gLeafPic.Picture, currX, CurrY
  759.                         End If
  760.                     End If
  761.                 Else
  762.                     PaintBranchBmp OtlPic, Otldat(foo).Expanded, Otldat(foo).Selected, OtlSet.CheckmarkFlag, currX, CurrY, OtlSet
  763.                 End If
  764.             End If
  765.             
  766.             'set next line
  767.             LineCount = LineCount + 1
  768.             If LineCount >= OtlSet.DisplayLines Or foo = Otldat.Count Then
  769.                 Exit For
  770.             End If
  771.         End If
  772.       End If
  773.     Next foo
  774.     LineCount = LineCount - 1
  775.     OtlSet.DisplayCount = LineCount + 1
  776.     
  777.     'Complete Line processing
  778.     If OtlSet.LineFlag = 1 And foo < TotItems Then
  779.         SearchLevel = Otldat(foo).Level  'Last item displayed
  780.         For foobar = foo + 1 To TotItems
  781.             If Otldat(foobar).Level <= SearchLevel Then
  782.                 currX = OutlineSetX(0, Otldat(foobar).Level, OtlSet)
  783.                 'vertical line down from expanded parent
  784.                 
  785.                 '*************************************************************************************
  786.                 'GMG 980811 : don't draw any lines above the top [+]
  787.                   yLine2 = OtlPic.Height
  788.                   yLine1 = PrevLevelLine(Otldat(foobar).Level + 1) * OtlSet.LineHeight
  789.                   If (yLine1 < OtlSet.LineHeight \ 2 + 10) And (Otldat(foobar).Level = 0) And (OtlSet.TopIdx = 1) Then
  790.                       'this must be the very top node, so dont draw too high
  791.                       yLine1 = OtlSet.LineHeight \ 2 + 10
  792.                   End If
  793.                   DotLine95 OtlPic, currX, yLine2, currX, yLine1 '- twipsy
  794.                 
  795.                 'DotLine95 OtlPic, currX, OtlPic.Height, currX, PrevLevelLine(OtlDat(foobar).Level + 1) * OtlSet.LineHeight '- twipsy
  796.                 '*************************************************************************************
  797.                 
  798.                 SearchLevel = Otldat(foobar).Level - 1
  799.                 If SearchLevel < 0 Then Exit For
  800.             End If
  801.         Next foobar
  802.     End If
  803.     
  804.     'draw plus minus boxes
  805.     LineCount = 0
  806.     CurrY = 0
  807.     If (OtlSet.PlusFlag = 1) Then
  808.       For foo = OtlSet.TopIdx To TotItems
  809.         'If (OtlDat(foo).Level < OtlSet.Levels - 1) And OtlDat(foo).Visible Then
  810.         If (Otldat(foo).IsParent) And Otldat(foo).Visible Then
  811.             CurrY = (LineCount) * OtlSet.LineHeight + OtlSet.LineHeight / 2 - Screen.TwipsPerPixelY
  812.             currX = OutlineSetX(1, Otldat(foo).Level, OtlSet)
  813.             OtlPic.CurrentX = currX
  814.             'does the branch have child entries?
  815.             If foo = TotItems Then
  816.                 'last entry so no children
  817.                 Drawbox Pic:=OtlPic, x:=(currX), y:=(CurrY), Plus:=False
  818.             Else
  819.                 'no kids
  820.                 If Otldat(foo + 1).Level <= Otldat(foo).Level Then
  821.                     Drawbox Pic:=OtlPic, x:=(currX), y:=(CurrY), Plus:=False
  822.                     Else
  823.                     'does have children, but is it expanded already?
  824.                     If Otldat(foo).Expanded = True Then
  825.                         Drawbox Pic:=OtlPic, x:=(currX), y:=(CurrY), Plus:=False
  826.                     Else 'PLUS - has unexpanded children
  827.                         Drawbox Pic:=OtlPic, x:=(currX), y:=(CurrY), Plus:=True
  828.                     End If
  829.                 End If
  830.             End If
  831.         End If
  832.         If Otldat(foo).Visible Then
  833.             'set next line
  834.             LineCount = LineCount + 1
  835.             If LineCount >= OtlSet.DisplayLines Or foo = Otldat.Count Then
  836.                 Exit For
  837.             End If
  838.         End If
  839.       Next foo
  840.     End If
  841.     'Set Scroll Bar
  842.     'Determine visible items
  843.     If OtlSet.VisChangeFlag Then
  844.         ChangingScroll = True
  845.         OtlSet.VisChangeFlag = False
  846.         OtlSet.VisibleItems = -1
  847.         For foo = 1 To TotItems
  848.             If Otldat(foo).Visible = True Then
  849.                 OtlSet.VisibleItems = OtlSet.VisibleItems + 1
  850.                 Otldat(foo).VisibleIdx = OtlSet.VisibleItems
  851.             Else
  852.                 Otldat(foo).VisibleIdx = -1
  853.             End If
  854.         Next foo
  855.         If OtlSet.VisibleItems > 0 Then
  856.             OtlScroll.Visible = True
  857.             OtlScroll.Max = OtlSet.VisibleItems
  858.         Else
  859.             OtlScroll.Visible = False
  860.             OtlScroll.value = 0
  861.         End If
  862.         OtlScroll.SmallChange = 1
  863.         OtlScroll.LargeChange = 10
  864.         ChangingScroll = False
  865.     End If
  866. End If
  867. If OtlScroll.Visible = True Then
  868.     ChangingScroll = True
  869.     OtlScroll.value = Otldat(OtlSet.SelectIdx).VisibleIdx
  870.     ChangingScroll = False
  871. End If
  872. OtlSet.PrevSel = OtlSet.SelectIdx
  873. OtlSet.PrevTop = OtlSet.TopIdx
  874.  
  875. End Sub
  876. Public Sub PaintBranchBmp(OtlPic As Object, Expanded As Integer, Selected As Integer, CheckmarkFlag As Integer, currX As Integer, CurrY As Integer, OtlSet As OtlSetup)
  877.  
  878. If CheckmarkFlag = False Then
  879.   If Expanded Then
  880.     OtlPic.PaintPicture gBranchOpenPic.Picture, currX, CurrY
  881.   Else
  882.     OtlPic.PaintPicture gBranchClosedPic.Picture, currX, CurrY
  883.   End If
  884. Else
  885.   If Expanded Then
  886.     Select Case Selected
  887.     Case 0
  888.       OtlPic.PaintPicture gBranchOpenPic.Picture, currX, CurrY
  889.     Case 1
  890.       OtlPic.PaintPicture gBranchOpenAllPic.Picture, currX, CurrY
  891.     Case 2
  892.       OtlPic.PaintPicture gBranchOpenSomePic.Picture, currX, CurrY
  893.     End Select
  894.   Else
  895.     Select Case Selected
  896.     Case 0
  897.       OtlPic.PaintPicture gBranchClosedPic.Picture, currX, CurrY
  898.     Case 1
  899.       OtlPic.PaintPicture gBranchClosedAllPic.Picture, currX, CurrY
  900.     Case 2
  901.       OtlPic.PaintPicture gBranchClosedSomePic.Picture, currX, CurrY
  902.     End Select
  903.   End If
  904. End If
  905.  
  906. End Sub
  907.                         
  908.                        
  909.  
  910. Public Function OutlineSetX(ViewType As Integer, Level As Integer, OtlSet As OtlSetup) As Integer
  911. 'used for win95 style outlines -- always have bmp, lines, +/-
  912. 'ViewType --> 0 = line, 1 = +/- box, 2 = bmp, 3 = text
  913. Dim currX As Integer
  914.  
  915. 'added to move text over if bitmaps or lines are not displayed
  916. If OtlSet.BmpFlag = 0 And ViewType = 3 Then ViewType = 2
  917. If OtlSet.PlusFlag = 0 And OtlSet.BmpFlag = 0 And ViewType = 3 Then ViewType = 2
  918. If OtlSet.PlusFlag = 0 And OtlSet.BmpFlag = 0 And OtlSet.LineFlag = 0 And ViewType = 2 Then ViewType = 1
  919. If OtlSet.PlusFlag = 0 And OtlSet.BmpFlag = 1 And OtlSet.LineFlag = 0 And ViewType = 2 Then ViewType = 1
  920. If OtlSet.PlusFlag = 0 And OtlSet.BmpFlag = 1 And OtlSet.LineFlag = 0 And ViewType = 3 Then ViewType = 2
  921.  
  922.  
  923. OtlSet.ColWidth = 17 * Screen.TwipsPerPixelX
  924. Select Case ViewType
  925. Case 0 'lines
  926.   If Level > 0 Then
  927.     currX = Level * OtlSet.ColWidth + OtlSet.LineHeight \ 2
  928.   Else
  929.     currX = OtlSet.LineHeight \ 2
  930.   End If
  931. Case 1 '+/- box
  932.   If Level > 0 Then
  933.     currX = Level * OtlSet.ColWidth + OtlSet.LineHeight \ 2
  934.   Else
  935.     currX = OtlSet.LineHeight \ 2 + Screen.TwipsPerPixelX
  936.   End If
  937. Case 2 'bmp
  938.   If Level > 0 Then
  939.     currX = Level * OtlSet.ColWidth + OtlSet.ColWidth + Screen.TwipsPerPixelX * 2
  940.   Else
  941.     currX = OtlSet.ColWidth + (Screen.TwipsPerPixelX * 2)
  942.   End If
  943. Case 3 'text caption
  944.   If Level > 0 Then
  945.     currX = Level * OtlSet.ColWidth + OtlSet.ColWidth + OtlSet.LineHeight + (Screen.TwipsPerPixelX * 2)
  946.   Else
  947.     currX = OtlSet.ColWidth + OtlSet.LineHeight + (Screen.TwipsPerPixelX * 2)
  948.   End If
  949. End Select
  950. OutlineSetX = currX
  951. End Function
  952.  
  953. Sub Drawbox(Pic As Object, x As Long, y As Long, Plus As Integer)
  954. Dim twips As Integer, Holdstyle As Integer
  955. twips = Screen.TwipsPerPixelY
  956. Holdstyle = Pic.DrawStyle
  957.  
  958. Pic.Line (x - 4 * twips, y - 4 * twips)-Step(8 * twips, 8 * twips), &HFFFFFF, BF
  959. Pic.DrawStyle = 0
  960. Pic.Line (x - 4 * twips, y - 4 * twips)-Step(8 * twips, 8 * twips), &H808080, B
  961. Pic.Line (x - 2 * twips, y)-Step(5 * twips, 0), &H0
  962. If Plus Then Pic.Line (x, y - 2 * twips)-Step(0, 5 * twips), &H0
  963. Pic.DrawStyle = Holdstyle
  964.  
  965. End Sub
  966.  
  967.  
  968.  
  969. Public Sub DotLine95(OtlPic As Control, x1, y1, x2, y2)
  970. 'draws horizontal or vertical only ... no angles in this rev
  971. Dim foo As Integer, LowVal, HighVal, TwipsX As Integer, TwipsY As Integer
  972. Dim OtlPicHdc As Long
  973. Dim Checkit As Long
  974. TwipsX = Screen.TwipsPerPixelX
  975. TwipsY = Screen.TwipsPerPixelY
  976. OtlPicHdc = OtlPic.hDC
  977. If x1 = x2 Then
  978.   If y1 < y2 Then
  979.     LowVal = y1
  980.     HighVal = y2
  981.   Else
  982.     LowVal = y2
  983.     HighVal = y1
  984.   End If
  985.   If (LowVal \ TwipsY) Mod 2 = 1 Then LowVal = (LowVal \ TwipsY) * TwipsY - TwipsY
  986.   If (x1 \ TwipsX) Mod 2 = 1 Then x1 = (x1 \ TwipsX) * TwipsX + TwipsX
  987.   For foo = LowVal To HighVal Step TwipsX * 2
  988.     Checkit = SetPixel(OtlPicHdc, x1 / TwipsX, foo / TwipsY, &H808080)
  989.   Next foo
  990. Else
  991.   If x1 < x2 Then
  992.     LowVal = x1
  993.     HighVal = x2
  994.   Else
  995.     LowVal = x2
  996.     HighVal = x1
  997.   End If
  998.   If (LowVal \ TwipsX) Mod 2 = 1 Then
  999.     LowVal = (LowVal \ TwipsX) * TwipsX + TwipsX
  1000.     HighVal = (HighVal \ TwipsX) * TwipsX + TwipsX
  1001.   End If
  1002.   If (HighVal \ TwipsX) Mod 2 = 1 Then HighVal = (HighVal \ TwipsX) * TwipsX + TwipsX
  1003.   If (y1 \ TwipsY) Mod 2 = 1 Then y1 = (y1 \ TwipsY) * TwipsY - TwipsY
  1004.   For foo = LowVal To HighVal Step TwipsY * 2
  1005.     Checkit = SetPixel(OtlPicHdc, foo / TwipsX, y1 / TwipsY, &H808080)
  1006.   Next foo
  1007. End If
  1008. End Sub
  1009.  
  1010.  
  1011. 'Used to adjust outline control in response to scroll bar changes.
  1012.  
  1013. Sub OutlineScroll(ScrollValue As Integer, OtlPic As Control, OtlScroll As Control, OtlSet As OtlSetup, Otldat As CollectionEx)
  1014. Dim foo As Integer, Vispoint As Long
  1015. If ChangingScroll Then Exit Sub
  1016. Vispoint = -1
  1017. If ScrollValue < Otldat(OtlSet.DisplayIdx(1)).VisibleIdx Then
  1018.     For foo = OtlSet.DisplayIdx(1) To 1 Step -1
  1019.         If ScrollValue = Otldat(foo).VisibleIdx Then
  1020.             OtlSet.CurrentLine = 1
  1021.             OtlSet.SelectIdx = foo
  1022.             OtlSet.TopIdx = OtlSet.SelectIdx
  1023.             OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  1024.             Exit For
  1025.         End If
  1026.     Next foo
  1027. Else
  1028.     If ScrollValue > Otldat(OtlSet.DisplayIdx(OtlSet.DisplayCount)).VisibleIdx Then
  1029.         'find bottom to select
  1030.         For foo = OtlSet.DisplayIdx(OtlSet.DisplayCount) To Otldat.Count
  1031.             If ScrollValue = Otldat(foo).VisibleIdx Then
  1032.                 OtlSet.CurrentLine = OtlSet.DisplayCount
  1033.                 OtlSet.SelectIdx = foo
  1034.                 Exit For
  1035.             End If
  1036.         Next foo
  1037.         'Find TopIdx for display
  1038.         For foo = OtlSet.SelectIdx To 1 Step -1
  1039.             If Otldat(foo).VisibleIdx = ScrollValue - OtlSet.DisplayCount Then Exit For
  1040.         Next foo
  1041.         OtlSet.TopIdx = foo + 1
  1042.         OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  1043.     Else
  1044.         'make sure current item is selected within display when scrollbar moves
  1045.         For foo = 1 To OtlSet.DisplayCount
  1046.             If Otldat(OtlSet.DisplayIdx(foo)).VisibleIdx = ScrollValue Then
  1047.                 OtlSet.CurrentLine = foo
  1048.                 OtlSet.SelectIdx = OtlSet.DisplayIdx(foo)
  1049.                 OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  1050.             End If
  1051.         Next foo
  1052.     End If
  1053. End If
  1054. OtlPic.SetFocus
  1055. End Sub
  1056.  
  1057. 'Initializes the parameters for a code-based outline control
  1058.  
  1059. Sub OutlineSetup(OtlPic As Control, OtlScroll As Control, OtlSet As OtlSetup, DataFields As String, Bmps As Boolean, Lines As Boolean, Plus As Boolean, Checkmarks As Boolean, SelectColor As Long, SelectTextColor As Long, BmpField As String, CheckmarkField As String)
  1060. 'Initializes the OtlSetup control psuedo-properties
  1061. 'Note: if using bitmaps for bullets, must have pic loaded for branch open, closed, and leaf
  1062. Dim foo As Integer
  1063. 'Dim VarArr() As String
  1064. 'ReDim VarArr(0) As String
  1065.  
  1066. 'OtlScroll.Move OtlPic.ScaleWidth - OtlScroll.Width, 0, OtlScroll.Width, OtlPic.ScaleHeight
  1067. OtlScroll.Move OtlPic.Width - OtlScroll.Width, 0, OtlScroll.Width, OtlPic.Height
  1068.  
  1069. 'removed for test - kdq
  1070. 'foo = Parse2Array(DataFields, VarArr(), ",")
  1071. 'DoEvents
  1072. 'OtlSet.Levels = UBound(VarArr) + 1
  1073.  
  1074. 'Erase OtlSet.VariableNames()
  1075. 'For foo = 0 To OtlSet.Levels - 1
  1076. '    OtlSet.VariableNames(foo) = Trim$(VarArr(foo))
  1077. 'Next foo
  1078.  
  1079. If BmpField > "" Then OtlSet.BmpField = BmpField Else OtlSet.BmpField = ""
  1080. OtlSet.VisChangeFlag = True 'force first count
  1081. If Bmps Then OtlSet.BmpFlag = 1 Else OtlSet.BmpFlag = 0
  1082. If Lines Then OtlSet.LineFlag = 1 Else OtlSet.LineFlag = 0
  1083. If Plus Then OtlSet.PlusFlag = 1 Else OtlSet.PlusFlag = 0
  1084. If Checkmarks Then OtlSet.CheckmarkFlag = True Else OtlSet.CheckmarkFlag = False
  1085. OtlSet.CheckmarkField = CheckmarkField
  1086. OtlSet.LineHeight = OtlPic.TextHeight("X") '* 1.1
  1087.  
  1088. 'If OtlSet.LineHeight Mod Screen.TwipsPerPixelY <> 0 Then OtlSet.LineHeight = (OtlSet.LineHeight \ Screen.TwipsPerPixelY) * Screen.TwipsPerPixelY + Screen.TwipsPerPixelY
  1089. OtlSet.LineHeight = OtlSet.LineHeight + ((OtlSet.LineHeight \ Screen.TwipsPerPixelY) Mod 4) * Screen.TwipsPerPixelY
  1090.  
  1091. OtlSet.DisplayLines = OtlPic.Height \ OtlSet.LineHeight
  1092. Erase OtlSet.DisplayIdx
  1093. OtlSet.SelectColor = SelectColor
  1094. OtlSet.SelectTextColor = SelectTextColor
  1095. OtlSet.TopIdx = 1
  1096. OtlSet.SelectIdx = 1
  1097. OtlSet.PrevTop = -1
  1098. OtlSet.PrevSel = -1
  1099.  
  1100. End Sub
  1101.  
  1102. 'Stretches a picture to a region in Destination
  1103.  
  1104. Sub StrBltAllToPoint(dest As Object, dX As Integer, dY As Integer, dWidth As Integer, dHeight As Integer, source As Control)
  1105. Dim foo As Integer, DestHoldMode As Integer, SrcHoldMode As Integer
  1106.  
  1107. DestHoldMode = dest.ScaleMode
  1108. dest.ScaleMode = 3 'Pixels
  1109. SrcHoldMode = source.ScaleMode
  1110. source.ScaleMode = 3 'Pixels
  1111.  
  1112. foo = StretchBlt(dest.hDC, dX, dY, dWidth, dHeight, source.hDC, 0, 0, source.ScaleWidth, source.ScaleHeight, &HCC0020)
  1113.  
  1114. dest.ScaleMode = DestHoldMode
  1115. source.ScaleMode = SrcHoldMode
  1116.  
  1117. End Sub
  1118.  
  1119.