Aros/Developer/Docs/Libraries/Intuition
Contents |
[edit] Introduction
- V34 = Amiga OS1.3
- V36 = Amiga OS2.x
- V37 = Amiga OS3.0
- V39 = Amiga OS3.1 AROS compatibility level
A typical application or game will involve...
- Setup any libraries, screen(s), windows.
- Setup any required intuition-based gadgets, menus and requesters or zune (mui-based) gadgets, menus and requesters.
- Wait() for a message from Intuition/Zune about user activity or other events.
- Copy needed data from the message and tell Intuition/Zune you received it by replying. Look at the data and take the appropriate action. e.g. (presses a key on the keyboard or moves the mouse, gadgets hits, menu item selection, time elapsing, disk insertion, disk removal, and window rearrangement.)
- Repeat until the user wants to quit. (then closes windows, screen(s) and libraries)
Most of the time, you will not need to setup a screen as you will frequently use an already in use public screen (Wanderer or another WB replacement), so you can jump to opening windows on that screen.
[edit] Screens
AROS (like Amigas before) supports a concept called screens, each screen can be setup with a specific resolution and color depth, limited by the monitor drivers or CRT or LCD display used.
- Own public screen where main application can "host" additional modules with same screen specs etc if needed
- Default shared public screen (NULL usually known as Wanderer, Scalos or Workbook) means multiple applications reside on the same screen which saves memory
- Last option, is a custom screen creates a new display for each application, i.e. if you want a specific resolution and color depth. Opening any new screen uses memory.
[edit] Opening a Screen using OpenScreenTags()
Below is the public structure that is already setup inside AROS, a template as such, for quick use in programming.
struct Screen {
struct Screen *NextScreen; /* linked list of screens */
struct Window *FirstWindow; /* linked list Screen's Windows */
WORD LeftEdge, TopEdge; /* parameters of the screen */
WORD Width, Height; /* parameters of the screen */
WORD MouseY, MouseX; /* position relative to upper-left */
UWORD Flags; /* see definitions below */
UBYTE *Title; /* null-terminated Title text */
UBYTE *DefaultTitle; /* for Windows without ScreenTitle */
/* Bar sizes for this Screen and all Window's in this Screen */
BYTE BarHeight, BarVBorder, BarHBorder, MenuVBorder, MenuHBorder;
BYTE WBorTop, WBorLeft, WBorRight, WBorBottom;
struct TextAttr *Font; /* this screen's default font */
/* the display data structures for this Screen */
struct ViewPort ViewPort; /* underlying graphics struct for each screen (&my_screen->ViewPort) */
struct RastPort RastPort; /* allow direct rendering into the screen (not useful) &my_screen->RastPort) */
struct BitMap BitMap; /* Screen->RastPort.BitMap in place of &Screen->BitMap whenever possible */
struct Layer_Info LayerInfo; /* each screen gets a LayerInfo */
/* Only system gadgets may be attached to a screen. The standard system Screen Gadgets automatically */
struct Gadget *FirstGadget;
UBYTE DetailPen, BlockPen; /* for bar/border/gadget rendering */
/* the following variable(s) are maintained by Intuition to support the DisplayBeep() color flashing technique */
UWORD SaveColor0;
/* This layer is for the Screen and Menu bars */
struct Layer *BarLayer;
UBYTE *ExtData;
UBYTE *UserData; /* general-purpose pointer to User data extension */
};
Each line adds and stores a bit of information about the screen in use. Each additional struct inside the Screen struct is an already existing 'blob' of pre-defined data storage inside AROS. A lot of AROS depends on struct's being used inside newer struct's to aid and speed up development.
every screen has a struct ViewPort (screen represent by graphics library) and each screen has a drawinfo (high level) and struct RastPort (low level handle that graphics library uses to draw on that screen). View is the whole display, including all visible screens accessed by ViewAddress()
- to write stuff we use *something (e.g. *myScreen)
- to read stuff we use &something (e.g. &myScreen)
- something (on its own) to describe which item exactly (e.g. myScreen)
Tags are a list of parameter names followed comma and then by a value. For example to specify the DefaultTitle of a screen you use the SA_Title followed a comma and then by the title in quotes and there are many other tags that can be used to define bits of a screen, see later for a list. The last tag item should always be TAG_DONE.
if ((scr->screen = LockPubScreen(PROGNAME)))
{
scr->screentype = PUBLICSCREEN;
success = TRUE;
scr->modeID = GetVPModeID(&scr->screen->ViewPort);
}
else
{
if (id != INVALID_ID)
{
UWORD empty = 0xffff;
if ((scr->screen = OpenScreenTags(NULL,
SA_Width, width,
SA_Height, height,
SA_Depth, depth,
SA_DisplayID, id,
SA_Type, PUBLICSCREEN,
SA_AutoScroll, TRUE,
SA_Title, (IPTR)PROGNAME,
SA_PubName, (IPTR)PROGNAME,
SA_ShowTitle, FALSE,
SA_LikeWorkbench, TRUE,
SA_FullPalette, TRUE,
SA_SharePens, TRUE,
SA_Pens, (IPTR)&empty,
TAG_DONE)))
{
PubScreenStatus(scr->screen, 0);
scr->screentype = CUSTOMSCREEN;
scr->modeID = id;
success = TRUE;
}
}
}
if (defscreen)
{
UnlockPubScreen(NULL, defscreen);
}
}
//else
if (!success)
{
if (!success)
{
if (mvs->scropenmode == SCROPENMODE_PUBLIC)
{
if ((scr->screen = LockPubScreen(mvs->pubscreen)))
{
ScreenToFront(scr->screen);
success = TRUE;
}
}
}
if (!success)
{
success = !!(scr->screen = LockPubScreen(NULL));
}
if (success)
{
scr->screentype = PUBLICSCREEN;
scr->modeID = GetVPModeID(&scr->screen->ViewPort);
}
}
#include <proto/intuition.h> #include <proto/dos.h> #include <intuition/screens.h> int main() { /* makes a copy of the Screen struct(ure) and calls that copy myScreen, changes are made to this copy */ struct Screen *myScreen; /* you can call the copy 'myScreen' any name you like, as long as you use it throughout the program consistently */ /* describe how 'myScreen' looks like by using tags SA_?, this is the next step from the struct stuff above */ myScreen = OpenScreenTags(NULL, SA_Left, 0, SA_Top, 0, SA_Width, 640, SA_Height, 480, SA_Depth, 8, SA_Title, "My New Screen", SA_Type, PUBLICSCREEN, SA_SysFont, 1, TAG_DONE); Delay(500); /* check if screen open, returns TRUE for success and FALSE for failure, if so, use CloseScreen() command to close */ if (myScreen) CloseScreen(myScreen); }
[edit] Opening or Locking a Public Screen
If you do not wish to use a custom screen, then you can use an existing public screen such as Wanderer. Screens can be closed at any time, so to prevent that, the public screen should be locked while the application is running. You can do this using the LockPubScreen function.
myScreen = LockPubScreen(name)
where name is the name of the Public Screen to lock.If no name is given then it will use the Workbench public screen. Once done with the Public screen you can then Unlock it:
UnlockPubScreen(NULL, myScreen); UnlockPubScreen(UBYTE *name, struct Screen *screen )
For example, the following code will lock and unlock the default Wanderer screen.
#include <proto/intuition.h> #include <intuition/screens.h> #include <proto/dos.h> #include <stdio.h> int main(void) { struct Screen *myScreen; if (myScreen = LockPubScreen(NULL)) { printf("Public Screen locked.\n"); Delay(100); UnlockPubScreen(NULL, myScreen); printf("Public Screen unlocked.\n"); } return 0; }
[edit] Screen Reference
[edit] Screen Tags
SA_Left
Default: 0
SA_Top
Default: 0
SA_Width
Default depends on display clip
SA_Height
Default depends on display clip
SA_Depth
Select depth of screen. This specifies how many
colors the screen can display.
Default: 1
SA_DetailPen
Pen number for details.
Default: 0
SA_BlockPen
Pen number for block fills.
Default: 1
SA_Title (STRPTR)
Default: NULL
SA_Font (struct TextAttr *)
Default: NULL, meaning user's preferred monospace font
SA_BitMap (struct BitMap *)
Provide a custom bitmap.
SA_ShowTitle (BOOL)
Default: TRUE
SA_Behind (BOOL)
Screen will be created behind other open screens.
Default: FALSE
SA_Quiet (BOOL)
Intuition doesn't draw system gadgets and screen title.
Defaults: FALSE
SA_Type
PUBLICSCREEN or CUSTOMSCREEN.
SA_DisplayID
32-bit display mode ID, as defined in the <graphics/modeid.h>.
SA_Overscan
Set an overscan mode.
Possible values:
OSCAN_TEXT - A region which is fully visible.
Recommended for text display.
OSCAN_STANDARD - A region whose edges are "just out of view."
Recommended for games and presentations.
OSCAN_MAX - Largest region which Intuition can handle comfortably.
OSCAN_VIDEO - Largest region the graphics.library can display.
Default: OSCAN_TEXT
SA_DClip (struct Rectangle *)
Define a DisplayClip region. See QueryOverscan().
It's easier to use SA_Overscan.
SA_AutoScroll (BOOL)
Screens can be larger than the DisplayClip region. Set this tag
to TRUE if you want to enable automatic scrolling when you reach
the edge of the screen with the mouse pointer.
SA_PubName (STRPTR)
Make this screen a public screen with the given name.
Screen is opened in "private" mode.
SA_Pens (UWORD *)
Define the pen array for struct DrawInfo. This enables
the 3D look.
This array contains often just the terminator ~0.
You define a list of pens which overwrite the DrawInfo pens.
The pen array must be terminated with ~0.
SA_PubTask (struct Task *)
Task to be signalled, when last visitor window of a public
screen is closed.
SA_PubSig (UBYTE)
Signal number used to notify a task when the last visitor window
of a public screen is closed.
SA_Colors (struct ColorSpec *)
Screen's initial color palette. Array must be terminated
with ColorIndex = -1.
SA_FullPalette (BOOL)
Intuition maintains a set of 32 preference colors.
Default: FALSE
SA_ErrorCode (ULONG *)
Intuition puts additional error code in this field when
opening the screen failed.
OSERR_NOMONITOR - monitor for display mode not available.
OSERR_NOCHIPS - you need newer custom chips for display mode.
OSERR_NOMEM - couldn't get normal memory
OSERR_NOCHIPMEM - couldn't get chip memory
OSERR_PUBNOTUNIQUE - public screen name already used
OSERR_UNKNOWNMODE - don't recognize display mode requested
OSERR_TOODEEP - screen too deep to be displayed on
this hardware (V39)
OSERR_ATTACHFAIL - An illegal attachment of screens was
requested (V39)
SA_SysFont
Select screen font type. This overwrites SA_Font.
Values:
0 - Fixed-width font (old-style)
1 - Font which is set by font preferences editor. Note: windows opened
on this screen will still have the rastport initialized with the
fixed-width font (sysfont 0).
Default: 0
SA_Parent (struct Screen *)
Attach the screen to the given parent screen.
SA_FrontChild (struct Screen *)
Attach given child screen to this screen. Child screen
must already be open. The child screen will go to the
front of the screen group.
SA_BackChild (struct Screen *)
Attach given child screen to this screen. Child screen
must already be open. The child screen will go behind other
child screens.
SA_BackFill (struct Hook *)
Backfill hook (see layers.library/InstallLayerInfoHook() ).
SA_Draggable (BOOL)
Make screen draggable.
Default: TRUE
SA_Exclusive (BOOL)
Set to TRUE if the screen must not share the display with
other screens. The screen will not be draggable and doesn't
appear behind other screens, but it still is depth arrangeable.
Default: FALSE
SA_SharePens (BOOL)
Per default, Intuition obtains the pens of a public screen with PENF_EXCLUSIVE.
Set this to TRUE to instruct Intuition to leave the pens unallocated.
Default: FALSE
SA_Colors32 (ULONG *)
Data is forwarded to graphics.library/LoadRGB32().
Overwrites values which were set by SA_Colors.
SA_Interleaved (BOOL)
Request interleaved bitmap. It this fails a non-interleaved
bitmap will be allocated.
Default: FALSE
SA_VideoControl (struct TagItem *)
Taglist which will be passed to VideoControl() after the
screen is open.
SA_ColorMapEntries:
Number of entries of the ColorMap.
Default: 1<<depth, but not less than 32
SA_LikeWorkbench (BOOL)
* Inherit depth, colors, pen-array, screen mode, etc. from the Workbench screen. Individual attributes can be overridden with tags.
Default: FALSE. Copying Screens can be done by the SA_LikeWorkbench tag (BOOL)? according to OpenScreenTagList() function's description, your screen will then inherit depth, colors,
pen-array, screen mode, etc. (and SA_SysFont will be set to 1, so the font which is set by font
preferences editor will be used. Note that windows opened on this screen will still have the rastport
initialized with the fixed-width font (sysfont 0).) from the Workbench screen.
Individual attributes can still be overridden with tags. SA_LikeWorkbench tag defaults to FALSE, so you have to set it explicitly.
SA_MinimizeISG (BOOL)
Minimize the Inter-Screen-Gap. For compatibility,
[edit] Windows
Below is another public structure that is already setup inside AROS, a template as such, for quick use in programming.
struct Window
{
struct Window *NextWindow; /* for the linked list to next Window */
WORD LeftEdge, TopEdge, Width, Height; /* window dimensions */
WORD MouseY, MouseX; /* relative top top-left corner */
WORD MinWidth, MinHeight; /* minimum sizes */
UWORD MaxWidth, MaxHeight; /* maximum sizes */
ULONG Flags;
struct Menu *MenuStrip; /* first in a list of menu headers */
UBYTE *Title; /* title text for the Window */
struct Requester *FirstRequest, *DMRequest; /* first in linked list of active reqs - the double-menu Requester */
WORD ReqCount; /* number of Requesters blocking this Window */
struct Screen *WScreen; /* this Window's Screen */
/* Each window has one RastPort but within each RastPort a BitMap pointer. */
struct RastPort *RPort;
BYTE BorderLeft, BorderTop, BorderRight, BorderBottom;
struct RastPort *BorderRPort;
struct Gadget *FirstGadget;
/* these are for opening/closing the windows */
struct Window *Parent, *Descendant;
/* sprite data information for your own Pointer set these AFTER you Open the Window by calling SetPointer() */
UWORD *Pointer;
BYTE PtrHeight, PtrWidth;
BYTE XOffset, YOffset;
/* the IDCMP Flags and User's and Intuition's Message Ports */
ULONG IDCMPFlagS;
struct MsgPort *UserPort, *WindowPort;
struct IntuiMessage *MessageKey;
UBYTE DetailPen, BlockPen;
/* the CheckMark is a pointer to the imagery that will be used when rendering MenuItems of this Window checkmarked - if this is equal to NULL, you'll get the default imagery */
struct Image *CheckMark;
/* if non-null, Screen title when Window is active */
UBYTE *ScreenTitle;
WORD GZZMouseX, GZZMouseY, GZZWidth, GZZHeight;
; general-purpose pointer to User data extension
UBYTE *ExtData;
BYTE *UserData;
struct Layer *WLayer; /* stash of Window.RPort->Layer */
struct TextFont *IFont;
ULONG MoreFlags;
};
Having set a screen, you can now have as many windows on that screen as you want.
Opening Windows is very similar to opening screens, OpenWindowTags() with window tags as well...
As Screen tags started with SA_, Window tags start with WA_ and in the case of WA_IDCMP and WA_Flags have further sub-tags. A list follows later...
So when I do window->Width / rport->TxWidth, the number of columns ends up being greater than the visible area, so text goes off screen, same for height. Is there a way to get the window size less the attached gadgets/widgets? For a non borderless window (aka normal window ), the usable width is w->Width - w->BorderLeft - w->BorderRight, and the height, w->Height - w->BorderTop - w->BorderBottom.
For a GimmeZeroZero window, use w->GZZWidth and w->GZZHeight instead w->Width and w->Height. GZZWidth and GZZHeight are maintained for non-GZZ windows, too. You don't need to calculate them yourself.
To be able to resize a window you need to set WA_MinWidth, WA_MinHeight, WA_MaxWidth and WA_MaxHeight because they all default to WA_Width resp. WA_Height.
| Window | Main Intuition structure that <intuition/intuition.h> defines a window |
| TagItem | General purpose parameter <utility/tagitem.h> structure used to set up windows |
| Layer | A drawing rectangle that <graphics/clip.h> clips graphic operations within its boundaries |
| RastPort | General purpose handle used <graphics/rastport.h> for graphics library drawing operations. |
[edit] Window Example
For AROS you should omit all the usual #?Base (GfxBase, IntuitionBase, DOSBase,... ) declarations and "OpenLibrary() & CloseLibrary()" calls for them because AROS GCC compiler opens and closes them automatically for you when it sees a reference. Most of the core libraries are auto opened by the compiler.
This is for background knowledge only. When a library is opened, it will return a pointer to a Library structure or a Base structure specific to that library otherwise it will return a NULL value. Converting old Commodore examples is probably a good way to get understanding of Amiga program to AROS program differences. NOTE those old examples need editing because of OpenLibrary, CloseLibrary and #?base stuff... In the past, to close a library, use the CloseLibrary() function and provide the pointer to the Library or Base structure which was returned in the OpenLibrary(). It is normal practice to test that the library was opened before trying to close it.
See AROS website examples, Aros/Developer/Docs/Examples/SimpleWindowIntuition and here
#include <proto/exec.h> #include <exec/libraries.h> #include <proto/dos.h> #include <proto/intuition.h> #include <intuition/intuition.h> int main(int argc, char *argv[]) { int error = RETURN_OK; /* makes a copy of the Window struct(ure) and calls that copy win, changes are made to this copy */ struct Window *win; /* describe the copy window 'win' looks like by using tags WA_?, this is separate from the struct stuff above */ win = OpenWindowTags ( NULL, WA_Width, 200, WA_Height, 100, WA_Title, "Hello World!", TAG_DONE ); if( win ) { /* Now wait for two seconds, so we can look at our nice window. */ Delay(100); /* We close our window again. */ CloseWindow(win); } return error; }
[edit] Windows Reference
struct TagItem + OpenWindowTagList() Open a window. Not used much see below... OpenWindowTags() Alternate calling sequence for OpenWindowTagList(). CloseWindow() Close a window. BeginRefresh() Turn on optimized window refresh mode. EndRefresh() Turn off optimized window refresh mode. RefreshWindowFrame() Redraw the borders and border gadgets of an open window. ActivateWindow() Make an open window active. SizeWindow() Change the size of an open window. MoveWindow() Change the position of an open window. ChangeWindowBox() Change the size and position of an open window. WindowLimits() Change the minimum and maximum sizes of an open window. WindowToBack() Move a window behind all other windows. WindowToFront() Move a window in front of all other windows. MoveWindowInFrontOf() Move a window in front of another window. ZipWindow() Change the size of window to its alternate size. SetWindowTitles() Change the window titles for the window and the screen. SetPointer() Set up a custom pointer to display whenever the window is active. ClearPointer() Restore the mouse pointer to its default imagery.
[edit] Windows Tags
WA_Left - Left edge of the window
WA_Top - Top edge of the window
WA_Width - Width of the window
WA_Height - Height of the window
WA_DetailPen - Pen number for window details (obsolete)
WA_BlockPen - Pen number for filled blocks (obsolete)
WA_IDCMP - Define what events should send messages to your task
IDCMP_CLOSEWINDOW - Check if the Window Close button has been pressed. If so, then close down program.
IDCMP_GADGETUP - Check to see if a Gadget has been pressed AND released.
IDCMP_GADGETDOWN - Check to see if a Gadget has been pressed (but not released yet). Not used as often.
IDCMP_MENUPICK - Check to see if a menu item has been selected.
IDCMP_ACTIVEWINDOW - Check to see if Window has been activated (clicked on title bar).
IDCMP_MOUSEMOVE - Check if mouse moves (useful to keep track of x,y position)
IDCMP_NEWSIZE - Check to see if window has been resized.
IDCMP_VANILLAKEY - Check to see if a key on keyboard has been pressed.
IDCMP_RAWKEY -
IDCMP_NEWPREFS -
IDCMP_DISKINSERTED - Check to see if a floppy disk has been inserted, probably ready for saving.
IDCMP_DISKREMOVED - message type is broadcast to all IDCMP that have this flag set, not just active win
IDCMP_INTUITICKS -
IDCMP_IDCMPUPDATE -
IDCMP_CHANGEWINDOW -
IDCMP_LONELYMESSAGE - system use only
WA_Flags
Initial values for various boolean window properties. Can be overwritten by WA_... tags.
WFLG_SIZEGADGET - Use a size gadget in window
WFLG_DRAGBAR - Use a drag bar in window
WFLG_DEPTHGADGET - Use a depth gadget in window
WFLG_CLOSEGADGET - Use a close gadget in Window
WFLG_BORDERLESS - Use a borderless window
WFLG_ACTIVATE - Activate window when displayed
WFLG_NEWLOOKMENUS - Use new style menus (if defined)
WA_Gadgets (struct Gadget *)
Pointer to a linked list of gadgets
WA_Title (STRPTR) - Window title string
WA_CustomScreen (struct Screen *)
Open window on the given screen
WA_SuperBitMap (struct BitMap *)
Create window with superbitmap refreshing
WA_MinWidth - Minimum width of the window
WA_MinHeight - Minimum height of the window
WA_MaxWidth - Maximum width of the window
WA_MaxHeight - Maximum height of the window
Use 0 to keep the current size as limit. The maximums can be
set to -1 or ~0 to limit size only to screen dimension.
WA_SizeGadget (BOOL) - Make window resizeable
WA_DragBar (BOOL) - Make window dragable
WA_DepthGadget (BOOL) - Add a depth gadget
WA_CloseGadget (BOOL) - Add a close gadget
WA_Backdrop (BOOL)
Create a window which is placed behind other windows
WA_ReportMouse (BOOL) - Store mouse position in struct Window
WA_NoCareRefresh (BOOL)
Use this if you don't want to be responsible for calling
BeginRefresh()/EndRefresh().
WA_Borderless (BOOL) - Create borderless window
WA_Activate (BOOL)
Make this window the active one, i.e. it
receives the input from mouse and keyboard.
WA_RMBTrap (BOOL)
Set to TRUE if you want to get button events
events for the right mouse button.
WA_SimpleRefresh (BOOL)
Enable simplerefresh mode. Only specify if TRUE.
WA_SmartRefresh (BOOL)
Enable smartrefresh mode. Only specify if TRUE.
WA_SizeBRight (BOOL) - Place size gadget in right window border
WA_SizeBBottom (BOOL) - Place size gadget in bottom window border
WA_GimmeZeroZero (BOOL)
Create a GimmeZeroZero window. will take almost twice the amount
of Chip RAM as a normal window on AmigaOS 3.x so use it sparingly.
The window borders have their own layer, so you can't overdraw it.
The coordinate 0,0 is related to the inner area of the window.
This makes handling of windows easier, but it slows down the system.
WA_NewLookMenus (BOOL)
Use DrawInfo colors for rendering the menu bar.
WA_ScreenTitle (STRPTR)
Screen title which is shown when window is active.
WA_AutoAdjust (BOOL)
TRUE means that Intuition can move or shrink the window
to fit on the screen, within the limits given with
WA_MinWidth and WA_MinHeight. This attribute defaults
to TRUE when you call OpenWindowTags() with a NULL pointer
for NewWindow.
WA_InnerWidth
WA_InnerHeight
Dimensions of the interior region of the window.
Note that this restricts border gadgets:
- GACT_LEFTBORDER gadgets can't be GFLG_RELWIDTH if
WA_InnerWidth is used.
- GACT_RIGHTBORDER gadgets must be GFLG_RELRIGHT if
WA_InnerWidth is used.
- GACT_TOPBORDER gadgets can't be GFLG_RELHEIGHT if
WA_InnerHeight is used.
- GACT_BOTTOMBORDER gadgets must be GFLG_RELBOTTOM if
WA_InnerHeight is used.
WA_PubScreen (struct Screen *)
Open the window on the public screen with the given address.
An address of NULL means default public screen. You're
responsible that the screen stays open until OpenWindowTags()
has finished, i.e.
you're the owner of the screen,
you have already a window open on the screen
or you use LockPubScreen()
WA_PubScreenName (STRPTR)
Open the window on the public screen with the given name.
WA_PubScreenFallBack (BOOL)
TRUE means that the default public screen can be used if
the specified named public screen is not available.
WA_Zoom (WORD *)
4 WORD's define the initial Left/Top/Width/Height of the
alternative zoom position/dimension. This adds a zoom
gadget to the window. If both left and top are set to ~0
the window will only be resized.
WA_MouseQueue
Limits the number of possible mousemove messages. Can
be changed with SetMouseQueue().
WA_RptQueue
Limits the number of possible repeated IDCMP_RAWKEY,
IDCMP_VANILLAKEY and IDCMP_IDCMPUPDATE messages.
WA_BackFill (struct Hook *)
Function to be called for backfilling
WA_MenuHelp (BOOL)
Enables menuhelp. Pressing the help key during menu handling
sends IDCMP_MENUHELP messages.
WA_NotifyDepth (BOOL)
If TRUE send IDCMP_CHANGEWINDOW events when window is
depth arranged. Code field will be CWCODE_DEPTH.
WA_Checkmark (struct Image *)
Image to use as a checkmark in menus.
WA_AmigaKey (struct Image *)
Image to use as the Amiga-key symbol in menus.
WA_Pointer (APTR)
The pointer to associate with the window. Use NULL
for the Preferences default pointer. You can create
custom pointers with NewObject() on "pointerclass".
Default: NULL.
WA_BusyPointer (BOOL)
Enable the Preferences busy-pointer.
Default: FALSE.
WA_PointerDelay (BOOL)
Set this to TRUE to delay change of the pointer image.
This avoids flickering of the mouse pointer when it's
changed for short times.
WA_HelpGroup (ULONG)
Get IDCMP_GADGETHELP messages not only from the active
window, but from all its windows.
You have to get a help ID with utility.library/GetUniqueID()
and use it as data for WA_HelpGroup for all windows.
WA_HelpGroupWindow (struct Window *)
Alternative for WA_HelpGroup. Use the helpgroup of
another window.
WA_TabletMessages (BOOL)
Request extended tablet data.
Default: FALSE
WA_ToolBox (BOOL)
Make this window a toolbox window
WA_Parent (struct Window *)
Make the window a child of the given window.
WA_Visible (BOOL)
Make window visible.
Default: TRUE
WA_Shape (struct Region *)
WA_ShapeHook (struct Hook *)
[edit] Event Handling
Although AmigaOS(TM) started with intuition events, AROS has incorporated these as well for backwards compatibility purposes but recommends using Zune instead, see here Zune
a) Wait for signal from the current Active Window b) If a signal has been sent, get the Message data structure c) Reply to the message, so that message is removed from the queue and is being dealt with. d) Determine the message class (or gadget or event) occurred by comparing class value with IDCMP flags e) Do some user processing with that event.
Input = Hardware Device -> HIDD or .device -> Event Handler -> IDCMP or Console -> Application
Output = Application -> Console or intuition -> graphics library -> display monitor
[edit] IDCMP
An application will have messages sent to it by any intuition event. These messages, IntuiMessages, are standard Exec messages, and are sent to a port called an IDCMP. Every window may/will have an IDCMP associated with it (Window->UserPort). Keys will not work automatically in a window. You must setup it by WA_IDCMP, tags.
struct IntuiMessage
{
struct Message ExecMessage;
ULONG Class;
UWORD Code;
UWORD Qualifier;
APTR IAddress;
WORD MouseX, MouseY;
ULONG Seconds, Micros;
struct Window *IDCMPWindow;
struct IntuiMessage *SpecialLink;
};
- IDCMP_VANILLAKEY - events provide for simple ASCII text and standard control keys like space, return and backspace
- IDCMP_RAWKEY - returns all keycodes, both key-up and key-down, including function keys (it's mean keyboards, moving, gadget (close/resize) and many other things)
If it possible to easily send an IDCMP_* to a window, an example: I have modified something on my window, this does not get properly redrawn until I resize the window a small bit... So it get updated only after an (I assume) IDCMP_refreshwindow? You can only receive IDCMP messages. And only then when you tell the intuition window specifically (upon creation with flags or after creation with the function ModifyIDCMP that you want to receive that specified IDCMP message.
#include <proto/exec.h> #include <proto/dos.h> #include <proto/graphics.h> #include <proto/intuition.h> int main (void) { /* set up variables to be used in this function */ struct Window *win; struct IntuiMessage *mess; BOOL cont; BOOL lbutton; BOOL rbutton; long old_x; long old_y; long x; long y; win = OpenWindowTags (NULL, WA_Left,112, WA_Top,84, WA_Width,800, WA_Height,600, WA_Flags,WFLG_CLOSEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_SIZEGADGET | WFLG_RMBTRAP | WFLG_REPORTMOUSE | WFLG_ACTIVATE | WFLG_GIMMEZEROZERO | WFLG_NOCAREREFRESH, WA_IDCMP,IDCMP_CLOSEWINDOW | IDCMP_VANILLAKEY | IDCMP_MOUSEBUTTONS | IDCMP_MOUSEMOVE, WA_MinWidth,80,WA_MinHeight,40, WA_MaxWidth,-1,WA_MaxHeight,-1, TAG_END); /* if (win==NULL) { */ if (!win) { Printf ("cannot open window\n"); return (RETURN_FAIL); } rbutton = FALSE; lbutton = FALSE; x = win->MouseX; y = win->MouseY; old_x = x; old_y = y; cont = TRUE; do { if (Wait ((1L << win->UserPort->mp_SigBit) | SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C) cont = FALSE; while (mess = (struct IntuiMessage *) GetMsg (win->UserPort)) { switch (mess->Class) { case IDCMP_MOUSEMOVE: x = mess->MouseX - win->BorderLeft;; y = mess->MouseY - win->BorderTop; break; case IDCMP_MOUSEBUTTONS: switch (mess->Code) { case SELECTDOWN: lbutton = TRUE; break; case SELECTUP: lbutton = FALSE; break; case MENUDOWN: rbutton = TRUE; break; case MENUUP: rbutton = FALSE; break; } break; case IDCMP_VANILLAKEY: if (mess->Code == 0x1b) /* Esc */ cont = FALSE; break; case IDCMP_CLOSEWINDOW: cont = FALSE; break; } ReplyMsg ((struct Message *)mess); } if (x != old_x || y != old_y) { if (rbutton && lbutton) { SetAPen (win->RPort,3); Move (win->RPort,old_x,old_y); Draw (win->RPort,x,y); } else if (rbutton) { SetAPen (win->RPort,2); Move (win->RPort,old_x,old_y); Draw (win->RPort,x,y); } else if (lbutton) { SetAPen (win->RPort,1); Move (win->RPort,old_x,old_y); Draw (win->RPort,x,y); } old_x = x; old_y = y; } } while (cont); CloseWindow (win); return (RETURN_OK); }
Invalid language.
You need to specify a language like this: <source lang="html4strict">...</source>
Supported languages for syntax highlighting:
4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt_sources, asm, asp, autoconf, autohotkey, autoit, avisynth, awk, bascomavr, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_loadrunner, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, coffeescript, cpp, cpp-qt, csharp, css, cuesheet, d, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, epc, erlang, euphoria, f1, falcon, fo, fortran, freebasic, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, hicest, hq9plus, html4strict, html5, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, jquery, kixtart, klonec, klonecpp, latex, lb, lisp, llvm, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, oobas, oracle11, oracle8, oxygene, oz, pascal, pcre, per, perl, perl6, pf, php, php-brief, pic16, pike, pixelbender, pli, plsql, postgresql, povray, powerbuilder, powershell, proftpd, progress, prolog, properties, providex, purebasic, pycon, python, q, qbasic, rails, rebol, reg, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, sql, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, uscript, vala, vb, vbnet, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xorg_conf, xpp, yaml, z80, zxbasic
/* loop for each frame */
while (loop) {
/* check for input */
while ((msg = (struct IntuiMessage *)GetMsg (w->UserPort)) != NULL) {
/* After we have successfully collected the message we can read */
/* it, and save any important values which we maybe want to check later */
class = msg->Class; /* IDCMP flag */
code = msg->Code;
/* After we have read it we reply as fast as possible: */
/* REMEMBER! Do never try to read a message after you have replied! */
/* (Some other process has maybe changed it.) */
ReplyMsg ((struct Message *)msg);
switch (class) {
case IDCMP_VANILLAKEY:
switch (code) {
case 0x03: /* CTRL/C */
case 0x1b: /* ESC */
case 'q': /* q */
case 'Q': /* Q */
break;
default:
break;
}
break;
case IDCMP_RAWKEY:
switch (code) {
case 0x50: /* F1 */
break;
case 0x51: /* F2 */
break;
case 0x52: /* F3 */
break;
case 0x53: /* F4 */
break;
case 0x54: /* F5 */
break;
case 0x55: /* F6 */
break;
case 0x56: /* F7 */
break;
case 0x57: /* F8 */
break;
case 0x58: /* F9 */
break;
case 0x59: /* F10 */
break;
default:
break;
}
break;
case IDCMP_MOUSEBUTTONS:
if (code == MENUDOWN)
loop = FALSE;
break;
default:
break;
}
}
[edit] INTUITICKS
Basically, creating an IDCMP loop to check for user input and/or timer events. Then you probably set up a timer device call that will give you those events. You have to update your window content with the help of IDCMP_INTUITICKS ("ticks" roughly ten times a second). These tick events are to be used as wake up call, and not as timers.
case IDCMP_GADGETUP:
gadget_down_happened=FALSE;
break;
case IDCMP_GADGETDOWN:
gadget_down_happened=TRUE;
break;
case IDCMP_INTUITICKS:
if(gadget_down_happened) {
update_window_contents();
}
break;
case IDCMP_INTUITICKS:
/*
* If the user is NOT holding the LMB down, then we'll
* report this event back to the program in order not to confuse
* the select box drawing routines.
*/
if( !(imsg->Qualifier & IEQUALIFIER_LEFTBUTTON))
method = GID_DW_INTUITICKS;
break;
Of course you might want to only update the content every 3rd intuitick for example and only, if the proportional gadget has changed etc.
[edit] Menus
Although AmigaOS(TM) started out with intuition based Menus, Gadgets, Requesters and Events. AROS has alternatives that are now recommended like Zune (MUI) Menus.
If you want to define your own menus, then I think intuition.library also covers you there, although menus are best left till later as IMHO they are overly complex & error prone.
[edit] Defining Menus
For each main menu heading (i.e. top option) in the menu bar, you declare one Menu structure for each. For each item or sub-item within a menu, you declare one a MenuItem structure for each. You should use more MenuItem than Menu. Text-based menus require an additional IntuiText structure for each menu and (sub)item. (they appear the most). Image menus require the image struct.
To use Menus you need to use the Menu and MenuItem structures, and then attached them to a Window. Please note than the IntuiTexts and Image structure should be defined before the MenuItem structures that are calling them.
struct Menu { struct Menu *NextMenu; /* same level */ WORD LeftEdge, TopEdge; /* position of the select box */ WORD Width, Height; /* dimensions of the select box */ UWORD Flags; /* flag definitions*/ BYTE *MenuName; /* text for this Menu Header */ struct MenuItem *FirstItem; /* pointer to first in chain */ };
struct MenuItem { struct MenuItem *NextItem; /* pointer to next in chained list */ WORD LeftEdge, TopEdge; /* position of the select box */ WORD Width, Height; /* dimensions of the select box */ UWORD Flags; /* see the defines below */ LONG MutualExclude; /* set bits mean this item excludes that */ IPTR ItemFill; /* points to Image, IntuiText, or NULL */ IPTR SelectFill; /* points to Image, IntuiText, or NULL */ BYTE Command; /* only if appliprog sets the COMMSEQ flag */ struct MenuItem *SubItem; /* if non-zero, points to MenuItem for submenu */ UWORD NextSelect; /* Menu no of next selected item when drag-selecting items */ };
struct IntuiText { UBYTE FrontPen, BackPen; /* the pen numbers for the rendering */ UBYTE DrawMode; /* the mode for rendering the text */ WORD LeftEdge; /* relative start location for the text */ WORD TopEdge; /* relative start location for the text */ struct TextAttr *ITextFont; /* if NULL, you accept the default */ UBYTE *IText; /* pointer to null-terminated text */ struct IntuiText *NextText; /* pointer to another IntuiText to render */ };
struct Image { WORD LeftEdge; /* starting offset relative to some origin */ WORD TopEdge; /* starting offsets relative to some origin */ WORD Width; /* pixel size (though data is word-aligned) */ WORD Height; WORD Depth; /* >= 0, for images you create */ UWORD *ImageData; /* pointer to the actual word-aligned bits */ UBYTE PlanePick, PlaneOnOff; struct Image *NextImage; };
[edit] Adding and Removing Menus from a Window
To add or remove a menu from a window, you need to use the following commands:
BOOL SetMenuStrip( struct Window *window, struct Menu *menu )
void ClearMenuStrip( struct Window *window )
Use the SetMenuStrip command after the Window has been defined and opened and provide the address of the Window and the address of the last Menu structure in the linked list. Before closing a window, you must use ClearMenuStrip command first to remove the menu from the screen before closing a Window. Attaching menus to windows rather than screens can allow your program to have flexibility so if you had multiple windows open you can customise the menu to suit the appropriate window, for example, in a paint package or video program you can have smaller windows with their own menus.
[edit] Enabling and Disabling Menu Items
It is possible to enable or disable menu items, when you don`t wish a user to have access to a menu function. This can be done with the OnMenu and OffMenu functions:
void OffMenu( struct Window *window, unsigned long menuNumber)
void OnMenu( struct Window *window, unsigned long menuNumber )
Just provide the menu number of the item to enable or disable. If you change the CHECKED or ITEMENABLED values of menu items then you can refresh the menu using ResetMenuStrip command which is similar and faster than using SetMenuStrip command.
[edit] Menu Example
[edit] Requesters
AROS supports several types of requesters: System (intuition) and ASL type requesters. ASL is the preferred option now, see here
The old intuition AutoRequest() and the intuition Request() functions. It is a very easy to use and just needs a Window with which to attach, a structure, a pointer to a list of IDCMP flags and optional arguments.
struct Requester
{
struct Requester *OlderRequest;
WORD LeftEdge, TopEdge;
WORD Width, Height;
WORD RelLeft, RelTop;
struct Gadget *ReqGadget;
struct Border *ReqBorder;
struct IntuiText *ReqText;
UWORD Flags;
POINTREL
PREDRAWN
NOISYREQ
USEREQIMAGE
NOREQBACKFILL
REQOFFWINDOW (the following are library called)
REQACTIVE
SYSREQUEST
UBYTE Backfill;
struct Layer *ReqLayer;
UBYTE ReqPad1[32];
struct BitMap *ImageBMap;
struct Window *RWindow;
struct Image *ReqImage;
UBYTE ReqPad2[32];
};
[edit] EasyRequest
EasyRequest() provides a simple way to make a requester that allows the user to select one of a limited number of choices LONG EasyRequest( struct Window *window, struct EasyStruct *easyStruct, ULONG *idcmpPtr, APTR argl, ... );
LONG EasyRequestArgst struct Window *window, struct EasyStruct *easyStruct, ULONG *idcmpPtr, APTR ergs );
struct EasyStruct
{
ULONG es_StructSize;
ULONG es_Flags;
UBYTE *es_Title;
UBYTE *es_TextFormat;
UBYTE *es_GadgetFormat;
};
[edit] Requester Example
[edit] Requester Reference
BuildSysRequest(Window)
FreeSysRequest (Window)
AutoRequest( Window, BodyText, PosText, NegText, PosFlags, NegFlags, Width, Height)
[edit] Gadgets
Each gadget (used in a window or requester) creates a separate Gadget struct
struct Gadget {
struct Gadget *NextGadget;
WORD LeftEdge, TopEdge;
WORD Width, Height;
UWORD Flags;
UWORD Activation;
UWORD GadgetType;
GTYP_BOOLGADGET - Boolean gadget type.
GTYP_STRGADGET - String gadget type. For an integer gadget, also set the GACT_LONGINT flag.
GTYP_PROPGADGET - Proportional gadget type.
GTYP_CUSTOMGADGET - Normally not set by the application. Used by custom BOOPSI gadget types.
GTYP_GZZGADGET - If the gadget is placed in a GimmeZeroZero window, will place the gadget in the border layer.
GTYP_REQGADGET - Set this bit if this gadget is placed in a requester.
APTR GadgetRender;
APTR SelectRender;
struct IntuiText *GadgetText;
IPTR MutualExclude; /* changed from LONG used by BOOPSI gadgets to store dispatcher address */
APTR SpecialInfo;
UWORD GadgetID;
APTR UserData;
};
Highlighting flags
GFLG_GADGHNONE - GFLG_GADGHCOMP - GFLG_GADGHBOX - GFLG_GADGHIMAGE -
In addition to the highlighting flags, these other values may be set in the Flags field of the Gadget structure.
GFLG_GADGIMAGE - GFLG_RELBOTTOM - GFLG_RELRIGHT - GFLG_RELWIDTH - GFLG_RELHEIGHT - GFLG_SELECTED - GFLG_DISABLED - GFLG_STRINGEXTEND - GFLG_TABCYCLE -
Gadget Activation Flags - may be set in the Activation field of the Gadget structure.
GACT_TOGGLESELECT GACT_IMMEDIATE GACT_RELVERIFY GACT_ENDGADGET GACT_FOLLOWMOUSE
Border Flags
GACT_RIGHTBORDER GACT_LEFTBORDER GACT_TOPBORDER GACT_BOTTOMBORDER
The following flags apply only to string gadgets:
GACT_STRINGCENTER GACT_STRINGRIGHT GACT_STRINGLEFT GACT_LONGINT GACT_ALTKEYMAP GACT_BOOLEXTEND GACT_STRINGEXTEND
If you use old-fashioned struct Gadget, you need to calculate and set BODY and POT fields of the PropInfo structure appropriately.
Read more gadtools.library.
[edit] String
String gadgets require their own special structure called the StringInfo structure. For a string gadget, set the GadgetType field in the Gadget structure to GTYP_STRGADGET. Set the SpecialInfo field to point to an instance of a StringInfo structure, which must be initialized by the application.
struct StringInfo
{
UBYTE *Buffer;
UBYTE *UndoBuffer;
WORD BufferPos;
WORD MaxChars;
WORD DispPos;
WORD UndoPos;
WORD NumChars;
WORD DispCount;
WORD CLeft, CTop;
struct StringExtend *Extension;
LONG LongInt;
struct KeyMap *AltKeyMap;
};
[edit] Custom
Custom string editing
struct SGWork
{
struct Gadget *Gadget;
struct StringInfo *StringInfo;
UBYTE *WorkBuffer;
UBYTE *PrevBuffer;
ULONG Modes;
struct InputEvent *IEvent;
UWORD Code;
WORD BufferPos;
WORD NumChars;
ULONG Actions;
LONG LongInt;
struct GadgetInfo *GadgetInfo;
UWORD EditOp;
};
EditOp Action Taken by Global Hook ------ --------------------------- EO_NOOP Did nothing. EO_DELBACKWARD Deleted some chars (possibly 0). EO_DELFORWARD Deleted some characters under and in front of the cursor. EO_MOVECURSOR Moved the cursor. EO_ENTER Enter or Return key, terminate. EO_RESET Current Intuition-style undo. EO_REPLACECHAR Replaced one character and (maybe) advanced cursor. EO_INSERTCHAR Inserted one character into string or added one at end. EO_BADFORMAT Didn't like the text data, e.g., alpha characters in a GACT_LONGINT type. EO_BIGCHANGE Complete or major change to the text, e.g. new string. EO_UNDO Some other style of undo. EO_CLEAR Clear the string. EO_SPECIAL An operation that doesn't fit into the categories here. These are the actions to be taken by Intuition after the hook returns. Actions Flag Purpose ------------ ------- SGA_USE If set, use contents of SGWork. SGA_END Terminate gadget, Code field is sent to application in IDCMP_GADGETUP event code field. SGA_BEEP Beep (i.e., flash) the screen. SGA_REUSE Reuse the input event. Only valid with SGA_END. SGA_REDISPLAY Gadget visuals have changed, update on screen. SGA_NEXTACTIVE Make next possible gadget active SGA_PREVACTIVE Make previous possible gadget active
[edit] Proportional
struct PropInfo
{
UWORD Flags;
PROPBORDERLESS -
AUTOKNOB -
FREEHORIZ and FREEVERT
PROPNEWLOOK
KNOBHIT
UWORD HorizPot;
UWORD VertPot;
UWORD HorizBody;
UWORD VertBody;
UWORD Cwidth;
UWORD Cheight;
UWORD HPotRes, VPotRes;
UWORD LeftBorder;
UWORD TopBorder;
};
In the Gadget structure, set the GadgetType field to GTYP_PROPGADGET and place the address of the PropInfo structure in the SpecialInfo field.
To change the flags and the pot and body variables after the gadget is displayed, the program can call NewModifyProp().
void NewModifyProp( struct Gadget *gadget, struct Window *window, struct Requester *requester,
unsigned long flags, unsigned long horizPot, unsigned long vertPot,
unsigned long horizBody, unsigned long vertBody, long numGad );
[edit] BOOPSI
If you use BOOPSI scrollers, you can set Total, Visible and Top attributes. And you can let it send you messages when the user moves the bar. Intuition comes with its own BOOPSI scroller class - the propgclass. It is better integrated inside the window border.
[edit] Classes
[edit] Misc
There also seems to be a problem with sending the SA_PubSig signal to the SA_PubTask. The SA_PubTask gets the signal, if UnlockPubScreen is called and this was the last lock. This is independent of the number of windows on the screen.
So this can happen:
- Open Pubscreen - Lock Pubscreen - Open window on Pubscreen - UnlockPubscreen - SA_PubSig is sent!! - .... - Close Window
As you can see in, it seems to be not necessary to lock a pubscreen to open a window on it, at least, if you own it.
LockPubScreen() Find Workbench or any other public screen; prevent it from closing while a window is opened or its attributes copied.
UnlockPubScreen() Release the lock allowing the screen to later be closed.
struct Screen *LockPubScreen( UBYTE * )
VOID UnlockPubScreen( UBYTE * , struct Screen *)
SetDefaultPubScreen() Establishes a given public screen as the default.
GetDefaultPubScreen() Copies the name of the default screen to a user supplied buffer for use by the screen manager utility
(the name is not needed by normal applications, use LockPubScreen(NULL) instead).
PubScreenStatus() Converts a screen to private or public status.
SetPubScreenModes() Controls the public screen global mode bits.
WBenchToBack() Move the Workbench screen behind all other screens.
WBenchToFront() Move the Workbench screen in front of all other screens.
OpenWorkBench() Open the Workbench screen. If the screen is already open, this call has no effect.
This call will re-awaken the Workbench application if it was active when CloseWorkBench() was called.
CloseWorkBench() Attempt to reclaim memory used for the Workbench screen.
If successful, this call closes the screen and puts the Workbench application to sleep.
This call fails if any application has windows open or locks on the Workbench screen.
LockPubScreenList() Lock the public screen list maintained by intuition so that it may be quickly copied.
UnlockPubScreenList() Release the lock on the public screen list.
NextPubScreen() Find the next screen in the public screen list.
[edit] Using Screens
There are some additional functions you can use to manipulate screens.
void DisplayBeep(struct Screen *) This function will flash the specified screen, for example, to indicate an error. e.g. DisplayBeep(myScreen); void MoveScreen(struct Screen *, WORD dx, WORD dy) This function will move the current screen to the specified pixel co-ordinates. This is similar to dragging the screen bar to a new location. e.g. MoveScreen(myScreen, 0, 100); /* Move screen down to y co-ord 100 */ void ScreenToBack(struct Screen *) void ScreenToFront(struct Screen *) If you have multiple screens open, then you can switch between screens using these functions. ScreenToFront will make a screen the visible screen. e.g. ScreenToFront(myScreen); void MakeScreen(struct Screen *) e.g. MakeScreen(myScreen); void ShowTitle(struct Screen *, BOOL) Specifies whether to show the screen's title bar or not. e.g. ShowTitle(myScreen, FALSE);
See Intuition Reference documentation for further commands.
GetScreenDrawInfo() Get the DrawInfo information for an open screen. FreeScreenDrawInfo() Free the DrawInfo information for a screen. MakeScreen() Low level screen handling--rebuild Copper list. RethinkDisplay() Low level screen handling--incorporate Copper list changes. RemakeDisplay() MakeScreen() for all screens, then RethinkDisplay(). ScreenNotify() Private function
[edit] Backfill Hook
see this thread
AROS_UFH3(void ,sbackfillfunc,
AROS_UFHA(struct Hook *,hook,a0),
AROS_UFHA(struct RastPort *,frp,a2),
AROS_UFHA(struct BackfillMsg *,bfm,a1))
{
AROS_USERFUNC_INIT
struct RastPort rp;
CopyMem(frp, &rp, sizeof(struct RastPort));
rp.Layer = NULL;
FillPixelArray( &rp,
bfm->rect.MinX,
bfm->rect.MinY,
bfm->rect.MaxX - bfm->rect.MinX + 1,
bfm->rect.MaxY - bfm->rect.MinY + 1,
0x00000000);
AROS_USERFUNC_EXIT
}
struct Hook sbackfillhook;
And here the open screen call:
sbackfillhook.h_Entry = (HOOKFUNC) sbackfillfunc;
info->screen = OpenScreenTags( NULL,
SA_Width, target_width,
SA_Height, target_height,
SA_Depth, target_depth,
SA_Quiet, TRUE,
SA_ShowTitle, FALSE,
SA_Type, CUSTOMSCREEN,
SA_DisplayID, dispid,
SA_BackFill, (ULONG) &sbackfillhook,
TAG_DONE);
SA_BackFill, (ULONG) &sbackfillhook,
Please don't use ULONG's to store/cast pointers in your code. use APTR/IPTR where appropriate.
If the code you posted is the code in its entirety, then the reason why it doesn't work maybe because of the way you have filled sbackfillhook. in Demos/scrbackfill the hook is filled like:
static void InitBackfillHook(void)
{
backfillhook.h_Entry = HookEntry;
backfillhook.h_SubEntry = (HOOKFUNC)MyBackfillFunc;
}
HookEntry is defined in clib/alib_protos.h and MyBackfillFunc is:
static void MyBackfillFunc(struct Hook *hook,struct RastPort *rp, struct LayerHookMsg *msg);
Or just look in Demos/scrbackfill.c
struct DrawInfo
{
UWORD dri_Version; /* will be DRI_VERSION */
UWORD dri_NumPens; /* guaranteed to be >= 9 */
UWORD *dri_Pens; /* pointer to pen array */
struct TextFont *dri_Font; /* screen default font */
UWORD dri_Depth; /* (initial) depth of screen bitmap */
struct { /* from DisplayInfo database for initial display mode */
UWORD X;
UWORD Y;
} dri_Resolution;
ULONG dri_Flags; /* defined below */
/* New for V39: dri_CheckMark, dri_AmigaKey. */
struct Image *dri_CheckMark; /* pointer to scaled checkmark image
* Will be NULL if DRI_VERSION < 2
*/
struct Image *dri_AmigaKey; /* pointer to scaled Amiga-key image
* Will be NULL if DRI_VERSION < 2
*/
ULONG dri_Reserved[5]; /* avoid recompilation ;^) */
};
#define DRIF_NEWLOOK 0x00000001L /* specified SA_Pens, full treatment */
/* rendering pen number indexes into DrawInfo.dri_Pens[] */
#define DETAILPEN (0x0000) /* compatible Intuition rendering pens */
#define BLOCKPEN (0x0001) /* compatible Intuition rendering pens */
#define TEXTPEN (0x0002) /* text on background */
#define SHINEPEN (0x0003) /* bright edge on 3D objects */
#define SHADOWPEN (0x0004) /* dark edge on 3D objects */
#define FILLPEN (0x0005) /* active-window/selected-gadget fill */
#define FILLTEXTPEN (0x0006) /* text over FILLPEN */
#define BACKGROUNDPEN (0x0007) /* may not always be color 0 */
#define HIGHLIGHTTEXTPEN (0x0008) /* special color text, on background */
/* New for V39, only present if DRI_VERSION >= 2: */
#define BARDETAILPEN (0x0009) /* text/detail in screen-bar/menus */
#define BARBLOCKPEN (0x000A) /* screen-bar/menus fill */
#define BARTRIMPEN (0x000B) /* trim under screen-bar */
#define NUMDRIPENS (0x000C)
/* New for V39: It is sometimes useful to specify that a pen value
* is to be the complement of color zero to three. The "magic" numbers
* serve that purpose:
*/
#define PEN_C3 0xFEFC /* Complement of color 3 */
#define PEN_C2 0xFEFD /* Complement of color 2 */
#define PEN_C1 0xFEFE /* Complement of color 1 */
#define PEN_C0 0xFEFF /* Complement of color 0 */
[edit] Windows Misc
To hide a window (and make in reappear again!), use ChangeWindowShape(). Still have no idea, how to make a window opened with WA_Visible=FALSE visible again ;)
If we get a MENUVERIFY message, we look at the according open window. If it has WFLG_RMBTRAP cleared at the time of the mouse click, we display an according AROS intuition menu.
the busy pointer, I have tried adding ..
SetWindowPointer( win, WA_BusyPointer, TRUE, WA_PointerDelay, TRUE, TAG_DONE ); SetWindowPointer( win, TAG_DONE );
as I will only get the default pointer and not the current one that might be set by an application using SetWindowPointer() or SetPointer() functions.
Is there a way to get the current pointer bitmap? You could always patch the necessary function at runtime so that your own routine would be called with the necessary information, and then do what you need (as well as call the original function to actually set the visible pointer).
- intercept the call,
- copy the bitmap so that I can use it for my own purpose
- forward the call to the original function
Digging into it is seems that it's not SetWindowPointerA that I shall patch but rather ChangeExtSpriteA. SetWindowPointer is used when a new pointer is set for a window, this pointer will therefore be used when the window is active. But ChangeExtSprite is called each time the pointer changes, i.e. also when active window is changing.
Is there a way to get notification of the current pointer change? An application can change the pointer image at any time by calling SetWindowPointer(), for example to show the busy pointer. These changes are not reflected by a file change and will not cause a DOS notification.