CustomTreeCtrl bug fixes

Hi gang,

    a couple of bug fixes reported by a Mac user (strange eh? :smiley: ):

in the DragImage class, in the __init__ method, the tests:

if colour is None:
    colour = wx.BLACK
if font is None:
    font = treeCtrl._normalFont

should read:

if colour is wx.NullColour:
    colour = wx.BLACK
if font is wx.NullFont:
    font = treeCtrl._normalFont

otherwise the dragging visual effects won't work on Mac.

Regarding the issue of the impossibility to select an item if it
doesn't have an icon assigned to it is due to a wrong indentation of
the code, at line 4243:

drawItemBackground = True

Should be dedented so that it is set also on Mac.

I tested the patch provided by Frank about the auto-unckecking of
checkbox-type item parents. Works on Windows, so if someone else
(Frank?) could possibbly confirm that it works also on GTK and Mac, I
suppose that Robin may actually integrate that patch into
wx.lib.customtreectrl.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/

Hi all
I am the mac user that found the fix but unfortunately it was ok only
in 2.7.1.2.
Updating to 2.7.1.3 I have a new issue as the image is created but not
displayed during the drag.
Any idea ?

G

···

On 11/6/06, Andrea Gavana <andrea.gavana@gmail.com> wrote:

Hi gang,

    a couple of bug fixes reported by a Mac user (strange eh? :smiley: ):

in the DragImage class, in the __init__ method, the tests:

if colour is None:
    colour = wx.BLACK
if font is None:
    font = treeCtrl._normalFont

should read:

if colour is wx.NullColour:
    colour = wx.BLACK
if font is wx.NullFont:
    font = treeCtrl._normalFont

otherwise the dragging visual effects won't work on Mac.

Regarding the issue of the impossibility to select an item if it
doesn't have an icon assigned to it is due to a wrong indentation of
the code, at line 4243:

drawItemBackground = True

Should be dedented so that it is set also on Mac.

I tested the patch provided by Frank about the auto-unckecking of
checkbox-type item parents. Works on Windows, so if someone else
(Frank?) could possibbly confirm that it works also on GTK and Mac, I
suppose that Robin may actually integrate that patch into
wx.lib.customtreectrl.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Andrea Gavana wrote:

Hi gang,

   a couple of bug fixes reported by a Mac user (strange eh? :smiley: ):

in the DragImage class, in the __init__ method, the tests:

if colour is None:
   colour = wx.BLACK
if font is None:
   font = treeCtrl._normalFont

should read:

if colour is wx.NullColour:
   colour = wx.BLACK
if font is wx.NullFont:
   font = treeCtrl._normalFont

otherwise the dragging visual effects won't work on Mac.

These shouldn't have anything Mac-specific about them...

Also, it's possible to have an invalid font or color without it being the same instance as the wx.NullFont or wx.NullColor, so a better test would be something like "if not colour:..." as that will handle both the case where it might be None, and if it is an instance of a wx.Colour then it will call the IsOk() method to see if it is valid or not.

Regarding the issue of the impossibility to select an item if it
doesn't have an icon assigned to it is due to a wrong indentation of
the code, at line 4243:

drawItemBackground = True

Should be dedented so that it is set also on Mac.

The line numbers in the CVS version are different. Can you give a little more context (or a patch made from the CVS version) to show which line you mean?

BTW, I fixed this problem differently:

http://cvs.wxwidgets.org/viewcvs.cgi/wxWidgets/wxPython/wx/lib/customtreectrl.py.diff?r1=1.4&r2=1.5

I tested the patch provided by Frank about the auto-unckecking of
checkbox-type item parents. Works on Windows, so if someone else
(Frank?) could possibbly confirm that it works also on GTK and Mac, I
suppose that Robin may actually integrate that patch into
wx.lib.customtreectrl.

I've already applied it to CVS.

···

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

Giovanni Porcari wrote:

