wxVScrolledWindow resize problem?

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

wxVScrolledWindow resize problem?

Post by priyank_bolia » Mon Feb 13, 2006 11:17 am

when the wxVScrolledWindow window size changes, it does not correctly displays the controls in the sizers, when the scrollbar is as position greater than zero.

eco
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 203
Joined: Tue Aug 31, 2004 7:06 pm
Location: Behind a can of Mountain Dew
Contact:

Post by eco » Mon Feb 13, 2006 5:14 pm

Yep. You can fix this by applying the wxVScrolledWindow parts of this patch to the version of wxWidgets you are using.

priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Post by priyank_bolia » Tue Feb 14, 2006 9:21 am

Can you post the particular part that handles that, rather than applying the whole patch, that modifies several parts.

eco
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 203
Joined: Tue Aug 31, 2004 7:06 pm
Location: Behind a can of Mountain Dew
Contact:

Post by eco » Tue Feb 14, 2006 5:43 pm

This should be it. The addition of Layout() fixes the window size resetting everything issue. There is also an issue while scrolling that is fixed by simplifying the code down to just the ScrollWindow() call.

Code: Select all

Index: include/wx/vscroll.h
===================================================================
RCS file: /pack/cvsroots/wxwidgets/wxWidgets/include/wx/vscroll.h,v
retrieving revision 1.18
diff -u -r1.18 vscroll.h
--- include/wx/vscroll.h	2005/09/23 12:48:50	1.18
+++ include/wx/vscroll.h	2006/01/24 22:17:21
@@ -2,9 +2,9 @@
 // Name:        include/wx/vscroll.h
 // Purpose:     wxVScrolledWindow: generalization of wxScrolledWindow
 // Author:      Vadim Zeitlin
-// Modified by:
+// Modified by: Brad Anderson
 // Created:     30.05.03
-// RCS-ID:      $Id: vscroll.h,v 1.18 2005/09/23 12:48:50 MR Exp $
+// RCS-ID:      $Id: vscroll.h,v 1.17 2005/04/05 22:43:41 VZ Exp $
 // Copyright:   (c) 2003 Vadim Zeitlin <[email protected]>
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -135,6 +135,8 @@
     // is kept for backwards compatibility
     size_t GetLastVisibleLine() const { return GetVisibleEnd() - 1; }
 
+    // layout the children (including the sizer if needed)
+    virtual bool Layout();
 
 protected:
     // this function must be overridden in the derived class and it should
@@ -212,6 +214,271 @@
     DECLARE_EVENT_TABLE()
     DECLARE_NO_COPY_CLASS(wxVScrolledWindow)
     DECLARE_ABSTRACT_CLASS(wxVScrolledWindow)
 };
 
 #endif // _WX_VSCROLL_H_
Index: src/generic/vscroll.cpp
===================================================================
RCS file: /pack/cvsroots/wxwidgets/wxWidgets/src/generic/vscroll.cpp,v
retrieving revision 1.20
diff -u -r1.20 vscroll.cpp
--- src/generic/vscroll.cpp	2005/09/23 12:53:31	1.20
+++ src/generic/vscroll.cpp	2006/01/24 22:37:50
@@ -2,9 +2,9 @@
 // Name:        src/generic/vscroll.cpp
 // Purpose:     wxVScrolledWindow implementation
 // Author:      Vadim Zeitlin
-// Modified by:
+// Modified by: Brad Anderson
 // Created:     30.05.03
-// RCS-ID:      $Id: vscroll.cpp,v 1.20 2005/09/23 12:53:31 MR Exp $
+// RCS-ID:      $Id: vscroll.cpp,v 1.19 2005/04/05 22:43:35 VZ Exp $
 // Copyright:   (c) 2003 Vadim Zeitlin <[email protected]>
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -263,6 +263,25 @@
     Refresh();
 }
 
+bool wxVScrolledWindow::Layout()
+{
+    if(GetSizer())
+    {
+        // adjust the sizer dimensions/position taking into account the
+        // virtual size and scrolled position of the window.
+
+        int y, w, h; // x is always 0 so no variable needed
+
+        y = -GetLinesHeight(0, GetFirstVisibleLine());
+        GetVirtualSize(&w, &h);
+        GetSizer()->SetDimension(0, y, w, h);
+        return true;
+    }
+
+    // fall back to default for LayoutConstraints
+    return wxPanel::Layout();
+}
+
 int wxVScrolledWindow::HitTest(wxCoord WXUNUSED(x), wxCoord y) const
 {
     const size_t lineMax = GetVisibleEnd();
@@ -303,8 +322,7 @@
 
 
     // remember the currently shown lines for the refresh code below
-    size_t lineFirstOld = GetVisibleBegin(),
-           lineLastOld = GetVisibleEnd();
+    size_t lineFirstOld = GetVisibleBegin();
 
     m_lineFirst = line;
 
@@ -312,21 +330,9 @@
     // the size of scrollbar thumb could have changed
     UpdateScrollbar();
 
+    // finally, scroll the actual window
+    ScrollWindow(0, GetLinesHeight(GetVisibleBegin(), lineFirstOld));
 
-    // finally refresh the display -- but only redraw as few lines as possible
-    // to avoid flicker
-    if ( GetVisibleBegin() >= lineLastOld ||
-            GetVisibleEnd() <= lineFirstOld )
-    {
-        // the simplest case: we don't have any old lines left, just redraw
-        // everything
-        Refresh();
-    }
-    else // overlap between the lines we showed before and should show now
-    {
-        ScrollWindow(0, GetLinesHeight(GetVisibleBegin(), lineFirstOld));
-    }
-
     return true;
 }
 
@@ -452,3 +458,931 @@
 }
 
 #endif

priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Post by priyank_bolia » Sat Feb 25, 2006 8:37 am

Scroll the scrollbar to the bottom, and then resize the application to big enough, so that scroll bars are not needed. But the scroll bars are still visible, click on them and the app hangs, can't resize for some time.

Post Reply