#ifndef DATATYPES_HYPERTEXTCLASS_H
#define DATATYPES_HYPERTEXTCLASS_H
/*
** $VER: hypertextclass.h 40.15 (23.11.97)
**
** by
**
** Stefan Ruppert <ruppert@amigaworld.com>
**
** (C) Copyright 1995-1997
** All Rights Reserved !
**
*/

/* ------------------------------- includes ------------------------------- */

#ifndef  UTILITY_TAGITEM_H
#include <utility/tagitem.h>
#endif

#ifndef  DATATYPES_DATATYPESCLASS_H
#include <datatypes/datatypesclass.h>
#endif

/* ------------------------------ class name ------------------------------ */

#define HYPERTEXTDTCLASS          "hypertext.datatype"
#define HYPERTEXTDTLIBRARY        "datatypes/hypertext.datatype"
#define HYPERTEXTDTVERSION        40

/* ------------------------------- methods -------------------------------- */

#define HTDTM_DUMMY         0x800
#define HTDTM_OBTAIN        0x801
#define HTDTM_RELEASE       0x802
#define HTDTM_ATTEMPT       0x803
#define HTDTM_LAYOUT        0x804
#define HTDTM_GETFONT       0x805
#define HTDTM_ALLOCVEC      0x806
#define HTDTM_FREEVEC       0x807
#define HTDTM_HTPROC        0x808
#define HTDTM_CONVATTRIB    0x809

#define HTDTM_LOADNODES     0x80A
#define HTDTM_SAVENODES     0x80B

#define HTDTM_OBTAINPEN     0x80C
/* not implemented yet */
#define HTDTM_GETPEN        0x80D

#define HTDTM_RENDER        0x811
#define HTDTM_SEARCH        0x812
#define HTDTM_GUISEARCH     0x813
#define HTDTM_EXPORT        0x814

/* HTDTM_LAYOUT message */
struct htLayout
{
   ULONG MethodID;
   struct GadgetInfo *dt_GInfo;
   struct TagItem *htl_AttrList;
   ULONG htl_Initial;
};

/* HTDTM_GETFONT */
struct htGetFont
{
   ULONG MethodID;
   struct GadgetInfo *dt_GInfo;
   LONG htgf_FontNum;
   STRPTR htgf_FontName;
   ULONG htgf_FontSize;
};

/* HTDTM_ALLOCVEC */
struct htAllocVec
{
   ULONG MethodID;
   struct GadgetInfo *dt_GInfo;
   ULONG htav_Size;
};

/* HTDTM_FREEVEC */
struct htFreeVec
{
   ULONG MethodID;
   struct GadgetInfo *dt_GInfo;
   APTR htfv_Memory;
};

/* HTDTM_CONVATTRIB */
struct htConvAttrib
{
   ULONG MethodID;
   struct GadgetInfo *dt_GInfo;
   STRPTR htca_Keyword;
   ULONG htca_KeywordLen;
   STRPTR htca_Arguments;
   ULONG htca_ArgumentsLen;
   struct TagItem *htca_TagList;
   struct HTSegInfo *htca_SegInfo;
   struct HTConvInfo *htca_ConvInfo;
   APTR htca_UserData;
};

/* HTDTM_LOADNODES */
struct htLoadNodes
{
   ULONG MethodID;
   struct GadgetInfo *dt_GInfo;
   struct List *htln_List;
   ULONG htln_NodeSize;
};

/* HTDTM_SAVENODES */
struct htSaveNodes
{
   ULONG MethodID;
   struct GadgetInfo *dt_GInfo;
   struct List *htsn_List;
};

/*  HTDTM_OBTAINPEN */
struct htObtainPen
{
   ULONG MethodID;
   struct GadgetInfo *dt_GInfo;
   STRPTR htop_String;
   ULONG htop_StringLen;
   ULONG htop_Red;
   ULONG htop_Green;
   ULONG htop_Blue;
};

/* HTDTM_RENDER */
struct htRender
{
   ULONG MethodID;
   struct GadgetInfo *dt_GInfo;
};


/* HTDTM_SEARCH, HTDTM_GUISEARCH */
struct htSearch
{
   ULONG MethodID;
   struct GadgetInfo *dt_GInfo;
   STRPTR hts_String;
   LONG hts_StringLen;
   ULONG hts_Flags;
};

