Discussion:
ScrollTo() in wxTreeCtrl
(too old to reply)
Vadim Zeitlin
2009-05-07 08:47:51 UTC
Permalink
On Wed, 6 May 2009 08:14:27 -0700 (PDT) raananb <***@barzel.org> wrote:

r> With 'tree->ScrollTo(ItemX)', when the number of tree items following ItemX
r> is bigger than the number of lines in the display panel, ItemX is the first
r> visible item in Windows, and last in GTK.

I'm not sure to understand the problem exactly, would you have a patch to
the treectrl sample reproducing it?

r> Any way to always have it first?

I guess the answer lies in the sources of src/generic/treectlg.cpp but I
don't know more about it...

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
raananb
2009-05-08 09:53:04 UTC
Permalink
Windows version of ScrollTo(Item) (in src/msw/treectrl.cpp) has a very simple
strategy: Item is always displayed it at the top of the client area. The
root is not visible unless Item is root.

void wxTreeCtrl::ScrollTo(const wxTreeItemId& item)
{
if ( !TreeView_SelectSetFirstVisible(GetHwnd(), HITEM(item)) )
{
wxLogLastError(wxT("TreeView_SelectSetFirstVisible"));
}
}


In Linux ScrollTo(Item) (in src/generic/treectlg.cpp) has a different
strategy: the display show root as long as Item fits in the client area.
When Item is outside (below) the client area, the tree is scrolled to make
Item visible, and Item is displayed at the bottom of the client area. So
successive siblings sre displayed lower and lower until they become 'sticky'
at the bottom.

The functionalities of ScrollTo() are thus different between Windows and
Linux. Should they be made identical?
Post by Vadim Zeitlin
r> With 'tree->ScrollTo(ItemX)', when the number of tree items following
ItemX
r> is bigger than the number of lines in the display panel, ItemX is the
first
r> visible item in Windows, and last in GTK.
I'm not sure to understand the problem exactly, would you have a patch to
the treectrl sample reproducing it?
r> Any way to always have it first?
I guess the answer lies in the sources of src/generic/treectlg.cpp but I
don't know more about it...
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
_______________________________________________
wx-users mailing list
http://lists.wxwidgets.org/mailman/listinfo/wx-users
--
View this message in context: http://www.nabble.com/ScrollTo%28%29-in-wxTreeCtrl-tp23408665p23443166.html
Sent from the wxWidgets - Users mailing list archive at Nabble.com.
Vadim Zeitlin
2009-05-08 14:40:48 UTC
Permalink
On Fri, 8 May 2009 02:53:04 -0700 (PDT) raananb <***@barzel.org> wrote:

r> Windows version of ScrollTo(Item) (in src/msw/treectrl.cpp) has a very simple
r> strategy: Item is always displayed it at the top of the client area.

I think this is not ideal actually. It probably would be better to avoid
scrolling if the item is already visible. But this is discussable...

r> In Linux ScrollTo(Item) (in src/generic/treectlg.cpp) has a different
r> strategy: the display show root as long as Item fits in the client area.
r> When Item is outside (below) the client area, the tree is scrolled to make
r> Item visible, and Item is displayed at the bottom of the client area. So
r> successive siblings sre displayed lower and lower until they become 'sticky'
r> at the bottom.

This definitely doesn't seem right though, it makes much more sense to
display the item at top of the window than at the bottom. And I don't
understand why does it need to care about the root at all.

r> The functionalities of ScrollTo() are thus different between Windows and
r> Linux. Should they be made identical?

Yes, they should. Patches to modify the generic version to show the item
at the top would be most welcome.

Thanks,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
raananb
2009-05-09 08:53:33 UTC
Permalink
Rectification: windows 'simply' calls TreeView_SelectSetFirstVisible for
item, but TreeView_SelectSetFirstVisible scrolls item to first position
only if necessary for displaying item's children.

I'll try to get treectlg.cpp to duplicate this behaviour, and submit a patch
if successful.
Post by Vadim Zeitlin
With 'tree->ScrollTo(ItemX)', when the number of tree items following
ItemX is bigger than the number of lines in the display panel, ItemX is
the first visible item in Windows, and last in GTK.
Any way to always have it first?
2.8.10 GTK2.0 GCC 4.3.3 XP, Vista, Ubuntu 9.04
--
View this message in context: http://www.nabble.com/ScrollTo%28%29-in-wxTreeCtrl-tp23408665p23458559.html
Sent from the wxWidgets - Users mailing list archive at Nabble.com.
Loading...