home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / ADDONINC.PAK / ITOOL.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  9.5 KB  |  293 lines

  1. /*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2.  
  3.    itool.h
  4.    Created: 09/27/95
  5.    Copyright (c) 1995, Borland International
  6.    $Header:   Y:/ADMIN/BRIDE/ADDON/DELIVER/INTERFAC/ITOOL.H_V   1.22   16 Jan 1997 14:47:32   JDOUGLAS  $
  7.    $Revision:   1.22  $
  8.  
  9.    Tool Interface
  10.  
  11.    This interface is one of several being brought forward from BC4.x IdeHook
  12.    interface.
  13.  
  14.    There are a few changes:
  15.  
  16.    The "ToolInfo" struct has been replaced with an interface, IToolInfo.
  17.  
  18.    The major change in the Tool interface involves a new mechanism for
  19.    registering tool entry points for non-standalone tools. Instead of
  20.    submitting an array of entry points that are methods on your derived
  21.    'ToolClient' class, you now derive a class from IToolImplementor for
  22.    each of this kind of tool and register a pointer to it using the
  23.    'SetImplementor' method of the IToolInfo interface. This and the other
  24.    IToolInfo information you provide is then submitted to IToolServer through
  25.    its 'ToolAdd' method.
  26.  
  27.    PolyStrings are used instead of char pointers.
  28.  
  29.    For other minor changes, see 'IDEHOOK CHANGES' comments.
  30.  
  31. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/
  32.  
  33. #ifndef __ITOOL_H
  34. #define __ITOOL_H
  35.  
  36. #include <objbase.h>
  37. #include <ideaddon\common.h>
  38. #include <ideaddon\ipolystr.h>
  39. #include <ideaddon\istatus.h>
  40. #include <ideaddon\itool.uid>
  41. #include <ideaddon\itoolinf.uid>
  42. #include <ideaddon\itoolexe.uid>
  43.  
  44. enum ToolLaunchType
  45. {
  46.    //
  47.    // 'StandAlone' refers to tools that run as seperate tasks and 'Callback'
  48.    // refers to tools that are launched through the 'IToolImplementor::Execute'
  49.    // Method (See IToolImplementor, below).
  50.    //
  51.    TLT_StandAlone,
  52.    TLT_Callback = -1
  53. };
  54.  
  55. enum ToolTypes
  56. {
  57.     TT_UserBase = -6,
  58.          TT_DepChecker,
  59.     TT_Transfer,
  60.     TT_Viewer,
  61.     TT_Translator
  62. };
  63.  
  64. #define TIFlag_TargetTranslator     0x00000001L
  65. #define TIFlag_ReadOnly             0x00000100L       // tool can't be renamed or removed
  66. #define TIFlag_OnLocalMenu          0x00001000L
  67. #define TIFlag_OnToolsMenu          0x00002000L
  68. #define TIFlag_OnFileOpenMenu       0x00010000L
  69. #define TIFlag_OnFileNewMenu        0x00020000L
  70.  
  71. enum ToolReturn
  72. {
  73.      TR_NotHandled = -1,
  74.      TR_Success,
  75.      TR_Warnings,
  76.      TR_Errors,
  77.      TR_FatalError
  78. };
  79.  
  80.  
  81. //.............................................................................
  82. //
  83. // IToolImplementor
  84. //
  85. // Derive a class from this interface for each tool for which you wish to
  86. // register an entry point. The entry point will be the 'Execute' method.
  87. //
  88. // Use the 'SetImplementor' method of IToolInfo to register your
  89. // IToolImplementor interface with IToolServer through its 'AddTool' method.
  90. //
  91. // Warning! Please see the warning in ISCRIPT.H concerning calling through the
  92. // IScriptServer interface from within the IToolImplementor::Execute() method.
  93. //
  94. //.............................................................................
  95. class IToolImplementor : public IUnknown
  96. {
  97.  public:
  98.    virtual ToolReturn BCWADDON_CMETHOD Execute(
  99.                         IPolyString * cmdLine,
  100.                         ProjectNode * nodeArray,
  101.                         int numNodes ) = 0;
  102. };
  103.  
  104. //.............................................................................
  105. class IToolInfo : public IUnknown
  106. {
  107.  public:
  108.    virtual ToolTypes BCWADDON_CMETHOD GetTypes() = 0;
  109.    virtual void BCWADDON_CMETHOD SetTypes( ToolTypes types ) = 0;
  110.  
  111.    virtual IPolyString * BCWADDON_CMETHOD GetName() = 0;
  112.    virtual void BCWADDON_CMETHOD SetName( IPolyString * name ) = 0;
  113.  
  114.    virtual IPolyString * BCWADDON_CMETHOD GetPath() = 0;
  115.    virtual void BCWADDON_CMETHOD SetPath( IPolyString * path ) = 0;
  116.  
  117.    virtual unsigned BCWADDON_CMETHOD GetFlags() = 0;
  118.    virtual void BCWADDON_CMETHOD SetFlags( unsigned flags ) = 0;
  119.  
  120.    virtual IPolyString * BCWADDON_CMETHOD GetMenuName() = 0;
  121.    virtual void BCWADDON_CMETHOD SetMenuName( IPolyString * menuName ) = 0;
  122.  
  123.    virtual IPolyString * BCWADDON_CMETHOD GetHelpHint() = 0;
  124.    virtual void BCWADDON_CMETHOD SetHelpHint( IPolyString * helpHint ) = 0;
  125.  
  126.    virtual IPolyString * BCWADDON_CMETHOD GetDefCmdLine() = 0;
  127.    virtual void BCWADDON_CMETHOD SetDefCmdLine( IPolyString * defCmdLine ) = 0;
  128.  
  129.    //
  130.    // IDEHOOK CHANGES:
  131.    // - This was a union of 'appliesTo' and 'translateFrom' in 'ToolInfo'
  132.    //
  133.    virtual IPolyString * BCWADDON_CMETHOD GetSupportedTypes() = 0;
  134.    virtual void BCWADDON_CMETHOD SetSupportedTypes( IPolyString * supported ) = 0;
  135.  
  136.    //
  137.    // 'DefaultFor' objects will use this tool as the default tool.
  138.    // e.g. ".c;.cpp"
  139.    //
  140.    virtual IPolyString * BCWADDON_CMETHOD GetDefaultForTypes() = 0;
  141.    virtual void BCWADDON_CMETHOD SetDefaultForTypes( IPolyString * defaultForTypes ) = 0;
  142.  
  143.    virtual IPolyString * BCWADDON_CMETHOD GetTranslateTo() = 0;
  144.  
  145.    //
  146.    // SetTranslateTo()
  147.    // Tip: Don't stick a semi-colon at the end of the translateTo file
  148.    // type or the ide's make engine will not properly recognize the existence
  149.    // of the output file.
  150.    //
  151.    virtual void BCWADDON_CMETHOD SetTranslateTo( IPolyString * translateTo ) = 0;
  152.  
  153.    //
  154.    // IDEHOOK_CHANGES:
  155.    // - This used to be called a ToolLaunchId
  156.    //
  157.    virtual ToolLaunchType BCWADDON_CMETHOD GetLaunchType() = 0;
  158.  
  159.    virtual void BCWADDON_CMETHOD SetImplementor( IToolImplementor * implementor ) = 0;
  160.    virtual IToolImplementor * BCWADDON_CMETHOD GetImplementor( void ) = 0;
  161. };
  162.  
  163.  
  164. //
  165. // flags for SetDependencyChekerID
  166. //
  167. #define MAKE_DEP_Collector  2
  168. #define MAKE_DEP_Auto       3
  169. #define MAKE_DEP_TimeStamp  4
  170. #define MAKE_DEP_Child      7
  171.  
  172. //
  173. // An IToolInfo2 pointer can be received through QueryInterface() on the
  174. // IToolInfo pointer returned from IToolServer::QueryToolInfo().
  175. // IToolInfo2 supports the IToolInfo methods plus two new ones.
  176. //
  177. class IToolInfo2 : IToolInfo {
  178.  public:
  179.    //
  180.    // Use SetDependencyCheckerID to change set the dependency checking scheme
  181.    // for a tool you are about to add using IToolServer::ToolAdd()
  182.    //
  183.    virtual void BCWADDON_CMETHOD SetDependencyCheckerID( int id ) = 0;
  184.    //
  185.    // Reserved for future use...
  186.    //
  187.    virtual int BCWADDON_CMETHOD GetDependencyCheckerID() = 0;
  188. };
  189.  
  190.  
  191. //
  192. // Addon's can use this interface to retrieve an interface to the status dialog
  193. // while a tool is being invoked. Call this from IToolImplementor::Execute function.
  194. //
  195.  
  196. class IToolInfo3 : public IToolInfo2
  197. {
  198.   public:
  199.     virtual IStatusDialog* BCWADDON_CMETHOD GetStatusDialog() = 0;
  200. };
  201.  
  202.  
  203. //.............................................................................
  204. //
  205. // IToolServer
  206. //
  207. // IDEHOOK CHANGES:
  208. // -  'ToolRegisterImplementor' is no longer provided. See 'SetImplementor'
  209. //    in the IToolInfo interface definition above.
  210. // -  New Methods:
  211. //       'CreateToolInfoInstance'
  212. //
  213. //.............................................................................
  214. class IToolServer : public IUnknown
  215. {
  216.  
  217.  public:
  218.    //
  219.    // The caller of 'CreateToolInfoInstance' is responsible for calling
  220.    // IToolInfo's 'Release' method when the interface is no longer needed.
  221.    //
  222.    virtual IToolInfo * BCWADDON_CMETHOD CreateToolInfoInstance() = 0;
  223.  
  224.    //
  225.    // Install a tool into the user's project
  226.    //
  227.    // IDEHOOK CHANGES:
  228.    // -  Now takes an IToolInfo pointer instead of a ToolInfo struct. Use
  229.    //    'CreateToolInfoInstance' to get an IToolInfo pointer. You can re-use
  230.    //    the IToolInfo object for subsequent 'ToolAdd' calls before
  231.    //    'Release'ing it if you like ('ToolAdd' will not reset its properties
  232.    //    to default settings, however).
  233.    //
  234.    //  Use ToolAdd to update an existing tool with new information such
  235.    //  as new paths, new implementor, etc..
  236.    //
  237.    //  Now returns the ToolObj of the tool if the operation was successful
  238.    //  or 0 if not.
  239.    //
  240.    virtual ToolObj BCWADDON_CMETHOD ToolAdd( IToolInfo * toolInfo ) = 0;
  241.  
  242.    //
  243.    // Query the existance of a tool in the current project
  244.    //
  245.    virtual ToolObj BCWADDON_CMETHOD ToolFind( IPolyString * name ) = 0;
  246.  
  247.    //
  248.    // Remove a tool from the current project
  249.    //
  250.    // IDEHOOK_CHANGES:
  251.    // -  Now takes a ToolObj instead of a name string. This used to do the
  252.    //    equivelant of a call to 'ToolFind' for every call to this method,
  253.    //    so now, call 'ToolFind' first if you don't already have the ToolObj.
  254.    //
  255.    virtual void BCWADDON_CMETHOD ToolRemove( ToolObj tool ) = 0;
  256.  
  257.    //
  258.    // Query the detailed information of a tool
  259.    //
  260.    // IDEHOOK CHANGES:
  261.    // -  Now returns an IToolInfo pointer instead of taking a reference to
  262.    //    a ToolInfo struct. The caller is responsible for calling 'Release'
  263.    //    on through the IToolInfo pointer when it is no longer needed.
  264.    //
  265.    virtual IToolInfo * BCWADDON_CMETHOD QueryToolInfo( ToolObj ) = 0;
  266.  
  267.    //
  268.    // Invoke any tool in the IDE. If 'ProjectNode' is zero, the
  269.    // tool is invoked on the 'currently selected object' in the
  270.    // IDE, as determined by the IDE.
  271.    //
  272.    virtual ToolReturn BCWADDON_CMETHOD ToolInvoke(
  273.                            ToolObj,
  274.                            ProjectNode = 0,
  275.                            IPolyString * cmdLineOverride = NULL ) = 0;
  276.  
  277.  
  278.    //
  279.    // This version of 'ToolInvoke' takes a file name instead of a project
  280.    // node.
  281.    //
  282.    virtual ToolReturn BCWADDON_CMETHOD ToolInvokeName(
  283.                             ToolObj,
  284.                             IPolyString * fileName,
  285.                             IPolyString * cmdLineOverride = 0 ) = 0;
  286.  
  287. };
  288.  
  289.  
  290.  
  291.  
  292. #endif // __ITOOL_H
  293.