#define HTDTSF_NOCASE         (1<<0)
#define HTDTSF_PATTERN        (1<<1)
#define HTDTSF_ALLNODES       (1<<2)
#define HTDTSF_STRING         (1<<3)
#define HTDTSF_BACKWARD       (1<<4)
#define HTDTSF_PROMPT         (1<<5)

/* HTDTM_EXPORT */
struct htExport
{
   ULONG MethodID;
   struct GadgetInfo *dt_GInfo;
   STRPTR hte_Type;
   STRPTR hte_File;
   ULONG hte_Unit;
   STRPTR hte_Args;
};

/* ------------------------------ attributes ------------------------------ */

#define HTDTA_Dummy              (TAG_USER + 40000)


#define HTDTA_Buffer             (HTDTA_Dummy + 0)
			/* (UBYTE *) pointer to the data area, which should be
			 * displayed.
			 * Applicability is (ISG)
			 */

#define HTDTA_BufferLen          (HTDTA_Dummy + 1)
			/* (ULONG) length of the data specified by HTDTA_Buffer
			 * Applicability is (ISG)
			 */

#define HTDTA_SegmentList        (HTDTA_Dummy + 2)
			/* (struct List *) list of Segment structures to
			 * render.
			 * Applicability is (G)
			 */

#define HTDTA_WordSelect         (HTDTA_Dummy + 3)
			/* (STRPTR) user selected the given word
			 * (not implemented yet)
			 * Applicability is (NU)
			 */

#define HTDTA_WordDelim          (HTDTA_Dummy + 4)
			/* (STRPTR) string which defines the delimiters to
			 * extract a word !
			 * Applicability is (ISG)
			 */

#define HTDTA_WordWrap            (HTDTA_Dummy + 5)
			/* (BOOL) indicate if the text should layout with
			 * the wordwrap and not with smartwrap !
			 * Default is FALSE. Thus smartwrap is used.
			 * Applicability is (ISGNU)
			 */

#define HTDTA_Pool                (HTDTA_Dummy + 6)
			/* (APTR) pool of the "hypertext.datatype" object
			 * Applicability : (G)
			 */

#define HTDTA_Spacing             (HTDTA_Dummy + 7)
			/* (UWORD) number of pixel between two lines
			 * Applicability is (ISG). Default is 0.
			 */

#define HTDTA_EmbeddedList        (HTDTA_Dummy + 8)
			/* (struct List *) exec list of all embedded
			 * dtobjects. NextObject() must be used to
			 * step through the list.
			 * But don't use this at this time. I will
			 * implement a interface for accessing embedded
			 * objects.
			 * Applicability is (G).
			 */

#define HTDTA_Contents            (HTDTA_Dummy + 9)
			/* (STRPTR) contents object name.
			 * Applicability is (ISG). Default is NULL.
			 */

#define HTDTA_Index               (HTDTA_Dummy + 10)
			/* (STRPTR) index object name.
			 * Applicability is (ISG). Default is NULL.
			 */

#define HTDTA_Help                (HTDTA_Dummy + 11)
			/* (STRPTR) help object name.
			 * Applicability is (ISG). Default is NULL.
			 */

#define HTDTA_Previous            (HTDTA_Dummy + 12)
			/* (STRPTR) previous object name.
			 * Applicability is (ISG). Default is NULL.
			 */

#define HTDTA_Next                (HTDTA_Dummy + 13)
			/* (STRPTR) next object name.
			 * Applicability is (ISG). Default is NULL.
			 */

#define HTDTA_LoadBuffer          (HTDTA_Dummy + 14)
			/* (BOOL) boolean, which indicates if the
			 * hypertext.datatype should load the given
			 * file into one buffer. If it should not
			 * overwrite it in your subclass OM_GET method.
			 * Applicability is (G). Default is TRUE.
			 */

#define HTDTA_TabWidth            (HTDTA_Dummy + 15)
			/* (UWORD) number of spaces used for a tab
			 * Applicability is (ISG). Default is 8.
			 */

#define HTDTA_FileHandle          (HTDTA_Dummy + 16)
			/* (BPTR) file handle to the hypertext document
			 * Applicability is (G).
			 */

#define HTDTA_HyperText           (HTDTA_Dummy + 17)
			/* (LONG) indicates , if this is a HyperText object
			 * TRUE or FALSE.
			 * Applicability is (G).
			 */

#define HTDTA_ScanNodeStr         (HTDTA_Dummy + 18)
			/* (STRPTR) string, which indicates the begin of a
			 * internal node within a document (file).
			 * (not implemented yet)
			 * Applicability is (G).
			 */

