[ wxwindows-Patches-1857650 ] Verical Listbook does not respond to EnsureVisible

SourceForge.net noreply at sourceforge.net
Wed Jan 2 16:53:10 PST 2008


Patches item #1857650, was opened at 2007-12-24 18:57
Message generated for change (Comment added) made by vadz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=309863&aid=1857650&group_id=9863

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Generic
Group: None
>Status: Closed
>Resolution: Accepted
Priority: 5
Private: No
Submitted By: erik Vogan (erik_vogan)
Assigned to: Nobody/Anonymous (nobody)
Summary: Verical Listbook does not respond to EnsureVisible

Initial Comment:
A ListBook in a vertical orientation (only LB_LEFT tested) does nothing in response to the EnsureVisible(item#) call.

See the report here (includes sample code):

http://article.gmane.org/gmane.comp.python.wxpython/53917

This can be fixed by patching $WXDIR/src/generic/listctrl.cpp as follows (unified diff format):


--- listctrl.cpp.orig   2007-12-24 10:13:50.000000000 -0500
+++ listctrl.cpp        2007-12-24 12:54:25.000000000 -0500
@@ -66,6 +66,7 @@
 // static const int HEADER_HEIGHT = 23;

 static const int SCROLL_UNIT_X = 15;
+static const int SCROLL_UNIT_Y = 15;

 // the spacing between the lines (in report mode)
 static const int LINE_SPACING = 0;
@@ -3316,6 +3317,12 @@
             Scroll( (rect.x - 5) / SCROLL_UNIT_X, -1 );
         if (rect.x + rect.width - 5 > view_x + client_w)
             Scroll( (rect.x + rect.width - client_w + SCROLL_UNIT_X) / SCROLL_UNIT_X, -1 );
+
+        if (rect.y-view_y < 5)
+            Scroll( -1, (rect.y - 5) / SCROLL_UNIT_Y );
+        if (rect.y + rect.height - 5 > view_y + client_h)
+            Scroll( -1, (rect.y + rect.height - client_h + SCROLL_UNIT_Y) / SCROLL_UNIT_Y );
+
     }
 }


NOTES on the patch:

- patch is against wxPython 2.8.7.1
- SCROLL_UNIT_Y was defined equal to SCROLL_UNIT_X (15), but someone who know what they are doing should really decide if that is the right value.
- The patch is also attached as a text file (can be applied with patch -p0 < listctrl_ensurevisible.patch) in case this comes out garbled.



----------------------------------------------------------------------

>Comment By: Vadim Zeitlin (vadz)
Date: 2008-01-03 01:53

Message:
Logged In: YES 
user_id=71618
Originator: NO

Thanks for testing, patch applied to both branches now!

----------------------------------------------------------------------

Comment By: erik Vogan (erik_vogan)
Date: 2008-01-03 01:28

Message:
Logged In: YES 
user_id=1966688
Originator: YES

Vadz,

    I tested your patch against 2.8.7.1, for both a vertical and for a
horizontal ListBook, and it works beautifully.  Thank you for cleaning it
up and for substituting the correct variable name for me.

Erik

----------------------------------------------------------------------

Comment By: Vadim Zeitlin (vadz)
Date: 2008-01-02 21:52

Message:
Logged In: YES 
user_id=71618
Originator: NO

Thanks for the patch and the explanation!

I think however that you should use hLine and not SCROLL_UNIT_Y for the
vertical scrolling. And it would be better to avoid scrolling twice, so
what about this patch:

Index: src/generic/listctrl.cpp
===================================================================
--- src/generic/listctrl.cpp    (revision 50981)
+++ src/generic/listctrl.cpp    (working copy)
@@ -3309,10 +3309,20 @@
     }
     else // !report
     {
+        int sx = -1,
+            sy = -1;
+
         if (rect.x-view_x < 5)
-            Scroll( (rect.x - 5) / SCROLL_UNIT_X, -1 );
+            sx = (rect.x - 5) / SCROLL_UNIT_X;
         if (rect.x + rect.width - 5 > view_x + client_w)
-            Scroll( (rect.x + rect.width - client_w + SCROLL_UNIT_X) /
SCROLL_UNIT_X, -1 );
+            sx = (rect.x + rect.width - client_w + SCROLL_UNIT_X) /
SCROLL_UNIT_X;
+
+        if (rect.y-view_y < 5)
+            sy = (rect.y - 5) / hLine;
+        if (rect.y + rect.height - 5 > view_y + client_h)
+            sy = (rect.y + rect.height - client_h + hLine) / hLine;
+
+        Scroll(sx, sy);
     }
 }


Could you please test it? If it works for you, I can apply it to both
branches. Thanks in advance!

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=309863&aid=1857650&group_id=9863




More information about the wx-dev mailing list