home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "PolarDraw"
- 'this module contains some functions and declarations needed
- 'in this application
- 'those are functions for easier manipulation of Polar Draw instance
-
- Public pd_Page As POLARDRAW20Lib.Page
- Public pd_Environment As POLARDRAW20Lib.Environment
- Public pd_Shapes As POLARDRAW20Lib.Shapes
- Public pd_Selection As POLARDRAW20Lib.Selection
- Public pd_Window As POLARDRAW20Lib.Window
- Public pd_HorGuides As POLARDRAW20Lib.Guidelines
- Public pd_VertGuides As POLARDRAW20Lib.Guidelines
- Public arr_ShapeTypeConstants As Variant
- Public arr_ShapeTypeNames As Variant
-
- Public Sub SetShapeTypes()
- arr_ShapeTypeConstants = Array(polArc, polDiamond, polDimensionBar, polEllipse, polFreeform, polHexagon, polIsoscelesTriangle, polLeftArrow, polLine, polLink, polOctagon, polParallelogram, polPentagon, polPlainText, polPlusSign, polRectangle, polRightTriangle, polRoundRectangle, polStar, polTextBox, polTrapezoid)
- arr_ShapeTypeNames = Array("Arc", "Diamond", "Dimension Bar", "Ellipse", "Freeform", "Hexagon", "Isosceles Triangle", "Left Arrow", "Line", "Link", "Octagon", "Parallelogram", "Pentagon", "Plain Text", "Plus Sign", "Rectangle", "Right Triangle", "Round Rectangle", "Star", "Text Box", "Trapezoid")
-
- End Sub
- Public Sub SetEditMode(EditType As polEditMode, TypeOfShape As polShapeType, TypeOfPolygon As polPolygonTypes)
- 'This sub sets current edit mode and shape type according to the sent parameters
- 'if edit mode isn't CreateNew, TypeOfShape and TypeOfPolygon must be sent as -1
- If pd_Environment.EditMode = -1 Then Exit Sub
- With pd_Environment
- .EditMode = EditType
- If TypeOfShape <> -1 Then
- .CurrentShapeType = TypeOfShape
- If .CurrentShapeType = polLink Then
- .Root.ShowConnectors = True
- Else
- .Root.ShowConnectors = False
- End If
- End If
- If TypeOfPolygon <> -1 Then .CurrentPolygonType = TypeOfPolygon
- End With
-
- End Sub
-
- Public Sub FreeObjects()
- Set pd_Page = Nothing
- Set pd_Window = Nothing
- Set pd_Environment = Nothing
- Set pd_Shapes = Nothing
- Set pd_Selection = Nothing
-
- Set pd_HorGuides = Nothing
- Set pd_VertGuides = Nothing
- End Sub
- Public Sub CreateObjects()
- Set pd_Page = frmDrawVB.POLARDraw1.ActivePage
- Set pd_Window = frmDrawVB.POLARDraw1.ActiveWindow
- Set pd_Environment = frmDrawVB.POLARDraw1.ActiveWindow.Environment
- Set pd_Shapes = pd_Page.Shapes
- Set pd_Selection = pd_Page.Selection
-
- End Sub
-
- Public Function SelectionExists() As Boolean
- If pd_Selection.ShapeRange Is Nothing Then
- MsgBox "Nothing selected!", vbExclamation, "Warning"
- SelectionExists = False
- Else
- If pd_Selection.ShapeRange.Count < 1 Then
- MsgBox "Nothing selected!", vbExclamation, "Warning"
- SelectionExists = False
- Else
- SelectionExists = True
- End If
- End If
- End Function
-
- Public Sub SetEnvironment()
- With pd_Environment
- .EditMode = polResize
- .RulerMeasurementUnits = polUnitsMilimeter
- .ShowHorizontalRuler = True
- .ShowHorizontalScrollBar = True
- .ShowVerticalRuler = True
- .ShowVerticalScrollBar = True
- .ShowGrid = True
- .ShowGuidelines = True
- End With
-
- pd_Window.CenterPage
- pd_Environment.Root.MeasurementUnits = polUnitsMilimeter
- pd_Environment.Root.AllowErrorReporting = True
- Set pd_HorGuides = pd_Page.HorGuidelines
- Set pd_VertGuides = pd_Page.VertGuidelines
- pd_HorGuides.Add 0.1 * pd_Page.Height
- pd_HorGuides.Add 0.9 * pd_Page.Height
- pd_VertGuides.Add 0.1 * pd_Page.Width
- pd_VertGuides.Add 0.9 * pd_Page.Width
- SetShapeTypes
- End Sub
- Function GetShapeType(lShapeID As Long) As Long
- For i = 1 To UBound(arr_ShapeTypeConstants)
- If pd_Shapes.ItemFromID(lShapeID).Type = arr_ShapeTypeConstants(i) Then
- MsgBox arr_ShapeTypeNames(i)
- GetShapeType = arr_ShapeTypeConstants(i)
- Exit Function
- End If
- Next i
- End Function
-