home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / wxos2240.zip / wxWindows-2.4.0 / src / generic / scrlwing.cpp < prev    next >
C/C++ Source or Header  |  2002-12-28  |  39KB  |  1,250 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name:        generic/scrolwin.cpp
  3. // Purpose:     wxGenericScrolledWindow implementation
  4. // Author:      Julian Smart
  5. // Modified by: Vadim Zeitlin on 31.08.00: wxScrollHelper allows to implement.
  6. //              Ron Lee on 10.4.02:  virtual size / auto scrollbars et al.
  7. // Created:     01/02/97
  8. // RCS-ID:      $Id: scrlwing.cpp,v 1.28.2.4 2002/12/27 14:04:10 JS Exp $
  9. // Copyright:   (c) wxWindows team
  10. // Licence:     wxWindows license
  11. /////////////////////////////////////////////////////////////////////////////
  12.  
  13. // ============================================================================
  14. // declarations
  15. // ============================================================================
  16.  
  17. // ----------------------------------------------------------------------------
  18. // headers
  19. // ----------------------------------------------------------------------------
  20.  
  21. #ifdef __GNUG__
  22.     #pragma implementation "genscrolwin.h"
  23. #endif
  24.  
  25. #ifdef __VMS
  26. #define XtDisplay XTDISPLAY
  27. #endif
  28.  
  29. // For compilers that support precompilation, includes "wx.h".
  30. #include "wx/wxprec.h"
  31.  
  32. #ifdef __BORLANDC__
  33.     #pragma hdrstop
  34. #endif
  35.  
  36. #if !defined(__WXGTK__) || defined(__WXUNIVERSAL__)
  37.  
  38. #include "wx/utils.h"
  39. #include "wx/dcclient.h"
  40.  
  41. #include "wx/scrolwin.h"
  42. #include "wx/panel.h"
  43. #include "wx/timer.h"
  44. #include "wx/sizer.h"
  45.  
  46. #ifdef __WXMSW__
  47.     #include <windows.h> // for DLGC_WANTARROWS
  48. #endif
  49.  
  50. #ifdef __WXMOTIF__
  51. // For wxRETAINED implementation
  52. #ifdef __VMS__ //VMS's Xm.h is not (yet) compatible with C++
  53.                //This code switches off the compiler warnings
  54. # pragma message disable nosimpint
  55. #endif
  56. #include <Xm/Xm.h>
  57. #ifdef __VMS__
  58. # pragma message enable nosimpint
  59. #endif
  60. #endif
  61.  
  62. IMPLEMENT_CLASS(wxScrolledWindow, wxGenericScrolledWindow)
  63.  
  64. // ----------------------------------------------------------------------------
  65. // wxScrollHelperEvtHandler: intercept the events from the window and forward
  66. // them to wxScrollHelper
  67. // ----------------------------------------------------------------------------
  68.  
  69. class WXDLLEXPORT wxScrollHelperEvtHandler : public wxEvtHandler
  70. {
  71. public:
  72.     wxScrollHelperEvtHandler(wxScrollHelper *scrollHelper)
  73.     {
  74.         m_scrollHelper = scrollHelper;
  75.     }
  76.  
  77.     virtual bool ProcessEvent(wxEvent& event);
  78.  
  79.     void ResetDrawnFlag() { m_hasDrawnWindow = FALSE; }
  80.  
  81. private:
  82.     wxScrollHelper *m_scrollHelper;
  83.  
  84.     bool m_hasDrawnWindow;
  85. };
  86.  
  87. // ----------------------------------------------------------------------------
  88. // wxAutoScrollTimer: the timer used to generate a stream of scroll events when
  89. // a captured mouse is held outside the window
  90. // ----------------------------------------------------------------------------
  91.  
  92. class wxAutoScrollTimer : public wxTimer
  93. {
  94. public:
  95.     wxAutoScrollTimer(wxWindow *winToScroll, wxScrollHelper *scroll,
  96.                       wxEventType eventTypeToSend,
  97.                       int pos, int orient);
  98.  
  99.     virtual void Notify();
  100.  
  101. private:
  102.     wxWindow *m_win;
  103.     wxScrollHelper *m_scrollHelper;
  104.     wxEventType m_eventType;
  105.     int m_pos,
  106.         m_orient;
  107. };
  108.  
  109. // ============================================================================
  110. // implementation
  111. // ============================================================================
  112.  
  113. // ----------------------------------------------------------------------------
  114. // wxAutoScrollTimer
  115. // ----------------------------------------------------------------------------
  116.  
  117. wxAutoScrollTimer::wxAutoScrollTimer(wxWindow *winToScroll,
  118.                                      wxScrollHelper *scroll,
  119.                                      wxEventType eventTypeToSend,
  120.                                      int pos, int orient)
  121. {
  122.     m_win = winToScroll;
  123.     m_scrollHelper = scroll;
  124.     m_eventType = eventTypeToSend;
  125.     m_pos = pos;
  126.     m_orient = orient;
  127. }
  128.  
  129. void wxAutoScrollTimer::Notify()
  130. {
  131.     // only do all this as long as the window is capturing the mouse
  132.     if ( wxWindow::GetCapture() != m_win )
  133.     {
  134.         Stop();
  135.     }
  136.     else // we still capture the mouse, continue generating events
  137.     {
  138.         // first scroll the window if we are allowed to do it
  139.         wxScrollWinEvent event1(m_eventType, m_pos, m_orient);
  140.         event1.SetEventObject(m_win);
  141.         if ( m_scrollHelper->SendAutoScrollEvents(event1) &&
  142.                 m_win->GetEventHandler()->ProcessEvent(event1) )
  143.         {
  144.             // and then send a pseudo mouse-move event to refresh the selection
  145.             wxMouseEvent event2(wxEVT_MOTION);
  146.             wxGetMousePosition(&event2.m_x, &event2.m_y);
  147.  
  148.             // the mouse event coordinates should be client, not screen as
  149.             // returned by wxGetMousePosition
  150.             wxWindow *parentTop = m_win;
  151.             while ( parentTop->GetParent() )
  152.                 parentTop = parentTop->GetParent();
  153.             wxPoint ptOrig = parentTop->GetPosition();
  154.             event2.m_x -= ptOrig.x;
  155.             event2.m_y -= ptOrig.y;
  156.  
  157.             event2.SetEventObject(m_win);
  158.  
  159.             // FIXME: we don't fill in the other members - ok?
  160.  
  161.             m_win->GetEventHandler()->ProcessEvent(event2);
  162.         }
  163.         else // can't scroll further, stop
  164.         {
  165.             Stop();
  166.         }
  167.     }
  168. }
  169.  
  170. // ----------------------------------------------------------------------------
  171. // wxScrollHelperEvtHandler
  172. // ----------------------------------------------------------------------------
  173.  
  174. bool wxScrollHelperEvtHandler::ProcessEvent(wxEvent& event)
  175. {
  176.     wxEventType evType = event.GetEventType();
  177.  
  178.     // the explanation of wxEVT_PAINT processing hack: for historic reasons
  179.     // there are 2 ways to process this event in classes deriving from
  180.     // wxScrolledWindow. The user code may
  181.     //
  182.     //  1. override wxScrolledWindow::OnDraw(dc)
  183.     //  2. define its own OnPaint() handler
  184.     //
  185.     // In addition, in wxUniversal wxWindow defines OnPaint() itself and
  186.     // always processes the draw event, so we can't just try the window
  187.     // OnPaint() first and call our HandleOnPaint() if it doesn't process it
  188.     // (the latter would never be called in wxUniversal).
  189.     //
  190.     // So the solution is to have a flag telling us whether the user code drew
  191.     // anything in the window. We set it to true here but reset it to false in
  192.     // wxScrolledWindow::OnPaint() handler (which wouldn't be called if the
  193.     // user code defined OnPaint() in the derived class)
  194.     m_hasDrawnWindow = TRUE;
  195.  
  196.     // pass it on to the real handler
  197.     bool processed = wxEvtHandler::ProcessEvent(event);
  198.  
  199.     // always process the size events ourselves, even if the user code handles
  200.     // them as well, as we need to AdjustScrollbars()
  201.     //
  202.     // NB: it is important to do it after processing the event in the normal
  203.     //     way as HandleOnSize() may generate a wxEVT_SIZE itself if the
  204.     //     scrollbar[s] (dis)appear and it should be seen by the user code
  205.     //     after this one
  206.     if ( evType == wxEVT_SIZE )
  207.     {
  208.         m_scrollHelper->HandleOnSize((wxSizeEvent &)event);
  209.  
  210.         return TRUE;
  211.     }
  212.  
  213.     if ( processed )
  214.     {
  215.         // normally, nothing more to do here - except if it was a paint event
  216.         // which wasn't really processed, then we'll try to call our
  217.         // OnDraw() below (from HandleOnPaint)
  218.         if ( m_hasDrawnWindow )
  219.         {
  220.             return TRUE;
  221.         }
  222.     }
  223.  
  224.     // reset the skipped flag to FALSE as it might have been set to TRUE in
  225.     // ProcessEvent() above
  226.     event.Skip(FALSE);
  227.  
  228.     if ( evType == wxEVT_PAINT )
  229.     {
  230.         m_scrollHelper->HandleOnPaint((wxPaintEvent &)event);
  231.         return TRUE;
  232.     }
  233.  
  234.     if ( evType == wxEVT_SCROLLWIN_TOP ||
  235.          evType == wxEVT_SCROLLWIN_BOTTOM ||
  236.          evType == wxEVT_SCROLLWIN_LINEUP ||
  237.          evType == wxEVT_SCROLLWIN_LINEDOWN ||
  238.          evType == wxEVT_SCROLLWIN_PAGEUP ||
  239.          evType == wxEVT_SCROLLWIN_PAGEDOWN ||
  240.          evType == wxEVT_SCROLLWIN_THUMBTRACK ||
  241.          evType == wxEVT_SCROLLWIN_THUMBRELEASE )
  242.     {
  243.             m_scrollHelper->HandleOnScroll((wxScrollWinEvent &)event);
  244.             return !event.GetSkipped();
  245.     }
  246.  
  247.     if ( evType == wxEVT_ENTER_WINDOW )
  248.     {
  249.         m_scrollHelper->HandleOnMouseEnter((wxMouseEvent &)event);
  250.     }
  251.     else if ( evType == wxEVT_LEAVE_WINDOW )
  252.     {
  253.         m_scrollHelper->HandleOnMouseLeave((wxMouseEvent &)event);
  254.     }
  255. #if wxUSE_MOUSEWHEEL
  256.     else if ( evType == wxEVT_MOUSEWHEEL )
  257.     {
  258.         m_scrollHelper->HandleOnMouseWheel((wxMouseEvent &)event);
  259.     }
  260. #endif // wxUSE_MOUSEWHEEL
  261.     else if ( evType == wxEVT_CHAR )
  262.     {
  263.         m_scrollHelper->HandleOnChar((wxKeyEvent &)event);
  264.         return !event.GetSkipped();
  265.     }
  266.  
  267.     return FALSE;
  268. }
  269.  
  270. // ----------------------------------------------------------------------------
  271. // wxScrollHelper construction
  272. // ----------------------------------------------------------------------------
  273.  
  274. wxScrollHelper::wxScrollHelper(wxWindow *win)
  275. {
  276.     m_xScrollPixelsPerLine =
  277.     m_yScrollPixelsPerLine =
  278.     m_xScrollPosition =
  279.     m_yScrollPosition =
  280.     m_xScrollLines =
  281.     m_yScrollLines =
  282.     m_xScrollLinesPerPage =
  283.     m_yScrollLinesPerPage = 0;
  284.  
  285.     m_xScrollingEnabled =
  286.     m_yScrollingEnabled = TRUE;
  287.  
  288.     m_scaleX =
  289.     m_scaleY = 1.0;
  290. #if wxUSE_MOUSEWHEEL
  291.     m_wheelRotation = 0;
  292. #endif
  293.  
  294.     m_win =
  295.     m_targetWindow = (wxWindow *)NULL;
  296.  
  297.     m_timerAutoScroll = (wxTimer *)NULL;
  298.  
  299.     m_handler = NULL;
  300.  
  301.     if ( win )
  302.         SetWindow(win);
  303. }
  304.  
  305. wxScrollHelper::~wxScrollHelper()
  306. {
  307.     StopAutoScrolling();
  308.  
  309.     DeleteEvtHandler();
  310. }
  311.  
  312. // ----------------------------------------------------------------------------
  313. // setting scrolling parameters
  314. // ----------------------------------------------------------------------------
  315.  
  316. void wxScrollHelper::SetScrollbars(int pixelsPerUnitX,
  317.                                    int pixelsPerUnitY,
  318.                                    int noUnitsX,
  319.                                    int noUnitsY,
  320.                                    int xPos,
  321.                                    int yPos,
  322.                                    bool noRefresh)
  323. {
  324.     int xpos, ypos;
  325.  
  326.     CalcUnscrolledPosition(xPos, yPos, &xpos, &ypos);
  327.     bool do_refresh =
  328.     (
  329.       (noUnitsX != 0 && m_xScrollLines == 0) ||
  330.       (noUnitsX < m_xScrollLines && xpos > pixelsPerUnitX * noUnitsX) ||
  331.  
  332.       (noUnitsY != 0 && m_yScrollLines == 0) ||
  333.       (noUnitsY < m_yScrollLines && ypos > pixelsPerUnitY * noUnitsY) ||
  334.       (xPos != m_xScrollPosition) ||
  335.       (yPos != m_yScrollPosition)
  336.     );
  337.  
  338.     m_xScrollPixelsPerLine = pixelsPerUnitX;
  339.     m_yScrollPixelsPerLine = pixelsPerUnitY;
  340.     m_xScrollPosition = xPos;
  341.     m_yScrollPosition = yPos;
  342.  
  343.     // For better backward compatibility we set persisting limits
  344.     // here not just the size.  It makes SetScrollbars 'sticky'
  345.     // emulating the old non-autoscroll behaviour.
  346.  
  347.     wxSize sz = m_targetWindow->GetClientSize();
  348. #if 1
  349.     int x = wxMax(noUnitsX * pixelsPerUnitX, sz.x);
  350.     int y = wxMax(noUnitsY * pixelsPerUnitY, sz.y);
  351. #else
  352.     int x = noUnitsX * pixelsPerUnitX;
  353.     int y = noUnitsY * pixelsPerUnitY;
  354. #endif
  355.     m_targetWindow->SetVirtualSizeHints( x, y );
  356.  
  357.     // The above should arguably be deprecated, this however we still need.
  358.  
  359.     m_targetWindow->SetVirtualSize( x, y );
  360.  
  361.     if (do_refresh && !noRefresh)
  362.         m_targetWindow->Refresh(TRUE, GetRect());
  363.  
  364. #ifdef __WXMAC__
  365.     m_targetWindow->MacUpdateImmediately() ;
  366. #endif
  367. }
  368.  
  369. // ----------------------------------------------------------------------------
  370. // [target] window handling
  371. // ----------------------------------------------------------------------------
  372.  
  373. void wxScrollHelper::DeleteEvtHandler()
  374. {
  375.     // search for m_handler in the handler list
  376.     if ( m_win && m_handler )
  377.     {
  378.         if ( m_win->RemoveEventHandler(m_handler) )
  379.         {
  380.             delete m_handler;
  381.         }
  382.         //else: something is very wrong, so better [maybe] leak memory than
  383.         //      risk a crash because of double deletion
  384.  
  385.         m_handler = NULL;
  386.     }
  387. }
  388.  
  389. void wxScrollHelper::SetWindow(wxWindow *win)
  390. {
  391.     wxCHECK_RET( win, _T("wxScrollHelper needs a window to scroll") );
  392.  
  393.     m_win = win;
  394.  
  395.     // by default, the associated window is also the target window
  396.     DoSetTargetWindow(win);
  397. }
  398.  
  399. void wxScrollHelper::DoSetTargetWindow(wxWindow *target)
  400. {
  401.     m_targetWindow = target;
  402.  
  403.     // install the event handler which will intercept the events we're
  404.     // interested in (but only do it for our real window, not the target window
  405.     // which we scroll - we don't need to hijack its events)
  406.     if ( m_targetWindow == m_win )
  407.     {
  408.         // if we already have a handler, delete it first
  409.         DeleteEvtHandler();
  410.  
  411.         m_handler = new wxScrollHelperEvtHandler(this);
  412.         m_targetWindow->PushEventHandler(m_handler);
  413.     }
  414. }
  415.  
  416. void wxScrollHelper::SetTargetWindow(wxWindow *target)
  417. {
  418.     wxCHECK_RET( target, wxT("target window must not be NULL") );
  419.  
  420.     if ( target == m_targetWindow )
  421.         return;
  422.  
  423.     DoSetTargetWindow(target);
  424. }
  425.  
  426. wxWindow *wxScrollHelper::GetTargetWindow() const
  427. {
  428.     return m_targetWindow;
  429. }
  430.  
  431. // ----------------------------------------------------------------------------
  432. // scrolling implementation itself
  433. // ----------------------------------------------------------------------------
  434.  
  435. void wxScrollHelper::HandleOnScroll(wxScrollWinEvent& event)
  436. {
  437.     int nScrollInc = CalcScrollInc(event);
  438.     if ( nScrollInc == 0 )
  439.     {
  440.         // can't scroll further
  441.         event.Skip();
  442.  
  443.         return;
  444.     }
  445.  
  446.     int orient = event.GetOrientation();
  447.     if (orient == wxHORIZONTAL)
  448.     {
  449.         m_xScrollPosition += nScrollInc;
  450.         m_win->SetScrollPos(wxHORIZONTAL, m_xScrollPosition);
  451.     }
  452.     else
  453.     {
  454.         m_yScrollPosition += nScrollInc;
  455.         m_win->SetScrollPos(wxVERTICAL, m_yScrollPosition);
  456.     }
  457.  
  458.     bool needsRefresh = FALSE;
  459.     int dx = 0,
  460.         dy = 0;
  461.     if (orient == wxHORIZONTAL)
  462.     {
  463.        if ( m_xScrollingEnabled )
  464.        {
  465.            dx = -m_xScrollPixelsPerLine * nScrollInc;
  466.        }
  467.        else
  468.        {
  469.            needsRefresh = TRUE;
  470.        }
  471.     }
  472.     else
  473.     {
  474.         if ( m_yScrollingEnabled )
  475.         {
  476.             dy = -m_yScrollPixelsPerLine * nScrollInc;
  477.         }
  478.         else
  479.         {
  480.             needsRefresh = TRUE;
  481.         }
  482.     }
  483.  
  484.     if ( needsRefresh )
  485.     {
  486.         m_targetWindow->Refresh(TRUE, GetRect());
  487.     }
  488.     else
  489.     {
  490.         m_targetWindow->ScrollWindow(dx, dy, GetRect());
  491.     }
  492.  
  493. #ifdef __WXMAC__
  494.     m_targetWindow->MacUpdateImmediately() ;
  495. #endif
  496. }
  497.  
  498. int wxScrollHelper::CalcScrollInc(wxScrollWinEvent& event)
  499. {
  500.     int pos = event.GetPosition();
  501.     int orient = event.GetOrientation();
  502.  
  503.     int nScrollInc = 0;
  504.     if (event.GetEventType() == wxEVT_SCROLLWIN_TOP)
  505.     {
  506.             if (orient == wxHORIZONTAL)
  507.                 nScrollInc = - m_xScrollPosition;
  508.             else
  509.                 nScrollInc = - m_yScrollPosition;
  510.     } else
  511.     if (event.GetEventType() == wxEVT_SCROLLWIN_BOTTOM)
  512.     {
  513.             if (orient == wxHORIZONTAL)
  514.                 nScrollInc = m_xScrollLines - m_xScrollPosition;
  515.             else
  516.                 nScrollInc = m_yScrollLines - m_yScrollPosition;
  517.     } else
  518.     if (event.GetEventType() == wxEVT_SCROLLWIN_LINEUP)
  519.     {
  520.             nScrollInc = -1;
  521.     } else
  522.     if (event.GetEventType() == wxEVT_SCROLLWIN_LINEDOWN)
  523.     {
  524.             nScrollInc = 1;
  525.     } else
  526.     if (event.GetEventType() == wxEVT_SCROLLWIN_PAGEUP)
  527.     {
  528.             if (orient == wxHORIZONTAL)
  529.                 nScrollInc = -GetScrollPageSize(wxHORIZONTAL);
  530.             else
  531.                 nScrollInc = -GetScrollPageSize(wxVERTICAL);
  532.     } else
  533.     if (event.GetEventType() == wxEVT_SCROLLWIN_PAGEDOWN)
  534.     {
  535.             if (orient == wxHORIZONTAL)
  536.                 nScrollInc = GetScrollPageSize(wxHORIZONTAL);
  537.             else
  538.                 nScrollInc = GetScrollPageSize(wxVERTICAL);
  539.     } else
  540.     if ((event.GetEventType() == wxEVT_SCROLLWIN_THUMBTRACK) ||
  541.         (event.GetEventType() == wxEVT_SCROLLWIN_THUMBRELEASE))
  542.     {
  543.             if (orient == wxHORIZONTAL)
  544.                 nScrollInc = pos - m_xScrollPosition;
  545.             else
  546.                 nScrollInc = pos - m_yScrollPosition;
  547.     }
  548.  
  549.     if (orient == wxHORIZONTAL)
  550.     {
  551.         if (m_xScrollPixelsPerLine > 0)
  552.         {
  553.             int w, h;
  554.             GetTargetSize(&w, &h);
  555.  
  556.             int nMaxWidth = m_xScrollLines*m_xScrollPixelsPerLine;
  557.             int noPositions = (int) ( ((nMaxWidth - w)/(double)m_xScrollPixelsPerLine) + 0.5 );
  558.             if (noPositions < 0)
  559.                 noPositions = 0;
  560.  
  561.             if ( (m_xScrollPosition + nScrollInc) < 0 )
  562.                 nScrollInc = -m_xScrollPosition; // As -ve as we can go
  563.             else if ( (m_xScrollPosition + nScrollInc) > noPositions )
  564.                 nScrollInc = noPositions - m_xScrollPosition; // As +ve as we can go
  565.         }
  566.         else
  567.             m_targetWindow->Refresh(TRUE, GetRect());
  568.     }
  569.     else
  570.     {
  571.         if (m_yScrollPixelsPerLine > 0)
  572.         {
  573.             int w, h;
  574.             GetTargetSize(&w, &h);
  575.  
  576.             int nMaxHeight = m_yScrollLines*m_yScrollPixelsPerLine;
  577.             int noPositions = (int) ( ((nMaxHeight - h)/(double)m_yScrollPixelsPerLine) + 0.5 );
  578.             if (noPositions < 0)
  579.                 noPositions = 0;
  580.  
  581.             if ( (m_yScrollPosition + nScrollInc) < 0 )
  582.                 nScrollInc = -m_yScrollPosition; // As -ve as we can go
  583.             else if ( (m_yScrollPosition + nScrollInc) > noPositions )
  584.                 nScrollInc = noPositions - m_yScrollPosition; // As +ve as we can go
  585.         }
  586.         else
  587.             m_targetWindow->Refresh(TRUE, GetRect());
  588.     }
  589.  
  590.     return nScrollInc;
  591. }
  592.  
  593. // Adjust the scrollbars - new version.
  594. void wxScrollHelper::AdjustScrollbars()
  595. {
  596. #ifdef __WXMAC__
  597.     m_targetWindow->MacUpdateImmediately();
  598. #endif
  599.  
  600.     int w = 0, h = 0;
  601.     int oldw, oldh;
  602.  
  603.     int oldXScroll = m_xScrollPosition;
  604.     int oldYScroll = m_yScrollPosition;
  605.  
  606.     do {
  607.         GetTargetSize(&w, 0);
  608.  
  609.         if (m_xScrollPixelsPerLine == 0)
  610.         {
  611.             m_xScrollLines = 0;
  612.             m_xScrollPosition = 0;
  613.             m_win->SetScrollbar (wxHORIZONTAL, 0, 0, 0, FALSE);
  614.         }
  615.         else
  616.         {
  617.             m_xScrollLines = m_targetWindow->GetVirtualSize().GetWidth() / m_xScrollPixelsPerLine;
  618.  
  619.             // Calculate page size i.e. number of scroll units you get on the
  620.             // current client window
  621.             int noPagePositions = (int) ( (w/(double)m_xScrollPixelsPerLine) + 0.5 );
  622.             if (noPagePositions < 1) noPagePositions = 1;
  623.             if ( noPagePositions > m_xScrollLines )
  624.                 noPagePositions = m_xScrollLines;
  625.  
  626.             // Correct position if greater than extent of canvas minus
  627.             // the visible portion of it or if below zero
  628.             m_xScrollPosition = wxMin( m_xScrollLines - noPagePositions, m_xScrollPosition);
  629.             m_xScrollPosition = wxMax( 0, m_xScrollPosition );
  630.  
  631.             m_win->SetScrollbar(wxHORIZONTAL, m_xScrollPosition, noPagePositions, m_xScrollLines);
  632.             // The amount by which we scroll when paging
  633.             SetScrollPageSize(wxHORIZONTAL, noPagePositions);
  634.         }
  635.  
  636.         GetTargetSize(0, &h);
  637.  
  638.         if (m_yScrollPixelsPerLine == 0)
  639.         {
  640.             m_yScrollLines = 0;
  641.             m_yScrollPosition = 0;
  642.             m_win->SetScrollbar (wxVERTICAL, 0, 0, 0, FALSE);
  643.         }
  644.         else
  645.         {
  646.             m_yScrollLines = m_targetWindow->GetVirtualSize().GetHeight() / m_yScrollPixelsPerLine;
  647.  
  648.             // Calculate page size i.e. number of scroll units you get on the
  649.             // current client window
  650.             int noPagePositions = (int) ( (h/(double)m_yScrollPixelsPerLine) + 0.5 );
  651.             if (noPagePositions < 1) noPagePositions = 1;
  652.             if ( noPagePositions > m_yScrollLines )
  653.                 noPagePositions = m_yScrollLines;
  654.  
  655.             // Correct position if greater than extent of canvas minus
  656.             // the visible portion of it or if below zero
  657.             m_yScrollPosition = wxMin( m_yScrollLines - noPagePositions, m_yScrollPosition );
  658.             m_yScrollPosition = wxMax( 0, m_yScrollPosition );
  659.  
  660.             m_win->SetScrollbar(wxVERTICAL, m_yScrollPosition, noPagePositions, m_yScrollLines);
  661.             // The amount by which we scroll when paging
  662.             SetScrollPageSize(wxVERTICAL, noPagePositions);
  663.         }
  664.  
  665.         // If a scrollbar (dis)appeared as a result of this, adjust them again.
  666.  
  667.         oldw = w;
  668.         oldh = h;
  669.  
  670.         GetTargetSize( &w, &h );
  671.     } while ( w != oldw && h != oldh );
  672.  
  673. #ifdef __WXMOTIF__
  674.     // Sorry, some Motif-specific code to implement a backing pixmap
  675.     // for the wxRETAINED style. Implementing a backing store can't
  676.     // be entirely generic because it relies on the wxWindowDC implementation
  677.     // to duplicate X drawing calls for the backing pixmap.
  678.  
  679.     if ( m_targetWindow->GetWindowStyle() & wxRETAINED )
  680.     {
  681.         Display* dpy = XtDisplay((Widget)m_targetWindow->GetMainWidget());
  682.  
  683.         int totalPixelWidth = m_xScrollLines * m_xScrollPixelsPerLine;
  684.         int totalPixelHeight = m_yScrollLines * m_yScrollPixelsPerLine;
  685.         if (m_targetWindow->GetBackingPixmap() &&
  686.            !((m_targetWindow->GetPixmapWidth() == totalPixelWidth) &&
  687.              (m_targetWindow->GetPixmapHeight() == totalPixelHeight)))
  688.         {
  689.             XFreePixmap (dpy, (Pixmap) m_targetWindow->GetBackingPixmap());
  690.             m_targetWindow->SetBackingPixmap((WXPixmap) 0);
  691.         }
  692.  
  693.         if (!m_targetWindow->GetBackingPixmap() &&
  694.            (m_xScrollLines != 0) && (m_yScrollLines != 0))
  695.         {
  696.             int depth = wxDisplayDepth();
  697.             m_targetWindow->SetPixmapWidth(totalPixelWidth);
  698.             m_targetWindow->SetPixmapHeight(totalPixelHeight);
  699.             m_targetWindow->SetBackingPixmap((WXPixmap) XCreatePixmap (dpy, RootWindow (dpy, DefaultScreen (dpy)),
  700.               m_targetWindow->GetPixmapWidth(), m_targetWindow->GetPixmapHeight(), depth));
  701.         }
  702.  
  703.     }
  704. #endif // Motif
  705.  
  706.     if (oldXScroll != m_xScrollPosition)
  707.     {
  708.        if (m_xScrollingEnabled)
  709.             m_targetWindow->ScrollWindow( m_xScrollPixelsPerLine * (oldXScroll - m_xScrollPosition), 0,
  710.                                           GetRect() );
  711.        else
  712.             m_targetWindow->Refresh(TRUE, GetRect());
  713.     }
  714.  
  715.     if (oldYScroll != m_yScrollPosition)
  716.     {
  717.         if (m_yScrollingEnabled)
  718.             m_targetWindow->ScrollWindow( 0, m_yScrollPixelsPerLine * (oldYScroll-m_yScrollPosition),
  719.                                           GetRect() );
  720.         else
  721.             m_targetWindow->Refresh(TRUE, GetRect());
  722.     }
  723.  
  724. #ifdef __WXMAC__
  725.     m_targetWindow->MacUpdateImmediately();
  726. #endif
  727. }
  728.  
  729. void wxScrollHelper::DoPrepareDC(wxDC& dc)
  730. {
  731.     wxPoint pt = dc.GetDeviceOrigin();
  732.     dc.SetDeviceOrigin( pt.x - m_xScrollPosition * m_xScrollPixelsPerLine,
  733.                         pt.y - m_yScrollPosition * m_yScrollPixelsPerLine );
  734.     dc.SetUserScale( m_scaleX, m_scaleY );
  735. }
  736.  
  737. void wxScrollHelper::SetScrollRate( int xstep, int ystep )
  738. {
  739.     int old_x = m_xScrollPixelsPerLine * m_xScrollPosition;
  740.     int old_y = m_yScrollPixelsPerLine * m_yScrollPosition;
  741.  
  742.     m_xScrollPixelsPerLine = xstep;
  743.     m_yScrollPixelsPerLine = ystep;
  744.  
  745.     int new_x = m_xScrollPixelsPerLine * m_xScrollPosition;
  746.     int new_y = m_yScrollPixelsPerLine * m_yScrollPosition;
  747.  
  748.     m_win->SetScrollPos( wxHORIZONTAL, m_xScrollPosition );
  749.     m_win->SetScrollPos( wxVERTICAL, m_yScrollPosition );
  750.     m_targetWindow->ScrollWindow( old_x - new_x, old_y - new_y );
  751.  
  752.     AdjustScrollbars();
  753. }
  754.  
  755. void wxScrollHelper::GetScrollPixelsPerUnit (int *x_unit, int *y_unit) const
  756. {
  757.     if ( x_unit )
  758.         *x_unit = m_xScrollPixelsPerLine;
  759.     if ( y_unit )
  760.         *y_unit = m_yScrollPixelsPerLine;
  761. }
  762.  
  763. int wxScrollHelper::GetScrollPageSize(int orient) const
  764. {
  765.     if ( orient == wxHORIZONTAL )
  766.         return m_xScrollLinesPerPage;
  767.     else
  768.         return m_yScrollLinesPerPage;
  769. }
  770.  
  771. void wxScrollHelper::SetScrollPageSize(int orient, int pageSize)
  772. {
  773.     if ( orient == wxHORIZONTAL )
  774.         m_xScrollLinesPerPage = pageSize;
  775.     else
  776.         m_yScrollLinesPerPage = pageSize;
  777. }
  778.  
  779. /*
  780.  * Scroll to given position (scroll position, not pixel position)
  781.  */
  782. void wxScrollHelper::Scroll( int x_pos, int y_pos )
  783. {
  784.     if (!m_targetWindow)
  785.         return;
  786.  
  787.     if (((x_pos == -1) || (x_pos == m_xScrollPosition)) &&
  788.         ((y_pos == -1) || (y_pos == m_yScrollPosition))) return;
  789.  
  790. #ifdef __WXMAC__
  791.     m_targetWindow->MacUpdateImmediately();
  792. #endif
  793.  
  794.     int w, h;
  795.     GetTargetSize(&w, &h);
  796.  
  797.     if ((x_pos != -1) && (m_xScrollPixelsPerLine))
  798.     {
  799.         int old_x = m_xScrollPosition;
  800.         m_xScrollPosition = x_pos;
  801.  
  802.         // Calculate page size i.e. number of scroll units you get on the
  803.         // current client window
  804.         int noPagePositions = (int) ( (w/(double)m_xScrollPixelsPerLine) + 0.5 );
  805.         if (noPagePositions < 1) noPagePositions = 1;
  806.  
  807.         // Correct position if greater than extent of canvas minus
  808.         // the visible portion of it or if below zero
  809.         m_xScrollPosition = wxMin( m_xScrollLines-noPagePositions, m_xScrollPosition );
  810.         m_xScrollPosition = wxMax( 0, m_xScrollPosition );
  811.  
  812.         if (old_x != m_xScrollPosition) {
  813.             m_win->SetScrollPos( wxHORIZONTAL, m_xScrollPosition );
  814.             m_targetWindow->ScrollWindow( (old_x-m_xScrollPosition)*m_xScrollPixelsPerLine, 0,
  815.                                           GetRect() );
  816.         }
  817.     }
  818.     if ((y_pos != -1) && (m_yScrollPixelsPerLine))
  819.     {
  820.         int old_y = m_yScrollPosition;
  821.         m_yScrollPosition = y_pos;
  822.  
  823.         // Calculate page size i.e. number of scroll units you get on the
  824.         // current client window
  825.         int noPagePositions = (int) ( (h/(double)m_yScrollPixelsPerLine) + 0.5 );
  826.         if (noPagePositions < 1) noPagePositions = 1;
  827.  
  828.         // Correct position if greater than extent of canvas minus
  829.         // the visible portion of it or if below zero
  830.         m_yScrollPosition = wxMin( m_yScrollLines-noPagePositions, m_yScrollPosition );
  831.         m_yScrollPosition = wxMax( 0, m_yScrollPosition );
  832.  
  833.         if (old_y != m_yScrollPosition) {
  834.             m_win->SetScrollPos( wxVERTICAL, m_yScrollPosition );
  835.             m_targetWindow->ScrollWindow( 0, (old_y-m_yScrollPosition)*m_yScrollPixelsPerLine,
  836.                                           GetRect() );
  837.         }
  838.     }
  839.  
  840. #ifdef __WXMAC__
  841.     m_targetWindow->MacUpdateImmediately();
  842. #endif
  843.  
  844. }
  845.  
  846. void wxScrollHelper::EnableScrolling (bool x_scroll, bool y_scroll)
  847. {
  848.     m_xScrollingEnabled = x_scroll;
  849.     m_yScrollingEnabled = y_scroll;
  850. }
  851.  
  852. // Where the current view starts from
  853. void wxScrollHelper::GetViewStart (int *x, int *y) const
  854. {
  855.     if ( x )
  856.         *x = m_xScrollPosition;
  857.     if ( y )
  858.         *y = m_yScrollPosition;
  859. }
  860.  
  861. void wxScrollHelper::DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const
  862. {
  863.     if ( xx )
  864.         *xx = x - m_xScrollPosition * m_xScrollPixelsPerLine;
  865.     if ( yy )
  866.         *yy = y - m_yScrollPosition * m_yScrollPixelsPerLine;
  867. }
  868.  
  869. void wxScrollHelper::DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const
  870. {
  871.     if ( xx )
  872.         *xx = x + m_xScrollPosition * m_xScrollPixelsPerLine;
  873.     if ( yy )
  874.         *yy = y + m_yScrollPosition * m_yScrollPixelsPerLine;
  875. }
  876.  
  877. // ----------------------------------------------------------------------------
  878. // event handlers
  879. // ----------------------------------------------------------------------------
  880.  
  881. // Default OnSize resets scrollbars, if any
  882. void wxScrollHelper::HandleOnSize(wxSizeEvent& WXUNUSED(event))
  883. {
  884.     if( m_win->GetAutoLayout() )
  885.     {
  886.         if ( m_targetWindow != m_win )
  887.             m_targetWindow->FitInside();
  888.  
  889.         m_win->FitInside();
  890.  
  891. #if wxUSE_CONSTRAINTS
  892.         m_win->Layout();
  893. #endif
  894.     }
  895.     else
  896.         AdjustScrollbars();
  897. }
  898.  
  899. // This calls OnDraw, having adjusted the origin according to the current
  900. // scroll position
  901. void wxScrollHelper::HandleOnPaint(wxPaintEvent& WXUNUSED(event))
  902. {
  903.     // don't use m_targetWindow here, this is always called for ourselves
  904.     wxPaintDC dc(m_win);
  905.     DoPrepareDC(dc);
  906.  
  907.     OnDraw(dc);
  908. }
  909.  
  910. // kbd handling: notice that we use OnChar() and not OnKeyDown() for
  911. // compatibility here - if we used OnKeyDown(), the programs which process
  912. // arrows themselves in their OnChar() would never get the message and like
  913. // this they always have the priority
  914. void wxScrollHelper::HandleOnChar(wxKeyEvent& event)
  915. {
  916.     int stx, sty,       // view origin
  917.         szx, szy,       // view size (total)
  918.         clix, cliy;     // view size (on screen)
  919.  
  920.     GetViewStart(&stx, &sty);
  921.     GetTargetSize(&clix, &cliy);
  922.     m_targetWindow->GetVirtualSize(&szx, &szy);
  923.  
  924.     if( m_xScrollPixelsPerLine )
  925.     {
  926.         clix /= m_xScrollPixelsPerLine;
  927.         szx /= m_xScrollPixelsPerLine;
  928.     }
  929.     else
  930.     {
  931.         clix = 0;
  932.         szx = -1;
  933.     }
  934.     if( m_yScrollPixelsPerLine )
  935.     {
  936.         cliy /= m_yScrollPixelsPerLine;
  937.         szy /= m_yScrollPixelsPerLine;
  938.     }
  939.     else
  940.     {
  941.         cliy = 0;
  942.         szy = -1;
  943.     }
  944.  
  945.     int xScrollOld = m_xScrollPosition,
  946.         yScrollOld = m_yScrollPosition;
  947.  
  948.     int dsty;
  949.     switch ( event.KeyCode() )
  950.     {
  951.         case WXK_PAGEUP:
  952.         case WXK_PRIOR:
  953.             dsty = sty - (5 * cliy / 6);
  954.             Scroll(-1, (dsty == -1) ? 0 : dsty);
  955.             break;
  956.  
  957.         case WXK_PAGEDOWN:
  958.         case WXK_NEXT:
  959.             Scroll(-1, sty + (5 * cliy / 6));
  960.             break;
  961.  
  962.         case WXK_HOME:
  963.             Scroll(0, event.ControlDown() ? 0 : -1);
  964.             break;
  965.  
  966.         case WXK_END:
  967.             Scroll(szx - clix, event.ControlDown() ? szy - cliy : -1);
  968.             break;
  969.  
  970.         case WXK_UP:
  971.             Scroll(-1, sty - 1);
  972.             break;
  973.  
  974.         case WXK_DOWN:
  975.             Scroll(-1, sty + 1);
  976.             break;
  977.  
  978.         case WXK_LEFT:
  979.             Scroll(stx - 1, -1);
  980.             break;
  981.  
  982.         case WXK_RIGHT:
  983.             Scroll(stx + 1, -1);
  984.             break;
  985.  
  986.         default:
  987.             // not for us
  988.             event.Skip();
  989.     }
  990.  
  991.     if ( m_xScrollPosition != xScrollOld )
  992.     {
  993.         wxScrollWinEvent event(wxEVT_SCROLLWIN_THUMBTRACK, m_xScrollPosition,
  994.                                wxHORIZONTAL);
  995.         event.SetEventObject(m_win);
  996.         m_win->GetEventHandler()->ProcessEvent(event);
  997.     }
  998.  
  999.     if ( m_yScrollPosition != yScrollOld )
  1000.     {
  1001.         wxScrollWinEvent event(wxEVT_SCROLLWIN_THUMBTRACK, m_yScrollPosition,
  1002.                                wxVERTICAL);
  1003.         event.SetEventObject(m_win);
  1004.         m_win->GetEventHandler()->ProcessEvent(event);
  1005.     }
  1006. }
  1007.  
  1008. // ----------------------------------------------------------------------------
  1009. // autoscroll stuff: these functions deal with sending fake scroll events when
  1010. // a captured mouse is being held outside the window
  1011. // ----------------------------------------------------------------------------
  1012.  
  1013. bool wxScrollHelper::SendAutoScrollEvents(wxScrollWinEvent& event) const
  1014. {
  1015.     // only send the event if the window is scrollable in this direction
  1016.     wxWindow *win = (wxWindow *)event.GetEventObject();
  1017.     return win->HasScrollbar(event.GetOrientation());
  1018. }
  1019.  
  1020. void wxScrollHelper::StopAutoScrolling()
  1021. {
  1022.     if ( m_timerAutoScroll )
  1023.     {
  1024.         delete m_timerAutoScroll;
  1025.         m_timerAutoScroll = (wxTimer *)NULL;
  1026.     }
  1027. }
  1028.  
  1029. void wxScrollHelper::HandleOnMouseEnter(wxMouseEvent& event)
  1030. {
  1031.     StopAutoScrolling();
  1032.  
  1033.     event.Skip();
  1034. }
  1035.  
  1036. void wxScrollHelper::HandleOnMouseLeave(wxMouseEvent& event)
  1037. {
  1038.     // don't prevent the usual processing of the event from taking place
  1039.     event.Skip();
  1040.  
  1041.     // when a captured mouse leave a scrolled window we start generate
  1042.     // scrolling events to allow, for example, extending selection beyond the
  1043.     // visible area in some controls
  1044.     if ( wxWindow::GetCapture() == m_targetWindow )
  1045.     {
  1046.         // where is the mouse leaving?
  1047.         int pos, orient;
  1048.         wxPoint pt = event.GetPosition();
  1049.         if ( pt.x < 0 )
  1050.         {
  1051.             orient = wxHORIZONTAL;
  1052.             pos = 0;
  1053.         }
  1054.         else if ( pt.y < 0 )
  1055.         {
  1056.             orient = wxVERTICAL;
  1057.             pos = 0;
  1058.         }
  1059.         else // we're lower or to the right of the window
  1060.         {
  1061.             wxSize size = m_targetWindow->GetClientSize();
  1062.             if ( pt.x > size.x )
  1063.             {
  1064.                 orient = wxHORIZONTAL;
  1065.                 pos = m_xScrollLines;
  1066.             }
  1067.             else if ( pt.y > size.y )
  1068.             {
  1069.                 orient = wxVERTICAL;
  1070.                 pos = m_yScrollLines;
  1071.             }
  1072.             else // this should be impossible
  1073.             {
  1074.                 // but seems to happen sometimes under wxMSW - maybe it's a bug
  1075.                 // there but for now just ignore it
  1076.  
  1077.                 //wxFAIL_MSG( _T("can't understand where has mouse gone") );
  1078.  
  1079.                 return;
  1080.             }
  1081.         }
  1082.  
  1083.         // only start the auto scroll timer if the window can be scrolled in
  1084.         // this direction
  1085.         if ( !m_targetWindow->HasScrollbar(orient) )
  1086.             return;
  1087.  
  1088.         delete m_timerAutoScroll;
  1089.         m_timerAutoScroll = new wxAutoScrollTimer
  1090.                                 (
  1091.                                     m_targetWindow, this,
  1092.                                     pos == 0 ? wxEVT_SCROLLWIN_LINEUP
  1093.                                              : wxEVT_SCROLLWIN_LINEDOWN,
  1094.                                     pos,
  1095.                                     orient
  1096.                                 );
  1097.         m_timerAutoScroll->Start(50); // FIXME: make configurable
  1098.     }
  1099. }
  1100.  
  1101. #if wxUSE_MOUSEWHEEL
  1102.  
  1103. void wxScrollHelper::HandleOnMouseWheel(wxMouseEvent& event)
  1104. {
  1105.     m_wheelRotation += event.GetWheelRotation();
  1106.     int lines = m_wheelRotation / event.GetWheelDelta();
  1107.     m_wheelRotation -= lines * event.GetWheelDelta();
  1108.  
  1109.     if (lines != 0)
  1110.     {
  1111.  
  1112.         wxScrollWinEvent newEvent;
  1113.  
  1114.         newEvent.SetPosition(0);
  1115.         newEvent.SetOrientation(wxVERTICAL);
  1116.         newEvent.m_eventObject = m_win;
  1117.  
  1118.         if (event.IsPageScroll())
  1119.         {
  1120.             if (lines > 0)
  1121.                 newEvent.m_eventType = wxEVT_SCROLLWIN_PAGEUP;
  1122.             else
  1123.                 newEvent.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN;
  1124.  
  1125.             m_win->GetEventHandler()->ProcessEvent(newEvent);
  1126.         }
  1127.         else
  1128.         {
  1129.             lines *= event.GetLinesPerAction();
  1130.             if (lines > 0)
  1131.                 newEvent.m_eventType = wxEVT_SCROLLWIN_LINEUP;
  1132.             else
  1133.                 newEvent.m_eventType = wxEVT_SCROLLWIN_LINEDOWN;
  1134.  
  1135.             int times = abs(lines);
  1136.             for (; times > 0; times--)
  1137.                 m_win->GetEventHandler()->ProcessEvent(newEvent);
  1138.         }
  1139.     }
  1140. }
  1141.  
  1142. #endif // wxUSE_MOUSEWHEEL
  1143.  
  1144. // ----------------------------------------------------------------------------
  1145. // wxGenericScrolledWindow implementation
  1146. // ----------------------------------------------------------------------------
  1147.  
  1148. IMPLEMENT_DYNAMIC_CLASS(wxGenericScrolledWindow, wxPanel)
  1149.  
  1150. BEGIN_EVENT_TABLE(wxGenericScrolledWindow, wxPanel)
  1151.     EVT_PAINT(wxGenericScrolledWindow::OnPaint)
  1152. END_EVENT_TABLE()
  1153.  
  1154. bool wxGenericScrolledWindow::Create(wxWindow *parent,
  1155.                               wxWindowID id,
  1156.                               const wxPoint& pos,
  1157.                               const wxSize& size,
  1158.                               long style,
  1159.                               const wxString& name)
  1160. {
  1161.     m_targetWindow = this;
  1162.  
  1163.     bool ok = wxPanel::Create(parent, id, pos, size, style, name);
  1164.  
  1165.     return ok;
  1166. }
  1167.  
  1168. wxGenericScrolledWindow::~wxGenericScrolledWindow()
  1169. {
  1170. }
  1171.  
  1172. bool wxGenericScrolledWindow::Layout()
  1173. {
  1174.     if (GetSizer() && m_targetWindow == this)
  1175.     {
  1176.         // If we're the scroll target, take into account the
  1177.         // virtual size and scrolled position of the window.
  1178.  
  1179.         int x, y, w, h;
  1180.         CalcScrolledPosition(0,0, &x,&y);
  1181.         GetVirtualSize(&w, &h);
  1182.         GetSizer()->SetDimension(x, y, w, h);
  1183.         return TRUE;
  1184.     }
  1185.  
  1186.     // fall back to default for LayoutConstraints
  1187.     return wxPanel::Layout();
  1188. }
  1189.  
  1190. void wxGenericScrolledWindow::DoSetVirtualSize(int x, int y)
  1191. {
  1192.     wxPanel::DoSetVirtualSize( x, y );
  1193.     AdjustScrollbars();
  1194.  
  1195. #if wxUSE_CONSTRAINTS
  1196.     if (GetAutoLayout())
  1197.         Layout();
  1198. #endif
  1199. }
  1200.  
  1201. void wxGenericScrolledWindow::OnPaint(wxPaintEvent& event)
  1202. {
  1203.     // the user code didn't really draw the window if we got here, so set this
  1204.     // flag to try to call OnDraw() later
  1205.     m_handler->ResetDrawnFlag();
  1206.  
  1207.     event.Skip();
  1208. }
  1209.  
  1210. #ifdef __WXMSW__
  1211. long
  1212. wxGenericScrolledWindow::MSWWindowProc(WXUINT nMsg,
  1213.                                        WXWPARAM wParam,
  1214.                                        WXLPARAM lParam)
  1215. {
  1216.     long rc = wxPanel::MSWWindowProc(nMsg, wParam, lParam);
  1217.  
  1218.     // we need to process arrows ourselves for scrolling
  1219.     if ( nMsg == WM_GETDLGCODE )
  1220.     {
  1221.         rc |= DLGC_WANTARROWS;
  1222.     }
  1223.  
  1224.     return rc;
  1225. }
  1226.  
  1227. #endif // __WXMSW__
  1228.  
  1229. #if WXWIN_COMPATIBILITY
  1230.  
  1231. void wxGenericScrolledWindow::GetScrollUnitsPerPage (int *x_page, int *y_page) const
  1232. {
  1233.       *x_page = GetScrollPageSize(wxHORIZONTAL);
  1234.       *y_page = GetScrollPageSize(wxVERTICAL);
  1235. }
  1236.  
  1237. void wxGenericScrolledWindow::CalcUnscrolledPosition(int x, int y, float *xx, float *yy) const
  1238. {
  1239.     if ( xx )
  1240.         *xx = (float)(x + m_xScrollPosition * m_xScrollPixelsPerLine);
  1241.     if ( yy )
  1242.         *yy = (float)(y + m_yScrollPosition * m_yScrollPixelsPerLine);
  1243. }
  1244.  
  1245. #endif // WXWIN_COMPATIBILITY
  1246.  
  1247. #endif // !wxGTK
  1248.  
  1249. // vi:sts=4:sw=4:et
  1250.