[wxPython-users] ANN: HyperTreeList Control for wxPython :-D

Robin Dunn robin at alldunn.com
Wed May 9 12:54:20 PDT 2007


Andrea Gavana wrote:
> Hi Robin & All,
> 
> On 5/9/07, Robin Dunn wrote:


>> IIRC that was the main reason that wxTreeListCtrl was never moved into
>> the core wxWidgets, because it duplicated and slightly modified all of
>> the treectrl code instead of refactoring so they both could share the
>> common code.
> 
> Ok, I refactored a bit the implementation:
> 
> 1) Now HyperTreeList is a subclass of CustomTreeCtrl, except for the
> drawing functions and mouse event handling;
> 2) TreeListItem is a subclass of GenericTreeItem (that is implemented
> in CustomTreeCtrl) plus some other attributes/methods;
> 3) The DragImage, TreeEvent, TreeItemAttr, TreeRenameTimer classes are
> taken directly from CustomTreeCtrl.
> 
> Plus some other tweaks. The original HyperTreeList implementation is
> 6400 lines long, and I was able to kick it down to 3100. It should be
> possible to hack it more in order to share (part of) the drawing and
> mouse handling code between the two classes, but that would require
> medium-sized modifications to CustomTreeCtrl and major tweaks to
> HyperTreeList.

How about this:  Refactor CTC so the drawing and mouse events don't 
assume that the tree is located at the (0,0) position of the window. 
Then the drawing can be positioned anywhere without problems, and the 
behavior of the CTC would remain exactly the same as it is now with very 
little risk for breaking something.  Of course when using the CTC it 
would still use (0,0) as the origin, but the derived HTL class can 
change the origin as needed to make room for the header, or to position 
the tree in any column.  Then the next step would be to change 
CTC.PaintLevel and add a call to some PaintOtherStuff method which would 
be just an empty stub in CTC.  In HTL the PaintOtherStuff method would 
be overridden and would handle painting the rest of the row.

Make sense?


-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-users mailing list