wxWidgets / Phoenix

wxPython's Project Phoenix. A new implementation of wxPython, better, stronger, faster than he was before.
http://wxpython.org/
2.21k stars 509 forks source link

Add support for ULC_AUTO_CHECK_PARENT #2518

Closed reticulatus closed 3 months ago

reticulatus commented 3 months ago

Fixes #2516

This PR implements the fix proposed in #2516 to add support for the ULC_AUTO_CHECK_PARENT style of the UltimateListCtrl.

The following code can be used to test the fix:

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

class MyFrame(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent)
        agw_style = (wx.LC_REPORT | wx.LC_VRULES | wx.LC_HRULES | wx.LC_SINGLE_SEL |
                     ULC.ULC_AUTO_CHECK_CHILD | ULC.ULC_AUTO_CHECK_PARENT)
        self.ulc = ULC.UltimateListCtrl(self, -1, agwStyle=agw_style, size=(640, 480))
        self.populateList()

    def populateList(self):
        info = ULC.UltimateListItem()
        info._mask = wx.LIST_MASK_TEXT | wx.LIST_MASK_FORMAT | ULC.ULC_MASK_WIDTH | ULC.ULC_MASK_CHECK
        info._format = 0
        info._kind = 1
        info._text = "Column 0"
        info._width = 120
        self.ulc.InsertColumnInfo(0, info)
        info = ULC.UltimateListItem()
        info._mask = wx.LIST_MASK_TEXT | wx.LIST_MASK_FORMAT | ULC.ULC_MASK_WIDTH | ULC.ULC_MASK_CHECK
        info._format = 0
        info._kind = 1
        info._text = "Column 1"
        info._width = 120
        self.ulc.InsertColumnInfo(1, info)
        for r in range(8):
            label = f"Col 0, Item {r}"
            self.ulc.InsertStringItem(r, label, it_kind=1)
            label = f"Col 1, Item {r}"
            self.ulc.SetStringItem(r, 1, label, it_kind=1)

if __name__ == '__main__':
    app = wx.App()
    frame = MyFrame(None)
    frame.Show()
    app.MainLoop()
RobinD42 commented 3 months ago

This pull request has been mentioned on Discuss wxPython. There might be relevant details there:

https://discuss.wxpython.org/t/ultimatelistctrl-header-checkbox-partial-check/36784/12