Core Common Graphics class hierarchy
The core Common Graphics subsystem contains several classes. The most frequently used classes are presented first. Frequently used classes are covered in different subsections of this chapter, and are listed in
Table 14.
Table 14. Frequently used classes
| | | |
CgCursor* | A cursor | Varies by platform | |
CgDisplay | A connection to the graphics server | CgDisplay default | |
CgDrawable* | A place to draw (either a window or a pixmap) | CgScreen default rootWindow or CgWindow default | |
CgFont* | A font resource | CgDisplay default defaultFont or CgFont default | |
CgFontStruct | A font structure | CgDisplay default defaultFontStruct or CgFontStruct default | |
CgGC (graphics context) | A table of graphic display attributes such as line width, line style | CgScreen default defaultGC or CgGC default | |
CgGCValues | A data structure used for configuring a CgGC | | |
CgPixmap* | An off-screen rectangular array of pixels (monochrome or color) | None | |
CgWindow* | A window | CgScreen default rootWindow or CgWindow default | |
CgScreen | A physical screen device | CgScreen default | |
CgTextItem | A text data structure | None | |
Note:
*Denotes a class that is a subclass of the abstract class CgId.
The following figure illustrates the most frequently used core Common Graphics classes.
A CgDisplay object represents a connection to a graphics server: the link between your application and the server. Your application can control several display objects, each one representing a link between your application and a different graphics server. You can obtain the default instance using CgDisplay default.
A CgScreen object represents a single hardware output device. It contains information about the device including its dimensions, its color capabilities and its default graphics context. You can obtain the default screen of the default display using CgDisplay default defaultScreen or CgScreen default.
A CgDrawable object represents an area that can be drawn upon--either an instance of CgWindow or CgPixmap. All drawing operations are performed on a drawable. Conceptually, drawables are located in the graphics server. Drawing commands are sent from the application to the graphics server, which then performs the required operations on the drawable. Drawing operations are performed with respect to the origin (the point defined by 0@0), which is in the upper left corner of the drawable.
A CgWindow object represents an area of the screen, usually the visible area of a user interface widget. Widgets are created by the application using the Common Widgets subsystem (see the "Common Widgets" chapter). Each widget has a corresponding window, which is obtained by sending the window message to the widget. In addition to the windows of widgets, each screen has a root window covering the entire area of the screen. All other windows are layered on top of the root window. You can obtain the root window of the default screen using CgWindow default. In general, VA Smalltalk applications use windows provided by the Common Widgets subsystem. The root window is useful for testing purposes and is used throughout this chapter to show examples.
Note:
It is important to note that
CgWindow forms a link between the Common Graphics and Common Widgets subsystems of VA Smalltalk. A
CwWidget cannot be drawn on directly. However, every
CwWidget has a corresponding
CgWindow that can be used for drawing. That is,
CgWindows are also
CgDrawables. This is obtained by sending the
window message to the
CwWidget. For further information, see
"Drawing area widgets" in the Common Widgets chapter.
A
CgPixmap object represents an off-screen monochrome or color bitmapped image created by your application. The format of pixmap memory is device dependent and is not directly accessible to the application. Pixmaps are used to specify stipple and tile pattern drawing attributes. They are also often used to cache the results of drawing for high speed display. A pixmap is displayed by copying a rectangular area of its contents to a window. Your application is responsible for creating, manipulating, and freeing pixmap objects. These operations are described in
"Using pixmaps".
A CgGC object (also called a GC or Graphics Context) is a data type that contains drawing attribute information. The GC manages attributes such as the current foreground color, line width, and line style. Requests to change the value of an attribute are made to the GC. Your application is responsible for creating, manipulating, and freeing GC objects. In general, applications will create their own GCs. However, each screen has a default GC that is useful for testing purposes. You can obtain the default GC of the default screen using CgGC default.
Each of these objects plays an important role in the Common Graphics subsystem.
Last modified date: 05/12/2020