24.05.2014 Views

AIX Version 4.3 Differences Guide

AIX Version 4.3 Differences Guide

AIX Version 4.3 Differences Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

hierarchical relationship between these objects or any particular implementation<br />

of the trait.<br />

For example, consider the I am a navigator trait. This trait characterizes the fact that<br />

an object can set a value between a minimum and a maximum limit, regardless of<br />

the particular method used to set the value or the particular look and feel. A<br />

navigator can be implemented by a scroll bar, a thermometer-like control, or even<br />

a choice in the list of all possible values. The navigator provides the abstraction<br />

that guarantees that any object carrying this trait can be used to navigate<br />

arbitrarily between two values.<br />

The I am a navigator trait implements methods that make it possible for clients of<br />

the object carrying the trait to set and get the min/max/current value<br />

independently of the implementation.<br />

In Motif 2.1, both the XmScrollBar (an XmPrimitive subclass) widget and the<br />

XmSpinBox (an XmManager subclass) hold the I am a navigator trait, and they<br />

can both inherit, or specialize, the methods of that trait.<br />

Therefore, the traits mechanism makes it possible to implement a form of multiple<br />

inheritance on top of the Xt object oriented framework, which only supports single<br />

inheritance. In the Motif 2.1 model, traits are seen as light abstract classes,<br />

sometimes called mix-ins.<br />

Traits also make it possible to implement a form of polymorphism on the various<br />

widgets. For example, if a trait has a setvalue method, it can be used to set<br />

values of resources that actually have a different name. For example, a<br />

trait::setvalue() replaces XtSetValues() on multiple XmNresource names.<br />

A side effect of traits is the potential reduction of code size in applications. In<br />

many cases, a Motif Manager widget would check the class of its children. Doing<br />

so requires access to the class pointer and at link time. Linking the class pointer<br />

global variable usually links chained modules in the application. Because those<br />

tests are replaced in the manager code with checking the children’s traits, the<br />

spaghetti effect is eliminated.<br />

Traits also augment code re-use inside Motif. A widget writer can simply decide to<br />

inherit a trait from another widget. It then inherits the class methods implemented<br />

by the OSF engineers at no cost.<br />

8.3.3.2 Uniform Transfer Model (UTM)<br />

OSF/Motif 1.2 provides the application programmer and widget writer with a<br />

number of different mechanisms to interchange data between applications. There<br />

are four forms of data transfer supported within Motif:<br />

• Primary transfer. When the user clicks on pointer button BTransfer, the data<br />

currently selected (possibly in another application) is immediately transferred<br />

at the pointer location.<br />

• The clipboard. This is probably the most widely-known mechanism. When the<br />

user activates the cut key (or the cut command into the Edit menu) the<br />

selected data is cut into the clipboard. Activating the paste key inserts the data<br />

at the current location of the destination cursor.<br />

• Drag and drop. The visual metaphor for data exchange. The user can select<br />

data, drag it over the screen and drop it onto a recipient.<br />

Graphical Environment Enhancements 219

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!