|##########|
|#MAGIC   #|DBGFFCCI
|#PROJECT #|""
|#PATHS   #|"EGSProject"
|#FLAGS   #|xx---x--x---xxx-----------------
|#USERSW  #|--------------------------------
|#USERMASK#|--------------------------------
|#SWITCHES#|x----x----------
|##########|
DEFINITION MODULE EGSIcon;

FROM EGSIntui AS I IMPORT EIntuiMsg,EGSWBObject;
FROM System        IMPORT SysStringPtr,Regs;
FROM Exec          IMPORT Library,MsgPortPtr;
FROM EGSGfx        IMPORT EFontPtr;
                   IMPORT Workbench;
                   IMPORT EGS;

|
| UseCounts...
|
| Arguments:
|
|   [0] : The usecount is not changed
|   [-] : The usecount will be decremented = ReleaseObject
|   [+] : The usecount will be incremented = GrepObject
|
| Results:
|
|   All objects are returned with an incremented usecount. They have to
|   be released after use.
|

TYPE
  Process      = EGSWBObject;
  Symbol       = EGSWBObject;

  ParamList    = CLASSPTR TO ARRAY OF EGSWBObject;
  ParamListPtr = POINTER TO ARRAY OF EGSWBObject;

  ErrorDescPtr = POINTER TO EGSWBObject;

  Destructor   = PROCEDURE(data IN A1 : ANYPTR;
                           ptr  IN A2 : ANYPTR);


CONST
  |
  | Portname for the port where execution requests have to be posted
  |
  EGSWBPortName  = "WOMBAT";

TYPE
  EObjectMsgPtr  = POINTER TO EObjectMsg;
  EObjectMsg     = RECORD OF EIntuiMsg;
                     |
                     | the class of all messages that you get from
                     | EGSIcon is "iWBObjectMsg". You can use the same
                     | port for EIDCMP and EGSIcon.
                     |

                     |
                     |
                     | the senders process, when the message is a request
                     | to a server.
                     |
                     process  : Process;

                     |
                     | Server:
                     |
                     |   Represents self, the object that received the message.
                     |
                     |   Comes with incremented usecount, and will be released
                     |   by the library, after the message was returned.
                     |
                     | Client:
                     |
                     |   The object to receive the message.
                     |
                     |   [-]
                     |
                     receiver : EGSWBObject;

                     |
                     | symbol representing the methodname
                     |
                     method   : Symbol;

                     |
                     | Server:
                     |
                     |   Array of arguments for your method execution.
                     |   All objects come with an incremented usecount,
                     |   and will be released by the library, after the
                     |   method was returned.
                     |
                     | Client:
                     |
                     |   The arguments for your message.
                     |
                     |   [-]
                     |
                     params   : ParamList;

                     |
                     | Server:
                     |
                     |   The result of the method invocation,
                     |   if the method has no result, the server should
                     |   return self.
                     |
                     |    ...
                     |    GrepObject(msg.receiver);
                     |    msg.result:=msg.receiver;
                     |    ...
                     |
                     |   [-]
                     |
                     |   In an error case, this one gets the extension
                     |   information or simple NIL
                     |
                     | Client:
                     |
                     |   The result of your message, if the message
                     |   endet successfull. The usecount is incremented,
                     |   so it has to be decremented after use.
                     |
                     result   : EGSWBObject;
                     |
                     | error result from or to library.
                     |
                     | Server:
                     |
                     |   This is normally NIL for no error. If you want
                     |   to return an error, this one gets the Errorsymbol.
                     |
                     |   e.g.
                     |
                     |     msg.error:=GetSym("MisallignedUser");
                     |
                     | Client:
                     |
                     |   This is either NIL for no error, or an error
                     |   object describing the error.  You can get
                     |   more information by using FindSlot.
                     |
                     |   e.g.
                     |
                     |     ...
                     |     type:=FindSlot(msg.error,typeSym);
                     |     extension:=FindSlot(msg.error,extensionSym);
                     |     location:=FindSlot(msg.error,locationSym);
                     |     ...
                     |
                     |   "type" shall be a Symbol, extension may be anything.
                     |   For example in "CreateRoutine" it is the char pos
                     |   of the error in the source code.
                     |
                     |   "location" is the activation frame, where the error
                     |   occurred. You can also retrieve some information
                     |   from the frame.
                     |
                     |     ...
                     |     method:=DoMethodA(location,getMethodSym,NIL...);
                     |     charPos:=DoMethodA(location,getCharPosSym,NIL...);
                     |     ...
                     |
                     error    : EGSWBObject;
                   END;


  |
  | Hook, used in iterative procedures.
  |
  |  obj  : the curent object in this iteration step
  |  sym  :  "   "     symbol  "  "     "         "
  |  data : your pointer to freedom and independency
  |
  | You will receive the object with an incremented usecount. It will be
  | released by the library after your return.
  |
  ObjectIterator = PROCEDURE(obj  IN A0 : EGSWBObject;
                             sym  IN D0 : Symbol;
                             data IN A1 : ANYPTR);

  |
  | This message is send to a newly created server. The object self
  | is only valid until you return the message.
  | You should call "AddObjectPort" before you return the message.
  |
  EGSWBStartupMsgPtr = POINTER TO EGSWBStartupMsg;
  EGSWBStartupMsg    = RECORD OF Workbench.WBStartup;
                         self : EGSWBObject;
                       END;

