+
+// 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
+ // flag to try to call OnDraw() later
+ m_handler->ResetDrawnFlag();
+
+ event.Skip();
+}
+
+#ifdef __WXMSW__
+WXLRESULT
+wxGenericScrolledWindow::MSWWindowProc(WXUINT nMsg,
+ WXWPARAM wParam,
+ WXLPARAM lParam)
+{
+ WXLRESULT rc = wxPanel::MSWWindowProc(nMsg, wParam, lParam);
+
+#ifndef __WXWINCE__
+ // we need to process arrows ourselves for scrolling
+ if ( nMsg == WM_GETDLGCODE )
+ {
+ rc |= DLGC_WANTARROWS;
+ }
+#endif
+
+ return rc;
+}
+
+#endif // __WXMSW__