#define HTDTA_ScanEndNodeStr      (HTDTA_Dummy + 19)
			/* (STRPTR) string, which indicates the end of a
			 * internal node within a document (file). If this
			 * is NULL, the end of a node is determined by the
			 * HTDTA_ScanNodeStr string.
			 * (not implemented yet)
			 * Applicability is (G).
			 */

#define HTDTA_ObjName             (HTDTA_Dummy + 20)
			/* (STRPTR) full file name including path
			 */

#define HTDTA_ObjectDir           (HTDTA_Dummy + 21)
			/* (BPTR) to the objects directory. If non NULL
			 * you have to UnLock() it when done with it.
			 * Applicability is (G).
			 */

#define HTDTA_Secure              (HTDTA_Dummy + 22)
			/* (BOOL) indicates, that this object can't execute
			 * any rexx script or program.
			 * Default is FALSE.
			 * Applicability is (ISG).
			 */

#define HTDTA_ARexxCommand        (HTDTA_Dummy + 23)
			/* (STRPTR) ARexx command to execute on this object.
			 * Applicability is (U).
			 */

#define HTDTA_Depth               (HTDTA_Dummy + 24)
			/* (UBYTE) color depth, which should be used for this
			 * hypertext object.
			 * Applicability is (ISG).
			 */

#define HTDTA_NodeList            (HTDTA_Dummy + 25)
			/* (struct List *) list of "internal" nodes.
			 * like HyperGuide nodes from one file
			 * Applicability is (G).
			 */

#define HTDTA_UnderlineLink       (HTDTA_Dummy + 26)
			/* (BOOL) use a line under a link instead of a border
			 * Applicability is (I).
			 */

#define HTDTA_Background          (HTDTA_Dummy + 27)
			/* (STRPTR) background picture. (not implemented)
			 * Applicability is (I).
			 */

#define HTDTA_ShowLink            (HTDTA_Dummy + 28)
			/* (BOOL) if this tag is present in an notify taglist
			 * the DTA_Title is a link. So subclasses of the
			 * hypertext.datatype can absolutify the link or
			 * something similar.
			 * Applicability is (N).
			 */

#define HTDTA_NodeIndexing        (HTDTA_Dummy + 29)
			/* (BOOL) boolean, which indicates if the
			 * hypertext.datatype should try to load the index
			 * for all nodes within this document. If it should use
			 * indexing overwrite it in your subclass OM_GET method.
			 * Default is FALSE.
			 * Applicability is (G).
			 */

#define HTDTA_BackgroundPen       (HTDTA_Dummy + 30)
			/* (LONG) background pen.
			 * Applicability is (ISG).
			 */

#define HTDTA_ForegroundPen       (HTDTA_Dummy + 31)
			/* (LONG) foreground pen.
			 * Applicability is (ISG).
			 */

#define HTDTA_AltForegroundPen    (HTDTA_Dummy + 32)
			/* (LONG) alternate foreground pen, if foreground == background pen.
			 * Applicability is (ISG).
			 */

#define HTDTA_PathList            (HTDTA_Dummy + 33)
			/* (struct List *) list of path names (ln_Name) to
			 * search for objects of the current object.
			 * NOTE: Subclass implementors have to provide this
			 * attribute, if they support object dependend
			 * pathlists.
			 * Applicability is (G).
			 */

#define HTDTA_SeparatorIsFF       (HTDTA_Dummy + 34)
			/* (BOOL) interprete a separator as a form feed for
			 * printing.
			 * Default is FALSE.
			 * Applicability is (ISG).
			 */

/* ------------------------ SegmentInfo attributes ------------------------ */

struct HTSegInfo
{
   void *si_PRIVATE;
};

#define HTDTSIA_Dummy             (TAG_USER + 0x000)

#define HTDTSIA_Pool              (HTDTSIA_Dummy + 1)
			/* (APTR) memory pool for AllocPooled().
			 * REQUIRED !
			 */

#define HTDTSIA_Object            (HTDTSIA_Dummy + 2)
			/* (Object *) datatypes object to create segment
			 * structures for.
			 * REQUIRED !
			 */

#define HTDTSIA_GadgetInfo        (HTDTSIA_Dummy + 3)
			/* (struct GadgetInfo *) needed GadgetInfo structure
			 * REQUIRED !
			 */

#define HTDTSIA_List              (HTDTSIA_Dummy + 4)
			/* (struct List *) list to append Segment structures
			 * Defaults to the Object's SegmentList !
			 */

