Re: [gtk-list] Re: Why is system visual == DefaultVisual?



>  I've run into this on Suns when getting a drawing area widget and end
>  up with an 8 bit visual and want a 24 bit visual.
>  
>  Is the following ok (as long as I do it before the widget is realized)?
>  
>  GdkVisual *vis_24 = gdk_visual_get_best_with_depth(24);
>  if (vis_24) {
>      gtk_widget_set_visual(GTK_WIDGET(widget_), vis_24);
>  }

In general you don't want to do this, since it won't work for machines
without 24-bit visuals.  

What you usually care about is just a "thin" visual for most of your
app and a "fat" visual for the widgets that require high image
quality.  Assuming you will be painting to these widgets with
something like GdkRGB, it is better to do

	/* Make sure GdkRGB is initialized */
	gdk_rgb_init ();

	/* Switch to a fat visual */
	gtk_widget_push_visual (gdk_rgb_get_visual ()):
	gtk_widget_push_colormap (gdk_rgb_get_cmap ());

	da = gtk_drawing_area_new ();

	/* Go back to the default visual */
	gtk_widget_pop_colormap ();
	gtk_widget_pop_visual ();

Good luck,

  Federico



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