| Online Eiffel Documentation

EiffelStudio

# Interface

This document describes the use of graphical widgets to display and manipulate preferences.

The preference library contains a cluster called interface. This cluster provides some basic classes which can be used to graphically display and manipulate the PREFERENCE types used by the library. There are various widget classes which correspond to particular types of preferences and can be used to view and change the values of an associated preference. The table below illustrates which widgets are used to display each of the known preference types:

Preference Type | Associated Widget
INTEGER_PREFERENCE | STRING_PREFERENCE_WIDGET
BOOLEAN_PREFERENCE | BOOLEAN_PREFERENCE_WIDGET
STRING_PREFERENCE | STRING_PREFERENCE_WIDGET
ARRAY_PREFERENCE | STRING_PREFERENCE_WIDGET or CHOICE_PREFERENCE_WIDGET
COLOR_PREFERENCE | COLOR_PREFERENCE_WIDGET
FONT_PREFERENCE | FONT_PREFERENCE_WIDGET

All of these widgets inherit the abstract base class PREFERENCE_WIDGET and implement the required deferred features therein. Each implementation implements handling of an EV_GRID_ITEM widget from EiffelVision2 for use in the EV_GRID control, which allows for viewing and editing of the underlying preference value. For example, BOOLEAN_PREFERENCE_WIDGET uses an EV_GRID_COMBO_ITEM to display the 'True' and 'False' properties of a BOOLEAN_PREFERENCE. When the widget is loaded it displays the current value of the associated preference in the combo box. When the user changes the combo box value the preference value is changed also, and optionally saved.

Using these supplied widgets in your interface is simply a matter of creating the object and adding the change_item_widget to an instance of EV_GRID. By default the library provides such a view, in the form of PREFERENCES_WINDOW, which is a control that contains an EV_GRID and has all the necessary logic to handle graphical manipulation of the prefernce types provided in the library. This is an EV_TITLED_WINDOW with a navigable tree for finding groups of related preferences (i.e. managers), and a grid for displaying each preference. It is a useful, general purpose interface for preference manipulation. As with preferences themselves you may create your own custom view if this dialog is not sufficient for your needs, and can use the code therein as a template for your owm code. Below is an image of the supplied window as it appears in the EiffelStudio preferences environment.

For an example of creating custom widget views for individual preferences, or a custom view for all preferences, please refer to the example in this documentation.