A WIMP Hello World?
Garry (87) 184 posts |
Hello, Thanks Garry |
Rick Murray (539) 13840 posts |
Most people use a library to do the grunt work. There are (IIRC) three libraries.
e? m? w? Why make a nice library and mess it up with dumb naming?!
There are some other options:
Anyway – your main choices will be DeskLib and OSLib. Investigate those. I know DeskLib comes with a StrongHelp manual, detailed header files, examples, and such. I’d be very surprised if OSLib wasn’t the same. I can’t give you a concrete example as it depends upon the library you choose… OSLib is at http://ro-oslib.sourceforge.net/ DeskLib is at http://www.riscos.info/index.php/DeskLib [huh? the latest (not released?) DeskLib version is ELF only for GCC? WTF is ELF doing on RISC OS?! I have a feeling, once I’ve bought a copy of the latest DDE (don’t hold your breath, my pay is….pitiful….and the price of my phone/net/mobile package would make a Brit cry!), I might look to porting it back to the Norcroft suite, plus maybe also tackling some of the interesting-looking outstanding issues. ;-) ] |
GavinWraith (26) 1563 posts |
A wimp hello world? Try this in RiscLua 5.60: local task in (require “wimp.task”) |
Chris Hall (132) 3554 posts |
Just the most basic thing in the world would be great, I know this may not be what you expected but why not look at a multi-tasking programme written in BASIC (which does not use libraries). Adding buttons and things like that is just a matter of reading the PRMs to get the numbers right. That might help you make the decision about what library (if any) you want to use. If you download the programme !Cat from !Store you’ll find it has a lot of help and REM statements… |
Theo Markettos (89) 919 posts |
To summarise, doing things ‘bare metal’ with the SWIs is perfectly do-able, but as Chris says there’s a lot of offsets to remember (block%!76 and suchlike). In C you’d call SWIs with _kernel_swi or _swix (better). OSLib is a type-safe frontend to the swis, so you’re using C structures not arbitrary memory and register numbering. There’s a 1:1 mapping between OSLib calls and a SWIs – almost all SWIs are covered. DeskLib is an event library, so at a higher level. It takes care of the polling for you, you have to write handlers when events like mouse clicked or window dragged happen. I’m not familiar with BASIC libraries, but I think DrWimp comes in at roughly the same level as DeskLib. In C++ there are a few class libraries, with which I’m not really familiar and are mostly not really developed any more. The most recent one I’ve seen is RTK (book , source ) which looks OK, though I haven’t used it much in anger. There isn’t much takeup of C++ libraries in general (partly due to the woeful Norcroft C++ compiler). |
Garry (87) 184 posts |
I think I’ll stick with OSLib for the moment. In some ways I like the idea of bare SWIs, just for the lack of other libraries required, but my comfort zone is well and truly C toolkits like Motif or QNX Photon. Gavin, actually the project I plan to work on is Lua-based, but I want to do the UI in C, so it works the same as on other platforms I’m working on. I may well be in touch about your Lua builds though. |
Chris Johnson (125) 825 posts |
Remember that complementary to oslib is the oslib-support library which adds such things as event libraries, exception handling, an interface to messagetrans, and also provides some veneers to allow code originally intended for the Acorn toolbox lib to be used with the oslib toolbox functions. |
Alan Buckley (167) 232 posts |
There is also my TBX C++ library (https://sites.google.com/site/alansriscosstuff/tbx). It works with the RISC OS Toolbox modules. It’s fairly comprehensive. I’m still developing it, but at the moment it is driven by what I need only. If others use it they can email me to add any missing features and I’d see what I could do. The GCC compiler for RISC OS is excellent for C++ programs. I switched to GCC from Norcroft many years ago because of this. As the toolbox handles a lot of the initial application setup and UI, you can use !ResEd to build your UI and then the minimum tbx source code is: #include “tbx/application.h” int main() my_app.run(); return 0; |
Rick Murray (539) 13840 posts |
My uncle wrote an educational textbook about C++, classes, and such. I read the copy he sent me and I remember thinking that while sine stuff was friendlier, but never understood the attraction. I guess I think like an assembler coder. ;-) |
Garry (87) 184 posts |
Alan, TBX looks impressive, but I am a C guy really, and for the moment I think I’d like to stick to that. If anyone else is interested, I found exactly what I wanted, a ‘Hello World’ for the WIMP with OSLib: http://www.sfryatt.eclipse.co.uk/temp/wimp.html This looks just like what I need. |
Raik (463) 2061 posts |
Too easy? ;-) |
Garry (87) 184 posts |
Raik, Perhaps… I’m going to try OSLib first and see how I go, if I don’t like it, I may take a look at DrWimp. Cheers Garry |
Colin (478) 2433 posts |
If you are using Norcroft use toolbox libs (C libraries) that come with it. There’s a manual included – toolbox.pdf. For most apps you can just use ResEd to create the interface, try it out in restest, give each action (menu press, button press etc.) an event number and catch the events in your program and act on them. There are some examples included with Norcroft. |
Dave Higton (1515) 3526 posts |
What is the status of FormEd? Is it available for free somewhere, or does it only come with the Norcroft kit? It occurs to me that our target group of Raspberry Pi RISC OS users might want to create their windows using a GUI like FormEd rather than programmatically. |
Colin (478) 2433 posts |
FormEd doesn’t come with Norcroft. |
Raik (463) 2061 posts |
I use !WinEd. |
Garry (87) 184 posts |
Colin, yes I am using Norcroft, although I do not want to build my UI in ResEd. The program I want to write involves interfaces being built from description files, so I want to do it all in code. Do you know of any quick examples of how to put a window on the screen, and put a button on the Window, in code, with the Toolbox C veneers? I looked through the toolbox.pdf manual, but I tend to get a lot further if I see a simple example. Cheers Garry |
Theo Markettos (89) 919 posts |
If you’re programmatically generating Templates or Resource files, have a look at CCres |
Colin (478) 2433 posts |
Look at AcornDDE.Sources.dde-examples.legacy.!MinApp. The only thing legacy about it is that you dont use !make for make files anymore. Double click on the Res file to see the windows – it should load into ResEd. Toolbox objects can be dynamically created. Easiest way is to create a window in resed, which you don’t show, containing the gadgets you want and copy them at runtime. |
Steve Fryatt (216) 2105 posts |
If anyone else is interested, I found exactly what I wanted, a ‘Hello World’ for the WIMP with OSLib: Wow. It took a while to remember why I’d posted that… It’s worth pointing out that it was a re-working of code posted somewhere (csap, probably) in a debate about the usefulness of OSLib — I re-wrote the exact code posted by someone else but used OSLib to dispose of all the I would strongly suggest that while that code is a working example of a Wimp application in C, you heed the advice of others regarding the use of some kind of event library to avoid the need for the unscalable
construct: if you don’t things will quickly become unmanageable when you have more than one window. I think OSLib comes with such a library, although I’ve never used it as I use my own (which can be found at http://www.stevefryatt.org.uk/software/build/ for completeness). |
Steve Drain (222) 1620 posts |
May I mention using BASIC with Basalt and the Toolbox? This is event driven and can make application development quite rapid. Events can also be used with normal wimp programs, so I think it is a step closer to DeskLib than DrWimp, and is certainly much faster. Keep your eyes open for Basalt with structures in a few days. It works fine, but there are a couple of advanced features I want to add before releasing it. Then you will be able to put window blocks into structures in normal wimp programs. ;-) |
Garry (87) 184 posts |
Right then, I’ve put aside my OSLib efforts, and decided to try out Toolbox. Must say, I’m pretty pleasantly surprised by it, at the recommendation of Colin, I created a blank window, and a also a window with ‘spare’ gadgets in, which I then copy into my blank window at runtime, it works great! Only thing is, if I copy over a button, then click it, the whole window disappears. This does not happen with check boxes, writables etc. Any ideas why this would happen? I think I’d like to stick with Toolbox as opposed to DrWimp or whatever, I think I “get” it and it’s similar in concept to other widget libraries I’ve used. Once I can start to reliably add gadgets to a window, then I can look at porting over my program to RISC OS in earnest. Cheers Garry |
Colin (478) 2433 posts |
Mark the button as ‘Local’. Default action is to remove the window when clicked on with the left button (select), leave the window on screen when clicked on with the right button (adjust). These are normal actions for the ok and cancel button in a dialogue box. |
Garry (87) 184 posts |
Perfect, thanks Colin. I don’t suppose you know how to get a nice ‘printf’ going? I can get it painting direct to the screen, but I’d rather output to a little console window or something. |
Steve Fryatt (216) 2105 posts |
Er, no — don’t… The Toolbox is a good thing to investigate, but use it in addition to OSLib and not instead of. OSLib isn’t a programming “library” — it’s clean and type-safe way to access the OS APIs, and it provides access to all of the Toolbox APIs in addition to everything else. You really don’t want to start a new RISC OS project in C without using OSLib — IMHO, of course. |