It is the shared responsibility of the Wimp and the application to ensure that windows on the screen are updated. The Wimp does not, after all know what the contents of a window should be.
The Wimp is responsible for informing applications when a window needs to be redrawn and which part of a window is to be redrawn. It is the responsibility of an application to actually redraw the contents of a window.
When a window needs to be redrawn, it is quite possible that only part of the window needs to be updated, and hence the Wimp will inform the application which rectangular part(s) of a window needs to be redrawn. The Wimp splits these parts into non-overlapping rectangles so that the application can either;
• efficiently update only the rectangular parts of a window
• simply but inefficiently update the whole window in one go
An application receives notification that one of its windows needs redrawing by receiving a Redraw_Window_Request? event from the Wimp_Poll.
Upon notification, the application should enter a loop whereby it checks with the Wimp which rectangular part of a window needs updating. The application itself must then take responsibility to update each rectangular part of the window.
The snippet of pseudo code below shows how an application would deal with this.
REM block is the Wimp_Poll block SYS"Wimp_RedrawWindow",,block TO flag WHILE flag :REM Get each rectangular are needing updating Redraw contents of the appropriate rectangular part of a window SYS"Wimp_GetRectangle",,block TO flag ENDWHILE Return to polling loop
The block
returns numerous values that are of use for updating a window including and full details are available in the Wimp_GetRectangle page.
The areas specified by the Wimp_RedrawWindow call are automatically cleared to the window’s background colour by the Wimp. The task must determine how to update the windows contents taking into account the visible work area and scroll offsets.
The following operations should not be used within the redraw loop
By ensuring that these operations are excluded from the window redraw loop, the same code can be reused to draw the window contents to a printer.
A full description on improving redraw speed is available in the Redrawing Speed? section in the RISC OS Style Guide.