// The above should arguably be deprecated, this however we still need.
- m_targetWindow->SetVirtualSize( w, h );
+ // take care not to set 0 virtual size, 0 means that we don't have any
+ // scrollbars and hence we should use the real size instead of the virtual
+ // one which is indicated by using wxDefaultCoord
+ m_targetWindow->SetVirtualSize( w ? w : wxDefaultCoord,
+ h ? h : wxDefaultCoord);
if (do_refresh && !noRefresh)
m_targetWindow->Refresh(true, GetScrollRect());
void wxScrollHelper::DoSetTargetWindow(wxWindow *target)
{
m_targetWindow = target;
+#ifdef __WXMAC__
+ target->MacSetClipChildren( true ) ;
+#endif
// install the event handler which will intercept the events we're
// interested in (but only do it for our real window, not the target window
// it here for now but it would be better to ensure that all ports
// generate EVT_SIZE when scrollbars [dis]appear, emulating it if
// necessary, and remove it later
+ // JACS: Stop potential infinite loop by limiting number of iterations
+ int iterationCount = 0;
+ const int iterationMax = 5;
do
{
+ iterationCount ++;
+
GetTargetSize(&w, 0);
// scroll lines per page: if 0, no scrolling is needed
oldh = h;
GetTargetSize( &w, &h );
- } while ( w != oldw || h != oldh );
+ } while ( (w != oldw || h != oldh) && (iterationCount < iterationMax) );
#ifdef __WXMOTIF__
// Sorry, some Motif-specific code to implement a backing pixmap
const wxString& name)
{
m_targetWindow = this;
+#ifdef __WXMAC__
+ MacSetClipChildren( true ) ;
+#endif
bool ok = wxPanel::Create(parent, id, pos, size, style|wxHSCROLL|wxVSCROLL, name);
Layout();
}
+// wxWindow's GetBestVirtualSize returns the actual window size,
+// whereas we want to return the virtual size
+wxSize wxGenericScrolledWindow::GetBestVirtualSize() const
+{
+ wxSize clientSize( GetClientSize() );
+ if (GetSizer())
+ {
+ wxSize minSize( GetSizer()->CalcMin() );
+
+ return wxSize( wxMax( clientSize.x, minSize.x ), wxMax( clientSize.y, minSize.y ) );
+ }
+ else
+ return clientSize;
+}
+
+// return the size best suited for the current window
+// (this isn't a virtual size, this is a sensible size for the window)
+wxSize wxGenericScrolledWindow::DoGetBestSize() const
+{
+ wxSize best;
+
+ if ( GetSizer() )
+ {
+ wxSize b = GetSizer()->GetMinSize();
+
+ // Only use the content to set the window size in the direction
+ // where there's no scrolling; otherwise we're going to get a huge
+ // window in the direction in which scrolling is enabled
+ int ppuX, ppuY;
+ GetScrollPixelsPerUnit(& ppuX, & ppuY);
+
+ wxSize minSize;
+ if ( GetMinSize().IsFullySpecified() )
+ minSize = GetMinSize();
+ else
+ minSize = GetSize();
+
+ if (ppuX > 0)
+ b.x = minSize.x;
+ if (ppuY > 0)
+ b.y = minSize.y;
+ best = b;
+ }
+ else
+ return wxWindow::DoGetBestSize();
+
+ // Add any difference between size and client size
+ wxSize diff = GetSize() - GetClientSize();
+ best.x += wxMax(0, diff.x);
+ best.y += wxMax(0, diff.y);
+
+ return best;
+}
+
void wxGenericScrolledWindow::OnPaint(wxPaintEvent& event)
{
// the user code didn't really draw the window if we got here, so set this