wxVScrolledWindow resize problem?
-
- wxWorld Domination!
- Posts: 1339
- Joined: Wed Aug 03, 2005 8:10 am
- Location: BANGALORE, INDIA
- Contact:
wxVScrolledWindow resize problem?
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.
-
- Filthy Rich wx Solver
- Posts: 203
- Joined: Tue Aug 31, 2004 7:06 pm
- Location: Behind a can of Mountain Dew
- Contact:
Yep. You can fix this by applying the wxVScrolledWindow parts of this patch to the version of wxWidgets you are using.
-
- wxWorld Domination!
- Posts: 1339
- Joined: Wed Aug 03, 2005 8:10 am
- Location: BANGALORE, INDIA
- Contact:
-
- Filthy Rich wx Solver
- Posts: 203
- Joined: Tue Aug 31, 2004 7:06 pm
- Location: Behind a can of Mountain Dew
- Contact:
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
-
- wxWorld Domination!
- Posts: 1339
- Joined: Wed Aug 03, 2005 8:10 am
- Location: BANGALORE, INDIA
- Contact: