UltimateListCtrl background color and ULC.ULC_BORDER_SELECT weird rendering issue

299 views
Skip to first unread message

Nathan McCorkle

unread,
Jun 3, 2014, 4:48:59 PM6/3/14
to wxpytho...@googlegroups.com
I've created an UltimateListCtrl, I've changed certain items fore and background colors...

When not using the ULC_BORDER_SELECT style color look pretty horrible for different rows (they aren't all the same color on selection), but when using the ULC_BORDER_SELECT option, the items which I called SetBackgroundColour all have the border selection blue bounding box ALWAYS drawn... as in when you do actually select one of them, you don't see a visual difference for that row, at all (the row that was previously selected will have its bounding box removed, if it wasn't a SetBackgroundColour affected item).


Here's a simple working example demonstrating the problem.. see how the middle row looks:

import wx
from wx.lib.agw import ultimatelistctrl as ULC

class TestUltimateListCtrl(ULC.UltimateListCtrl):
    def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, agwStyle=0):
        ULC.UltimateListCtrl.__init__(self, parent, id, pos, size, style, agwStyle)

########################################################################
class TestPanel(wx.Panel):
    """"""
 
    #----------------------------------------------------------------------
    def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent)
 
        font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
        boldfont = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
        boldfont.SetWeight(wx.BOLD)
        boldfont.SetPointSize(12)
 
        self.ultimateList = TestUltimateListCtrl(self, agwStyle = wx.LC_REPORT 
                                         | wx.LC_VRULES
                                         | wx.LC_HRULES | ULC.ULC_BORDER_SELECT)#|ULC.ULC_EDIT_LABELS)
 
        info = ULC.UltimateListItem()
        info._mask = wx.LIST_MASK_TEXT | wx.LIST_MASK_IMAGE | wx.LIST_MASK_FORMAT |ULC.ULC_MASK_FONTCOLOUR#| ULC.ULC_MASK_CHECK# |ULC.ULC_EDIT_LABELS
        #info._image = []
        info._format = 0
        #info._kind = 1
        info._mask = wx.LIST_MASK_TEXT | wx.LIST_MASK_IMAGE | wx.LIST_MASK_FORMAT | ULC.ULC_MASK_BACKCOLOUR

        info._font = font
        info.SetMask(ULC.ULC_MASK_FONTCOLOUR| wx.LIST_MASK_WIDTH | wx.LIST_MASK_TEXT| wx.LIST_MASK_FORMAT )
        info.SetTextColour(wx.Colour(255,0,0))
        info._text = "Artist Name"
        self.ultimateList.InsertColumnInfo(0, info)
 
        info = ULC.UltimateListItem()
        info._format = wx.LIST_FORMAT_RIGHT
        info._mask = wx.LIST_MASK_TEXT | wx.LIST_MASK_IMAGE | wx.LIST_MASK_FORMAT | ULC.ULC_MASK_FONTCOLOUR#|ULC.ULC_EDIT_LABELS
        #info._image = []
        info._text = "Title"
        #info._font = boldfont
        self.ultimateList.InsertColumnInfo(1, info)
 
        info = ULC.UltimateListItem()
        info._mask = wx.LIST_MASK_TEXT | wx.LIST_MASK_IMAGE | wx.LIST_MASK_FORMAT | ULC.ULC_MASK_FONTCOLOUR#|ULC.ULC_EDIT_LABELS
        info._format = 0
        info._text = "Genre"
        #info._font = font
        #info._image = []
        self.ultimateList.InsertColumnInfo(2, info)
 

        self.ultimateList.InsertStringItem(0, "Puffy")
        self.ultimateList.SetStringItem(0, 1, "Bring It!")
        self.ultimateList.SetStringItem(0, 2, "Pop")
        item2 = self.ultimateList.GetItem(0, 1)
        item3 = self.ultimateList.GetItem(0, 2)
        item2.SetMask(ULC.ULC_MASK_FONTCOLOUR| wx.LIST_MASK_WIDTH)
        item3.SetMask(ULC.ULC_MASK_FONTCOLOUR| wx.LIST_MASK_WIDTH)
        item2.SetTextColour(wx.Colour(255,0,0))
        item3.SetTextColour(wx.Colour(255,0,0))
        self.ultimateList.SetItem(item2)
        self.ultimateList.SetItem(item3)


        self.ultimateList.InsertStringItem(1, "Newsboys")
        self.ultimateList.SetStringItem(1, 1, "Go")
        self.ultimateList.SetStringItem(1, 2, "Rock")
        item1 = self.ultimateList.GetItem(1, 0)
        item2 = self.ultimateList.GetItem(1, 1)
        item3 = self.ultimateList.GetItem(1, 2)
        item1.SetMask(ULC.ULC_MASK_BACKCOLOUR| wx.LIST_MASK_WIDTH)
        item2.SetMask(ULC.ULC_MASK_BACKCOLOUR| wx.LIST_MASK_WIDTH)
        item3.SetMask(ULC.ULC_MASK_BACKCOLOUR| wx.LIST_MASK_WIDTH)
        item1.SetBackgroundColour(wx.Colour(242,242,242))
        item2.SetBackgroundColour(wx.Colour(242,242,242))
        item3.SetBackgroundColour(wx.Colour(242,242,242))
        self.ultimateList.SetItem(item1)
        self.ultimateList.SetItem(item2)
        self.ultimateList.SetItem(item3)


        self.ultimateList.InsertStringItem(2, "Family Force 5")
        self.ultimateList.SetStringItem(2, 1, "III")
        self.ultimateList.SetStringItem(2, 2, "Crunk")        
        item2 = self.ultimateList.GetItem(2, 1)
        item3 = self.ultimateList.GetItem(2, 2)
        item2.SetMask(ULC.ULC_MASK_FONTCOLOUR| wx.LIST_MASK_WIDTH)
        item3.SetMask(ULC.ULC_MASK_FONTCOLOUR| wx.LIST_MASK_WIDTH)        
        item2.SetTextColour(wx.Colour(111,158,219))
        item3.SetTextColour(wx.Colour(111,158,219))
        self.ultimateList.SetItem(item2)
        self.ultimateList.SetItem(item3)


        self.ultimateList.SetColumnWidth(0, wx.LIST_AUTOSIZE_USEHEADER)
        self.ultimateList.SetColumnWidth(1, wx.LIST_AUTOSIZE_USEHEADER)
        self.ultimateList.SetColumnWidth(2, -3)
        self.ultimateList.SetColumnWidth(0, wx.LIST_AUTOSIZE)#150)
        self.ultimateList.SetColumnWidth(1, wx.LIST_AUTOSIZE)#200)
        self.ultimateList.SetColumnWidth(2, -3)#100)
        
        
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.ultimateList, 1, wx.EXPAND)
        self.SetSizer(sizer)
 
