💾 Archived View for jeacle.ie › amiga › gtb captured on 2023-12-28 at 15:17:46. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-03)

-=-=-=-=-=-=-

GadToolsBox V2.0

Karl Jeacle

July 1993

CUGI Newsletter

GadToolsBox is a `giftware' program written by Jan van den Baard which lets you draw/edit GadTools gadgets and menus and then generates the corresponding source code for you. The latest version is 2.0 and is on Fish Disk 842. It is also available on Infomatique BBS. I must point out that this is by no means a comprehensive review of the program --- it is merely an account of one user's experience with it.

So what does it do?

After coming home from work/college/school or whatever you do during the day, you don't always have the time to launch into writing code for the Amiga. Time is always at a premium. Playing a few games, logging onto a BBS or just hacking around in general always seems a lot easier than writing code. This is certainly my experience anyway.

I came across GadToolsBox recently while going through some of the Fish Disks. I installed the program and decided to give it a try. Usually, I'd skip over a lot of the programming tools I'd come across as I figured I just didn't have time for them, however I decided to try out GadToolsBox.

Not having programmed the Amiga for some time, my Amiga C was a bit rusty, so I was curious to find out just how easy it was to generate a front-end for whatever killer application I could now write. Without looking at the documentation, I created a couple of windows on a custom screen, set up various attributes for each window, and selected `Generate C Source'. A C source file and header file were promptly created.

Having had a quick look at the source which was generated, I typed in the following:

main()
{
       SetupScreen();
       OpenWindow1();
       OpenWindow2();

       Delay(500);

       CloseWindow2();
       CloseWindow1();
       CloseDownScreen();
}

I ran the above through DICE along with the GadToolsBox code expecting a few million compilation or link errors. To my surprise, an executable was created without any problems! And sure enough, when I ran it, up came the screen with two windows, and after a short delay, they were gone again. It was no big deal --- but I was impressed. I decided this program was worth a more serious look.

You pays yer money...

GadToolsBox is `giftware' which means that if you like the program you should reward the author with a gift that, you think, matches his efforts. This can be any gift you like --- not just money.

Since GadToolsBox is all about `gadtools.library' and this comes with OS2.0, you must have at least this revision of the Amiga OS to use the program. It also needs a few other libraries such as the `reqtools' and `powerpacker' libraries.

The documentation supplied is pretty good. A 3000 line AmigaGuide file is provided with plenty of `links' and sample source to help you do most things you'll want. The complete source code to the program is also provided. And naturally, most of the requesters the program uses were generated by GadToolsBox itself.

GadToolsBox not only allows C source to be generated, but it can also produce Assembler and Oberon\footnote{Yet another Niklaus Wirth creation --- he of Pascal and Modula-2 fame.} code. And not only does it produce the basic GUI code, but it can now also create `IDCMP handler' code --- more on this later.

The only competitor to GadToolsBox that I know of is Commodore's `Toolmaker' which was demonstrated at CUGI recently. This is a commerical product and costs about US$75.

Down to business

The whole point of GadToolsBox is to take the pain out of creating GUI code. While it's all very interesting figuring out how it all works, and taking great pride in handcrafting an interface, writing GUI code can be rather tedious, and at times, quite boring. The other consideration, as mentionted earlier, is time. Creating a GUI can be quite a time intensive task --- an edit-compile-run cycle just to check if those windows line up or that gadget is in just the right place.

With GadToolsBox, you can create screens, windows, menus, and every type of GadTools gadget available. You can do this interactively. You can move windows and gadgets around on the screen to your heart's content until they meet your approval. You can test how your menus look, and how they operate. You really can create your whole GUI with this program and then just have all the source code generated in the language of your choice.

But GadToolsBox doesn't stop here. Not only can it generate the code to create and display your GUI, but it can also create `handler' code and provide you with `stub' functions where you can fill out the code which should be executed when a certain menu item is selected or a gadget clicked.

For example, Figure 1 shows the menu creation window. Here you can define everything about your menus: item names, keyboard shortcuts, whether the option should be initially disabled/ghosted, whether or not this menu item should have checkmarks, and what other items are mutually exclusive to that selection. But what you can also do here, is give the name of the function which should be called when this menu item is selected. In the figure shown, selecting `9600' would cause a function called `Receive9600()' to be called --- `Receive' being the name of the window to which the menus are attached.

[‡ gtb]

To make use of this facility, your mainline code should make a call to a `handler' routine called (in this case) `HandleReceiveIDCMP()'. This function acts as a despatch function, and checks what message has been sent by Intuition and calls the appropriate function. A global copy of the IntuiMessage which caused the function to be called is available to you when inside your function code.

One thing you do have to remember with GadToolsBox is that you should never attempt to modify or tweak the code that it has created. This is because if you intend to generate that code again, any changes that you have made will be overwritten when the new source is output.

Criticisms

If I'd have to make a criticism of GadToolsBox, it would have to be that both it, and the source it creates are a little bit buggy in places. I have come across at least one bug while using the program and have read on UseNet of various scenarios where incorrect code has been created. Another point is that the code it creates is a little lacking on the side of comments --- variable names are a little obscure at times, and it's not always clear what's going on.

Having said this, of course, you have to bear in mind that this code was never really intended for human consumption, it's supposed to be run through a compiler without the user ever looking at it.

Conclusion

GadToolsBox should not only be of interest to those who want to create a complete GUI with minimum hassle, but also to those who are interested in learning more about programming gadtools.library. Simply seeing how it's done by looking at the generated source can be extremely useful... The bulk of GadToolsBox users, however, are probably those who are going to use the code it produces as a basis for their own GUI code. They can take the output and modify and enhance it to suit their own needs.

For me, GadToolBox was something that got me back into programming the Amiga. At first I thought it could do just about everything, but now I can see the limitations involved in using it. What you gain in ease of use, you lose in flexibility. There are several things I'd like to do with GadToolsBox now, but I can't, and because of this, I'm tempted to move into that last catagory of users who take its output and hack on it. This is unfortunate as one of the nicest aspects of using GadToolsBox is being able to flick screens, revamp your GUI, flick back and do another `make' to have a brand new GUI on your program.

In conclusion, I'd say that GadToolsBox is a pretty darn handy program to have around, and if you've ever played about with C on the Amiga, but never quite managed to to get to grips with programming the GUI then it's well worth taking a serious look at.

GadToolsBox screenshot