From: Carl G. <cg...@gm...> - 2005-11-23 17:39:38
|
On 11/23/05, Otto Wyss <ott...@or...> wrote: > Carl Godkin wrote: > > >When I create the control and populate it with more items than fit verti= cally, > >I don't get a scrollbar right away until I click on one of the items. T= his > >happens both on Windows and Linux so I presume it's intentional. Howeve= r, > >I'd like to always show the vertical scrollbar so that the user knows th= ere are > >more items below. > > > > > > > I've seen this as well lately and think it's something wrong within > wxWidgets but I'm not sure. I haven't seen it in any of my old apps, > only in the new TorMgr I write for the Tor GUI contest. So it might be a > problem of 2.6.2, again I'm not sure. > > >Is there some way I can force this? I looked into this and found the problem, I think. The member function wxTreeListMainWindow::AdjustMyScrollbars() calls GetSize() on the root item. However wxTreeListItem::GetSize() doesn't think the root item is expanded, so all you get is the (hidden) root item's size. I worked around this by adding Expand(rootId) after I populate the tree initially and now the vertical scrollbar appears as I think it should. This even makes sense to me. I wondered if this problem would happen in the generic tree control which was apparently the model for the tree list control but found that there is a little code we might wa= nt to add to avoid this problem. Notice the difference here: void wxTreeListMainWindow::SetWindowStyle (const long styles) { // right now, just sets the styles. Eventually, we may // want to update the inherited styles, but right now // none of the parents has updatable styles m_windowStyle =3D styles; m_dirty =3D true; } void wxGenericTreeCtrl::SetWindowStyle(const long styles) { if (!HasFlag(wxTR_HIDE_ROOT) && (styles & wxTR_HIDE_ROOT)) { // if we will hide the root, make sure children are visible m_anchor->SetHasPlus(); m_anchor->Expand(); CalculatePositions(); } // right now, just sets the styles. Eventually, we may // want to update the inherited styles, but right now // none of the parents has updatable styles m_windowStyle =3D styles; m_dirty =3D true; } (Note that m_anchor in the generic tree control is the same as m_rootItem in the tree list control.) Thanks, carl |