-
- m_win->SetScrollbar(wxHORIZONTAL, m_xScrollPosition,
- linesPerPage, m_xScrollLines);
-
- // The amount by which we scroll when paging
- SetScrollPageSize(wxHORIZONTAL, linesPerPage);
-
- GetTargetSize(0, &h);
-
- if ( m_yScrollPixelsPerLine == 0 )
- {
- // scrolling is disabled
- m_yScrollLines = 0;
- m_yScrollPosition = 0;
- linesPerPage = 0;
- }
- else // might need scrolling
- {
- // Round up integer division to catch any "leftover" client space.
- const int hVirt = m_targetWindow->GetVirtualSize().GetHeight();
- m_yScrollLines = ( hVirt + m_yScrollPixelsPerLine - 1 ) / m_yScrollPixelsPerLine;
-
- // Calculate page size i.e. number of scroll units you get on the
- // current client window.
- linesPerPage = h / m_yScrollPixelsPerLine;
-
- // Special case. When client and virtual size are very close but
- // the client is big enough, kill scrollbar.
- if ((linesPerPage < m_yScrollLines) && (h >= hVirt)) ++linesPerPage;
-
- if (linesPerPage >= m_yScrollLines)
- {
- // we're big enough to not need scrolling
- linesPerPage =
- m_yScrollLines =
- m_yScrollPosition = 0;
- }
- else // we do need a scrollbar
- {
- if ( linesPerPage < 1 )
- linesPerPage = 1;
-
- // Correct position if greater than extent of canvas minus
- // the visible portion of it or if below zero
- const int posMax = m_yScrollLines - linesPerPage;
- if ( m_yScrollPosition > posMax )
- m_yScrollPosition = posMax;
- else if ( m_yScrollPosition < 0 )
- m_yScrollPosition = 0;
- }
- }
-
- m_win->SetScrollbar(wxVERTICAL, m_yScrollPosition,
- linesPerPage, m_yScrollLines);
-
- // The amount by which we scroll when paging
- SetScrollPageSize(wxVERTICAL, linesPerPage);
-
-
- // If a scrollbar (dis)appeared as a result of this, adjust them again.
- oldw = w;
- oldh = h;
-
- GetTargetSize( &w, &h );
- } while ( w != oldw || h != oldh );
-
-#ifdef __WXMOTIF__
- // Sorry, some Motif-specific code to implement a backing pixmap
- // for the wxRETAINED style. Implementing a backing store can't
- // be entirely generic because it relies on the wxWindowDC implementation
- // to duplicate X drawing calls for the backing pixmap.
-
- if ( m_targetWindow->GetWindowStyle() & wxRETAINED )
- {
- Display* dpy = XtDisplay((Widget)m_targetWindow->GetMainWidget());
-
- int totalPixelWidth = m_xScrollLines * m_xScrollPixelsPerLine;
- int totalPixelHeight = m_yScrollLines * m_yScrollPixelsPerLine;
- if (m_targetWindow->GetBackingPixmap() &&
- !((m_targetWindow->GetPixmapWidth() == totalPixelWidth) &&
- (m_targetWindow->GetPixmapHeight() == totalPixelHeight)))
- {
- XFreePixmap (dpy, (Pixmap) m_targetWindow->GetBackingPixmap());
- m_targetWindow->SetBackingPixmap((WXPixmap) 0);
- }
-
- if (!m_targetWindow->GetBackingPixmap() &&
- (m_xScrollLines != 0) && (m_yScrollLines != 0))
- {
- int depth = wxDisplayDepth();
- m_targetWindow->SetPixmapWidth(totalPixelWidth);
- m_targetWindow->SetPixmapHeight(totalPixelHeight);
- m_targetWindow->SetBackingPixmap((WXPixmap) XCreatePixmap (dpy, RootWindow (dpy, DefaultScreen (dpy)),
- m_targetWindow->GetPixmapWidth(), m_targetWindow->GetPixmapHeight(), depth));
- }
-