flickering problem



Dear all,

I am currently writing a widget for displaying 2-dimensional matrices.
As they can be quite big (say, thousands of columns and tens of rows), I
do not want to create a gtkScrolledWindow containing a gtkTable with one
gtkEntry per element in the matrix. The solution I use currently is to
put a gtkTable into a gtkViewport that I control myself and I allocate
into the gtkTable just enough gtkEntries for the viewport to be
displayed properly. Upon moving scrollbars, say to the right, I move the
viewport accordingly and when the leftmost column of the gtkTable
becomes invisible, I copy the contents of each gtkEntry into its left
neighbor, so that the leftmost column of the gtkTable becomes again the
first one visible, and I change the adjustments of the viewport so that
the visible area is that which shall be visible.

The process works fine except that it is flickering. Reading the code of
gtkentry, it seems to me that calls to gtk_entry_set_text (which I used
for the copies) will allways result in calls to gtk_entry_recompute,
which update the screen and induce the flickering. Is there a simple way
to avoid this flickering without having to copy the gtkentry.c code and
to modify it (which I do not want to do for compatibility reasons)?

Currently the solution I try is to put the viewport as the first page of
a gtkNotebook, and a custom widget containing a gdkPixmap as the second
page of the notebook. Before copying the contents of the entries, I try
to copy the window's image of the viewport into the gdkPixmap, set the
current page of the notebook as the second one, perform the copies, and
change again the current page of the notebook as the first one. Using
this method, some tables do not flicker while others still do. The code
I use to copy the window's image into the gdkPixmap is essentially
similar to the one below (I translate it roughly from my gtkmm's code):

GtkAllocation *allocation = viewport->allocation;
GdkPixmap* pixmap = gdk_pixmap_new (viewport->window,
                                    allocation->width,
                                    allocation->height,
                                    -1);
gdk_draw_drawable (pixmap, gc, viewport->window,
                   allocation->x,
                   allocation->y,
                   0,
                   0,
                   allocation->width,
                   allocation->height);

Is there something wrong with this piece of code ?

Thanks for any advice.
Ch.

-- 
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
_/ Christophe GONZALES              _/                                _/
_/ LIP6 - DESIR department          _/ Computer science is not more   _/
_/ Decision Theory team, office 512 _/ about computers than astronomy _/
_/ 104 avenue du président Kennedy  _/      is about telescopes.      _/
_/ F-75016 Paris                    _/                                _/
_/ tel: (+33) 1-44-27-88-11         _/           Dijkstra             _/
_/ gpg: http://www-desir.lip6.fr/~gonzales/christophe.asc             _/
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/



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