Attribute VB_Name = "Module1"
'#Uses "..\include\Const.inc"
'#Uses "..\include\Install.inc"

Option Explicit
'*****************************************************************************
' Module:
'        GRAPH
'-----------------------------------------------------------------------------
' Description:
'        This file contains functions which are create controls for the
'        module 'GRAPH'.
'        Furthermore it contains functions for the event handling of
'        these controls.
'
'-----------------------------------------------------------------------------
' History:
'
'        Rev. Author         Date        Description
'        ---------------------------------------------------------------------
'        0.0  Sunil          06.10.04    initial version
'
'
'
'*****************************************************************************

'*****************************************************************************
'Description:
'        This function is called from DAvE just before the Graphics
'        window is shown.
'-----------------------------------------------------------------------------
'Parameters:
'        gc              reference to the Graphics object
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Function OnLoad(gc As GraphicConfigure) As Boolean
    On Error GoTo OnLoadError

    OnLoad = False
    
    '------------------------------------------------------
    ' load the back image
    '------------------------------------------------------
    If (Not InstallBackimage(gc)) Then Exit Function

    '------------------------------------------------------
    ' create the hotspots
    '------------------------------------------------------
    If (Not InstallHotspots(gc)) Then Exit Function

    OnLoad = True
    Exit Function

OnLoadError:
'    ErrorBox "Error in Function OnLoad", Err.Description
    Exit Function
End Function

'*****************************************************************************
'Description:
'          This function will be called if mask should be closed
'          and closing can NOT be canceled
'-----------------------------------------------------------------------------
'Parameters:
'        gc              reference to the Graphics object
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Function OnTerminate(gc As GraphicConfigure) As Boolean
    On Error Resume Next

    OnTerminate = True
End Function

'*****************************************************************************
'Description:
'          This function will be called if mask should be closed
'          and closing can be canceled
'-----------------------------------------------------------------------------
'Parameters:
'        gc              reference to the Graphics object
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Function OnCancelTerminate(gc As GraphicConfigure) As Boolean
    On Error Resume Next
    '------------------------------------------------------
    ' ask user if he wants to close the project
    '------------------------------------------------------
    If (Ask(MSG_CLOSE_PROJECT)) Then
        ' close the project
        ObjectCollection("Main").ProjectClose
        OnCancelTerminate = False
    Else
        OnCancelTerminate = True
    End If
End Function

'*****************************************************************************
'Description:
'          This function will be called if the user clicks on a
'          menu entry of a hotspot
'-----------------------------------------------------------------------------
'Parameters:
'        gc              reference to the Graphics object
'        Name            key of the menu entry
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Function OnHotspotMenuClick(gc As GraphicConfigure, Name As String) As Boolean
    On Error Resume Next
    OnHotspotMenuClick = True
End Function

'*****************************************************************************
'Description:
'          This function will be called if the user clicks the
'          right mouse button over a hotspot
'-----------------------------------------------------------------------------
'Parameters:
'        gc              reference to the Graphics object
'        key             key of the hotspot
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Function OnHotspotRightMouseButton(gc As GraphicConfigure, Key As String) As Boolean
    On Error Resume Next
    OnHotspotRightMouseButton = True
End Function

'*****************************************************************************
'Description:
'-----------------------------------------------------------------------------
'          This function will be called if the user clicks on a
'          highlighted hotspot
'Parameters:
'        gc              reference to the Graphics object
'        key             key of the hotspot
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Function OnHotspotClick(gc As GraphicConfigure, Key As String) As Boolean
    On Error GoTo OnHotspotClickError

    OnHotspotClick = False

    Dim p As Peripherals
    Dim cp As DAvECollection

        Set cp = ObjectCollection("MODULENAMES")
        
        Set p = New Peripherals
        Set p.ProjectData = gc.ProjectData
        p.Caption = cp(Key).ModuleDescription
        p.Scriptfile = DefGetPath("Scripts") & cp(Key).ModuleDirectory & "\Dialog.dave"
        p.Parameters.Add ("x")
        p.Parameters.v("x") = cp(Key).ParameterValue
        p.Show


    OnHotspotClick = True
    Exit Function

OnHotspotClickError:
    Errorbox "Can not process the click ", Err.Description
    Exit Function
End Function

