Skip to content

User Guide : wxRuby Modules

Martin Corino edited this page Mar 19, 2024 · 2 revisions
     About      HowTo      FAQ      Reference documentation

Introduction

Previous wxRuby implementations provided a single toplevel module approach for the wxRuby API with a single loading option. Including require 'wx' in any application would load the entire wxRuby library and make all classes, module methods and constants available under the Wx toplevel module.

The wxRuby project however implements a more modular approach similar to wxWidgets itself which distributes implementations over various sub-modules. These sub-modules can be loaded separately to provide more control. The core module still provides the toplevel Wx namespace and all classes and constants declared in that namespace. All other modules add to that (and all require the core module).

Loading and Naming scopes

The old all-in-one approach in still supported with the wxRuby project. Using

require 'wx'

will load all wxRuby API modules and make all classes and constants available from the Wx toplevel module. This global naming scope approach does not extend to class or module methods (including dialog functors; see here for more information).

The new sub-module approach however allows for loading only part(s) of the wxRuby library like:

require 'wx/core' # load wxRuby core Wx module
require 'wx/grid' # load wxRuby Wx::GRID module - provides Grid control
require 'wx/rtc'  # load wxRuby Wx::RTC module - provides RichText control 

However, when loading the library like this scoping rules change by default. Specifically the constants and classes from the loaded sub-modules will not be accessible from the Wx scope anymore (like Wx::Grid) but must instead be explicitly scoped from the sub-module (like Wx::GRID::Grid).

It is possible to revert the 'global scope' resolution behaviour by setting the toplevel constant WX_GLOBAL_CONSTANTS to true before the require statements like:

WX_GLOBAL_CONSTANTS=true
require 'wx/core' # load wxRuby core Wx module
require 'wx/grid' # load wxRuby Wx::GRID module - provides Grid control
require 'wx/rtc'  # load wxRuby Wx::RTC module - provides RichText control 

The Modules

Currently the following modules have been implemented.

Core

The core wxRuby package providing the toplevel Wx module. This package includes basic classes like:

as well as most common window classes, control/widget classes, event classes, constant and enum definitions and global functions not part of any of the other packages.

AUI - Advanced User Interface controls and related classes

The wxRuby AUI package providing the Wx::AUI module. This package includes all classes, constants and enum definitions that are considered part of the wxWidgets AUI framework like:

GRID - Grid control and related classes

The wxRuby GRID package providing the Wx::GRID module. This package includes all classes, constants and enum definitions that are associated with the wxWidgets wxGrid control like:

HTML - Html framework classes

The wxRuby HTML package providing the Wx::HTML module. This package includes all classes, constants and enum definitions that are considered part of the wxWidgets Html framework like:

PG - PropertyGrid control and related classes

The wxRuby PG package providing the Wx::PG module. This package includes all classes, constants and enum definitions that are associated with the wxWidgets wxPropertyGrid control like:

PRT - Printing framework classes

The wxRuby PRT package providing the Wx::PRT module. This package includes all classes, constants and enum definitions that are considered part of the wxWidgets Printing framework like:

RBN - Ribbon framework classes

The wxRuby RBN package providing the Wx::RBN module. This package includes all classes, constants and enum definitions that are considered part of the wxWidgets Ribbon framework like:

RTC - RichText control and related classes

The wxRuby RTC package providing the Wx::RTC module. This package includes all classes, constants and enum definitions that are associated with the wxWidgets wxRichTextCtrl control like:

STC - StyledText control and related classes

The wxRuby STC package providing the Wx::STC module. This package includes all classes, constants and enum definitions that are associated with the wxWidgets wxStyledTextCtrl control (Scintilla integration) like:

Feature dependencies

Availability of wxRuby packages is controlled by the wxWidget feature switches. The default build options will include all platform supported features but in case of building wxRuby for customized wxWidgets builds the wxRuby build procedures will take the wxWidgets settings into account.

If for instance wxWidgets was built without Html support (using the configure --disable-html switch) the wxRuby HTML package will not be available as well. This behavior is controlled by the wxUSE_xxx macros that wxRuby extracts from the wxWidgets wx/setup.h file.

Clone this wiki locally