home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD1.bin
/
useful
/
dev
/
c
/
cmanual
/
intuition
/
windows
/
windows.doc
< prev
next >
Wrap
Text File
|
1993-10-12
|
37KB
|
1,097 lines
2 WINDOWS
2.1 INTRODUCTION
Windows are rectangular boxes which can be as big as the screen
or only 1 pixel wide. They can be resized, moved around on the
screen, put in front or behind other windows and so on. All
this is taken care of by Intuition, and your program does not even
need to know about it if you do not want.
The aim with Windows is to make the communication between the
user and the computer as easy as possible. Windows gives the
user a structured display which is easy to understand. It also
allows the user to interact with the programs through graphics
symbols (gadgets) which can be connected to the windows. (See
chapter 4 GADGETS for more information about gadgets.)
Windows are working close together with screens, since the
screen's resolution etc affects the way the windows are drawn.
Moving a screen will also result in moving all the windows
connected to that screen.
2.2 SPECIAL WINDOWS
The normal windows are rectangular boxes with a border around.
However, there exist some special types of windows:
2.2.1 BACKDROP WINDOWS
Backdrop Windows will always be behind any other windows. This
allows you to have a window in the bottom of the display, and
it will stay there, even if the user is using the "depth-
arrange gadgets".
Backdrop Windows differ from other windows since:
- It will always open behind all other windows, including other
already opened Backdrop Windows.
- The "close-window gadget" is the only System Gadget you can
attach to a Backdrop Window. (You can of course attach your
own gadgets as usual.)
- It will always be behind any other windows.
The Backdrop Window is very handy when you want to have a
bottom drawing (for example your main display), with some tools
etc on top of the bottom window. This allows the user to move
around your tools as he/she wants without needing to worry
about hiding the windows behind the main display.
Drawing into a Backdrop Window instead of the screen itself is
very common since you can then not draw anything at the wrong
moment. If a menu (See chapter 5 MENUS for more information) is
displayed, the drawing routines will wait automatically, and
will therefore not destroy the menu, as it would have happened
if you were drawing directly into the screen.
2.2.2 BORDERLESS WINDOWS
Borderless windows are as normal windows except that they
(surprise, surprise) do not have any borders. It is very common
to combine a Borderless window with a Backdrop window, to cover
a screen.
It can be confusing for the user if a Borderless window does
not cover the entire display, since he/she will not be able to
see where the window's edges are. It is therefore normally
best to make a Borderless window as big as the screen.
2.2.3 GIMMEZEROZERO WINDOWS
A Gimmezerozero Window is as a normal window, except that it
consist of two drawing areas: one Outer and one Inner window.
The Outer window is used for displaying the borders, system
gadgets etc, while the Inner window is only used by yourself.
If you are drawing into a normal window you need to start some
pixels down/out (11, 1), so you do not draw into the borders
etc. However, if you are drawing into a Gimmezerozero Window
you do not need to make any adjustments. The top left corner of
your inner window is always at the position (0,0).
Gimmezerozero Windows are therefore very handy if you want to
make a lot of drawings, without wanting to worry about the
borders. The disadvantages is that it takes more memory and
processing time than a normal window.
2.2.4 SUPERBITMAP WINDOWS
If you are using a SuperBitMap Window you allocate display
memory yourself for the window instead of letting Intuition
take care of it. The advantage is that you can define a larger
drawing area than the size of the window. You can then scroll
the drawing area inside the window. A good example of this are
the demo programs that followed with you Workbench disk when
you bought your computer.
It normally best to combine a SuperBitMap Window together with
a Gimmezerozero Window. The borders etc will then NOT be drawn
into your SuperBitMap, and will instead be drawn in the Outer
window. This allows you to make whatever you want with the
inner window without destroying any borders etc.
2.3 SYSTEM GADGETS
The System Gadgets enables the user to move the window, resize
it, push it behind other windows etc, without your program even
knowing about it. The System Gadgets are controlled by
Intuition, and are always looking the same. The only thing you
need to do is to tell Intuition which gadgets you want, and the
rest is done for you.
The five System Gadgets are placed like this:
1 2 3 4
[*][***********][*][*]
| |
| WINDOW |
| |
| |
|__________________[*]
5
1 Close Gadget. Press this to close the window. (This is the
only System Gadget which your program have to respond to.
Your program will be told that the user has clicked on the
Close Gadget, but you need to close the window yourself by
calling the function CloseWindow().)
2 Drag Gadget. Pressing the left mouse button somewhere on it
and move the mouse while the button is still pressed, will
move the window. If your window has a title it will be
displayed over the Drag Gadget, but will not interfere with
it.
3 Depth-Arrangement Gadget BACK. Clicking on this gadget will
push the window behind all other windows.
4 Depth-Arrangement Gadget UP. Clicking on this gadget will
put the window in front of all other windows.
5 Sizing Gadget. Pressing the left mouse button somewhere on
it and move the mouse while the button is still pressed,
will change the size of the window.
2.4 REDRAWING THE WINDOW DISPLAY
Since windows can be dragged around the screen it is very
common that they sometimes overlap each other. If the user is
then moving away the top window, the bottom window has to be
refreshed.
There exist two methods of redrawing the window:
- Simple Refresh. Intuition will only tell you that you need
to refresh it, and your program has to redraw everything
itself.
- Smart Refresh. Intuition saves the obscured pieces, and
replaces them automatically. Needs more memory than Simple
Refresh, but redraws the display much faster.
If you have a SuperBitMap Window, you have allocated the
display memory yourself, and your window will therefore not be
destroyed by other windows.
If you change the size of a Simple Refresh Window, or it is
revealed after having been overlapped, Intuition will tell you
that you need to refresh the window. A Smart Refresh Window
will only ask you to redraw its display if you enlarged it.
The IDCMP message "REFRESHWINDOW" tells you that the window
needs to be refreshed. (See chapter 8 IDCMP for more about
IDCMP flags.)
IMPORTANT! If your program receive a REFRESHWINDOW message you
must call the functions BeginRefresh() - EndRefresh():
- BeginRefresh() will make the redrawing as fast as possible.
Only the destroyed pieces of the window will be refreshed.
- EndRefresh() tells Intuition that you are finished with the
redrawing.
If you receive a REFRESHWINDOW message and you do not want to
redraw the display, you should still call the two functions.
This will clear up the system and reorganize the Layer Library.
2.5 INITIALIZE A WINDOW
Before you can open a window you need to initialize a NewWindow
structure which looks like this:
struct NewWindow
{
SHORT LeftEdge, TopEdge;
SHORT Width, Height;
UBYTE DetailPen, BlockPen;
ULONG IDCMPFlags;
ULONG Flags;
struct Gadget *FirstGadget;
struct Image *CheckMark;
UBYTE *Title;
struct Screen *Screen;
struct BitMap *BitMap;
SHORT MinWidth, MinHeight;
SHORT MaxWidth, MaxHeight;
USHORT Type;
};
LeftEdge: Initial x position of the window.
TopEdge: Initial y position of the window.
Width: Initial width of the window. If the window is
connected to a high-resolution screen, it can be
anything between 1 and 640. Otherwise (low-
resolution screen) it can be between 1 and 320.
Height: