The first decision you have to make is whether to use the
canvas in GDK mode or antialiased mode. When you create a
canvas widget, you must specify the mode you want; there
is no way to change it later.
gnome_canvas_new() creates a GDK canvas. gnome_canvas_new_aa() creates an
antialiased canvas. These are shown in Figure 5.
Sometimes it matters which visual and colormap the canvas
will use. In particular:
-
In GDK mode, if you want to use the GnomeCanvasImage item to display
images, you must use Imlib's visual and colormap.
GnomeCanvasImage uses
Imlib to render images.
-
In antialiased mode, GDK's RGB buffer rendering
facilities (see the
section called RGB Buffers in the chapter
called GDK Basics) are used to copy the
RGB buffer to the screen. You must use the visual and
colormap from the GDK RGB module.
To create a widget with a non-default visual and
colormap,
gtk_widget_push_visual() and
gtk_widget_push_colormap() are used. Here is the
code to create a GDK canvas that supports the image item:
GtkWidget* canvas;
gtk_widget_push_visual(gdk_imlib_get_visual());
gtk_widget_push_colormap(gdk_imlib_get_colormap());
canvas = gnome_canvas_new();
gtk_widget_pop_visual();
gtk_widget_pop_colormap();
|
To create an antialiased canvas, do this:
GtkWidget* canvas;
gtk_widget_push_visual(gdk_rgb_get_visual());
gtk_widget_push_colormap(gdk_rgb_get_cmap());
canvas = gnome_canvas_new_aa();
gtk_widget_pop_colormap();
gtk_widget_pop_visual();
|