Give wxScrolledWindow its own Layout method that takes into account

the virtual size and scrolled offset of the window.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14597 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2002-03-15 00:21:47 +00:00
parent 5057e65939
commit 3048629765
6 changed files with 68 additions and 15 deletions

View File

@@ -66,6 +66,9 @@ public:
virtual void PrepareDC(wxDC& dc) { DoPrepareDC(dc); } virtual void PrepareDC(wxDC& dc) { DoPrepareDC(dc); }
// lay out the window and its children
virtual bool Layout();
protected: protected:
// this is needed for wxEVT_PAINT processing hack described in // this is needed for wxEVT_PAINT processing hack described in
// wxScrollHelperEvtHandler::ProcessEvent() // wxScrollHelperEvtHandler::ProcessEvent()

View File

@@ -108,6 +108,9 @@ public:
// automatically change the origin according to the scroll position. // automatically change the origin according to the scroll position.
virtual void PrepareDC(wxDC& dc); virtual void PrepareDC(wxDC& dc);
// lay out the window and its children
virtual bool Layout();
// Adjust the scrollbars // Adjust the scrollbars
virtual void AdjustScrollbars(); virtual void AdjustScrollbars();

View File

@@ -108,6 +108,9 @@ public:
// automatically change the origin according to the scroll position. // automatically change the origin according to the scroll position.
virtual void PrepareDC(wxDC& dc); virtual void PrepareDC(wxDC& dc);
// lay out the window and its children
virtual bool Layout();
// Adjust the scrollbars // Adjust the scrollbars
virtual void AdjustScrollbars(); virtual void AdjustScrollbars();

View File

@@ -836,11 +836,6 @@ void wxScrollHelper::CalcUnscrolledPosition(int x, int y, int *xx, int *yy) cons
// Default OnSize resets scrollbars, if any // Default OnSize resets scrollbars, if any
void wxScrollHelper::HandleOnSize(wxSizeEvent& WXUNUSED(event)) void wxScrollHelper::HandleOnSize(wxSizeEvent& WXUNUSED(event))
{ {
#if wxUSE_CONSTRAINTS
if ( m_win->GetAutoLayout() )
m_win->Layout();
#endif
AdjustScrollbars(); AdjustScrollbars();
} }
@@ -1109,6 +1104,21 @@ wxGenericScrolledWindow::~wxGenericScrolledWindow()
{ {
} }
bool wxGenericScrolledWindow::Layout()
{
if (GetSizer())
{
// Take into account the virtual size and scrolled position of the window
int x, y, w, h;
CalcScrolledPosition(0,0, &x,&y);
GetVirtualSize(&w, &h);
GetSizer()->SetDimension(x, y, w, h);
return TRUE;
}
else
return wxPanel::Layout(); // fall back to default for LayoutConstraints
}
void wxGenericScrolledWindow::OnPaint(wxPaintEvent& event) void wxGenericScrolledWindow::OnPaint(wxPaintEvent& event)
{ {
// the user code didn't really draw the window if we got here, so set this // the user code didn't really draw the window if we got here, so set this

View File

@@ -33,6 +33,7 @@
#include "wx/scrolwin.h" #include "wx/scrolwin.h"
#include "wx/panel.h" #include "wx/panel.h"
#include "wx/sizer.h"
#include "wx/gtk/private.h" #include "wx/gtk/private.h"
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
@@ -760,6 +761,22 @@ void wxScrolledWindow::GtkVDisconnectEvent()
(GtkSignalFunc) gtk_scrolled_window_vscroll_callback, (gpointer) this ); (GtkSignalFunc) gtk_scrolled_window_vscroll_callback, (gpointer) this );
} }
bool wxScrolledWindow::Layout()
{
if (GetSizer())
{
// Take into account the virtual size and scrolled position of the window
int x, y, w, h;
CalcScrolledPosition(0,0, &x,&y);
GetVirtualSize(&w, &h);
GetSizer()->SetDimension(x, y, w, h);
return TRUE;
}
else
return wxPanel::Layout(); // fall back to default for LayoutConstraints
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// event handlers // event handlers
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -33,6 +33,7 @@
#include "wx/scrolwin.h" #include "wx/scrolwin.h"
#include "wx/panel.h" #include "wx/panel.h"
#include "wx/sizer.h"
#include "wx/gtk/private.h" #include "wx/gtk/private.h"
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
@@ -760,6 +761,22 @@ void wxScrolledWindow::GtkVDisconnectEvent()
(GtkSignalFunc) gtk_scrolled_window_vscroll_callback, (gpointer) this ); (GtkSignalFunc) gtk_scrolled_window_vscroll_callback, (gpointer) this );
} }
bool wxScrolledWindow::Layout()
{
if (GetSizer())
{
// Take into account the virtual size and scrolled position of the window
int x, y, w, h;
CalcScrolledPosition(0,0, &x,&y);
GetVirtualSize(&w, &h);
GetSizer()->SetDimension(x, y, w, h);
return TRUE;
}
else
return wxPanel::Layout(); // fall back to default for LayoutConstraints
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// event handlers // event handlers
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------