HUGE drawing areas and scrolled windows (odd/bug report?)




Hi All, 

Thanks Owen for pointing me at the proper way of setting the values of the 
scrollbars in scrolled windows.  

	Unfortunately I've come across some odd behavior when you have
a scrolled_window widget which contains a HUGE drawing area (44000x34000).
Attached is a program which shows this odd behavior.   Basically if 
you scroll to the far right (or far bottom) you will notice three things:

	1) At some point the x or y coordinates will go negative (around
	   32768 :-( (press the mouse button in the canvas to see the coords) 

	2) The canvas will go black (I'm not doing *any* drawing in my test
	   program) (and this is when the events stop)

	3) Events will stop happening (no more expose or button press).


Please let me know if I've done something really stupid.  I would debug
gtk if I knew where to look.  I'm not sure if this is a problem with
the drawing area widget or the scrolled window (or viewport) or the signal
handling in gtk? (I'm using gtk+ 0.99.9 under Linux)

Thanks for any info!


								-Ales


Build with: gcc -o testd test.c `gtk-config --cflags` `gtk-config --libs`

----- Cut here for test.c -------

#include <stdio.h>

#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>

GtkWidget *main_window;

GtkWidget *main_box;
GtkWidget *scrolled_window;
GtkWidget *drawing_area;

int count=0;

gint
x_event_expose(GtkWidget *widget, GdkEventExpose *event, char *none)
{                 
	printf("expose %d\n", count++);
}

gint
x_event_button_pressed(GtkWidget *widget, GdkEventButton *event, char *none) 
{
	printf("pressed\n");
	printf("coords: %f %f\n", event->x, event->y);
}

int main(int argc, char *argv[])
{
	GtkWidget *drawbox2; 
	GtkWidget *drawbox; 

	/* allocate a HUGE canvas */
	int max_width = 2200*20;
        int max_height = 1700*20;

        gtk_init(&argc, &argv);

        main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

  	gtk_widget_set_uposition (main_window, 0, 0);

	gtk_signal_connect (GTK_OBJECT (main_window), "destroy",
                      GTK_SIGNAL_FUNC(gtk_main_quit),
                      NULL);

	/* Containers first */        
        main_box = gtk_vbox_new(FALSE, 1);
        gtk_container_border_width(GTK_CONTAINER(main_box), 0);
        gtk_container_add(GTK_CONTAINER(main_window), main_box);
        gtk_widget_show(main_box);

        drawbox = gtk_hbox_new(FALSE, 0);
        gtk_container_border_width(GTK_CONTAINER(drawbox), 0);
        gtk_container_add(GTK_CONTAINER(main_box), drawbox);
        gtk_widget_show(drawbox);

	scrolled_window = gtk_scrolled_window_new (NULL, NULL);
	gtk_container_border_width (GTK_CONTAINER (scrolled_window), 0);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
                                      GTK_POLICY_ALWAYS,
                                      GTK_POLICY_ALWAYS);
        gtk_widget_set_usize(GTK_WIDGET(scrolled_window), 580, 480);
        gtk_box_pack_start (GTK_BOX (drawbox), scrolled_window, TRUE, TRUE, 0);
      	gtk_widget_show (scrolled_window);

        drawbox2 = gtk_hbox_new(FALSE, 0);
        gtk_container_border_width(GTK_CONTAINER(drawbox2), 0);
        gtk_container_add(GTK_CONTAINER(scrolled_window), drawbox2);
        gtk_widget_show(drawbox2);
 
	drawing_area = gtk_drawing_area_new (); 
 	gtk_drawing_area_size (GTK_DRAWING_AREA (drawing_area), 
		max_width, max_height);

        gtk_box_pack_start (GTK_BOX (drawbox2), drawing_area, TRUE, TRUE, 0);
        gtk_widget_show (drawing_area); 

	gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK | 
                                             GDK_BUTTON_PRESS_MASK ) ;
                                             
	gtk_signal_connect (GTK_OBJECT (drawing_area), "expose_event",
                          GTK_SIGNAL_FUNC (x_event_expose), 0);    
	gtk_signal_connect (GTK_OBJECT (drawing_area), "button_press_event",
                           (GtkSignalFunc) x_event_button_pressed, NULL);

        gtk_widget_show(main_window);

	gtk_main();
}



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