// Modified by:
// Created: 30.05.03
// RCS-ID: $Id$
-// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
+// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_VSCROLL_H_
#define _WX_VSCROLL_H_
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
+#pragma interface "vscroll.h"
+#endif
+
#include "wx/panel.h" // base class
// ----------------------------------------------------------------------------
// just as with the ctor above, wxVSCROLL style is always used, there is no
// need to specify it
bool Create(wxWindow *parent,
- wxWindowID id,
+ wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
virtual bool ScrollLines(int lines);
virtual bool ScrollPages(int pages);
+ // redraw the specified line
+ virtual void RefreshLine(size_t line);
+
+ // redraw all lines in the specified range (inclusive)
+ virtual void RefreshLines(size_t from, size_t to);
+
+ // return the item at the specified (in physical coordinates) position or.
+
+ // wxNOT_FOUND if none, i.e. if it is below the last item
+ int HitTest(wxCoord x, wxCoord y) const;
+ int HitTest(const wxPoint& pt) const { return HitTest(pt.x, pt.y); }
+
+ // recalculate all our parameters and redisplay all lines
+ virtual void RefreshAll();
+
// accessors
// ---------
size_t GetLineCount() const { return m_lineMax; }
// get the first currently visible line
+ size_t GetVisibleBegin() const { return m_lineFirst; }
+
+ // get the first currently visible line
+ size_t GetVisibleEnd() const { return m_lineFirst + m_nVisible; }
+
+ // is this line currently visible?
+ bool IsVisible(size_t line) const
+ { return line >= GetVisibleBegin() && line < GetVisibleEnd(); }
+
+
+ // this is the same as GetVisibleBegin(), exists to match
+ // GetLastVisibleLine() and for backwards compatibility only
size_t GetFirstVisibleLine() const { return m_lineFirst; }
// get the last currently visible line
- size_t GetLastVisibleLine() const { return m_lineFirst + m_nVisible - 1; }
+ //
+ // this function is unsafe as it returns (size_t)-1 (i.e. a huge positive
+ // number) if the control is empty, use GetVisibleEnd() instead, this one
+ // is kept for backwards compatibility
+ size_t GetLastVisibleLine() const { return GetVisibleEnd() - 1; }
-//protected:
+protected:
// this function must be overridden in the derived class and it should
// return the height of the given line in pixels
virtual wxCoord OnGetLineHeight(size_t n) const = 0;
//
// finally note that lineMin is inclusive, while lineMax is exclusive, as
// usual
- virtual void OnGetLinesHint(size_t lineMin, size_t lineMax) const { }
+ virtual void OnGetLinesHint(size_t WXUNUSED(lineMin),
+ size_t WXUNUSED(lineMax)) const { }
+
+ // when the number of lines changes, we try to estimate the total height
+ // of all lines which is a rather expensive operation in terms of lines
+ // access, so if the user code may estimate the average height
+ // better/faster than we do, it should override this function to implement
+ // its own logic
+ //
+ // this function should return the best guess for the total height it may
+ // make
+ virtual wxCoord EstimateTotalHeight() const;
+
-protected:
// the event handlers
void OnSize(wxSizeEvent& event);
void OnScroll(wxScrollWinEvent& event);
+#if wxUSE_MOUSEWHEEL
+ void OnMouseWheel(wxMouseEvent& event);
+#endif
// find the index of the line we need to show at the top of the window such
- // that the last line shown is the given one
- size_t FindFirstFromBottom(size_t lineLast);
+ // that the last (fully or partially) visible line is the given one
+ size_t FindFirstFromBottom(size_t lineLast, bool fullyVisible = false);
// get the total height of the lines between lineMin (inclusive) and
// lineMax (exclusive)
// partly, visible one)
size_t m_nVisible;
+ // accumulated mouse wheel rotation
+#if wxUSE_MOUSEWHEEL
+ int m_sumWheelRotation;
+#endif
DECLARE_EVENT_TABLE()
+ DECLARE_NO_COPY_CLASS(wxVScrolledWindow)
+ DECLARE_ABSTRACT_CLASS(wxVScrolledWindow)
};
#endif // _WX_VSCROLL_H_