X Window system graphics library compatibility
The core Common Graphics subsystem is based on the X Window system's library of graphics operations (Xlib) and provides the same functions as the Xlib C calls. The Common Graphics Image Support classes are not based on Xlib.
This section will be of interest to developers familiar with Xlib graphic operations, as it describes the two main strategies that were used to convert the standard Xlib C calls to Smalltalk classes and methods. By understanding these two principles, experienced Xlib software engineers should be able to use the Common Graphics subsystem relatively quickly.
First, objects have been created for all C data types. These data types include items such as Display, Drawable, GC, and Font. These objects were named by prefixing the Xlib data type name with Cg and removing any leading X. For example, the Xlib type Display becomes the Smalltalk class CgDisplay.
Second, each Xlib C function has been converted to a corresponding Smalltalk method. To understand this conversion, consider the following standard Xlib function XDrawRectangle:
XDrawRectangle(display, drawable, gc, x, y, width, height);
In the Common Graphics subsystem, this function has been converted to the following method:
CgDrawable>>#drawRectangle: gc x: x y: y width: width height: height.
In translating C Xlib functions to Smalltalk, two rules have been applied:
•If the first parameter of the C function is a display and the second parameter is a graphics resource, such as a drawable or a graphics context, the second parameter indicates the receiver of the equivalent Smalltalk message. Graphics resources such as a CgDrawable know the display on which they are located, so it is not necessary to specify the display in the Smalltalk equivalent. If the second parameter is not a graphics resource, the first parameter is used to indicate the receiver.
•The Smalltalk message selector is formed using the C function name, with the preceding 'X' removed, and the remaining parameter names.
Last modified date: 01/29/2015