TYPE
  IconStyle      = (normal,small,text);
  IconGadFlags   = (selected,igf31=31);
  IconGadFlagSet = SET OF IconGadFlags;
  IconGadPtr     = POINTER TO IconGadget;
  IconGadget     = RECORD OF I.MasterGadget;
                     |
                     | the object for this gadget
                     |
                     object        : EGSWBObject;
                     |
                     | flags for this icon (eg. selected)
                     |
                     iconFlags     : IconGadFlagSet;
                     nextIcon,
                     prevIcon      : IconGadPtr;
                     normalImage,
                     selectedImage : I.IntuiGfxPtr;
                     name          : STRING(32);
                     win           : I.WindowPtr;
                     click         : I.UserGadget;
                     drop          : I.DropGadget;
                     seconds,
                     micros        : LONGINT;
                   END;

VAR
  EGSIconBase  : POINTER TO RECORD OF Library;
                 END;

|
| ############################################################################
|
| Symbolmanagement
|


|
| Get a unique longword value for a string. Every call with a value equal
| string will return the same value. Symbols are system global, they are
| shared by all processes.
|
LIBRARY EGSIconBase BY - 30
  PROCEDURE GetSym(REF name IN A0 : STRING):Symbol;

|
| Reconvert a symbol to a string.
|
LIBRARY EGSIconBase BY - 36
  PROCEDURE SymToStr(sym IN D0 : Symbol):SysStringPtr;

|
| ############################################################################
|
| Einfachobjekte, Konvertierung
|

|
| Create a string object, from a string value. The value may be
| discarded after the call.
|
LIBRARY EGSIconBase BY - 42
  PROCEDURE CreateString(REF str IN A0 : STRING):EGSWBObject;

|
| Copy the string value of an object into a supplied buffer.
| Returns 0 if successfull, -1 if the object was no string, or
| the size of the string, if the buffer was not large enough.
|
| obj [0]
|
LIBRARY EGSIconBase BY - 48
  PROCEDURE GetStringValue(    obj      IN A0 : EGSWBObject;
                           REF buff     IN A1 : STRING;
                               buffSize IN D0 : INTEGER):INTEGER;


|
| Create an integer object. The value must be in the range:
|
|   -$40000000..$3FFFFFFF
|
LIBRARY EGSIconBase BY - 54
  PROCEDURE CreateInteger(val IN D0 : LONGINT):EGSWBObject;

|
| Returns the value of an integer object. If the object was no integer,
| the result will be: $7FFFFFFF.
|
| obj [0]
|
LIBRARY EGSIconBase BY - 60
  PROCEDURE GetIntegerValue(obj IN D0 : EGSWBObject):LONGINT;


