Ticket #9484 (closed enhancement: fixed)
Patch Adding Report View to wxListbook
|Reported by:||crjjrc||Owned by:|
wxListbook currently uses a wxLC_ICON style unconditionally for the underlying wxListCtrl. However, if no icons are attached to the page labels, this style seems inappropriate. Until ticket 9472, iconless items were displayed with excessive whitespace. The patch on that ticket eliminated the whitespace if the control's imageList was NULL, but labels were still centered due to the wxLC_ICON style.
This patch goes a step further and modifies wxListbook to use a wxLC_REPORT style by default. If wxListbook::SetImageList is called with a non-NULL imageList, the style of list control is modified to use a wxLC_ICON style.
Users can effectively toggle between a report view and an icon view by calling SetImageList with respectively a NULL or non-NULL argument. In report view, the labels are left-aligned and displayed compactly in one column. In icon view, the labels are centered under their icons in one column (as per usual).
Since changing the wxListCtrl style is done by calling SetWindowStyleFlag, which deletes all its items, the items must be re-added. The labels and image ids are stored temporarily and then used for repopulation.
To get the image id, I had to implement wxListbook::GetPageImage(). I don't know why this was left unimplemented.
This modification seems to perform well with the notebook sample. (Under wxGTK 2,9, this sample occasionally gives me an assertion failure regarding the cursor when I navigate between pages. The failure occurred before my modifications.)