mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-05 11:30:06 +01:00
Fix item window alignment in HyperTreeList
If wx.ALIGN_LEFT or wx.ALIGN_RIGHT are used on columns with item windows they won't be placed properly and will extend outside their column. Affects both items with text and without. This fix aligns the windows properly under all conditions. Can be seen in the HyperTreeList demo by expanding 'Item 0' and 'item 0-a', double-clicking on all column separators to autosize the columns to their contents, and enabling the TR_COLUMN_LINES style. The demo window size should be increased to show all list controls and make 'item 0-d' and its two items visible. Changing the alignment between LEFT/CENTER/RIGHT will show poor placement of the windows.
This commit is contained in:
@@ -3073,9 +3073,23 @@ class TreeListMainWindow(CustomTreeCtrl):
|
||||
wnd = item.GetWindow(i)
|
||||
if wnd:
|
||||
if text_w == 0:
|
||||
wndx = text_x
|
||||
# No text. Honor column alignment for window.
|
||||
if alignment == wx.ALIGN_RIGHT:
|
||||
# text_x = right edge of window
|
||||
wndx = text_x - wnd.GetSize().width
|
||||
elif alignment == wx.ALIGN_CENTER:
|
||||
# text_x = center of window
|
||||
wndx = text_x - (wnd.GetSize().width // 2)
|
||||
else:
|
||||
# text_x = left of window (default).
|
||||
wndx = text_x
|
||||
else:
|
||||
wndx = text_x + text_w + 2*_MARGIN
|
||||
if alignment == wx.ALIGN_RIGHT:
|
||||
# Place window left of text with 2*_MARGIN in between.
|
||||
wndx = text_x - 2*_MARGIN - wnd.GetSize().width
|
||||
else:
|
||||
# Place window at end of text plus 2*_MARGIN (default).
|
||||
wndx = text_x + text_w + 2*_MARGIN
|
||||
xa, ya = self.CalcScrolledPosition(0, item.GetY())
|
||||
wndx += xa
|
||||
if item.GetHeight() > item.GetWindowSize(i)[1]:
|
||||
|
||||
Reference in New Issue
Block a user