|
| Creates an object of type array and number of possible elements size.
| Returns NIL, if the call fails
|
LIBRARY EGSIconBase BY -288
  PROCEDURE CreateArray(size IN D0 : LONGINT):EGSWBObject;

|
| Put an object in an array object
|
| array [0]
| obj   [-]
|
LIBRARY EGSIconBase BY -294
  PROCEDURE ArrayPutAt(array IN A0,obj IN A1 : EGSWBObject;at IN D0 : LONGINT);

|
| Gets an object out of an array object. Returns NIL, if the call fails.
|
| array [0]
|
LIBRARY EGSIconBase BY -300
  PROCEDURE ArrayGetAt(array IN A0 : EGSWBObject;at IN D0 : LONGINT):EGSWBObject;



|
| Compile a method object from a source string. If the compile failed,
| the character position of the error is an integer object in err.extension
|
LIBRARY EGSIconBase BY - 66
  PROCEDURE CreateRoutine(REF str IN A0 : STRING;
                              err IN A1 : ErrorDescPtr):EGSWBObject;

|
| Get the sourcecode of a method object.
| Returns 0 if successfull, -1 if the object was no method, or
| the size of the string, if the buffer was not large enough.
|
| obj [0]
|
LIBRARY EGSIconBase BY - 72
  PROCEDURE GetRoutineValue(    obj      IN A0 : EGSWBObject;
                            REF buff     IN A1 : STRING;
                                buffSize IN D0 : INTEGER):INTEGER;

|
| Try to create the sourcecode for a constant, that defines the
| value of this object, or the object itself, if it is a disk object
| Returns 0 if successfull, -1 if the object was no method, or
| the size of the string, if the buffer was not large enough.
|
| obj [0]
|
LIBRARY EGSIconBase BY -222
  PROCEDURE GetConstString(    obj      IN A0 : EGSWBObject;
                           REF buff     IN A1 : STRING;
                               buffSize IN D0 : INTEGER):INTEGER;

|
| Tries to create or retrieve an object from a textual description.
| If the compile failed, the character position of the error is an
| integer object in err.extension
|
LIBRARY EGSIconBase BY -228
  PROCEDURE CompileConst(REF str IN A0 : STRING;
                             err IN A1 : ErrorDescPtr):EGSWBObject;

|
| Associate an external pointer/value with an object. In case that
| the object is marked dead by the garbage collector, your destructor
| procedure will be called (only if non NIL). During this call no
| EGSIcon functions should be called. If you need to do so, make this
| call a message send to your server.
|
| obj [0]
|
LIBRARY EGSIconBase BY -318
  PROCEDURE SetObjectPtr(obj      IN A0 : EGSWBObject;
                         ptr      IN A1 : ANYPTR;
                         destruct IN A2 : Destructor;
                         data     IN A3 : ANYPTR);

|
| Gets the external pointer that is associated with this object, or
| NIL if no pointer was linked to it.
|
LIBRARY EGSIconBase BY -324
  PROCEDURE GetObjectPtr(obj IN A0 : EGSWBObject):ANYPTR;

LIBRARY EGSIconBase BY -354
  PROCEDURE CreateMapImage(map IN A0 : EGS.EBitMapPtr):EGSWBObject;

LIBRARY EGSIconBase BY -360
  PROCEDURE CreatePlaneImage(image IN A0 : EGS.ImagePtr):EGSWBObject;


|
| ############################################################################
|
| Objektresourcemanagement
|

|
| Increment the usecount of an object
|
| obj [+]
|
LIBRARY EGSIconBase BY - 78
  PROCEDURE GrepObject(obj IN A0 : EGSWBObject);

LIBRARY EGSIconBase BY - 78
  PROCEDURE GO(obj IN A0 : EGSWBObject):EGSWBObject;

|
| ????
|
LIBRARY EGSIconBase BY - 84
  PROCEDURE LockObject(obj IN A0 : EGSWBObject);

