Opened 8 years ago

Last modified 4 weeks ago

#3224 confirmed defect

wxListBox's EnsureVisible not implemented in wxMSW

Reported by: jejackson Owned by:
Priority: low Milestone:
Component: wxMSW Version:
Keywords: wxListBox simple Cc: jejackson, leio, rivdsl@…
Blocked By: Blocking:
Patch: yes

Description

I've tried using wxListBox's EnsureVisible to make sure that top element
of a list box is the displayed item.

However, if there is a selection that would be out-of-view, it always
scrolls to that one instead of what EnsureVisible is set to.

Code snippet: (wxPython)

listBox.SetSelection(10)
listBox.EnsureVisible(0)

always shows item 10, and not item 0.

It appears from looking at the sources that this was never implemented.

Attachments (3)

3224.patch download (1.5 KB) - added by oneeyeman 20 months ago.
Implementation patch
3224EnsureVisible.patch download (1.9 KB) - added by RIVDSL 4 weeks ago.
Implementation patch
3224ControlSample.patch download (1.5 KB) - added by RIVDSL 4 weeks ago.
Sample Patch

Download all attachments as: .zip

Change History (15)

comment:1 Changed 8 years ago by leio

From bug #836309:

Razvan Cojocaru:

EnsureVisible() doesn't scroll with the correct ammount
on wxGTK 2.5.1 and wxMac 2.5.1, so the wanted item is
not shown. I don't know if the problem exists on other
wxWindows flavours, but I've een it for myself on wxGTK
2.5.1 and it's been reported that it happens with wxMac
CVS HEAD.

comment:2 Changed 6 years ago by wojdyr

  • Keywords wxListBox added
  • Resolution set to invalid
  • Status changed from new to closed

wxListBox has EnsureVisible() in the base class, but it's not documented and it's not implemented in wxMSW.

comment:3 Changed 6 years ago by vadz

  • Resolution invalid deleted
  • Status changed from closed to reopened

I think we should document EnsureVisible() and support it. OTOH I don't know if the problem is still present in 2.8 or svn trunk, could someone please test this?

comment:4 Changed 6 years ago by vadz

  • Priority changed from normal to low
  • Status changed from reopened to infoneeded

comment:5 Changed 6 years ago by wojdyr

  • Status changed from infoneeded to accepted

afaict it's not implemented on wxMSW and never was implemented. There is nothing to test, this function is just empty.

comment:6 Changed 22 months ago by oneeyeman

The documentation for wxListBox::EnsureVisible() was added and it mentions that the function implemented only on GTK and Mac.

Probably worth changing the subject so that someone will implement that.

comment:7 Changed 22 months ago by vadz

  • Component changed from GUI-generic to wxMSW
  • Keywords simple added
  • Status changed from accepted to new
  • Summary changed from wxListBox's EnsureVisible not implemented to wxListBox's EnsureVisible not implemented in wxMSW

Considering that wxMSW does implement SetFirstItem(), it shouldn't be difficult to implement this one.

comment:8 Changed 22 months ago by vadz

  • Status changed from new to confirmed

Changed 20 months ago by oneeyeman

Implementation patch

comment:9 Changed 20 months ago by oneeyeman

  • Patch set

Attached please find a patch that implements EnsureVisible for the listbox in wxMSW.
It also corrects the documentation.

comment:10 Changed 20 months ago by vadz

  • Patch unset

Sorry, this is not the right implementation. If EnsureVisible() were the same as SetFirstItem(), what would be the point of having it?

EnsureVisible() is supposed to scroll just enough to make the item visible and, in particular, not scroll at all if it's already visible.

Changed 4 weeks ago by RIVDSL

Implementation patch

Changed 4 weeks ago by RIVDSL

Sample Patch

comment:11 Changed 4 weeks ago by RIVDSL

  • Patch set

I added a patch for this, including a sample to test it.

Only potential problem is that this will not work with LBS_OWNERDRAWVARIABLE since the implementation relies on fixed height items. But I don't think this is supported at this time anyway.

comment:12 Changed 4 weeks ago by RIVDSL

  • Cc rivdsl@… added
Note: See TracTickets for help on using tickets.