[gtkmm] problem using Rulers and Statusbar



I have some problems using Gtk::Statusbar and Gtk::VRuler and
Gtk::HRuler.
I've connected Gtk::DrawingArea::signal_motion_notify_event() with handlers:
(class Stat_bar: public Gtk::Statusbar)
bool Stat_bar::refresh(GdkEventMotion* motion_event)
{
     std::stringstream stream;
     stream<<" x: "<<event->x<<" y: "<<event->y;
     int id = push(stream.str(),0);
     return false;
}

(class H_Ruler: public Gtk:: HRuler)
bool H_Ruler::refresh(GdkEventMotion* event)
{
     if(event) property_position().set_value(event->x);
     return false;
}

It works, but too slow. CPU is loaded on 90-100% when I'm
moving mouse pointer. I thought that I did something wrong connecting
signal with handlers, but I've got same results with example rulers.cc.
Is there any way to do this handling properly?
I've also tried this:
...
conn=Glib::signal_timeout().connect(
   SigC::slot(Stat_bar_obj, &Stat_bar::refresh_on_timeout ), 20, Glib::PRIORITY_LOW);
...
bool Stat_bar::refresh(GdkEventMotion* motion_event)
{
    x=event->x; y=event->y;
    flag=true;
    return false;
}
bool Stat_bar::refresh_on_timeout()
{
    if(flag)
    {
     std::stringstream stream;
     stream<<" x: "<<x<<" y: "<<y;
     int id = push(stream.str(),0);
     flag=false;
    }   
    return true;
}

It works, but not very good.

I would highly appreciate any help.
-- 
Best regards,
 Denis                          mailto:disya21 yandex ru




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