crunch@well.UUCP (John Draper) (01/04/87)
This is a very careful explanation of my feeble attempt at trying to use the very poorly documented Layers routines. This is fairly long, but would appreciate anyone who would take the 1-2 minutes of time to "capture" it and try and understand what I'm trying to do. Is it possible to use the Layers Library directly from Intuition. I'm asking this because I haven't seen ANY example code that describes how to do this. Another tutorial is in order if I can find out how to do it, I'll publish the results. Here is what I want to do, and YOU will probably eventually want to do something like this as well. Lets Imagine that we have a standard Intuition Screen (our own customscreen) called "scr" thats declared like this: struct Screen *scr; We open this screen, and window as well, in the normal Intuition way of doing things. In this window, lets pretend there is a smaller section within this window where text is rendered via the Graphics calls "DrawText", where I pass it a Rastport in the normal way; ie: rp = w->RPort; EXAMPLE #1 ---------- Our display screen ------------------------------------------------------ | MENU AREA | |------------------------------------------------------| | | | -------------------------------------- | | | Top Hidden area | | | |--------------------------------------| | | | | | | | Area where text is displayed | | | | | | | | | | | |--------------------------------------| | | | Bottom hidden area | | | -------------------------------------- | | | ------------------------------------------------------ As shown in Example #1, the top and bottom hidden areas are where I want to render text, then I want to be able to scroll up the text and as the text scrolls up, to reveal the text that was rendered in the bottom area, and vice versa if I want to scroll down. The manuals explain what Layers does to control layers, and cryptically mention something about a "common bitmap". For the past 6 days, I've been on a never-ending search, trying to locate where to find this magic "common bitmap". Naturally, the manuals, in keeping up with Amiga documentation standards NEVER MENTION any of this. My feeble attempt, is something like this: rp = w->RPort; bm = rp->BitMap; <--- This is where I THINK!!! this common bitmap is. vp = ViewPortAddress(w); For some strange reason, I have to call this function, otherwize the following LayerInfo field in the layer structure is NULL. layer = rp->Layer; li = layer->LayerInfo; <--- li is NULL if I dont call ViewPortAddress() above. Now, I have my Layer pointer, LayerInfo pointer, Bitmap, and Rasport. I then call My own function called: AddClipPort() in the following way: rgn = AddClipPort(layer, 80, 5, 300,140); rgn is a pointer to a region which I use to DisposeRegion() later. The code to AddClipPort() is as follows: /************************************************************************ AddClipPort(layer, top, left, right, bottom) - Specifies an area on the screen where clipping is to take place, It returns a pointer to a Region which I can later use to dispose the Region. ************************************************************************/ struct Region *AddClipPort(layer, top, left, right, bottom) struct Layer *layer; SHORT top, left, right, bottom; { struct Region *rgn; /* Region to return */ /* Allocate a region */ if ((rgn = NewRegion()) == NULL) { kprintf("Unable to allocate a region in clip.c\n"); return(NULL); } /* Initialize the regions rectangle */ rgn->bounds.MinX = left; rgn->bounds.MinY = top; rgn->bounds.MaxX = right; rgn->bounds.MaxY = bottom; /* Install the Clip Region */ InstallClipRegion(layer, rgn); return(rgn); } AddClipPort is SUPPOSED to make renderings ONLY in the prescribed area in the window as given by the 4 coordinate values. It's SUPPOSED to allow the text to be scrolled and any text that got rendered OUTSIDE of the rectangle would appear at the bottom, if I scrolled that region up. At least thats what the manuals SAY. But who can believe them?? After calling the above function AddClipPort, I draw the text on the screen and want renderings in ONLY the prescribed rectangle. Next, I tried creating my OWN region and my own RegionInfo, then allocating a completly different BitMap altogether from one of the very poorly written example programs that was very hastily hacked together from an un-identified person who used to work at Amiga. I follow the usual sequence of: -- opening Layers library -- calling NewLayerInfo() to get new Layer_Info pointer -- InitBitMap() - with my own SUPERBITMAP that covers both top and bottom hidden areas and the text rendering area. -- AllocRaster() for 2 bitplanes, then clear the bitplanes -- CreateUpfrontLayer() - describing only the text area minus the top hidden area and the bottom hidden areas. -- I get my RasPort "rp" like: rp = layer->rp; < Now I draw the text in the window > < Naturally, it crashes when I call CreateUpfrontLayer() > Next, I tried putting BeginUpdate() just after calling CreateUpfront Layer(), then "EndUpdate()" just before quitting. THAT didn't work. Then After that, I remembered reading in the Layers documentation about doing LockLayerRom, and UnLockLayerROM, but see ABSOLUTLY NO examples using these, but I tried anyway, but NO LUCK. I have the layers.c, region.c, and super.c, and 2-3 other example programs provided by Amiga and they work fine, but I make the very slightest modifications and it breaks. I tried the "slight change" approach where I gradually change an existing program into something more what I want and I fail miserably at that. It failes whenever I try to run Intuition. Which leads me to believe that using Layers from Intuition is either IMPOSSIBLE or Amiga doesn't want programmers to use Layers from Intuition by not giving us enough information to do it. Is the ANYONE OUT THERE that has sucessfully done anything similar to what I tried to explain above?? I'm sorry this message has to be long, but after many postings of my problem earlier, It seems that people somehow mis-understood what I was trying to do, So I took this 2 hours to VERY CAREFULLY explain, with PLENTY of source code examples in the hopes that someone might spot whatever it was that I left out.. Thanx..... Crunch
gary@mit-eddie.MIT.EDU (Gary Samad) (01/05/87)
1.2 provides a routine that was sore lacking to do exactly what the previous poster (sorry, I don't remember your name) wanted - to clip to a region that is smaller than the window. The routine is called ClibRectRegion (I believe). I got it to work and played around a little with it and it works as advertised. However, it does slow things down a bit. You don't have to diddle around with Layers to use it though. I think it is described in the "Enhancer" book, but, if not, drop me a line and I'll see if I can find it again... Gary (617) 655-7449