www.riscos.com Technical Support: |
|
In RISC OS 3.6 the DragAnObject module was introduced. It provides SWI calls similar to those provided by the DragASprite module, save that you can use them to make the pointer drag any object around the screen. To do so, you must specify a SWI or a C / assembler function to render the object.
Since not all users will prefer this effect to dragging an outline - whether for aesthetics or performance - there is a bit in the CMOS RAM used to indicate their preference. (See CMOS RAM allocation.) You should examine that bit before using this module; if it shows that the user would prefer to drag outlines, oblige them!
To drag an object:
Starts dragging an object
R0 = flags
R1 = renderer called to render the object:
R0 - R4 preserved
Interrupt status is undefined
Fast interrupts are enabled
Processor is in SVC mode
Not defined
This call starts dragging an object. To do so, it uses the given SWI / function to render your object twice into workspace that it claims. It then combines the two images into a single masked image, so only those pixels rendered will be used for the drag. It finally starts a Wimp drag of the masked image, and frees any workspace not needed for the drag itself.
You may dispose of any workspace used by the rendering SWI / function as soon as this call returns. If there is insufficient memory available to start the drag, the call reverts to a normal drag of a dotted outline.
The flags given in R0 have the following meanings:
Bits | Meaning | |
---|---|---|
0 - 1 | Horizontal location of object in box: | |
00 | left | |
01 | centre | |
10 | right | |
2 - 3 | Vertical location of object in box: | |
00 | bottom | |
01 | centre | |
10 | top | |
4 - 5 | Drag bounding box is: | |
00 | whole screen | |
01 | display area of window that the pointer's over | |
10 | specified in block pointed to by R4 | |
6 | Bounding box applies to: | |
0 | the box | |
1 | the pointer | |
7 | Control of drop-shadow: | |
0 | don't do a drop-shadow | |
1 | make a drop shadow | |
8 | Control of dithering: | |
0 | dither the dragged object | |
1 | don't dither the dragged object | |
9 - 15 | Reserved for future use - should be set to 0 | |
16 | Rendering is done by: | |
0 | a SWI (see below) | |
1 | a C / assembler function (see below) | |
17 | If the renderer is a function, it is called in: | |
0 | User mode | |
1 | SVC mode (use for modules; also allows access to statics) | |
18 - 31 | Reserved for future use - should be set to 0 |
The type of renderer is set by bit 16 of the flags:
The blocks pointed to by R3 and - optionally - R4 have the following format:
Offset | Use | |
---|---|---|
0 | x-low | box |
4 | y-low | bottom-left (x-low, y-low) is inclusive |
8 | x-high | top-right (x-high, y-high) is exclusive |
12 | y-high |
None
Terminates any current drag operation, and releases workspace
--
--
Interrupt status is undefined
Fast interrupts are enabled
Processor is in SVC mode
Not defined
This call terminates any current drag operation, and releases any workspace still claimed to do a drag. You should make this call when your application receives the User_Drag_Box reason code from Wimp_Poll (see Wimp_Poll) during a drag.
None
The following code fragments show how you might call DragAnObject_Start from C:
void start_drag(...) { _kernel_swi_regs regs, render; /* Set up registers for Wimp_PlotIcon renderer */ render.r[1] = (int) &icon; render.r[4] = 0; render.r[5] = 0; /* Set up registers for DragAnObject_Start... */ regs.r[0] = some flags; regs.r[1] = Wimp_PlotIcon; regs.r[2] = (int) &render; regs.r[3] = (int) &bbox; /* ...and call it */ _kernel_swi(DragAnObject_Start, ®s, ®s); }
void _my_render(data) { /* do the render */ } void start_drag(...) { _kernel_swi_regs regs; int render[4]; /* Set up registers for _my_render renderer; render[0] - render[3] */ /* will be passed to the function as parameters */ render[0] = (int) data; /* as required by renderer */ /* Set up registers for DragAnObject_Start... */ /* (tell it we're a function and a module) */ regs.r[0] = some_flags + (1<<16) + (1<<17); regs.r[1] = (int) _my_render; regs.r[2] = (int) &render; regs.r[3] = (int) &bbox; /* ...and call it */ _kernel_swi(DragAnObject_Start, ®s, ®s); }