Success with Gadgets... 
Author Message
 Success with Gadgets...

Hi, all.

Well, I stared at the sacred ETH Gadgets scripts long enough and
enlightenment finally arrived. I'd like to outline what and how I
got a little gadgets thing working so as to 1) share my observations
about some things hidden in the manuals that ought to be in bold-face
28 point type, and 2) make sure I'm doing this right.

As I mentioned in an earlier post, I'm trying to make a gadget that
represents a viewable window onto an array of 8-bit pixels comprising
and image. Since the array is bigger (usually) than the window, I wanted
to have some attributes for the gadget showing the position of the
origin of the window relative to the underlying array, and wanted to
connect these attributes to some scroll bars. Finally, I wanted to be
able to have other modules load, process, and save the array of pixels
displayed by this module, and cause the display to be updated.

Here's what I did:
1. Changed the name of the Skeleton.Mod module to Images.Mod, and
   named the New function "Images.NewImage". The record is augmented
   with, among other things, a Screen.Image which contains a pointer
   to an array of chars that Screen can blit to the screen display in
   a portable way with Screen.Display(Image, etc), but that's another
   story.

2. Set up some integer attributes with support in the Attr handler
   function, including the "enum" section so it they can be seen
   using the Inspector. These include XScroll & YScroll.

3. Set up the Restore function to call Screen.Display to display
   the section of the array in the window using these attributes to
   decide the origin of the window vs. the pixel array.

4. Now everything displayed fine, and playing with the attributes using
   Gadgets.ChangeAttr worked just fine. So I made a couple of scroll
   bars, set the ranges and positions appropriately for the gadget,
   and started to set the command to manipulate the Image scrolling
   attributes. Amazingly enough, how to do this isn't really detailed
   in the section on how to use macros to *get* the values of other
   widgets, nor anywhere in the programming reference. In the back of
   the Gadgets Guide lives a tiny, unassuming one-liner:
        Gadgets.Set Library.Object.Attribute Value
   where Library can be omitted for things in the same context. This
   turns out to work for things on the same panel; I assume this is
   what's meant by that, more or less.

   I think this is a pretty basic bit of information that should be
   more predominately displayed, IMHO.

   Anyway, so the scroll bars' commands now read something like:

        Gadgets.Set .ImageWindow.XScroll  #Value

   and this works quite well.

5. Now, to somehow process this image. I didn't want to put all the
   processing into the Images gadget module, as that seemed kind of
   a crude way to do things. After some perusal I found (and I'm
   trying to remember this from memory here)
        Gadgets.FindObj(Name:ARRAY OF CHAR):Objects.Object
   where Name is of the form Library.Object where Library can be omitted
   for things in the same context. So I wrote another module called
   Process with a procedure Load:

        PROCEDURE Load*;
        VAR
          F : Objects.Object;
          Gadget, Filename : ARRAY 255 OF CHAR;
        BEGIN
          In.Open;
          In.String(Gadget);
          In.String(Filename);
          IF In.Done THEN
            F := Gadgets.FindObj(Gadget);
            IF F IS Images.Image THEN
              WITH F:Images.Image THEN
                (* using F, load the image, process it, whatever *)
                Gadgets.Update(F); (* or something like this,
                                      to send a redisplay message *)
              END;
            END;
          END;
        END Load;

   Now I have some button take the value of a text field and
   call Process.Load in its command field:

        Process.Load .Window  &.TF.Value

   or something like that. I can make other commands, even using
   other modules, that can also look up this gadget by name, get
   its data, process it, and cause it to be redisplayed.

---
Anyway, I'd like some feedback. Given that I can't have ETH ring
me up and tell me how brilliantly I've mastered the concepts here,
what I'd like to ask is:
        1) Am I doing this right?
        2) Is there a better way to do this?
        3) Why isn't this programming methodology discussed
           to any extent in the documents, if it works? Or
           am I just reading the wrong documents?

