Gnome Canvas




Hello Everybody,

Sorry for the naive question: does anybody know how to
set the background color in a gnome canvas widget?

Also, does anybody know why whenever I draw an item
on a canvas it always comes up black, when I tell
it draw in different colors with "fill_color_rgba"?

#include <gnome.h>
int main(int argc, char *argv[])
{
        GtkWidget * window;
        GtkWidget * canvas;

        gnome_init("canvas-test", "0.0", argc, argv);
        gdk_rgb_init();

        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_signal_connect(
                        GTK_OBJECT(window),
                        "delete_event",
                        GTK_SIGNAL_FUNC(gtk_main_quit),
                        NULL);
	
        gtk_widget_push_visual(gdk_rgb_get_visual());
        gtk_widget_push_colormap(gdk_rgb_get_cmap());
        canvas = gnome_canvas_new();
        gtk_widget_pop_colormap();
        gtk_widget_pop_visual();

        gnome_canvas_set_scroll_region(GNOME_CANVAS(canvas), 0, 0, 200, 100);
        gnome_canvas_item_new(
                        gnome_canvas_root(GNOME_CANVAS(canvas)),
                        gnome_canvas_rect_get_type(),
                        "x1", 5.0,
                        "y1", 5.0,
                        "x2", 100.0,
                        "y2", 50.0,
                        "fill_color_rgba", 0xFF0000FF,
                        "outline_color", "blue",
                        "width_units", 2.0,
                        NULL);

        gtk_container_add(GTK_CONTAINER(window), canvas);
        gtk_window_set_default_size(GTK_WINDOW(window), 200, 100);
        gtk_widget_show_all(window);
        gtk_main();
        return 0;
}

This code should draw a rectangle with a blue border, and a
fill color of red.  But it always comes up with a black fill
color! (no matter what I specify as a fill color)  It's driving
me crazy.  If I replace "fill_color_rgba" with "fill_color",
"0xFF0000" it works fine...  

I'm using gnome-libs-1.0.10-2 and gnome-core-1.0.7-2 and gtk+-1.2.3
which admittedly are a little crufty, but I haven't had
a chance to update.

Any thoughts?  

-Matt



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]