Wimp Programming In C

Like many other RISC OS users, I started programming in BBC BASIC. Although it served me well, I began to find that it didn’t always scale well – especially when software had to handle large, variable amounts of data or multiple documents.

After learning C on Unix systems, I began to investigate how it could be used on RISC OS. My first efforts directly copied the techniques used in BASIC, and quickly became just as unweildy as their predecessors.

Eventually I settled on using a combination of OSLib and my own libraries – imaginatively called SFLib – based on it. Together, these have formed the basis of all of my software which has been started since 2000.

The aim of this guide is to give some help to those who are competent in C but have not used it when writing for the RISC OS desktop. It will also introduce the use of SFLib, which may be of interest to those writing Wimp software using OSLib.

Many thanks to all those on the ROOL Forums who have answered my questions about the DDE and offered suggestions while I’ve worked on this guide.

Chapter 1: Starting in BASIC
For those familiar with BBC BASIC, we start by getting a simple application up and running using this language.
Chapter 2: Moving to C
We can write a very similar application in C, which should help show the parallels with – and differences from – BASIC.
Chapter 3: Compiling the Application
How to get the code using OSLib to compile in the DDE.
Chapter 4: Event Driven Programming
The RISC OS Wimp is essentially an event-driven environment, so why don’t we take advantage of that?
Chapter 5: A Better Way to Compile
Compiling the code ‘by hand’ soon becomes very tedious.
Chapter 6: Onto the Iconbar
Giving an application its own icon on the iconbar isn’t too hard to do.
Chapter 7: Clicks on the Iconbar
There’s not much point having an iconbar icon if it doesn’t respond to the user!
Chapter 8: Reporting Errors and Other Messages
It’s time to start communicating with the user...
Chapter 9: A Look at Debugging
Before moving on to the ‘serious stuff’, it might help to take a look at a tool to help us see what’s going on.
Chapter 10: Closing the Loose Reporting Ends
Now that we can use Reporter to quickly see what’s going on in our code, let’s tidy up the report code a little.
Chapter 11: Creating our First Window
We’re finally ready to create our first window!
Chapter 12: Window Theory
With a window on the screen, we now need to understand how it works.
Chapter 13: Handling Windows
Manipulating windows isn’t too difficult, but there are a few things to get to grips with.
Chapter 14: Introducing Icons
Icons are the building blocks used to make windows do something useful.
Chapter 15: Indirected Icons
Having seen the basics, it’s time to start making icons do more complicated things.
Chapter 16: Mouse Clicks in Windows
The mouse can make it easy for the user to interact with and control the application, if we let it.
Chapter 17: Creating an Application Directory
Applications on RISC OS usually come packaged in an application directory, and ours needs to follow suit.
Chapter 18: Sprite Icons and Choosing Options
We can do more interesting things with icons when we can include sprites and group them together.
Chapter 19: Window Templates
There’s a much easier way to design windows and icons than doing it by hand in C.
Chapter 20: Radio Icons Revisited
Let’s tidy up some loose ends on the subject of icons, before moving on to other things.
Chapter 21: Sprite Icons and Areas
Sprites don’t need text in them, and we can do more if we escape the Wimp Sprite Pool.
Chapter 22: The Missing Menus
With windows and icons introduced, now we can take a look at the third part of the RISC OS desktop.
Chapter 23: Menu Selections
Menus aren’t a lot of use if we can’t see the selections made by the user!
Chapter 24: Pop-Up Menus and Other Features
Pop-up menus provide a compact alternative to radio icons, and also allow us to show off some more menu features.
Chapter 25: Standard Window Menus
There’s one type of menu that we haven’t yet looked at: the ‘standard’ one which opens at the mouse pointer.
Chapter 26: Menus Revisited
We have seen how menus work from the perspective of the Wimp but, before moving on, let’s see what SFLib can do to improve things.
Chapter 27: Writable Icons
The Wimp isn’t all about interacting with the mouse, and it can be useful to allow the user to enter values from the keyboard too.
Chapter 28: Keyboard Input
How do we actually find out what keys the user is pressing when they are typing into our window?
Chapter 29: Internationalisation
English isn’t the first language of all RISC OS users, so how can we cater for those who would prefer to use our application in a different one?

About this tutorial

This tutorial is licenced under Version 1.2 of the European Union Public Licence, and the source – in the form of a collection of XML files and the associated graphics and example downloads – can be found on GitHub. It can be built into the format required by this website using my XML Docs tools; these may be useful as a starting point for using the content in other forms, and are also released under the EUPL v1.2.