########################################################################
class TestFrame(wx.Frame):
    """"""
 
    #----------------------------------------------------------------------
    def __init__(self):
        """Constructor"""
        wx.Frame.__init__(self, None, title="MvP UltimateListCtrl Demo")
        panel = TestPanel(self)
        self.Show()
 
#----------------------------------------------------------------------
if __name__ == "__main__":
    app = wx.App(False)
    frame = TestFrame()
    app.MainLoop()


Nathan McCorkle

unread,
Jun 3, 2014, 5:29:41 PM6/3/14
to wxpytho...@googlegroups.com
Oh, here's the code attached as a file.
testULC.py

Nathan McCorkle

unread,
Jun 4, 2014, 10:12:30 PM6/4/14
to wxpytho...@googlegroups.com
Ok, I found that if I change the line from 

if self.SetAttributes(dc, attr, highlighted) and enabled

to:
if current and enabled:

in wx\lib\agw\ultimatelistctrl.py

in the DrawInReportMode function

the border goes away when the colored item is unselected!


Is there a better place than here to file this bug (along with the issue where ULC errors when using a colour defined by a string, rather than a wx.Colour object)?


P.S. I moved the SetAttributes call one line up, and didn't save the return value.

Mike Driscoll

unread,
Jun 11, 2014, 1:23:11 PM6/11/14
to wxpytho...@googlegroups.com
Hi Nathan,


On Wednesday, June 4, 2014 9:12:30 PM UTC-5, Nathan McCorkle wrote:
Ok, I found that if I change the line from 

if self.SetAttributes(dc, attr, highlighted) and enabled

to:
if current and enabled:

in wx\lib\agw\ultimatelistctrl.py

in the DrawInReportMode function

the border goes away when the colored item is unselected!


Is there a better place than here to file this bug (along with the issue where ULC errors when using a colour defined by a string, rather than a wx.Colour object)?


There's a link on the main page (http://wxpython.org/) labeled "Report a bug".  Click that and follow the directions on the page the appears. You will want to make sure you set the bug to be against wxPython and not wxWidgets.

- Mike

Nathan McCorkle

unread,
Jun 24, 2014, 7:19:51 PM6/24/14
to wxpytho...@googlegroups.com
Thanks Mike.

I looked through existing tickets and found a similar one. I submitted a patch assuming it would fix the original ticket, but just after submitting I tried it for the ticket's use-case and my patch didn't work. So I spent a bit more time on it and came up with a patch that fixes my issue and the ticket's.

I also added another ticket for an enhancement, which allows the user to specify what color is applied to an item that has been selected/highlighted.
http://trac.wxwidgets.org/ticket/16355


Hope this helps someone else!
Reply all
Reply to author
Forward
0 new messages