|
| Decrement the usecount of an object
|
| obj [-]
|
LIBRARY EGSIconBase BY - 90
  PROCEDURE ReleaseObject(obj IN A0 : EGSWBObject);

|
| Get an object, that is public available by its short name
|
LIBRARY EGSIconBase BY - 96
  PROCEDURE GrepPublicObject(name IN A0 : Symbol):EGSWBObject;

|
| Create an empty object out of hot air.
| The normal way to create an object of a specific class, is to send
| a create message to the class.
|
LIBRARY EGSIconBase BY -102
  PROCEDURE CreateObject():EGSWBObject;

|
| ???
|
LIBRARY EGSIconBase BY -108
  PROCEDURE CloneObject(obj IN A0 : EGSWBObject):EGSWBObject;

|
| ############################################################################
|
| Klassenverwaltung
|

|
| Tests if an object belongs to a given class, and returns TRUE if so.
|
| obj   [0]
| class [0]
|
LIBRARY EGSIconBase BY -312
  PROCEDURE is(obj IN A0,class IN A1 : EGSWBObject):BOOLEAN;


|
| Free all parents, slots and methods of an object and make it pure
| and innocent.
|
| obj   [0]
|
LIBRARY EGSIconBase BY -306
  PROCEDURE ClearObject(obj IN A0 : EGSWBObject);

|
| Add a parent class to an existing object
|
| obj   [0]
| class [0]
|
LIBRARY EGSIconBase BY -114
  PROCEDURE AddParent(obj   IN A0 : EGSWBObject;
                      class IN A1 : EGSWBObject;
                      err   IN A2 : ErrorDescPtr);

|
| Remove a parent from a class
|
| obj   [0]
| class [0]
|
LIBRARY EGSIconBase BY -120
  PROCEDURE RemParent(obj   IN A0 : EGSWBObject;
                      class IN A1 : EGSWBObject;
                      err   IN A2 : ErrorDescPtr);

|
| Iterate through all parents of an object. The symbol value in the
| iteration method is not valid.
|
| obj   [0]
|
LIBRARY EGSIconBase BY -126
  PROCEDURE IterateParents(obj  IN A0 : EGSWBObject;
                           call IN A1 : ObjectIterator;
                           data IN A2 : ANYPTR;
                           err  IN A3 : ErrorDescPtr);

|
| Add a method to an existing object. The method must be a method object.
| The method may not exist before in the current object.
|
| obj  [0]
| code [-]
|
LIBRARY EGSIconBase BY -132
  PROCEDURE AddMethod(obj    IN A0 : EGSWBObject;
                      sym    IN D0 : Symbol;
                      code   IN A1 : EGSWBObject;
                      err    IN A2 : ErrorDescPtr);

|
| Changes an existing method of an object. A method with the same name must
| exist in the object before.
|
| obj  [0]
| code [-]
|
LIBRARY EGSIconBase BY -138
  PROCEDURE ChangeMethod(obj    IN A0 : EGSWBObject;
                         sym    IN D0 : Symbol;
                         code   IN A1 : EGSWBObject;
                         err    IN A2 : ErrorDescPtr);

|
| Look for a method in a object. Returns NIL, if the method could not be found.
| This function may also return the method of a parent class.
|
| obj  [0]
|
LIBRARY EGSIconBase BY -144
  PROCEDURE FindMethod(obj   IN A0 : EGSWBObject;
                       sym   IN D0 : Symbol;
                       err   IN A1 : ErrorDescPtr):EGSWBObject;

|
| Delete an existing method of an object. This function will not delete the
| method of a parent class.
|
| obj  [0]
|
LIBRARY EGSIconBase BY -150
  PROCEDURE DeleteMethod(obj    IN A0 : EGSWBObject;
                         sym    IN D0 : Symbol;
                         err    IN A1 : ErrorDescPtr);

|
| Iterate through all methods of an object.
|
| obj  [0]
|
LIBRARY EGSIconBase BY -156
  PROCEDURE IterateMethods(obj  IN A0 : EGSWBObject;
                           call IN A1 : ObjectIterator;
                           data IN A2 : ANYPTR;
                           err  IN A3 : ErrorDescPtr);



