category: Specification <div id="toc_heading"></div><div id="toc"></div> <notextile> <h2>Rendering into Windows</h2> <p> In some instances it is necessary to have a complex graphic in a window which cannot be represented as text or a sprite and so requires an external source to redraw it. This is achieved via the Wimp’s <i>Post-</i><i>Rectangle Filters</i>. The Filter Manager (version 0.13 and above) makes these filters available to other modules so that they can draw directly into a Wimp window. Filter Manager 0.15, in conjunction with version 3.86 of the Wimp also provides <i>Post-Icon Filters</i>. </p> <p> Post-Rectangle filters are available in Window Manager modules 3.86 or later. On versions 3.16–3.85 of the Wimp, the Filter Manager will simulate the post-rectangle filter using the rectangle filter. (The original rectangle filter itself is not useful for this application because it is called for the window tools as well as window contents, and is also called before the Window Manager draws the window background). </p> <p> Post-Icon filters are only are only available in Window Manager modules 3.86 or later; they are not simulated on older Window Managers. </p> <p> Post-Rectangle and Post-Icon filters are quite low level and there are a number of complications when using them directly, so a new module, the Redraw Manager has been written. This enables a module to ‘register interest’ in a region of a wimp window and then be called back whenever this region has been invalidated. Note that Rectangle filters work even if the window is ‘auto-redraw’ and so the client does not need to know that the Gadget is being provided in this way. </p> <p> When the callback is made, the module is told which part of the window is being updated and how this intersects with the region that was registered for. A data pointer is also passed back so that the module can access the required information for redrawing the region. As a result the call will be made separately for each region that is currently invalid that the module has registered an interest in. </p> <p> The callback is made during a redraw loop (so Wimp_PlotIcon takes work area coordinates). Do not call Wimp_GetRectangle or Wimp_UpdateWindow in your callback routine. The order of actions for each rectangle being redrawn is: </p> <ol type="1"> <li>The Filter Manager calls rectangle filters.</li> <li>The Window Manager draws the window tools and the window background.</li> <li>The Filter Manager calls post-rectangle filters, including the Redraw Manager.</li> <li>The Redraw Manager calls ‘early’ callback routines for the areas of interest intersecting the rectangle being drawn.</li> <li>The Window Manager sets the graphics foreground and background colours according to the window definition.</li> <li>The application owning the window draws any contents in its redraw loop.</li> <li>The Window Manager draws the icons.</li> <li>The Filter Manager calls post-icon filters, including the Redraw Manager.</li> <li>The Redraw Manager calls ‘late’ callback routines for the areas of interest intersecting the rectangle being drawn.</li> </ol> <p> Thus anything your callback routine redraws will appear <i>behind</i> the rest of the window contents, unless you ask for a ‘late’ callback (bit 3 of R0 set in Redraw_AddCallBack), in which case what you draw will appear in front of the rest of the window contents. It is generally recommended that you do not use ‘late’ callbacks unless your application/gadget will only ever run on version 3.86 or later of the Wimp. </p> <p> <b>Notes:</b><br />Wimps prior to 3.86 have a bug which means that rectangle filters (and hence the simulated post-rectangle filters) are erroneously called when the caret moves. This can result in strange effects if, for example, a writable icon is placed in front of a graphic drawn via the Redraw Manager. This shouldn’t normally affect gadget authors, as gadgets shouldn’t normally overlap. A fix for this may be implemented in future releases of the Filter Manager. </p> <p> When post-rectangle filters are being simulated on Wimps prior to 3.86, the Window Manager will set up graphics colours between stages 2 and 3 above as well as in step 5. This does not happen with Wimp 3.86 or later, so do not rely on this behaviour. </p> <p> The RedrawManager has an API as follows:- </p> <h2>Service_RedrawManagerInstalled (Service Call &A5)</h2> <p> Entry:<br /> R0 = Redraw Manager version * 100<br /> R1 = &A5 (reason code)<br /> </p> <p> Exit: All registers preserved<br /> </p> <p> This service call is issued when the Redraw Manager starts up. You may then register areas of interest using Redraw_AddCallBack. </p> <h2>Service_RedrawManagerDying (Service Call &A6)</h2> <p> Entry:<br /> R1 = &A6 (reason code)<br /> </p> <p> Exit: All registers preserved<br /> </p> <p> This service call is issued as a broadcast to inform Redraw Manager clients that they have been deregistered and that the Redraw Manager is about to die. </p> <h2>Redraw_AddCallBack (SWI &82C80)</h2> <p> Entry:<br /> R0 = flags:<br /> bit 0 reserved<br /> bit 1 set -> set up graphics rectangle before making SWI<br /> bit 2 set -> return co-ordinates to callback in screen co-ordinates<br /> bit 3 set -> call after plotting icons, else before user contents<br /> bits 4–31 reserved<br /> R1 = Wimp window handle<br /> R2 = SWI to call out to<br /> R3 -> bounding box of region (in work area coordinates)<br /> R4 = data to associate with region<br /> </p> <p> Exit: All regs preserved<br /> </p> <p> This SWI registers 'an interest' in a region of a window so that the module will be called whenever the region is updated. Setting bit 1 will ensure that a suitable graphics window will have been set up before the module is called (restricting output to within both the redraw rectangle and the area of interest). If bit 1 isn’t set the graphics window will be the whole redraw rectangle. </p> <p> Setting bit 3 means that you will be called after the Wimp has plotted any icons in the window, so what you draw will appear on top of anything else. This behaviour is only available with version 3.86 or later of the Window Manager. </p> <h2>Redraw_RemoveCallBack (SWI &82C81)</h2> <p> Entry: R0 = flags (must match flags passed to Redraw_AddCallBack)<br /> R1 = wimp window handle<br /> R2 = SWI<br /> R3 -> bounding box of region (in work area coordinates)<br /> R4 = data to associate with region<br /> </p> <p> Exit: All regs preserved<br /> </p> <p> This SWI deregisters 'an interest' in a region of a window. In order to deregister successfully, all the parameters must match in the way that the region was registered. </p> <h2>Callback handler</h2> <p> Entry:<br /> R0 = flags:<br /> bit 0 set -> your region is entirely inside the area being updated<br /> bits 1–31 reserved<br /> R1 -> bounding box of region being updated (in work area coordinates or screen<br /> coordinates depending on bit 2 of flags in call to Redraw_AddCallBack)<br /> R2 -> 'state' for this window (block as returned from Wimp_GetWindowState)<br /> R3 -> bounding box of registered region (in work area coordinates)<br /> R4 = data associated with region<br /> </p> <p> Exit: All registers preserved<br /> </p> <p> The Redraw Manager calls a module when a region requires redrawing with the above registers set up. </p></notextile>