Hi all
I am the mac user that found the fix but unfortunately it was ok only
in 2.7.1.2.
Updating to 2.7.1.3 I have a new issue as the image is created but not
displayed during the drag.
Any idea ?

There is only one change in customtreectrl.py between those versions, and it would not have any effect on dragging...

http://cvs.wxwidgets.org/viewcvs.cgi/wxWidgets/wxPython/wx/lib/customtreectrl.py.diff?r1=1.3&r2=1.4

···

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

I know that it is the only difference in customtreectrl so it is even
more difficult to understand. So I suspect that something happened in
another place in an .so module.

···

On 11/6/06, Robin Dunn <robin@alldunn.com> wrote:

Giovanni Porcari wrote:
> Hi all
> I am the mac user that found the fix but unfortunately it was ok only
> in 2.7.1.2.
> Updating to 2.7.1.3 I have a new issue as the image is created but not
> displayed during the drag.
> Any idea ?

There is only one change in customtreectrl.py between those versions,
and it would not have any effect on dragging...

http://cvs.wxwidgets.org/viewcvs.cgi/wxWidgets/wxPython/wx/lib/customtreectrl.py.diff?r1=1.3&r2=1.4

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

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Andrea Gavana wrote:
> Hi gang,
>
> a couple of bug fixes reported by a Mac user (strange eh? :smiley: ):
>
> in the DragImage class, in the __init__ method, the tests:
>
> if colour is None:
> colour = wx.BLACK
> if font is None:
> font = treeCtrl._normalFont
>
> should read:
>
> if colour is wx.NullColour:
> colour = wx.BLACK
> if font is wx.NullFont:
> font = treeCtrl._normalFont
>
> otherwise the dragging visual effects won't work on Mac.

These shouldn't have anything Mac-specific about them...

I don't know if it is a Mac issue but the problem was this statement :

   width, height, dummy = tempdc.GetMultiLineTextExtent(text + "M")
as the font is invalid if the tree item has not a specific font.

Also, it's possible to have an invalid font or color without it being
the same instance as the wx.NullFont or wx.NullColor, so a better test
would be something like "if not colour:..." as that will handle both the
case where it might be None, and if it is an instance of a wx.Colour
then it will call the IsOk() method to see if it is valid or not.

>
> Regarding the issue of the impossibility to select an item if it
> doesn't have an icon assigned to it is due to a wrong indentation of
> the code, at line 4243:
>
> drawItemBackground = True
>
> Should be dedented so that it is set also on Mac.

The line numbers in the CVS version are different. Can you give a
little more context (or a patch made from the CVS version) to show which
line you mean?

Here is the code snippet:

def PaintItem(self, item, dc):
        """Actually paint an item."""
<----- snip ------->
             if item.IsSelected():

            # under mac selections are only a rectangle in case they
don't have the focus
            if wx.Platform == "__WXMAC__":
                if not self._hasFocus:
                    dc.SetBrush(wx.TRANSPARENT_BRUSH)

dc.SetPen(wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHT),
1, wx.SOLID))
                else:
                         dc.SetBrush(self._hilightBrush)
            else:
                    dc.SetBrush((self._hasFocus and
[self._hilightBrush] or [self._hilightUnfocusedBrush])[0])
                    drawItemBackground = True
        else:
<----- snip ------->
As you can see if drawItemBackground = True is not executed if the
platform is MAC.

···

On 11/6/06, Robin Dunn <robin@alldunn.com> wrote:

BTW, I fixed this problem differently:

http://cvs.wxwidgets.org/viewcvs.cgi/wxWidgets/wxPython/wx/lib/customtreectrl.py.diff?r1=1.4&r2=1.5

>
> I tested the patch provided by Frank about the auto-unckecking of
> checkbox-type item parents. Works on Windows, so if someone else
> (Frank?) could possibbly confirm that it works also on GTK and Mac, I
> suppose that Robin may actually integrate that patch into
> wx.lib.customtreectrl.

I've already applied it to CVS.

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

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org