Re: [NTLK] NHttplib Fetch URL vs Jpeg

From: Eckhart Köppen (eck1001_at_gmx.net)
Date: Thu May 15 2003 - 00:06:25 PDT


On Wednesday, May 14, 2003, at 09:01 PM, Tom McDougal wrote:

> This does sound like an interesting exercise, and I am indeed at the
> stage of trying to create my first Newt App. Since you say it should be
> easy I 1 will give it a try.
>
> I assume I will need to know how to make use of the jpeg plug in. A
> pointer to documentation would be welcome.

Here are some more general things that might help...

Basically, there are four options on how to implement this:
1. An application that opens the Inbox itself and tries to display what
it finds in there
2. A NewtApp based application that supports "Put Away" of image/gif and
image/jpeg data types from the Inbox into its own data soup
3. Stationery that can be used to display pictures in the Inbox directly
4. A NewtApp application based on Stationery (combination of 2 and 3)

Number 4 is probably the most elegant but has also the steepest learning
curve. Number 2 is not that bad.

As a starter, I strongly recommend getting "Programming for the Newton
using Macintosh" from Unna. (It doesn't matter if you're not working on
a Mac). If you can get hold of a paper copy, even better. It is an
excellent book. If you feel confident with the NTK and some small
example apps, read the chapters on Data Storage and NewtApp.

Then, either create a minimal NewtApp or use an existing project (from
Apple, from the Book, from my software, other software...) as the basis
for your experiments (a Card-based NewtApp is what you want).

The magic happens on the Entry Layer. This is where your code goes. I
think it might be easiest to simply add a clPictureView to the Entry
Layer and implement the Retarget method for that clPictureView.

The Retarget method of any proto within an Entry Layer is responsible
for taking the existing data (available in the target variable) and
putting it into the necessary slots to display it. In your case, the
Retarget method would read the JPEG data, decompress it and put it into
the icon slot of the clPictureView.

The big question however is the data storage layer. There are two things
to take care of: First, the data format of your own data, and second,
how to get the data from the Inbox into your app.

The data format of your app is defined in the allSoups slot of the
application base view. You can define anything you need in there, take a
look at the examples and how they implement CreateBlankEntry and you'll
get the idea.

Getting data from the Inbox into your app is pretty straightforward
using "Put Away" (covered in the Programmer's Guide unter "Routing
Interface"). To enable put away in your app, you need to register the
data type and implement the PutAwayScript in your application base view.
Registering is done via RegAppClasses. If you need an example, look at
MAD Max which does something very similar to what you need.

This might all sound a bit confusing at first, but you should take it
step by step. If you wonder how certain things work, take a look at any
application that does what you want to do and see how it is implemented.
Don't worry about ripping of code! One of the ideas behind my software
is that it should enable others to figure out how things work.

The learning curve might be steep (maybe a couple of weeks) but once
you've mastered NewtApp, you can implement almost any application in a
very short time.

Good luck,

Eckhart

-- 
This is the NewtonTalk list - http://www.newtontalk.net/ for all inquiries
List FAQ/Etiquette/Terms: http://www.newtontalk.net/faq.html
Official Newton FAQ: http://www.chuma.org/newton/faq/


This archive was generated by hypermail 2.1.5 : Thu May 15 2003 - 07:30:01 PDT