home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2002 March / PCWMAR02.iso / software / turbocad / v8trial / TurboCADv8ProfessionalNoReg.exe / Data.Cab / F41941_modStyles.bas < prev    next >
Encoding:
BASIC Source File  |  2001-10-16  |  5.5 KB  |  178 lines

  1. Attribute VB_Name = "modStyles"
  2. '******************************************************************'
  3. '*                                                                *'
  4. '*                      TurboCAD for Windows                      *'
  5. '*                   Copyright (c) 1993 - 2001                    *'
  6. '*             International Microcomputer Software, Inc.         *'
  7. '*                            (IMSI)                              *'
  8. '*                      All rights reserved.                      *'
  9. '*                                                                *'
  10. '******************************************************************'
  11.  
  12. Option Explicit
  13.  
  14. Sub ShowLineStyles()
  15.     On Error Resume Next
  16.     Dim st As IMSIGX.LineStyle
  17.     Debug.Print "LineStyles"
  18.     For Each st In ActiveDrawing.LineStyles
  19.         ShowLineStyle st
  20.     Next
  21. End Sub
  22.  
  23. Sub ShowProperties(ByVal props As IMSIGX.Properties)
  24.     On Error Resume Next
  25.     Dim prop As IMSIGX.Property
  26.     Debug.Print "Properties"
  27.     For Each prop In props
  28.         ShowProperty prop
  29.     Next
  30. End Sub
  31.  
  32. Sub ShowProperty(ByVal prop As IMSIGX.Property)
  33.     On Error Resume Next
  34.     Debug.Print "Property"
  35.     Debug.Print " Name: " & prop.Name
  36.     Debug.Print " Type: " & prop.Type
  37.     Debug.Print " Value: " & prop.Value
  38. End Sub
  39.  
  40. Function FindNamedColor(ByVal clr As Long, maxDist As Long) As IMSIGX.NamedColor
  41.     On Error Resume Next
  42.     Dim nclr, best As IMSIGX.NamedColor
  43.     Dim tr, tg, tb As Long
  44.     Dim dr, dg, db, i As Long
  45.     Set best = Nothing
  46.     tr = clr Mod 256&
  47.     tg = (clr \ 256&) Mod 256&
  48.     tb = (clr \ (256& * 256&)) Mod 256&
  49.     Debug.Print Application.NamedColors.Count; " named colors"
  50.     i = 0
  51.     For Each nclr In Application.NamedColors
  52.         clr = nclr.Color
  53.         If clr >= 0 Then
  54.             dr = clr Mod 256&
  55.             dg = (clr \ 256&) Mod 256&
  56.             db = (clr \ (256& * 256&)) Mod 256&
  57.             dr = tr - dr
  58.             If dr < 0 Then dr = -dr
  59.             dg = tg - dg
  60.             If dg < 0 Then dg = -dg
  61.             db = tb - db
  62.             If db < 0 Then db = -db
  63.             Debug.Print "(" & i & ") " & nclr.Name & " " & dr & " " & dg & " " & db
  64.             If dr < maxDist And dg < maxDist And db < maxDist Then
  65.                 If dr < dg Then
  66.                     maxDist = dr
  67.                 Else
  68.                     maxDist = dg
  69.                 End If
  70.                 If db < maxDist Then
  71.                     maxDist = db
  72.                 End If
  73.                 Set best = nclr
  74.                 If maxDist = 0 Then Exit For
  75.             End If
  76.         End If
  77.         i = i + 1
  78.     Next
  79.     Set FindNamedColor = best
  80. End Function
  81.  
  82. Sub ShowColorProperty(ByVal prop As IMSIGX.Property)
  83.     On Error Resume Next
  84.     Dim r, g, b, clr, maxDist As Long
  85.     Dim nclr As IMSIGX.NamedColor
  86.     Debug.Print prop.Name
  87.     clr = prop.Value
  88.     If clr >= 0 Then
  89.         r = clr Mod 256&
  90.         g = (clr \ 256&) Mod 256&
  91.         b = (clr \ (256& * 256&)) Mod 256&
  92.         Debug.Print clr & " (&H" & Hex$(clr) & ") = RGB(" & r & ", " & g & ", " & b & ")"
  93.         maxDist = 10
  94.         Set nclr = FindNamedColor(clr, maxDist)
  95.         If Not nclr Is Nothing Then
  96.             Debug.Print "->" & nclr.Name
  97.         End If
  98.     Else
  99.         Debug.Print clr
  100.     End If
  101. End Sub
  102.  
  103. Sub ShowBrushStyles()
  104.     On Error Resume Next
  105.     Dim st As IMSIGX.BrushStyle
  106.     Debug.Print "BrushStyles"
  107.     For Each st In ActiveDrawing.BrushStyles
  108.         ShowBrushStyle st
  109.     Next
  110. End Sub
  111.  
  112. Sub ShowLineStyle(ByVal st As IMSIGX.LineStyle)
  113.     On Error Resume Next
  114.     Dim j As Long
  115.     Dim dashes As Variant
  116.     Debug.Print "LineStyle"
  117.     Debug.Print " Name: " & st.Name
  118.     Debug.Print " Description: " & st.Description
  119.     Debug.Print " PatternLength: " & st.PatternLength
  120.     Debug.Print " Dashes"
  121.     st.GetDashes dashes
  122.     For j = LBound(dashes) To UBound(dashes)
  123.         Debug.Print "  (" & j & ") " & dashes(j)
  124.     Next j
  125. End Sub
  126.  
  127. Sub ShowBrushStyle(ByVal st As IMSIGX.BrushStyle)
  128.     On Error Resume Next
  129.     Debug.Print "BrushStyle"
  130.     Debug.Print " Name: " & st.Name
  131.     Debug.Print " Description: " & st.Description
  132.     Debug.Print " Type: " & st.Type
  133.     Debug.Print " Color: " & st.Color
  134.     Debug.Print " Bitmap: " & st.Bitmap
  135.     Debug.Print " HatchStyle: " & st.HatchStyle
  136.     ShowBrushPatterns st.Patterns
  137. End Sub
  138.  
  139. Sub ShowBrushPatterns(ByVal pats As IMSIGX.BrushPatterns)
  140.     On Error Resume Next
  141.     Debug.Print "BrushPatterns"
  142.     Dim pat As IMSIGX.BrushPattern
  143.     For Each pat In pats
  144.         ShowBrushPattern pat
  145.     Next pat
  146. End Sub
  147.  
  148. Sub ShowBrushPattern(ByVal pat As IMSIGX.BrushPattern)
  149.     On Error Resume Next
  150.     Dim dashes As Variant
  151.     Dim i, j As Long
  152.     Dim x, y, w, h, a As Double
  153.     Debug.Print "BrushPattern"
  154.     pat.GetItem i, dashes, x, y, w, h, a
  155.     Debug.Print " Item: " & i
  156.     Debug.Print " Dashes: "
  157.     For j = LBound(dashes) To UBound(dashes)
  158.         Debug.Print "  (" & j & ") " & dashes(j)
  159.     Next j
  160.     Debug.Print " X: " & x
  161.     Debug.Print " Y: " & y
  162.     Debug.Print " Width: " & w
  163.     Debug.Print " Height: " & h
  164.     Debug.Print " Angle: " & a
  165. End Sub
  166.  
  167. Sub ShowSelStyles()
  168.     On Error Resume Next
  169.     Dim gr As Graphic
  170.     For Each gr In ActiveDrawing.Selection
  171.         DebugPrint "Graphic -- " & gr.Type
  172.         ShowLineStyle gr.LineStyle
  173.         ShowBrushStyle gr.BrushStyle
  174.         ShowColorProperty gr.Properties("PenColor")
  175.         ShowColorProperty gr.Properties("BrushColor")
  176.     Next
  177. End Sub
  178.