Jonatan Johansson wrote:
Hello, Happy New Year etc.!
I was looking at the TreeListCtrl demo and a few questions popped up.
I noticed it is necessary to handle window resize events and in the
event handler call the TreeListControl's SetSize method;
In the demo it is because the TreeListCtrl is located on a Panel, and the panel's EVT_SIZE handler is resizing the treelist to completly cover the panel. The treelist's EVT_SIZE is not being handled anywhere but in the treelist itself.
otherwise one
will have redrawal problems (notice how the column header changes from
http://www.cyd.liu.se/users/~jonjo002/treelistctrl/maximized.png to
http://www.cyd.liu.se/users/~jonjo002/treelistctrl/restored.png when
the window size changes). Also notice the low contrast between the
hierarchy indicating lines and the background of the TreeListCtrl.
It probably just needs a call to Refresh somewhere.
My
questions are:* Why is it necessary to call SetSize? Shouldn't this be default
behaviour? I mean, I don't have to call SetSize explicitly for other
contorls.
It is not necessary. In the demo it is just a brute force way to not have to use a sizer.
* In the demo, self.tree.SetSize is called with self.GetSize() as the
argument (self being the panel on which the TreeListCtrl is located.
Where is the logic in setting the size of the TreeListCtrl to the size
of the panel?
It was probably done because in some situations a window derived from wx.ScrolledWindow that was placed directly in a wx.Notebook could sometimes have bg colour refresh problems on wxGTK(1). Putting a panel under the window fixes that problem.
* If I use this in the __init__ of a class derived from TreeListCtrl,
subsequent calls to the tree's GetSize method returns (150, 300),
although other values are sent as argument to SetSize in the EVT_SIZE
event handler. Why doesn't this size change?
Use what in the __init__?
* Why is the default color of the TreeListCtrl the same as the
standard panel color, rather than plain white (as is the case of
ListCtrl and TreeCtrl)?
This would be a bug. What version are you using?
* How can I change the background color to better see the hierarchy
lines? I tried using tree.SetBackgroundColour("white") but this didn't
change anything.
Also a bug. Is this a build done from CVS in the past few weeks? If so then there were some bugs dealing with background erase and colour inheritance on MSW. This would probably also explain your refresh issue above. Try updating and building again.
* After searching/reading here and there, my conclusion is that gizmos
= custom controls.
Why aren't these included in the standard wxWidgets distribution?
Because in the case of wxTreeListCtrl there is a deisre to add a new set of classes to the core that would overlap the functionality of this one. The new classes however would use a native implementaiton on at least OSX and GTK2.
For the other gizmos and contribs in general a determination is made if a class is vital or useful enough that it is worth bloating the main library to add it. If not then they end up in contrib and if people like them enough they can use them in addition to the library. There is some shift happening to this policy though, now that we have the new build system it is easy to add additional optional libs to the main build.
* How do I know what platforms this control is available on? The
gizmos don't seem to be listed at
http://www.wxwidgets.org/supported.htm. From the C++ source code and
the API reference that comes with it, it seems to be available for
Windows, Mac and GTK but I'm no C++ genius, so it would be nice to
know.
It's totally generic code, so all of them.
* Should I simply join the wxCode list and post this message there,
since most of it probably isn't wxPython-specific but rather problems
with the original C++ source?
It may or may not help as the version of the wxTreeListCtrl code I am using is a bit different than what is in wxCode. They made some changes that would have either broken the existing API or been hard to work around so I havn't updated for a while. But if my guess above is correct then the problem isn't in the wxTreeListCtrl code at all.
···
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!