In binding wxWidgets to Erlang, it is necessary to decide how to render its object-oriented structure and event-handling mechanism within Erlang so that it fits as closely as possible with the design principles underlying the language. This section explains the top-level correspondences, with more specific details coming in subsequent sections.
The wxErlang documentation contains an overview page together with an EDoc page for each module, which gives type information on each function as well as linking into the corresponding pages of the wxWidgets online documentation.
In the wxErlang binding, each class is represented by a module and each object by an object reference. For example, the wxErlang function call in:
File = wxMenu:new(),
constructs a new
wxMenu object and
assigns a reference to this object to the
File variable, with the same effect as the
call to the constructor in the C++ fragment:
wxMenu *File = new wxMenu;
To call methods on the object, as in this C++ example:
wxErlang provides a three-argument
append function, where
the first argument to
append is the
The pattern of wxErlang functions taking an extra “this” or “self”
value as the first argument is used throughout the
binding. In a similar way, the constructors for a class are replaced by
new functions of the same arity. Some wxWidgets methods take optional arguments; ...