Scrolling problem



Hello,

I am building a widget used to draw curves using Gdk under WinXp.

It works fine but I have a problem with the scroll bar.

When I move the scroll bar cursor, the widget is not immediately redrawn
and some bad lines appear before the good redraw (old lines with an
offset corresponding with the scroll bar cursor move). This is an
example : 

      before moving                               during move
After moving
 ___________________________               ___________________________
___________________________ 
|                           |             |                           |
|                           |
|       .                   |             |       .                   |
|            .              |
|       |                   |             |         |                 |
|            |              |
|       \                   |             |          \                |
|            \              |
|        \                  |             |            \              |
|             \             |
|         \                 |             |              \            |
|              \            |
----------------------------              ----------------------------
----------------------------

The lines moves with before redraw.



The main of my application is something like that :

void AppCreate(void)
{
        ...
        pScroll = gtk_scrolled_window_new(NULL, NULL);
        gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(pScroll),
GTK_CORNER_TOP_LEFT);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(pScroll),
GTK_POLICY_ALWAYS, GTK_POLICY_ALWAYS);
        
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(pScroll),
GTK_SHADOW_IN);

        pArea->pPlot = mywidget_new();
        gtk_container_add(GTK_CONTAINER(pScroll), pArea->pPlot);
        ...
        gtk_widget_show_all(pApp->pNotebook);
}

I think that all is correct at this level.

To draw curves (the maximum is 4000 points), I use gdk_draw_segments()
and gdk_draw_arc().

But when there is a low number of points (about 100), all works without
a strange behavior and when I draw 4000 points, the strange behaviour
appears.

In the scroll bar management callback ("value_changed" signal), I have
the following code :

{
  mywidget* pPlot = (mywidget*) (data);
  gdouble value;
  gint dx;

  value = pH->value;
  dx = (gint)(value - pPlot->Range.MinX);
  pPlot->Range.MinX = value;

  if (GTK_WIDGET_DRAWABLE (pPlot))
    {
        GdkRectangle Rect = pPlot->widget.allocation;

        Rect.x = 0;
        Rect.y = 0;

        gdk_window_invalidate_rect(pPlot->widget.window, &Rect, FALSE);
      gdk_window_scroll (pPlot->widget.window, dx, 0);
    }
}

I use the gdk_window_invalidate_rect() function to be sure that the
widget is redrawn.

If it is not clear, I can explain better this problem.

Thank you for any response,

Cyril





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