[comp.sys.amiga.programmer] Using the Layers library to do non-Intuition windows

rodent@netcom.COM (Ben Discoe) (04/19/91)

  I'm working on a custom screen and I'd like to manipulate several
"text windows" without using real Intuition windows.  In fact, I am
trying to emulate the manner in which MSDOS applications allow
"windowing" on text-based screens.  I think the Layers library is
ideal for doing this?

  1. The windows won't be moved or resized, but they will be opened,
	closed, and depth-arranged under program control.
  2. Using SMART_REFRESH layers would make the Amiga do all my
	refreshing for me, I assume.
  3. I DON'T want Intuition redirecting the user input, drawing a window
	title, responding to the mouse etc.

  Is creating my own Layers a good idea?  I've never heard of anyone doing
this before (Layers lib seems like toolkit for Intuition's use only).

-------------------
Ben in San Jose, programmer/ecologist at large.

peter@cbmvax.commodore.com (Peter Cherna) (04/20/91)

In article <1991Apr19.003233.16889@netcom.COM> rodent@netcom.COM (Ben Discoe) writes:
>
>  I'm working on a custom screen and I'd like to manipulate several
>"text windows" without using real Intuition windows.  In fact, I am
>trying to emulate the manner in which MSDOS applications allow
>"windowing" on text-based screens.  I think the Layers library is
>ideal for doing this?

Yes it is.  You will be able to use it readily, if you keep Intuition
out of your way.  Just keep in mind that you have to allocate your
own screen-equivalent, and associate a Layer_Info with it.  Windows
and requesters are built on Layer structures.  Window-functions
have underlying layers versions, when applicable.

>  2. Using SMART_REFRESH layers would make the Amiga do all my
>	refreshing for me, I assume.

This is true, with the exception of sizing layers bigger, which you
say you won't do.

     Peter
--
Peter Cherna, Operating Systems Development Group, Commodore-Amiga, Inc.
{uunet|rutgers}!cbmvax!peter    peter@cbmvax.commodore.com
My opinions do not necessarily represent the opinions of my employer.
"If all you have is a hammer, everything looks like a nail."

markv@kuhub.cc.ukans.edu (04/20/91)

In article <1991Apr19.003233.16889@netcom.COM>, rodent@netcom.COM (Ben Discoe) writes:
> 
>   I'm working on a custom screen and I'd like to manipulate several
> "text windows" without using real Intuition windows.  In fact, I am
> trying to emulate the manner in which MSDOS applications allow
> "windowing" on text-based screens.  I think the Layers library is
> ideal for doing this?
> 
>   1. The windows won't be moved or resized, but they will be opened,
> 	closed, and depth-arranged under program control.
>   2. Using SMART_REFRESH layers would make the Amiga do all my
> 	refreshing for me, I assume.
>   3. I DON'T want Intuition redirecting the user input, drawing a window
> 	title, responding to the mouse etc.
> 
>   Is creating my own Layers a good idea?  I've never heard of anyone doing
> this before (Layers lib seems like toolkit for Intuition's use only).

No, generally its not.  Esp. if your a novice Amiga programmer there
is a lot to worry about with Layers library.  I would use intution and
open windows with the following either as BORDERLESS or with no flags
(which will give a single line border but no system gadgets).
Intuition will only render what it is supposed to.  With a BORDERLESS
SMARTREFRESH inituion will refresh exposed areas, although you still
have to deal with REFRESH messages, such as when its resized.  

I suggest using windows because Windows are much easier to deal with
and much less easy to cause problems with than simple layers.  You can
still use intuition to do your window managment, but under program
control, via things like WindowToFront(), ResizeWindow(), MoveWindow()
etc.  Also, since you have a text application, if you wish to have a
true charecter stream input and/or output, you can attach consoles to
each window, for either read, write, or both.  For instance, I did a
simple editor that I used Intuition for input (to support menus, etc),
but by having a console attached to the window for output, things were
greatly simplified.  This is even more powerful with the 2.0 console
device.  In 2.0 you can even attach a DOS CON: filehandle to an
existing window with an open call like:

	FILE		*ConOut;
	struct Window   *MyWind:
	char		*ConName[255+1];

	MyWind = OpenWindow(foo stuff...);

	sprintf(ConName, "CON://////WINDOW %p", MyWind);

	ConOut = fopen(ConName, "w");

or open a "quiet" CON like:

    ConOut = fopen("CON:/0/0/640/200/DummyTitle/NOBORDER/NODRAG/NOSIZE", "w");

In General, the 2.0 CON: supports the following flags (that are
seperated by / following the Title argument):

	AUTO	-Only open if I/O occurs.
	CLOSE	-Put Close gadget on window
	WAIT	-Hold of close until Close gad clicked or CTRL-\
	WINDOW 0xAddr -Use Specifed window (may be on custom screen).
	SCREEN name   -Open on public screen name
	BACKDROP -Open as backdrop window.
	NODRAG	 -Leave off drag bar (and title)
	NOBORDER -BORDLESS window
	NOSIZE	 -Leave off sizing gad
	SIMPLE	 -Open as SIMPLE_REFRESH
	SMART	 -Open as SMART_REFRESH

Hope this helps.

> -------------------
> Ben in San Jose, programmer/ecologist at large.
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mark Gooderum			Only...		\    Good Cheer !!!
Academic Computing Services	       ///	  \___________________________
University of Kansas		     ///  /|         __    _
Bix:	  mgooderum	      \\\  ///  /__| |\/| | | _   /_\  makes it
Bitnet:   MARKV@UKANVAX		\/\/  /    | |  | | |__| /   \ possible...
Internet: markv@kuhub.cc.ukans.edu
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

baxter_a@wehi.dn.mu.oz (04/20/91)

In article <1991Apr19.003233.16889@netcom.COM>, rodent@netcom.COM (Ben Discoe) writes:


Step 1: Get the Rom Kernal Manual and read the chapter on windows.

> 
>   I'm working on a custom screen and I'd like to manipulate several
> "text windows" without using real Intuition windows.  In fact, I am
> trying to emulate the manner in which MSDOS applications allow
> "windowing" on text-based screens.  I think the Layers library is
> ideal for doing this?
> 
>   1. The windows won't be moved or resized, but they will be opened,
> 	closed, and depth-arranged under program control.

Don't set the flags for dragging, resizing or depth arrangement.
(I really wonder why you want to go backwards with the GUI though)


>   2. Using SMART_REFRESH layers would make the Amiga do all my
> 	refreshing for me, I assume.

Use SMART_REFRESH windows. But your window will be so easy to refresh anyway
you may as well you SIMPLE and do it yourself.

>   3. I DON'T want Intuition redirecting the user input, drawing a window
> 	title, responding to the mouse etc.

Turn off system requesters  (I can send code.
Don't have a window title.
Set no IDCMP flags.

(You are really not doing yourself a favour)


> 
>   Is creating my own Layers a good idea?  I've never heard of anyone doing
> this before (Layers lib seems like toolkit for Intuition's use only).
> 

No. It is silly.

> -------------------
> Ben in San Jose, programmer/ecologist at large.


Regards Alan

peter@sugar.hackercorp.com (Peter da Silva) (04/22/91)

In article <1991Apr19.003233.16889@netcom.COM> rodent@netcom.COM (Ben Discoe) writes:
>   I'm working on a custom screen and I'd like to manipulate several
> "text windows" without using real Intuition windows.  In fact, I am
> trying to emulate the manner in which MSDOS applications allow
> "windowing" on text-based screens.  I think the Layers library is
> ideal for doing this?

Why are you doing this?

If this is for a real program, please reconsider. The biggest advantage that
the Mac has is that Apple sits down hard on developers that break with their
look and feel (and sits down hard on competitors that don't. :-<). In any case,
proghrams should work as hard as they can to stick to the general Amiga user
interface. Why make things harder for yourself when all it'll do is hurt?
-- 
Peter da Silva.   `-_-'
<peter@sugar.hackercorp.com>.

ken@cbmvax.commodore.com (Ken Farinsky - CATS) (04/22/91)

In article <1991Apr19.162052.29848@kuhub.cc.ukans.edu> markv@kuhub.cc.ukans.edu writes:
>
>...I would use intution and
>open windows with the following either as BORDERLESS or with no flags
>(which will give a single line border but no system gadgets).

Careful...You have to respect the border size given in the window
structure.  While under 1.3 the window may appear to have a single pixel
border, the border size reported by win->BorderXXX will be larger.
Under 2.0 the border is three pixels wide all the way around for
a window that is not borderless but has no border gadgets.  There
is an inner border, a gap, and an outter border.

>Mark Gooderum			Only...		\    Good Cheer !!!
>Internet: markv@kuhub.cc.ukans.edu
-- 
--
Ken Farinsky - CATS - (215) 431-9421 - Commodore Business Machines
uucp: ken@cbmvax.commodore.com   or  ...{uunet,rutgers}!cbmvax!ken
bix:  kfarinsky

jimm@amiga.UUCP (Jim Mackraz) (04/23/91)

(Peter Cherna) writes:
)(Ben Discoe) writes:
)>
)>  I'm working on a custom screen and I'd like to manipulate several
)>"text windows" without using real Intuition windows.  In fact, I am
)>trying to emulate the manner in which MSDOS applications allow
)>"windowing" on text-based screens.  I think the Layers library is
)>ideal for doing this?
)
)Yes it is.  You will be able to use it readily, if you keep Intuition
)out of your way.  Just keep in mind that you have to allocate your
)own screen-equivalent, and associate a Layer_Info with it.  Windows
)and requesters are built on Layer structures.  Window-functions
)have underlying layers versions, when applicable.

Intuition will probably get confused when the user clicks over a
non-Intuition layer.  Depends on which LayerInfo you use, I think:
Intuition's or your own.

Ben, you didn't mention why borderless Intuition windows wouldn't
work for you.  I'm not sure your comments on input redirection
were right on the mark, to the point of making it worthwhile to
try to go about your  project this way...

	jimm

-- 
--- opinions expressed herein are my own. ---
"... Because they can."
		- profound punchline to joke about dogs

rodent@netcom.COM (Ben Discoe) (04/24/91)

It seems I did a poor job of stating my original question about using the
Layers library directly.
  1. I have 6 years experience, telling me to "get the RKM" hurts.
  2. I CANNOT use a intuition window, because there is NO WAY to keep
intuition from drawing into a window when you activate it with the mouse.
Yes, even if you specify a borderless, title-less window with no gadgets,
Intuition will still paint a bar at the top of the window when you click
in it.  Also, I will no longer be able to receive input through my
original, backdrop window if I open other Intuition windows.  Tapping
the input device is (hopefully) unnecessary trouble.

  To explain why I seem to be going backwards in GUI evolution, let me
explain: I am very seriously creating a dBASE 4 work-a-like for the Amiga.
dBASE 4 windows are drawn with text, have no gadgets and in fact do not
support mice at all.  I would use text buffers to refresh each window,
but that involves writing my own text-based window manager to handle
refreshing.  I though, why do that when the Layers library will do refreshing
for me, and allow me to draw lines graphically in the windows as well?

  All I need is to define areas of my main window that can be depth-arranged.
(and opened, closed etc. like windows.)  My question is: can I use the
Layers library to do this, or will Intuition interfere, making it unfeasable?
I hope I've made myself clear... it is frustrating to be so misunderstood.

------------------
Ben in San Jose, trying to do Great Things for the Amiga.

peter@cbmvax.commodore.com (Peter Cherna) (04/25/91)

In article <1991Apr24.031607.28073@netcom.COM> rodent@netcom.COM (Ben Discoe) writes:
>  2. I CANNOT use a intuition window, because there is NO WAY to keep
>intuition from drawing into a window when you activate it with the mouse.
>Yes, even if you specify a borderless, title-less window with no gadgets,
>Intuition will still paint a bar at the top of the window when you click
>in it.

I suspect that your title-less window actually has a window title of "",
instead of NULL.  A null-string will give you the problem you report.
A NULL pointer for NewWindow.Title (along with the BORDERLESS flag,
and none of the WINDOW(DRAG|CLOSE|SIZE|DEPTH) flags) will make the
problem go away.

>Also, I will no longer be able to receive input through my
>original, backdrop window if I open other Intuition windows.  Tapping
>the input device is (hopefully) unnecessary trouble.

The best way is to make all your windows share a single IDCMP port.
That way, you don't have to worry about which window is providing
input, unless you care.  Send mail if you don't know the technique
for sharing IDCMP ports among multiple windows.

>  To explain why I seem to be going backwards in GUI evolution, let me
>explain: I am very seriously creating a dBASE 4 work-a-like for the Amiga.
>dBASE 4 windows are drawn with text, have no gadgets and in fact do not
>support mice at all.  I would use text buffers to refresh each window,
>but that involves writing my own text-based window manager to handle
>refreshing.  I though, why do that when the Layers library will do refreshing
>for me, and allow me to draw lines graphically in the windows as well?

I'd recommend doing your dbase-like rendering inside a regular Amiga
window.  If you use the BridgeBoard software, you get exactly
that effect (a PC window with an Amiga border around it).
If you remain unconvinced that you should use regular Amiga windows
with borders, think again.  If you're still unconvinced, use
borderless windows.  It can work.

>------------------
>Ben in San Jose, trying to do Great Things for the Amiga.

     Peter
--
Peter Cherna, Operating Systems Development Group, Commodore-Amiga, Inc.
{uunet|rutgers}!cbmvax!peter    peter@cbmvax.commodore.com
My opinions do not necessarily represent the opinions of my employer.
"If all you have is a hammer, everything looks like a nail."

sschaem@starnet.uucp (Stephan Schaem) (04/25/91)

 Let me try that! I know it dont happen with BACKDROP window.
 So I open a window on my screen with stuff on it covering it...
 Select/deselect/deselect... Nothing.
 So if your problem is intuition modifying your window bitmap when
 selection, then you should look at your window setup.
 My curent is done with a customscreen V1.3, BACKDROP and non BACKDROP
 window, BORDERLESS!SIMPLE_REFRESH!ACTIVATE
 !RMBTRAP!NOCAREREFRESH !BACKDROP...
 Going to try on 2.... Same thing happen, nothing.

 But I might have done the test wrong? what parameters should I
 take/add...

						Stephan.

jsmoller@jsmami.UUCP (Jesper Steen Moller) (04/26/91)

In article <1991Apr24.031607.28073@netcom.COM> rodent@netcom.COM (Ben Discoe) writes:
> 
> It seems I did a poor job of stating my original question about using the
> Layers library directly.
>   1. I have 6 years experience, telling me to "get the RKM" hurts.
>   2. I CANNOT use a intuition window, because there is NO WAY to keep
> intuition from drawing into a window when you activate it with the mouse.
Oh yes there is!
> Yes, even if you specify a borderless, title-less window with no gadgets,
> Intuition will still paint a bar at the top of the window when you click
> in it.

Hey ho! That's not what my Intuition says... I get the rendering I need
from (BORDERLESS | SMART_REFRESH | RMBTRAP | ACTIVATE | NOCAREREFRESH),
and that is none. Not on deactivating og activating windows or anything.
Neither on 2.0 er 1.3. I use no title, of course (have it set to NULL).

>  Also, I will no longer be able to receive input through my
> original, backdrop window if I open other Intuition windows.

Well you could easily merge the input streams from all the windows and
pass the same IDCMP-codes to each of the child windows as to the backdrop
one. I have no code for this as of this moment (haft past one and I'm
tired as h*ll), but somebody out there has shared an IDCMP port and is
willing to share it with you, I'm sure.

> Tapping the input device is (hopefully) unnecessary trouble.

Yes.

>   To explain why I seem to be going backwards in GUI evolution, let me
> explain: I am very seriously creating a dBASE 4 work-a-like for the Amiga.
Now that's going somewhere!

> dBASE 4 windows are drawn with text, have no gadgets and in fact do not
> support mice at all.  I would use text buffers to refresh each window,
> but that involves writing my own text-based window manager to handle
> refreshing.  I though, why do that when the Layers library will do refreshing
> for me, and allow me to draw lines graphically in the windows as well?
> 
>   All I need is to define areas of my main window that can be depth-arranged.
> (and opened, closed etc. like windows.)  My question is: can I use the
> Layers library to do this, or will Intuition interfere, making it unfeasable?
> I hope I've made myself clear... it is frustrating to be so misunderstood.

I understand you, but I think you have missed something with intuition.
You _can_ keep it from rendering into your windows, for sure.

> Ben in San Jose, trying to do Great Things for the Amiga.

Well I appreciate it - I try to do that myself (not succesful)

--                     __
Jesper Steen Moller   ///  VOICE: +45 31 62 46 45
Maglemosevej 52  __  ///  USENET: cbmehq!cbmdeo!jsmami!jsmoller
DK-2920 Charl    \\\///  FIDONET: 2:231/84.45
Denmark           \XX/

schwager@m.cs.uiuc.edu (Michael Schwager) (04/27/91)

jsmoller@jsmami.UUCP (Jesper Steen Moller) writes:

>In article <1991Apr24.031607.28073@netcom.COM> rodent@netcom.COM (Ben Discoe) writes:
>> 
>> It seems I did a poor job of stating my original question about using the
>> Layers library directly.
>>   1. I have 6 years experience, telling me to "get the RKM" hurts.
>>   2. I CANNOT use a intuition window, because there is NO WAY to keep
>> intuition from drawing into a window when you activate it with the mouse.
>Oh yes there is!
>> Yes, even if you specify a borderless, title-less window with no gadgets,
>> Intuition will still paint a bar at the top of the window when you click
>> in it.

In my project I open a window with the following NewWindow structure:

struct NewWindow SetupWindowOrig = {
  225,50,
  SETUP_X, SETUP_Y,
  BLUE,BLUE,
  VANILLAKEY|MOUSEBUTTONS|GADGETUP|GADGETDOWN|INTUITICKS, /* IDCMP flags
first */
  BORDERLESS|SUPER_BITMAP|RMBTRAP, /* Window Flags */
  &SetupGadgets, /* was &MyGadget */
  NULL,
  NULL, /* text */
  NULL,
  NULL,
  0, 0,
  NULL, NULL,
  CUSTOMSCREEN
  };

I have a 3 bitplane custom screen open already.  Then I do this:
(bm is a bitmap structure, of course)

  InitBitMap (&bm, 3, SETUP_X, SETUP_Y);
  for (i = 0; i < 3; i++) {
    if (! (bm.Planes[i] = (PLANEPTR) AllocRaster (SETUP_X, SETUP_Y))) {
      FreeupRaster(&bm);
      shutdown ("Can't allocate bitplanes!");
    }
  }
/* just a little iff loader into the bitmap here */
  dsplay_win ("SetupWindow.iff", &bm, SETUP_X, SETUP_Y);
  SetupWindowOrig.BitMap = &bm;

Then I open my window:
  if ((SetupWindow = (struct Window *) OpenWindow (&SetupWindowOrig)) ==
      NULL)
    shutdown ("Can't open setup window");


I never have a problem with Intuition drawing unwanted things into my
Window.
-Mike