Use DFAllEnt.pkg
Use cCJStandardCommandBarSystem.pkg
Use cCJCommandBarSystem.pkg
Use cCJSkinFramework.pkg
Use SourceCode.inc
Use vWin32fh.pkg

Object oHtmlHelp is a cHtmlHelp
End_Object

Object oApplication is a cApplication
    Set peHelpType to htHtmlHelp
    Set psProduct to "DataFlex Source Code Tools"

    Property String psAutoLoadAppSrc
    Property String psFileCompareApp
    Property Boolean pbCodeIndent False

    // Enable to pass a path to an folder or filename on the command line.
    // Or add something like this to the Studio's Tools menu:
    // To activate the CleanMarkers view:
    // Label:                Command:                                                 Parameters:
    // "Cleanup Source Code" "C:\Projects\CleanMarkers\Programs\SourceCodeTools.exe" "<project>" "/c"
    // ...or to activate the CodeIndent view:
    // Label:                Command:                                                 Parameters:
    // "Cleanup Source Code" "C:\Projects\CleanMarkers\Programs\SourceCodeTools.exe" "<file>" "/i"
    Procedure OnCreate
        Handle hoCommandLine
        Integer iArgs
        String sValue sDirSep sFlag sCompareApp

        Forward Send OnCreate
        Get phoCommandLine of ghoApplication to hoCommandLine
        If (hoCommandLine > 0) Begin
            Get Argument of hoCommandLine 1 to sValue
            Get Argument of hoCommandLine 2 to sFlag
            Move (Uppercase(sFlag)) to sFlag
            Set pbCodeIndent to (sFlag = "/I")
            If (pbCodeIndent(Self) = False) Begin
                Get ParseFolderName sValue to sValue
            End
            Move (SysConf(SYSCONF_DIR_SEPARATOR)) to sDirSep  // normally \ (backslash)
            Move (Trim(sValue)) to sValue
            If (Right(sValue, 1) = sDirSep) Begin
                Move (Left(sValue, (Length(sValue) -1))) to sValue
            End
            Set psAutoLoadAppSrc to sValue
        End
        
        Get ReadString "" "FileCompare" "" to sCompareApp
        Set psFileCompareApp to sCompareApp
        
    End_Procedure

    // Returns the current Studio "File mask" setting as a string. See
    Function StudioFileMaskSettings Returns String
        Handle hoReg
        String sStudioRegPath sRetval sDFVersion
        Boolean bExists bOk
        Integer iMajorVersion iMinorVersion

        Move FMAC_VERSION  to iMajorVersion
        Move FMAC_REVISION to iMinorVersion
        Move (String(iMajorVersion) + "." + String(iMinorVersion)) to sDFVersion

        Get Create (RefClass(cRegistry)) to hoReg
        Set pfAccessRights of hoReg to Key_Read

        Move CS_StudioToolsPathStart to sStudioRegPath
        Move (sStudioRegPath + sDFVersion + CS_StudioToolsPathEnd) to sStudioRegPath
        Set phRootKey of hoReg to HKEY_CURRENT_USER

        // First check if the VDF version is installed
        Get KeyExists of hoReg sStudioRegPath to bExists
        If (bExists = False) Begin
            Send Destroy of hoReg
            Function_Return cx_RegKeyVDFKeyDoesNotExist
        End

        Get OpenKey of hoReg sStudioRegPath to bOk
        If (bOk = True) Begin
            Set pfAccessRights of hoReg to KEY_READ
            Get ReadString of hoReg CS_VdfExtensionsKey to sRetval
        End

        Send CloseKey of hoReg
        Send Destroy of hoReg
        Function_Return sRetval
    End_Function

    // Returns the current Studio "Code-Editor" key value setting as a string.
    Function StudioCodeEditorSettings String sKey Boolean bDword Returns String
        Handle hoReg
        String sStudioRegPath sRetval sDFVersion
        Boolean bExists bOk
        Integer iMajorVersion iMinorVersion

        Move FMAC_VERSION  to iMajorVersion
        Move FMAC_REVISION to iMinorVersion
        Move (String(iMajorVersion) + "." + String(iMinorVersion)) to sDFVersion

        Get Create (RefClass(cRegistry)) to hoReg
        Move CS_StudioToolsPathStart to sStudioRegPath
        Move (sStudioRegPath + sDFVersion + CS_StudioCodeEditorPath) to sStudioRegPath
        Set phRootKey of hoReg to HKEY_CURRENT_USER

        // First check if the DF version is installed
        Get KeyExists of hoReg sStudioRegPath to bExists
        If (bExists = False) Begin
            Send Destroy of hoReg
            Function_Return cx_RegKeyVDFKeyDoesNotExist
        End

        Get OpenKey of hoReg sStudioRegPath to bOk
        If (bOk = True) Begin
            Set pfAccessRights of hoReg to KEY_READ
            If (bDword = True) Begin
                Get ReadDword  of hoReg sKey to sRetval
            End
            Else Begin
                Get ReadString of hoReg sKey to sRetval
            End
        End

        Send CloseKey of hoReg
        Send Destroy of hoReg
        Function_Return sRetval
    End_Function

    Procedure Set FileCompareApp String sCompareApp
      Send WriteString "" "FileCompare" sCompareApp
      Set psFileCompareApp To sCompareApp
    End_Procedure

    Function FileCompareApp Returns String
      String sCompareApp
      Get psFileCompareApp to sCompareApp
      Function_Return sCompareApp
    End_Function

End_Object

