Re: queue_draw_area query..



On 04/21/01 Paul Schulz wrote:
It runs and will update the screen on an expose events,
(resize, and moving a window in front..)
but doesn't update the display if I draw on the backing pixmap
(with update_chart).
[...]
sub expose_chart {
  my ($widget, $event ) = @_;

  my ( $event_area );

  $event_area = ${$event}{'area'};

I suggest using:
        my @event_area = @{$event->{'area'}};
and then reference the items as:
        $event_area[0], etc
to reduce line noise.


  $widget->window->draw_pixmap(
    $widget->style->fg_gc('normal'),
    $pixmapChart,
    ${$event_area}[0],
    ${$event_area}[1],
    ${$event_area}[0],
    ${$event_area}[1],
    ${$event_area}[2],
    ${$event_area}[3]
    );

use Data::Dumper; print Dumper(\ _);

0;
}

sub update_chart {
    my( $widget, $pos, $traffic ) = @_;
    
    my $blue_gc = new Gtk::Gdk::GC ( $widget->window );   

    $pixmapChart->draw_line(
                          $blue_gc,
                          $margin+$pos,
                          $height-$margin,
                          $margin+$pos,
                          $height-$margin-$traffic
                          );
    print "$pos - $traffic\n";

    $widget->queue_draw_area ($margin+$pos, 
                            $height-$margin,
                            $margin+$pos,
                            $height-$margin-$traffic);    

You are requesting the update of the wrong area: in Gtk/X coordinates
start from 0 at the top-left corner. Also, the prototype is

        $widget->queue_draw_area($x, $y, $width, $height);

Changing the code to read:

        $widget->queue_draw_area ($margin+$pos, 0, 1, $height);

makes it work.

$dareaChart->show;
$dareaChart->realize;

No need to realize here.
 
$b = new Gtk::Button("Quit");
$b->signal_connect('clicked', sub {Gtk->exit(0)});
$vb->add($b);

$w->show_all;

If you use show_all() on the toplevel widget it's not necessary to 
show the child widgets one at a time earlier...

lupus

-- 
-----------------------------------------------------------------
lupus debian org                                     debian/rules
lupus ximian com                             Monkeys do it better




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