Copyright (c) Hyperion Entertainment and contributors.

Difference between revisions of "ReAction"

From AmigaOS Documentation Wiki
Jump to navigation Jump to search
(Added the Class Opening and Closing section)
Line 12: Line 12:
   
 
; object-oriented
 
; object-oriented
: All GUI elements created via the toolkit are manipulated as ''objects'' of a certain ''class''. The class determines the look, function and general properties of the object; objects of the same class serve the same purpose and share the same properties.
+
: All GUI elements created via the toolkit are manipulated as ''objects'' of a certain ''class''. The class determines the look, function and general properties of the object; objects of the same class serve the same purpose and share the same properties. In a program, a GUI element (object) is an ''instance'' of a class, therefore object creation is often referred to as [[#Object Creation (Instantiation)|instantiation]].
   
 
; modular and extensible
 
; modular and extensible
Line 22: Line 22:
 
; BOOPSI-compatible
 
; BOOPSI-compatible
 
: Program GUIs created through ReAction can include other AmigaOS components based on BOOPSI, such as [[Datatypes_Library|datatypes]] or Intuition’s internal BOOPSI classes.
 
: Program GUIs created through ReAction can include other AmigaOS components based on BOOPSI, such as [[Datatypes_Library|datatypes]] or Intuition’s internal BOOPSI classes.
  +
  +
== Class Opening and Closing ==
  +
  +
Classes are, in fact, standard Amiga libraries. The data structure describing a BOOPSI class is called ClassLibrary. As you can see from the C-language definition below, the structure contains the standard ''struct Library'' plus some additional fields. This makes it possible to treat classes as normal libraries and, at the same time, support BOOPSI-specific features:
  +
  +
<syntaxhighlight>
  +
struct ClassLibrary
  +
{
  +
struct Library cl_Lib; /* Embedded library */
  +
UWORD cl_Pad; /* Align the structure */
  +
Class *cl_Class; /* Class pointer */
  +
};
  +
</syntaxhighlight>
  +
  +
Like other system libraries, classes must be opened before they are used. An exception to this rule are classes that are part of another component. For example, certain BOOPSI classes reside in Intuition so they can be accessed as soon as you open the Intuition Library. Similarly, in the ReAction toolkit, the Page Gadget class is part of the Layout Gadget binary; therefore, pages can be used once the Layout Gadget class becomes available.
  +
  +
In the past, BOOPSI classes were opened and closed just like you would open and close any other library, that is, through the Exec functions OpenLibrary() and CloseLibrary(). The practice has changed in AmigaOS 4 when Intuition received dedicated functions OpenClass() and CloseClass(). The opening call returns two variables: the ''class library base'' and the ''class pointer''. When closing the class, the library base is passed as parameter. The class pointer can (and should) be used for [[#Object Creation (Instantiation)|object instantiation]]; see below.
  +
  +
The following code snippet opens and closes the ReAction Window Class:
  +
  +
<syntaxhighlight>
  +
struct ClassLibrary *WindowBase; /* the class library base */
  +
Class *WindowClass; /* the class pointer */
  +
  +
WindowBase = IIntuition->OpenClass("window.class", 52, &WindowClass);
  +
  +
/.../
  +
  +
IIntuition->CloseClass(WindowBase);
  +
</syntaxhighlight>
  +
  +
== Object Creation (Instantiation) ==
  +
  +
   
 
''(to be continued)''
 
''(to be continued)''

Revision as of 09:39, 5 December 2012

Introduction

ReAction is a toolkit for GUI programming in AmigaOS. It is based on Intuition's BOOPSI, an object-oriented philosophy. Understanding the basic concepts of BOOPSI is an important prerequisite for working with ReAction so make sure you have studied the BOOPSI documentation linked above.

Note
There seems to be a certain degree of confusion as regards the relation between ReAction and BOOPSI. It must be understood that the two are not really interchangeable terms (although they are sometimes used in this way). ReAction is a BOOPSI toolkit so there is a part-whole relation between them. ReAction can’t exist without BOOPSI, but BOOPSI can perfectly exist without ReAction. BOOPSI is a general object-oriented programming framework while ReAction is a set of ready-made classes based on this framework.

Originally a third-party product, ReAction became part of the operating system in AmigaOS 3.5. The system, whose internal BOOPSI class set had been rather limited, received a comprehensive toolkit covering most GUI programming needs. Over the years ReAction has grown and matured, with many features added. It is now the recommended toolkit for GUI programming under AmigaOS.

Overview

ReAction is:

object-oriented
All GUI elements created via the toolkit are manipulated as objects of a certain class. The class determines the look, function and general properties of the object; objects of the same class serve the same purpose and share the same properties. In a program, a GUI element (object) is an instance of a class, therefore object creation is often referred to as instantiation.
modular and extensible
It is implemented as a set of modules (class libraries) that reside on disk. New classes can be written or derived (“subclassed”) from existing classes, thus adding new functionality to the toolkit.
layout-based
GUI elements provided by the toolkit are meant to be placed in a layout: a structure determining how objects are positioned, sized and grouped in the GUI. Objects governed by a layout are not programmed for specific positions or sizes; instead, these parameters are automatically decided by the layout according to the properties of the individual objects.
BOOPSI-compatible
Program GUIs created through ReAction can include other AmigaOS components based on BOOPSI, such as datatypes or Intuition’s internal BOOPSI classes.

Class Opening and Closing

Classes are, in fact, standard Amiga libraries. The data structure describing a BOOPSI class is called ClassLibrary. As you can see from the C-language definition below, the structure contains the standard struct Library plus some additional fields. This makes it possible to treat classes as normal libraries and, at the same time, support BOOPSI-specific features:

struct ClassLibrary
{
    struct Library  cl_Lib;   /* Embedded library */
    UWORD           cl_Pad;   /* Align the structure */
    Class          *cl_Class; /* Class pointer */
};

Like other system libraries, classes must be opened before they are used. An exception to this rule are classes that are part of another component. For example, certain BOOPSI classes reside in Intuition so they can be accessed as soon as you open the Intuition Library. Similarly, in the ReAction toolkit, the Page Gadget class is part of the Layout Gadget binary; therefore, pages can be used once the Layout Gadget class becomes available.

In the past, BOOPSI classes were opened and closed just like you would open and close any other library, that is, through the Exec functions OpenLibrary() and CloseLibrary(). The practice has changed in AmigaOS 4 when Intuition received dedicated functions OpenClass() and CloseClass(). The opening call returns two variables: the class library base and the class pointer. When closing the class, the library base is passed as parameter. The class pointer can (and should) be used for object instantiation; see below.

The following code snippet opens and closes the ReAction Window Class:

struct ClassLibrary *WindowBase; /* the class library base */
Class *WindowClass;              /* the class pointer */
 
WindowBase = IIntuition->OpenClass("window.class", 52, &WindowClass);
 
/.../
 
IIntuition->CloseClass(WindowBase);

Object Creation (Instantiation)

(to be continued)

Context and Input/Output

Describe how input.task is involved, etc.