Re: [gtkmm] Re: automatic scrolling window (scrolledwindow)



On Thu, 13 Nov 2003, David Kinyanjui wrote:

> Anyhow, I'm still trying to find help on how to automatically
> make the scrollbars in a scrolledwindow (especially
> the vertical scrollbar), position itself such that the current
> focused widget (grabbing focus) is always visible at the bottom of the
> scrolled window.
> At this moment, I can only scroll  up and down by clicking the scrollbar.

I did something similar for a table widget I wrote for a sequencer.
I wrote a function scrollToRect, like this:

void GridWrapper::scrollToRect(int x1, int y1, int x2, int y2) {
  if (x1 < hAdj->get_value())
    hAdj->set_value(x1);
  else if (x2 > hAdj->get_value() + hAdj->get_page_size())
    hAdj->set_value(x2 - hAdj->get_page_size());
  if (y1 < vAdj->get_value())
    vAdj->set_value(y1);
  else if (y2 > vAdj->get_value() + vAdj->get_page_size())
    vAdj->set_value(y2 - vAdj->get_page_size());
}

I called this function every time the user selected a new cell, with
the boundaries of the cell as x1, y1, x2, y2. Maybe you could do
something like that, and use signal_focus_in_event in your widgets to
know when to call it?

If you want to see how I use this, the source is at
http://cvs.sourceforge.net/viewcvs.py/keso-project/keso/ (the
relevant files are gtkmm-gui/common/grid.[c|h]pp and
gtkmm-gui/common/gridwrapper.[c|h]pp.


--ll



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