|
| Look for the value of a slot of a object or one of its parents. Returns
| NIL, if the slot could not be found.
|
| obj  [0]
|
LIBRARY EGSIconBase BY -162
  PROCEDURE FindSlot(obj IN A0 : EGSWBObject;
                     sym IN D0 : Symbol;
                     err IN A1 : ErrorDescPtr):EGSWBObject;

|
| Adds a slot and a value to an object. The slot may not have existed before
|
| obj  [0]
| data [0]
|
LIBRARY EGSIconBase BY -168
  PROCEDURE AddSlot(obj  IN A0 : EGSWBObject;
                    sym  IN D0 : Symbol;
                    data IN A1 : EGSWBObject;
                    err  IN A2 : ErrorDescPtr);

|
| Changes the value of an existing slot. The slot must exist either in the
| object or in one of its parents.
|
| obj  [0]
| data [0]
|
LIBRARY EGSIconBase BY -174
  PROCEDURE ChangeSlot(obj  IN A0 : EGSWBObject;
                       sym  IN D0 : Symbol;
                       data IN A1 : EGSWBObject;
                       err  IN A2 : ErrorDescPtr);

|
| Delete a slot from an object. This function does not delete the slot of
| any parent.
|
| obj  [0]
|
LIBRARY EGSIconBase BY -180
  PROCEDURE DeleteSlot(obj IN A0 : EGSWBObject;
                       sym IN D0 : Symbol;
                       err IN A1 : ErrorDescPtr);

|
| Iterates through all slots of an object.
|
| obj  [0]
|
LIBRARY EGSIconBase BY -186
  PROCEDURE IterateSlots(obj  IN A0 : EGSWBObject;
                         call IN A1 : ObjectIterator;
                         data IN A2 : ANYPTR;
                         err  IN A3 : ErrorDescPtr);

|
| ############################################################################
|
| Diskobjekte
|

|
| Attempts to access an named object. The object may either reside on disk
| or in memory. Returns NIL if the object could not be found.
|
LIBRARY EGSIconBase BY -192
  PROCEDURE GetDiskObject(REF name IN A0 : STRING):EGSWBObject;

|
| Writes a disk object in memory back to the disk.
|
| obj  [0]
|
LIBRARY EGSIconBase BY -198
  PROCEDURE CopyBackDiskObject(obj IN A0 : EGSWBObject);

|
| Name a disk object. The name may not have existed before. The name must be
| a valid file name. If you need a temporary name, use "t:xxx".
|
| ### should get a success return value !!! ###
|
| obj  [0]
|
LIBRARY EGSIconBase BY -204
  PROCEDURE NameDiskObject(REF name IN A0 : STRING;
                               obj  IN A1 : EGSWBObject);
|
| Delete a disk object
|
| obj  [0]
|
LIBRARY EGSIconBase BY -210
  PROCEDURE DeleteDiskObject(REF name IN A0 : STRING);

|
| Get the name of a named object the name is only valid as long as
| the object is locked.
|
| obj  [0]
|
LIBRARY EGSIconBase BY -216
  PROCEDURE GetDiskObjectName(obj IN A0 : EGSWBObject):SysStringPtr;

|
| ############################################################################
|
| Gadgets
|

|
| Create a gadget for an object. Each object can only have one of this gadgets.
|
|   If the object has no name, you can give a name to the icon. If name is
|   NIL, the name of the object will be used (the last part of the filename).
|
|   id is the id value of the created master gadget.
|
| object [-]
|
LIBRARY EGSIconBase BY -234
  PROCEDURE CreateIconGadget(object IN A0 : EGSWBObject;
                             style  IN D0 : IconStyle;
                             font   IN A1 : EFontPtr;
                             x      IN D1,
                             y      IN D2 : INTEGER;
                             name   IN A2 : SysStringPtr;
                             id     IN D3 : LONGINT;
                             scr    IN A3 : I.ScreenPtr):IconGadPtr;

