column headers and virtual ListCtrl

I’m using virtual list controls most of the time, partly for scalability reasons and partly just because my code ends up being much cleaner and more modular. However, the lack of sorting is beginning to annoy me. I can figure out how to sort items easily enough, but on Mac the column headers do not appear to be selectable. I can still bind to wx.EVT_LIST_COL_CLICK and identify when and where a column header is clicked, but the appearance stays the same, instead of applying an Aqua-blue highlight to the clicked header. Is this an oversight, or an incompatibility? And is there any way I can invoke the highlighting manually?

thanks,

Nat

By default the wx.ListCtrl on the mac ports is a generic widget, but it does use the native APIs for rendering the col headers. I do see the blue header on the sorted column with the ListCtrl sample in the demo when I try it here, do you? If not then there are a few possible explanations: Is your version of wxPython up to date? What version of OSX are you running on? It's possible that the native API used for rendering the header behaved differently or was not available in previous versions.

···

On 12/13/10 2:58 PM, Nat Echols wrote:

I'm using virtual list controls most of the time, partly for scalability
reasons and partly just because my code ends up being much cleaner and
more modular. However, the lack of sorting is beginning to annoy me. I
can figure out how to sort items easily enough, but on Mac the column
headers do not appear to be selectable. I can still bind
to wx.EVT_LIST_COL_CLICK and identify when and where a column header is
clicked, but the appearance stays the same, instead of applying an
Aqua-blue highlight to the clicked header. Is this an oversight, or an
incompatibility? And is there any way I can invoke the highlighting
manually?

--
Robin Dunn
Software Craftsman

Yes, the regular ListCtrl sample has the blue headers (and sorting), but my problem is specifically with a control with style=wx.LC_REPORT|wx.LC_VIRTUAL, i.e. the ListCtrl_virtual sample in the demo, which does not have the blue headers. (Or sorting, but I think the headers in the non-virtual control will be highlighted on clicking even if no sorting is done.)

-Nat

···

On Tue, Dec 14, 2010 at 10:07 AM, Robin Dunn robin@alldunn.com wrote:

By default the wx.ListCtrl on the mac ports is a generic widget, but it does use the native APIs for rendering the col headers. I do see the blue header on the sorted column with the ListCtrl sample in the demo when I try it here, do you? If not then there are a few possible explanations: Is your version of wxPython up to date? What version of OSX are you running on? It’s possible that the native API used for rendering the header behaved differently or was not available in previous versions.

I followed this recepy, and I have no problem both in win and in Mac.

http://code.activestate.com/recipes/426407-columnsortermixin-with-a-virtual-wxlistctrl/

···

On Dec 14, 7:31 pm, Nat Echols <nathaniel.ech...@gmail.com> wrote:

On Tue, Dec 14, 2010 at 10:07 AM, Robin Dunn <ro...@alldunn.com> wrote:
> By default the wx.ListCtrl on the mac ports is a generic widget, but it
> does use the native APIs for rendering the col headers. I do see the blue
> header on the sorted column with the ListCtrl sample in the demo when I try
> it here, do you? If not then there are a few possible explanations: Is
> your version of wxPython up to date? What version of OSX are you running
> on? It's possible that the native API used for rendering the header behaved
> differently or was not available in previous versions.

Yes, the regular ListCtrl sample has the blue headers (and sorting), but my
problem is specifically with a control with
style=wx.LC_REPORT|wx.LC_VIRTUAL, i.e. the ListCtrl_virtual sample in the
demo, which does not have the blue headers. (Or sorting, but I think the
headers in the non-virtual control will be highlighted on clicking even if
no sorting is done.)

-Nat

This adds up/down arrows to the sorted list, which is definitely an improvement, but it still doesn’t highlight the column header, which is what I really want.

-Nat

···

On Tue, Dec 14, 2010 at 12:30 PM, tinauser tinauser@libero.it wrote:

I followed this recepy, and I have no problem both in win and in Mac.

http://code.activestate.com/recipes/426407-columnsortermixin-with-a-virtual-wxlistctrl/

There is this code in the generic listctrl code for rendering the col headers, item is the wxListItem used for the column header info:

         if ( !m_owner->IsVirtual() && (item.m_mask & wxLIST_MASK_STATE) &&
                 (item.m_state & wxLIST_STATE_SELECTED) )
             flags |= wxCONTROL_SELECTED;

So it looks like it won't even try to draw them in the selected state if the listctrl is in virtual mode. I have no idea why this is done and as you can tell from my prior response I wasn't expecting it either. It might be worth creating a ticket about this and see what the other wx developers think about it.

···

On 12/14/10 10:31 AM, Nat Echols wrote:

On Tue, Dec 14, 2010 at 10:07 AM, Robin Dunn <robin@alldunn.com > <mailto:robin@alldunn.com>> wrote:

    By default the wx.ListCtrl on the mac ports is a generic widget, but
    it does use the native APIs for rendering the col headers. I do see
    the blue header on the sorted column with the ListCtrl sample in the
    demo when I try it here, do you? If not then there are a few
    possible explanations: Is your version of wxPython up to date?
      What version of OSX are you running on? It's possible that the
    native API used for rendering the header behaved differently or was
    not available in previous versions.

Yes, the regular ListCtrl sample has the blue headers (and sorting), but
my problem is specifically with a control with
style=wx.LC_REPORT|wx.LC_VIRTUAL, i.e. the ListCtrl_virtual sample in
the demo, which does not have the blue headers. (Or sorting, but I
think the headers in the non-virtual control will be highlighted on
clicking even if no sorting is done.)

--
Robin Dunn
Software Craftsman

The AGW listctrl may work as expected.

Mark

···

There is this code in the generic listctrl code for rendering the col
headers, item is the wxListItem used for the column header info:

     if \( \!m\_owner\-&gt;IsVirtual\(\) &amp;&amp; \(item\.m\_mask &amp; wxLIST\_MASK\_STATE\) &amp;&amp;
             \(item\.m\_state &amp; wxLIST\_STATE\_SELECTED\) \)
         flags |= wxCONTROL\_SELECTED;

So it looks like it won't even try to draw them in the selected state if
the listctrl is in virtual mode. I have no idea why this is done and as
you can tell from my prior response I wasn't expecting it either. It
might be worth creating a ticket about this and see what the other wx
developers think about it.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org