Programming AmigaOS in C

Reaction

Reaction is a new graphical API that replaced the old Intuition and Gadtools with more new modern, granular and expandable interface. It is made up of Classes, Gadgets and Images. These files can be found in the SYS:Classes folder on AmigaOS 3.5 or later. AmigaOS 2.0 to 3.1 can use an older version called ClassAct.
AmigaOS 4.x does not use Reaction shared library instead it is now built into Intuition, and it uses the same headers and most macros.

Reaction contains the following classes, gadgets and images.

images/bevel.image
images/bitmap.image
gadgets/button.gadget
gadgets/checkbox.gadget
gadgets/chooser.gadget
gadgets/datebrowser.gadget
images/drawlist.image
gadgets/fuelgauge.gadget
gadgets/getfile.gadget
gadgets/getfont.gadget
gadgets/getscreenmode.gadget
images/glyph.image
gadgets/integer.gadget
images/label.image
gadgets/layout.gadget
gadgets/listbrowser.gadget
gadgets/radiobutton.gadget
gadgets/scroller.gadget
gadgets/slider.gadget
gadgets/space.gadget
gadgets/speedbar.gadget
gadgets/string.gadget

Plus the following items which are included:

gadgets/calendar.gadget
gadgets/colorwheel.gadget
gadgets/gradientslider.gadget
images/led.image
gadgets/statusbar.gadget
gadgets/tabs.gadget
gadgets/tapedeck.gadget
gadgets/textfield.gadget

a) Headers

To use the new classes and gadgets there are a number of header files that need to be included in your source code.
As the classes and gadgets are treated as Libraries, then you will need the proto headers loaded.
e.g.

#include <proto/layout.h>
#include <proto/label.h>
#include <proto/palette.h>
#include <proto/window.h>
For access to the DoMethod function to open and close Windows, you need to add the alib_protos.h header.
#include <clib/alib_protos.h>

Then you need the individual headers files that describe the tags and parameters needed for the classes and gadgets.
e.g.

#include <classes/window.h>
#include <gadgets/layout.h>
#include <gadgets/button.h>
#include <gadgets/palette.h>
#include <images.label.h>

Finally, you will need the reaction include files themselves and the macro definitions when defining reaction windows and gadgets
for the graphics.
e.g.

#include <reaction/reaction.h> /* Required for AmigaOS 3.x */

#include <reaction/reaction_macros.h> /* Required for all AmigaOS */

b) Libraries

The reaction classes, gadgets and images should be treated as special Libraries. So you need to open them with the OpenLibrary() function and
close them with the CloseLibrary() function. They should be declared as pointers to type Library.
e.g.
struct Library *WindowBase, *LayoutBase, *LabelBase;

WindowBase = OpenLibrary("window.class", 44);
LayoutBase = OpenLibrary("gadgets/layout.gadget", 44);
LabelBase= OpenLibrary("images/label.image", 44);
When finished with a library, you should close the library. It is good practice to test the library value before trying to close it.
 e.g.
if (WindowBase) CloseLibrary(WindowBase);
if (LayoutBase) CloseLibrary(LayoutBase);
if (LabelBase) CloseLibrary(LabelBase);

In AmigaOS 4, gadgets and images are now called Classes. They are an extended versions of Libraries with an extra Class field
e.g.
struct ClassLibrary *LayoutBase;
Class *LayoutClass;
LayoutBase = IIntuition->OpenClass("layout.gadget", 52, &LayoutClass); IIntuition->CloseClass(LayoutBase);

Reaction Window