Subclassing SimpleHTML Datatype

4 posts / 0 new
Last post
trixie
trixie's picture
Offline
Last seen: 6 months 3 weeks ago
Joined: 2011-02-03 13:58
Subclassing SimpleHTML Datatype

How would one go about subclassing the SimpleHTML Datatype? As it doesn't come with any public include file, I'm wondering how to obtain a data buffer from it. For example, with the Text Datatype you can use GetDTAttrs() to query about TDTA_Buffer and then process the buffer data in your subclass. I need something similar - a buffer with unprocessed data - but looking at the source code in A-EON's repository I'm not sure SimpleHTML is designed for subclassing at all.

broadblues
broadblues's picture
Offline
Last seen: 4 years 9 months ago
Joined: 2012-05-02 21:48
Re: Subclassing SimpleHTML Datatype

What would you want to acheive with a subclass?

I doubt subclassing is really feasible TBH.

It's a very annoying datatype that's stops you from view HTML src in MultiView(er) :-)

It's html rendering is rather horrid. Best use a webbrowser...

Note text.datatype is root class (well at least its the root of the GID_TEXT group anyway) so is designed for subclassing.

BTW I'm not sure you could easily subclass amigaguide.datatype either.

trixie
trixie's picture
Offline
Last seen: 6 months 3 weeks ago
Joined: 2011-02-03 13:58
Re: Subclassing SimpleHTML Datatype

@broadblues

What would you want to acheive with a subclass?

To cut a long story short: I've ported a MarkDown parser, which I have turned into an Amiga datatype. I wrote it as a Text Datatype subclass but then I realized that the Text Datatype has some shortcomings: for example, the public include file indicates that the datatype supports in-text links but in reality, links have never been implemented.

Because the parser automatically converts into HTML as it goes through the MarkDown data, I thought I might be better off if I turned it into a SimpleHTML subclass instead. The idea was that SimpleHTML would provide a buffer containing the original data (i.e. MarkDown text) which the subclass would then parse, convert, and pass the HTML output back to the superclass to take care of the display.

But it appears I may have overestimated SimpleHTML, and looking at its rather convoluted source code I can't see an easy way to achieve what I need.

Note text.datatype is root class (well at least its the root of the GID_TEXT group anyway) so is designed for subclassing.

I think both Text Datatype and SimpleHTML Datatype are direct subclasses of datatypesclass (which is a subclass of gadgetclass) and as such they should have been designed for further subclassing, or otherwise what's the purpose of Amiga Datatypes being object-oriented?

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

broadblues
broadblues's picture
Offline
Last seen: 4 years 9 months ago
Joined: 2012-05-02 21:48
Re: Subclassing SimpleHTML Datatype

But it appears I may have overestimated SimpleHTML, and looking at its rather convoluted source code I can't see an easy way to achieve what I need.

Your going about that the wrong way. Subclass a class that complex is not going to work. But you can *embed* an html datatype object in your mark down object in the same way as you might embed a button gadget in more complex file request gadget.

So parse in the markdown data as a top level GID_DOCUMENT then pass the html created to the embded html object.

Note text.datatype is root class (well at least its the root of the GID_TEXT group anyway) so is designed for subclassing.

I think both Text Datatype and SimpleHTML Datatype are direct subclasses of datatypesclass (which is a subclass of gadgetclass) and as such they should have been designed for further subclassing, or otherwise what's the purpose of Amiga Datatypes being object-oriented?

Zen reponse: Not all branches on a tree have twigs.

Gadget analogy: Consider one of the really heavy duty gadgets like listbrowser.gadget usefully subclassing that would be very difficult, as there is no public access to the inner datastructures, like wise with the more heavy duty datatypes.

Log in or register to post comments