Richard Ashbery takes a look at the latest publication from Chris Dewhurst
Towards the latter part of last year, Chris Dewhurst of Drag’n Drop fame published a new book for RISC OS users. Priced at £20.00 (plus £3.00 for postage and handling), the book is aimed at RISC OS users who are familiar with BBC BASIC and wish to write RISC OS desktop applications by learning to program the WIMP. The information and example programs are fully compliant with RISC OS 5 systems, and this brief review covers the first 5 chapters.
The first chapter contains an introduction to writing programs for the Graphical User Interface (GUI) and provides an overview of what the book will help you learn. It includes a Cyclic Redundancy Check (CRC) program that could be useful if you type in demo programs by hand – but if you purchase the additional download of example programs (available for £10.00) you won’t need it.
This chapter introduces SWI Wimp calls, which are key to interfacing your program with the WIMP, enabling it to multi-task. Examples covered are:
- SYS “Wimp_Initialise”
- SYS “Wimp_Poll”
- SYS “Wimp_CloseDown”
- SYS “Wimp_GetPointerInfo”
Also introduced is the concept of a memory block, which is often used to pass data to the system, WIMP poll codes that allow mouse buttons to be seen and acted on by the program, along with a number of other Wimp commands.
Here, the user is guided into the analysis of Words, Bytes and Bits – three basic units of storage in memory, and how to access and manipulate them using BBC BASIC’s indirection operators !, ?, and $. There are many examples to explain these, and a knowledge of them is essential to understand subsequent chapters.
Revealed in this chapter are the intricacies of creating a desktop window by examining the all important window block. Apart from the window title and coordinates, drawing a window requires a large block of data, typically twenty-two 32-bit words describing its characteristics. The approach used by Chris in the book is to use a group of DATA statements in a procedure, PROCWINDOWS, to describe them. These include:
- Window title
- Coordinates for position of window on screen and its size
- Window furniture flags (scroll bars/toggle size icon/close icon etc.)
- Window colours
- Work area
- Title flags
Another procedure, FNMKWINDOW, is the method used in the book to read the DATA values, and creates a block which draws the window using SYS “Wimp_CreateWindow”.
Chris has printed some very useful diagrams of the window block with the window flags and title bar flags on separate pages. Understanding the window block, and how the different values it contains relate to what appears on screen is the basis of understanding the WIMP.
This shows the reader how the WIMP handles icons in windows. A clear understanding of this chapter means the programmer is close to being able to write some useful apps. Once again it’s important to have an understanding of the icon block and its icon flags. The icon block describes the icon characteristics like position coordinates, dimensions, flags, validation, etc. and in the book is defined via a DATA statement comprising nine 32-bit words in the procedure, PROCMKICONS before the icon gets drawn on the desktop by SYS “Wimp_CreateIcon”. Once again there are some useful diagrams explaining the icon block and associated flags.
Beyond the first five chapters, Chris has provided a host of other important information on error handling, dealing with menus, loading and saving files using drag and drop, etc.
- Excellent resource (over 300 pages) providing a thorough introduction for creating your own apps.
- Numerous examples.
- Programs use a set of standard routines (e.g. FNMKWINDOW, PROCMKICON) listed in appendix 1.
- Each chapter ends with a useful summary.
- There are a number of text inaccuracies, but considering the amount of information offered (over 300 pages) this really is no surprise.
- Program text is faint and quite difficult to read, but as noted above Chris has released a download of all example programs contained in the book.
The Application Tutorial and Listings Book is an excellent publication and extremely good value even if you include the separate programs download.