| classes {RGtk2.10} | R Documentation |
Highly experimental support for constructing new GObject
classes entirely from with R.
gClass(name, parent = "GObject", class_def = NULL) parentHandler(method, obj = NULL, ...) assignProp(obj, pspec, value) getProp(obj, pspec) registerVirtuals(virtuals) unregisterVirtuals(virtuals)
name |
The name of the new class |
parent |
The name of the parent class |
class_def |
A list that defines the new class - please see the details section |
method |
The name of the method to invoke in the parent |
obj |
A GObject |
... |
The additional arguments to the parent method |
pspec |
A GParamSpec describing the property |
value |
The value to set on the property |
virtuals |
An environment containing lists where each list contains the names of the virtual methods for the class matching the name of the list |
.
The bulk of the class definition (everything except the name and the parent)
is contained in the class_def parameter. This includes:
GObject class.
Functions overriding methods in the same class are grouped together in a list and
are named according to the virtual they override. Each list is a member of the
class_def list and bears the name of the corresponding class.GSignalFlags enumeration. The list of signal definitions
has the name .signals in the class_def list.GParamSpec, as created by gParamSpec.
The list is named .props in the class_def list. The property values
are stored in a private environment. To override that behavior or to be notified
(first) upon property changes, simply override the set_property and
get_property virtuals in the GObject class. To override
the implementation of properties defined by an ancestor class, specify their
names in a separate vector named .prop_overrides. If you override
the setting or getting of properties, you can use assignProp or
getProp to conveniently directly assign or get the
value of a property to or from the low-level data structure, respectively.
These functions differ from the normal property accessor mechanism in that
they bypass the property system, thus avoiding recursion. They should
only be used when overriding property handling..initialize (in class_def) will be called with the instance
as the only argument..public,
.protected, and .private keys, respectively. The encapsulation
works much the same as Java. Any protected and public functions may be
overriden in a class derived from the defining class. All public fields
are immutable. All function bindings are locked except for private ones. This
means private functions can be replaced.
The above may seem complicated, and it is. Please see the alphaSliderClass
for an example. Also note that the local function
is convenient for defining static namespaces on the fly. For calling
parent virtuals, use parentHandler.
assignProp and getProp are low-level functions; they should
not be used in place of the conventional GObject property
mechanism, except in the case mentioned above.
registerVirtuals and unregisterVirtuals are meant for use by
packages that bind C GObject classes to R using the RGtk2 system. An example
of such a package is rggobi.
For gClass, the GType of the new class.
For getProp, the value of the property.
This functionality is not for casual users. If you don't know what you're doing you will break things. Otherwise, have fun.
Michael Lawrence