/* ------------------------- ConvInfo attributes -------------------------- */

struct HTConvInfo
{
   void *ci_PRIVATE;
};


#define HTDTCIA_Dummy            (TAG_USER + 0x0)

#define HTDTCIA_Format           (HTDTCIA_Dummy + 0x1)
			/* (STRPTR) format to be used for convertion,
			 * currently only "hyperguide" is defined.
			 * Defaults to "hyperguide".
			 */
#define HTDTCIA_UserData         (HTDTCIA_Dummy + 0x02)
			/* (APTR) UserData field for htConvAttrib message
			 * structure.
			 */

/* -------------------------- Segment attributes -------------------------- */


#define HTDTSA_Dummy              (TAG_USER + 0x100)

#define HTDTSA_Text               (HTDTSA_Dummy + 1)
			/* (STRPTR) text to render
			 */

#define HTDTSA_TextLen            (HTDTSA_Dummy + 2)
			/* (UWORD) length of HTDTSA_Text
			 */

#define HTDTSA_XOffset            (HTDTSA_Dummy + 3)
			/* (UWORD) xoffset in pixel to render segment
			 */

#define HTDTSA_YOffset            (HTDTSA_Dummy + 4)
			/* (UWORD) yoffset in pixel to render segment
			 * Do not use this use instead the HTDTM_LAYOUT
			 * method
			 */
#define HTDTSA_Width              (HTDTSA_Dummy + 5)
			/* (UWORD) width of the segment in pixel
			 */

#define HTDTSA_Height             (HTDTSA_Dummy + 6)
			/* (UWORD) height of the segment in pixel
			 */

#define HTDTSA_Flags              (HTDTSA_Dummy + 7)
			/* (UWORD) HTSF_#? flags
			 */

#define HTDTSA_FgPen              (HTDTSA_Dummy + 8)
			/* (UBYTE) foreground pen
			 * Defaults to 1.
			 */

#define HTDTSA_BgPen              (HTDTSA_Dummy + 9)
			/* (UBYTE) background pen
			 * Defaults to 0.
			 */

#define HTDTSA_Style              (HTDTSA_Dummy + 10)
			/* (UWORD)
			 * TextAttr style for HTST_NORMAL.
			 * Defaults to FS_NORMAL.
			 *
			 * separator style for HTST_SEPARATOR.
			 * Defaults to SEPS_RAISED.
			 */

#define HTDTSA_TextFont           (HTDTSA_Dummy + 11)
			/* (struct TextFont *) font to use for this segment
			 * Default is NULL, which uses the objects font.
			 */

#define HTDTSA_LinkType           (HTDTSA_Dummy + 12)
			/* (ULONG) type of the link to perform. This attribute
			 * is send with the DTM_GOTO method.
			 */

#define HTDTSA_LinkData           (HTDTSA_Dummy + 13)
			/* (APTR) userdata field from the ExtLine structure.
			 * This attribute is send with the DTM_GOTO method .
			 */

#define HTDTSA_Name               (HTDTSA_Dummy + 14)
			/* (STRPTR) dtobject name
			 */

#define HTDTSA_AllocText          (HTDTSA_Dummy + 15)
			/* (BOOL) allocate memory for the text specified via
			 * HTDTSA_Text and copy it.
			 * Default is FALSE.
			 */
#define HTDTSA_AllocLink          (HTDTSA_Dummy + 16)
			/* (BOOL) allocates memory for the link text specified
			 * via HTDTSA_LinkData and copies it.
			 * Default is FALSE.
			 */

#define HTDTSA_ParaIndent         (HTDTSA_Dummy + 17)
			/* (ULONG) number of spaces to indent the first line
			 * of a paragraph. The default font is used for that.
			 * Defaults to 4.
			 */

#define HTDTSA_BodyIndent         (HTDTSA_Dummy + 18)
			/* (ULONG) number of spaces to indent the body of a
			 * paragraph. The default font is used for that.
			 * Defaults to 0.
			 */

#define HTDTSA_LayoutFlags        (HTDTSA_Dummy + 19)
			/* (ULONG) HTSLF_#? */

#define HTDTSA_NumTabs            (HTDTSA_Dummy + 20)
			/* (ULONG) number of tabs for this segment.
			 * Defaults to 1.
			 */

#define HTDTSA_TabStops           (HTDTSA_Dummy + 21)
			/* (UWORD *) ~0 terminated array of tab stop
			 * positions.
			 * Defaults to NULL.
			 */