I've only seen from ETH two examples of programming Gadgets: Skeleton.Mod
and its relatives, and CAFE.Mod, a program that, while impressive, is
so huge that SPARC Oberon won't even compile the module, and it's not
a trivial program to read in any sense.  Can we get some intermediate
complexity examples of real-world Gadgets applications using multiple
intercommunicating gadgets?  I for one would like to see such a thing.

If there is interest, I will see if I can contribute the code for the
image-displaying window to an ftp site somewhere. I have code to read
sunraster files and straight pixel maps, and some simple IP filters I
can share; once you've seen the code, extending it is pretty easy. But
again, I'd like to make sure I'm doing this right. Oh, and the code
has only been tested on DOS and SPARC Oberon.

Well, sorry about the length of this. Gadgets has got me pretty
enthusiastic about using it as a serious programming tool, but I'd
like to be sure I'm not missing something big before writing a few
kilolines of code for my next project...

Well, back to deciphering the sacred scrolls...  :-)

Best wishes...

-greg
---
Greg DeLozier/Senior Scientific Analyst, L{*filter*}Defense Systems



Sun, 10 Mar 1996 11:38:39 GMT  
 Success with Gadgets...

Quote:

> ---
> Anyway, I'd like some feedback. Given that I can't have ETH ring
> me up and tell me how brilliantly I've mastered the concepts here,
> what I'd like to ask is:
>         1) Am I doing this right?
>         2) Is there a better way to do this?
>         3) Why isn't this programming methodology discussed
>            to any extent in the documents, if it works? Or
>            am I just reading the wrong documents?

There are a lot of interesting things to discover and explore with
Gadgets. You have to read the reports very carefully. And the examples
in Skeleton.Mod and Examples.Mod do not show all interesting facts.
So I missed the line with Gadgets.Set too. If you want to create
Gadgets like the Icon, you have to know much more than Skeleton.Mod
shows (e.g. about the message thread and the display mask).

And now to your design. I think you have mastered your problem quite well
but maybe there is another interesting solution for you:

I would create a new Thing (a nonviewable Gadget), which holds your Image
and acts as a model. So let us call this Thing 'Image' and your Gadget an
'ImageViewer' (or ImagePanel or something like this). Now you can have
several ImageViewers showing different parts of your Image. And if you
process your Image all ImageViewers show the changes immediately.

There is no example of a Thing in Skeleton.Mod but it is easy to create:
a) define Image as an extension of Gadgets.Object
b) delete all the Display.FrameMsg's from the handler (it is no frame)
c) change Gadgets.framehandler to Gadgets.objecthandler

At last you have to handle a Gadgets.UpdateMsg in your ImageViewer
(also not shown in Skeleton.Mod). So here is an example:

PROCEDURE ImageViewerHandler (..);
..
  IF M IS Display.DisplayMsg THEN
    ...
  ELSIF M IS Gadgets.UpdateMsg THEN
    WITH M : Gadgets.UpdateMsg DO
      IF (M.obj = F.obj) & (F.obj # NIL) & (M.stamp # F.stamp) THEN
        F.stamp := M.stamp;
        Gadgets.MakeMask (F, x, y, M.dlink, R);
        RestoreImageViewer (F, R, x, y, w, h)
      END
    END
  ELSIF ...
..
END ImageViewerHandler;

The way you get the pointer to your Image is ok. And you can still use
Gadgets.FindObj for Things. The context for searching with Gadgets.FindObj
is the private library from within the command was activated.
So if you have opened a Cabinet with several hidden Panels,
you can search for Gadgets in hidden Panels too but not across private
library boundaries and you can not activate the command from System.Tool.

I hope this will help you.

- Erwin



Mon, 11 Mar 1996 21:30:36 GMT  
 Success with Gadgets...

Quote:


>> Anyway, I'd like some feedback...

>There are a lot of interesting things to discover and explore with
>Gadgets.

Boy, is that an understatement!.

Quote:
>You have to read the reports very carefully.

And another one. I'd say about a dozen passes over everything *might*
get you started! :-)

