home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ARM Club 3
/
TheARMClub_PDCD3.iso
/
hensa
/
programming
/
a220_1
/
Docs
/
Windows
< prev
Wrap
Text File
|
1993-03-02
|
6KB
|
141 lines
Technical description of the 'window' data type
-----------------------------------------------
To make life easier a standard window structure has been defined to allow
library routines to work with a range of different windows, whilst being
able to locate data local to that window.
As a consequence wimp window handles are not generally used as parameters in
the procedures/functions, rather pointers to these defined structures. This
file sets out the format of these structures so that you can create your own
specific window types.
The window library allows for upto 65536 different window 'types'. By
default all created windows are given a null window type (number 0) which
does nothing to describe the window. Simple Text Windows (STW library) are
given a window type 1, thus you can easily work out that upon a redraw
event, say, for any window of type 1 you need to call FNstw_redraw.
Useful routines to keep in mind with windows are :
PROCwin_settype - Sets a window's type
FNwin_findtype - Gets a window's type (or -1 for a bad window structure)
FNwin_findwin - Returns a 'window' given the window handle
(useful for when the WIMP simply gives you a handle)
If you want to create your own window type you should initially give it a
number between &F000 and &FFFF. This will allow future officially released
libraries to fit in with your own libraries without a clash as only
officially released window types should be numbered from &1 to &EFFF. This
does leave you to define upto 4096 types of your own and so should not be
too much of a limitation.
A 'window' is a pointer to a data block which is as follows :
Address Contents Extra description
________________
| |
window - 16 | Identifier | &076Cxxxx where xxxx is the type
|________________|
| |
window - 12 | Local pointer | to data associated with window
|________________|
| |
window - 8 | Wimp Handle |
|________________|
| |
window - 4 | Indirect Data | pointer to indirected icons' data
|________________|
| |
window | Definition Ptr | Pointer to window definition
|________________|
Thus a 'window' is basically a pointer to the last word in a 20 word block.
However with windows created by copying templates (using the templates
library) the window definition follows directly on from this block (ie.
!window = window + 4).
The &076C part of the 'window' identifier is used by the window library for
checking that a given 'window' is valid, and thus all window structures must
contain this value.
The local pointer ( !(window-12) ) is free for the use of a particular
window type, and is not used by the window library at all. For example the
STW library uses this pointer to point to the text contained within the
window.
When a window is destroyed (using PROCtemp_delcopy) the complete structure
is deallocted, and it's contents become undefined. Thus before destroying a
window you should make sure that any data pointed to by the local pointer is
deallocted.
I know the window 'block' may seem a bit odd, particularly as the pointer
points to the final word, but this is for historical reasons which are best
not entered into. It also allows for future extension without affecting any
current libraries (except the window library itself). Thus when writing your
own window routines you can assume the structure given above, but nothing
more as future extensions to this structure will be added to the top of the
data structure (eg. at window!-20, etc.).
Fake Windows
------------
Often you do not wish to have multiple copies of a template floating around,
in many cases just one is enough (eg. the program information window for the
main menu). For this reason it is possible to create a window directly from
the template stored in memory, rather than first creating a copy of the
template. Windows created in this way are termed 'Fake Windows'. This term
refers to the fact that the window structure is very slightly different to
that of a window created from a copy of the template.
A fake window block has a NULL pointer at window!-4 (indirected icons' data
area). This does not mean that there is no area set aside for indirected icons
but it means you can't get at it directly from the window structure.
It is possible, however, to use a fake window in almost exactly the same way
as a normal window, even as far as passing it to PROCtemp_delcopy. If this
is done, however, it is only the fake window that is deleted, NOT the template
(or it's indirected icons' data area). Thus after a PROCtemp_delcopy you could
create another fake window (or normal one) from that template.
Thus the only real difference, as far as the user is concerned, between a
fake window and the normal (copy) window is that you can only have 1 fake
window from each template, but as many copies as you like (memory permitting).
Further more, it does not matter if you create a fake window from a template,
and then create a normal window as a copy of that template.
New Window Types
----------------
When defining a new window type there are a few things that are important :
1) You should always use the access routines FNwin_findtype and PROCwin_settype
for accessing/setting the window type.
2) Your access routines should check that the window passed to it is of the
valid type.
3) You should have a procedure/function to perform the initialisation from
a plain window to a window of your new type.
4) If your window type makes use of the 'local pointer' (window!-12) and
memory is allocated for this purpose, then you should supply a procedure/
function to deallocate this memory and leave window!-12 clear so that the
window can be destroyed without leaving any dangling memory blocks.
5) If your window type needs a redraw routine, this should ideally take the
form of a function taking a single parameter (the wimp_poll_block). This
function should accept any window as it's input, and simply return FALSE
if it is of the wrong type, and return TRUE if it is of the correct type.