|
| Deletes a gadget that has been created by CreateIconGadget.
|
LIBRARY EGSIconBase BY -240
  PROCEDURE DeleteIconGadget(gadget IN A0 : IconGadPtr);

|
| Change the left/top coordinates of an IconGadget, the gadget is not
| really moved. You should use this function only when the gadget is
| not attached to a window.
|
LIBRARY EGSIconBase BY -246
  PROCEDURE MoveIconGadget(gadget IN A0 : IconGadPtr;
                           x      IN D0,
                           y      IN D1 : INTEGER);

|
| Deselect all currently selected icons.
|
LIBRARY EGSIconBase BY -252
  PROCEDURE DeactivateIcons;

|
| Get an object that contains all currently selected objects. If more than
| one gadget is selected, this will return an "array" of gadgets.
| Returns NIL, if no gadget was selected.
|
LIBRARY EGSIconBase BY -258
  PROCEDURE GetActiveIcons():EGSWBObject;

|
| Get the icon gadget that is linked to an object.
|
LIBRARY EGSIconBase BY -264
  PROCEDURE GetObjectIcon(obj IN A0 : EGSWBObject):IconGadPtr;

|
| Create a gadget for the window background. This gadget must be the first
| one in the window.
|
LIBRARY EGSIconBase BY -270
  PROCEDURE CreateIconWindowGadget(w IN D0,h IN D1 : INTEGER):I.DropGadPtr;

|
| Delete a gadget that has been created by CreateIconWindowGadget
|
LIBRARY EGSIconBase BY -276
  PROCEDURE DeleteIconWindowGadget(gad IN A0 : I.DropGadPtr);

|
| ############################################################################
|
| Methodinvocation
|

|
| Invoke a method and wait until its finished. If you do not supply a reply
| port, this routine will create one temporary for you. The list of arguments
| may either be NIL for no arguments or a NIL terminated array/list of
| EGSWBObjects.
|
| receiver     [-]
| arguments..  [-]
|
LIBRARY EGSIconBase BY -282
  PROCEDURE DoMethod(receiver  IN A0 : EGSWBObject;
                     method    IN D0 : Symbol;
                     error     IN A1 : ErrorDescPtr;
                     port      IN A2 : Exec.MsgPortPtr;
                     arguments IN A3 : LIST OF EGSWBObject):EGSWBObject;

LIBRARY EGSIconBase BY -282
  PROCEDURE DoMethodA(receiver  IN A0 : EGSWBObject;
                      method    IN D0 : Symbol;
                      error     IN A1 : ErrorDescPtr;
                      port      IN A2 : Exec.MsgPortPtr;
                      arguments IN A3 : ParamListPtr):EGSWBObject;

LIBRARY EGSIconBase BY -342
  PROCEDURE SendMethod(receiver  IN A0 : EGSWBObject;
                       method    IN D0 : Symbol;
                       port      IN A1 : Exec.MsgPortPtr;
                       arguments IN A3 : LIST OF EGSWBObject);

LIBRARY EGSIconBase BY -342
  PROCEDURE SendMethodA(receiver  IN A0 : EGSWBObject;
                        method    IN D0 : Symbol;
                        port      IN A1 : Exec.MsgPortPtr;
                        arguments IN A3 : ParamListPtr);

LIBRARY EGSIconBase BY -348
  PROCEDURE ReceiveMethod(msg    IN A0 : EObjectMsgPtr;
                          error  IN A1 : ErrorDescPtr):EGSWBObject;

|
| ############################################################################
|
| Server related stuff
|

|
| Add the port to your server object.
|
| obj [0]
|
LIBRARY EGSIconBase BY -330
  PROCEDURE AddObjectPort(obj   IN A0 : EGSWBObject;
                          port  IN A1 : MsgPortPtr):BOOLEAN;

|
| Remove the port from your server object.
|
LIBRARY EGSIconBase BY -336
  PROCEDURE RemObjectPort(obj   IN A0 : EGSWBObject);

END EGSIcon.
