[comp.windows.x.openlook] NeWS programming question

hogan@bisco.kodak.com (Patrick Hogan) (02/26/91)

Fellow readers,

   This is my first time posting, so please forgive me if I'm posting this 
in the wrong news group. By chance if I am posting in the wrong place, please
direct me to the correct news group !! Anyway, I'm attempting to do some NeWS 
programming and meeting some resistence.

I create a class, ColorCanvas from ClassCanvas, which is later instanciated 
later into another class. (This is bound to get confusing, at the end I have an
example) I attempt to read a sunraster file via readcanvas in to the 
ColorCanvas Canvas entry in its dictionary. Note that the Canvas entry is
actually in its parents dictionary, ClassCanvas. I also have a button that
is "Next" with will determine the next raster file I'm attempting to view
on the canvas from an array.

The delema is that nothing is displayed on the canvas, 
  * the canvas is mapped
  * retained is false
  * no error message is displayed.

I'm a bit confused, since I looked through all kinds of books, as well as the
examples in $OPENWINHOME/demo (specifically "imagedemo") but to no avail.
Any ideas on what is happening would be GREATLY appreciated. 

Thanks in advance for any input you may have. Also If I can elaborate on any 
thing just let me know.


Example:******************************************

/SimpleBag Classbag []
classbegin
  /newinit {
	  /newinit super send }
  .....
  /PaintCanvas nullproc def
classend

/ColorCanvas ClassCanvas
dictbegin
   /ImageArray    null   def
   /ImageName     null   def
   /TheImage      null   def
   /ImageExt     (.im8)  def
   /ImageWidth       0   def
   /ImageHeight      0   def
   /ImageIndex       -1  def
dictend
classbegin
   %% A couple procedures to set up an array - no biggie.

   /newinit {
      %% Call routines to build image array
      /newinit super send
   } def

  /UpdatePicture {
      /TheImage {
          ImageArray ImageIndex get ImageExt append
          imagedirectory (/) append exch append
          readcanvas
      } store
      gsave

%%%     Is ther something else I need to be doing, is there another variable
%%%     I need set, or have I declared something wrong.

        Canvas setcanvas
        TheImage imagecanvas


      grestore
  }def

  /viewraster {
        console (Reading Canvas: %\n)
        [ ImageArray ImageIndex get ImageExt append
        imagedirectory (/) append exch append ] fprintf
        /UpdatePicture self send
  }def

  /nextrast {
      ImageIndex 1 add
      dup 10 lt
      { /ImageIndex exch def }
      { pop /ImageIndex 0 def} ifelse
      /viewraster self send
  } def

classend  def

/ControlArea FlexBag []
classbegin
    /PaintCanvas nullproc def
    /RegisterClient {
        0 0 /preferredsize 3 index send /reshape 5 index send
        /RegisterClient super send
    }def
classend def

/cc framebuffer /new ColorCanvas send def

/next (Next) { /nextrast /sendtarget 3 -1 roll send}
	framebuffer /new OpenLookButton send def

/fb framebuffer /new ControlArea send def
null [/nw {/nw self POSITION 10 -10 XYADD} next] /addclient fb send
10 10 /setpadding fb send

/win [fb cc SimpleBag] [/Footer false]
	framebuffer /new OpenLookBaseFrame send def

/place win send
/activate win send
/map win send

newprocessgroup
************************************************************************

Patrick Hogan        hogan@bisco.Kodak.Com
Voice: (716) 726-7291
-- 

-----------------------------------------------------------
Patrick Hogan