Quote:
>And now to your design. I think you have mastered your problem quite well
>but maybe there is another interesting solution for you:

>I would create a new Thing (a nonviewable Gadget), which holds your Image
>and acts as a model.

Yes, this occurred to me, but only after I figured out how FindObj works,
and that was after I'd written a good deal of the Image code. I'll
probably do it in the next pass, but for now, alas, no time.

Quote:
>So if you have opened a Cabinet with several hidden Panels,...

I don't know much about hidden panels yet, but I'm getting there...

Quote:
>I hope this will help you.

>- Erwin

These are good ideas, and I'll toss them on the pile of things to look
at next go-round.  In the meantime, things are going quite well with the
image display design, and I can do things I've not seen in any other
language anywhere. I mean, how many times have you been able to replace
processing modules with recompiled ones *in a running application* ?
Just amazing, really.

I wonder how many people out there are really programming Gadgets? Just
us two?

Well, gotta run.  I'm trying to get some others interested in programming
Gadgets, too, but I have to know what I'm doing first, so, as I said last
time, back to the scrolls!

-greg

P.S. I realize it's customary to complain about the DOS version, and I've
even done it myself, but code portability between Gadgets for SPARC & DOS
seems very good under system 3, so: Good work, people!

---
Greg DeLozier/Senior Scientific Analyst/L{*filter*}Defense Systems



Tue, 12 Mar 1996 12:14:29 GMT  
 Success with Gadgets...
: Yes, this occurred to me, but only after I figured out how FindObj works,
: and that was after I'd written a good deal of the Image code. I'll
: probably do it in the next pass, but for now, alas, no time.

"next pass" - the joys of using a fast compiler.

: I wonder how many people out there are really programming Gadgets? Just
: us two?

The rest of us are waiting patiently. Gadgets hasn't been ported to
POWEROberon or the Mac.

**** This should be in the FAQ ******
: P.S. I realize it's customary to complain about the DOS version, and I've
: even done it myself, but code portability between Gadgets for SPARC & DOS
: seems very good under system 3, so: Good work, people!

Whitney



Tue, 12 Mar 1996 20:52:11 GMT  
 Success with Gadgets...

(paraphrase of previous thread post,  "only us two programming in gadgets?")
Well,
    I'm thinking about it... does that count?  :)

Doug Danforth
--
UMECORP, The creator of UME Voice
73 Digital Drive
Novato, CA 94949
pho (415) 883-1500, fax (415) 883-1711



Wed, 13 Mar 1996 05:27:08 GMT  
 Success with Gadgets...

: (paraphrase of previous thread post,  "only us two programming in gadgets?")
: Well,
:     I'm thinking about it... does that count?  :)

What a silly question ! Of course !
Just follow the same rule used with C++. C++ has exception handling,
namespaces and ( if we count proposals ) type-guards.

Whitney



Wed, 13 Mar 1996 07:06:56 GMT  
 Success with Gadgets...

Quote:


>: (paraphrase of previous thread post,  "only us two programming in gadgets?")
>: Well,
>:     I'm thinking about it... does that count?  :)

>What a silly question ! Of course !
>Just follow the same rule used with C++. C++ has exception handling,
>namespaces and ( if we count proposals ) type-guards.

>Whitney

I think this is also the same rule so successfully used for Windows NT
since about 1990...

-

Anyway, back to "thinking about it" -- I strongly encourage you to give
it a try. I found it somewhat easier to program, though, using this
set of tools on the SPARC due to the greater screen resolution, since on
a 640x480 screen all the Gadgets panels open in the user track, where on
Suns this is not the case. I'm trying to rearrange some of the panels
(after unlocking them) to fit in the 640x480 system track, but haven't
completed this yet.

