RE: [gtk-list] Window creation



On Thursday, November 26, 1998 12:23 PM, Gerald Kuehne 
[SMTP:kuehne@informatik.uni-mannheim.de] wrote:
>
> Hi,
>
> I checked the documentation but I could not find something appropriate.
> I want to display an RGB image with gtk/gdk. Here are some snippets from
> the code:
>
>   GtkWidget* window;
>   GtkWidget* drawing_area;
>
>   /* create window and drawing area */
>   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
>   drawing_area = gtk_drawing_area_new ();
>   gtk_drawing_area_size (GTK_DRAWING_AREA (drawing_area), 200, 200);
>   ...
>
>   GdkVisual* visual = gdk_visual_get_best();
>
>   /* create image structure with "best" visual */
>   image = gdk_image_new(GDK_IMAGE_FASTEST, visual, 200, 200);
>
>   gdk_draw_image (window->window,
>                   window->style->fg_gc[GTK_WIDGET_STATE (window)],
>                   image, 0, 0, 0, 0, 200, 200);
>
> Now my problem: gtk_window_new takes the depth of the root window (8 bit
> in my case) gdk_visual_get_best returns 24 bit (TrueColor).
>
> How can I create a window widget using the visual returned by
> gdk_visual_get_best?
>
> Thanks,
> Gerald
>

I believe there is a function gtk_push_visual(). I never used it, but I 
think the code would look this:

GdkVisual *visal = gdk_visual_get_best ();
gtk_push_visual (visual);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_pop_visual ();

/* Do the rest of the stuff */


Again, I've never done this, but the simple reasoning suggests it should 
work this way. Please, someone with a clue, correct me if I'm wrong. I'm 
very interested in finding the correct sollution myself.

-Martynas








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