Use cToolTipController.pkg
Object oToolTipController is a cToolTipController
    Move Self to ghoToolTipController
    Set piIcon to TTI_INFO
    Set psTitle to "Information"
    Set piMaxWidth to 400
    Set piDurationPopup to 14000    // 14 seconds, needed for long tooltips.
    Set pbUsePrefix to True
End_Object

Object oCJSkinFramework is a cCJSkinFramework
    Set pbLoadPreference to True
End_Object

Use oEditContextMenu.pkg
Use oDEOEditContextMenu.pkg
Use cSkinComboBoxCJMenuItem.pkg

Object oMain is a Panel
    Set Label to "DataFlex Source Code Tools"
    Set Location to 13 19
    Set Size to 305 540
    Set piMinSize to 305 540 
    Set Locate_Mode to Center_On_Screen

    Object oCJCommandBarSystem is a cCJCommandBarSystem
        Set pbTimerUpdate to True
        #IF (!@ >= 190)
            Set pbAutoResizeIcons to True
            Set pbTabbedWorkspaces to True // Switch on for DF 19 to see the new tabbed-view look.
            Set peVisualTheme to xtpThemeVisualStudio2008
        #ENDIF

        Procedure OnCreateCommandBars
            Forward Send OnCreateCommandBars
            #IF (!@ < 190)
            Send DisplayTabWorkspace
            #ENDIF
        End_Procedure

        #IF (!@ < 190)
        Procedure DisplayTabWorkspace
            Variant vTab vPaintManager
            Handle hoTab hoPaintManager  hoOptions
            Integer iSize

            If (not(IsComObjectCreated(Self))) Begin
                Procedure_Return
            End

            Get OptionsObject to hoOptions

            // Create the tab workspace object. It will get created for the Client_Area so
            // each view will be displayd on a separate tab-page (instead of the standard VDF MDI-interface)
            Get Create (RefClass(cCJTabWorkspace)) to hoTab
            Get ComShowTabWorkspace True to vTab
            // Connect the CodeJock side to the DataFlex proxy object.
            Set pvComObject  of hoTab to vTab

            Set ComFlags of hoTab to xtpWorkspaceShowCloseTab
            Send ComEnableGroups of hoTab

            // Create a paint manager object that is needed to set some
            // of the tab-workspace properties.
            Get Create (RefClass(cCJTabPaintManager)) to hoPaintManager
            Get ComPaintManager of hoTab          to vPaintManager
            Set pvComObject     of hoPaintManager to vPaintManager
            // This will truncate the middle part of long items
            Set ComDrawTextPathEllipsis of hoPaintManager to True
            Move 24 to iSize
            Send ComSetIconSize         of hoOptions False iSize iSize  // Set icon size for Toolbar buttons.
            Send ComSetIconSize         of hoPaintManager iSize iSize   // Set icon size for Tab-workspace.

            Send ComRecalcLayout
            Send Destroy of hoTab
            Send Destroy of hoPaintManager
        End_Procedure
        #ENDIF
        
        #IF (!@ >= 190)
        Procedure OnCreateTabbedWorkspace Handle hoTabWorkspace Handle hoTabPaintManager
            Set ComShowIcons of hoTabPaintManager to True
            Send ComSetIconSize of hoTabPaintManager 24 24

            // This will truncate the middle part of long items
            Set ComDrawTextPathEllipsis of hoTabPaintManager to True
        End_Procedure
        #ENDIF

        Object oCJSkinsToolbar is a cCJToolbar

            Object oSkinsDummyMenuItem is a cCJMenuItem
                Set psImage to "Skins024N32.ico"
                Set peControlStyle to xtpButtonIconAndCaption
                Set peControlType to xtpControlLabel
            End_Object

            Object oSkinsMenuItem is a cSkinComboBoxCJMenuItem
            End_Object

            Object oAbout_MenuItem is a cCJMenuItem
                Set psCaption to "About"
                Set psToolTip to "About Info"
                Set psDescription to "About the program"
                Set psImage to "ActionAbout.ico"
                Set pbControlBeginGroup to True
                Procedure OnExecute Variant vCommandBarControl
                    Forward Send OnExecute vCommandBarControl
                    Send Activate_About of (Client_Id(ghoCommandBars))
                End_Procedure
            End_Object

            Object oExitMenuItem is a cCJExitMenuItem
                Set psImage to "ActionExit.ico"
                Set psToolTip to "Exit"
                Set psDescription to "Exit the program (Alt+F4)"
                Set pbControlBeginGroup to True
            End_Object

        End_Object

        Object oStatusBar is a cCJStatusBar

            Object oStatusPane1 is a cCJStatusBarPane
                Set piID to sbpIDIdlePane
                Set pbStyleStretch to True
            End_Object

            Object oStatusPane2 is a cCJStatusBarPane
                Set phoViewPane to Self
                Set pbStyleStretch to True
            End_Object

        End_Object

    End_Object


    Object oClientArea is a ClientArea
        Use StdAbout.pkg
        Use CleanMarkers.vw
        Use CodeIndent.vw
        Use CleanMarkersSetup.dg

        Procedure Activate_About
            Send DoAbout "DataFlex Source Code Tools" "" "" "Authors: Marcia Booth, Allan Kim Eriksen, Chris Spencer, Bob Worsley, Wil van Antwerpen and Nils G. Svedmyr" "CleanMarkers80x80.bmp"
        End_Procedure

        On_Key Key_Ctrl+Key_Tab           Send Switch_Next_View
        On_Key Key_Ctrl+Key_Shift+Key_Tab Send Switch_Prior_View
        On_Key Key_Ctrl+Key_F4            Send None
    End_Object

End_Object

Start_UI