Other than this minor complaint, I've been having a lot of fun. The guy
at work I get to compare results with has spent about $4,000 to program
in NextStep on Intel. I convinced him to leave a small DOS partition
so he could run Gadgets and get some real work done :-) :-) :-)

However, Oberon doesn't ship with the complete works of Shakespeare, so
he's got that on me. (NextStep does (!))

Anyway, Gadgets is turning out to be pretty useful. If you're thinking
about messing with it, give it a try. Start with editing Skeleton.Mod
in the DOS distribution and play around.

Be sure and read every line of Gadgets documentation *slowly*, first!

By the way, has someone fixed printing on 8 1/2x11 paper and I never
heard about it? I was going through the usual pains to get an 8 1/2x
11 printout on a PS laser using Script the other day (which I've never
used to print anything before) and accidentally printed a file directly
to the printer. It worked fine. What's the deal? Anyone know?

Best wishes,

-greg
---
Greg DeLozier/Senior Scientific Analyst/L{*filter*}Defense Systems



Fri, 15 Mar 1996 18:42:31 GMT  
 Success with Gadgets...

Quote:
Delozier) writes:
> Other than this minor complaint, I've been having a lot of fun. The guy
> at work I get to compare results with has spent about $4,000 to program
> in NextStep on Intel. I convinced him to leave a small DOS partition
> so he could run Gadgets and get some real work done :-) :-) :-)

> However, Oberon doesn't ship with the complete works of Shakespeare, so
> he's got that on me. (NextStep does (!))

I have a Next machine (now an orphan) and I've been reading this group for  
several weeks, wishing that there were an implementation of Oberon that would  
run on this machine, or failing that at least something that runs under generic  
NextStep.  Does such a thing exist?

Rod Price



Fri, 15 Mar 1996 22:47:56 GMT  
 Success with Gadgets...

Quote:


>Delozier) writes:

>> Other than this minor complaint, I've been having a lot of fun. The guy
>> at work I get to compare results with has spent about $4,000 to program
>> in NextStep on Intel. I convinced him to leave a small DOS partition
>> so he could run Gadgets and get some real work done :-) :-) :-)

>> However, Oberon doesn't ship with the complete works of Shakespeare, so
>> he's got that on me. (NextStep does (!))

>I have a Next machine (now an orphan) and I've been reading this group for  
>several weeks, wishing that there were an implementation of Oberon that would  
>run on this machine, or failing that at least something that runs under generic  
>NextStep.  Does such a thing exist?

Presently, no.  I've not heard of any work being done on this front,
either.  It's a shame.  The next would host Oberon very nicely!  (I've
forgotten how many buttons the Next has on its mouse, though).

Taylor "Middle Name" Hutt
Windows NT tastes like chicken.  No, wait.  Chicken tastes like Windows NT.



Sat, 16 Mar 1996 00:09:17 GMT  
 Success with Gadgets...

Quote:
>(paraphrase of previous thread post,  "only us two programming in gadgets?")
>Well,
>    I'm thinking about it... does that count?  :)
>Doug Danforth
>--
>UMECORP, The creator of UME Voice
>73 Digital Drive
>Novato, CA 94949
>pho (415) 883-1500, fax (415) 883-1711

I will to when I master the basics of Oberon.

--

---------------------------------------------------------------------------
Andrew Wenn          Victoria University of Technology
                     Footscray Campus.



Sat, 16 Mar 1996 07:38:21 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. come changes to the deuce editor gadget

2. Deuce gadgets and streams

3. adobe-svg-gadget available

4. Custom gadgets in a frame

5. Browser gadget sugguestions for a DUIM app

6. DUIM date gadgets for Harlequin Dylan

7. Stuck with displaying a gadget

8. Gadget images & tutorials

9. Gadget images & tutorials

10. Gadgets to LayLa?

11. Questions about Gadgets programming in Linux Native Oberon 2.3.7

12. Gadgets - Link Storage

 

 
Powered by phpBB® Forum Software