#define HTDTSA_ListType           (HTDTSA_Dummy + 22)
			/* (ULONG) type of HTST_STARTLIST segment.
			 * See HTSLT_#? values.
			 * Default is HTSLIT_ITEMIZE.
			 */

#define HTDTSA_Label              (HTDTSA_Dummy + 23)
			/* (STRPTR) label to goto to within the document
			 */

#define HTDTSA_LabelLen           (HTDTSA_Dummy + 24)
			/* (STRPTR) length of the label string
			 */

#define HTDTSA_ListItemFormat     (HTDTSA_Dummy + 25)
			/* (STRPTR) formatstring for the item
			 */

#define HTDTSA_Paragraph          (HTDTSA_Dummy + 26)
			/* (BOOL) indicates, that this is a real paragraph.
			 */

struct HTSegment
{
   struct MinNode s_Link;

   /* private data follows here */
};

/* ----------------------------- segment type ----------------------------- */

#define HTST_NORMAL             0   /* normal text segment */
#define HTST_DTOBJECT           1   /* the text segment points to a
				     * datatype object, which supports
				     * the DTM_DRAW method */
#define HTST_SEPARATOR          2   /* horizontal separator line */
#define HTST_GADGET             3   /* segment is a gadget (not implemented
				     * yet) */
#define HTST_STARTPARAGRAPH     4   /* start a paragraph */
#define HTST_ENDPARAGRAPH       5   /* end of a paragraph */

#define HTST_TAB                6   /* one or more tabs */

#define HTST_SETTABS            7   /* define a (un)regular tabs */
#define HTST_INTERN             8   /* internal segment, don't touch at all */
#define HTST_SETPARAGRAPH       9   /* set current position to paragraph indent */
#define HTST_STARTLIST         10   /* start a list */
#define HTST_ENDLIST           11   /* end of a list */
#define HTST_LABEL             12   /* label to goto */

/* ---------------------------- segment flags ----------------------------- */

#define HTSF_LF          (1<< 0)    /* indicates, that this is a end of a
				     * line */
#define HTSF_LINK        (1<< 1)    /* this is a link segment ! */
#define HTSF_SELECTED    (1<< 2)    /* this segment is currently selected
				     * the STM_ACTIVATE_FIELD trigger method
				     * would execute the link , if also the
				     * SF_LINK flag is set ! */

#define HTSF_MARKED      (1<< 3)    /* the user has marked this segment */
#define HTSF_TOGGLE      (1<< 4)    /* the SF_MARKED toggle's if the user
				     * select it */
#define HTSF_BR          (1<< 5)    /* break line, but don't end paragraph */

#define HTSF_ITEM        (1<< 9)    /* indicates, this is an item segment (<LI>) */
#define HTSF_ITEM2       (1<<10)    /* indicates, this is an second item segment (<DD>) */

#define HTSLF_JCENTER    (1<< 6)    /* center this segment */
#define HTSLF_JRIGHT     (1<< 7)    /* place this segment to the right */
#define HTSLF_WRAP       (1<< 8)    /* this segment can be wrapped */

/* ------------------------------ link types ------------------------------ */

#define HTLKT_NODE       0            /* a nodename (amigaguide style) */
#define HTLKT_OBJECT     1            /* a complete filename using datatypes to
				       * open it */
#define HTLKT_RX         2            /* a ARexx script */
#define HTLKT_RXS        3            /* a ARexx command */
#define HTLKT_SYSTEM     4            /* a AmigaDOS command using System()*/
#define HTLKT_RUNCMD     5            /* a AmigaDOS command using RunCommand() */
#define HTLKT_WBSTART    6            /* a AmigaDOS command using wbstart */
#define HTLKT_QUIT       7            /* terminate the current object */
#define HTLKT_USER       128          /* belongs only to the derived class */

/* ------------------------------ list types ------------------------------ */

#define HTSLIT_ITEMIZE           0
#define HTSLIT_ENUMERATION       1
#define HTSLIT_DEFINITION        2

/* --------------------------- separator styles --------------------------- */

#define SEPS_RAISED     0
#define SEPS_RECESSED   1
#define SEPS_NOSHADE    2

/* --------------------------- node definition ---------------------------- */

struct HTNode
{
   struct Node htn_Node;
   ULONG htn_Pos;
   ULONG htn_Length;
};

#endif /* !DATATYPES_HYPERTEXTCLASS_H */

