home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
sibylft1.zip
/
DOC.DAT
/
DOC
/
SPCC
/
TOOLSAPI.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1997-04-07
|
19KB
|
390 lines
{╔══════════════════════════════════════════════════════════════════════════╗
║ ║
║ Sibyl Portable Component Classes ║
║ ║
║ Copyright (c) 1995,97 SpeedSoft Germany, All rights reserved. ║
║ ║
╚══════════════════════════════════════════════════════════════════════════╝}
UNIT ToolsApi;
INTERFACE
USES Classes,Forms,Graphics,Editors;
TYPE
//Tools service API. The reference for this class is ToolServices and is created by the SP/2
//IDE on library initialization
TCreateModuleFlag = (cmfAddToProject,cmfShowSource,cmfShowForm,
cmfUnNamed,cmfNewUnit,cmfNewForm,cmfMainForm,cmfMarkModified,
cmfNewFile,cmfExisting);
TCreateModuleFlags = SET OF TCreateModuleFlag;
TProjectEnumProc = FUNCTION(Param: Pointer;CONST FileName, UnitName,
FormName:STRING):Boolean;
TFileNotification = (fnFileOpening, fnFileOpened, fnFileClosing,
fnProjectOpening, fnProjectOpened, fnProjectClosing, fnAddedToProject,
fnRemovedFromProject, fnDefaultDesktopLoad, fnDefaultDesktopSave,
fnProjectDesktopLoad, fnProjectDesktopSave, fnProjectSaved, fnFileSaved);
TIMainMenuIntf = CLASS;
TIAddInNotifier = CLASS
PROCEDURE FileNotification(NotifyCode: TFileNotification;
CONST FileName:STRING;VAR Cancel:Boolean); VIRTUAL;ABSTRACT;
END;
TIModuleInterface=CLASS;
TIToolServices = CLASS
//Opens a new Project. If PrjName is empty, create a new, empty project.
FUNCTION OpenProject(CONST PrjName:STRING):Boolean; VIRTUAL;ABSTRACT;
{Rene}
{}
//Extended version of OpenProject
FUNCTION OpenProjectEx(CONST PrjName:STRING;VisualProject,CreateNew:BOOLEAN):Boolean;VIRTUAL;ABSTRACT;
{}
//Close Project and return TRUE on success
FUNCTION CloseProject:Boolean; VIRTUAL;ABSTRACT;
//Determines if a named project can be opened, no load
FUNCTION OpenProjectInfo(CONST PrjName:STRING):Boolean; VIRTUAL;ABSTRACT;
//Save current project and return TRUE on success
FUNCTION SaveProject:Boolean; VIRTUAL;ABSTRACT;
//returns TRUE if specified file is open or can be loaded
FUNCTION OpenFile(CONST FileName:STRING):Boolean; VIRTUAL;ABSTRACT;
//Closes open editor file, if it is not open return also TRUE
FUNCTION CloseFile(CONST FileName:STRING):Boolean; VIRTUAL;ABSTRACT;
//Saves the specified files, if it is not open return also TRUE
FUNCTION SaveFile(CONST FileName:STRING):Boolean; VIRTUAL;ABSTRACT;
//Creates a new module
FUNCTION CreateModule(CONST ModuleName:STRING;
Source, Form: TMemoryStream;
CreateFlags: TCreateModuleFlags):Boolean; VIRTUAL;ABSTRACT;
//Extended version of CreateModule
FUNCTION CreateModuleEx(CONST ModuleName, FormName, AncestorClass:STRING;
Source, Form: TMemoryStream;
CreateFlags: TCreateModuleFlags):TIModuleInterface; VIRTUAL;ABSTRACT;
//returns IDE application form
FUNCTION GetParentForm:TForm; VIRTUAL;ABSTRACT;
//returns current project name
FUNCTION GetProjectName:STRING; VIRTUAL;ABSTRACT;
{Rene}
//returns primary file of project
FUNCTION GetPrimaryFile:STRING;VIRTUAL;ABSTRACT;
//returns count of units belonging to the current project
FUNCTION GetUnitCount:LONGINT; VIRTUAL;ABSTRACT;
//returns full name of project unit with specified index
FUNCTION GetUnitName(Index:LONGINT):STRING; VIRTUAL;ABSTRACT;
//Calls EnumProc for each unit in the project
FUNCTION EnumProjectUnits(EnumProc: TProjectEnumProc;Param: Pointer):Boolean; VIRTUAL;ABSTRACT;
{Rene}
//Return all files that belong to the current project
PROCEDURE GetProjectFiles(AStrings:TStrings);VIRTUAL;ABSTRACT;
//Return number of available forms in current project
FUNCTION GetFormCount:LONGINT; VIRTUAL;ABSTRACT;
//Get name of form with specified index
FUNCTION GetFormName(Index:LONGINT):STRING; VIRTUAL;ABSTRACT;
//Get full name of current file or form-unit-file, empty string if no file is active
FUNCTION GetCurrentFile:STRING; VIRTUAL;ABSTRACT;
//returns TRUE if specified file is open
FUNCTION IsFileOpen(CONST FileName:STRING):Boolean; VIRTUAL;ABSTRACT;
//Generate new unit name and file name
FUNCTION GetNewModuleName(VAR UnitIdent,FileName:STRING):Boolean; VIRTUAL;ABSTRACT;
//Get Count of currently installed component modules (units)
FUNCTION GetModuleCount:LONGINT; VIRTUAL;ABSTRACT;
//Get component unit name with specified index
FUNCTION GetModuleName(Index:LONGINT):STRING; VIRTUAL;ABSTRACT;
//Get component count of component unit with specified index
FUNCTION GetComponentCount(Index:LONGINT):LONGINT; VIRTUAL;ABSTRACT;
//Get component name from component unit with specified index
FUNCTION GetComponentName(ModIndex,CompIndex:LONGINT):STRING; VIRTUAL;ABSTRACT;
//Get Interface for a file loaded into the editor
FUNCTION GetModuleInterface(CONST FileName:STRING):TIModuleInterface; VIRTUAL;ABSTRACT;
//Get Interface for a form and its associated editor file
FUNCTION GetFormModuleInterface(CONST FormName:STRING):TIModuleInterface; VIRTUAL;ABSTRACT;
//Gets IDE main menu
FUNCTION GetMainMenu:TIMainMenuIntf; VIRTUAL;ABSTRACT;
//Adds a notification proc
{Rene}
{}
//Gets main menu handle - use with care
FUNCTION GetMainMenuHandle:TMenu;VIRTUAL;ABSTRACT;
{}
FUNCTION AddNotifier(AddInNotifier:TIAddInNotifier):Boolean; VIRTUAL;ABSTRACT;
//Remove notification proc
FUNCTION RemoveNotifier(AddInNotifier:TIAddInNotifier):Boolean; VIRTUAL;ABSTRACT;
//Get version of the IDE
FUNCTION GetVersion:LONGINT; VIRTUAL;ABSTRACT;
END;
TIMenuItemIntf=CLASS;
TIMenuFlag = (mfInvalid, mfEnabled, mfVisible, mfChecked, mfBreak, mfBarBreak,mfRadioItem);
TIMenuFlags = SET OF TIMenuFlag;
TIMenuClickEvent = PROCEDURE(Sender:TIMenuItemIntf) OF OBJECT;
//Note: all TIMainMenuIntf queried must be freed by the client !!
TIMainMenuIntf = CLASS
//Returns Interface for IDE main menu (top level)
FUNCTION GetMenuItems: TIMenuItemIntf; VIRTUAL;ABSTRACT;
//Returns Interface for menu item or submenu with specified name
FUNCTION FindMenuItem(CONST MenuName:STRING):TIMenuItemIntf; VIRTUAL;ABSTRACT;
END;
//Note: all TIMenuItemIntf queried must be freed by the client !!
TIMenuItemIntf = CLASS
//Destroys menu item associated with the interface, returns FALSE if the item was created by IDE
FUNCTION DestroyMenuItem:Boolean; VIRTUAL;ABSTRACT;
//Get Index of this item within the menu tree
FUNCTION GetIndex:LONGINT; VIRTUAL;ABSTRACT;
//Get count of submenus for this interface
FUNCTION GetItemCount:LONGINT; VIRTUAL;ABSTRACT;
//Get SubMenu item with specified index
FUNCTION GetItem(Index:LONGINT):TIMenuItemIntf; VIRTUAL;ABSTRACT;
//Get (internal !) Name of menu associated with interface, see also GetCaption
FUNCTION GetName:STRING; VIRTUAL;ABSTRACT;
//Get Parent interface of item or NIL
FUNCTION GetParent: TIMenuItemIntf; VIRTUAL;ABSTRACT;
//Get Caption of menu associated with the interface
FUNCTION GetCaption:STRING; VIRTUAL;ABSTRACT;
//Set Caption of menu associated with the interface
FUNCTION SetCaption(CONST Caption:STRING):Boolean; VIRTUAL;ABSTRACT;
//get ShortCut of menu
FUNCTION GetShortCut:TKeyCode; VIRTUAL;ABSTRACT;
//set ShortCut of menu
FUNCTION SetShortCut(ShortCut:TKeyCode):Boolean; VIRTUAL;ABSTRACT;
//Get Flags of menu
FUNCTION GetFlags:TIMenuFlags; VIRTUAL;ABSTRACT;
//Set Flags of menu
FUNCTION SetFlags(Mask,Flags: TIMenuFlags):Boolean; VIRTUAL;ABSTRACT;
//Get Hint of menu
FUNCTION GetHint:STRING; VIRTUAL;ABSTRACT;
//Set Hint of menu
FUNCTION SetHint(Hint:STRING):Boolean; VIRTUAL;ABSTRACT;
//Get Help context of Menu
FUNCTION GetContext:THelpContext; VIRTUAL;ABSTRACT;
//Set Help context for Menu
FUNCTION SetContext(Context:THelpContext):Boolean; VIRTUAL;ABSTRACT;
//Get OnClick event for the menu
FUNCTION GetOnClick:TIMenuClickEvent; VIRTUAL;ABSTRACT;
//Set OnClick event for the menu
FUNCTION SetOnClick(Click:TIMenuClickEvent):Boolean; VIRTUAL;ABSTRACT;
//Inserts an item
FUNCTION InsertItem(Index:LONGINT;Caption,Name,Hint:STRING;
ShortCut:TKeyCode;Context:THelpContext;Flags:TIMenuFlags;
EventHandler:TIMenuClickEvent):TIMenuItemIntf; VIRTUAL;ABSTRACT;
//Get Menu item associates with the interface - use with care !
FUNCTION GetMenuEntry:TMenuItem; VIRTUAL;ABSTRACT;
END;
TNotifyCode = (ncModuleDeleted, ncModuleRenamed, ncEditorModified,
ncFormModified, ncEditorSelected, ncFormSelected, ncBeforeSave,
ncAfterSave, ncFormSaving, ncProjResModified);
TIModuleNotifier=CLASS
PROCEDURE Notify(NotifyCode:TNotifyCode); VIRTUAL;ABSTRACT;
PROCEDURE ComponentRenamed(ComponentHandle:Pointer;
CONST OldName,NewName:STRING); VIRTUAL;ABSTRACT;
END;
TIEditorInterface=CLASS;
TIFormInterface=CLASS;
//represents file and forms open in a project
//Note: all TIModuleInterface queried must be freed by the client !!
TIModuleInterface=CLASS
//Get editor interface for the module or NIL
FUNCTION GetEditorInterface:TIEditorInterface; VIRTUAL;ABSTRACT;
//Get Form interface for the module or NIL
FUNCTION GetFormInterface:TIFormInterface; VIRTUAL;ABSTRACT;
//Close the module without Saving (see Save)
FUNCTION Close:Boolean; VIRTUAL;ABSTRACT;
//Saves the module, if forcesave is TRUE, the user will not be asked
FUNCTION Save(ForceSave: Boolean):Boolean; VIRTUAL;ABSTRACT;
//Rename module
FUNCTION Rename(CONST NewName:STRING):Boolean; VIRTUAL;ABSTRACT;
//Show source file of editor in topmost editor window
FUNCTION ShowSource:Boolean; VIRTUAL;ABSTRACT;
//Show Form of module if present
FUNCTION ShowForm:Boolean; VIRTUAL;ABSTRACT;
//Add notification proc
FUNCTION AddNotifier(AModuleNotifier:TIModuleNotifier):Boolean; VIRTUAL;ABSTRACT;
//Remove notification proc
FUNCTION RemoveNotifier(AModuleNotifier:TIModuleNotifier):Boolean; VIRTUAL;ABSTRACT;
END;
TEditPos = record
Col: SmallInt;
Line: Longint;
end;
TSyntaxHighlighter = (shNone, shPascal, shSQL, shQuery);
//represents editor file opened
//Note: all TIEditorInterface queried must be freed by the client !!
TIEditorInterface=CLASS
//Gets text at specified position
FUNCTION GetText(Position:Longint;VAR Buffer;BufSize:Longint):Longint;VIRTUAL;ABSTRACT;
//Copies text from actual position to Pos into the clipboard
FUNCTION CopyTo(Pos:Longint):Boolean; VIRTUAL;ABSTRACT;
//Deletes text from actual positon to Pos into the clipboard
FUNCTION DeleteTo(Pos:Longint):Boolean; VIRTUAL;ABSTRACT;
//Insert specified text at current position
FUNCTION Insert(VAR Buffer;BufSize:LONGINT):Boolean; VIRTUAL;ABSTRACT;
//Get editor position
FUNCTION Position: Longint; VIRTUAL;ABSTRACT;
//Get File Name of editor
FUNCTION FileName:STRING; VIRTUAL;ABSTRACT;
//Get total lines of edit buffer
FUNCTION LinesInBuffer:LONGINT; VIRTUAL;ABSTRACT;
//returns TRUE if edit buffer was modified
FUNCTION BufferModified:Boolean; VIRTUAL;ABSTRACT;
//Forces the editor to be modified
FUNCTION MarkModified:Boolean; VIRTUAL;ABSTRACT;
//Sets color table
FUNCTION SetSyntaxHighlighter(SyntaxHighlighter:TSyntaxHighlighter):TSyntaxHighlighter;VIRTUAL;ABSTRACT;
//Get editor position
FUNCTION GetPos:TEditPos; VIRTUAL;ABSTRACT;
//Set editor positon
PROCEDURE SetPos(Value: TEditPos); VIRTUAL;ABSTRACT;
//Get editor form instance - use with care !
FUNCTION GetEditorForm:TEditor; VIRTUAL;ABSTRACT;
PROPERTY CursorPos: TEditPos read GetPos write SetPos;
END;
TIComponentInterface=CLASS;
//represents form inside designer
//Note: all TIFormInterface queried must be freed by the client !!
TIFormInterface=CLASS
//returns unit file name for the form
FUNCTION FileName:STRING; VIRTUAL;ABSTRACT;
//returns TRUE if the form is modified
FUNCTION FormModified:Boolean; VIRTUAL;ABSTRACT;
//Forces the form to be marked as modified
FUNCTION MarkModified:Boolean; VIRTUAL;ABSTRACT;
//Get component interface for the form
FUNCTION GetFormComponent:TIComponentInterface; VIRTUAL;ABSTRACT;
//Get Form instance for the form - use with care !
FUNCTION GetFormInstance:TForm; VIRTUAL;ABSTRACT;
//Find component by name and return interface
FUNCTION FindComponent(CONST Name:STRING):TIComponentInterface; VIRTUAL;ABSTRACT;
//Get component interface from instance
FUNCTION GetComponentFromHandle(ComponentHandle:TObject):TIComponentInterface; VIRTUAL;ABSTRACT;
//Get Selection Count in form editor
FUNCTION GetSelCount:LONGINT; VIRTUAL;ABSTRACT;
//Get selected component interface from index
FUNCTION GetSelComponent(Index:LONGINT):TIComponentInterface; VIRTUAL;ABSTRACT;
//Gets parent interface that created the form
FUNCTION GetCreateParent: TIComponentInterface; VIRTUAL;ABSTRACT;
//Create new component, if containter is not nil, it is the parent, if name is empty, it is auto-created
FUNCTION CreateComponent(Container: TIComponentInterface;CONST TypeName,Name:STRING;
X,Y,W,H:LONGINT):TIComponentInterface; VIRTUAL;ABSTRACT;
END;
TPropertyType = (ptUnknown, ptInteger, ptChar, ptEnumeration, ptFloat,
ptString, ptSet, ptClass, ptMethod, ptWChar, ptLString, ptLWString,
ptVariant,{Rene}ptBoolean,ptCString,ptClassRef,ptRecord);
TGetChildCallback = FUNCTION(Param:Pointer;ComponentInterface:TIComponentInterface):Boolean;
//represents components inside a form
//Note: all TIComponentInterface queried must be freed by the client !!
TIComponentInterface=CLASS
//Returns component type as string
FUNCTION GetComponentType:STRING; VIRTUAL;ABSTRACT;
//Returns Component Instance - use with care !
{Rene}
FUNCTION GetComponentHandle:TComponent; VIRTUAL;ABSTRACT;
//Returns Parent interface
FUNCTION GetParent:TIComponentInterface; VIRTUAL;ABSTRACT;
//Returns TRUE if interface is a descendant of TControl
FUNCTION IsTControl:Boolean; VIRTUAL;ABSTRACT;
//Returns property count for the interface instance
FUNCTION GetPropCount:LONGINT; VIRTUAL;ABSTRACT;
//Get property name from Index
FUNCTION GetPropName(Index:LONGINT):STRING; VIRTUAL;ABSTRACT;
//Get property type from Index
FUNCTION GetPropType(Index:LONGINT;VAR TypeLen:LONGINT):TPropertyType; VIRTUAL;ABSTRACT;
//Get property type from Name
FUNCTION GetPropTypeByName(CONST Name:STRING;VAR TypeLen:LONGINT):TPropertyType; VIRTUAL;ABSTRACT;
//Gets Property value from index
FUNCTION GetPropValue(Index:LONGINT;VAR Value):Boolean; VIRTUAL;ABSTRACT;
//Gets Property value from name
FUNCTION GetPropValueByName(CONST Name:STRING;VAR Value):Boolean; VIRTUAL;ABSTRACT;
//Sets property from index
FUNCTION SetProp(Index:LONGINT;CONST Value):Boolean; VIRTUAL;ABSTRACT;
//Sets property from name
FUNCTION SetPropByName(CONST Name:STRING;CONST Value):Boolean; VIRTUAL;ABSTRACT;
//Enums component's children
FUNCTION GetChildren(Param:Pointer;Proc:TGetChildCallback): Boolean; VIRTUAL;ABSTRACT;
//Get count of child controls
FUNCTION GetControlCount:LONGINT; VIRTUAL;ABSTRACT;
//Get control from index
FUNCTION GetControl(Index:LONGINT):TIComponentInterface; VIRTUAL;ABSTRACT;
//Get count of child components
FUNCTION GetComponentCount:LONGINT; VIRTUAL;ABSTRACT;
//Get child component from index
FUNCTION GetComponent(Index:LONGINT):TIComponentInterface; VIRTUAL;ABSTRACT;
//Select component
FUNCTION Select: Boolean; VIRTUAL;ABSTRACT;
//Focus component
FUNCTION Focus: Boolean; VIRTUAL;ABSTRACT;
//Delete component
FUNCTION Delete: Boolean; VIRTUAL;ABSTRACT;
{Rene}
{}
//Set Event Property and add some code to it (optional)
FUNCTION SetEventProperty(CONST PropertyName,MethodName:STRING;Code:TStream):BOOLEAN;VIRTUAL;ABSTRACT;
//Get Method Name of a event property
FUNCTION GetEventProperty(CONST PropertyName:STRING):STRING;VIRTUAL;ABSTRACT;
{}
END;
//Expert interfaces - provided by client, created and destroyed by IDE
TExpertStyle = (esStandard, esForm, esProject, esAddIn);
TExpertState = set of (esEnabled, esChecked);
TIExpert=CLASS(TComponent)
//Required: returns name of expert
FUNCTION GetName:STRING; VIRTUAL;ABSTRACT;
//Required for styles esForm and esProject: returns author of expert
FUNCTION GetAuthor:STRING; VIRTUAL;ABSTRACT;
//Required for styles esForm and esProject: returns Comment of expert
FUNCTION GetComment:STRING; VIRTUAL;ABSTRACT;
//Required for styles esForm and esProject: returns page for repository, empty string for default
FUNCTION GetPage:STRING; VIRTUAL;ABSTRACT;
//Required for styles esForm and esProject: returns Bitmap for expert, NIL for default
FUNCTION GetGlyph: TBitmap; VIRTUAL;ABSTRACT;
//Required: returns Style of expert
FUNCTION GetStyle: TExpertStyle; VIRTUAL;ABSTRACT;
//Required if style is esStandard: returns menu State of expert
FUNCTION GetState: TExpertState; VIRTUAL;ABSTRACT;
//Required: returns UNIQUE IDString of expert. Supposed format is: CompanyName.ExpertFunction, ex. SpeedSoft.AppExpert
FUNCTION GetIDString:STRING; VIRTUAL;ABSTRACT;
//Required if style is esStandard:returns Menu text for expert
FUNCTION GetMenuText:STRING; VIRTUAL;ABSTRACT;
//Required if Style is esForm,esStandard or esProject: called whenever project is invoked
PROCEDURE Execute; VIRTUAL;ABSTRACT;
//Required: Is called whenever the IDE registeres this expert
PROCEDURE Register; VIRTUAL;ABSTRACT;
//Required: Is called whenever the IDE unloads this expert. The expert is destroyed after this call
PROCEDURE Unload; VIRTUAL;ABSTRACT;
END;
TIExpertClass=CLASS OF TIExpert;
CONST
ToolServices:TIToolServices=NIL;
PROCEDURE RegisterLibraryExperts(Experts:ARRAY OF TIExpertClass);
PROCEDURE FreeAllLibraryExperts;
IMPLEMENTATION