GTK+ / Gnome Application Development | |||
---|---|---|---|
<<< Previous | Home | Next >>> |
This chapter describes the GnomeCanvas widget, and the standard canvas items that come with Gnome. The following chapter discusses in more detail how to write a custom canvas item.
The canvas widget is a powerful and extensible object-oriented display engine, useful in a wide variety of Gnome applications. The widget itself is simply a blank area; you can place GnomeCanvasItems on it. A GnomeCanvasItem is a GtkObject representing some element of the display, such as an image, a rectangle, an ellipse, or some text. You can refer to this architecture as structured graphics; the canvas lets you deal with graphics in terms of items, rather than an undifferentiated grid of pixels. Since a GnomeCanvasItem is a GtkObject, you can create your own subclasses to supplement those that come with Gnome. This gives you quite a bit of flexibility. Using custom canvas items, the canvas can render almost anything. At the same time, you can use stock canvas items to save time and effort. The canvas puts you in control.
GnomeCanvas has two modes, representing a quality/speed tradeoff. In "GDK" mode, canvas items render directly to a GdkPixmap buffer using the GDK drawing primitives. The canvas copies the buffer to the screen once all items are rendered. In antialiased or "AA" mode, the canvas items write RGB pixels to a vector of bytes; after all the items have drawn on the RGB buffer, the canvas copies it to the screen. This RGB buffer mode is called "antialiased" mode because all the standard canvas items draw to the RGB buffer using the high-quality antialiased routines in libart_lgpl. This results in smooth lines and very high display quality, with some cost in speed.