The functions in this section are simplified versions of Amiga system functions (in the Intuition library, as the title suggests). To make best use of them you are probably going to need something like the Rom Kernel Reference Manual (Libraries), especially if you want to understand the Amiga specific things like IDCMP and raster ports.
The descriptions given here vary slightly in style from the previous descriptions. All function parameters can be expressions which represent numbers or addresses, as appropriate. Because many of the functions take several parameters they have been named (fairly descriptively) so they can be more easily referenced.
OpenW(x,y,wid,hgt,idcmp,wflgs,title,scrn,sflgs,gads,tags=NIL)
NIL is returned.
NIL).
If sflgs is $F (i.e., 15) the window will open on the custom screen pointed to by scrn (which must then be valid).
See OpenS to see how to open a custom screen and get a screen pointer.
NIL if you don't want any gadgets.
These are not the standard window gadgets, since they are specified using the window flags.
A gadget list can be created using the Gadget function.
NIL.
See the Rom Kernel Reference Manual (Libraries) for details about the available tags and their meanings.
There's not enough space to describe all the fine details about windows and IDCMP (see the Rom Kernel Reference Manual (Libraries) for complete details), but a brief description in terms of flags might be useful. Here's a small table of common IDCMP flags:
IDCMP Flag Value -------------------------- IDCMP_NEWSIZE $2 IDCMP_REFRESHWINDOW $4 IDCMP_MOUSEBUTTONS $8 IDCMP_MOUSEMOVE $10 IDCMP_GADGETDOWN $20 IDCMP_GADGETUP $40 IDCMP_MENUPICK $100 IDCMP_CLOSEWINDOW $200 IDCMP_RAWKEY $400 IDCMP_DISKINSERTED $8000 IDCMP_DISKREMOVED $10000
Here's a table of useful window flags:
Window Flag Value -------------------------- WFLG_SIZEGADGET $1 WFLG_DRAGBAR $2 WFLG_DEPTHGADGET $4 WFLG_CLOSEGADGET $8 WFLG_SIZEBRIGHT $10 WFLG_SIZEBBOTTOM $20 WFLG_SMART_REFRESH 0 WFLG_SIMPLE_REFRESH $40 WFLG_SUPER_BITMAP $80 WFLG_BACKDROP $100 WFLG_REPORTMOUSE $200 WFLG_GIMMEZEROZERO $400 WFLG_BORDERLESS $800 WFLG_ACTIVATE $1000
All these flags are defined in the module `intuition/intuition', so if you use that module you can use the constants rather than having to write the less descriptive value (see 12 Modules). Of course, you can always define your own constants for the values that you use.
You use the flags by OR-ing the ones you want together, in a similar way to using sets (see 8.5 Sets).
However, you should supply only IDCMP flags as part of the idcmp parameter, and you should supply only window flags as part of the wflgs parameter.
So, to get IDCMP messages when a disk is inserted and when the close gadget is clicked you specify both of the flags IDCMP_DISKINSERTED and IDCMP_CLOSEWINDOW for the idcmp parameter, either by OR-ing the constants or (less readably) by using the calculated value $8200.
Some of the window flags require some of IDCMP flags to be used as well, if an effect is to be complete.
For example, if you want your window to have a close gadget (a standard window gadget) you need to use WFLG_CLOSEGADGET as one of the window flags.
If you want that gadget to be useful then you need to get an IDCMP message when the gadget is clicked.
You therefore need to use IDCMP_CLOSEWINDOW as one of the IDCMP flags.
So the full effect requires both a window and an IDCMP flag (a gadget is pretty useless if you can't tell when it's been clicked).
The worked example in Part Three illustrates how to use these flags in this way (see 22.1 Gadgets).
If you only want to output text to a window (and maybe do some input from a window), it may be better to use a console window.
These provide a text based input and output window, and are opened using the Dos library function Open with the appropriate `CON:' file name.
See the AmigaDOS Manual for more details about console windows.
CloseW(winptr)
NIL for winptr, but in this case, of course, no window will be closed!
The window pointer is usually a pointer returned by a matching call to OpenW.
You must remember to close any windows you may have opened before terminating your program.
OpenS(wid,hgt,depth,scrnres,title,tags=NIL)
NIL is returned.
SetColour function.
The screen resolution flags control the screen mode. The following (common) values are taken from the module `graphics/view' (see 12 Modules). You can, if you want, define your own constants for the values that you use. Either way it's best to use descriptive constants rather than directly using the values.
Mode Flag Value ------------------------ V_LACE $4 V_SUPERHIRES $20 V_PFBA $40 V_EXTRA_HALFBRITE $80 V_DUALPF $400 V_HAM $800 V_HIRES $8000
So, to get a hires, interlaced screen you specify both of the flags V_HIRES and V_LACE, either by OR-ing the constants or (less readably) by using calculated value $8004.
There is a worked example using this function in Part Three (see 22.4 Screens).
CloseS(scrnptr)
NIL for scrnptr, but in this case, of course, no screen will be closed!
The screen pointer is usually a pointer returned by a matching call to OpenS.
You must remember to close any screens you may have opened before terminating your program.
Also, you must close all windows that you opened on your screen before you can close the screen.
Gadget(buf,glist,id,flags,x,y,width,text)
Gadget will use the array as the buffer, and subsequent calls use the result of the previous call as the buffer (since this function returns the next free position in the buffer).
a, this parameter should be NIL.
For all other gadgets in the list this parameter should be the array a.
Once a gadget list has been created by possibly several calls to this function the list can be passed as the gads parameter to OpenW.
There is a worked example using this function in Part Three (see 22.1 Gadgets).
Mouse()
Button Pressed Value ---------------------- Left %001 Right %010 Middle %100
So, if this function returns %001 you know the left button is being pressed, and if it returns %110 you know the middle and right buttons are both being pressed.
This mouse function is not strictly the proper way to do things.
It is suggested you use this function only for small tests or demo-like programs.
LeftMouse and WaitLeftMouse can be used to do things in a friendly way, but are restricted to seeing when the left mouse button is pressed.
More generally, the proper way of getting mouse details is to use the appropriate IDCMP flags for your window, wait for events (using WaitIMessage, for example) and decode the received information.
MouseX(winptr)
As above, this mouse function is not strictly the proper way to do things.
MouseY(winptr)
As above, this mouse function is not strictly the proper way to do things.
LeftMouse(winptr)
TRUE if left mouse button has been clicked in the window pointed to by winptr, and FALSE otherwise.
In order for this to work sensibly the window must have the IDCMP flag IDCMP_MOUSEBUTTONS set (see above).
This function does things in a proper, Intuition-friendly manner and so is a good alternative to the Mouse function.
WaitIMessage(winptr)
MsgXXX functions to get some more information about the message.
See the Rom Kernel Reference Manual (Libraries) for more details on Intuition and IDCMP.
There is a worked example using this function in Part Three (see 22.2 IDCMP Messages).
This function is basically equivalent to the following function, except that the MsgXXX functions can also access the message data held in the variables code, qual and iaddr.
PROC waitimessage(win:PTR TO window)
DEF port,msg:PTR TO intuimessage,class,code,qual,iaddr
port:=win.userport
IF (msg:=GetMsg(port))=NIL
REPEAT
WaitPort(port)
UNTIL (msg:=GetMsg(port))<>NIL
ENDIF
class:=msg.class
code:=msg.code
qual:=msg.qualifier
iaddr:=msg.iaddress
ReplyMsg(msg)
ENDPROC class
MsgCode()
code part of the message returned by WaitIMessage.
MsgIaddr()
iaddr part of the message returned by WaitIMessage.
There is a worked example using this function in Part Three (see 22.2 IDCMP Messages).
MsgQualifier()
qual part of the message returned by WaitIMessage.
WaitLeftMouse(winptr)
IDCMP_MOUSEBUTTONS set for the window (see above).
This function does things in a proper, Intuition-friendly manner and so is a good alternative to the Mouse function.
Go to the Next or Previous section, the Detailed Contents, or the Amiga E Encyclopedia.